Skip to content

Commit 545f521

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 6ad426c commit 545f521

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
@@ -416,9 +416,12 @@ static RecordDecl *getRecordDeclForType(const QualType &T) {
416416
static TypeInfo getTypeInfoForType(const QualType &T,
417417
const PrintingPolicy &Policy) {
418418
const TagDecl *TD = getTagDeclForType(T);
419-
if (!TD)
420-
return TypeInfo(Reference(SymbolID(), T.getAsString(Policy)));
421-
419+
if (!TD) {
420+
TypeInfo TI = TypeInfo(Reference(SymbolID(), T.getAsString(Policy)));
421+
TI.IsBuiltIn = T->isBuiltinType();
422+
TI.IsTemplate = T->isTemplateTypeParmType();
423+
return TI;
424+
}
422425
InfoType IT;
423426
if (isa<EnumDecl>(TD)) {
424427
IT = InfoType::IT_enum;
@@ -427,8 +430,12 @@ static TypeInfo getTypeInfoForType(const QualType &T,
427430
} else {
428431
IT = InfoType::IT_default;
429432
}
430-
return TypeInfo(Reference(getUSRForDecl(TD), TD->getNameAsString(), IT,
431-
T.getAsString(Policy), getInfoRelativePath(TD)));
433+
Reference R = Reference(getUSRForDecl(TD), TD->getNameAsString(), IT,
434+
T.getAsString(Policy), getInfoRelativePath(TD));
435+
TypeInfo TI = TypeInfo(R);
436+
TI.IsBuiltIn = T->isBuiltinType();
437+
TI.IsTemplate = T->isTemplateTypeParmType();
438+
return TI;
432439
}
433440

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

0 commit comments

Comments
 (0)