[clang-tools-extra] aa324c5 - [clangd][NFC] Don't query the index if the rename symbol is function

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 27 06:08:05 PST 2020


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)})});


        


More information about the cfe-commits mailing list