With this patch, we reject the rename if the new name would conflict with
any other decls in the decl context of the renamed decl.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clangd/refactor/Rename.cpp | ||
---|---|---|
263 | explain this list somewhat? | |
263 | I think you want to walk up DC while isTransparentContext() | |
315 | Can you explain this a bit more (e.g. why?) My guess is given: void foo() { int bar; } foo is a DC but bar is not declared directly within it (rather within the CompoundStmt that is its body), therefore will not be looked up. In which case an explanation like "Note that the enclosing DeclContext may not be the enclosing scope, particularly for function-local declarations, so this has both false positives and negatives." might help. |
Thanks! Just style nits.
clang-tools-extra/clangd/refactor/Rename.cpp | ||
---|---|---|
266 | this comment is missing the *reason*. FunctionDecl is a good example, but the fundamental reason is again not given. Notably, FunctionDecl is excluded, because local variables are not scoped to the function, but rather to the CompoundStmt that is its body. Lookup will not find function-local variables. | |
268 | confidence in what? I think the condition is: don't have any subscopes that are neither DeclContexts nor transparent. | |
320 | This is still a bit confusing: *here* you seem to decide which scope to look up in, but then inside the lookup() function you may change your mind. Also while early-exit is often good, I find early-exit in the *success* case confusing. // Name conflict detection. // Function conflicts are subtle (overloading), so ignore them. if (RenameDecl.getKind() != Decl::Function) { if (lookupSiblingWithName(ASTCtx, RenameDecl, NewName)) return InvalidName{...}; } return llvm::None; |
This breaks compillation on windows when using clang as compiler: http://45.33.8.238/win/27605/step_4.txt
explain this list somewhat?
e.g. these are the declcontexts which form a namespace where conflicts can occur?
and why function doesn't belong here