[clang-tools-extra] Refactor clang doc comment structure (PR #142273)
Erick Velez via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 3 15:28:47 PDT 2025
================
@@ -198,37 +198,107 @@ static json::Value extractValue(const TypedefInfo &I) {
}
static json::Value extractValue(const CommentInfo &I) {
- assert((I.Kind == "BlockCommandComment" || I.Kind == "FullComment" ||
- I.Kind == "ParagraphComment" || I.Kind == "TextComment") &&
- "Unknown Comment type in CommentInfo.");
-
Object Obj = Object();
json::Value Child = Object();
- // TextComment has no children, so return it.
- if (I.Kind == "TextComment") {
- Obj.insert({"TextComment", I.Text});
+ json::Value ChildArr = Array();
+ auto &CARef = *ChildArr.getAsArray();
+ CARef.reserve(I.Children.size());
+ for (const auto &C : I.Children) {
+ CARef.emplace_back(extractValue(*C));
+ }
+
+ switch (I.Kind) {
+ case CommentKind::CK_TextComment: {
+ Obj.insert({commentKindToString(I.Kind), I.Text});
return Obj;
}
- // BlockCommandComment needs to generate a Command key.
- if (I.Kind == "BlockCommandComment")
+ case CommentKind::CK_BlockCommandComment: {
Child.getAsObject()->insert({"Command", I.Name});
----------------
evelez7 wrote:
Might be better to declare `Child` as an `Object` to avoid these gets, or use a reference. I believe all of this is still valid if `Child` is an `Object`.
https://github.com/llvm/llvm-project/pull/142273
More information about the cfe-commits
mailing list