Skip to content

Commit f8eff8a

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 dc1b8f6 commit f8eff8a

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
@@ -164,6 +164,9 @@ struct TypeInfo {
164164
bool operator==(const TypeInfo &Other) const { return Type == Other.Type; }
165165

166166
Reference Type; // Referenced type in this info.
167+
168+
bool IsTemplate = false;
169+
bool IsBuiltIn = false;
167170
};
168171

169172
// 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
@@ -420,9 +420,12 @@ static RecordDecl *getRecordDeclForType(const QualType &T) {
420420
static TypeInfo getTypeInfoForType(const QualType &T,
421421
const PrintingPolicy &Policy) {
422422
const TagDecl *TD = getTagDeclForType(T);
423-
if (!TD)
424-
return TypeInfo(Reference(SymbolID(), T.getAsString(Policy)));
425-
423+
if (!TD) {
424+
TypeInfo TI = TypeInfo(Reference(SymbolID(), T.getAsString(Policy)));
425+
TI.IsBuiltIn = T->isBuiltinType();
426+
TI.IsTemplate = T->isTemplateTypeParmType();
427+
return TI;
428+
}
426429
InfoType IT;
427430
if (isa<EnumDecl>(TD)) {
428431
IT = InfoType::IT_enum;
@@ -431,8 +434,12 @@ static TypeInfo getTypeInfoForType(const QualType &T,
431434
} else {
432435
IT = InfoType::IT_default;
433436
}
434-
return TypeInfo(Reference(getUSRForDecl(TD), TD->getNameAsString(), IT,
435-
T.getAsString(Policy), getInfoRelativePath(TD)));
437+
Reference R = Reference(getUSRForDecl(TD), TD->getNameAsString(), IT,
438+
T.getAsString(Policy), getInfoRelativePath(TD));
439+
TypeInfo TI = TypeInfo(R);
440+
TI.IsBuiltIn = T->isBuiltinType();
441+
TI.IsTemplate = T->isTemplateTypeParmType();
442+
return TI;
436443
}
437444

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

0 commit comments

Comments
 (0)