[PATCH] D41661: [clangd] Don't navigate to forward class declaration when go to definition.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 2 02:01:48 PST 2018
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41661.128399.patch
Type: text/x-patch
Size: 862 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180102/4ef595a9/attachment.bin>
More information about the cfe-commits
mailing list