[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 20 01:31:12 PDT 2016


hokein added inline comments.


================
Comment at: change-namespace/ChangeNamespace.cpp:566
+      break;
+    if (isDeclVisibleAtLocation(*Result.SourceManager, Using, DeclCtx, Start)) {
+      for (const auto *UsingShadow : Using->shadows()) {
----------------
Yeah, it works for most cases, but it can not guarantee that they are still in the same DeclContext after changing to new namespace.

For example, the following case where an using-decl is used in the namespace being renamed, we change `b::c` to `d::e`, although DeclContext `d` of callexpr `f()` is a nested DeclContext of `b` (also DeclContext of `using a::f`), but this assumption is wrong after changing namespace because we keep `using a::f` in its original namespace.

```
namespace a { void f(); }

namespace b {
using a::f;
namespace c {
void d() { f(); }
}  // c
} // b
```

Not sure whether we should do this in our tool. I suspect there might be a lot of corner cases.



https://reviews.llvm.org/D25771





More information about the cfe-commits mailing list