]> granicus.if.org Git - clang/commitdiff
[index] USR generation: use getTemplateArgs() instead of getTemplateInstantiationArgs()
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 15 Feb 2017 16:16:27 +0000 (16:16 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 15 Feb 2017 16:16:27 +0000 (16:16 +0000)
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

lib/Index/USRGeneration.cpp
test/Index/Core/index-source.cpp

index f9ed3c47995582aed9569fb535f9e44d39990807..3960074b5a41230f4aebc6996c178ae13b008f9f 100644 (file)
@@ -310,7 +310,7 @@ void USRGenerator::VisitVarDecl(const VarDecl *D) {
   // 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 TagDecl *D) {
   // 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 << '#';
index 68eafecf6795f0d3c787885dfa76f9661ce45579..2a4c1efa960d1dce7cde5757c3fd5f0af67a97e8 100644 (file)
@@ -23,6 +23,16 @@ public:
 TemplCls<int> gtv(0);
 // CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | TemplCls | c:@ST>1#T@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 {