https://github.com/evelez7 updated https://github.com/llvm/llvm-project/pull/171936
>From 3fa22eb125c56c4354d6007b2c7af86b44ab72f0 Mon Sep 17 00:00:00 2001 From: Erick Velez <[email protected]> Date: Thu, 11 Dec 2025 09:38:13 -0800 Subject: [PATCH] [clang-doc] Add JSON output to existing template tests clang-doc has some useful, preexisting tests for templates, so we'll reuse them to cover more cases. --- .../test/clang-doc/templates.cpp | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/clang-tools-extra/test/clang-doc/templates.cpp b/clang-tools-extra/test/clang-doc/templates.cpp index abe03a7d2d0ea..171ff496ab8ef 100644 --- a/clang-tools-extra/test/clang-doc/templates.cpp +++ b/clang-tools-extra/test/clang-doc/templates.cpp @@ -7,6 +7,9 @@ // RUN: clang-doc --doxygen --executor=standalone %s -output=%t/docs --format=md // RUN: cat %t/docs/GlobalNamespace/index.md | FileCheck %s --check-prefix=MD +// RUN: clang-doc --doxygen --executor=standalone %s -output=%t/docs --format=json +// RUN: cat %t/docs/json/GlobalNamespace/index.json | FileCheck %s --check-prefix=JSON + // YAML: --- // YAML-NEXT: USR: '{{([0-9A-F]{40})}}' // YAML-NEXT: ChildRecords: @@ -44,6 +47,27 @@ void ParamPackFunction(T... args); // MD: ### ParamPackFunction // MD: *void ParamPackFunction(T... args)* +// JSON: "Name": "ParamPackFunction", +// JSON-NEXT: "Params": [ +// JSON-NEXT: { +// JSON-NEXT: "End": true, +// JSON-NEXT: "Name": "args", +// JSON-NEXT: "Type": "T..." +// JSON-NEXT: } +// JSON-NEXT: ], +// JSON-NEXT: "ReturnType": { +// JSON-NEXT: "IsBuiltIn": true, +// JSON-NEXT: "IsTemplate": false, +// JSON-NEXT: "Name": "void", +// JSON-NEXT: "QualName": "void", +// JSON-NEXT: "USR": "0000000000000000000000000000000000000000" +// JSON-NEXT: }, +// JSON-NEXT: "Template": { +// JSON-NEXT: "Parameters": [ +// JSON-NEXT: "class... T" +// JSON-NEXT: ] +// JSON-NEXT: }, + template <typename T, int U = 1> void function(T x) {} @@ -70,6 +94,28 @@ void function(T x) {} // MD: *void function(T x)* // MD: *Defined at {{.*}}templates.cpp#[[# @LINE - 23]]* +// JSON: "Name": "function", +// JSON-NEXT: "Params": [ +// JSON-NEXT: { +// JSON-NEXT: "End": true, +// JSON-NEXT: "Name": "x", +// JSON-NEXT: "Type": "T" +// JSON-NEXT: } +// JSON-NEXT: ], +// JSON-NEXT: "ReturnType": { +// JSON-NEXT: "IsBuiltIn": true, +// JSON-NEXT: "IsTemplate": false, +// JSON-NEXT: "Name": "void", +// JSON-NEXT: "QualName": "void", +// JSON-NEXT: "USR": "0000000000000000000000000000000000000000" +// JSON-NEXT: }, +// JSON-NEXT: "Template": { +// JSON-NEXT: "Parameters": [ +// JSON-NEXT: "typename T", +// JSON-NEXT: "int U = 1" +// JSON-NEXT: ] +// JSON-NEXT: }, + template <> void function<bool, 0>(bool x) {} @@ -98,6 +144,31 @@ void function<bool, 0>(bool x) {} // MD: *void function(bool x)* // MD: *Defined at {{.*}}templates.cpp#[[# @LINE - 26]]* +// JSON: "Name": "function", +// JSON-NEXT: "Params": [ +// JSON-NEXT: { +// JSON-NEXT: "End": true, +// JSON-NEXT: "Name": "x", +// JSON-NEXT: "Type": "bool" +// JSON-NEXT: } +// JSON-NEXT: ], +// JSON-NEXT: "ReturnType": { +// JSON-NEXT: "IsBuiltIn": true, +// JSON-NEXT: "IsTemplate": false, +// JSON-NEXT: "Name": "void", +// JSON-NEXT: "QualName": "void", +// JSON-NEXT: "USR": "0000000000000000000000000000000000000000" +// JSON-NEXT: }, +// JSON-NEXT: "Template": { +// JSON-NEXT: "Specialization": { +// JSON-NEXT: "Parameters": [ +// JSON-NEXT: "bool", +// JSON-NEXT: "0" +// JSON-NEXT: ], +// JSON-NEXT: "SpecializationOf": "{{([0-9A-F]{40})}}" +// JSON-NEXT: } +// JSON-NEXT: }, + /// A Tuple type /// /// Does Tuple things. @@ -154,3 +225,20 @@ tuple<int, int, bool> func_with_tuple_param(tuple<int, int, bool> t) { return t; // MD: *Defined at {{.*}}templates.cpp#[[# @LINE - 44]]* // MD: A function with a tuple parameter // MD: **t** The input to func_with_tuple_param + +// JSON: "Name": "func_with_tuple_param", +// COM: FIXME: Add type info to parameters +// JSON-NEXT: "Params": [ +// JSON-NEXT: { +// JSON-NEXT: "End": true, +// JSON-NEXT: "Name": "t", +// JSON-NEXT: "Type": "tuple" +// JSON-NEXT: } +// JSON-NEXT: ], +// JSON-NEXT: "ReturnType": { +// JSON-NEXT: "IsBuiltIn": false, +// JSON-NEXT: "IsTemplate": false, +// JSON-NEXT: "Name": "tuple", +// JSON-NEXT: "QualName": "tuple<int, int, bool>", +// JSON-NEXT: "USR": "{{([0-9A-F]{40})}}" +// JSON-NEXT: }, _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
