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/lib/Basic/Warnings.cpp b/clang/lib/Basic/Warnings.cpp
index 88ef2ea..2c909d9 100644
--- a/clang/lib/Basic/Warnings.cpp
+++ b/clang/lib/Basic/Warnings.cpp
@@ -36,8 +36,9 @@
StringRef Opt) {
StringRef Suggestion = DiagnosticIDs::getNearestOption(Flavor, Opt);
Diags.Report(diag::warn_unknown_diag_option)
- << (Flavor == diag::Flavor::WarningOrError ? 0 : 1) << (Prefix.str() += Opt)
- << !Suggestion.empty() << (Prefix.str() += Suggestion);
+ << (Flavor == diag::Flavor::WarningOrError ? 0 : 1)
+ << (Prefix.str() += std::string(Opt)) << !Suggestion.empty()
+ << (Prefix.str() += std::string(Suggestion));
}
void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,