[clang-tools-extra] [clang-doc] Do not serialize empty text comments (PR #169087)
Erick Velez via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 28 15:49:11 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;
----------------
evelez7 wrote:
Since we're only expecting Objects, I thought it would be better to exit early since something must be wrong. But it's functionally the same to just continue in this loop. so I'll change it to continue.
https://github.com/llvm/llvm-project/pull/169087
More information about the cfe-commits
mailing list