summaryrefslogtreecommitdiff
path: root/clang-tools-extra/change-namespace
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2016-12-05 11:17:04 +0000
committerEric Liu <ioeric@google.com>2016-12-05 11:17:04 +0000
commit121b31d79ff368dd89b32cac4ecf879ba38225de (patch)
tree7b7a7ecb91ca7c1d9b7cd6698c4c28a821443969 /clang-tools-extra/change-namespace
parentf31b964edc06f40ea35437423c04d9b868b73d75 (diff)
[change-namespace] get changing namespace to global correct.
Diffstat (limited to 'clang-tools-extra/change-namespace')
-rw-r--r--clang-tools-extra/change-namespace/ChangeNamespace.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang-tools-extra/change-namespace/ChangeNamespace.cpp b/clang-tools-extra/change-namespace/ChangeNamespace.cpp
index 7de4690ac11..c0a8fe0370e 100644
--- a/clang-tools-extra/change-namespace/ChangeNamespace.cpp
+++ b/clang-tools-extra/change-namespace/ChangeNamespace.cpp
@@ -210,7 +210,8 @@ std::string wrapCodeInNamespace(StringRef NestedNs, std::string Code) {
if (Code.back() != '\n')
Code += "\n";
llvm::SmallVector<StringRef, 4> NsSplitted;
- NestedNs.split(NsSplitted, "::");
+ NestedNs.split(NsSplitted, "::", /*MaxSplit=*/-1,
+ /*KeepEmpty=*/false);
while (!NsSplitted.empty()) {
// FIXME: consider code style for comments.
Code = ("namespace " + NsSplitted.back() + " {\n" + Code +
@@ -272,7 +273,9 @@ void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
// be "a::b". Declarations in this namespace will not be visible in the new
// namespace. If DiffOldNamespace is empty, Prefix will be a invalid name "-".
llvm::SmallVector<llvm::StringRef, 4> DiffOldNsSplitted;
- llvm::StringRef(DiffOldNamespace).split(DiffOldNsSplitted, "::");
+ llvm::StringRef(DiffOldNamespace)
+ .split(DiffOldNsSplitted, "::", /*MaxSplit=*/-1,
+ /*KeepEmpty=*/false);
std::string Prefix = "-";
if (!DiffOldNsSplitted.empty())
Prefix = (StringRef(FullOldNs).drop_back(DiffOldNamespace.size()) +