-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[clang-doc] Track if a type is a template or builtin #138067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-clang-tools-extra Author: Paul Kirth (ilovepi) ChangesOriginally part of #133161. This patch adds preliminary tracking The new functionality is not yet exercised. Co-authored-by: Peter Chou <[email protected]> Full diff: https://github.com/llvm/llvm-project/pull/138067.diff 2 Files Affected:
diff --git a/clang-tools-extra/clang-doc/Representation.h b/clang-tools-extra/clang-doc/Representation.h
index 89e264f541a76..4d34109c399da 100644
--- a/clang-tools-extra/clang-doc/Representation.h
+++ b/clang-tools-extra/clang-doc/Representation.h
@@ -163,6 +163,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 21cf44c1ccd35..c6ca43d148440 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -424,9 +424,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;
@@ -435,8 +438,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,
|
|
@PeterChou1 can you provide some context about how you originally expected these fields to be used/consumed? Here we bake them into the representation and serialize them, but I don't see any handling of them in the original patch. How should they be used by the different backends? |
e04a368 to
f70cfdf
Compare
952c914 to
4851a86
Compare
f70cfdf to
d18b211
Compare
4851a86 to
5ebecc6
Compare
d18b211 to
622f2ef
Compare
41c2767 to
f5b3853
Compare
622f2ef to
c7955f5
Compare
f5b3853 to
a30feee
Compare
c7955f5 to
b5a3bc4
Compare
a30feee to
fe2cad2
Compare
3107a2f to
657483d
Compare
1a0c8b9 to
429d1ea
Compare
d829981 to
ec5d920
Compare
79d6630 to
90657f6
Compare
ec5d920 to
049c4ae
Compare
90657f6 to
a3420f9
Compare
5475c90 to
e94b231
Compare
a3420f9 to
4679534
Compare
e94b231 to
47a8fc0
Compare
4679534 to
57cfbd4
Compare
47a8fc0 to
5dd55e8
Compare
57cfbd4 to
fae895b
Compare
5dd55e8 to
3ddddd4
Compare
fae895b to
73cdd50
Compare
3ddddd4 to
fb5adf7
Compare
73cdd50 to
bb3d1b0
Compare
fb5adf7 to
bfd1d03
Compare
b6c17fe to
f8eff8a
Compare
bfd1d03 to
dc1b8f6
Compare
dc1b8f6 to
d8ddebc
Compare
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 <[email protected]>
f8eff8a to
96de320
Compare

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 [email protected]