r295191 - [index] USR generation: use getTemplateArgs() instead of getTemplateInstantiationArgs()

Argyrios Kyrtzidis via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 15 08:16:28 PST 2017


Author: akirtzidis
Date: Wed Feb 15 10:16:27 2017
New Revision: 295191

URL: http://llvm.org/viewvc/llvm-project?rev=295191&view=rev
Log:
[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.

Modified:
    cfe/trunk/lib/Index/USRGeneration.cpp
    cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=295191&r1=295190&r2=295191&view=diff
==============================================================================
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Wed Feb 15 10:16:27 2017
@@ -310,7 +310,7 @@ void USRGenerator::VisitVarDecl(const Va
   // For a template specialization, mangle the template arguments.
   if (const VarTemplateSpecializationDecl *Spec
                               = dyn_cast<VarTemplateSpecializationDecl>(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 Ta
   // For a class template specialization, mangle the template arguments.
   if (const ClassTemplateSpecializationDecl *Spec
                               = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
-    const TemplateArgumentList &Args = Spec->getTemplateInstantiationArgs();
+    const TemplateArgumentList &Args = Spec->getTemplateArgs();
     Out << '>';
     for (unsigned I = 0, N = Args.size(); I != N; ++I) {
       Out << '#';

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=295191&r1=295190&r2=295191&view=diff
==============================================================================
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Wed Feb 15 10:16:27 2017
@@ -23,6 +23,16 @@ public:
 TemplCls<int> gtv(0);
 // CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | TemplCls | c:@ST>1#T at TemplCls | <no-cgname> | Ref,RelCont | rel: 1
 
+template<class T>
+class Wrapper {};
+template<class T, class P>
+class Wrapper<T(P)> {};
+
+// CHECK: [[@LINE+1]]:6 | function/C | test1 | [[TEST1_USR:.*]] | [[TEST1_CG:.*]] | Decl | rel: 0
+void test1(Wrapper<void(int)> f);
+// CHECK: [[@LINE+1]]:6 | function/C | test1 | [[TEST1_USR]] | [[TEST1_CG]] | Def | rel: 0
+void test1(Wrapper<void(int)> f) {}
+
 template <typename T>
 class BT {
   struct KLR {




More information about the cfe-commits mailing list