[PATCH] D30493: [change-namespace] avoid adding leading '::' when possible.

Eric Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 17 06:23:46 PDT 2017

ioeric added inline comments.

Comment at: change-namespace/ChangeNamespace.cpp:291
+  assert(!SymbolSplitted.empty());
+  SymbolSplitted.pop_back();
hokein wrote:
> Is this needed? Looks like you are removing the name of the symbol here, but from the code below, you only use the first element of it.  The QualifiedSymbol should always be a fully-qualified name with at least 1 namespace qualifier in the code, right?
`QualifiedSymbol` can be in the global namespace, so `SymbolSplitted` could be empty after `pop_back`.

Comment at: change-namespace/ChangeNamespace.cpp:296
+    assert(!NsSplitted.empty());
+    for (auto I = NsSplitted.begin() + 1, E = NsSplitted.end(); I != E; ++I) {
+      if (*I == SymbolSplitted.front())
hokein wrote:
> Why skipping the first element? And use `is_contained` instead?
See newly added comments for reasoning.


More information about the cfe-commits mailing list