[llvm-branch-commits] [clang-tools-extra] [clang-doc] Track if a type is a template or builtin (PR #138067)
Paul Kirth via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon May 12 09:41:30 PDT 2025
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/138067
>From 545f5213ce67f0a5513803496e7b5c2a2ca21800 Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at 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.chou at 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,
More information about the llvm-branch-commits
mailing list