From: Manuel Klimek
Matches C++ class template declarations. Example matches Z @@ -84,7 +85,7 @@ Example matches Z
Matches C++ class template specializations. Given @@ -96,7 +97,7 @@ classTemplateSpecializationDecl()
Matches C++ constructor declarations. Example matches Foo::Foo() and Foo::Foo(int) @@ -109,7 +110,7 @@ Example matches Foo::Foo() and Foo::Foo(int)
Matches declarations. Examples matches X, C, and the friend declaration inside C; @@ -120,7 +121,7 @@ Examples matches X, C, and the friend declaration inside C;
Matches explicit C++ destructor declarations. Example matches Foo::~Foo() @@ -131,7 +132,7 @@ Example matches Foo::~Foo()
Matches enum constants. Example matches A, B, C @@ -141,7 +142,7 @@ Example matches A, B, C
Matches enum declarations. Example matches X @@ -151,7 +152,7 @@ Example matches X
Matches field declarations. Given @@ -161,7 +162,7 @@ fieldDecl()
Matches function declarations. Example matches f @@ -169,7 +170,7 @@ Example matches f
Matches C++ function template declarations. Example matches f @@ -177,7 +178,7 @@ Example matches f
Matches method declarations. Example matches y @@ -185,7 +186,7 @@ Example matches y
Matches a declaration of anything that could have a name. Example matches X, S, the anonymous union type, i, and U; @@ -198,7 +199,7 @@ Example matches X, S, the anonymous union type, i, and U;
Matches C++ class declarations. Example matches X, Z @@ -207,7 +208,7 @@ Example matches X, Z
Matches using declarations. Given @@ -217,7 +218,7 @@ usingDecl() matches using X::x
Matches variable declarations. Note: this does not match declarations of member variables, which are @@ -228,7 +229,7 @@ Example matches a
Matches bool literals. Example matches true @@ -236,7 +237,7 @@ Example matches true
Matches any cast nodes of Clang's AST. Example: castExpr() matches each of the following: @@ -249,7 +250,7 @@ but does not match
Matches character literals (also matches wchar_t). Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), @@ -260,7 +261,7 @@ Example matches 'a', L'a'
Matches a const_cast expression. Example: Matches const_cast<int*>(&r) in @@ -270,7 +271,7 @@ Example: Matches const_cast<int*>(&r) in
Matches a dynamic_cast expression. Example: @@ -284,7 +285,7 @@ in
Matches explicit cast expressions. Matches any cast expression written in user code, whether it be a @@ -305,7 +306,7 @@ but does not match the implicit conversion in
Matches functional cast expressions Example: Matches Foo(bar); @@ -315,7 +316,7 @@ Example: Matches Foo(bar);
Matches the implicit cast nodes of Clang's AST. This matches many different places, including function call return value @@ -323,7 +324,7 @@ eliding, as well as any type conversions.
Matches integer literals of all sizes encodings. Not matching character-encoded integers such as L'a'. @@ -332,7 +333,7 @@ Example matches 1, 1L, 0x1, 1U
Matches a reinterpret_cast expression. Either the source expression or the destination type can be matched @@ -344,7 +345,7 @@ Example matches reinterpret_cast<char*>(&p) in
Matches a C++ static_cast expression. hasDestinationType @@ -359,7 +360,7 @@ in
Matches string literals (also matches wide string literals). Example matches "abcd", L"abcd" @@ -367,7 +368,7 @@ Example matches "abcd", L"abcd"
Matches array subscript expressions. Given @@ -377,7 +378,7 @@ arraySubscriptExpr()
Matches binary operator expressions. Example matches a || b @@ -385,7 +386,7 @@ Example matches a || b
Matches nodes where temporaries are created. Example matches FunctionTakesString(GetStringByValue()) @@ -395,7 +396,7 @@ Example matches FunctionTakesString(GetStringByValue())
Matches call expressions. Example matches x.y() and y() @@ -405,7 +406,7 @@ Example matches x.y() and y()
Matches compound statements. Example matches '{}' and '{{}}'in 'for (;;) {{}}' @@ -413,7 +414,7 @@ Example matches '{}' and '{{}}'in 'for (;;) {{}}'
Matches conditional operator expressions. Example matches a ? b : c @@ -421,7 +422,7 @@ Example matches a ? b : c
Matches constructor call expressions (including implicit ones). Example matches string(ptr, n) and ptr within arguments of f @@ -433,7 +434,7 @@ Example matches string(ptr, n) and ptr within arguments of f
Matches expressions that refer to declarations. Example matches x in if (x) @@ -442,7 +443,7 @@ Example matches x in if (x)
Matches declaration statements. Given @@ -452,7 +453,7 @@ declStmt()
Matches the value of a default argument at the call site. Example matches the CXXDefaultArgExpr placeholder inserted for the @@ -463,7 +464,7 @@ Example matches the CXXDefaultArgExpr placeholder inserted for the
Matches delete expressions. Given @@ -473,7 +474,7 @@ deleteExpr()
Matches do statements. Given @@ -483,7 +484,7 @@ doStmt()
Matches expressions. Example matches x() @@ -491,7 +492,7 @@ Example matches x()
Matches for statements. Example matches 'for (;;) {}' @@ -499,7 +500,7 @@ Example matches 'for (;;) {}'
Matches if statements. Example matches 'if (x) {}' @@ -507,7 +508,7 @@ Example matches 'if (x) {}'
Matches init list expressions. Given @@ -519,7 +520,7 @@ initList()
Matches nodes where temporaries are materialized. Example: Given @@ -535,7 +536,7 @@ but does not match
Matches member call expressions. Example matches x.y() @@ -544,7 +545,7 @@ Example matches x.y()
Matches member expressions. Given @@ -557,7 +558,7 @@ memberExpr()
Matches new expressions. Given @@ -567,7 +568,7 @@ newExpr()
Matches overloaded operator calls. Note that if an operator isn't overloaded, it won't match. Instead, use @@ -583,7 +584,7 @@ Example matches both operator<<((o << b), c) and operator<<(o,
Matches statements. Given @@ -593,7 +594,7 @@ stmt()
Matches case and default statements inside switch statements. Given @@ -603,7 +604,7 @@ switchCase()
Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) Given @@ -614,7 +615,7 @@ unaryExprOrTypeTraitExpr()
Matches unary operator expressions. Example matches !a @@ -622,7 +623,7 @@ Example matches !a
Matches while statements. Given @@ -648,21 +649,21 @@ which allow users to create more powerful match expressions.- Return type Name Parameters + Matcher<*> allOf Matcher<*> P1, Matcher<*> P2 Matcher<*> allOf Matcher<*> P1, Matcher<*> P2 - Matches if all given matchers match. Usable as: Any Matcher+ Matcher<*> anyOf Matcher<*> P1, Matcher<*> P2 Matcher<*> anyOf Matcher<*> P1, Matcher<*> P2 - Matches if any of the given matchers matches. Usable as: Any Matcher+ Matcher<*> anything Matcher<*> anything - Matches any node. Useful when another matcher requires a child matcher, but there's no @@ -678,7 +679,7 @@ Usable as: Any Matcher+ Matcher<*> unless Matcher<*> InnerMatcher Matcher<*> unless Matcher<*> InnerMatcher - Matches if the provided matcher does not match. Example matches Y (matcher = recordDecl(unless(hasName("X")))) @@ -689,7 +690,7 @@ Usable as: Any Matcher+ Matcher<BinaryOperator> hasOperatorName std::string Name Matcher<BinaryOperator> hasOperatorName std::string Name - Matches the operator Name of operator expressions (binary or unary). @@ -698,7 +699,7 @@ Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))+ Matcher<CXXBoolLiteral> equals ValueT Value Matcher<CXXBoolLiteral> equals ValueT Value + Matches literals that are equal to the given value. Example matches true (matcher = boolLiteral(equals(true))) @@ -709,13 +710,13 @@ Usable as: Matcher<CXXConstructorDecl>isImplicit Matcher<CXXConstructorDecl> isImplicit - Matches a constructor declaration that has been implicitly added by the compiler (eg. implicit defaultcopy constructors).+ Matcher<CXXCtorInitializer> isWritten Matcher<CXXCtorInitializer> isWritten - Matches a contructor initializer if it is explicitly written in code (as opposed to implicitly added by the compiler). @@ -730,7 +731,7 @@ constructorDecl(hasAnyConstructorInitializer(isWritten()))+ Matcher<CXXOperatorCallExpr> hasOverloadedOperatorName std::string Name Matcher<CXXOperatorCallExpr> hasOverloadedOperatorName std::string Name - Matches overloaded operator names. Matches overloaded operator names specified in strings without the @@ -744,12 +745,17 @@ Example matches a << b+ Matcher<CXXRecordDecl> isDerivedFrom StringRef BaseName + Matcher<CXXRecordDecl> isA StringRef BaseName + + + Overloaded method as shortcut for isA(hasName(...)). +Matcher<CXXRecordDecl> isDerivedFrom StringRef BaseName - Overloaded method as shortcut for isDerivedFrom(hasName(...)).+ Matcher<CXXRecordDecl> isExplicitTemplateSpecialization Matcher<CXXRecordDecl> isExplicitTemplateSpecialization + Matches explicit template specializations of function, class, or static member variable template instantiations. @@ -763,7 +769,7 @@ Usable as: Matcher<CXXRecordDecl>isTemplateInstantiation Matcher<CXXRecordDecl> isTemplateInstantiation + Matches template instantiations of function, class, or static member variable template instantiations. @@ -784,7 +790,7 @@ Usable as: Matcher<CallExpr>argumentCountIs unsigned N Matcher<CallExpr> argumentCountIs unsigned N - Checks that a call expression or a constructor call expression has a specific number of arguments (including absent default arguments). @@ -794,7 +800,7 @@ Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))+ Matcher<CharacterLiteral> equals ValueT Value Matcher<CharacterLiteral> equals ValueT Value + Matches literals that are equal to the given value. Example matches true (matcher = boolLiteral(equals(true))) @@ -805,7 +811,7 @@ Usable as: Matcher<CompoundStmt>statementCountIs unsigned N Matcher<CompoundStmt> statementCountIs unsigned N - Checks that a compound statement contains a specific number of child statements. @@ -817,7 +823,7 @@ compoundStmt(statementCountIs(0)))+ Matcher<DeclStmt> declCountIs unsigned N Matcher<DeclStmt> declCountIs unsigned N - Matches declaration statements that contain a specific number of declarations. @@ -830,7 +836,7 @@ declCountIs(2)+ Matcher<FloatingLiteral> equals ValueT Value Matcher<FloatingLiteral> equals ValueT Value + Matches literals that are equal to the given value. Example matches true (matcher = boolLiteral(equals(true))) @@ -841,7 +847,7 @@ Usable as: Matcher<FunctionDecl>isDefinition Matcher<FunctionDecl> isDefinition + Matches if a declaration has a body attached. Example matches A, va, fa @@ -856,7 +862,7 @@ Usable as: Matcher<FunctionDecl>isExplicitTemplateSpecialization Matcher<FunctionDecl> isExplicitTemplateSpecialization + Matches explicit template specializations of function, class, or static member variable template instantiations. @@ -870,7 +876,7 @@ Usable as: Matcher<FunctionDecl>isExternC Matcher<FunctionDecl> isExternC - Matches extern "C" function declarations. Given: @@ -882,7 +888,7 @@ functionDecl(isExternC())+ Matcher<FunctionDecl> isTemplateInstantiation Matcher<FunctionDecl> isTemplateInstantiation + Matches template instantiations of function, class, or static member variable template instantiations. @@ -903,7 +909,7 @@ Usable as: Matcher<IntegerLiteral>equals ValueT Value Matcher<IntegerLiteral> equals ValueT Value + Matches literals that are equal to the given value. Example matches true (matcher = boolLiteral(equals(true))) @@ -914,7 +920,7 @@ Usable as: Matcher<MemberExpr>isArrow Matcher<MemberExpr> isArrow - Matches member expressions that are called with '->' as opposed to '.'. @@ -931,7 +937,7 @@ memberExpr(isArrow())+ Matcher<NamedDecl> hasName std::string Name Matcher<NamedDecl> hasName std::string Name - Matches NamedDecl nodes that have the specified name. Supports specifying enclosing namespaces or classes by prefixing the name @@ -946,7 +952,7 @@ Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")+ Matcher<NamedDecl> matchesName std::string RegExp Matcher<NamedDecl> matchesName std::string RegExp - Matches NamedDecl nodes whose full names partially match the given RegExp. @@ -962,7 +968,7 @@ Example matches X (regexp is one of "::X", "^foo::.*X", among others)+ Matcher<QualType> asString std::string Name Matcher<QualType> asString std::string Name - Matches if the matched type is represented by the given string. Given @@ -973,7 +979,7 @@ callExpr(on(hasType(asString("class Y *"))))+ Matcher<QualType> isConstQualified Matcher<QualType> isConstQualified - Matches QualType nodes that are const-qualified, i.e., that include "top-level" const. @@ -990,7 +996,7 @@ functionDecl(hasAnyParameter(hasType(isConstQualified())))+ Matcher<QualType> isInteger Matcher<QualType> isInteger - Matches QualType nodes that are of integer type. Given @@ -1002,7 +1008,7 @@ matches "a(int)", "b(long)", but not "c(double)".+ Matcher<TagDecl> isDefinition Matcher<TagDecl> isDefinition + Matches if a declaration has a body attached. Example matches A, va, fa @@ -1017,7 +1023,7 @@ Usable as: Matcher<UnaryExprOrTypeTraitExpr>ofKind UnaryExprOrTypeTrait Kind Matcher<UnaryExprOrTypeTraitExpr> ofKind UnaryExprOrTypeTrait Kind - Matches unary expressions of a certain kind. Given @@ -1028,7 +1034,7 @@ unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))+ Matcher<UnaryOperator> hasOperatorName std::string Name Matcher<UnaryOperator> hasOperatorName std::string Name - Matches the operator Name of operator expressions (binary or unary). @@ -1037,7 +1043,7 @@ Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))+ Matcher<VarDecl> isDefinition Matcher<VarDecl> isDefinition + Matches if a declaration has a body attached. Example matches A, va, fa @@ -1052,7 +1058,7 @@ Usable as: Matcher<VarDecl>isExplicitTemplateSpecialization Matcher<VarDecl> isExplicitTemplateSpecialization + Matches explicit template specializations of function, class, or static member variable template instantiations. @@ -1066,7 +1072,7 @@ Usable as: Matcher<VarDecl>isTemplateInstantiation Matcher<VarDecl> isTemplateInstantiation Matches template instantiations of function, class, or static member variable template instantiations. @@ -1104,7 +1110,7 @@ match expressions.- Return type Name Parameters + Matcher<*> forEach Matcher<ChildT> ChildMatcher Matcher<*> forEach Matcher<ChildT> ChildMatcher - Matches AST nodes that have child AST nodes that match the provided matcher. @@ -1122,7 +1128,7 @@ Usable as: Any Matcher+ Matcher<*> forEachDescendant Matcher<DescendantT> DescendantMatcher Matcher<*> forEachDescendant Matcher<DescendantT> DescendantMatcher - Matches AST nodes that have descendant AST nodes that match the provided matcher. @@ -1146,7 +1152,7 @@ Usable as: Any Matcher+ Matcher<*> has Matcher<ChildT> ChildMatcher Matcher<*> has Matcher<ChildT> ChildMatcher - Matches AST nodes that have child AST nodes that match the provided matcher. @@ -1161,7 +1167,20 @@ Usable as: Any Matcher+ Matcher<*> hasDescendant Matcher<DescendantT> DescendantMatcher + Matcher<*> hasAncestor Matcher<AncestorT> AncestorMatcher + + + Matches AST nodes that have an ancestor that matches the provided +matcher. + +Given +void f() { if (true) { int x = 42; } } +void g() { for (;;) { int x = 43; } } +expr(integerLiteral(hasAncsestor(ifStmt()))) matches 42, but not 43. + +Usable as: Any Matcher +Matcher<*> hasDescendant Matcher<DescendantT> DescendantMatcher - Matches AST nodes that have descendant AST nodes that match the provided matcher. @@ -1177,7 +1196,7 @@ Usable as: Any Matcher+ Matcher<ArraySubscriptExpr> hasBase Matcher<Expr> InnerMatcher Matcher<ArraySubscriptExpr> hasBase Matcher<Expr> InnerMatcher - Matches the base expression of an array subscript expression. Given @@ -1189,7 +1208,7 @@ arraySubscriptExpression(hasBase(implicitCastExpr(+ Matcher<ArraySubscriptExpr> hasIndex Matcher<Expr> InnerMatcher Matcher<ArraySubscriptExpr> hasIndex Matcher<Expr> InnerMatcher - Matches the index expression of an array subscript expression. Given @@ -1200,13 +1219,13 @@ arraySubscriptExpression(hasIndex(integerLiteral()))+ Matcher<BinaryOperator> hasEitherOperand Matcher<Expr> InnerMatcher Matcher<BinaryOperator> hasEitherOperand Matcher<Expr> InnerMatcher - Matches if either the left hand side or the right hand side of a binary operator matches.+ Matcher<BinaryOperator> hasLHS Matcher<Expr> InnerMatcher Matcher<BinaryOperator> hasLHS Matcher<Expr> InnerMatcher - Matches the left hand side of binary operator expressions. Example matches a (matcher = binaryOperator(hasLHS())) @@ -1214,7 +1233,7 @@ Example matches a (matcher = binaryOperator(hasLHS()))+ Matcher<BinaryOperator> hasRHS Matcher<Expr> InnerMatcher Matcher<BinaryOperator> hasRHS Matcher<Expr> InnerMatcher - Matches the right hand side of binary operator expressions. Example matches b (matcher = binaryOperator(hasRHS())) @@ -1222,7 +1241,7 @@ Example matches b (matcher = binaryOperator(hasRHS()))+ Matcher<CXXConstructExpr> hasDeclaration Matcher<Decl> InnerMatcher Matcher<CXXConstructExpr> hasDeclaration Matcher<Decl> InnerMatcher + Matches a type if the declaration of the type matches the given matcher. @@ -1230,7 +1249,7 @@ Usable as: Matcher<CXXConstructorDecl>hasAnyConstructorInitializer Matcher<CXXCtorInitializer> InnerMatcher Matcher<CXXConstructorDecl> hasAnyConstructorInitializer Matcher<CXXCtorInitializer> InnerMatcher - Matches a constructor initializer. Given @@ -1243,7 +1262,7 @@ recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything()))))+ Matcher<CXXCtorInitializer> forField Matcher<FieldDecl> InnerMatcher Matcher<CXXCtorInitializer> forField Matcher<FieldDecl> InnerMatcher - Matches the field declaration of a constructor initializer. Given @@ -1258,7 +1277,7 @@ with forField matching foo_+ Matcher<CXXCtorInitializer> withInitializer Matcher<Expr> InnerMatcher Matcher<CXXCtorInitializer> withInitializer Matcher<Expr> InnerMatcher - Matches the initializer expression of a constructor initializer. Given @@ -1273,7 +1292,7 @@ with withInitializer matching (1)+ Matcher<CXXMemberCallExpr> on Matcher<Expr> InnerMatcher Matcher<CXXMemberCallExpr> on Matcher<Expr> InnerMatcher - Matches on the implicit object argument of a member call expression. Example matches y.x() (matcher = callExpr(on(hasType(recordDecl(hasName("Y")))))) @@ -1284,16 +1303,16 @@ FIXME: Overload to allow directly matching types?+ Matcher<CXXMemberCallExpr> onImplicitObjectArgument Matcher<Expr> InnerMatcher Matcher<CXXMemberCallExpr> onImplicitObjectArgument Matcher<Expr> InnerMatcher - + Matcher<CXXMemberCallExpr> thisPointerType Matcher<Decl> InnerMatcher Matcher<CXXMemberCallExpr> thisPointerType Matcher<Decl> InnerMatcher - Overloaded to match the type's declaration.+ Matcher<CXXMethodDecl> ofClass Matcher<CXXRecordDecl> InnerMatcher Matcher<CXXMethodDecl> ofClass Matcher<CXXRecordDecl> InnerMatcher - Matches the class declaration that the given method declaration belongs to. @@ -1312,14 +1331,20 @@ Example matches A() in the last line+ Matcher<CXXRecordDecl> isDerivedFrom Matcher<NamedDecl> Base + Matcher<CXXRecordDecl> isA Matcher<NamedDecl> Base + + + Similar to isDerivedFrom(), but also matches classes that directly +match Base. +Matcher<CXXRecordDecl> isDerivedFrom Matcher<NamedDecl> Base - Matches C++ classes that are directly or indirectly derived from a class matching Base. -Note that a class is considered to be also derived from itself. +Note that a class is not considered to be derived from itself. -Example matches X, Y, Z, C (Base == hasName("X")) - class X; A class is considered to be derived from itself +Example matches Y, Z, C (Base == hasName("X")) + class X; class Y : public X {}; directly derived class Z : public Y {}; indirectly derived typedef X A; @@ -1333,7 +1358,7 @@ In the following example, Bar matches isDerivedFrom(hasName("X")):+ Matcher<CallExpr> callee Matcher<Decl> InnerMatcher Matcher<CallExpr> callee Matcher<Decl> InnerMatcher - Matches if the call expression's callee's declaration matches the given matcher. @@ -1343,7 +1368,7 @@ Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x")))))+ Matcher<CallExpr> hasAnyArgument Matcher<Expr> InnerMatcher Matcher<CallExpr> hasAnyArgument Matcher<Expr> InnerMatcher - Matches any argument of a call expression or a constructor call expression. @@ -1356,7 +1381,7 @@ with hasAnyArgument(...)+ Matcher<CallExpr> hasArgument unsigned N, Matcher<Expr> InnerMatcher Matcher<CallExpr> hasArgument unsigned N, Matcher<Expr> InnerMatcher - Matches the n'th argument of a call expression or a constructor call expression. @@ -1366,7 +1391,7 @@ Example matches y in x(y)+ Matcher<CallExpr> hasDeclaration Matcher<Decl> InnerMatcher Matcher<CallExpr> hasDeclaration Matcher<Decl> InnerMatcher + Matches a type if the declaration of the type matches the given matcher. @@ -1374,7 +1399,7 @@ Usable as: Matcher<CastExpr>hasSourceExpression Matcher<Expr> InnerMatcher Matcher<CastExpr> hasSourceExpression Matcher<Expr> InnerMatcher - Matches if the cast's source expression matches the given matcher. Example: matches "a string" (matcher = @@ -1384,7 +1409,7 @@ URL url = "a string";+ Matcher<ClassTemplateSpecializationDecl> hasAnyTemplateArgument Matcher<TemplateArgument> InnerMatcher Matcher<ClassTemplateSpecializationDecl> hasAnyTemplateArgument Matcher<TemplateArgument> InnerMatcher - Matches classTemplateSpecializations that have at least one TemplateArgument matching the given InnerMatcher. @@ -1398,7 +1423,7 @@ classTemplateSpecializationDecl(hasAnyTemplateArgument(+ Matcher<ClassTemplateSpecializationDecl> hasTemplateArgument unsigned N, Matcher<TemplateArgument> InnerMatcher Matcher<ClassTemplateSpecializationDecl> hasTemplateArgument unsigned N, Matcher<TemplateArgument> InnerMatcher - Matches classTemplateSpecializations where the n'th TemplateArgument matches the given InnerMatcher. @@ -1412,7 +1437,7 @@ classTemplateSpecializationDecl(hasTemplateArgument(+ Matcher<CompoundStmt> hasAnySubstatement Matcher<Stmt> InnerMatcher Matcher<CompoundStmt> hasAnySubstatement Matcher<Stmt> InnerMatcher - Matches compound statements where at least one substatement matches a given matcher. @@ -1425,7 +1450,7 @@ with compoundStmt()+ Matcher<ConditionalOperator> hasCondition Matcher<Expr> InnerMatcher Matcher<ConditionalOperator> hasCondition Matcher<Expr> InnerMatcher - Matches the condition expression of an if statement, for loop, or conditional operator. @@ -1434,7 +1459,7 @@ Example matches true (matcher = hasCondition(boolLiteral(equals(true))))+ Matcher<ConditionalOperator> hasFalseExpression Matcher<Expr> InnerMatcher Matcher<ConditionalOperator> hasFalseExpression Matcher<Expr> InnerMatcher - Matches the false branch expression of a conditional operator. Example matches b @@ -1442,7 +1467,7 @@ Example matches b+ Matcher<ConditionalOperator> hasTrueExpression Matcher<Expr> InnerMatcher Matcher<ConditionalOperator> hasTrueExpression Matcher<Expr> InnerMatcher - Matches the true branch expression of a conditional operator. Example matches a @@ -1450,7 +1475,7 @@ Example matches a+ Matcher<DeclRefExpr> throughUsingDecl Matcher<UsingShadowDecl> InnerMatcher Matcher<DeclRefExpr> throughUsingDecl Matcher<UsingShadowDecl> InnerMatcher - Matches a DeclRefExpr that refers to a declaration through a specific using shadow declaration. @@ -1468,7 +1493,7 @@ declRefExpr(throughUsingDeclaration(anything()))+ Matcher<DeclRefExpr> to Matcher<Decl> InnerMatcher Matcher<DeclRefExpr> to Matcher<Decl> InnerMatcher - Matches a DeclRefExpr that refers to a declaration that matches the specified matcher. @@ -1479,7 +1504,7 @@ Example matches x in if(x)+ Matcher<DeclStmt> containsDeclaration unsigned N, Matcher<Decl> InnerMatcher Matcher<DeclStmt> containsDeclaration unsigned N, Matcher<Decl> InnerMatcher - Matches the n'th declaration of a declaration statement. Note that this does not work for global declarations because the AST @@ -1498,7 +1523,7 @@ declStmt(containsDeclaration(1, varDecl()))+ Matcher<DeclStmt> hasSingleDecl Matcher<Decl> InnerMatcher Matcher<DeclStmt> hasSingleDecl Matcher<Decl> InnerMatcher - Matches the Decl of a DeclStmt which has a single declaration. Given @@ -1509,7 +1534,7 @@ declStmt(hasSingleDecl(anything()))+ Matcher<DoStmt> hasBody Matcher<Stmt> InnerMatcher Matcher<DoStmt> hasBody Matcher<Stmt> InnerMatcher - Matches a 'for', 'while', or 'do while' statement that has a given body. @@ -1522,7 +1547,7 @@ with compoundStmt()+ Matcher<DoStmt> hasCondition Matcher<Expr> InnerMatcher Matcher<DoStmt> hasCondition Matcher<Expr> InnerMatcher - Matches the condition expression of an if statement, for loop, or conditional operator. @@ -1531,7 +1556,7 @@ Example matches true (matcher = hasCondition(boolLiteral(equals(true))))+ Matcher<ExplicitCastExpr> hasDestinationType Matcher<QualType> InnerMatcher Matcher<ExplicitCastExpr> hasDestinationType Matcher<QualType> InnerMatcher - Matches casts whose destination type matches a given matcher. (Note: Clang's AST refers to other conversions as "casts" too, and calls @@ -1539,7 +1564,7 @@ actual casts "explicit" casts.)+ Matcher<Expr> hasType Matcher<Decl> InnerMatcher Matcher<Expr> hasType Matcher<Decl> InnerMatcher + Overloaded to match the declaration of the expression's or value declaration's type. @@ -1558,7 +1583,7 @@ Usable as: Matcher<Expr>ignoringImpCasts Matcher<Expr> InnerMatcher Matcher<Expr> ignoringImpCasts Matcher<Expr> InnerMatcher - Matches expressions that match InnerMatcher after any implicit casts are stripped off. @@ -1581,7 +1606,7 @@ only match the declarations for b, c, and d.+ Matcher<Expr> ignoringParenCasts Matcher<Expr> InnerMatcher Matcher<Expr> ignoringParenCasts Matcher<Expr> InnerMatcher - Matches expressions that match InnerMatcher after parentheses and casts are stripped off. @@ -1600,7 +1625,7 @@ only match the declaration for a.+ Matcher<Expr> ignoringParenImpCasts Matcher<Expr> InnerMatcher Matcher<Expr> ignoringParenImpCasts Matcher<Expr> InnerMatcher - Matches expressions that match InnerMatcher after implicit casts and parentheses are stripped off. @@ -1623,7 +1648,7 @@ would only match the declaration for a.+ Matcher<ForStmt> hasBody Matcher<Stmt> InnerMatcher Matcher<ForStmt> hasBody Matcher<Stmt> InnerMatcher - Matches a 'for', 'while', or 'do while' statement that has a given body. @@ -1636,7 +1661,7 @@ with compoundStmt()+ Matcher<ForStmt> hasCondition Matcher<Expr> InnerMatcher Matcher<ForStmt> hasCondition Matcher<Expr> InnerMatcher - Matches the condition expression of an if statement, for loop, or conditional operator. @@ -1645,7 +1670,7 @@ Example matches true (matcher = hasCondition(boolLiteral(equals(true))))+ Matcher<ForStmt> hasIncrement Matcher<Stmt> InnerMatcher Matcher<ForStmt> hasIncrement Matcher<Stmt> InnerMatcher - Matches the increment statement of a for loop. Example: @@ -1655,7 +1680,7 @@ matches '++x' in+ Matcher<ForStmt> hasLoopInit Matcher<Stmt> InnerMatcher Matcher<ForStmt> hasLoopInit Matcher<Stmt> InnerMatcher - Matches the initialization statement of a for loop. Example: @@ -1665,7 +1690,7 @@ matches 'int x = 0' in+ Matcher<FunctionDecl> hasAnyParameter Matcher<ParmVarDecl> InnerMatcher Matcher<FunctionDecl> hasAnyParameter Matcher<ParmVarDecl> InnerMatcher - Matches any parameter of a function declaration. Does not match the 'this' parameter of a method. @@ -1679,7 +1704,7 @@ with hasAnyParameter(...)+ Matcher<FunctionDecl> hasParameter unsigned N, Matcher<ParmVarDecl> InnerMatcher Matcher<FunctionDecl> hasParameter unsigned N, Matcher<ParmVarDecl> InnerMatcher - Matches the n'th parameter of a function declaration. Given @@ -1691,7 +1716,7 @@ with hasParameter(...)+ Matcher<FunctionDecl> returns Matcher<QualType> InnerMatcher Matcher<FunctionDecl> returns Matcher<QualType> InnerMatcher - Matches the return type of a function declaration. Given: @@ -1701,7 +1726,7 @@ methodDecl(returns(asString("int")))+ Matcher<IfStmt> hasCondition Matcher<Expr> InnerMatcher Matcher<IfStmt> hasCondition Matcher<Expr> InnerMatcher - Matches the condition expression of an if statement, for loop, or conditional operator. @@ -1710,7 +1735,7 @@ Example matches true (matcher = hasCondition(boolLiteral(equals(true))))+ Matcher<IfStmt> hasConditionVariableStatement Matcher<DeclStmt> InnerMatcher Matcher<IfStmt> hasConditionVariableStatement Matcher<DeclStmt> InnerMatcher - Matches the condition variable statement in an if statement. Given @@ -1720,7 +1745,7 @@ hasConditionVariableStatment(...)+ Matcher<ImplicitCastExpr> hasImplicitDestinationType Matcher<QualType> InnerMatcher Matcher<ImplicitCastExpr> hasImplicitDestinationType Matcher<QualType> InnerMatcher - Matches implicit casts whose destination type matches a given matcher. @@ -1728,7 +1753,7 @@ FIXME: Unit test this matcher+ Matcher<MemberExpr> hasObjectExpression Matcher<Expr> InnerMatcher Matcher<MemberExpr> hasObjectExpression Matcher<Expr> InnerMatcher - Matches a member expression where the object expression is matched by a given matcher. @@ -1742,7 +1767,7 @@ with hasObjectExpression(...)+ Matcher<MemberExpr> member Matcher<ValueDecl> InnerMatcher Matcher<MemberExpr> member Matcher<ValueDecl> InnerMatcher - Matches a member expression where the member is matched by a given matcher. @@ -1756,7 +1781,7 @@ memberExpr(member(hasName("first")))+ Matcher<QualType> hasDeclaration Matcher<Decl> InnerMatcher Matcher<QualType> hasDeclaration Matcher<Decl> InnerMatcher + Matches a type if the declaration of the type matches the given matcher. @@ -1764,29 +1789,29 @@ Usable as: Matcher<QualType>pointsTo Matcher<Decl> InnerMatcher Matcher<QualType> pointsTo Matcher<Decl> InnerMatcher - Overloaded to match the pointee type's declaration.+ Matcher<QualType> references Matcher<Decl> InnerMatcher Matcher<QualType> references Matcher<Decl> InnerMatcher - Overloaded to match the referenced type's declaration.+ Matcher<Stmt> alignOfExpr Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher Matcher<Stmt> alignOfExpr Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher - Same as unaryExprOrTypeTraitExpr, but only matching alignof.+ Matcher<Stmt> sizeOfExpr Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher Matcher<Stmt> sizeOfExpr Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher - Same as unaryExprOrTypeTraitExpr, but only matching sizeof.+ Matcher<TemplateArgument> refersToDeclaration Matcher<Decl> InnerMatcher Matcher<TemplateArgument> refersToDeclaration Matcher<Decl> InnerMatcher - Matches a TemplateArgument that refers to a certain declaration. Given @@ -1800,7 +1825,7 @@ classTemplateSpecializationDecl(hasAnyTemplateArgument(+ Matcher<TemplateArgument> refersToType Matcher<QualType> InnerMatcher Matcher<TemplateArgument> refersToType Matcher<QualType> InnerMatcher - Matches a TemplateArgument that refers to a certain type. Given @@ -1813,7 +1838,7 @@ classTemplateSpecializationDecl(hasAnyTemplateArgument(+ Matcher<UnaryExprOrTypeTraitExpr> hasArgumentOfType Matcher<QualType> InnerMatcher Matcher<UnaryExprOrTypeTraitExpr> hasArgumentOfType Matcher<QualType> InnerMatcher - Matches unary expressions that have a specific type of argument. Given @@ -1823,7 +1848,7 @@ unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))+ Matcher<UnaryOperator> hasUnaryOperand Matcher<Expr> InnerMatcher Matcher<UnaryOperator> hasUnaryOperand Matcher<Expr> InnerMatcher - Matches if the operand of a unary operator matches. Example matches true (matcher = hasOperand(boolLiteral(equals(true)))) @@ -1831,7 +1856,7 @@ Example matches true (matcher = hasOperand(boolLiteral(equals(true))))+ Matcher<UsingDecl> hasAnyUsingShadowDecl Matcher<UsingShadowDecl> InnerMatcher Matcher<UsingDecl> hasAnyUsingShadowDecl Matcher<UsingShadowDecl> InnerMatcher - Matches any using shadow declaration. Given @@ -1841,7 +1866,7 @@ usingDecl(hasAnyUsingShadowDecl(hasName("b")))) matches using X::b+ Matcher<UsingShadowDecl> hasTargetDecl Matcher<NamedDecl> InnerMatcher Matcher<UsingShadowDecl> hasTargetDecl Matcher<NamedDecl> InnerMatcher - Matches a using shadow declaration where the target declaration is matched by the given matcher. @@ -1853,7 +1878,7 @@ usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) matches using X::b but not using X::a+ Matcher<ValueDecl> hasType Matcher<Decl> InnerMatcher Matcher<ValueDecl> hasType Matcher<Decl> InnerMatcher + Overloaded to match the declaration of the expression's or value declaration's type. @@ -1872,7 +1897,7 @@ Usable as: Matcher<VarDecl>hasInitializer Matcher<Expr> InnerMatcher Matcher<VarDecl> hasInitializer Matcher<Expr> InnerMatcher - Matches a variable declaration that has an initializer expression that matches the given matcher. @@ -1882,7 +1907,7 @@ Example matches x (matcher = varDecl(hasInitializer(callExpr())))+ Matcher<WhileStmt> hasBody Matcher<Stmt> InnerMatcher Matcher<WhileStmt> hasBody Matcher<Stmt> InnerMatcher - Matches a 'for', 'while', or 'do while' statement that has a given body. @@ -1895,7 +1920,7 @@ with compoundStmt()+ Matcher<WhileStmt> hasCondition Matcher<Expr> InnerMatcher Matcher<WhileStmt> hasCondition Matcher<Expr> InnerMatcher Matches the condition expression of an if statement, for loop, or conditional operator. diff --git a/docs/tools/dump_ast_matchers.py b/docs/tools/dump_ast_matchers.py index 83fc420c96..bc5f1a64a5 100644 --- a/docs/tools/dump_ast_matchers.py +++ b/docs/tools/dump_ast_matchers.py @@ -14,7 +14,7 @@ MATCHERS_FILE = '../../include/clang/ASTMatchers/ASTMatchers.h' # The subsequent row contains the documentation and is hidden by default, # becoming visible via javascript when the user clicks the matcher name. TD_TEMPLATE=""" -+ %(result)s %(name)s %(args)s %(result)s %(name)s %(args)s """ %(comment)s