Author: Erick Velez Date: 2026-03-20T16:09:34-07:00 New Revision: 51c158b5d29bf7b16651344b402354f5d2339519
URL: https://github.com/llvm/llvm-project/commit/51c158b5d29bf7b16651344b402354f5d2339519 DIFF: https://github.com/llvm/llvm-project/commit/51c158b5d29bf7b16651344b402354f5d2339519.diff LOG: [clang-doc] Fix incorrectly rendered specialization args in HTML (#187761) Function template specialization arguments were incorrectly rendered without a comma. This was due to the "End" JSON property also being used in the levels above. Mustache looks for missing properties in parent contexts, see #174359. Added: Modified: clang-tools-extra/clang-doc/JSONGenerator.cpp clang-tools-extra/clang-doc/assets/function-template.mustache clang-tools-extra/test/clang-doc/json/class-specialization.cpp clang-tools-extra/test/clang-doc/templates.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp b/clang-tools-extra/clang-doc/JSONGenerator.cpp index e768d25e38971..a9223cb9c3e8a 100644 --- a/clang-tools-extra/clang-doc/JSONGenerator.cpp +++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp @@ -527,7 +527,7 @@ void JSONGenerator::serializeInfo(const TemplateInfo &Template, Object &Obj) { bool VerticalDisplay = Template.Specialization->Params.size() > getMaxParamWrapLimit(); serializeArray(Template.Specialization->Params, TemplateSpecializationObj, - "Parameters", SerializeTemplateParam, "End", + "Parameters", SerializeTemplateParam, "SpecParamEnd", [VerticalDisplay](Object &JsonObj) { JsonObj["VerticalDisplay"] = VerticalDisplay; }); diff --git a/clang-tools-extra/clang-doc/assets/function-template.mustache b/clang-tools-extra/clang-doc/assets/function-template.mustache index dc833cc70d635..10b9ca947b8ba 100644 --- a/clang-tools-extra/clang-doc/assets/function-template.mustache +++ b/clang-tools-extra/clang-doc/assets/function-template.mustache @@ -10,7 +10,7 @@ <pre><code class="language-cpp code-clang-doc">template <{{^VerticalDisplay}}{{#Parameters}}{{Param}}{{^End}}, {{/End}}{{/Parameters}}{{/VerticalDisplay}}</code>{{#VerticalDisplay}}<span class="param-container">{{#Parameters}}<span class="param"><code class="language-cpp code-clang-doc">{{Param}}{{^End}}, {{/End}}</code></span>{{/Parameters}}</span>{{/VerticalDisplay}}<code class="language-cpp code-clang-doc">></code></pre> {{/Template}} {{! Function Prototype }} - <pre><code class="language-cpp code-clang-doc">{{ReturnType.QualName}} {{Name}}{{#Template}}{{#Specialization}}<{{#Parameters}}{{Param}}{{^End}}, {{/End}}{{/Parameters}}>{{/Specialization}}{{/Template}} ({{^VerticalDisplay}}{{#Params}}{{Type.QualName}} {{Name}}{{^ParamEnd}}, {{/ParamEnd}}{{/Params}}){{/VerticalDisplay}}</code>{{#VerticalDisplay}}<span class="param-container">{{#Params}}<span class="param"><code class="language-cpp code-clang-doc">{{Type.QualName}}</code> <code class="language-cpp code-clang-doc">{{Name}}{{^ParamEnd}}, {{/ParamEnd}}</code></span>{{/Params}}</span><code class="language-cpp code-clang-doc">)</code>{{/VerticalDisplay}}</pre> + <pre><code class="language-cpp code-clang-doc">{{ReturnType.QualName}} {{Name}}{{#Template}}{{#Specialization}}<{{#Parameters}}{{Param}}{{^SpecParamEnd}}, {{/SpecParamEnd}}{{/Parameters}}>{{/Specialization}}{{/Template}} ({{^VerticalDisplay}}{{#Params}}{{Type.QualName}} {{Name}}{{^ParamEnd}}, {{/ParamEnd}}{{/Params}}){{/VerticalDisplay}}</code>{{#VerticalDisplay}}<span class="param-container">{{#Params}}<span class="param"><code class="language-cpp code-clang-doc">{{Type.QualName}}</code> <code class="language-cpp code-clang-doc">{{Name}}{{^ParamEnd}}, {{/ParamEnd}}</code></span>{{/Params}}</span><code class="language-cpp code-clang-doc">)</code>{{/VerticalDisplay}}</pre> {{! Function Comments }} {{#Description}} <div class="doc-card"> diff --git a/clang-tools-extra/test/clang-doc/json/class-specialization.cpp b/clang-tools-extra/test/clang-doc/json/class-specialization.cpp index 3c7785a849949..344ec08e9a21f 100644 --- a/clang-tools-extra/test/clang-doc/json/class-specialization.cpp +++ b/clang-tools-extra/test/clang-doc/json/class-specialization.cpp @@ -35,8 +35,8 @@ template<> struct MyClass<int> {}; // SPECIALIZATION-NEXT: "Specialization": { // SPECIALIZATION-NEXT: "Parameters": [ // SPECIALIZATION-NEXT: { -// SPECIALIZATION-NEXT: "End": true, -// SPECIALIZATION-NEXT: "Param": "int" +// SPECIALIZATION-NEXT: "Param": "int", +// SPECIALIZATION-NEXT: "SpecParamEnd": true // SPECIALIZATION-NEXT: } // SPECIALIZATION-NEXT: ], // SPECIALIZATION-NEXT: "SpecializationOf": "{{[0-9A-F]*}}", diff --git a/clang-tools-extra/test/clang-doc/templates.cpp b/clang-tools-extra/test/clang-doc/templates.cpp index 86af599472894..2bd8ebd5b9fbe 100644 --- a/clang-tools-extra/test/clang-doc/templates.cpp +++ b/clang-tools-extra/test/clang-doc/templates.cpp @@ -357,8 +357,8 @@ void function<bool, 0>(bool x) {} // JSON-NEXT: "Param": "bool" // JSON-NEXT: }, // JSON-NEXT: { -// JSON-NEXT: "End": true, -// JSON-NEXT: "Param": "0" +// JSON-NEXT: "Param": "0", +// JSON-NEXT: "SpecParamEnd": true // JSON-NEXT: } // JSON-NEXT: ], // JSON-NEXT: "SpecializationOf": "{{([0-9A-F]{40})}}", _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
