summaryrefslogtreecommitdiffstats
path: root/clang/lib/ASTMatchers/Dynamic/Parser.cpp
diff options
context:
space:
mode:
authorSamuel Benzaquen <sbenza@google.com>2013-10-21 18:40:51 +0000
committerSamuel Benzaquen <sbenza@google.com>2013-10-21 18:40:51 +0000
commitf46e5f1c9a75fa22d13c50e51c6b2e6158f9e825 (patch)
tree3a185a76bbaa1bec51f39f934c272558084a1007 /clang/lib/ASTMatchers/Dynamic/Parser.cpp
parent4517d598803dcac0e26363d5f3e32d0488ec799e (diff)
downloadbcm5719-llvm-f46e5f1c9a75fa22d13c50e51c6b2e6158f9e825.tar.gz
bcm5719-llvm-f46e5f1c9a75fa22d13c50e51c6b2e6158f9e825.zip
Refactor DynTypedMatcher into a value type class, just like Matcher<T>.
Summary: Refactor DynTypedMatcher into a value type class, just like Matcher<T>. This simplifies its usage and removes the virtual hierarchy from Matcher<T>. It also enables planned changes to replace MatcherInteface<T>. Too many instantiaions of this class hierarchy has been causing Registry.cpp.o to bloat in size and number of symbols. Reviewers: klimek CC: cfe-commits, revane Differential Revision: http://llvm-reviews.chandlerc.com/D1661 llvm-svn: 193100
Diffstat (limited to 'clang/lib/ASTMatchers/Dynamic/Parser.cpp')
-rw-r--r--clang/lib/ASTMatchers/Dynamic/Parser.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/clang/lib/ASTMatchers/Dynamic/Parser.cpp b/clang/lib/ASTMatchers/Dynamic/Parser.cpp
index 37e6c10478c..df9596e9b93 100644
--- a/clang/lib/ASTMatchers/Dynamic/Parser.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Parser.cpp
@@ -390,29 +390,29 @@ bool Parser::parseExpression(StringRef Code, Sema *S,
return true;
}
-DynTypedMatcher *Parser::parseMatcherExpression(StringRef Code,
- Diagnostics *Error) {
+llvm::Optional<DynTypedMatcher>
+Parser::parseMatcherExpression(StringRef Code, Diagnostics *Error) {
RegistrySema S;
return parseMatcherExpression(Code, &S, Error);
}
-DynTypedMatcher *Parser::parseMatcherExpression(StringRef Code,
- Parser::Sema *S,
- Diagnostics *Error) {
+llvm::Optional<DynTypedMatcher>
+Parser::parseMatcherExpression(StringRef Code, Parser::Sema *S,
+ Diagnostics *Error) {
VariantValue Value;
if (!parseExpression(Code, S, &Value, Error))
- return NULL;
+ return llvm::Optional<DynTypedMatcher>();
if (!Value.isMatcher()) {
Error->addError(SourceRange(), Error->ET_ParserNotAMatcher);
- return NULL;
+ return llvm::Optional<DynTypedMatcher>();
}
- const DynTypedMatcher *Result;
- if (!Value.getMatcher().getSingleMatcher(Result)) {
+ llvm::Optional<DynTypedMatcher> Result =
+ Value.getMatcher().getSingleMatcher();
+ if (!Result.hasValue()) {
Error->addError(SourceRange(), Error->ET_ParserOverloadedType)
<< Value.getTypeAsString();
- return NULL;
}
- return Result->clone();
+ return Result;
}
} // namespace dynamic
OpenPOWER on IntegriCloud