diff options
author | Jonas Toth <jonas.toth@gmail.com> | 2018-09-11 16:09:19 +0000 |
---|---|---|
committer | Jonas Toth <jonas.toth@gmail.com> | 2018-09-11 16:09:19 +0000 |
commit | 0a8a76da18b28bea9500c5f4539fe9c65075b4ac (patch) | |
tree | dd10e2c013b6673a07fd19d35e955da927ae0ca5 /docs/LibASTMatchersReference.html | |
parent | 7dfb64163cbc0a4ba1286a679dec3eab1e79ad2d (diff) |
[ASTMatchers] add three matchers for dependent expressions
Summary:
The new matchers can be used to check if an expression is type-, value- or instantiation-dependent
in a templated context.
These matchers are used in a clang-tidy check and generally useful as the
problem of unresolved templates occurs more often in clang-tidy and they
provide an easy way to check for this issue.
Reviewers: aaron.ballman, alexfh, klimek
Reviewed By: aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D51880
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341958 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/LibASTMatchersReference.html')
-rw-r--r-- | docs/LibASTMatchersReference.html | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/docs/LibASTMatchersReference.html b/docs/LibASTMatchersReference.html index ae44662489..68a1ab5915 100644 --- a/docs/LibASTMatchersReference.html +++ b/docs/LibASTMatchersReference.html @@ -2758,6 +2758,46 @@ enum class Y {}; </pre></td></tr> +<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('isInstantiationDependent0')"><a name="isInstantiationDependent0Anchor">isInstantiationDependent</a></td><td></td></tr> +<tr><td colspan="4" class="doc" id="isInstantiationDependent0"><pre>Matches expressions that are instantiation-dependent even if it is +neither type- nor value-dependent. + +In the following example, the expression sizeof(sizeof(T() + T())) +is instantiation-dependent (since it involves a template parameter T), +but is neither type- nor value-dependent, since the type of the inner +sizeof is known (std::size_t) and therefore the size of the outer +sizeof is known. + template<typename T> + void f(T x, T y) { sizeof(sizeof(T() + T()); } +expr(isInstantiationDependent()) matches sizeof(sizeof(T() + T()) +</pre></td></tr> + + +<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('isTypeDependent0')"><a name="isTypeDependent0Anchor">isTypeDependent</a></td><td></td></tr> +<tr><td colspan="4" class="doc" id="isTypeDependent0"><pre>Matches expressions that are type-dependent because the template type +is not yet instantiated. + +For example, the expressions "x" and "x + y" are type-dependent in +the following code, but "y" is not type-dependent: + template<typename T> + void add(T x, int y) { + x + y; + } +expr(isTypeDependent()) matches x + y +</pre></td></tr> + + +<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('isValueDependent0')"><a name="isValueDependent0Anchor">isValueDependent</a></td><td></td></tr> +<tr><td colspan="4" class="doc" id="isValueDependent0"><pre>Matches expression that are value-dependent because they contain a +non-type template parameter. + +For example, the array bound of "Chars" in the following example is +value-dependent. + template<int Size> int f() { return Size; } +expr(isValueDependent()) matches return Size +</pre></td></tr> + + <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>></td><td class="name" onclick="toggle('hasBitWidth0')"><a name="hasBitWidth0Anchor">hasBitWidth</a></td><td>unsigned Width</td></tr> <tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified bit width. |