[PATCH] D49476: [Index] Set OrigD before D is changed.

Eric Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 20 01:14:12 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL337529: [Index] Set OrigD before D is changed. (authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D49476

Files:
  cfe/trunk/lib/Index/IndexingContext.cpp
  cfe/trunk/test/Index/index-template-specialization.cpp
  cfe/trunk/tools/c-index-test/c-index-test.c
  cfe/trunk/tools/libclang/Indexing.cpp


Index: cfe/trunk/lib/Index/IndexingContext.cpp
===================================================================
--- cfe/trunk/lib/Index/IndexingContext.cpp
+++ cfe/trunk/lib/Index/IndexingContext.cpp
@@ -350,6 +350,9 @@
     }
   }
 
+  if (!OrigD)
+    OrigD = D;
+
   if (isTemplateImplicitInstantiation(D)) {
     if (!IsRef)
       return true;
@@ -359,9 +362,6 @@
     assert(!isTemplateImplicitInstantiation(D));
   }
 
-  if (!OrigD)
-    OrigD = D;
-
   if (IsRef)
     Roles |= (unsigned)SymbolRole::Reference;
   else if (isDeclADefinition(OrigD, ContainerDC, *Ctx))
Index: cfe/trunk/tools/libclang/Indexing.cpp
===================================================================
--- cfe/trunk/tools/libclang/Indexing.cpp
+++ cfe/trunk/tools/libclang/Indexing.cpp
@@ -402,6 +402,8 @@
   IndexingOptions IdxOpts;
   if (index_options & CXIndexOpt_IndexFunctionLocalSymbols)
     IdxOpts.IndexFunctionLocals = true;
+  if (index_options & CXIndexOpt_IndexImplicitTemplateInstantiations)
+    IdxOpts.IndexImplicitInstantiation = true;
   return IdxOpts;
 }
 
Index: cfe/trunk/tools/c-index-test/c-index-test.c
===================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c
+++ cfe/trunk/tools/c-index-test/c-index-test.c
@@ -3652,6 +3652,8 @@
     index_opts |= CXIndexOpt_IndexFunctionLocalSymbols;
   if (!getenv("CINDEXTEST_DISABLE_SKIPPARSEDBODIES"))
     index_opts |= CXIndexOpt_SkipParsedBodiesInSession;
+  if (getenv("CINDEXTEST_INDEXIMPLICITTEMPLATEINSTANTIATIONS"))
+    index_opts |= CXIndexOpt_IndexImplicitTemplateInstantiations;
 
   return index_opts;
 }
Index: cfe/trunk/test/Index/index-template-specialization.cpp
===================================================================
--- cfe/trunk/test/Index/index-template-specialization.cpp
+++ cfe/trunk/test/Index/index-template-specialization.cpp
@@ -0,0 +1,19 @@
+template <typename T>
+class Foo {
+public:
+  void f(T t) {}
+};
+
+void g() {
+  Foo<int> foo;
+  foo.f(0);
+}
+
+// FIXME: if c-index-test uses OrigD for symbol info, refererences below should
+// refer to template specialization decls.
+// RUN: env CINDEXTEST_INDEXIMPLICITTEMPLATEINSTANTIATIONS=1 c-index-test -index-file %s | FileCheck %s
+// CHECK: [indexDeclaration]: kind: c++-class-template | name: Foo
+// CHECK-NEXT: [indexDeclaration]: kind: c++-instance-method | name: f
+// CHECK-NEXT: [indexDeclaration]: kind: function | name: g
+// CHECK-NEXT: [indexEntityReference]: kind: c++-class-template | name: Foo | USR: c:@ST>1#T at Foo
+// CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: f | USR: c:@ST>1#T at Foo@F at f#t0.0#


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49476.156442.patch
Type: text/x-patch
Size: 2652 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180720/ff5b9fec/attachment.bin>


More information about the cfe-commits mailing list