Skip to content

[clang-doc] Track if a type is a template or builtin #138067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang-tools-extra/clang-doc/Representation.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ struct TypeInfo {
bool operator==(const TypeInfo &Other) const { return Type == Other.Type; }

Reference Type; // Referenced type in this info.

bool IsTemplate = false;
bool IsBuiltIn = false;
};

// Represents one template parameter.
Expand Down
17 changes: 12 additions & 5 deletions clang-tools-extra/clang-doc/Serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,12 @@ static RecordDecl *getRecordDeclForType(const QualType &T) {
static TypeInfo getTypeInfoForType(const QualType &T,
const PrintingPolicy &Policy) {
const TagDecl *TD = getTagDeclForType(T);
if (!TD)
return TypeInfo(Reference(SymbolID(), T.getAsString(Policy)));

if (!TD) {
TypeInfo TI = TypeInfo(Reference(SymbolID(), T.getAsString(Policy)));
TI.IsBuiltIn = T->isBuiltinType();
TI.IsTemplate = T->isTemplateTypeParmType();
return TI;
}
InfoType IT;
if (isa<EnumDecl>(TD)) {
IT = InfoType::IT_enum;
Expand All @@ -431,8 +434,12 @@ static TypeInfo getTypeInfoForType(const QualType &T,
} else {
IT = InfoType::IT_default;
}
return TypeInfo(Reference(getUSRForDecl(TD), TD->getNameAsString(), IT,
T.getAsString(Policy), getInfoRelativePath(TD)));
Reference R = Reference(getUSRForDecl(TD), TD->getNameAsString(), IT,
T.getAsString(Policy), getInfoRelativePath(TD));
TypeInfo TI = TypeInfo(R);
TI.IsBuiltIn = T->isBuiltinType();
TI.IsTemplate = T->isTemplateTypeParmType();
return TI;
}

static bool isPublic(const clang::AccessSpecifier AS,
Expand Down
Loading