[clang-tools-extra] [clang-doc] Do not serialize empty text comments (PR #169087)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 1 10:39:45 PST 2025
================
@@ -84,8 +84,24 @@ serializeLocation(const Location &Loc,
return LocationObj;
}
+/// Insert comments into a key in the Description object.
+///
+/// \param Comment Either an Object or Array, depending on the comment type
+/// \param Key The type (Brief, Code, etc.) of comment to be inserted
static void insertComment(Object &Description, json::Value &Comment,
StringRef Key) {
+ // The comment has a Children array for the actual text, with meta attributes
+ // alongside it in the Object.
+ if (auto *Obj = Comment.getAsObject()) {
+ if (auto *Children = Obj->getArray("Children");
+ !Children || Children->empty())
+ return;
+ }
----------------
ilovepi wrote:
I see a few checks along these lines ... do you think a helper function would be useful? It may be easier to reason about. At the very least the check for the Array existing and being non-empty seems useful for working w/ comment objects.
https://github.com/llvm/llvm-project/pull/169087
More information about the cfe-commits
mailing list