Skip to content
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

[Clang][Index] Add support for dependent class scope explicit specializations of function templates to USRGenerator #98027

Merged
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
18 changes: 13 additions & 5 deletions clang/lib/Index/USRGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,20 @@ void USRGenerator::VisitFunctionDecl(const FunctionDecl *D) {
!D->hasAttr<OverloadableAttr>())
return;

if (const TemplateArgumentList *
SpecArgs = D->getTemplateSpecializationArgs()) {
if (D->isFunctionTemplateSpecialization()) {
Out << '<';
for (unsigned I = 0, N = SpecArgs->size(); I != N; ++I) {
Out << '#';
VisitTemplateArgument(SpecArgs->get(I));
if (const TemplateArgumentList *SpecArgs =
D->getTemplateSpecializationArgs()) {
for (const auto &Arg : SpecArgs->asArray()) {
Out << '#';
VisitTemplateArgument(Arg);
}
} else if (const ASTTemplateArgumentListInfo *SpecArgsWritten =
D->getTemplateSpecializationArgsAsWritten()) {
for (const auto &ArgLoc : SpecArgsWritten->arguments()) {
Out << '#';
VisitTemplateArgument(ArgLoc.getArgument());
}
}
Out << '>';
}
Expand Down
15 changes: 15 additions & 0 deletions clang/test/Index/USR/func-template.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s

template<typename T>
struct A {
void f(int);
// CHECK: {{[0-9]+}}:8 | instance-method/C++ | f | c:@ST>1#T@A@F@f#I# |

template<typename U>
void f(U);
// CHECK: {{[0-9]+}}:8 | instance-method/C++ | f | c:@ST>1#T@A@FT@>1#Tf#t1.0#v# |

template<>
void f<int>(int);
// CHECK: {{[0-9]+}}:8 | instance-method/C++ | f | c:@ST>1#T@A@F@f<#I>#I# |
};
Loading