int X;
namespace NS {
int Y;
- } namespace NS
+ } // namespace NS
decl(hasDeclContext(translationUnitDecl()))
matches "int X", but not "int Y".
</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('floatLiteral0')"><a name="floatLiteral0Anchor">floatLiteral</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>...</td></tr>
-<tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes encodings, e.g.
+<tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes / encodings, e.g.
1.0, 1.0f, 1.0L and 1e10.
Does not match implicit conversions such as
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('integerLiteral0')"><a name="integerLiteral0Anchor">integerLiteral</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>>...</td></tr>
-<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings, e.g.
+<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes / encodings, e.g.
1, 1L, 0x1 and 1U.
Does not match character-encoded integers such as L'a'.
template <typename T>
class C { };
- template class C<int>; A
- C<char> var; B
+ template class C<int>; // A
+ C<char> var; // B
templateSpecializationType() matches the type of the explicit
instantiation in A and the type of the variable declaration in B.
Given
try {
- ...
+ // ...
} catch (int) {
- ...
+ // ...
} catch (...) {
- ...
+ // ...
}
-endcode
cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
</pre></td></tr>
Given
struct S {
- S(); #1
- S(const S &); #2
- S(S &&); #3
+ S(); // #1
+ S(const S &); // #2
+ S(S &&); // #3
};
cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.
</pre></td></tr>
Given
struct S {
- S(); #1
- S(const S &); #2
- S(S &&); #3
+ S(); // #1
+ S(const S &); // #2
+ S(S &&); // #3
};
cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.
</pre></td></tr>
Given
struct S {
- S(); #1
- S(int) {} #2
- S(S &&) : S() {} #3
+ S(); // #1
+ S(int) {} // #2
+ S(S &&) : S() {} // #3
};
- S::S() : S(0) {} #4
+ S::S() : S(0) {} // #4
cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not
#1 or #2.
</pre></td></tr>
Given
struct S {
- S(int); #1
- explicit S(double); #2
- operator int(); #3
- explicit operator bool(); #4
+ S(int); // #1
+ explicit S(double); // #2
+ operator int(); // #3
+ explicit operator bool(); // #4
};
cxxConstructorDecl(isExplicit()) will match #2, but not #1.
cxxConversionDecl(isExplicit()) will match #4, but not #3.
Given
struct S {
- S(); #1
- S(const S &); #2
- S(S &&); #3
+ S(); // #1
+ S(const S &); // #2
+ S(S &&); // #3
};
cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.
</pre></td></tr>
Given
struct S {
- S(int); #1
- explicit S(double); #2
- operator int(); #3
- explicit operator bool(); #4
+ S(int); // #1
+ explicit S(double); // #2
+ operator int(); // #3
+ explicit operator bool(); // #4
};
cxxConstructorDecl(isExplicit()) will match #2, but not #1.
cxxConversionDecl(isExplicit()) will match #4, but not #3.
Given
struct S {
- S(); #1
- S(const S &) = default; #2
- S(S &&) = delete; #3
+ S(); // #1
+ S(const S &) = default; // #2
+ S(S &&) = delete; // #3
};
cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.
</pre></td></tr>
class A { int operator*(); };
const A &operator<<(const A &a, const A &b);
A a;
- a << a; <-- This matches
+ a << a; // <-- This matches
cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the
specified line and
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr>
<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added
-by the compiler (eg. implicit defaultcopy constructors).
+by the compiler (eg. implicit default/copy constructors).
</pre></td></tr>
class A { int operator*(); };
const A &operator<<(const A &a, const A &b);
A a;
- a << a; <-- This matches
+ a << a; // <-- This matches
cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the
specified line and
Example matches A, va, fa
class A {};
- class B; Doesn't match, as it has no body.
+ class B; // Doesn't match, as it has no body.
int va;
- extern int vb; Doesn't match, as it doesn't define the variable.
+ extern int vb; // Doesn't match, as it doesn't define the variable.
void fa() {}
- void fb(); Doesn't match, as it has no body.
+ void fb(); // Doesn't match, as it has no body.
@interface X
- - (void)ma; Doesn't match, interface is declaration.
+ - (void)ma; // Doesn't match, interface is declaration.
@end
@implementation X
- (void)ma {}
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isStaticStorageClass0')"><a name="isStaticStorageClass0Anchor">isStaticStorageClass</a></td><td></td></tr>
-<tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variablefunction declarations that have "static" storage
+<tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variable/function declarations that have "static" storage
class specifier ("static" keyword) written in the source.
Given:
Given
namespace n {
- namespace {} #1
+ namespace {} // #1
}
namespaceDecl(isAnonymous()) will match #1 but not ::n.
</pre></td></tr>
CGRect bodyFrame = webView.frame;
bodyFrame.size.height = self.bodyContentHeight;
webView.frame = bodyFrame;
- ^---- matches here
+ // ^---- matches here
</pre></td></tr>
Example matches A, va, fa
class A {};
- class B; Doesn't match, as it has no body.
+ class B; // Doesn't match, as it has no body.
int va;
- extern int vb; Doesn't match, as it doesn't define the variable.
+ extern int vb; // Doesn't match, as it doesn't define the variable.
void fa() {}
- void fb(); Doesn't match, as it has no body.
+ void fb(); // Doesn't match, as it has no body.
@interface X
- - (void)ma; Doesn't match, interface is declaration.
+ - (void)ma; // Doesn't match, interface is declaration.
@end
@implementation X
- (void)ma {}
Example matches A, va, fa
class A {};
- class B; Doesn't match, as it has no body.
+ class B; // Doesn't match, as it has no body.
int va;
- extern int vb; Doesn't match, as it doesn't define the variable.
+ extern int vb; // Doesn't match, as it doesn't define the variable.
void fa() {}
- void fb(); Doesn't match, as it has no body.
+ void fb(); // Doesn't match, as it has no body.
@interface X
- - (void)ma; Doesn't match, interface is declaration.
+ - (void)ma; // Doesn't match, interface is declaration.
@end
@implementation X
- (void)ma {}
Example matches A, va, fa
class A {};
- class B; Doesn't match, as it has no body.
+ class B; // Doesn't match, as it has no body.
int va;
- extern int vb; Doesn't match, as it doesn't define the variable.
+ extern int vb; // Doesn't match, as it doesn't define the variable.
void fa() {}
- void fb(); Doesn't match, as it has no body.
+ void fb(); // Doesn't match, as it has no body.
@interface X
- - (void)ma; Doesn't match, interface is declaration.
+ - (void)ma; // Doesn't match, interface is declaration.
@end
@implementation X
- (void)ma {}
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isStaticStorageClass1')"><a name="isStaticStorageClass1Anchor">isStaticStorageClass</a></td><td></td></tr>
-<tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variablefunction declarations that have "static" storage
+<tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variable/function declarations that have "static" storage
class specifier ("static" keyword) written in the source.
Given:
Given:
void *v1 = NULL;
void *v2 = nullptr;
- void *v3 = __null; GNU extension
+ void *v3 = __null; // GNU extension
char *cp = (char *)0;
int *ip = 0;
int i = 0;
Example matches X, A, A::X, B, B::C, B::C::X
(matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")))))
class X {};
- class A { class X {}; }; Matches A, because A::X is a class of name
- X inside A.
+ class A { class X {}; }; // Matches A, because A::X is a class of name
+ // X inside A.
class B { class C { class X {}; }; };
DescendantT must be an AST base type.
Example matches X, Y, Y::X, Z::Y, Z::Y::X
(matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))
class X {};
- class Y { class X {}; }; Matches Y, because Y::X is a class of name X
- inside Y.
- class Z { class Y { class X {}; }; }; Does not match Z.
+ class Y { class X {}; }; // Matches Y, because Y::X is a class of name X
+ // inside Y.
+ class Z { class Y { class X {}; }; }; // Does not match Z.
ChildT must be an AST base type.
Example matches X, Y, Z
(matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X")))))
- class X {}; Matches X, because X::X is a class of name X inside X.
+ class X {}; // Matches X, because X::X is a class of name X inside X.
class Y { class X {}; };
class Z { class Y { class X {}; }; };
Example matches X, Y
(matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X")))
- class X {}; Matches X, because X::X is a class of name X inside X.
+ class X {}; // Matches X, because X::X is a class of name X inside X.
class Y { class X {}; };
- class Z { class Y { class X {}; }; }; Does not match Z.
+ class Z { class Y { class X {}; }; }; // Does not match Z.
ChildT must be an AST base type.
Example matches Y, Z, C (Base == hasName("X"))
class X;
- class Y : public X {}; directly derived
- class Z : public Y {}; indirectly derived
+ class Y : public X {}; // directly derived
+ class Z : public Y {}; // indirectly derived
typedef X A;
typedef A B;
- class C : public B {}; derived from a typedef of X
+ class C : public B {}; // derived from a typedef of X
In the following example, Bar matches isDerivedFrom(hasName("X")):
class Foo;
typedef Foo X;
- class Bar : public Foo {}; derived from a type that X is a typedef of
+ class Bar : public Foo {}; // derived from a type that X is a typedef of
</pre></td></tr>
namespace a { void f() {} }
using a::f;
void g() {
- f(); Matches this ..
- a::f(); .. but not this.
+ f(); // Matches this ..
+ a::f(); // .. but not this.
}
declRefExpr(throughUsingDecl(anything()))
matches f()