From aa324c5441f229bd1ff07407affeab95740328fe Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Thu, 27 Feb 2020 14:46:01 +0100 Subject: [PATCH] [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. --- clang-tools-extra/clangd/refactor/Rename.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/clangd/refactor/Rename.cpp b/clang-tools-extra/clangd/refactor/Rename.cpp index fd2146e..d31af9c 100644 --- a/clang-tools-extra/clangd/refactor/Rename.cpp +++ b/clang-tools-extra/clangd/refactor/Rename.cpp @@ -531,8 +531,9 @@ llvm::Expected 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)})}); -- 2.7.4