Author: Haojian Wu
Date: 2020-02-27T15:04:51+01:00
New Revision: aa324c5441f229bd1ff07407affeab95740328fe

URL: 
https://github.com/llvm/llvm-project/commit/aa324c5441f229bd1ff07407affeab95740328fe
DIFF: 
https://github.com/llvm/llvm-project/commit/aa324c5441f229bd1ff07407affeab95740328fe.diff

LOG: [clangd][NFC] Don't query the index if the rename symbol is function
local.

This would save an unnecessary index query when renaming a function
local symbol in cross-file rename mode.

Added: 
    

Modified: 
    clang-tools-extra/clangd/refactor/Rename.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index fd2146eb4fb7..d31af9c2adf1 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -531,8 +531,9 @@ llvm::Expected<FileEdits> rename(const RenameInputs 
&RInputs) {
   if (!MainFileRenameEdit)
     return MainFileRenameEdit.takeError();
 
-  if (!Opts.AllowCrossFile) {
-    // Within-file rename: just return the main file results.
+  // return the main file edit if this is a within-file rename or the symbol
+  // being renamed is function local.
+  if (!Opts.AllowCrossFile || RenameDecl.getParentFunctionOrMethod()) {
     return FileEdits(
         {std::make_pair(RInputs.MainFilePath,
                         Edit{MainFileCode, std::move(*MainFileRenameEdit)})});


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to