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/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index 9fcb36e..6b90c06 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -160,7 +160,7 @@
static std::string rewritePath(StringRef s) {
if (fs::exists(s))
return relativeToRoot(s);
- return s;
+ return std::string(s);
}
// Reconstructs command line arguments so that so that you can re-run
@@ -199,7 +199,7 @@
os << toString(*arg) << "\n";
}
}
- return data.str();
+ return std::string(data.str());
}
// Find a file by concatenating given paths. If a resulting path