[llvm-branch-commits] [clang-tools-extra] [clang-doc] separate comments into categories (PR #149590)

Erick Velez via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jul 22 09:55:22 PDT 2025


================
@@ -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


More information about the llvm-branch-commits mailing list