Update Clang for 3.5 rebase (r209713).
Change-Id: I8c9133b0f8f776dc915f270b60f94962e771bc83
diff --git a/unittests/ASTMatchers/Dynamic/ParserTest.cpp b/unittests/ASTMatchers/Dynamic/ParserTest.cpp
index cdf4f92..4e3239f 100644
--- a/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ b/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -39,9 +39,7 @@
Errors.push_back(Error.toStringFull());
}
- llvm::Optional<MatcherCtor> lookupMatcherCtor(StringRef MatcherName,
- const SourceRange &NameRange,
- Diagnostics *Error) {
+ llvm::Optional<MatcherCtor> lookupMatcherCtor(StringRef MatcherName) {
const ExpectedMatchersTy::value_type *Matcher =
&*ExpectedMatchers.find(MatcherName);
return reinterpret_cast<MatcherCtor>(Matcher);
@@ -175,6 +173,29 @@
EXPECT_TRUE(matches("void f(int a, int x);", M));
EXPECT_FALSE(matches("void f(int x, int a);", M));
+ // Test named values.
+ struct NamedSema : public Parser::RegistrySema {
+ public:
+ virtual VariantValue getNamedValue(StringRef Name) {
+ if (Name == "nameX")
+ return std::string("x");
+ if (Name == "param0")
+ return VariantMatcher::SingleMatcher(hasParameter(0, hasName("a")));
+ return VariantValue();
+ }
+ };
+ NamedSema Sema;
+ llvm::Optional<DynTypedMatcher> HasParameterWithNamedValues(
+ Parser::parseMatcherExpression(
+ "functionDecl(param0, hasParameter(1, hasName(nameX)))", &Sema,
+ &Error));
+ EXPECT_EQ("", Error.toStringFull());
+ M = HasParameterWithNamedValues->unconditionalConvertTo<Decl>();
+
+ EXPECT_TRUE(matches("void f(int a, int x);", M));
+ EXPECT_FALSE(matches("void f(int x, int a);", M));
+
+
EXPECT_TRUE(!Parser::parseMatcherExpression(
"hasInitializer(\n binaryOperator(hasLHS(\"A\")))",
&Error).hasValue());
@@ -208,6 +229,10 @@
"1:9: Error parsing matcher. Found token <123> while looking for ','.",
ParseWithError("Foo(\"A\" 123)"));
EXPECT_EQ(
+ "1:1: Error parsing argument 1 for matcher stmt.\n"
+ "1:6: Value not found: someValue",
+ ParseWithError("stmt(someValue)"));
+ EXPECT_EQ(
"1:1: Matcher not found: Foo\n"
"1:4: Error parsing matcher. Found end-of-code while looking for ')'.",
ParseWithError("Foo("));
@@ -232,7 +257,7 @@
"1:1: Matcher does not support binding.",
ParseWithError("isArrow().bind(\"foo\")"));
EXPECT_EQ("Input value has unresolved overloaded type: "
- "Matcher<DoStmt|ForStmt|WhileStmt>",
+ "Matcher<DoStmt|ForStmt|WhileStmt|CXXForRangeStmt>",
ParseMatcherWithError("hasBody(stmt())"));
}