]> granicus.if.org Git - clang/commitdiff
[index] Make sure to mark class template symbols as having 'generic' sub-kind.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 7 Nov 2016 21:20:08 +0000 (21:20 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 7 Nov 2016 21:20:08 +0000 (21:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286153 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 65f5241037c204a4802fa3bf1bfce6524235f92e..d98d7c072439d9cc62b1c577681610e1f421c196 100644 (file)
@@ -74,9 +74,14 @@ SymbolInfo index::getSymbolInfo(const Decl *D) {
       Info.Kind = SymbolKind::Enum; break;
     }
 
-    if (const CXXRecordDecl *CXXRec = dyn_cast<CXXRecordDecl>(D))
-      if (!CXXRec->isCLike())
+    if (const CXXRecordDecl *CXXRec = dyn_cast<CXXRecordDecl>(D)) {
+      if (!CXXRec->isCLike()) {
         Info.Lang = SymbolLanguage::CXX;
+        if (CXXRec->getDescribedClassTemplate()) {
+          Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
+        }
+      }
+    }
 
     if (isa<ClassTemplatePartialSpecializationDecl>(D)) {
       Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
index 11ac89529dd0cd64aee991be907bfc62d80b91c6..61b9675240c6e68c821e336f579924bba55179e7 100644 (file)
@@ -2,12 +2,16 @@
 
 template <typename TemplArg>
 class TemplCls {
-// CHECK: [[@LINE-1]]:7 | class/C++ | TemplCls | c:@ST>1#T@TemplCls | <no-cgname> | Def | rel: 0
+// CHECK: [[@LINE-1]]:7 | class(Gen)/C++ | TemplCls | c:@ST>1#T@TemplCls | <no-cgname> | Def | rel: 0
+public:
   TemplCls(int x);
   // CHECK: [[@LINE-1]]:3 | constructor/C++ | TemplCls | c:@ST>1#T@TemplCls@F@TemplCls#I# | <no-cgname> | Decl,RelChild | rel: 1
   // CHECK-NEXT: RelChild | TemplCls | c:@ST>1#T@TemplCls
 };
 
+TemplCls<int> gtv(0);
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | TemplCls | c:@ST>1#T@TemplCls | <no-cgname> | Ref | rel: 0
+
 template <typename T>
 class BT {
   struct KLR {