[clangd][NFC] Don't query the index if the rename symbol is function
authorHaojian Wu <hokein.wu@gmail.com>
Thu, 27 Feb 2020 13:46:01 +0000 (14:46 +0100)
committerHaojian Wu <hokein.wu@gmail.com>
Thu, 27 Feb 2020 14:04:51 +0000 (15:04 +0100)
local.

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

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

index fd2146e..d31af9c 100644 (file)
@@ -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)})});