[PATCH] D96247: [clangd] Fix false positive in local rename collision detetction
Kirill Bobyrev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 9 02:45:09 PST 2021
kbobyrev updated this revision to Diff 322323.
kbobyrev marked an inline comment as done.
kbobyrev added a comment.
Resolve review comment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96247/new/
https://reviews.llvm.org/D96247
Files:
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1083,12 +1083,23 @@
"conflict", !HeaderFile, nullptr, "Conflict"},
{R"cpp(
+ void func(int Var);
+
void func(int V^ar) {
bool Conflict;
}
)cpp",
"conflict", !HeaderFile, nullptr, "Conflict"},
+ {R"cpp(// No conflict: only forward declaration's argument is renamed.
+ void func(int [[V^ar]]);
+
+ void func(int Var) {
+ bool Conflict;
+ }
+ )cpp",
+ nullptr, !HeaderFile, nullptr, "Conflict"},
+
{R"cpp(
void func(int V^ar, int Conflict) {
}
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===================================================================
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -421,6 +421,11 @@
for (const auto *Parameter : EnclosingFunction->parameters())
if (Parameter != &RenamedDecl && Parameter->getName() == NewName)
return Parameter;
+ // FIXME: We don't modify all references to function parameters when
+ // renaming from forward declaration now, so using a name colliding with
+ // something in the definition's body is a valid transformation.
+ if (!EnclosingFunction->doesThisDeclarationHaveABody())
+ return nullptr;
return CheckCompoundStmt(EnclosingFunction->getBody(), NewName);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96247.322323.patch
Type: text/x-patch
Size: 1611 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210209/37c59a4a/attachment.bin>
More information about the cfe-commits
mailing list