Changeset View
Changeset View
Standalone View
Standalone View
clang/docs/LibASTMatchersReference.html
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 3,911 Lines • ▼ Show 20 Lines | |||||
For example, the array bound of "Chars" in the following example is | For example, the array bound of "Chars" in the following example is | ||||
value-dependent. | value-dependent. | ||||
template<int Size> int f() { return Size; } | template<int Size> int f() { return Size; } | ||||
expr(isValueDependent()) matches return Size | expr(isValueDependent()) matches return Size | ||||
</pre></td></tr> | </pre></td></tr> | ||||
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('nullPointerConstant0')"><a name="nullPointerConstant0Anchor">nullPointerConstant</a></td><td></td></tr> | |||||
<tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as | |||||
GNU's __null, C++11's nullptr, or C's NULL macro. | |||||
Given: | |||||
void *v1 = NULL; | |||||
void *v2 = nullptr; | |||||
void *v3 = __null; // GNU extension | |||||
char *cp = (char *)0; | |||||
int *ip = 0; | |||||
int i = 0; | |||||
expr(nullPointerConstant()) | |||||
matches the initializer for v1, v2, v3, cp, and ip. Does not match the | |||||
initializer for i. | |||||
</pre></td></tr> | |||||
<tr><td>Matcher<<a href="https://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>Matcher<<a href="https://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 | <tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified | ||||
bit width. | bit width. | ||||
Given | Given | ||||
class C { | class C { | ||||
int a : 2; | int a : 2; | ||||
int b : 4; | int b : 4; | ||||
▲ Show 20 Lines • Show All 1,088 Lines • ▼ Show 20 Lines | |||||
declStmt(isInTemplateInstantiation()) | declStmt(isInTemplateInstantiation()) | ||||
matches 'int i;' and 'unsigned i'. | matches 'int i;' and 'unsigned i'. | ||||
unless(stmt(isInTemplateInstantiation())) | unless(stmt(isInTemplateInstantiation())) | ||||
will NOT match j += 42; as it's shared between the template definition and | will NOT match j += 42; as it's shared between the template definition and | ||||
instantiation. | instantiation. | ||||
</pre></td></tr> | </pre></td></tr> | ||||
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('nullPointerConstant0')"><a name="nullPointerConstant0Anchor">nullPointerConstant</a></td><td></td></tr> | |||||
<tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as | |||||
GNU's __null, C++11's nullptr, or C's NULL macro. | |||||
Given: | |||||
void *v1 = NULL; | |||||
void *v2 = nullptr; | |||||
void *v3 = __null; // GNU extension | |||||
char *cp = (char *)0; | |||||
int *ip = 0; | |||||
int i = 0; | |||||
nullPointerConstant() | |||||
matches the initializer for v1, v2, v3, cp, and ip. Does not match the | |||||
initializer for i. | |||||
</pre></td></tr> | |||||
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral</a>></td><td class="name" onclick="toggle('hasSize1')"><a name="hasSize1Anchor">hasSize</a></td><td>unsigned N</td></tr> | <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral</a>></td><td class="name" onclick="toggle('hasSize1')"><a name="hasSize1Anchor">hasSize</a></td><td>unsigned N</td></tr> | ||||
<tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size. | <tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size. | ||||
Given | Given | ||||
int a[42]; | int a[42]; | ||||
int b[2 * 21]; | int b[2 * 21]; | ||||
int c[41], d[43]; | int c[41], d[43]; | ||||
char *s = "abcd"; | char *s = "abcd"; | ||||
▲ Show 20 Lines • Show All 3,900 Lines • Show Last 20 Lines |