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.
diff --git a/clang/unittests/libclang/TestUtils.h b/clang/unittests/libclang/TestUtils.h
index 883155e..347fa46 100644
--- a/clang/unittests/libclang/TestUtils.h
+++ b/clang/unittests/libclang/TestUtils.h
@@ -34,7 +34,7 @@
void SetUp() override {
llvm::SmallString<256> Dir;
ASSERT_FALSE(llvm::sys::fs::createUniqueDirectory("libclang-test", Dir));
- TestDir = Dir.str();
+ TestDir = std::string(Dir.str());
TUFlags = CXTranslationUnit_DetailedPreprocessingRecord |
clang_defaultEditingTranslationUnitOptions();
Index = clang_createIndex(0, 0);
@@ -51,7 +51,7 @@
if (!llvm::sys::path::is_absolute(Filename)) {
llvm::SmallString<256> Path(TestDir);
llvm::sys::path::append(Path, Filename);
- Filename = Path.str();
+ Filename = std::string(Path.str());
Files.insert(Filename);
}
llvm::sys::fs::create_directories(llvm::sys::path::parent_path(Filename));
@@ -63,7 +63,7 @@
if (!llvm::sys::path::is_absolute(Filename)) {
llvm::SmallString<256> Path(TestDir);
llvm::sys::path::append(Path, Filename);
- Filename = Path.str();
+ Filename = std::string(Path.str());
}
auto it = UnsavedFileContents.insert(std::make_pair(
fixed_addr_string(new std::string(Filename)),