Revert "Refactor DynTypedMatcher into a value type class, just like Matcher<T>."
This reverts commit r193100.
It was failing to compile with MSVC 2012 while instantiating
llvm::Optional<DynTypedMatcher>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193123 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/ASTMatchers/Dynamic/Parser.cpp b/lib/ASTMatchers/Dynamic/Parser.cpp
index df9596e..37e6c10 100644
--- a/lib/ASTMatchers/Dynamic/Parser.cpp
+++ b/lib/ASTMatchers/Dynamic/Parser.cpp
@@ -390,29 +390,29 @@
return true;
}
-llvm::Optional<DynTypedMatcher>
-Parser::parseMatcherExpression(StringRef Code, Diagnostics *Error) {
+DynTypedMatcher *Parser::parseMatcherExpression(StringRef Code,
+ Diagnostics *Error) {
RegistrySema S;
return parseMatcherExpression(Code, &S, Error);
}
-llvm::Optional<DynTypedMatcher>
-Parser::parseMatcherExpression(StringRef Code, Parser::Sema *S,
- Diagnostics *Error) {
+DynTypedMatcher *Parser::parseMatcherExpression(StringRef Code,
+ Parser::Sema *S,
+ Diagnostics *Error) {
VariantValue Value;
if (!parseExpression(Code, S, &Value, Error))
- return llvm::Optional<DynTypedMatcher>();
+ return NULL;
if (!Value.isMatcher()) {
Error->addError(SourceRange(), Error->ET_ParserNotAMatcher);
- return llvm::Optional<DynTypedMatcher>();
+ return NULL;
}
- llvm::Optional<DynTypedMatcher> Result =
- Value.getMatcher().getSingleMatcher();
- if (!Result.hasValue()) {
+ const DynTypedMatcher *Result;
+ if (!Value.getMatcher().getSingleMatcher(Result)) {
Error->addError(SourceRange(), Error->ET_ParserOverloadedType)
<< Value.getTypeAsString();
+ return NULL;
}
- return Result;
+ return Result->clone();
}
} // namespace dynamic