Home | History | Annotate | Download | only in ASTMatchers

Lines Matching refs:Matches

98 /// \brief If the provided matcher matches a node, binds the node to \c ID.
119 /// \brief Matches any node.
125 /// Example: \c DeclarationMatcher(anything()) matches all declarations, e.g.,
135 /// \brief Matches the top declaration context.
145 /// matches "int X", but not "int Y".
149 /// \brief Matches typedef declarations.
157 /// matches "typedef int X", but not "using Y = int"
160 /// \brief Matches typedef name declarations.
168 /// matches "typedef int X" and "using Y = int"
172 /// \brief Matches type alias declarations.
180 /// matches "using Y = int", but not "typedef int X"
183 /// \brief Matches type alias template declarations.
185 /// typeAliasTemplateDecl() matches
193 /// \brief Matches AST nodes that were expanded within the main-file.
195 /// Example matches X but not Y
214 /// \brief Matches AST nodes that were expanded within system-header-files.
216 /// Example matches Y but not X
238 /// \brief Matches AST nodes that were expanded within files whose name is
241 /// Example matches Y but not X
272 /// \brief Matches declarations.
274 /// Examples matches \c X, \c C, and the friend declaration inside \c C;
283 /// \brief Matches a declaration of a linkage specification.
290 /// matches "extern "C" {}"
294 /// \brief Matches a declaration of anything that could have a name.
296 /// Example matches \c X, \c S, the anonymous union type, \c i, and \c U;
307 /// \brief Matches a declaration of label.
315 /// matches 'FOO:'
318 /// \brief Matches a declaration of a namespace.
326 /// matches "namespace {}" and "namespace test {}"
329 /// \brief Matches a declaration of a namespace alias.
337 /// matches "namespace alias" but not "namespace test"
341 /// \brief Matches class, struct, and union declarations.
343 /// Example matches \c X, \c Z, \c U, and \c S
354 /// \brief Matches C++ class declarations.
356 /// Example matches \c X, \c Z
365 /// \brief Matches C++ class template declarations.
367 /// Example matches \c Z
375 /// \brief Matches C++ class template specializations.
384 /// matches the specializations \c A<int> and \c A<double>
389 /// \brief Matches declarator declarations (field, variable, function
397 /// matches \c int y.
401 /// \brief Matches parameter variable declarations.
408 /// matches \c int x.
411 /// \brief Matches C++ access specifier declarations.
421 /// matches 'public:'
426 /// \brief Matches constructor initializers.
428 /// Examples matches \c i(42).
437 /// \brief Matches template arguments.
445 /// matches 'int' in C<int>.
448 /// \brief Matches template name.
456 /// matches 'X' in X<int>.
459 /// \brief Matches non-type template parameter declarations.
466 /// matches 'N', but not 'T'.
471 /// \brief Matches template type parameter declarations.
478 /// matches 'T', but not 'N'.
483 /// \brief Matches public C++ declarations.
494 /// matches 'int a;'
499 /// \brief Matches protected C++ declarations.
510 /// matches 'int b;'
515 /// \brief Matches private C++ declarations.
526 /// matches 'int c;'
531 /// \brief Matches non-static data members that are bit-fields.
541 /// matches 'int a;' but not 'int b;'.
546 /// \brief Matches non-static data members that are bit-fields of the specified
558 /// matches 'int a;' and 'int c;' but not 'int b;'.
564 /// \brief Matches non-static data members that have an in-class initializer.
575 /// matches 'int a;' but not 'int b;'.
577 /// matches 'int a;' and 'int b;' but not 'int c;'.
582 InnerMatcher.matches(*Initializer, Finder, Builder));
585 /// \brief Matches
593 /// matches 'B' with classTemplateDecl() matching the class template
599 InnerMatcher.matches(*Decl, Finder, Builder));
602 /// \brief Matches a declaration that has been implicitly added
608 /// \brief Matches classTemplateSpecializations, templateSpecializationType and
625 /// matches the specialization \c A<int>
628 /// matches the specialization \c f<int>
641 /// \brief Matches expressions that match InnerMatcher after any implicit AST
664 return InnerMatcher.matches(*Node.IgnoreImplicit(), Finder, Builder);
667 /// \brief Matches expressions that match InnerMatcher after any implicit casts
694 return InnerMatcher.matches(*Node.IgnoreImpCasts(), Finder, Builder);
697 /// \brief Matches expressions that match InnerMatcher after parentheses and
715 return InnerMatcher.matches(*Node.IgnoreParenCasts(), Finder, Builder);
718 /// \brief Matches expressions that match InnerMatcher after implicit casts and
741 return InnerMatcher.matches(*Node.IgnoreParenImpCasts(), Finder, Builder);
744 /// \brief Matches types that match InnerMatcher after any parens are stripped.
757 return InnerMatcher.matches(Node.IgnoreParens(), Finder, Builder);
760 /// \brief Matches classTemplateSpecializations, templateSpecializationType and
761 /// functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
774 /// matches the specialization \c A<bool, int>
777 /// matches the specialization \c f<int>
788 return InnerMatcher.matches(List[N], Finder, Builder);
791 /// \brief Matches if the number of template arguments equals \p N.
799 /// matches C<int>.
808 /// \brief Matches a TemplateArgument that refers to a certain type.
818 /// matches the specialization \c A<X>
823 return InnerMatcher.matches(Node.getAsType(), Finder, Builder);
826 /// \brief Matches a TemplateArgument that refers to a certain template.
836 /// matches the specialization \c X<Y>
841 return InnerMatcher.matches(Node.getAsTemplate(), Finder, Builder);
844 /// \brief Matches a canonical TemplateArgument that refers to a certain
855 /// matches the specialization \c A<&B::next> with \c fieldDecl(...) matching
860 return InnerMatcher.matches(*Node.getAsDecl(), Finder, Builder);
864 /// \brief Matches a sugar TemplateArgument that refers to a certain expression.
874 /// matches the specialization \c A<&B::next> with \c fieldDecl(...) matching
878 return InnerMatcher.matches(*Node.getAsExpr(), Finder, Builder);
882 /// \brief Matches a TemplateArgument that is an integral value.
891 /// matches the implicit instantiation of C in C<42>
897 /// \brief Matches a TemplateArgument that referes to an integral type.
906 /// matches the implicit instantiation of C in C<42>.
911 return InnerMatcher.matches(Node.getIntegralType(), Finder, Builder);
914 /// \brief Matches a TemplateArgument of integral type with a given value.
927 /// matches the implicit instantiation of C in C<42>.
935 /// \brief Matches any value declaration.
937 /// Example matches A, B, C and F
944 /// \brief Matches C++ constructor declarations.
946 /// Example matches Foo::Foo() and Foo::Foo(int)
959 /// \brief Matches explicit C++ destructor declarations.
961 /// Example matches Foo::~Foo()
972 /// \brief Matches enum declarations.
974 /// Example matches X
982 /// \brief Matches enum constants.
984 /// Example matches A, B, C
994 /// \brief Matches method declarations.
996 /// Example matches y
1002 /// \brief Matches conversion operator declarations.
1004 /// Example matches the operator.
1011 /// \brief Matches variable declarations.
1016 /// Example matches a
1022 /// \brief Matches field declarations.
1029 /// matches 'm'.
1032 /// \brief Matches function declarations.
1034 /// Example matches f
1040 /// \brief Matches C++ function template declarations.
1042 /// Example matches f
1050 /// \brief Matches friend declarations.
1057 /// matches 'friend void foo()'.
1060 /// \brief Matches statements.
1067 /// matches both the compound statement '{ ++a; }' and '++a'.
1070 /// \brief Matches declaration statements.
1077 /// matches 'int a'.
1082 /// \brief Matches member expressions.
1092 /// matches this->x, x, y.x, a, this->b
1095 /// \brief Matches call expressions.
1097 /// Example matches x.y() and y()
1105 /// \brief Matches lambda expressions.
1107 /// Example matches [&](){return 5;}
1113 /// \brief Matches member call expressions.
1115 /// Example matches x.y()
1124 /// \brief Matches ObjectiveC Message invocation expressions.
1137 /// \brief Matches Objective-C interface declarations.
1139 /// Example matches Foo
1148 /// \brief Matches Objective-C implementation declarations.
1150 /// Example matches Foo
1159 /// \brief Matches Objective-C protocol declarations.
1161 /// Example matches FooDelegate
1170 /// \brief Matches Objective-C category declarations.
1172 /// Example matches Foo (Additions)
1181 /// \brief Matches Objective-C method declarations.
1183 /// Example matches both declaration and definition of -[Foo method]
1197 /// \brief Matches Objective-C instance variable declarations.
1199 /// Example matches _enabled
1210 /// \brief Matches Objective-C property declarations.
1212 /// Example matches enabled
1222 /// \brief Matches expressions that introduce cleanups to be run at the end
1225 /// Example matches std::string()
1233 /// \brief Matches init list expressions.
1242 /// matches "{ 1, 2 }" and "{ 5, 6 }"
1245 /// \brief Matches the syntactic form of init list expressions
1251 InnerMatcher.matches(*SyntForm, Finder, Builder));
1254 /// \brief Matches C++ initializer list expressions.
1264 /// matches "{ 1, 2, 3 }" and "{ 4, 5 }"
1268 /// \brief Matches implicit initializers of init list expressions.
1275 /// matches "[0].y" (implicitly)
1279 /// \brief Matches paren list expressions.
1292 /// parenListExpr() matches "*this" but NOT matches (a, b) because (a, b)
1296 /// \brief Matches substitutions of non-type template parameters.
1305 /// matches "N" in the right-hand side of "static const int n = N;"
1310 /// \brief Matches using declarations.
1318 /// matches \code using X::x \endcode
1321 /// \brief Matches using namespace declarations.
1329 /// matches \code using namespace X \endcode
1334 /// \brief Matches reference to a name that can be looked up during parsing
1347 /// matches \code foo<T>() \endcode
1352 /// \brief Matches unresolved using value declarations.
1362 /// matches \code using X::x \endcode
1367 /// \brief Matches unresolved using value declarations that involve the
1381 /// matches \code using Base<T>::Foo \endcode
1386 /// \brief Matches parentheses used in expressions.
1388 /// Example matches (foo() + 1)
1397 /// \brief Matches constructor call expressions (including implicit ones).
1399 /// Example matches string(ptr, n) and ptr within arguments of f
1411 /// \brief Matches unresolved constructor call expressions.
1413 /// Example matches T(t) in return statement of f
1423 /// \brief Matches implicit and explicit this expressions.
1425 /// Example matches the implicit this expression in "return i".
1435 /// \brief Matches nodes where temporaries are created.
1437 /// Example matches FunctionTakesString(GetStringByValue())
1447 /// \brief Matches nodes where temporaries are materialized.
1455 /// materializeTemporaryExpr() matches 'f()' in these statements
1469 /// \brief Matches new expressions.
1476 /// matches 'new X'.
1479 /// \brief Matches delete expressions.
1486 /// matches 'delete X'.
1489 /// \brief Matches array subscript expressions.
1496 /// matches "a[1]"
1501 /// \brief Matches the value of a default argument at the call site.
1503 /// Example matches the CXXDefaultArgExpr placeholder inserted for the
1514 /// \brief Matches overloaded operator calls.
1521 /// Example matches both operator<<((o << b), c) and operator<<(o, b)
1532 /// \brief Matches expressions.
1534 /// Example matches x()
1540 /// \brief Matches expressions that refer to declarations.
1542 /// Example matches x in if (x)
1549 /// \brief Matches if statements.
1551 /// Example matches 'if (x) {}'
1557 /// \brief Matches for statements.
1559 /// Example matches 'for (;;) {}'
1566 /// \brief Matches the increment statement of a for loop.
1570 /// matches '++x' in
1578 InnerMatcher.matches(*Increment, Finder, Builder));
1581 /// \brief Matches the initialization statement of a for loop.
1585 /// matches 'int x = 0' in
1592 return (Init != nullptr && InnerMatcher.matches(*Init, Finder, Builder));
1595 /// \brief Matches range-based for statements.
1597 /// cxxForRangeStmt() matches 'for (auto a : i)'
1606 /// \brief Matches the initialization statement of a for loop.
1610 /// matches 'int x' in
1617 return (Var != nullptr && InnerMatcher.matches(*Var, Finder, Builder));
1620 /// \brief Matches the range initialization statement of a for loop.
1624 /// matches 'a' in
1631 return (Init != nullptr && InnerMatcher.matches(*Init, Finder, Builder));
1634 /// \brief Matches while statements.
1641 /// matches 'while (true) {}'.
1644 /// \brief Matches do statements.
1651 /// matches 'do {} while(true)'
1654 /// \brief Matches break statements.
1661 /// matches 'break'
1664 /// \brief Matches continue statements.
1671 /// matches 'continue'
1674 /// \brief Matches return statements.
1681 /// matches 'return 1'
1684 /// \brief Matches goto statements.
1692 /// matches 'goto FOO'
1695 /// \brief Matches label statements.
1703 /// matches 'FOO:'
1706 /// \brief Matches address of label statements (GNU extension).
1715 /// matches '&&FOO'
1718 /// \brief Matches switch statements.
1725 /// matches 'switch(a)'.
1728 /// \brief Matches case and default statements inside switch statements.
1735 /// matches 'case 42: break;' and 'default: break;'.
1738 /// \brief Matches case statements inside switch statements.
1745 /// matches 'case 42: break;'.
1748 /// \brief Matches default statements inside switch statements.
1755 /// matches 'default: break;'.
1758 /// \brief Matches compound statements.
1760 /// Example matches '{}' and '{{}}'in 'for (;;) {{}}'
1766 /// \brief Matches catch statements.
1772 /// matches 'catch(int i)'
1775 /// \brief Matches try statements.
1781 /// matches 'try {}'
1784 /// \brief Matches throw expressions.
1790 /// matches 'throw 5'
1793 /// \brief Matches null statements.
1799 /// matches the second ';'
1802 /// \brief Matches asm statements.
1809 /// matches '__asm("mov al, 2")'
1812 /// \brief Matches bool literals.
1814 /// Example matches true
1822 /// \brief Matches string literals (also matches wide string literals).
1824 /// Example matches "abcd", L"abcd"
1833 /// \brief Matches character literals (also matches wchar_t).
1838 /// Example matches 'a', L'a'
1847 /// \brief Matches integer literals of all sizes / encodings, e.g.
1855 /// \brief Matches float literals of all sizes / encodings, e.g.
1866 /// \brief Matches user defined literal operator call.
1873 /// \brief Matches compound (i.e. non-scalar) literals
1884 /// \brief Matches nullptr literal.
1889 /// \brief Matches GNU __null expression.
1892 /// \brief Matches atomic builtins.
1893 /// Example matches __atomic_load_n(ptr, 1)
1899 /// \brief Matches statement expression (GNU extension).
1907 /// \brief Matches binary operator expressions.
1909 /// Example matches a || b
1917 /// \brief Matches unary operator expressions.
1919 /// Example matches !a
1927 /// \brief Matches conditional operator expressions.
1929 /// Example matches a ? b : c
1937 /// \brief Matches binary conditional operator expressions (GNU extension).
1939 /// Example matches a ?: b
1947 /// \brief Matches opaque value expressions. They are used as helpers
1951 /// Example matches 'a'
1959 /// \brief Matches a C++ static_assert declaration.
1963 /// matches
1976 /// \brief Matches a reinterpret_cast expression.
1982 /// Example matches reinterpret_cast<char*>(&p) in
1990 /// \brief Matches a C++ static_cast expression.
1997 /// matches
2007 /// \brief Matches a dynamic_cast expression.
2011 /// matches
2023 /// \brief Matches a const_cast expression.
2025 /// Example: Matches const_cast<int*>(&r) in
2035 /// \brief Matches a C-style cast expression.
2037 /// Example: Matches (int) 2.2f in
2045 /// \brief Matches explicit cast expressions.
2047 /// Matches any cast expression written in user code, whether it be a
2058 /// Example: matches all five of the casts in
2070 /// \brief Matches the implicit cast nodes of Clang's AST.
2072 /// This matches many different places, including function call return value
2078 /// \brief Matches any cast nodes of Clang's AST.
2080 /// Example: castExpr() matches each of the following:
2093 /// \brief Matches functional cast expressions
2095 /// Example: Matches Foo(bar);
2105 /// \brief Matches functional cast expressions having N != 1 arguments
2107 /// Example: Matches Foo(bar, bar)
2115 /// \brief Matches predefined identifier expressions [C99 6.4.2.2].
2117 /// Example: Matches __func__
2125 /// \brief Matches C99 designated initializer expressions [C99 6.7.8].
2127 /// Example: Matches { [2].y = 1.0, [0].x = 1.0 }
2135 /// \brief Matches designated initializer expressions that contain
2144 /// matches '{ [2].y = 1.0, [0].x = 1.0 }',
2150 /// \brief Matches \c QualTypes in the clang AST.
2153 /// \brief Matches \c Types in the clang AST.
2156 /// \brief Matches \c TypeLocs in the clang AST.
2159 /// \brief Matches if any of the given matchers matches.
2182 /// \brief Matches if any of the given matchers matches.
2189 /// \brief Matches if all given matchers match.
2196 /// \brief Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
2204 /// matches \c sizeof(x) and \c alignof(x)
2209 /// \brief Matches unary expressions that have a specific type of argument.
2216 /// matches \c sizeof(a) and \c alignof(c)
2220 return InnerMatcher.matches(ArgumentType, Finder, Builder);
2223 /// \brief Matches unary expressions of a certain kind.
2231 /// matches \c sizeof(x)
2252 /// \brief Matches NamedDecl nodes that have the specified name.
2258 /// Example matches X (Name == "X")
2263 /// Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")
2273 /// \brief Matches NamedDecl nodes that have any of the specified names.
2287 /// \brief Matches NamedDecl nodes whose fully qualified names contain
2294 /// Example matches X (regexp == "::X")
2299 /// Example matches X (regexp is one of "::X", "^foo::.*X", among others)
2310 /// \brief Matches overloaded operator names.
2312 /// Matches overloaded operator names specified in strings without the
2320 /// a << a; // <-- This matches
2323 /// \c cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the
2326 /// matches the declaration of \c A.
2338 /// \brief Matches C++ classes that are directly or indirectly derived from
2343 /// Example matches Y, Z, C (Base == hasName("X"))
2353 /// In the following example, Bar matches isDerivedFrom(hasName("X")):
2367 return isDerivedFrom(hasName(BaseName)).matches(Node, Finder, Builder);
2370 /// \brief Similar to \c isDerivedFrom(), but also matches classes that directly
2375 .matches(Node, Finder, Builder);
2383 return isSameOrDerivedFrom(hasName(BaseName)).matches(Node, Finder, Builder);
2386 /// \brief Matches the first method of a class or struct that satisfies \c
2395 /// \c cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of
2403 /// \brief Matches the generated class of lambda expressions.
2410 /// \c cxxRecordDecl(isLambda()) matches the implicit class declaration of
2416 /// \brief Matches AST nodes that have child AST nodes that match the
2419 /// Example matches X, Y
2422 /// class X {}; // Matches X, because X::X is a class of name X inside X.
2430 /// Note that has is direct matcher, so it also matches things like implicit
2437 /// \brief Matches AST nodes that have descendant AST nodes that match the
2440 /// Example matches X, Y, Z
2443 /// class X {}; // Matches X, because X::X is a class of name X inside X.
2454 /// \brief Matches AST nodes that have child AST nodes that match the
2457 /// Example matches X, Y
2460 /// class X {}; // Matches X, because X::X is a class of name X inside X.
2468 /// matches instead of only on the first one.
2474 /// \brief Matches AST nodes that have descendant AST nodes that match the
2477 /// Example matches X, A, B, C
2480 /// class X {}; // Matches X, because X::X is a class of name X inside X.
2488 /// each result that matches instead of only on the first one.
2490 /// Note: Recursively combined ForEachDescendant can cause many matches:
2494 /// will match 10 times (plus injected class name matches) on:
2503 /// \brief Matches if the node or any descendant matches.
2524 /// \brief Matches AST nodes that have a parent that matches the provided
2531 /// \c compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }".
2540 /// \brief Matches AST nodes that have an ancestor that matches the provided
2548 /// \c expr(integerLiteral(hasAncestor(ifStmt()))) matches \c 42, but not 43.
2557 /// \brief Matches if the provided matcher does not match.
2559 /// Example matches Y (matcher = cxxRecordDecl(unless(hasName("X"))))
2570 /// \brief Matches a node if the declaration associated with that node
2571 /// matches the given matcher.
2612 /// \brief Matches a \c NamedDecl whose underlying declaration matches the given
2622 /// matches the use of \c f in \c g() .
2628 InnerMatcher.matches(*UnderlyingDecl, Finder, Builder);
2631 /// \brief Matches on the implicit object argument of a member call expression.
2633 /// Example matches y.x()
2646 InnerMatcher.matches(*ExprNode, Finder, Builder));
2650 /// \brief Matches on the receiver of an ObjectiveC Message expression.
2654 /// matches the [webView ...] message invocation.
2663 return InnerMatcher.matches(TypeDecl, Finder, Builder);
2666 /// \brief Matches when BaseName == Selector.getAsString()
2669 /// matches the outer message expr in the code below, but NOT the message
2680 /// \brief Matches ObjC selectors whose name contains
2683 /// matches the outer message expr in the code below, but NOT the message
2695 /// \brief Matches when the selector is the empty selector
2697 /// Matches only when the selector of the objCMessageExpr is NULL. This may
2703 /// \brief Matches when the selector is a Unary Selector
2706 /// matches self.bodyView in the code below, but NOT the outer message
2715 /// \brief Matches when the selector is a keyword selector
2717 /// objCMessageExpr(hasKeywordSelector()) matches the generated setFrame
2725 /// // ^---- matches here
2731 /// \brief Matches when the selector has the specified number of arguments
2734 /// matches self.bodyView in the code below
2737 /// matches the invocation of "loadHTMLString:baseURL:" but not that
2746 /// \brief Matches if the call expression's callee expression matches.
2754 /// matches this->x(), x(), y.x(), f()
2766 InnerMatcher.matches(*ExprNode, Finder, Builder));
2769 /// \brief Matches if the call expression's callee's declaration matches the
2772 /// Example matches y.x() (matcher = callExpr(callee(
2780 return callExpr(hasDeclaration(InnerMatcher)).matches(Node, Finder, Builder);
2783 /// \brief Matches if the expression's or declaration's type matches a type
2786 /// Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
2797 return InnerMatcher.matches(internal::getUnderlyingType(Node),
2806 /// declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
2807 /// X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
2810 /// Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
2823 .matches(Node.getType(), Finder, Builder);
2826 /// \brief Matches if the type location of the declarator decl's type matches
2834 /// matches int x
2839 return Inner.matches(Node.getTypeSourceInfo()->getTypeLoc(), Finder, Builder);
2842 /// \brief Matches if the matched type is represented by the given string.
2850 /// matches y->x()
2855 /// \brief Matches if the matched type is a pointer type and the pointee type
2856 /// matches the specified matcher.
2858 /// Example matches y->x()
2869 InnerMatcher.matches(Node->getPointeeType(), Finder, Builder));
2876 .matches(Node, Finder, Builder);
2879 /// \brief Matches if the matched type matches the unqualified desugared
2887 /// The matcher type(hasUnqualifeidDesugaredType(recordType())) matches
2891 return InnerMatcher.matches(*Node.getUnqualifiedDesugaredType(), Finder,
2895 /// \brief Matches if the matched type is a reference type and the referenced
2896 /// type matches the specified matcher.
2898 /// Example matches X &x and const X &y
2911 InnerMatcher.matches(Node->getPointeeType(), Finder, Builder));
2914 /// \brief Matches QualTypes whose canonical type matches InnerMatcher.
2930 return InnerMatcher.matches(Node.getCanonicalType(), Finder, Builder);
2937 .matches(Node, Finder, Builder);
2944 InnerMatcher.matches(*ExprNode, Finder, Builder));
2947 /// \brief Matches if the expression's type either matches the specified
2948 /// matcher, or is a pointer to a type that matches the InnerMatcher.
2953 .matches(Node, Finder, Builder);
2961 .matches(Node, Finder, Builder);
2964 /// \brief Matches a DeclRefExpr that refers to a declaration that matches the
2967 /// Example matches x in if(x)
2977 InnerMatcher.matches(*DeclNode, Finder, Builder));
2980 /// \brief Matches a \c DeclRefExpr that refers to a declaration through a
2988 /// f(); // Matches this ..
2993 /// matches \c f()
2998 return InnerMatcher.matches(*UsingDecl, Finder, Builder);
3002 /// \brief Matches an \c OverloadExpr if any of the declarations in the set of
3003 /// overloads matches the given matcher.
3016 /// matches \c foo in \c foo(t); but not \c bar in \c bar(t);
3023 /// \brief Matches the Decl of a DeclStmt which has a single declaration.
3031 /// matches 'int c;' but not 'int a, b;'.
3035 return InnerMatcher.matches(*FoundDecl, Finder, Builder);
3040 /// \brief Matches a variable declaration that has an initializer expression
3041 /// that matches the given matcher.
3043 /// Example matches x (matcher = varDecl(hasInitializer(callExpr())))
3053 InnerMatcher.matches(*Initializer, Finder, Builder));
3056 /// \brief Matches a variable declaration that has function scope and is a
3059 /// Example matches x (matcher = varDecl(hasLocalStorage())
3071 /// \brief Matches a variable declaration that does not have local storage.
3073 /// Example matches y and z (matcher = varDecl(hasGlobalStorage())
3085 /// \brief Matches a variable declaration that has automatic storage duration.
3087 /// Example matches x, but not y, z, or a.
3101 /// \brief Matches a variable declaration that has static storage duration.
3115 /// matches the function declaration y, a, b and c.
3121 /// \brief Matches a variable declaration that has thread storage duration.
3123 /// Example matches z, but not x, z, or a.
3137 /// \brief Matches a variable declaration that is an exception variable from
3140 /// Example matches x (matcher = varDecl(isExceptionVariable())
3155 /// Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
3168 /// \brief Matches the n'th argument of a call expression or a constructor
3171 /// Example matches y in x(y)
3182 InnerMatcher.matches(
3186 /// \brief Matches declaration statements that contain a specific number of
3196 /// matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'.
3201 /// \brief Matches the n'th declaration of a declaration statement.
3214 /// matches only 'int d = 2, e;', and
3217 /// matches 'int a, b = 0' as well as 'int d = 2, e;'
3227 return InnerMatcher.matches(**Iterator, Finder, Builder);
3230 /// \brief Matches a C++ catch statement that has a catch-all handler.
3242 /// cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
3247 /// \brief Matches a constructor initializer.
3259 /// record matches Foo, hasAnyConstructorInitializer matches foo_(1)
3266 /// \brief Matches the field declaration of a constructor initializer.
3277 /// matches Foo
3283 InnerMatcher.matches(*NodeAsDecl, Finder, Builder));
3286 /// \brief Matches the initializer expression of a constructor initializer.
3297 /// matches Foo
3303 InnerMatcher.matches(*NodeAsExpr, Finder, Builder));
3306 /// \brief Matches a constructor initializer if it is explicitly written in
3323 /// \brief Matches a constructor initializer if it is initializing a base, as
3343 /// \brief Matches a constructor initializer if it is initializing a member, as
3363 /// \brief Matches any argument of a call expression or a constructor call
3371 /// matches x(1, y, 42)
3380 if (InnerMatcher.matches(*Arg, Finder, &Result)) {
3388 /// \brief Matches a constructor call expression which uses list initialization.
3393 /// \brief Matches a constructor call expression which requires
3409 /// \brief Matches the n'th parameter of a function declaration.
3416 /// matches f(int x) {}
3423 InnerMatcher.matches(
3427 /// \brief Matches all arguments and their respective ParmVarDecl.
3440 /// matches f(y);
3454 BoundNodesTreeBuilder Matches;
3456 .matches(Node, Finder, &Matches)
3463 if (ArgMatcher.matches(*(Node.getArg(ArgIndex)->IgnoreParenCasts()),
3470 .matches(Node, Finder, &ParamMatches)) {
3481 /// \brief Matches any parameter of a function declaration.
3490 /// matches f(int x, int y, int z) {}
3499 /// \brief Matches \c FunctionDecls and \c FunctionProtoTypes that have a
3511 /// matches void g(int i, int j) {}
3513 /// matches void h(int i, int j)
3515 /// matches void k(int x, int y, int z, ...);
3523 /// \brief Matches the return type of a function declaration.
3530 /// matches int f() { return 1; }
3533 return InnerMatcher.matches(Node.getReturnType(), Finder, Builder);
3536 /// \brief Matches extern "C" function or variable declarations.
3548 /// matches the declaration of f and g, but not the declaration of h.
3550 /// matches the declaration of x and y, but not the declaration of z.
3556 /// \brief Matches variable/function declarations that have "static" storage
3567 /// matches the function declaration f.
3569 /// matches the variable declaration i.
3576 /// \brief Matches deleted function declarations.
3584 /// matches the declaration of DeletedFunc, but not Func.
3589 /// \brief Matches defaulted function declarations.
3597 /// matches the declaration of ~B, but not ~A.
3602 /// \brief Matches functions that have a dynamic exception specification.
3625 /// \brief Matches functions that have a non-throwing exception specification.
3655 /// \brief Matches constexpr variable and function declarations.
3663 /// matches the declaration of foo.
3665 /// matches the declaration of bar.
3672 /// \brief Matches the condition expression of an if statement, for loop,
3675 /// Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
3686 InnerMatcher.matches(*Condition, Finder, Builder));
3689 /// \brief Matches the then-statement of an if statement.
3691 /// Examples matches the if statement
3698 return (Then != nullptr && InnerMatcher.matches(*Then, Finder, Builder));
3701 /// \brief Matches the else-statement of an if statement.
3703 /// Examples matches the if statement
3710 return (Else != nullptr && InnerMatcher.matches(*Else, Finder, Builder));
3713 /// \brief Matches if a node equals a previously bound node.
3715 /// Matches a node if it equals the node previously bound to \p ID.
3724 /// matches the class \c X, as \c a and \c b have the same type.
3726 /// Note that when multiple matches are involved via \c forEach* matchers,
3750 /// \brief Matches the condition variable statement in an if statement.
3757 /// matches 'A* a = GetAPointer()'.
3763 InnerMatcher.matches(*DeclarationStatement, Finder, Builder);
3766 /// \brief Matches the index expression of an array subscript expression.
3774 /// matches \c i[1] with the \c integerLiteral() matching \c 1
3778 return InnerMatcher.matches(*Expression, Finder, Builder);
3782 /// \brief Matches the base expression of an array subscript expression.
3791 /// matches \c i[1] with the \c declRefExpr() matching \c i
3795 return InnerMatcher.matches(*Expression, Finder, Builder);
3799 /// \brief Matches a 'for', 'while', 'do while' statement or a function
3807 /// matches 'for (;;) {}'
3818 InnerMatcher.matches(*Statement, Finder, Builder));
3821 /// \brief Matches compound statements where at least one substatement matches
3822 /// a given matcher. Also matches StmtExprs that have CompoundStmt as children.
3829 /// matches '{ {}; 1+2; }'
3849 /// matches '{}'
3855 /// \brief Matches literals that are equal to the given value of type ValueT.
3862 /// matches '\0'
3868 /// matches 42
3916 /// \brief Matches the operator Name of operator expressions (binary or
3919 /// Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
3930 /// \brief Matches the left hand side of binary operator expressions.
3932 /// Example matches a (matcher = binaryOperator(hasLHS()))
3942 InnerMatcher.matches(*LeftHandSide, Finder, Builder));
3945 /// \brief Matches the right hand side of binary operator expressions.
3947 /// Example matches b (matcher = binaryOperator(hasRHS()))
3957 InnerMatcher.matches(*RightHandSide, Finder, Builder));
3960 /// \brief Matches if either the left hand side or the right hand side of a
3961 /// binary operator matches.
3967 /// \brief Matches if the operand of a unary operator matches.
3969 /// Example matches true (matcher = hasUnaryOperand(
3978 InnerMatcher.matches(*Operand, Finder, Builder));
3981 /// \brief Matches if the cast's source expression
3982 /// or opaque value's source expression matches the given matcher.
3984 /// Example 1: matches "a string"
3991 /// Example 2: matches 'b' (matcher =
4004 InnerMatcher.matches(*SubExpression, Finder, Builder));
4007 /// \brief Matches casts that has a given cast kind.
4009 /// Example: matches the implicit cast around \c 0
4018 /// \brief Matches casts whose destination type matches a given matcher.
4025 return InnerMatcher.matches(NodeType, Finder, Builder);
4028 /// \brief Matches implicit casts whose destination type matches a given
4034 return InnerMatcher.matches(Node.getType(), Finder, Builder);
4037 /// \brief Matches RecordDecl object that are spelled with "struct."
4039 /// Example matches S, but not C or U.
4049 /// \brief Matches RecordDecl object that are spelled with "union."
4051 /// Example matches U, but not C or S.
4061 /// \brief Matches RecordDecl object that are spelled with "class."
4063 /// Example matches C, but not S or U.
4073 /// \brief Matches the true branch expression of a conditional operator.
4075 /// Example 1 (conditional ternary operator): matches a
4080 /// Example 2 (conditional binary operator): matches opaqueValueExpr(condition)
4088 InnerMatcher.matches(*Expression, Finder, Builder));
4091 /// \brief Matches the false branch expression of a conditional operator
4094 /// Example matches b
4103 InnerMatcher.matches(*Expression, Finder, Builder));
4106 /// \brief Matches if a declaration has a body attached.
4108 /// Example matches A, va, fa
4125 /// \brief Matches if a function declaration is variadic.
4127 /// Example matches f, but not g or h. The function i will not match, even when
4139 /// \brief Matches the class declaration that the given method declaration
4146 /// Example matches A() in the last line
4160 InnerMatcher.matches(*Parent, Finder, Builder));
4163 /// \brief Matches each method overriden by the given method. This matcher may
4164 /// produce multiple matches.
4174 /// matches once, with "b" binding "A::f" and "d" binding "C::f" (Note
4177 /// The check can produce multiple matches in case of multiple inheritance, e.g.
4185 /// matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and
4194 InnerMatcher.matches(*Overridden, Finder, &OverriddenBuilder);
4204 /// \brief Matches if the given method declaration is virtual.
4213 /// matches A::x
4218 /// \brief Matches if the given method declaration has an explicit "virtual".
4231 /// matches A::x but not B::x
4236 /// \brief Matches if the given method or class declaration is final.
4250 /// matches A and C::f, but not B, C, or B::f
4257 /// \brief Matches if the given method declaration is pure.
4266 /// matches A::x
4271 /// \brief Matches if the given method declaration is const.
4281 /// cxxMethodDecl(isConst()) matches A::foo() but not A::bar()
4286 /// \brief Matches if the given method declaration declares a copy assignment
4297 /// cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not
4303 /// \brief Matches if the given method declaration declares a move assignment
4314 /// cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not
4320 /// \brief Matches if the given method declaration overrides another method.
4333 /// matches B::x
4338 /// \brief Matches method declarations that are user-provided.
4353 /// \brief Matches member expressions that are called with '->' as opposed
4367 /// matches this->x, x, y.x, a, this->b
4372 /// \brief Matches QualType nodes that are of integer type.
4381 /// matches
4386 /// \brief Matches QualType nodes that are of unsigned integer type.
4395 /// matches "b(unsigned long)", but not "a(int)" and "c(double)".
4400 /// \brief Matches QualType nodes that are of signed integer type.
4409 /// matches "a(int)", but not "b(unsigned long)" and "c(double)".
4414 /// \brief Matches QualType nodes that are of character type.
4423 /// matches "a(char)", "b(wchar_t)", but not "c(double)".
4428 /// \brief Matches QualType nodes that are of any pointer type; this includes
4443 /// matches "int *i" and "Foo *f", but not "int j".
4448 /// \brief Matches QualType nodes that are const-qualified, i.e., that
4460 /// matches "void b(int const)", "void c(const int)" and
4467 /// \brief Matches QualType nodes that are volatile-qualified, i.e., that
4479 /// matches "void b(int volatile)", "void c(volatile int)" and
4486 /// \brief Matches QualType nodes that have local CV-qualifiers attached to
4497 /// \c varDecl(hasType(hasLocalQualifiers())) matches only \c j and \c k.
4503 /// \brief Matches a member expression where the member is matched by a
4513 /// matches second.first
4517 return InnerMatcher.matches(*Node.getMemberDecl(), Finder, Builder);
4520 /// \brief Matches a member expression where the object expression is
4529 /// matches "x.m" and "m"
4534 return InnerMatcher.matches(*Node.getBase(), Finder, Builder);
4537 /// \brief Matches any using shadow declaration.
4545 /// matches \code using X::b \endcode
4552 /// \brief Matches a using shadow declaration where the target declaration is
4562 /// matches \code using X::b \endcode
4566 return InnerMatcher.matches(*Node.getTargetDecl(), Finder, Builder);
4569 /// \brief Matches template instantiations of function, class, or static
4581 /// matches the template instantiation of X<A>.
4600 /// \brief Matches declarations that are template instantiations or are inside
4610 /// matches 'A(int) {...};' and 'A(unsigned) {...}'.
4617 /// \brief Matches statements inside of a template instantiation.
4627 /// matches 'int i;' and 'unsigned i'.
4637 /// \brief Matches explicit template specializations of function, class, or
4646 /// matches the specialization A<int>().
4655 /// \brief Matches \c TypeLocs for which the given inner
4656 /// QualType-matcher matches.
4663 /// \brief Matches type \c bool.
4670 /// matches "bool func();"
4675 /// \brief Matches type \c void.
4682 /// matches "void func();"
4687 /// \brief Matches builtin Types.
4698 /// matches "int b", "float c" and "bool d"
4701 /// \brief Matches all kinds of arrays.
4710 /// matches "int a[]", "int b[4]" and "int c[a[0]]";
4713 /// \brief Matches C99 complex types.
4720 /// matches "_Complex float f"
4723 /// \brief Matches any real floating-point type (float, double, long double).
4731 /// matches "float f" but not "int i"
4736 /// \brief Matches arrays and C99 complex types that have a specific element
4746 /// matches "int b[7]"
4753 /// \brief Matches C arrays with a specified constant size.
4764 /// matches "int a[2]"
4767 /// \brief Matches nodes that have the specified size.
4779 /// matches "int a[42]" and "int b[2 * 21]"
4781 /// matches "abcd", L"abcd"
4789 /// \brief Matches C++ arrays whose size is a value-dependent expression.
4799 /// matches "T data[Size]"
4802 /// \brief Matches C arrays with unspecified size.
4811 /// matches "int a[]" and "int c[]"
4814 /// \brief Matches C arrays with a specified size that is not an
4826 /// matches "int c[a[0]]"
4829 /// \brief Matches \c VariableArrayType nodes that have a specific size
4840 /// matches "int a[b]"
4843 return InnerMatcher.matches(*Node.getSizeExpr(), Finder, Builder);
4846 /// \brief Matches atomic types.
4853 /// matches "_Atomic(int) i"
4856 /// \brief Matches atomic types with a specific value type.
4864 /// matches "_Atomic(int) i"
4870 /// \brief Matches types nodes representing C++11 auto types.
4879 /// matches "auto n" and "auto i"
4882 /// \brief Matches \c AutoType nodes where the deduced type is a specific type.
4893 /// matches "auto a"
4899 /// \brief Matches \c FunctionType nodes.
4907 /// matches "int (*f)(int)" and the type of "g".
4910 /// \brief Matches \c FunctionProtoType nodes.
4918 /// matches "int (*f)(int)" and the type of "g" in C++ mode.
4922 /// \brief Matches \c ParenType nodes.
4930 /// \c varDecl(hasType(pointsTo(parenType()))) matches \c ptr_to_array but not
4934 /// \brief Matches \c ParenType nodes where the inner type is a specific type.
4942 /// \c varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches
4949 /// \brief Matches block pointer types, i.e. types syntactically represented as
4955 /// \brief Matches member pointer types.
4962 /// matches "A::* ptr"
4965 /// \brief Matches pointer types, but does not match Objective-C object pointer
4979 /// matches "int *a", but does not match "Foo *f".
4982 /// \brief Matches an Objective-C object pointer type, which is different from
4994 /// matches "Foo *f", but does not match "int *a".
4997 /// \brief Matches both lvalue and rvalue reference types.
5010 /// \c referenceType() matches the types of \c b, \c c, \c d, \c e, and \c f.
5013 /// \brief Matches lvalue reference types.
5026 /// \c lValueReferenceType() matches the types of \c b, \c d, and \c e. \c e is
5030 /// \brief Matches rvalue reference types.
5043 /// \c rValueReferenceType() matches the types of \c c and \c f. \c e is not
5048 /// \c pointee matches a given matcher.
5057 /// matches "int const *b"
5067 /// \brief Matches typedef types.
5074 /// matches "typedef int X"
5077 /// \brief Matches enum types.
5088 /// \c enumType() matches the type of the variable declarations of both \c c and
5092 /// \brief Matches template specialization types.
5103 /// \c templateSpecializationType() matches the type of the explicit
5107 /// \brief Matches types nodes representing unary type transformations.
5114 /// matches "__underlying_type(T)"
5117 /// \brief Matches record types (e.g. structs, classes).
5128 /// \c recordType() matches the type of the variable declarations of both \c c
5132 /// \brief Matches tag types (record and enum types).
5143 /// \c tagType() matches the type of the variable declarations of both \c e
5147 /// \brief Matches types specified with an elaborated type keyword or with a
5163 /// \c elaboratedType() matches the type of the variable declarations of both
5167 /// \brief Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
5168 /// matches \c InnerMatcher if the qualifier exists.
5181 /// matches the type of the variable declaration of \c d.
5185 return InnerMatcher.matches(*Qualifier, Finder, Builder);
5190 /// \brief Matches ElaboratedTypes whose named type matches \c InnerMatcher.
5203 /// hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable
5207 return InnerMatcher.matches(Node.getNamedType(), Finder, Builder);
5210 /// \brief Matches types that represent the result of substituting a type for a
5221 /// \c substTemplateTypeParmType() matches the type of 't' but not '1'
5224 /// \brief Matches template type parameter substitutions that have a replacement
5225 /// type that matches the provided matcher.
5235 /// \c substTemplateTypeParmType(hasReplacementType(type())) matches int
5240 /// \brief Matches template type parameter types.
5242 /// Example matches T, but not int.
5249 /// \brief Matches injected class name types.
5251 /// Example matches S s, but not S<T> s.
5261 /// \brief Matches decayed type
5262 /// Example matches i[] in declaration of f.
5264 /// Example matches i[1].
5273 /// \brief Matches the decayed type, whos decayed type matches \c InnerMatcher
5276 return InnerType.matches(Node.getDecayedType(), Finder, Builder);
5279 /// \brief Matches declarations whose declaration context, interpreted as a
5280 /// Decl, matches \c InnerMatcher.
5291 /// \c cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
5296 return InnerMatcher.matches(*Decl::castFromDeclContext(DC), Finder, Builder);
5299 /// \brief Matches nested name specifiers.
5311 /// matches "ns::" and both "A::"
5314 /// \brief Same as \c nestedNameSpecifier but matches \c NestedNameSpecifierLoc.
5318 /// \brief Matches \c NestedNameSpecifierLocs for which the given inner
5319 /// NestedNameSpecifier-matcher matches.
5328 /// \brief Matches nested name specifiers that specify a type matching the
5339 /// matches "A::"
5344 return InnerMatcher.matches(QualType(Node.getAsType(), 0), Finder, Builder);
5347 /// \brief Matches nested name specifier locs that specify a type matching the
5357 /// matches "A::"
5360 return Node && InnerMatcher.matches(Node.getTypeLoc(), Finder, Builder);
5363 /// \brief Matches on the prefix of a \c NestedNameSpecifier.
5371 /// matches "A::"
5378 return InnerMatcher.matches(*NextNode, Finder, Builder);
5381 /// \brief Matches on the prefix of a \c NestedNameSpecifierLoc.
5389 /// matches "A::"
5396 return InnerMatcher.matches(NextNode, Finder, Builder);
5399 /// \brief Matches nested name specifiers that specify a namespace matching the
5408 /// matches "ns::"
5413 return InnerMatcher.matches(*Node.getAsNamespace(), Finder, Builder);
5420 /// \brief Matches if a node equals another node.
5426 /// \brief Matches if a node equals another node.
5432 /// \brief Matches if a node equals another node.
5441 /// \brief Matches each case or default statement belonging to the given switch
5442 /// statement. This matcher may produce multiple matches.
5449 /// matches four times, with "c" binding each of "case 1:", "case 2:",
5463 bool CaseMatched = InnerMatcher.matches(*SC, Finder, &CaseBuilder);
5473 /// \brief Matches each constructor initializer in a constructor definition.
5482 /// will trigger two matches, binding for 'i' and 'j' respectively.
5489 if (InnerMatcher.matches(*I, Finder, &InitBuilder)) {
5498 /// \brief Matches constructor declarations that are copy constructors.
5513 /// \brief Matches constructor declarations that are move constructors.
5528 /// \brief Matches constructor declarations that are default constructors.
5543 /// \brief Matches constructors that delegate to another constructor.
5560 /// \brief Matches constructor and conversion declarations that are marked with
5580 /// \brief Matches function and namespace declarations that are marked with
5605 /// \brief Matches anonymous namespace declarations.
5619 /// extension, matches the constant given in the statement.
5626 /// matches "case 1:"
5632 return InnerMatcher.matches(*Node.getLHS(), Finder, Builder);
5635 /// \brief Matches declaration that has a given attribute.
5641 /// decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
5652 /// \brief Matches the return value expression of a return statement
5659 /// matches 'return a + b'
5665 return InnerMatcher.matches(*RetValue, Finder, Builder);
5670 /// \brief Matches CUDA kernel call expression.
5672 /// Example matches,
5681 /// \brief Matches expressions that resolve to a null pointer constant, such as
5694 /// matches the initializer for v1, v2, v3, cp, and ip. Does not match the
5702 /// \brief Matches declaration of the function the statement belongs to
5712 /// matches 'return *this'
5724 if(InnerMatcher.matches(*FuncDeclNode, Finder, Builder)) {
5728 if(InnerMatcher.matches(*LambdaExprNode->getCallOperator(),
5740 /// \brief Matches a declaration that has external formal linkage.
5742 /// Example matches only z (matcher = varDecl(hasExternalFormalLinkage()))
5751 /// Example matches f() because it has external formal linkage despite being