summaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-move
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2020-01-28 20:23:46 +0100
committerBenjamin Kramer <benny.kra@googlemail.com>2020-01-28 23:25:25 +0100
commitadcd02683856c30ba6f349279509acecd90063df (patch)
tree7b5927ef2ecab1618842183fac5ebe848f5832dd /clang-tools-extra/clang-move
parent5eaf44f99f0a0a3bdfa892892b8aaca841c8dbe0 (diff)
downloadllvm-adcd02683856c30ba6f349279509acecd90063df.tar.gz
Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
Diffstat (limited to 'clang-tools-extra/clang-move')
-rw-r--r--clang-tools-extra/clang-move/Move.cpp8
-rw-r--r--clang-tools-extra/clang-move/tool/ClangMove.cpp3
2 files changed, 6 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-move/Move.cpp b/clang-tools-extra/clang-move/Move.cpp
index 14052178fba2..ebeb5d001920 100644
--- a/clang-tools-extra/clang-move/Move.cpp
+++ b/clang-tools-extra/clang-move/Move.cpp
@@ -65,7 +65,7 @@ std::string CleanPath(StringRef PathRef) {
llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
// FIXME: figure out why this is necessary.
llvm::sys::path::native(Path);
- return Path.str();
+ return std::string(Path.str());
}
// Make the Path absolute using the CurrentDir if the Path is not an absolute
@@ -785,13 +785,13 @@ void ClangMoveTool::removeDeclsInOldFiles() {
continue;
}
auto CleanReplacements = format::cleanupAroundReplacements(
- Code, Context->FileToReplacements[FilePath], *Style);
+ Code, Context->FileToReplacements[std::string(FilePath)], *Style);
if (!CleanReplacements) {
llvm::errs() << llvm::toString(CleanReplacements.takeError()) << "\n";
continue;
}
- Context->FileToReplacements[FilePath] = *CleanReplacements;
+ Context->FileToReplacements[std::string(FilePath)] = *CleanReplacements;
}
}
@@ -870,7 +870,7 @@ void ClangMoveTool::moveAll(SourceManager &SM, StringRef OldFile,
else if (Context->Spec.NewHeader == NewFile &&
OldHeaderIncludeRangeInHeader.isValid())
ReplaceOldInclude(OldHeaderIncludeRangeInHeader);
- Context->FileToReplacements[NewFile] = std::move(AllCode);
+ Context->FileToReplacements[std::string(NewFile)] = std::move(AllCode);
}
}
diff --git a/clang-tools-extra/clang-move/tool/ClangMove.cpp b/clang-tools-extra/clang-move/tool/ClangMove.cpp
index 214c4f616ba6..7e16dc2b3b94 100644
--- a/clang-tools-extra/clang-move/tool/ClangMove.cpp
+++ b/clang-tools-extra/clang-move/tool/ClangMove.cpp
@@ -124,7 +124,8 @@ int main(int argc, const char **argv) {
Twine(EC.message()));
move::ClangMoveContext Context{Spec, Tool.getReplacements(),
- InitialDirectory.str(), Style, DumpDecls};
+ std::string(InitialDirectory.str()), Style,
+ DumpDecls};
move::DeclarationReporter Reporter;
move::ClangMoveActionFactory Factory(&Context, &Reporter);