From: Argyrios Kyrtzidis Date: Wed, 15 Feb 2017 16:16:27 +0000 (+0000) Subject: [index] USR generation: use getTemplateArgs() instead of getTemplateInstantiationArgs() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c64d3a5d1acd999cc1869f49f588de3af33813e0;p=clang [index] USR generation: use getTemplateArgs() instead of getTemplateInstantiationArgs() Otherwise we may end up creating a different USR for the definition of a function, vs its declaration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@295191 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Index/USRGeneration.cpp b/lib/Index/USRGeneration.cpp index f9ed3c4799..3960074b5a 100644 --- a/lib/Index/USRGeneration.cpp +++ b/lib/Index/USRGeneration.cpp @@ -310,7 +310,7 @@ void USRGenerator::VisitVarDecl(const VarDecl *D) { // For a template specialization, mangle the template arguments. if (const VarTemplateSpecializationDecl *Spec = dyn_cast(D)) { - const TemplateArgumentList &Args = Spec->getTemplateInstantiationArgs(); + const TemplateArgumentList &Args = Spec->getTemplateArgs(); Out << '>'; for (unsigned I = 0, N = Args.size(); I != N; ++I) { Out << '#'; @@ -521,7 +521,7 @@ void USRGenerator::VisitTagDecl(const TagDecl *D) { // For a class template specialization, mangle the template arguments. if (const ClassTemplateSpecializationDecl *Spec = dyn_cast(D)) { - const TemplateArgumentList &Args = Spec->getTemplateInstantiationArgs(); + const TemplateArgumentList &Args = Spec->getTemplateArgs(); Out << '>'; for (unsigned I = 0, N = Args.size(); I != N; ++I) { Out << '#'; diff --git a/test/Index/Core/index-source.cpp b/test/Index/Core/index-source.cpp index 68eafecf67..2a4c1efa96 100644 --- a/test/Index/Core/index-source.cpp +++ b/test/Index/Core/index-source.cpp @@ -23,6 +23,16 @@ public: TemplCls gtv(0); // CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | TemplCls | c:@ST>1#T@TemplCls | | Ref,RelCont | rel: 1 +template +class Wrapper {}; +template +class Wrapper {}; + +// CHECK: [[@LINE+1]]:6 | function/C | test1 | [[TEST1_USR:.*]] | [[TEST1_CG:.*]] | Decl | rel: 0 +void test1(Wrapper f); +// CHECK: [[@LINE+1]]:6 | function/C | test1 | [[TEST1_USR]] | [[TEST1_CG]] | Def | rel: 0 +void test1(Wrapper f) {} + template class BT { struct KLR {