[ASTMatchers] StringRef'ify hasName
This was just inconvenient, and we make a copy anyways.
diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp
index 8c3dc6c..3e8f804 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -115,8 +115,8 @@
const BindableMatcher<NodeType> &VerificationMatcher) {
return testImport(
FromCode, FromArgs, ToCode, ToArgs, Verifier,
- translationUnitDecl(has(namedDecl(hasName(std::string(DeclToImportID)))
- .bind(DeclToImportID))),
+ translationUnitDecl(
+ has(namedDecl(hasName(DeclToImportID)).bind(DeclToImportID))),
VerificationMatcher);
}
diff --git a/clang/unittests/AST/DeclPrinterTest.cpp b/clang/unittests/AST/DeclPrinterTest.cpp
index 3bb17ab..f85358b 100644
--- a/clang/unittests/AST/DeclPrinterTest.cpp
+++ b/clang/unittests/AST/DeclPrinterTest.cpp
@@ -108,9 +108,8 @@
StringRef ExpectedPrinted,
PrintingPolicyModifier PolicyModifier = nullptr) {
std::vector<std::string> Args(1, "-std=c++98");
- return PrintedDeclMatches(
- Code, Args, namedDecl(hasName(std::string(DeclName))).bind("id"),
- ExpectedPrinted, "input.cc", PolicyModifier);
+ return PrintedDeclMatches(Code, Args, namedDecl(hasName(DeclName)).bind("id"),
+ ExpectedPrinted, "input.cc", PolicyModifier);
}
::testing::AssertionResult
@@ -130,9 +129,8 @@
StringRef DeclName,
StringRef ExpectedPrinted) {
std::vector<std::string> Args(1, "-std=c++11");
- return PrintedDeclMatches(
- Code, Args, namedDecl(hasName(std::string(DeclName))).bind("id"),
- ExpectedPrinted, "input.cc");
+ return PrintedDeclMatches(Code, Args, namedDecl(hasName(DeclName)).bind("id"),
+ ExpectedPrinted, "input.cc");
}
::testing::AssertionResult PrintedDeclCXX11Matches(
diff --git a/clang/unittests/AST/NamedDeclPrinterTest.cpp b/clang/unittests/AST/NamedDeclPrinterTest.cpp
index d5077b8..a38b28b 100644
--- a/clang/unittests/AST/NamedDeclPrinterTest.cpp
+++ b/clang/unittests/AST/NamedDeclPrinterTest.cpp
@@ -112,45 +112,41 @@
PrintedNamedDeclCXX98Matches(StringRef Code, StringRef DeclName,
StringRef ExpectedPrinted) {
std::vector<std::string> Args(1, "-std=c++98");
- return PrintedNamedDeclMatches(
- Code, Args,
- /*SuppressUnwrittenScope*/ false,
- namedDecl(hasName(std::string(DeclName))).bind("id"), ExpectedPrinted,
- "input.cc");
+ return PrintedNamedDeclMatches(Code, Args,
+ /*SuppressUnwrittenScope*/ false,
+ namedDecl(hasName(DeclName)).bind("id"),
+ ExpectedPrinted, "input.cc");
}
::testing::AssertionResult
PrintedWrittenNamedDeclCXX11Matches(StringRef Code, StringRef DeclName,
StringRef ExpectedPrinted) {
std::vector<std::string> Args(1, "-std=c++11");
- return PrintedNamedDeclMatches(
- Code, Args,
- /*SuppressUnwrittenScope*/ true,
- namedDecl(hasName(std::string(DeclName))).bind("id"), ExpectedPrinted,
- "input.cc");
+ return PrintedNamedDeclMatches(Code, Args,
+ /*SuppressUnwrittenScope*/ true,
+ namedDecl(hasName(DeclName)).bind("id"),
+ ExpectedPrinted, "input.cc");
}
::testing::AssertionResult
PrintedWrittenPropertyDeclObjCMatches(StringRef Code, StringRef DeclName,
StringRef ExpectedPrinted) {
std::vector<std::string> Args{"-std=c++11", "-xobjective-c++"};
- return PrintedNamedDeclMatches(
- Code, Args,
- /*SuppressUnwrittenScope*/ true,
- objcPropertyDecl(hasName(std::string(DeclName))).bind("id"),
- ExpectedPrinted, "input.m");
+ return PrintedNamedDeclMatches(Code, Args,
+ /*SuppressUnwrittenScope*/ true,
+ objcPropertyDecl(hasName(DeclName)).bind("id"),
+ ExpectedPrinted, "input.m");
}
::testing::AssertionResult
PrintedNestedNameSpecifierMatches(StringRef Code, StringRef DeclName,
StringRef ExpectedPrinted) {
std::vector<std::string> Args{"-std=c++11"};
- return PrintedDeclMatches(
- Code, Args, namedDecl(hasName(std::string(DeclName))).bind("id"),
- ExpectedPrinted, "input.cc",
- [](llvm::raw_ostream &Out, const NamedDecl *D) {
- D->printNestedNameSpecifier(Out);
- });
+ return PrintedDeclMatches(Code, Args, namedDecl(hasName(DeclName)).bind("id"),
+ ExpectedPrinted, "input.cc",
+ [](llvm::raw_ostream &Out, const NamedDecl *D) {
+ D->printNestedNameSpecifier(Out);
+ });
}
} // unnamed namespace
diff --git a/clang/unittests/AST/StmtPrinterTest.cpp b/clang/unittests/AST/StmtPrinterTest.cpp
index 76195af..080c18b 100644
--- a/clang/unittests/AST/StmtPrinterTest.cpp
+++ b/clang/unittests/AST/StmtPrinterTest.cpp
@@ -34,7 +34,7 @@
enum class StdVer { CXX98, CXX11, CXX14, CXX17, CXX2a };
DeclarationMatcher FunctionBodyMatcher(StringRef ContainingFunction) {
- return functionDecl(hasName(std::string(ContainingFunction)),
+ return functionDecl(hasName(ContainingFunction),
has(compoundStmt(has(stmt().bind("id")))));
}
diff --git a/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp b/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
index b24ec07..1c3e00c 100644
--- a/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ b/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -44,7 +44,7 @@
}
ExprMatcher declRefTo(StringRef Name) {
- return declRefExpr(to(namedDecl(hasName(std::string(Name)))));
+ return declRefExpr(to(namedDecl(hasName(Name))));
}
StmtMatcher withEnclosingCompound(ExprMatcher Matcher) {
diff --git a/clang/unittests/StaticAnalyzer/Reusables.h b/clang/unittests/StaticAnalyzer/Reusables.h
index db9c085..bac2808 100644
--- a/clang/unittests/StaticAnalyzer/Reusables.h
+++ b/clang/unittests/StaticAnalyzer/Reusables.h
@@ -34,7 +34,7 @@
template <typename T>
const T *findDeclByName(const Decl *Where, StringRef Name) {
using namespace ast_matchers;
- return findNode<T>(Where, namedDecl(hasName(std::string(Name))));
+ return findNode<T>(Where, namedDecl(hasName(Name)));
}
// A re-usable consumer that constructs ExprEngine out of CompilerInvocation.