diff options
| author | Eric Liu <ioeric@google.com> | 2017-01-26 16:31:32 +0000 |
|---|---|---|
| committer | Eric Liu <ioeric@google.com> | 2017-01-26 16:31:32 +0000 |
| commit | 9122916ee539cc79a58e428fdd60237a53298c5c (patch) | |
| tree | 3c342e8b5f7b2003c9794b44c19a19f9138eab62 /clang-tools-extra/change-namespace/ChangeNamespace.cpp | |
| parent | c4540b371de372dca730ecba16d1638abb69bbf0 (diff) | |
| download | bcm5719-llvm-9122916ee539cc79a58e428fdd60237a53298c5c.tar.gz bcm5719-llvm-9122916ee539cc79a58e428fdd60237a53298c5c.zip | |
[change-namespace] correctly shorten namespace when references have leading '::'
Reviewers: bkramer
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D29182
llvm-svn: 293187
Diffstat (limited to 'clang-tools-extra/change-namespace/ChangeNamespace.cpp')
| -rw-r--r-- | clang-tools-extra/change-namespace/ChangeNamespace.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/clang-tools-extra/change-namespace/ChangeNamespace.cpp b/clang-tools-extra/change-namespace/ChangeNamespace.cpp index 1e60dbdf5a5..2f234da0887 100644 --- a/clang-tools-extra/change-namespace/ChangeNamespace.cpp +++ b/clang-tools-extra/change-namespace/ChangeNamespace.cpp @@ -703,9 +703,6 @@ void ChangeNamespaceTool::replaceQualifiedSymbolInDeclContext( Result.SourceManager->getSpellingLoc(Start), Result.SourceManager->getSpellingLoc(End)), *Result.SourceManager, Result.Context->getLangOpts()); - // If the symbol is already fully qualified, no change needs to be make. - if (NestedName.startswith("::")) - return; std::string FromDeclName = FromDecl->getQualifiedNameAsString(); std::string ReplaceName = getShortestQualifiedNameInNamespace(FromDeclName, NewNs); @@ -774,7 +771,8 @@ void ChangeNamespaceTool::replaceQualifiedSymbolInDeclContext( } // If the new nested name in the new namespace is the same as it was in the // old namespace, we don't create replacement. - if (NestedName == ReplaceName) + if (NestedName == ReplaceName || + (NestedName.startswith("::") && NestedName.drop_front(2) == ReplaceName)) return; // If the reference need to be fully-qualified, add a leading "::" unless // NewNamespace is the global namespace. |

