https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/138067
>From dd059d8da867c93aacc9ed078acc34148ba4e0b4 Mon Sep 17 00:00:00 2001 From: Paul Kirth <paulki...@google.com> Date: Wed, 30 Apr 2025 14:20:40 -0700 Subject: [PATCH] [clang-doc] Track if a type is a template or builtin Originally part of #133161. This patch adds preliminary tracking for of TypeInfo, by tracking if the type is a builtin or template. The new functionality is not yet exercised. Co-authored-by: Peter Chou <peter.c...@mail.utoronto.ca> --- clang-tools-extra/clang-doc/Representation.h | 3 +++ clang-tools-extra/clang-doc/Serialize.cpp | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/clang-tools-extra/clang-doc/Representation.h b/clang-tools-extra/clang-doc/Representation.h index 1673be496b7b2..a3a6217f76bbd 100644 --- a/clang-tools-extra/clang-doc/Representation.h +++ b/clang-tools-extra/clang-doc/Representation.h @@ -164,6 +164,9 @@ struct TypeInfo { bool operator==(const TypeInfo &Other) const { return Type == Other.Type; } Reference Type; // Referenced type in this info. + + bool IsTemplate = false; + bool IsBuiltIn = false; }; // Represents one template parameter. diff --git a/clang-tools-extra/clang-doc/Serialize.cpp b/clang-tools-extra/clang-doc/Serialize.cpp index b7c0d95c3be39..241a3de081d9a 100644 --- a/clang-tools-extra/clang-doc/Serialize.cpp +++ b/clang-tools-extra/clang-doc/Serialize.cpp @@ -416,9 +416,12 @@ static RecordDecl *getRecordDeclForType(const QualType &T) { static TypeInfo getTypeInfoForType(const QualType &T, const PrintingPolicy &Policy) { const TagDecl *TD = getTagDeclForType(T); - if (!TD) - return TypeInfo(Reference(SymbolID(), T.getAsString(Policy))); - + if (!TD) { + TypeInfo TI = TypeInfo(Reference(SymbolID(), T.getAsString(Policy))); + TI.IsBuiltIn = T->isBuiltinType(); + TI.IsTemplate = T->isTemplateTypeParmType(); + return TI; + } InfoType IT; if (isa<EnumDecl>(TD)) { IT = InfoType::IT_enum; @@ -427,8 +430,12 @@ static TypeInfo getTypeInfoForType(const QualType &T, } else { IT = InfoType::IT_default; } - return TypeInfo(Reference(getUSRForDecl(TD), TD->getNameAsString(), IT, - T.getAsString(Policy), getInfoRelativePath(TD))); + Reference R = Reference(getUSRForDecl(TD), TD->getNameAsString(), IT, + T.getAsString(Policy), getInfoRelativePath(TD)); + TypeInfo TI = TypeInfo(R); + TI.IsBuiltIn = T->isBuiltinType(); + TI.IsTemplate = T->isTemplateTypeParmType(); + return TI; } static bool isPublic(const clang::AccessSpecifier AS, _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits