Skip to content

Commit bb3d1b0

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 fb5adf7 commit bb3d1b0

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
@@ -411,9 +411,12 @@ static RecordDecl *getRecordDeclForType(const QualType &T) {
411411
static TypeInfo getTypeInfoForType(const QualType &T,
412412
const PrintingPolicy &Policy) {
413413
const TagDecl *TD = getTagDeclForType(T);
414-
if (!TD)
415-
return TypeInfo(Reference(SymbolID(), T.getAsString(Policy)));
416-
414+
if (!TD) {
415+
TypeInfo TI = TypeInfo(Reference(SymbolID(), T.getAsString(Policy)));
416+
TI.IsBuiltIn = T->isBuiltinType();
417+
TI.IsTemplate = T->isTemplateTypeParmType();
418+
return TI;
419+
}
417420
InfoType IT;
418421
if (isa<EnumDecl>(TD)) {
419422
IT = InfoType::IT_enum;
@@ -422,8 +425,12 @@ static TypeInfo getTypeInfoForType(const QualType &T,
422425
} else {
423426
IT = InfoType::IT_default;
424427
}
425-
return TypeInfo(Reference(getUSRForDecl(TD), TD->getNameAsString(), IT,
426-
T.getAsString(Policy), getInfoRelativePath(TD)));
428+
Reference R = Reference(getUSRForDecl(TD), TD->getNameAsString(), IT,
429+
T.getAsString(Policy), getInfoRelativePath(TD));
430+
TypeInfo TI = TypeInfo(R);
431+
TI.IsBuiltIn = T->isBuiltinType();
432+
TI.IsTemplate = T->isTemplateTypeParmType();
433+
return TI;
427434
}
428435

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

0 commit comments

Comments
 (0)