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/llvm/lib/TextAPI/MachO/ArchitectureSet.cpp b/llvm/lib/TextAPI/MachO/ArchitectureSet.cpp
index c589671..a05d3eb 100644
--- a/llvm/lib/TextAPI/MachO/ArchitectureSet.cpp
+++ b/llvm/lib/TextAPI/MachO/ArchitectureSet.cpp
@@ -40,7 +40,7 @@
std::string result;
auto size = count();
for (auto arch : *this) {
- result.append(getArchitectureName(arch));
+ result.append(std::string(getArchitectureName(arch)));
size -= 1;
if (size)
result.append(" ");
diff --git a/llvm/lib/TextAPI/MachO/InterfaceFile.cpp b/llvm/lib/TextAPI/MachO/InterfaceFile.cpp
index c40a952..9f08456 100644
--- a/llvm/lib/TextAPI/MachO/InterfaceFile.cpp
+++ b/llvm/lib/TextAPI/MachO/InterfaceFile.cpp
@@ -63,7 +63,7 @@
Target RHS) { return LHS.first < RHS; });
if ((Iter != ParentUmbrellas.end()) && !(Target_ < Iter->first)) {
- Iter->second = Parent;
+ Iter->second = std::string(Parent);
return;
}
@@ -77,7 +77,7 @@
Target RHS) { return LHS.first < RHS; });
if ((Iter != UUIDs.end()) && !(Target_ < Iter->first)) {
- Iter->second = UUID;
+ Iter->second = std::string(UUID);
return;
}
diff --git a/llvm/lib/TextAPI/MachO/TextStub.cpp b/llvm/lib/TextAPI/MachO/TextStub.cpp
index 0584e43..cdfe7f4 100644
--- a/llvm/lib/TextAPI/MachO/TextStub.cpp
+++ b/llvm/lib/TextAPI/MachO/TextStub.cpp
@@ -1107,7 +1107,7 @@
Expected<std::unique_ptr<InterfaceFile>>
TextAPIReader::get(MemoryBufferRef InputBuffer) {
TextAPIContext Ctx;
- Ctx.Path = InputBuffer.getBufferIdentifier();
+ Ctx.Path = std::string(InputBuffer.getBufferIdentifier());
yaml::Input YAMLIn(InputBuffer.getBuffer(), &Ctx, DiagHandler, &Ctx);
// Fill vector with interface file objects created by parsing the YAML file.
@@ -1127,7 +1127,7 @@
Error TextAPIWriter::writeToStream(raw_ostream &OS, const InterfaceFile &File) {
TextAPIContext Ctx;
- Ctx.Path = File.getPath();
+ Ctx.Path = std::string(File.getPath());
Ctx.FileKind = File.getFileType();
llvm::yaml::Output YAMLOut(OS, &Ctx, /*WrapColumn=*/80);
diff --git a/llvm/lib/TextAPI/MachO/TextStubCommon.cpp b/llvm/lib/TextAPI/MachO/TextStubCommon.cpp
index a7fd58f..e4e58cd 100644
--- a/llvm/lib/TextAPI/MachO/TextStubCommon.cpp
+++ b/llvm/lib/TextAPI/MachO/TextStubCommon.cpp
@@ -215,7 +215,7 @@
auto UUID = Split.second.trim();
if (UUID.empty())
return "invalid uuid string pair";
- Value.second = UUID;
+ Value.second = std::string(UUID);
Value.first = Target{getArchitectureFromName(Arch), PlatformKind::unknown};
return {};
}