================ @@ -83,7 +83,21 @@ serializeLocation(const Location &Loc, return LocationObj; } -static json::Value serializeComment(const CommentInfo &I) { +static void insertComment(Object &Description, json::Value &Comment, + std::string Key) { + auto *CommentArray = Description.getArray(Key); + if (!CommentArray) { + auto CommentsArray = json::Array(); + CommentsArray.push_back(Comment); + Description[Key] = std::move(CommentsArray); + Description["Has" + Key] = true; + } else { + CommentArray->push_back(Comment); + Description[Key] = std::move(*CommentArray); + } ---------------- evelez7 wrote:
Since the array that might exist at `Description[Key]` is returned as a pointer, allocating it via `new` means deleting it after the move, but then that's a bad free if the array existed. ASan doesn't like this approach but this could be better. https://github.com/llvm/llvm-project/pull/149590 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits