[clang-tools-extra] [clang-doc] Do not serialize empty text comments (PR #169087)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 25 16:55:46 PST 2025
================
@@ -98,10 +114,29 @@ static void insertComment(Object &Description, json::Value &Comment,
}
}
+/// Takes the nested "Children" array from a comment Object.
+///
+/// \return a json::Array of comments, possible json::Value::Kind::Null
static json::Value extractTextComments(Object *ParagraphComment) {
if (!ParagraphComment)
- return json::Object();
- return *ParagraphComment->get("Children");
+ return json::Value(nullptr);
+ json::Value *Children = ParagraphComment->get("Children");
+ if (!Children)
+ return json::Value(nullptr);
+ auto ChildrenArray = *Children->getAsArray();
+ auto ChildrenIt = ChildrenArray.begin();
+ while (ChildrenIt != ChildrenArray.end()) {
+ auto *ChildObj = ChildrenIt->getAsObject();
+ if (!ChildObj)
+ break;
----------------
ilovepi wrote:
you just return on the first one that isn't an object?
https://github.com/llvm/llvm-project/pull/169087
More information about the cfe-commits
mailing list