[PATCH] D133440: [clangd] Allow programmatically disabling rename of virtual method hierarchies.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 7 11:03:56 PDT 2022
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
This feature relies on Relations in the index being complete.
An out-of-tree index implementation is missing some override relations, so
such renames end up breaking the code.
We plan to fix it, but this flag is a cheap band-aid for now.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133440
Files:
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/refactor/Rename.h
Index: clang-tools-extra/clangd/refactor/Rename.h
===================================================================
--- clang-tools-extra/clangd/refactor/Rename.h
+++ clang-tools-extra/clangd/refactor/Rename.h
@@ -26,6 +26,8 @@
size_t LimitFiles = 50;
/// If true, format the rename edits, only meaningful in ClangdServer layer.
bool WantFormat = false;
+ /// Allow rename of virtual method hierarchies.
+ bool RenameVirtual = true;
};
struct RenameInputs {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===================================================================
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -181,7 +181,8 @@
llvm::Optional<ReasonToReject> renameable(const NamedDecl &RenameDecl,
StringRef MainFilePath,
- const SymbolIndex *Index) {
+ const SymbolIndex *Index,
+ const RenameOptions& Opts) {
trace::Span Tracer("Renameable");
// Filter out symbols that are unsupported in both rename modes.
if (llvm::isa<NamespaceDecl>(&RenameDecl))
@@ -213,6 +214,12 @@
RenameDecl, RenameDecl.getASTContext(), SymbolCollector::Options(),
IsMainFileOnly))
return ReasonToReject::NonIndexable;
+ if (!Opts.RenameVirtual) {
+ if (const auto *S = llvm::dyn_cast<CXXMethodDecl>(&RenameDecl)) {
+ if (S->isVirtual())
+ return ReasonToReject::UnsupportedSymbol;
+ }
+ }
return None;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133440.458520.patch
Type: text/x-patch
Size: 1599 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220907/899fa8e7/attachment.bin>
More information about the cfe-commits
mailing list