hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: ilya-biryukov, klimek.

For some cases, GoToDefinition will navigate to the forward class
declaration, we should always navigate to the class definition.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41661

Files:
  clangd/XRefs.cpp
  unittests/clangd/XRefsTests.cpp


Index: unittests/clangd/XRefsTests.cpp
===================================================================
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -203,6 +203,12 @@
         #define MACRO 2
         #undef macro
       )cpp",
+
+      R"cpp(// Forward class declaration
+        class Foo;
+        [[class Foo {}]];
+        F^oo* foo();
+      )cpp",
   };
   for (const char *Test : Tests) {
     Annotations T(Test);
Index: clangd/XRefs.cpp
===================================================================
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -51,7 +51,7 @@
                       unsigned Offset,
                       index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
     if (isSearchedLocation(FID, Offset))
-      Decls.push_back(D);
+      Decls.push_back(ASTNode.OrigD);
     return true;
   }
 


Index: unittests/clangd/XRefsTests.cpp
===================================================================
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -203,6 +203,12 @@
         #define MACRO 2
         #undef macro
       )cpp",
+
+      R"cpp(// Forward class declaration
+        class Foo;
+        [[class Foo {}]];
+        F^oo* foo();
+      )cpp",
   };
   for (const char *Test : Tests) {
     Annotations T(Test);
Index: clangd/XRefs.cpp
===================================================================
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -51,7 +51,7 @@
                       unsigned Offset,
                       index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
     if (isSearchedLocation(FID, Offset))
-      Decls.push_back(D);
+      Decls.push_back(ASTNode.OrigD);
     return true;
   }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to