https://github.com/evelez7 created https://github.com/llvm/llvm-project/pull/171698
None >From 602d10e27803fdd140bd52632be2847e3b5fdb79 Mon Sep 17 00:00:00 2001 From: Erick Velez <[email protected]> Date: Thu, 13 Nov 2025 20:23:17 -0800 Subject: [PATCH] [clang-doc] Serialize "IsStatic" for fields --- clang-tools-extra/clang-doc/JSONGenerator.cpp | 1 + clang-tools-extra/clang-doc/assets/class-template.mustache | 4 ++-- clang-tools-extra/test/clang-doc/basic-project.mustache.test | 2 +- clang-tools-extra/test/clang-doc/json/class.cpp | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp b/clang-tools-extra/clang-doc/JSONGenerator.cpp index 77aa8794561e4..0253ebf5335da 100644 --- a/clang-tools-extra/clang-doc/JSONGenerator.cpp +++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp @@ -551,6 +551,7 @@ static void serializeInfo(const RecordInfo &I, json::Object &Obj, auto &MemberObj = *MemberVal.getAsObject(); MemberObj["Name"] = Member.Name; MemberObj["Type"] = Member.Type.Name; + MemberObj["IsStatic"] = Member.IsStatic; if (Member.Access == AccessSpecifier::AS_public) PubMembersArrayRef.push_back(MemberVal); diff --git a/clang-tools-extra/clang-doc/assets/class-template.mustache b/clang-tools-extra/clang-doc/assets/class-template.mustache index 1197e76ab553c..22cd5f06894a4 100644 --- a/clang-tools-extra/clang-doc/assets/class-template.mustache +++ b/clang-tools-extra/clang-doc/assets/class-template.mustache @@ -154,7 +154,7 @@ <div> {{#PublicMembers}} <div id="{{Name}}" class="delimiter-container"> - <pre><code class="language-cpp code-clang-doc" >{{Type}} {{Name}}</code></pre> + <pre><code class="language-cpp code-clang-doc" >{{#IsStatic}}static {{/IsStatic}}{{Type}} {{Name}}</code></pre> {{#MemberComments}} <div> {{>Comments}} @@ -171,7 +171,7 @@ <div> {{#Obj}} <div id="{{Name}}" class="delimiter-container"> - <pre><code class="language-cpp code-clang-doc" >{{Type}} {{Name}}</code></pre> + <pre><code class="language-cpp code-clang-doc" >{{#IsStatic}}static {{/IsStatic}}{{Type}} {{Name}}</code></pre> {{#MemberComments}} <div> {{>Comments}} diff --git a/clang-tools-extra/test/clang-doc/basic-project.mustache.test b/clang-tools-extra/test/clang-doc/basic-project.mustache.test index b985a39265de7..d406c9f297960 100644 --- a/clang-tools-extra/test/clang-doc/basic-project.mustache.test +++ b/clang-tools-extra/test/clang-doc/basic-project.mustache.test @@ -204,7 +204,7 @@ HTML-CALC: <div id="public_val" class="delimiter-container"> HTML-CALC: <pre><code class="language-cpp code-clang-doc" >int public_val</code></pre> HTML-CALC: </div> HTML-CALC: <div id="static_val" class="delimiter-container"> -HTML-CALC: <pre><code class="language-cpp code-clang-doc" >const int static_val</code></pre> +HTML-CALC: <pre><code class="language-cpp code-clang-doc" >static const int static_val</code></pre> HTML-CALC: </div> HTML-CALC: </div> HTML-CALC: </section> diff --git a/clang-tools-extra/test/clang-doc/json/class.cpp b/clang-tools-extra/test/clang-doc/json/class.cpp index 8bf9402adf054..9d3102a11db9d 100644 --- a/clang-tools-extra/test/clang-doc/json/class.cpp +++ b/clang-tools-extra/test/clang-doc/json/class.cpp @@ -158,6 +158,7 @@ struct MyClass { // CHECK-NEXT: ], // CHECK-NEXT: "ProtectedMembers": [ // CHECK-NEXT: { +// CHECK-NEXT: "IsStatic": false, // CHECK-NEXT: "Name": "ProtectedField", // CHECK-NEXT: "Type": "int" // CHECK-NEXT: } @@ -198,6 +199,7 @@ struct MyClass { // CHECK-NEXT: }, // CHECK: "PublicMembers": [ // CHECK-NEXT: { +// CHECK-NEXT: "IsStatic": false, // CHECK-NEXT: "Name": "PublicField", // CHECK-NEXT: "Type": "int" // CHECK-NEXT: } _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
