[PATCH] D133440: [clangd] Allow programmatically disabling rename of virtual method hierarchies.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 19 07:59:44 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rGe42441835827: [clangd] Allow programmatically disabling rename of virtual method hierarchies. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D133440?vs=458520&id=461211#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133440/new/

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,10 @@
   size_t LimitFiles = 50;
   /// If true, format the rename edits, only meaningful in ClangdServer layer.
   bool WantFormat = false;
+  /// Allow rename of virtual method hierarchies.
+  /// Disable to support broken index implementations with missing relations.
+  /// FIXME: fix those implementations and remove this option.
+  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,8 +181,15 @@
 
 llvm::Optional<ReasonToReject> renameable(const NamedDecl &RenameDecl,
                                           StringRef MainFilePath,
-                                          const SymbolIndex *Index) {
+                                          const SymbolIndex *Index,
+                                          const RenameOptions& Opts) {
   trace::Span Tracer("Renameable");
+  if (!Opts.RenameVirtual) {
+    if (const auto *S = llvm::dyn_cast<CXXMethodDecl>(&RenameDecl)) {
+      if (S->isVirtual())
+        return ReasonToReject::UnsupportedSymbol;
+    }
+  }
   // Filter out symbols that are unsupported in both rename modes.
   if (llvm::isa<NamespaceDecl>(&RenameDecl))
     return ReasonToReject::UnsupportedSymbol;
@@ -746,7 +753,8 @@
   if (Invalid)
     return makeError(std::move(*Invalid));
 
-  auto Reject = renameable(RenameDecl, RInputs.MainFilePath, RInputs.Index);
+  auto Reject =
+      renameable(RenameDecl, RInputs.MainFilePath, RInputs.Index, Opts);
   if (Reject)
     return makeError(*Reject);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133440.461211.patch
Type: text/x-patch
Size: 1900 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220919/416fc96d/attachment.bin>


More information about the cfe-commits mailing list