Skip to content

Commit 429d1ea

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 d829981 commit 429d1ea

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
@@ -405,9 +405,12 @@ static RecordDecl *getRecordDeclForType(const QualType &T) {
405405
static TypeInfo getTypeInfoForType(const QualType &T,
406406
const PrintingPolicy &Policy) {
407407
const TagDecl *TD = getTagDeclForType(T);
408-
if (!TD)
409-
return TypeInfo(Reference(SymbolID(), T.getAsString(Policy)));
410-
408+
if (!TD) {
409+
TypeInfo TI = TypeInfo(Reference(SymbolID(), T.getAsString(Policy)));
410+
TI.IsBuiltIn = T->isBuiltinType();
411+
TI.IsTemplate = T->isTemplateTypeParmType();
412+
return TI;
413+
}
411414
InfoType IT;
412415
if (isa<EnumDecl>(TD)) {
413416
IT = InfoType::IT_enum;
@@ -416,8 +419,12 @@ static TypeInfo getTypeInfoForType(const QualType &T,
416419
} else {
417420
IT = InfoType::IT_default;
418421
}
419-
return TypeInfo(Reference(getUSRForDecl(TD), TD->getNameAsString(), IT,
420-
T.getAsString(Policy), getInfoRelativePath(TD)));
422+
Reference R = Reference(getUSRForDecl(TD), TD->getNameAsString(), IT,
423+
T.getAsString(Policy), getInfoRelativePath(TD));
424+
TypeInfo TI = TypeInfo(R);
425+
TI.IsBuiltIn = T->isBuiltinType();
426+
TI.IsTemplate = T->isTemplateTypeParmType();
427+
return TI;
421428
}
422429

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

0 commit comments

Comments
 (0)