diff options
author | Jonas Toth <development@jonas-toth.eu> | 2020-01-11 19:21:03 +0100 |
---|---|---|
committer | Jonas Toth <development@jonas-toth.eu> | 2020-01-11 19:21:03 +0100 |
commit | 4c48ea68e491cb42f1b5d43ffba89f6a7f0dadc4 (patch) | |
tree | b184cd10a71042c26bb53ece21203642d5eeca43 /clang/docs/LibASTMatchersReference.html | |
parent | 2bdf33cc4c733342fc83081bc7410ac5e9a24f55 (diff) | |
download | bcm5719-llvm-4c48ea68e491cb42f1b5d43ffba89f6a7f0dadc4.tar.gz bcm5719-llvm-4c48ea68e491cb42f1b5d43ffba89f6a7f0dadc4.zip |
[ASTMatchers] extract public matchers from const-analysis into own patch
Summary:
The analysis for const-ness of local variables required a view generally useful
matchers that are extracted into its own patch.
They are `decompositionDecl` and `forEachArgumentWithParamType`, that works
for calls through function pointers as well.
Reviewers: aaron.ballman
Reviewed By: aaron.ballman
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D72505
Diffstat (limited to 'clang/docs/LibASTMatchersReference.html')
-rw-r--r-- | clang/docs/LibASTMatchersReference.html | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index 5bb181b04d3..099462f17d2 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -635,6 +635,30 @@ Example matches a </pre></td></tr> +<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecompositionDecl.html">DecompositionDecl</a>></td><td class="name" onclick="toggle('decompositionDecl0')"><a name="decompositionDecl0Anchor">decompositionDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecompositionDecl.html">DecompositionDecl</a>>...</td></tr> +<tr><td colspan="4" class="doc" id="decompositionDecl0"><pre>Matches decomposition-declarations. + +Examples matches the declaration node with foo and bar, but not +number. +(matcher = declStmt(has(decompositionDecl()))) + + int number = 42; + auto [foo, bar] = std::make_pair{42, 42}; +</pre></td></tr> + + +<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecompositionDecl.html">DecompositionDecl</a>></td><td class="name" onclick="toggle('decompositionDecl0')"><a name="decompositionDecl0Anchor">decompositionDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecompositionDecl.html">DecompositionDecl</a>>...</td></tr> +<tr><td colspan="4" class="doc" id="decompositionDecl0"><pre>Matches decomposition-declarations. + +Examples matches the declaration node with foo and bar, but not +number. +(matcher = declStmt(has(decompositionDecl()))) + + int number = 42; + auto [foo, bar] = std::make_pair{42, 42}; +</pre></td></tr> + + <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>></td><td class="name" onclick="toggle('nestedNameSpecifierLoc0')"><a name="nestedNameSpecifierLoc0Anchor">nestedNameSpecifierLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>>...</td></tr> <tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. </pre></td></tr> @@ -4969,6 +4993,60 @@ and parmVarDecl(...) </pre></td></tr> +<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('forEachArgumentWithParamType1')"><a name="forEachArgumentWithParamType1Anchor">forEachArgumentWithParamType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> ArgMatcher, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> ParamMatcher</td></tr> +<tr><td colspan="4" class="doc" id="forEachArgumentWithParamType1"><pre>Matches all arguments and their respective types for a CallExpr or +CXXConstructExpr. It is very similar to forEachArgumentWithParam but +it works on calls through function pointers as well. + +The difference is, that function pointers do not provide access to a +ParmVarDecl, but only the QualType for each argument. + +Given + void f(int i); + int y; + f(y); + void (*f_ptr)(int) = f; + f_ptr(y); +callExpr( + forEachArgumentWithParamType( + declRefExpr(to(varDecl(hasName("y")))), + qualType(isInteger()).bind("type) +)) + matches f(y) and f_ptr(y) +with declRefExpr(...) + matching int y +and qualType(...) + matching int +</pre></td></tr> + + +<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('forEachArgumentWithParamType1')"><a name="forEachArgumentWithParamType1Anchor">forEachArgumentWithParamType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> ArgMatcher, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> ParamMatcher</td></tr> +<tr><td colspan="4" class="doc" id="forEachArgumentWithParamType1"><pre>Matches all arguments and their respective types for a CallExpr or +CXXConstructExpr. It is very similar to forEachArgumentWithParam but +it works on calls through function pointers as well. + +The difference is, that function pointers do not provide access to a +ParmVarDecl, but only the QualType for each argument. + +Given + void f(int i); + int y; + f(y); + void (*f_ptr)(int) = f; + f_ptr(y); +callExpr( + forEachArgumentWithParamType( + declRefExpr(to(varDecl(hasName("y")))), + qualType(isInteger()).bind("type) +)) + matches f(y) and f_ptr(y) +with declRefExpr(...) + matching int y +and qualType(...) + matching int +</pre></td></tr> + + <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasAnyArgument1')"><a name="hasAnyArgument1Anchor">hasAnyArgument</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> <tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call expression, or an ObjC-message-send expression. @@ -5447,6 +5525,60 @@ and parmVarDecl(...) </pre></td></tr> +<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('forEachArgumentWithParamType0')"><a name="forEachArgumentWithParamType0Anchor">forEachArgumentWithParamType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> ArgMatcher, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> ParamMatcher</td></tr> +<tr><td colspan="4" class="doc" id="forEachArgumentWithParamType0"><pre>Matches all arguments and their respective types for a CallExpr or +CXXConstructExpr. It is very similar to forEachArgumentWithParam but +it works on calls through function pointers as well. + +The difference is, that function pointers do not provide access to a +ParmVarDecl, but only the QualType for each argument. + +Given + void f(int i); + int y; + f(y); + void (*f_ptr)(int) = f; + f_ptr(y); +callExpr( + forEachArgumentWithParamType( + declRefExpr(to(varDecl(hasName("y")))), + qualType(isInteger()).bind("type) +)) + matches f(y) and f_ptr(y) +with declRefExpr(...) + matching int y +and qualType(...) + matching int +</pre></td></tr> + + +<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('forEachArgumentWithParamType0')"><a name="forEachArgumentWithParamType0Anchor">forEachArgumentWithParamType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> ArgMatcher, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> ParamMatcher</td></tr> +<tr><td colspan="4" class="doc" id="forEachArgumentWithParamType0"><pre>Matches all arguments and their respective types for a CallExpr or +CXXConstructExpr. It is very similar to forEachArgumentWithParam but +it works on calls through function pointers as well. + +The difference is, that function pointers do not provide access to a +ParmVarDecl, but only the QualType for each argument. + +Given + void f(int i); + int y; + f(y); + void (*f_ptr)(int) = f; + f_ptr(y); +callExpr( + forEachArgumentWithParamType( + declRefExpr(to(varDecl(hasName("y")))), + qualType(isInteger()).bind("type) +)) + matches f(y) and f_ptr(y) +with declRefExpr(...) + matching int y +and qualType(...) + matching int +</pre></td></tr> + + <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('hasAnyArgument0')"><a name="hasAnyArgument0Anchor">hasAnyArgument</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> <tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call expression, or an ObjC-message-send expression. |