diff options
| author | Gabor Horvath <xazax.hun@gmail.com> | 2016-05-04 11:59:39 +0000 |
|---|---|---|
| committer | Gabor Horvath <xazax.hun@gmail.com> | 2016-05-04 11:59:39 +0000 |
| commit | 1b3f8db8b6effddf363affce4f66da241d2234ff (patch) | |
| tree | 57e0867526ea9c13606283e065ebe38b7b48fa32 /clang/docs/LibASTMatchersReference.html | |
| parent | b7a29675fcd1802e06e3f03231fd53650f784822 (diff) | |
| download | bcm5719-llvm-1b3f8db8b6effddf363affce4f66da241d2234ff.tar.gz bcm5719-llvm-1b3f8db8b6effddf363affce4f66da241d2234ff.zip | |
[ASTMatchers] New matcher forFunction
Summary: Matcher proposed in the review of checker misc-assign-operator (name pending). Its goal is to find the direct enclosing function declaration of a statement and run the inner matcher on it. Two version is attached in this patch (thus it will not compile), to be decided which approach to take. The second one always chooses one single parent while the first one does a depth-first search upwards (thus a height-first search) and returns the first positive match of the inner matcher (thus it always returns zero or one matches, not more). Further questions: is it enough to implement it in-place, or ASTMatchersInternals or maybe ASTMatchFinder should be involved?
Reviewers: sbenza
Subscribers: aaron.ballman, klimek, o.gyorgy, xazax.hun, cfe-commits
Differential Revision: http://reviews.llvm.org/D19357
llvm-svn: 268490
Diffstat (limited to 'clang/docs/LibASTMatchersReference.html')
| -rw-r--r-- | clang/docs/LibASTMatchersReference.html | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index 0f474136ee2..d17a32d7a48 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -4923,6 +4923,20 @@ alignof. </pre></td></tr> +<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('forFunction0')"><a name="forFunction0Anchor">forFunction</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> InnerMatcher</td></tr> +<tr><td colspan="4" class="doc" id="forFunction0"><pre>Matches declaration of the function the statemenet belongs to + +Given: +F& operator=(const F& o) { + std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; }); + return *this; +} +returnStmt(forFunction(hasName("operator="))) + matches 'return *this' + but does match 'return > 0' +</pre></td></tr> + + <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('sizeOfExpr0')"><a name="sizeOfExpr0Anchor">sizeOfExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>> InnerMatcher</td></tr> <tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching sizeof. |

