diff options
author | Samuel Benzaquen <sbenza@google.com> | 2013-11-22 14:41:48 +0000 |
---|---|---|
committer | Samuel Benzaquen <sbenza@google.com> | 2013-11-22 14:41:48 +0000 |
commit | 4d05874ba2e1a7116c1eac22ab0eca537795cb75 (patch) | |
tree | e2a35f80fff4d5655fda9c3e312bd23a58964583 /clang/lib/ASTMatchers/ASTMatchersInternal.cpp | |
parent | bf9b24edc3d62989e420d6ea0b1cf1ae8f6bcac3 (diff) | |
download | bcm5719-llvm-4d05874ba2e1a7116c1eac22ab0eca537795cb75.tar.gz bcm5719-llvm-4d05874ba2e1a7116c1eac22ab0eca537795cb75.zip |
Add support for the 'unless' matcher in the dynamic layer.
Summary: Add support for the 'unless' matcher in the dynamic layer.
Reviewers: klimek
CC: cfe-commits, revane, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D2247
llvm-svn: 195466
Diffstat (limited to 'clang/lib/ASTMatchers/ASTMatchersInternal.cpp')
-rw-r--r-- | clang/lib/ASTMatchers/ASTMatchersInternal.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp index d15eb54002f..47b8b6d2f27 100644 --- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp +++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -34,6 +34,26 @@ void BoundNodesTreeBuilder::addMatch(const BoundNodesTreeBuilder &Other) { } } +bool NotUnaryOperator(const ast_type_traits::DynTypedNode DynNode, + ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder, + ArrayRef<DynTypedMatcher> InnerMatchers) { + if (InnerMatchers.size() != 1) + return false; + + // The 'unless' matcher will always discard the result: + // If the inner matcher doesn't match, unless returns true, + // but the inner matcher cannot have bound anything. + // If the inner matcher matches, the result is false, and + // any possible binding will be discarded. + // We still need to hand in all the bound nodes up to this + // point so the inner matcher can depend on bound nodes, + // and we need to actively discard the bound nodes, otherwise + // the inner matcher will reset the bound nodes if it doesn't + // match, but this would be inversed by 'unless'. + BoundNodesTreeBuilder Discard(*Builder); + return !InnerMatchers[0].matches(DynNode, Finder, &Discard); +} + bool AllOfVariadicOperator(const ast_type_traits::DynTypedNode DynNode, ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder, |