This revision was automatically updated to reflect the committed changes.
Closed by commit rL322370: [clangd] Dont navigate to forward class
declaration when go to definition. (authored by hokein, committed by ).
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
hokein added inline comments.
Comment at: clangd/XRefs.cpp:68
+ // declaration, and it could be a forward declaration.
+ auto Def = std::find_if(D->redecls_begin(), D->redecls_end(),
+ [](const Decl *D) { return IsDefinition(D); });
hokein updated this revision to Diff 128516.
hokein added a comment.
Use getDefinition to simply the code.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D41661
Files:
clangd/XRefs.cpp
unittests/clangd/XRefsTests.cpp
Index: unittests/clangd/XRefsTests.cpp
ilya-biryukov added inline comments.
Comment at: clangd/XRefs.cpp:68
+ // declaration, and it could be a forward declaration.
+ auto Def = std::find_if(D->redecls_begin(), D->redecls_end(),
+ [](const Decl *D) { return IsDefinition(D); });
hokein added a comment.
With more test, it turns out that `ASTNode.OrigD` is not always pointed to the
definition, so we can't rely on `D` or `ASTNode.OrigD` :(.
I revised the way of checking definition, it should works for major cases.
Please review it again.
Repository:
rCTE Clang Tools
hokein updated this revision to Diff 128501.
hokein marked an inline comment as done.
hokein added a comment.
- Revise the way of checking definition.
- Add a test for function declaration.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D41661
Files:
clangd/XRefs.cpp
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.
Comment at: clangd/XRefs.cpp:54
if (isSearchedLocation(FID, Offset))
- Decls.push_back(D);
+ Decls.push_back(ASTNode.OrigD);
return true;
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