[PATCH] D95925: [clangd] Detect rename conflicits within enclosing scope
Kirill Bobyrev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 3 04:23:04 PST 2021
kbobyrev added inline comments.
================
Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:339
+ if (const auto *If = ParentNode->get<IfStmt>())
+ if (const auto *Then = dyn_cast<CompoundStmt>(If->getThen()))
+ EnclosingScope = Then;
----------------
hokein wrote:
> thinking more about the `if` case, I think else should be included as well? no need to address in this patch.
>
> like
>
> ```
> if (int a = 0) {
> } else {
> int s; // rename s=>a will cause a compiling error.
> }
> ```
This case is already supported: `else`'s `CompoundStmt` is attached to the same `IfStmt` with variable declaration and is checked just like the "main" branch.
The other one wasn't (renaming `a` into `s`) but I've added this and also added tests for this.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95925/new/
https://reviews.llvm.org/D95925
More information about the cfe-commits
mailing list