Improve libclang indexing support for class template specializations
in a few related ways:

  - Don't recurse into instantiations of templates.
  - Recurse into explicit specializations.
  - Visit the template arguments of an explicit specialization or
    explicit instantiation.
  - Include template specialization arguments in the USRs for class
    template specializations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112720 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndexUSRs.cpp b/tools/libclang/CIndexUSRs.cpp
index 5628aef..a60d1d3 100644
--- a/tools/libclang/CIndexUSRs.cpp
+++ b/tools/libclang/CIndexUSRs.cpp
@@ -422,6 +422,17 @@
     else
       Buf[off] = 'a';
   }
+  
+  // For a class template specialization, mangle the template arguments.
+  if (ClassTemplateSpecializationDecl *Spec
+                              = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
+    const TemplateArgumentList &Args = Spec->getTemplateInstantiationArgs();
+    Out << '>';
+    for (unsigned I = 0, N = Args.size(); I != N; ++I) {
+      Out << '#';
+      VisitTemplateArgument(Args.get(I));
+    }
+  }
 }
 
 void USRGenerator::VisitTypedefDecl(TypedefDecl *D) {