Skip to content

Commit b9eb7b2

Browse files
ilovepiPeterChou1
andcommitted
[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 <[email protected]>
1 parent e184062 commit b9eb7b2

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

clang-tools-extra/clang-doc/Representation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ struct TypeInfo {
163163
bool operator==(const TypeInfo &Other) const { return Type == Other.Type; }
164164

165165
Reference Type; // Referenced type in this info.
166+
167+
bool IsTemplate = false;
168+
bool IsBuiltIn = false;
166169
};
167170

168171
// Represents one template parameter.

clang-tools-extra/clang-doc/Serialize.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,12 @@ static RecordDecl *getRecordDeclForType(const QualType &T) {
424424
static TypeInfo getTypeInfoForType(const QualType &T,
425425
const PrintingPolicy &Policy) {
426426
const TagDecl *TD = getTagDeclForType(T);
427-
if (!TD)
428-
return TypeInfo(Reference(SymbolID(), T.getAsString(Policy)));
429-
427+
if (!TD) {
428+
TypeInfo TI = TypeInfo(Reference(SymbolID(), T.getAsString(Policy)));
429+
TI.IsBuiltIn = T->isBuiltinType();
430+
TI.IsTemplate = T->isTemplateTypeParmType();
431+
return TI;
432+
}
430433
InfoType IT;
431434
if (isa<EnumDecl>(TD)) {
432435
IT = InfoType::IT_enum;
@@ -435,8 +438,12 @@ static TypeInfo getTypeInfoForType(const QualType &T,
435438
} else {
436439
IT = InfoType::IT_default;
437440
}
438-
return TypeInfo(Reference(getUSRForDecl(TD), TD->getNameAsString(), IT,
439-
T.getAsString(Policy), getInfoRelativePath(TD)));
441+
Reference R = Reference(getUSRForDecl(TD), TD->getNameAsString(), IT,
442+
T.getAsString(Policy), getInfoRelativePath(TD));
443+
TypeInfo TI = TypeInfo(R);
444+
TI.IsBuiltIn = T->isBuiltinType();
445+
TI.IsTemplate = T->isTemplateTypeParmType();
446+
return TI;
440447
}
441448

442449
static bool isPublic(const clang::AccessSpecifier AS,

0 commit comments

Comments
 (0)