[PATCH] D73690: [clangd] Make go-to-def jumps to overriden methods on `final` specifier.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 30 03:53:06 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG827f49e3faf5: [clangd] Make go-to-def jumps to overriden methods on `final` specifier. (authored by hokein).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73690/new/
https://reviews.llvm.org/D73690
Files:
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -452,6 +452,11 @@
class X : Y { void a() ^override {} };
)cpp",
+ R"cpp(// Final specifier jumps to overridden method
+ class Y { virtual void $decl[[a]]() = 0; };
+ class X : Y { void a() ^final {} };
+ )cpp",
+
R"cpp(// Heuristic resolution of dependent method
template <typename T>
struct S {
Index: clang-tools-extra/clangd/XRefs.cpp
===================================================================
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -22,6 +22,7 @@
#include "index/SymbolLocation.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
+#include "clang/AST/Attrs.inc"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
@@ -277,7 +278,9 @@
for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
// Special case: void foo() ^override: jump to the overridden method.
if (const auto *CMD = llvm::dyn_cast<CXXMethodDecl>(D)) {
- const auto *Attr = D->getAttr<OverrideAttr>();
+ const InheritableAttr* Attr = D->getAttr<OverrideAttr>();
+ if (!Attr)
+ Attr = D->getAttr<FinalAttr>();
const syntax::Token *Tok =
spelledIdentifierTouching(SourceLoc, AST.getTokens());
if (Attr && Tok &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73690.241403.patch
Type: text/x-patch
Size: 1573 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200130/c75b2856/attachment-0001.bin>
More information about the cfe-commits
mailing list