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/AST/DeclPrinterTest.cpp b/clang/unittests/AST/DeclPrinterTest.cpp
index 5a0a804..3bb17ab 100644
--- a/clang/unittests/AST/DeclPrinterTest.cpp
+++ b/clang/unittests/AST/DeclPrinterTest.cpp
@@ -108,12 +108,9 @@
StringRef ExpectedPrinted,
PrintingPolicyModifier PolicyModifier = nullptr) {
std::vector<std::string> Args(1, "-std=c++98");
- return PrintedDeclMatches(Code,
- Args,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted,
- "input.cc",
- PolicyModifier);
+ return PrintedDeclMatches(
+ Code, Args, namedDecl(hasName(std::string(DeclName))).bind("id"),
+ ExpectedPrinted, "input.cc", PolicyModifier);
}
::testing::AssertionResult
@@ -133,11 +130,9 @@
StringRef DeclName,
StringRef ExpectedPrinted) {
std::vector<std::string> Args(1, "-std=c++11");
- return PrintedDeclMatches(Code,
- Args,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted,
- "input.cc");
+ return PrintedDeclMatches(
+ Code, Args, namedDecl(hasName(std::string(DeclName))).bind("id"),
+ ExpectedPrinted, "input.cc");
}
::testing::AssertionResult PrintedDeclCXX11Matches(