[PATCH] D69162: [clangd] Remove using-namespace present inside a namespace.
UTKARSH SAXENA via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 31 04:49:34 PDT 2019
usaxena95 marked 3 inline comments as done.
usaxena95 added inline comments.
================
Comment at: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp:179
+
+ if (ContainingNS) {
+ for (auto ReDeclNS : ContainingNS->redecls())
----------------
ilya-biryukov wrote:
> Could you explain why don't we always just run across the whole TU?
> What disadvantages would that have?
Working with a using decl inside the `ContainingNS` is quite similar to our initial version with GlobalNS.
For example we take advantage of that to replace the whole qualifier with just TargetNS. We use the fact that since `using namespace TargetNS;` was valid inside `ContainingNS` then qualifying the reference with just `TargetNS` would also be valid inside `ContainingNS`.
When we are outside `ContainingNS`, we would have to fully qualify the ref to be 100% correct. To reduce the qualification we might have to figure out which is enclosing NS for the reference.
```
namespace aa {
namespace bb {
struct map {};
}
using namespace b^b;
}
int main() {
aa::map m1; // We do not qualify this currently.
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69162/new/
https://reviews.llvm.org/D69162
More information about the cfe-commits
mailing list