[PATCH] D95231: [clangd] Selection handles CXXBaseSpecifier
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 25 02:42:19 PST 2021
njames93 updated this revision to Diff 318933.
njames93 marked an inline comment as done.
njames93 added a comment.
Remove FindTarget to instead add in a follow up patch.
Side note, Think I'll wait til after tomorrow to land this, unsure if the changes will break anything elsewhere.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95231/new/
https://reviews.llvm.org/D95231
Files:
clang-tools-extra/clangd/Selection.cpp
clang-tools-extra/clangd/unittests/RenameTests.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",
+ "RecordTypeLoc",
+ },
+ {
+ R"cpp(
+ struct Foo {};
+ struct Bar : [[Fo^o]] {};
+ )cpp",
+ "RecordTypeLoc",
+ },
// Point selections.
{"void foo() { [[^foo]](); }", "DeclRefExpr"},
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1024,6 +1024,12 @@
}
)cpp",
"new name is the same", !HeaderFile, nullptr, "SameName"},
+ {R"cpp(// Ensure it doesn't associate base specifier with base name.
+ struct A {};
+ struct B : priv^ate A {};
+ )cpp",
+ "Cannot rename symbol: there is no symbol at the given location", false,
+ nullptr},
};
for (const auto& Case : Cases) {
Index: clang-tools-extra/clangd/Selection.cpp
===================================================================
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -493,6 +493,9 @@
return traverseNode(
X, [&] { return Base::TraverseConstructorInitializer(X); });
}
+ bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &X) {
+ return traverseNode(&X, [&] { return Base::TraverseCXXBaseSpecifier(X); });
+ }
// 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.318933.patch
Type: text/x-patch
Size: 2622 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210125/352cc348/attachment.bin>
More information about the cfe-commits
mailing list