[clang-tools-extra] [clang-doc] Update serializer for improved template handling (PR #138065)
Petr Hosek via cfe-commits
cfe-commits at lists.llvm.org
Mon May 26 23:23:54 PDT 2025
================
@@ -35,6 +35,169 @@ static void populateMemberTypeInfo(RecordInfo &I, AccessSpecifier &Access,
const DeclaratorDecl *D,
bool IsStatic = false);
+static 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();
----------------
petrhosek wrote:
We also need to handle type constraints, see `TTP->hasTypeConstraint()`, for example:
```
template <class T = void>
class C {};
```
https://github.com/llvm/llvm-project/pull/138065
More information about the cfe-commits
mailing list