diff --git a/clang-tools-extra/clangd/refactor/Rename.h b/clang-tools-extra/clangd/refactor/Rename.h --- a/clang-tools-extra/clangd/refactor/Rename.h +++ b/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 { diff --git a/clang-tools-extra/clangd/refactor/Rename.cpp b/clang-tools-extra/clangd/refactor/Rename.cpp --- a/clang-tools-extra/clangd/refactor/Rename.cpp +++ b/clang-tools-extra/clangd/refactor/Rename.cpp @@ -181,7 +181,8 @@ llvm::Optional 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(&RenameDecl)) @@ -213,6 +214,12 @@ RenameDecl, RenameDecl.getASTContext(), SymbolCollector::Options(), IsMainFileOnly)) return ReasonToReject::NonIndexable; + if (!Opts.RenameVirtual) { + if (const auto *S = llvm::dyn_cast(&RenameDecl)) { + if (S->isVirtual()) + return ReasonToReject::UnsupportedSymbol; + } + } return None; }