[clang-tools-extra] [llvm] [clang-doc] Adds a mustache backend (PR #133161)
Paul Kirth via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 27 14:00:19 PDT 2025
================
@@ -32,6 +33,183 @@ populateParentNamespaces(llvm::SmallVector<Reference, 4> &Namespaces,
static void populateMemberTypeInfo(MemberTypeInfo &I, const FieldDecl *D);
+void getTemplateParameters(const TemplateParameterList *TemplateParams,
+ llvm::raw_ostream &Stream) {
+ Stream << "template <";
+
+ for (unsigned i = 0; i < TemplateParams->size(); ++i) {
+ if (i > 0) {
+ Stream << ", ";
+ }
+
+ const NamedDecl *Param = TemplateParams->getParam(i);
+ if (const auto *TTP = llvm::dyn_cast<TemplateTypeParmDecl>(Param)) {
+ if (TTP->wasDeclaredWithTypename()) {
+ Stream << "typename";
+ } else {
+ Stream << "class";
+ }
+ if (TTP->isParameterPack()) {
+ Stream << "...";
+ }
+ Stream << " " << TTP->getNameAsString();
+ } else if (const auto *NTTP = llvm::dyn_cast<NonTypeTemplateParmDecl>(Param)) {
+ NTTP->getType().print(Stream, NTTP->getASTContext().getPrintingPolicy());
+ if (NTTP->isParameterPack()) {
+ Stream << "...";
+ }
+ Stream << " " << NTTP->getNameAsString();
+ } else if (const auto *TTPD = llvm::dyn_cast<TemplateTemplateParmDecl>(Param)) {
+ Stream << "template <";
+ getTemplateParameters(TTPD->getTemplateParameters(), Stream);
+ Stream << "> class " << TTPD->getNameAsString();
+ }
+ }
+
+ Stream << "> ";
+}
+
+// Extract the full function prototype from a FunctionDecl including
+// Full Decl
+llvm::SmallString<256> getFunctionPrototype(const FunctionDecl *FuncDecl) {
----------------
ilovepi wrote:
How much does this output differ from `PrintName()` or `getNameForDiagnostic()`? I'm wondering if we need a custom thing here since we have the FunctionDecl.
https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html#af40656355e6d13ca9d7de07340b1b46c
https://github.com/llvm/llvm-project/pull/133161
More information about the llvm-commits
mailing list