[PATCH] D95231: [clangd] Selection handles CXXBaseSpecifier
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 22 06:44:24 PST 2021
njames93 created this revision.
njames93 added reviewers: kadircet, hokein, sammccall.
Herald added subscribers: usaxena95, arphaman.
njames93 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.
Selection now includes the virtual and access modifier as part of their range for cxx base specifiers.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D95231
Files:
clang-tools-extra/clangd/Selection.cpp
clang-tools-extra/clangd/unittests/SelectionTests.cpp
clang/lib/AST/ASTTypeTraits.cpp
Index: clang/lib/AST/ASTTypeTraits.cpp
===================================================================
--- clang/lib/AST/ASTTypeTraits.cpp
+++ clang/lib/AST/ASTTypeTraits.cpp
@@ -193,5 +193,7 @@
return TAL->getSourceRange();
if (const auto *C = get<OMPClause>())
return SourceRange(C->getBeginLoc(), C->getEndLoc());
+ if (const auto *CBS = get<CXXBaseSpecifier>())
+ return CBS->getSourceRange();
return SourceRange();
}
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -261,6 +261,27 @@
)cpp",
"StringLiteral", // Not DeclRefExpr to operator()!
},
+ {
+ R"cpp(
+ struct Foo {};
+ struct Bar : [[v^ir^tual private Foo]] {};
+ )cpp",
+ "CXXBaseSpecifier",
+ },
+ {
+ R"cpp(
+ struct Foo {};
+ struct Bar : [[private Fo^o]] {};
+ )cpp",
+ "CXXBaseSpecifier",
+ },
+ {
+ R"cpp(
+ struct Foo {};
+ struct Bar : [[Fo^o]] {};
+ )cpp",
+ "CXXBaseSpecifier",
+ },
// Point selections.
{"void foo() { [[^foo]](); }", "DeclRefExpr"},
Index: clang-tools-extra/clangd/Selection.cpp
===================================================================
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -493,6 +493,14 @@
return traverseNode(
X, [&] { return Base::TraverseConstructorInitializer(X); });
}
+ bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &X) {
+ auto N = DynTypedNode::create(X);
+ if (canSafelySkipNode(N))
+ return true;
+ push(std::move(N));
+ pop();
+ return true;
+ }
// Stmt is the same, but this form allows the data recursion optimization.
bool dataTraverseStmtPre(Stmt *X) {
if (!X || isImplicit(X))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95231.318511.patch
Type: text/x-patch
Size: 2052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210122/6ac95e58/attachment.bin>
More information about the cfe-commits
mailing list