# AST Matcher Reference

This document shows all currently implemented matchers. The matchers are grouped by category and node type they match. You can click on matcher names to show the matcher's source documentation.

There are three different basic categories of matchers:

- Node Matchers: Matchers that match a specific type of AST node.
- Narrowing Matchers: Matchers that match attributes on AST nodes.
- Traversal Matchers: Matchers that allow traversal between AST nodes.

Within each category the matchers are ordered by node type they match on. Note that if a matcher can match multiple node types, it will it will appear multiple times. This means that by searching for Matcher<Stmt> you can find all matchers that can be used to match on Stmt nodes.

The exception to that rule are matchers that can match on any node. Those are marked with a * and are listed in the beginning of each category.

Note that the categorization of matchers is a great help when you combine them into matcher expressions. You will usually want to form matcher expressions that read like english sentences by alternating between node matchers and narrowing or traversal matchers, like this:

    recordDecl(hasDescendant(
        ifStmt(hasTrueExpression(
            expr(hasDescendant(
                ifStmt()))))))

## Node Matchers

Node matchers are at the core of matcher expressions - they specify the type of node that is expected. Every match expression starts with a node matcher, which can then be further refined with a narrowing or traversal matcher. All traversal matchers take node matchers as their arguments.

For convenience, all node matchers take an arbitrary number of arguments and implicitly act as allOf matchers.

Node matchers are the only matchers that support the bind("id") call to bind the matched node to the given string, to be later retrieved from the match callback.

It is important to remember that the arguments to node matchers are predicates on the same node, just with additional information about the type. This is often useful to make matcher expression more readable by inlining bind calls into redundant node matchers inside another node matcher:

    // This binds the CXXRecordDecl to "id", as the decl() matcher will stay on
    // the same node.
    recordDecl(decl().bind("id"), hasName("::MyClass"))

Return type | Name | Parameters
--- | --- | ---
Matcher<CXXCtorInitializer> | ctorInitializer | Matcher<CXXCtorInitializer>...

    Matches constructor initializers.

    Examples matches i(42).
      class C {
        C() : i(42) {}
        int i;
      };

Matcher<Decl> | accessSpecDecl | Matcher<AccessSpecDecl>...

    Matches C++ access specifier declarations.

    Given
      class C {
      public:
        int a;
      };
    accessSpecDecl()
      matches 'public:'

Matcher<Decl> | classTemplateDecl | Matcher<ClassTemplateDecl>...

    Matches C++ class template declarations.

    Example matches Z
      template<class T> class Z {};

Matcher<Decl> | classTemplateSpecializationDecl | Matcher<ClassTemplateSpecializationDecl>...

    Matches C++ class template specializations.

    Given
      template<typename T> class A {};
      template<> class A<double> {};
      A<int> a;
    classTemplateSpecializationDecl()
      matches the specializations A<int> and A<double>

Matcher<Decl> | constructorDecl | Matcher<CXXConstructorDecl>...

    Matches C++ constructor declarations.

    Example matches Foo::Foo() and Foo::Foo(int)
      class Foo {
       public:
        Foo();
        Foo(int);
        int DoSomething();
      };

Matcher<Decl> | decl | Matcher<Decl>...

    Matches declarations.

    Examples matches X, C, and the friend declaration inside C;
      void X();
      class C {
        friend X;
      };

Matcher<Decl> | declaratorDecl | Matcher<DeclaratorDecl>...

    Matches declarator declarations (field, variable, function
    and non-type template parameter declarations).

    Given
      class X { int y; };
    declaratorDecl()
      matches int y.

Matcher<Decl> | destructorDecl | Matcher<CXXDestructorDecl>...

    Matches explicit C++ destructor declarations.

    Example matches Foo::~Foo()
      class Foo {
       public:
        virtual ~Foo();
      };

Matcher<Decl> | enumConstantDecl | Matcher<EnumConstantDecl>...

    Matches enum constants.

    Example matches A, B, C
      enum X {
        A, B, C
      };

Matcher<Decl> | enumDecl | Matcher<EnumDecl>...

    Matches enum declarations.

    Example matches X
      enum X {
        A, B, C
      };

Matcher<Decl> | fieldDecl | Matcher<FieldDecl>...

    Matches field declarations.

    Given
      class X { int m; };
    fieldDecl()
      matches 'm'.

Matcher<Decl> | friendDecl | Matcher<FriendDecl>...

    Matches friend declarations.

    Given
      class X { friend void foo(); };
    friendDecl()
      matches 'friend void foo()'.

Matcher<Decl> | functionDecl | Matcher<FunctionDecl>...

    Matches function declarations.

    Example matches f
      void f();

Matcher<Decl> | functionTemplateDecl | Matcher<FunctionTemplateDecl>...

    Matches C++ function template declarations.

    Example matches f
      template<class T> void f(T t) {}

Matcher<Decl> | linkageSpecDecl | Matcher<LinkageSpecDecl>...

    Matches a declaration of a linkage specification.

    Given
      extern "C" {}
    linkageSpecDecl()
      matches "extern "C" {}"

Matcher<Decl> | methodDecl | Matcher<CXXMethodDecl>...

    Matches method declarations.

    Example matches y
      class X { void y(); };

Matcher<Decl> | namedDecl | Matcher<NamedDecl>...

    Matches a declaration of anything that could have a name.

    Example matches X, S, the anonymous union type, i, and U;
      typedef int X;
      struct S {
        union {
          int i;
        } U;
      };

Matcher<Decl> | namespaceDecl | Matcher<NamespaceDecl>...

    Matches a declaration of a namespace.

    Given
      namespace {}
      namespace test {}
    namespaceDecl()
      matches "namespace {}" and "namespace test {}"

Matcher<Decl> | parmVarDecl | Matcher<ParmVarDecl>...

    Matches parameter variable declarations.

    Given
      void f(int x);
    parmVarDecl()
      matches int x.

Matcher<Decl> | recordDecl | Matcher<CXXRecordDecl>...

    Matches C++ class declarations.

    Example matches X, Z
      class X;
      template<class T> class Z {};

Matcher<Decl> | typedefDecl | Matcher<TypedefDecl>...

    Matches typedef declarations.

    Given
      typedef int X;
    typedefDecl()
      matches "typedef int X"

Matcher<Decl> | unresolvedUsingValueDecl | Matcher<UnresolvedUsingValueDecl>...

    Matches unresolved using value declarations.

    Given
      template<typename X>
      class C : private X {
        using X::x;
      };
    unresolvedUsingValueDecl()
      matches using X::x

Matcher<Decl> | usingDecl | Matcher<UsingDecl>...

    Matches using declarations.

    Given
      namespace X { int x; }
      using X::x;
    usingDecl()
      matches using X::x

Matcher<Decl> | usingDirectiveDecl | Matcher<UsingDirectiveDecl>...

    Matches using namespace declarations.

    Given
      namespace X { int x; }
      using namespace X;
    usingDirectiveDecl()
      matches using namespace X

Matcher<Decl> | valueDecl | Matcher<ValueDecl>...

    Matches any value declaration.

    Example matches A, B, C and F
      enum X { A, B, C };
      void F();

Matcher<Decl> | varDecl | Matcher<VarDecl>...

    Matches variable declarations.

    Note: this does not match declarations of member variables, which are
    "field" declarations in Clang parlance.

    Example matches a
      int a;

Matcher<NestedNameSpecifierLoc> | nestedNameSpecifierLoc | Matcher<NestedNameSpecifierLoc>...

    Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.

Matcher<NestedNameSpecifier> | nestedNameSpecifier | Matcher<NestedNameSpecifier>...

    Matches nested name specifiers.

    Given
      namespace ns {
        struct A { static void f(); };
        void A::f() {}
        void g() { A::f(); }
      }
      ns::A a;
    nestedNameSpecifier()
      matches "ns::" and both "A::"

Matcher<QualType> | qualType | Matcher<QualType>...

    Matches QualTypes in the clang AST.

Matcher<Stmt> | CUDAKernelCallExpr | Matcher<CUDAKernelCallExpr>...

    Matches CUDA kernel call expression.

    Example matches,
      kernel<<<i,j>>>();

Matcher<Stmt> | arraySubscriptExpr | Matcher<ArraySubscriptExpr>...

    Matches array subscript expressions.

    Given
      int i = a[1];
    arraySubscriptExpr()
      matches "a[1]"

Matcher<Stmt> | asmStmt | Matcher<AsmStmt>...

    Matches asm statements.

     int i = 100;
      __asm("mov al, 2");
    asmStmt()
      matches '__asm("mov al, 2")'

Matcher<Stmt> | binaryOperator | Matcher<BinaryOperator>...

    Matches binary operator expressions.

    Example matches a || b
      !(a || b)

Matcher<Stmt> | bindTemporaryExpr | Matcher<CXXBindTemporaryExpr>...

    Matches nodes where temporaries are created.

    Example matches FunctionTakesString(GetStringByValue())
        (matcher = bindTemporaryExpr())
      FunctionTakesString(GetStringByValue());
      FunctionTakesStringByPointer(GetStringPointer());

Matcher<Stmt> | boolLiteral | Matcher<CXXBoolLiteralExpr>...

    Matches bool literals.

    Example matches true
      true

Matcher<Stmt> | breakStmt | Matcher<BreakStmt>...

    Matches break statements.

    Given
      while (true) { break; }
    breakStmt()
      matches 'break'

Matcher<Stmt> | cStyleCastExpr | Matcher<CStyleCastExpr>...

    Matches a C-style cast expression.

    Example: Matches (int*) 2.2f in
      int i = (int) 2.2f;

Matcher<Stmt> | callExpr | Matcher<CallExpr>...

    Matches call expressions.

    Example matches x.y() and y()
      X x;
      x.y();
      y();

Matcher<Stmt> | caseStmt | Matcher<CaseStmt>...

    Matches case statements inside switch statements.

    Given
      switch(a) { case 42: break; default: break; }
    caseStmt()
      matches 'case 42: break;'.

Matcher<Stmt> | castExpr | Matcher<CastExpr>...

    Matches any cast nodes of Clang's AST.

    Example: castExpr() matches each of the following:
      (int) 3;
      const_cast<Expr *>(SubExpr);
      char c = 0;
    but does not match
      int i = (0);
      int k = 0;

Matcher<Stmt> | catchStmt | Matcher<CXXCatchStmt>...

    Matches catch statements.

      try {} catch(int i) {}
    catchStmt()
      matches 'catch(int i)'

Matcher<Stmt> | characterLiteral | Matcher<CharacterLiteral>...

    Matches character literals (also matches wchar_t).

    Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral),
    though.

    Example matches 'a', L'a'
      char ch = 'a'; wchar_t chw = L'a';

Matcher<Stmt> | compoundLiteralExpr | Matcher<CompoundLiteralExpr>...

    Matches compound (i.e. non-scalar) literals

    Example match: {1}, (1, 2)
      int array[4] = {1}; vector int myvec = (vector int)(1, 2);

Matcher<Stmt> | compoundStmt | Matcher<CompoundStmt>...

    Matches compound statements.

    Example matches '{}' and '{{}}'in 'for (;;) {{}}'
      for (;;) {{}}

Matcher<Stmt> | conditionalOperator | Matcher<ConditionalOperator>...

    Matches conditional operator expressions.

    Example matches a ? b : c
      (a ? b : c) + 42

Matcher<Stmt> | constCastExpr | Matcher<CXXConstCastExpr>...

    Matches a const_cast expression.

    Example: Matches const_cast<int*>(&r) in
      int n = 42;
      const int &r(n);
      int* p = const_cast<int*>(&r);

Matcher<Stmt> | constructExpr | Matcher<CXXConstructExpr>...

    Matches constructor call expressions (including implicit ones).

    Example matches string(ptr, n) and ptr within arguments of f
        (matcher = constructExpr())
      void f(const string &a, const string &b);
      char *ptr;
      int n;
      f(string(ptr, n), ptr);

Matcher<Stmt> | continueStmt | Matcher<ContinueStmt>...

    Matches continue statements.

    Given
      while (true) { continue; }
    continueStmt()
      matches 'continue'

Matcher<Stmt> | declRefExpr | Matcher<DeclRefExpr>...

    Matches expressions that refer to declarations.

    Example matches x in if (x)
      bool x;
      if (x) {}

Matcher<Stmt> | declStmt | Matcher<DeclStmt>...

    Matches declaration statements.

    Given
      int a;
    declStmt()
      matches 'int a'.

Matcher<Stmt> | defaultArgExpr | Matcher<CXXDefaultArgExpr>...

    Matches the value of a default argument at the call site.

    Example matches the CXXDefaultArgExpr placeholder inserted for the
        default value of the second parameter in the call expression f(42)
        (matcher = defaultArgExpr())
      void f(int x, int y = 0);
      f(42);

Matcher<Stmt> | defaultStmt | Matcher<DefaultStmt>...

    Matches default statements inside switch statements.

    Given
      switch(a) { case 42: break; default: break; }
    defaultStmt()
      matches 'default: break;'.

Matcher<Stmt> | deleteExpr | Matcher<CXXDeleteExpr>...

    Matches delete expressions.

    Given
      delete X;
    deleteExpr()
      matches 'delete X'.

Matcher<Stmt> | doStmt | Matcher<DoStmt>...

    Matches do statements.

    Given
      do {} while (true);
    doStmt()
      matches 'do {} while(true)'

Matcher<Stmt> | dynamicCastExpr | Matcher<CXXDynamicCastExpr>...

    Matches a dynamic_cast expression.

    Example:
      dynamicCastExpr()
    matches
      dynamic_cast<D*>(&b);
    in
      struct B { virtual ~B() {} }; struct D : B {};
      B b;
      D* p = dynamic_cast<D*>(&b);

Matcher<Stmt> | explicitCastExpr | Matcher<ExplicitCastExpr>...

    Matches explicit cast expressions.

    Matches any cast expression written in user code, whether it be a
    C-style cast, a functional-style cast, or a keyword cast.

    Does not match implicit conversions.

    Note: the name "explicitCast" is chosen to match Clang's terminology, as
    Clang uses the term "cast" to apply to implicit conversions as well as to
    actual cast expressions.

    hasDestinationType.

    Example: matches all five of the casts in
      int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42)))))
    but does not match the implicit conversion in
      long ell = 42;

Matcher<Stmt> | expr | Matcher<Expr>...

    Matches expressions.

    Example matches x()
      void f() { x(); }

Matcher<Stmt> | exprWithCleanups | Matcher<ExprWithCleanups>...

    Matches expressions that introduce cleanups to be run at the end
    of the sub-expression's evaluation.

    Example matches std::string()
      const std::string str = std::string();

Matcher<Stmt> | floatLiteral | Matcher<FloatingLiteral>...

    Matches float literals of all sizes encodings, e.g.
    1.0, 1.0f, 1.0L and 1e10.

    Does not match implicit conversions such as
      float a = 10;

Matcher<Stmt> | forRangeStmt | Matcher<CXXForRangeStmt>...

    Matches range-based for statements.

    forRangeStmt() matches 'for (auto a : i)'
      int i[] =  {1, 2, 3}; for (auto a : i);
      for(int j = 0; j < 5; ++j);

Matcher<Stmt> | forStmt | Matcher<ForStmt>...

    Matches for statements.

    Example matches 'for (;;) {}'
      for (;;) {}
      int i[] =  {1, 2, 3}; for (auto a : i);

Matcher<Stmt> | functionalCastExpr | Matcher<CXXFunctionalCastExpr>...

    Matches functional cast expressions

    Example: Matches Foo(bar);
      Foo f = bar;
      Foo g = (Foo) bar;
      Foo h = Foo(bar);

Matcher<Stmt> | gotoStmt | Matcher<GotoStmt>...

    Matches goto statements.

    Given
      goto FOO;
      FOO: bar();
    gotoStmt()
      matches 'goto FOO'

Matcher<Stmt> | ifStmt | Matcher<IfStmt>...

    Matches if statements.

    Example matches 'if (x) {}'
      if (x) {}

Matcher<Stmt> | implicitCastExpr | Matcher<ImplicitCastExpr>...

    Matches the implicit cast nodes of Clang's AST.

    This matches many different places, including function call return value
    eliding, as well as any type conversions.

Matcher<Stmt> | initListExpr | Matcher<InitListExpr>...

    Matches init list expressions.

    Given
      int a[] = { 1, 2 };
      struct B { int x, y; };
      B b = { 5, 6 };
    initListExpr()
      matches "{ 1, 2 }" and "{ 5, 6 }"

Matcher<Stmt> | integerLiteral | Matcher<IntegerLiteral>...

    Matches integer literals of all sizes encodings, e.g.
    1, 1L, 0x1 and 1U.

    Does not match character-encoded integers such as L'a'.

Matcher<Stmt> | labelStmt | Matcher<LabelStmt>...

    Matches label statements.

    Given
      goto FOO;
      FOO: bar();
    labelStmt()
      matches 'FOO:'

Matcher<Stmt> | lambdaExpr | Matcher<LambdaExpr>...

    Matches lambda expressions.

    Example matches [&](){return 5;}
      [&](){return 5;}

Matcher<Stmt> | materializeTemporaryExpr | Matcher<MaterializeTemporaryExpr>...

    Matches nodes where temporaries are materialized.

    Example: Given
      struct T {void func()};
      T f();
      void g(T);
    materializeTemporaryExpr() matches 'f()' in these statements
      T u(f());
      g(f());
    but does not match
      f();
      f().func();

Matcher<Stmt> | memberCallExpr | Matcher<CXXMemberCallExpr>...

    Matches member call expressions.

    Example matches x.y()
      X x;
      x.y();

Matcher<Stmt> | memberExpr | Matcher<MemberExpr>...

    Matches member expressions.

    Given
      class Y {
        void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
        int a; static int b;
      };
    memberExpr()
      matches this->x, x, y.x, a, this->b

Matcher<Stmt> | newExpr | Matcher<CXXNewExpr>...

    Matches new expressions.

    Given
      new X;
    newExpr()
      matches 'new X'.

Matcher<Stmt> | nullPtrLiteralExpr | Matcher<CXXNullPtrLiteralExpr>...

    Matches nullptr literal.

Matcher<Stmt> | nullStmt | Matcher<NullStmt>...

    Matches null statements.

      foo();;
    nullStmt()
      matches the second ';'

Matcher<Stmt> | operatorCallExpr | Matcher<CXXOperatorCallExpr>...

    Matches overloaded operator calls.

    Note that if an operator isn't overloaded, it won't match. Instead, use
    binaryOperator matcher.
    Currently it does not match operators such as new delete.
    FIXME: figure out why these do not match?

    Example matches both operator<<((o << b), c) and operator<<(o, b)
        (matcher = operatorCallExpr())
      ostream &operator<< (ostream &out, int i) { };
      ostream &o; int b = 1, c = 1;
      o << b << c;

Matcher<Stmt> | reinterpretCastExpr | Matcher<CXXReinterpretCastExpr>...

    Matches a reinterpret_cast expression.

    Either the source expression or the destination type can be matched
    using has(), but hasDestinationType() is more specific and can be
    more readable.

    Example matches reinterpret_cast<char*>(&p) in
      void* p = reinterpret_cast<char*>(&p);

Matcher<Stmt> | returnStmt | Matcher<ReturnStmt>...

    Matches return statements.

    Given
      return 1;
    returnStmt()
      matches 'return 1'

Matcher<Stmt> | staticCastExpr | Matcher<CXXStaticCastExpr>...

    Matches a C++ static_cast expression.

    hasDestinationType
    reinterpretCast

    Example:
      staticCastExpr()
    matches
      static_cast<long>(8)
    in
      long eight(static_cast<long>(8));

Matcher<Stmt> | stmt | Matcher<Stmt>...

    Matches statements.

    Given
      { ++a; }
    stmt()
      matches both the compound statement '{ ++a; }' and '++a'.

Matcher<Stmt> | stringLiteral | Matcher<StringLiteral>...

    Matches string literals (also matches wide string literals).

    Example matches "abcd", L"abcd"
      char *s = "abcd"; wchar_t *ws = L"abcd"

Matcher<Stmt> | substNonTypeTemplateParmExpr | Matcher<SubstNonTypeTemplateParmExpr>...

    Matches substitutions of non-type template parameters.

    Given
      template <int N>
      struct A { static const int n = N; };
      struct B : public A<42> {};
    substNonTypeTemplateParmExpr()
      matches "N" in the right-hand side of "static const int n = N;"

Matcher<Stmt> | switchCase | Matcher<SwitchCase>...

    Matches case and default statements inside switch statements.

    Given
      switch(a) { case 42: break; default: break; }
    switchCase()
      matches 'case 42: break;' and 'default: break;'.

Matcher<Stmt> | switchStmt | Matcher<SwitchStmt>...

    Matches switch statements.

    Given
      switch(a) { case 42: break; default: break; }
    switchStmt()
      matches 'switch(a)'.

Matcher<Stmt> | temporaryObjectExpr | Matcher<CXXTemporaryObjectExpr>...

    Matches functional cast expressions having N != 1 arguments

    Example: Matches Foo(bar, bar)
      Foo h = Foo(bar, bar);

Matcher<Stmt> | thisExpr | Matcher<CXXThisExpr>...

    Matches implicit and explicit this expressions.

    Example matches the implicit this expression in "return i".
        (matcher = thisExpr())
    struct foo {
      int i;
      int f() { return i; }
    };

Matcher<Stmt> | throwExpr | Matcher<CXXThrowExpr>...

    Matches throw expressions.

      try { throw 5; } catch(int i) {}
    throwExpr()
      matches 'throw 5'

Matcher<Stmt> | tryStmt | Matcher<CXXTryStmt>...

    Matches try statements.

      try {} catch(int i) {}
    tryStmt()
      matches 'try {}'

Matcher<Stmt> | unaryExprOrTypeTraitExpr | Matcher<UnaryExprOrTypeTraitExpr>...

    Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)

    Given
      Foo x = bar;
      int y = sizeof(x) + alignof(x);
    unaryExprOrTypeTraitExpr()
      matches sizeof(x) and alignof(x)

Matcher<Stmt> | unaryOperator | Matcher<UnaryOperator>...

    Matches unary operator expressions.

    Example matches !a
      !a || b

Matcher<Stmt> | unresolvedConstructExpr | Matcher<CXXUnresolvedConstructExpr>...

    Matches unresolved constructor call expressions.

    Example matches T(t) in return statement of f
        (matcher = unresolvedConstructExpr())
      template <typename T>
      void f(const T& t) { return T(t); }

Matcher<Stmt> | userDefinedLiteral | Matcher<UserDefinedLiteral>...

    Matches user defined literal operator call.

    Example match: "foo"_suffix

Matcher<Stmt> | whileStmt | Matcher<WhileStmt>...

    Matches while statements.

    Given
      while (true) {}
    whileStmt()
      matches 'while (true) {}'.

Matcher<TemplateArgument> | templateArgument | Matcher<TemplateArgument>...

    Matches template arguments.

    Given
      template <typename T> struct C {};
      C<int> c;
    templateArgument()
      matches 'int' in C<int>.

Matcher<TypeLoc> | typeLoc | Matcher<TypeLoc>...

    Matches TypeLocs in the clang AST.

Matcher<Type> | arrayType | Matcher<ArrayType>...

    Matches all kinds of arrays.

    Given
      int a[] = { 2, 3 };
      int b[4];
      void f() { int c[a[0]]; }
    arrayType()
      matches "int a[]", "int b[4]" and "int c[a[0]]";

Matcher<Type> | atomicType | Matcher<AtomicType>...

    Matches atomic types.

    Given
      _Atomic(int) i;
    atomicType()
      matches "_Atomic(int) i"

Matcher<Type> | autoType | Matcher<AutoType>...

    Matches types nodes representing C++11 auto types.

    Given:
      auto n = 4;
      int v[] = { 2, 3 }
      for (auto i : v) { }
    autoType()
      matches "auto n" and "auto i"

Matcher<Type> | blockPointerType | Matcher<BlockPointerType>...

    Matches block pointer types, i.e. types syntactically represented as
    "void (^)(int)".

    The pointee is always required to be a FunctionType.

Matcher<Type> | builtinType | Matcher<BuiltinType>...

    Matches builtin Types.

    Given
      struct A {};
      A a;
      int b;
      float c;
      bool d;
    builtinType()
      matches "int b", "float c" and "bool d"

Matcher<Type> | complexType | Matcher<ComplexType>...

    Matches C99 complex types.

    Given
      _Complex float f;
    complexType()
      matches "_Complex float f"

Matcher<Type> | constantArrayType | Matcher<ConstantArrayType>...

    Matches C arrays with a specified constant size.

    Given
      void() {
        int a[2];
        int b[] = { 2, 3 };
        int c[b[0]];
      }
    constantArrayType()
      matches "int a[2]"

Matcher<Type> | dependentSizedArrayType | Matcher<DependentSizedArrayType>...

    Matches C++ arrays whose size is a value-dependent expression.

    Given
      template<typename T, int Size>
      class array {
        T data[Size];
      };
    dependentSizedArrayType
      matches "T data[Size]"

Matcher<Type> | elaboratedType | Matcher<ElaboratedType>...

    Matches types specified with an elaborated type keyword or with a
    qualified name.

    Given
      namespace N {
        namespace M {
          class D {};
        }
      }
      class C {};

      class C c;
      N::M::D d;

    elaboratedType() matches the type of the variable declarations of both
    c and d.

Matcher<Type> | functionType | Matcher<FunctionType>...

    Matches FunctionType nodes.

    Given
      int (*f)(int);
      void g();
    functionType()
      matches "int (*f)(int)" and the type of "g".

Matcher<Type> | incompleteArrayType | Matcher<IncompleteArrayType>...

    Matches C arrays with unspecified size.

    Given
      int a[] = { 2, 3 };
      int b[42];
      void f(int c[]) { int d[a[0]]; };
    incompleteArrayType()
      matches "int a[]" and "int c[]"

Matcher<Type> | lValueReferenceType | Matcher<LValueReferenceType>...

    Matches lvalue reference types.

    Given:
      int *a;
      int &b = *a;
      int &&c = 1;
      auto &d = b;
      auto &&e = c;
      auto &&f = 2;
      int g = 5;

    lValueReferenceType() matches the types of b, d, and e. e is
    matched since the type is deduced as int& by reference collapsing rules.

Matcher<Type> | memberPointerType | Matcher<MemberPointerType>...

    Matches member pointer types.
    Given
      struct A { int i; }
      A::* ptr = A::i;
    memberPointerType()
      matches "A::* ptr"

Matcher<Type> | parenType | Matcher<ParenType>...

    Matches ParenType nodes.

    Given
      int (*ptr_to_array)[4];
      int *array_of_ptrs[4];

    varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not
    array_of_ptrs.

Matcher<Type> | pointerType | Matcher<PointerType>...

    Matches pointer types.

    Given
      int *a;
      int &b = *a;
      int c = 5;
    pointerType()
      matches "int *a"

Matcher<Type> | rValueReferenceType | Matcher<RValueReferenceType>...

    Matches rvalue reference types.

    Given:
      int *a;
      int &b = *a;
      int &&c = 1;
      auto &d = b;
      auto &&e = c;
      auto &&f = 2;
      int g = 5;

    rValueReferenceType() matches the types of c and f. e is not
    matched as it is deduced to int& by reference collapsing rules.

Matcher<Type> | recordType | Matcher<RecordType>...

    Matches record types (e.g. structs, classes).

    Given
      class C {};
      struct S {};

      C c;
      S s;

    recordType() matches the type of the variable declarations of both c
    and s.

Matcher<Type> | referenceType | Matcher<ReferenceType>...

    Matches both lvalue and rvalue reference types.

    Given
      int *a;
      int &b = *a;
      int &&c = 1;
      auto &d = b;
      auto &&e = c;
      auto &&f = 2;
      int g = 5;

    referenceType() matches the types of b, c, d, e, and f.

Matcher<Type> | templateSpecializationType | Matcher<TemplateSpecializationType>...

    Matches template specialization types.

    Given
      template <typename T>
      class C { };

      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.

Matcher<Type> | type | Matcher<Type>...

    Matches Types in the clang AST.

Matcher<Type> | typedefType | Matcher<TypedefType>...

    Matches typedef types.

    Given
      typedef int X;
    typedefType()
      matches "typedef int X"

Matcher<Type> | unaryTransformType | Matcher<UnaryTransformType>...

    Matches types nodes representing unary type transformations.

    Given:
      typedef __underlying_type(T) type;
    unaryTransformType()
      matches "__underlying_type(T)"

Matcher<Type> | variableArrayType | Matcher<VariableArrayType>...

    Matches C arrays with a specified size that is not an
    integer-constant-expression.

    Given
      void f() {
        int a[] = { 2, 3 }
        int b[42];
        int c[a[0]];
      }
    variableArrayType()
      matches "int c[a[0]]"

## Narrowing Matchers

Narrowing matchers match certain attributes on the current node, thus narrowing down the set of nodes of the current type to match on.

There are special logical narrowing matchers (allOf, anyOf, anything and unless) which allow users to create more powerful match expressions.

Return type | Name | Parameters
--- | --- | ---
Matcher<*> | allOf | Matcher<*>, ..., Matcher<*>

    Matches if all given matchers match.

    Usable as: Any Matcher

Matcher<*> | anyOf | Matcher<*>, ..., Matcher<*>

    Matches if any of the given matchers matches.

    Usable as: Any Matcher

Matcher<*> | anything |

    Matches any node.

    Useful when another matcher requires a child matcher, but there's no
    additional constraint. This will often be used with an explicit conversion
    to an internal::Matcher<> type such as TypeMatcher.

    Example: DeclarationMatcher(anything()) matches all declarations, e.g.,
    "int* p" and "void f()" in
      int* p;
      void f();

    Usable as: Any Matcher

Matcher<*> | unless | Matcher<*>

    Matches if the provided matcher does not match.

    Example matches Y (matcher = recordDecl(unless(hasName("X"))))
      class X {};
      class Y {};

    Usable as: Any Matcher

Matcher<BinaryOperator> | hasOperatorName | std::string Name

    Matches the operator Name of operator expressions (binary or
    unary).

    Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
      !(a || b)

Matcher<CXXBoolLiteral> | equals | ValueT Value

    Matches literals that are equal to the given value.

    Example matches true (matcher = boolLiteral(equals(true)))
      true

    Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteral>,
               Matcher<FloatingLiteral>, Matcher<IntegerLiteral>

Matcher<CXXConstructExpr> | argumentCountIs | unsigned N

    Checks that a call expression or a constructor call expression has
    a specific number of arguments (including absent default arguments).

    Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
      void f(int x, int y);
      f(0, 0);

Matcher<CXXConstructExpr> | isListInitialization |

    Matches a constructor call expression which uses list initialization.

Matcher<CXXCtorInitializer> | isWritten |

    Matches a constructor initializer if it is explicitly written in
    code (as opposed to implicitly added by the compiler).

    Given
      struct Foo {
        Foo() { }
        Foo(int) : foo_("A") { }
        string foo_;
      };
    constructorDecl(hasAnyConstructorInitializer(isWritten()))
      will match Foo(int), but not Foo()

Matcher<CXXMethodDecl> | isConst |

    Matches if the given method declaration is const.

    Given
    struct A {
      void foo() const;
      void bar();
    };

    methodDecl(isConst()) matches A::foo() but not A::bar()

Matcher<CXXMethodDecl> | isOverride |

    Matches if the given method declaration overrides another method.

    Given
      class A {
       public:
        virtual void x();
      };
      class B : public A {
       public:
        virtual void x();
      };
      matches B::x

Matcher<CXXMethodDecl> | isPure |

    Matches if the given method declaration is pure.

    Given
      class A {
       public:
        virtual void x() = 0;
      };
      matches A::x

Matcher<CXXMethodDecl> | isVirtual |

    Matches if the given method declaration is virtual.

    Given
      class A {
       public:
        virtual void x();
      };
      matches A::x

Matcher<CXXOperatorCallExpr> | hasOverloadedOperatorName | StringRef Name

    Matches overloaded operator names.

    Matches overloaded operator names specified in strings without the
    "operator" prefix: e.g. "<<".

    Given:
      class A { int operator*(); };
      const A &operator<<(const A &a, const A &b);
      A a;
      a << a;   <-- This matches

    operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified
    line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches
    the declaration of A.

    Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl>

Matcher<CXXRecordDecl> | isDerivedFrom | StringRef BaseName

    Overloaded method as shortcut for isDerivedFrom(hasName(...)).

Matcher<CXXRecordDecl> | isExplicitTemplateSpecialization |

    Matches explicit template specializations of function, class, or
    static member variable template instantiations.

    Given
      template<typename T> void A(T t) { }
      template<> void A(int N) { }
    functionDecl(isExplicitTemplateSpecialization())
      matches the specialization A<int>().

    Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>

Matcher<CXXRecordDecl> | isSameOrDerivedFrom | StringRef BaseName

    Overloaded method as shortcut for
    isSameOrDerivedFrom(hasName(...)).

Matcher<CXXRecordDecl> | isTemplateInstantiation |

    Matches template instantiations of function, class, or static
    member variable template instantiations.

    Given
      template <typename T> class X {}; class A {}; X<A> x;
    or
      template <typename T> class X {}; class A {}; template class X<A>;
    recordDecl(hasName("::X"), isTemplateInstantiation())
      matches the template instantiation of X<A>.

    But given
      template <typename T>  class X {}; class A {};
      template <> class X<A> {}; X<A> x;
    recordDecl(hasName("::X"), isTemplateInstantiation())
      does not match, as X<A> is an explicit template specialization.

    Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>

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).

    Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
      void f(int x, int y);
      f(0, 0);

Matcher<CharacterLiteral> | equals | ValueT Value

    Matches literals that are equal to the given value.

    Example matches true (matcher = boolLiteral(equals(true)))
      true

    Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteral>,
               Matcher<FloatingLiteral>, Matcher<IntegerLiteral>

Matcher<ClassTemplateSpecializationDecl> | templateArgumentCountIs | unsigned N

    Matches if the number of template arguments equals N.

    Given
      template<typename T> struct C {};
      C<int> c;
    classTemplateSpecializationDecl(templateArgumentCountIs(1))
      matches C<int>.

Matcher<CompoundStmt> | statementCountIs | unsigned N

    Checks that a compound statement contains a specific number of
    child statements.

    Example: Given
      { for (;;) {} }
    compoundStmt(statementCountIs(0)))
      matches '{}'
      but does not match the outer compound statement.

Matcher<ConstantArrayType> | hasSize | unsigned N

    Matches ConstantArrayType nodes that have the specified size.

    Given
      int a[42];
      int b[2 * 21];
      int c[41], d[43];
    constantArrayType(hasSize(42))
      matches "int a[42]" and "int b[2 * 21]"

Matcher<DeclStmt> | declCountIs | unsigned N

    Matches declaration statements that contain a specific number of
    declarations.

    Example: Given
      int a, b;
      int c;
      int d = 2, e;
    declCountIs(2)
      matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'.

Matcher<Decl> | equalsBoundNode | std::string ID

    Matches if a node equals a previously bound node.

    Matches a node if it equals the node previously bound to ID.

    Given
      class X { int a; int b; };
    recordDecl(
        has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
        has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
      matches the class X, as a and b have the same type.

    Note that when multiple matches are involved via forEach* matchers,
    equalsBoundNodes acts as a filter.
    For example:
    compoundStmt(
        forEachDescendant(varDecl().bind("d")),
        forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
    will trigger a match for each combination of variable declaration
    and reference to that variable declaration within a compound statement.

Matcher<Decl> | hasAttr | attr::Kind AttrKind

    Matches declaration that has a given attribute.

    Given
      __attribute__((device)) void f() { ... }
    decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
    f.

Matcher<Decl> | isExpansionInFileMatching | std::string RegExp

    Matches AST nodes that were expanded within files whose name is
    partially matching a given regex.

    Example matches Y but not X
        (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
      #include "ASTMatcher.h"
      class X {};
    ASTMatcher.h:
      class Y {};

    Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>

Matcher<Decl> | isExpansionInMainFile |

    Matches AST nodes that were expanded within the main-file.

    Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile())
      #include <Y.h>
      class X {};
    Y.h:
      class Y {};

    Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>

Matcher<Decl> | isExpansionInSystemHeader |

    Matches AST nodes that were expanded within system-header-files.

    Example matches Y but not X
        (matcher = recordDecl(isExpansionInSystemHeader())
      #include <SystemHeader.h>
      class X {};
    SystemHeader.h:
      class Y {};

    Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>

Matcher<Decl> | isImplicit |

    Matches a declaration that has been implicitly added
    by the compiler (eg. implicit defaultcopy constructors).

Matcher<Decl> | isInstantiated |

    Matches declarations that are template instantiations or are inside
    template instantiations.

    Given
      template<typename T> void A(T t) { T i; }
      A(0);
      A(0U);
    functionDecl(isInstantiated())
      matches 'A(int) {...};' and 'A(unsigned) {...}'.

Matcher<Decl> | isPrivate |

    Matches private C++ declarations.

    Given
      class C {
      public:    int a;
      protected: int b;
      private:   int c;
      };
    fieldDecl(isPrivate())
      matches 'int c;'

Matcher<Decl> | isProtected |

    Matches protected C++ declarations.

    Given
      class C {
      public:    int a;
      protected: int b;
      private:   int c;
      };
    fieldDecl(isProtected())
      matches 'int b;'

Matcher<Decl> | isPublic |

    Matches public C++ declarations.

    Given
      class C {
      public:    int a;
      protected: int b;
      private:   int c;
      };
    fieldDecl(isPublic())
      matches 'int a;'

Matcher<FloatingLiteral> | equals | ValueT Value

    Matches literals that are equal to the given value.

    Example matches true (matcher = boolLiteral(equals(true)))
      true

    Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteral>,
               Matcher<FloatingLiteral>, Matcher<IntegerLiteral>

Matcher<FunctionDecl> | hasOverloadedOperatorName | StringRef Name

    Matches overloaded operator names.

    Matches overloaded operator names specified in strings without the
    "operator" prefix: e.g. "<<".

    Given:
      class A { int operator*(); };
      const A &operator<<(const A &a, const A &b);
      A a;
      a << a;   <-- This matches

    operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified
    line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches
    the declaration of A.

    Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl>

Matcher<FunctionDecl> | isDefinition |

    Matches if a declaration has a body attached.

    Example matches A, va, fa
      class A {};
      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.
      void fa() {}
      void fb();  Doesn't match, as it has no body.

    Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>

Matcher<FunctionDecl> | isDeleted |

    Matches deleted function declarations.

    Given:
      void Func();
      void DeletedFunc() = delete;
    functionDecl(isDeleted())
      matches the declaration of DeletedFunc, but not Func.

Matcher<FunctionDecl> | isExplicitTemplateSpecialization |

    Matches explicit template specializations of function, class, or
    static member variable template instantiations.

    Given
      template<typename T> void A(T t) { }
      template<> void A(int N) { }
    functionDecl(isExplicitTemplateSpecialization())
      matches the specialization A<int>().

    Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>

Matcher<FunctionDecl> | isExternC |

    Matches extern "C" function declarations.

    Given:
      extern "C" void f() {}
      extern "C" { void g() {} }
      void h() {}
    functionDecl(isExternC())
      matches the declaration of f and g, but not the declaration h

Matcher<FunctionDecl> | isTemplateInstantiation |

    Matches template instantiations of function, class, or static
    member variable template instantiations.

    Given
      template <typename T> class X {}; class A {}; X<A> x;
    or
      template <typename T> class X {}; class A {}; template class X<A>;
    recordDecl(hasName("::X"), isTemplateInstantiation())
      matches the template instantiation of X<A>.

    But given
      template <typename T>  class X {}; class A {};
      template <> class X<A> {}; X<A> x;
    recordDecl(hasName("::X"), isTemplateInstantiation())
      does not match, as X<A> is an explicit template specialization.

    Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>

Matcher<FunctionDecl> | parameterCountIs | unsigned N

    Matches FunctionDecls that have a specific parameter count.

    Given
      void f(int i) {}
      void g(int i, int j) {}
    functionDecl(parameterCountIs(2))
      matches g(int i, int j) {}

Matcher<IntegerLiteral> | equals | ValueT Value

    Matches literals that are equal to the given value.

    Example matches true (matcher = boolLiteral(equals(true)))
      true

    Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteral>,
               Matcher<FloatingLiteral>, Matcher<IntegerLiteral>

Matcher<MemberExpr> | isArrow |

    Matches member expressions that are called with '->' as opposed
    to '.'.

    Member calls on the implicit this pointer match as called with '->'.

    Given
      class Y {
        void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
        int a;
        static int b;
      };
    memberExpr(isArrow())
      matches this->x, x, y.x, a, this->b

Matcher<NamedDecl> | hasName | std::string Name

    Matches NamedDecl nodes that have the specified name.

    Supports specifying enclosing namespaces or classes by prefixing the name
    with '<enclosing>::'.
    Does not match typedefs of an underlying type with the given name.

    Example matches X (Name == "X")
      class X;

    Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")
      namespace a { namespace b { class X; } }

Matcher<NamedDecl> | matchesName | std::string RegExp

    Matches NamedDecl nodes whose fully qualified names contain
    a substring matched by the given RegExp.

    Supports specifying enclosing namespaces or classes by
    prefixing the name with '<enclosing>::'.  Does not match typedefs
    of an underlying type with the given name.

    Example matches X (regexp == "::X")
      class X;

    Example matches X (regexp is one of "::X", "^foo::.*X", among others)
      namespace foo { namespace bar { class X; } }

Matcher<QualType> | asString | std::string Name

    Matches if the matched type is represented by the given string.

    Given
      class Y { public: void x(); };
      void z() { Y* y; y->x(); }
    callExpr(on(hasType(asString("class Y *"))))
      matches y->x()

Matcher<QualType> | equalsBoundNode | std::string ID

    Matches if a node equals a previously bound node.

    Matches a node if it equals the node previously bound to ID.

    Given
      class X { int a; int b; };
    recordDecl(
        has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
        has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
      matches the class X, as a and b have the same type.

    Note that when multiple matches are involved via forEach* matchers,
    equalsBoundNodes acts as a filter.
    For example:
    compoundStmt(
        forEachDescendant(varDecl().bind("d")),
        forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
    will trigger a match for each combination of variable declaration
    and reference to that variable declaration within a compound statement.

Matcher<QualType> | hasLocalQualifiers |

    Matches QualType nodes that have local CV-qualifiers attached to
    the node, not hidden within a typedef.

    Given
      typedef const int const_int;
      const_int i;
      int *const j;
      int *volatile k;
      int m;
    varDecl(hasType(hasLocalQualifiers())) matches only j and k.
    i is const-qualified but the qualifier is not local.

Matcher<QualType> | isConstQualified |

    Matches QualType nodes that are const-qualified, i.e., that
    include "top-level" const.

    Given
      void a(int);
      void b(int const);
      void c(const int);
      void d(const int*);
      void e(int const) {};
    functionDecl(hasAnyParameter(hasType(isConstQualified())))
      matches "void b(int const)", "void c(const int)" and
      "void e(int const) {}". It does not match d as there
      is no top-level const on the parameter type "const int *".

Matcher<QualType> | isInteger |

    Matches QualType nodes that are of integer type.

    Given
      void a(int);
      void b(long);
      void c(double);
    functionDecl(hasAnyParameter(hasType(isInteger())))
    matches "a(int)", "b(long)", but not "c(double)".

Matcher<Stmt> | equalsBoundNode | std::string ID

    Matches if a node equals a previously bound node.

    Matches a node if it equals the node previously bound to ID.

    Given
      class X { int a; int b; };
    recordDecl(
        has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
        has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
      matches the class X, as a and b have the same type.

    Note that when multiple matches are involved via forEach* matchers,
    equalsBoundNodes acts as a filter.
    For example:
    compoundStmt(
        forEachDescendant(varDecl().bind("d")),
        forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
    will trigger a match for each combination of variable declaration
    and reference to that variable declaration within a compound statement.

Matcher<Stmt> | isExpansionInFileMatching | std::string RegExp

    Matches AST nodes that were expanded within files whose name is
    partially matching a given regex.

    Example matches Y but not X
        (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
      #include "ASTMatcher.h"
      class X {};
    ASTMatcher.h:
      class Y {};

    Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>

Matcher<Stmt> | isExpansionInMainFile |

    Matches AST nodes that were expanded within the main-file.

    Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile())
      #include <Y.h>
      class X {};
    Y.h:
      class Y {};

    Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>

Matcher<Stmt> | isExpansionInSystemHeader |

    Matches AST nodes that were expanded within system-header-files.

    Example matches Y but not X
        (matcher = recordDecl(isExpansionInSystemHeader())
      #include <SystemHeader.h>
      class X {};
    SystemHeader.h:
      class Y {};

    Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>

Matcher<Stmt> | isInTemplateInstantiation |

    Matches statements inside of a template instantiation.

    Given
      int j;
      template<typename T> void A(T t) { T i; j += 42;}
      A(0);
      A(0U);
    declStmt(isInTemplateInstantiation())
      matches 'int i;' and 'unsigned i'.
    unless(stmt(isInTemplateInstantiation()))
      will NOT match j += 42; as it's shared between the template definition and
      instantiation.

Matcher<TagDecl> | isDefinition |

    Matches if a declaration has a body attached.

    Example matches A, va, fa
      class A {};
      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.
      void fa() {}
      void fb();  Doesn't match, as it has no body.

    Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>

Matcher<TemplateArgument> | equalsIntegralValue | std::string Value

    Matches a TemplateArgument of integral type with a given value.

    Note that 'Value' is a string as the template argument's value is
    an arbitrary precision integer. 'Value' must be euqal to the canonical
    representation of that integral value in base 10.

    Given
      template<int T> struct A {};
      C<42> c;
    classTemplateSpecializationDecl(
      hasAnyTemplateArgument(equalsIntegralValue("42")))
      matches the implicit instantiation of C in C<42>.

Matcher<TemplateArgument> | isIntegral |

    Matches a TemplateArgument that is an integral value.

    Given
      template<int T> struct A {};
      C<42> c;
    classTemplateSpecializationDecl(
      hasAnyTemplateArgument(isIntegral()))
      matches the implicit instantiation of C in C<42>
      with isIntegral() matching 42.

Matcher<TemplateSpecializationType> | templateArgumentCountIs | unsigned N

    Matches if the number of template arguments equals N.

    Given
      template<typename T> struct C {};
      C<int> c;
    classTemplateSpecializationDecl(templateArgumentCountIs(1))
      matches C<int>.

Matcher<TypeLoc> | isExpansionInFileMatching | std::string RegExp

    Matches AST nodes that were expanded within files whose name is
    partially matching a given regex.

    Example matches Y but not X
        (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
      #include "ASTMatcher.h"
      class X {};
    ASTMatcher.h:
      class Y {};

    Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>

Matcher<TypeLoc> | isExpansionInMainFile |

    Matches AST nodes that were expanded within the main-file.

    Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile())
      #include <Y.h>
      class X {};
    Y.h:
      class Y {};

    Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>

Matcher<TypeLoc> | isExpansionInSystemHeader |

    Matches AST nodes that were expanded within system-header-files.

    Example matches Y but not X
        (matcher = recordDecl(isExpansionInSystemHeader())
      #include <SystemHeader.h>
      class X {};
    SystemHeader.h:
      class Y {};

    Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>

Matcher<Type> | equalsBoundNode | std::string ID

    Matches if a node equals a previously bound node.

    Matches a node if it equals the node previously bound to ID.

    Given
      class X { int a; int b; };
    recordDecl(
        has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
        has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
      matches the class X, as a and b have the same type.

    Note that when multiple matches are involved via forEach* matchers,
    equalsBoundNodes acts as a filter.
    For example:
    compoundStmt(
        forEachDescendant(varDecl().bind("d")),
        forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
    will trigger a match for each combination of variable declaration
    and reference to that variable declaration within a compound statement.

Matcher<UnaryExprOrTypeTraitExpr> | ofKind | UnaryExprOrTypeTrait Kind

    Matches unary expressions of a certain kind.

    Given
      int x;
      int s = sizeof(x) + alignof(x)
    unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
      matches sizeof(x)

Matcher<UnaryOperator> | hasOperatorName | std::string Name

    Matches the operator Name of operator expressions (binary or
    unary).

    Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
      !(a || b)

Matcher<VarDecl> | hasGlobalStorage |

    Matches a variable declaration that does not have local storage.

    Example matches y and z (matcher = varDecl(hasGlobalStorage())
    void f() {
      int x;
      static int y;
    }
    int z;

Matcher<VarDecl> | hasLocalStorage |

    Matches a variable declaration that has function scope and is a
    non-static local variable.

    Example matches x (matcher = varDecl(hasLocalStorage())
    void f() {
      int x;
      static int y;
    }
    int z;

Matcher<VarDecl> | isDefinition |

    Matches if a declaration has a body attached.

    Example matches A, va, fa
      class A {};
      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.
      void fa() {}
      void fb();  Doesn't match, as it has no body.

    Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>

Matcher<VarDecl> | isExplicitTemplateSpecialization |

    Matches explicit template specializations of function, class, or
    static member variable template instantiations.

    Given
      template<typename T> void A(T t) { }
      template<> void A(int N) { }
    functionDecl(isExplicitTemplateSpecialization())
      matches the specialization A<int>().

    Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>

Matcher<VarDecl> | isTemplateInstantiation |

    Matches template instantiations of function, class, or static
    member variable template instantiations.

    Given
      template <typename T> class X {}; class A {}; X<A> x;
    or
      template <typename T> class X {}; class A {}; template class X<A>;
    recordDecl(hasName("::X"), isTemplateInstantiation())
      matches the template instantiation of X<A>.

    But given
      template <typename T>  class X {}; class A {};
      template <> class X<A> {}; X<A> x;
    recordDecl(hasName("::X"), isTemplateInstantiation())
      does not match, as X<A> is an explicit template specialization.

    Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>

## AST Traversal Matchers

Traversal matchers specify the relationship to other nodes that are reachable from the current node.

Note that there are special traversal matchers (has, hasDescendant, forEach and forEachDescendant) which work on all nodes and allow users to write more generic match expressions.

Return type | Name | Parameters
--- | --- | ---
Matcher<*> | eachOf | Matcher<*>, ..., Matcher<*>

    Matches if any of the given matchers matches.

    Unlike anyOf, eachOf will generate a match result for each
    matching submatcher.

    For example, in:
      class A { int a; int b; };
    The matcher:
      recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
                        has(fieldDecl(hasName("b")).bind("v"))))
    will generate two results binding "v", the first of which binds
    the field declaration of a, the second the field declaration of
    b.

    Usable as: Any Matcher

Matcher<*> | forEachDescendant | Matcher<*>

    Matches AST nodes that have descendant AST nodes that match the
    provided matcher.

    Example matches X, A, B, C
        (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X")))))
      class X {};  Matches X, because X::X is a class of name X inside X.
      class A { class X {}; };
      class B { class C { class X {}; }; };

    DescendantT must be an AST base type.

    As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
    each result that matches instead of only on the first one.

    Note: Recursively combined ForEachDescendant can cause many matches:
      recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl()))))
    will match 10 times (plus injected class name matches) on:
      class A { class B { class C { class D { class E {}; }; }; }; };

    Usable as: Any Matcher

Matcher<*> | forEach | Matcher<*>

    Matches AST nodes that have child AST nodes that match the
    provided matcher.

    Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("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.

    ChildT must be an AST base type.

    As opposed to 'has', 'forEach' will cause a match for each result that
    matches instead of only on the first one.

    Usable as: Any Matcher

Matcher<*> | hasAncestor | Matcher<*>

    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(hasAncestor(ifStmt()))) matches 42, but not 43.

    Usable as: Any Matcher

Matcher<*> | hasDescendant | Matcher<*>

    Matches AST nodes that have descendant AST nodes that match the
    provided matcher.

    Example matches X, Y, Z
        (matcher = recordDecl(hasDescendant(recordDecl(hasName("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 {}; }; };

    DescendantT must be an AST base type.

    Usable as: Any Matcher

Matcher<*> | has | Matcher<*>

    Matches AST nodes that have child AST nodes that match the
    provided matcher.

    Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("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.

    ChildT must be an AST base type.

    Usable as: Any Matcher

Matcher<*> | hasParent | Matcher<*>

    Matches AST nodes that have a parent that matches the provided
    matcher.

    Given
    void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
    compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }".

    Usable as: Any Matcher

Matcher<ArraySubscriptExpr> | hasBase | Matcher<Expr> InnerMatcher

    Matches the base expression of an array subscript expression.

    Given
      int i[5];
      void f() { i[1] = 42; }
    arraySubscriptExpression(hasBase(implicitCastExpr(
        hasSourceExpression(declRefExpr()))))
      matches i[1] with the declRefExpr() matching i

Matcher<ArraySubscriptExpr> | hasIndex | Matcher<Expr> InnerMatcher

    Matches the index expression of an array subscript expression.

    Given
      int i[5];
      void f() { i[1] = 42; }
    arraySubscriptExpression(hasIndex(integerLiteral()))
      matches i[1] with the integerLiteral() matching 1

Matcher<ArrayTypeLoc> | hasElementTypeLoc | Matcher<TypeLoc>

    Matches arrays and C99 complex types that have a specific element
    type.

    Given
      struct A {};
      A a[7];
      int b[7];
    arrayType(hasElementType(builtinType()))
      matches "int b[7]"

    Usable as: Matcher<ArrayType>, Matcher<ComplexType>

Matcher<ArrayType> | hasElementType | Matcher<Type>

    Matches arrays and C99 complex types that have a specific element
    type.

    Given
      struct A {};
      A a[7];
      int b[7];
    arrayType(hasElementType(builtinType()))
      matches "int b[7]"

    Usable as: Matcher<ArrayType>, Matcher<ComplexType>

Matcher<AtomicTypeLoc> | hasValueTypeLoc | Matcher<TypeLoc>

    Matches atomic types with a specific value type.

    Given
      _Atomic(int) i;
      _Atomic(float) f;
    atomicType(hasValueType(isInteger()))
     matches "_Atomic(int) i"

    Usable as: Matcher<AtomicType>

Matcher<AtomicType> | hasValueType | Matcher<Type>

    Matches atomic types with a specific value type.

    Given
      _Atomic(int) i;
      _Atomic(float) f;
    atomicType(hasValueType(isInteger()))
     matches "_Atomic(int) i"

    Usable as: Matcher<AtomicType>

Matcher<AutoType> | hasDeducedType | Matcher<Type>

    Matches AutoType nodes where the deduced type is a specific type.

    Note: There is no TypeLoc for the deduced type and thus no
    getDeducedLoc() matcher.

    Given
      auto a = 1;
      auto b = 2.0;
    autoType(hasDeducedType(isInteger()))
      matches "auto a"

    Usable as: Matcher<AutoType>

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

    Matches the left hand side of binary operator expressions.

    Example matches a (matcher = binaryOperator(hasLHS()))
      a || b

Matcher<BinaryOperator> | hasRHS | Matcher<Expr> InnerMatcher

    Matches the right hand side of binary operator expressions.

    Example matches b (matcher = binaryOperator(hasRHS()))
      a || b

Matcher<BlockPointerTypeLoc> | pointeeLoc | Matcher<TypeLoc>

    Narrows PointerType (and similar) matchers to those where the
    pointee matches a given matcher.

    Given
      int *a;
      int const *b;
      float const *f;
    pointerType(pointee(isConstQualified(), isInteger()))
      matches "int const *b"

    Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
      Matcher<PointerType>, Matcher<ReferenceType>

Matcher<BlockPointerType> | pointee | Matcher<Type>

    Narrows PointerType (and similar) matchers to those where the
    pointee matches a given matcher.

    Given
      int *a;
      int const *b;
      float const *f;
    pointerType(pointee(isConstQualified(), isInteger()))
      matches "int const *b"

    Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
      Matcher<PointerType>, Matcher<ReferenceType>

Matcher<CXXConstructExpr> | hasAnyArgument | Matcher<Expr> InnerMatcher

    Matches any argument of a call expression or a constructor call
    expression.

    Given
      void x(int, int, int) { int y; x(1, y, 42); }
    callExpr(hasAnyArgument(declRefExpr()))
      matches x(1, y, 42)
    with hasAnyArgument(...)
      matching y

    FIXME: Currently this will ignore parentheses and implicit casts on
    the argument before applying the inner matcher. We'll want to remove
    this to allow for greater control by the user once ignoreImplicit()
    has been implemented.

Matcher<CXXConstructExpr> | hasArgument | unsigned N, Matcher<Expr> InnerMatcher

    Matches the n'th argument of a call expression or a constructor
    call expression.

    Example matches y in x(y)
        (matcher = callExpr(hasArgument(0, declRefExpr())))
      void x(int) { int y; x(y); }

Matcher<CXXConstructExpr> | hasDeclaration | Matcher<Decl> InnerMatcher

    Matches a node if the declaration associated with that node
    matches the given matcher.

    The associated declaration is:
    - for type nodes, the declaration of the underlying type
    - for CallExpr, the declaration of the callee
    - for MemberExpr, the declaration of the referenced member
    - for CXXConstructExpr, the declaration of the constructor

    Also usable as Matcher<T> for any T supporting the getDecl() member
    function. e.g. various subtypes of clang::Type and various expressions.

    Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>,
      Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>,
      Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>,
      Matcher<RecordType>, Matcher<TagType>,
      Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>,
      Matcher<TypedefType>, Matcher<UnresolvedUsingType>

Matcher<CXXConstructorDecl> | forEachConstructorInitializer | Matcher<CXXCtorInitializer> InnerMatcher

    Matches each constructor initializer in a constructor definition.

    Given
      class A { A() : i(42), j(42) {} int i; int j; };
    constructorDecl(forEachConstructorInitializer(forField(decl().bind("x"))))
      will trigger two matches, binding for 'i' and 'j' respectively.

Matcher<CXXConstructorDecl> | hasAnyConstructorInitializer | Matcher<CXXCtorInitializer> InnerMatcher

    Matches a constructor initializer.

    Given
      struct Foo {
        Foo() : foo_(1) { }
        int foo_;
      };
    recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything()))))
      record matches Foo, hasAnyConstructorInitializer matches foo_(1)

Matcher<CXXCtorInitializer> | forField | Matcher<FieldDecl> InnerMatcher

    Matches the field declaration of a constructor initializer.

    Given
      struct Foo {
        Foo() : foo_(1) { }
        int foo_;
      };
    recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
        forField(hasName("foo_"))))))
      matches Foo
    with forField matching foo_

Matcher<CXXCtorInitializer> | withInitializer | Matcher<Expr> InnerMatcher

    Matches the initializer expression of a constructor initializer.

    Given
      struct Foo {
        Foo() : foo_(1) { }
        int foo_;
      };
    recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
        withInitializer(integerLiteral(equals(1)))))))
      matches Foo
    with withInitializer matching (1)

Matcher<CXXForRangeStmt> | hasBody | Matcher<Stmt> InnerMatcher

    Matches a 'for', 'while', or 'do while' statement that has
    a given body.

    Given
      for (;;) {}
    hasBody(compoundStmt())
      matches 'for (;;) {}'
    with compoundStmt()
      matching '{}'

Matcher<CXXForRangeStmt> | hasLoopVariable | Matcher<VarDecl> InnerMatcher

    Matches the initialization statement of a for loop.

    Example:
        forStmt(hasLoopVariable(anything()))
    matches 'int x' in
        for (int x : a) { }

Matcher<CXXForRangeStmt> | hasRangeInit | Matcher<Expr> InnerMatcher

    Matches the range initialization statement of a for loop.

    Example:
        forStmt(hasRangeInit(anything()))
    matches 'a' in
        for (int x : a) { }

Matcher<CXXMemberCallExpr> | onImplicitObjectArgument | 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"))))))
      class Y { public: void x(); };
      void z() { Y y; y.x(); }",

    FIXME: Overload to allow directly matching types?

Matcher<CXXMemberCallExpr> | thisPointerType | Matcher<Decl> InnerMatcher

    Overloaded to match the type's declaration.

Matcher<CXXMemberCallExpr> | thisPointerType | Matcher<QualType> InnerMatcher

    Matches if the expression's type either matches the specified
    matcher, or is a pointer to a type that matches the InnerMatcher.

Matcher<CXXMethodDecl> | ofClass | Matcher<CXXRecordDecl> InnerMatcher

    Matches the class declaration that the given method declaration
    belongs to.

    FIXME: Generalize this for other kinds of declarations.
    FIXME: What other kind of declarations would we need to generalize
    this to?

    Example matches A() in the last line
        (matcher = constructExpr(hasDeclaration(methodDecl(
            ofClass(hasName("A"))))))
      class A {
       public:
        A();
      };
      A a = A();

Matcher<CXXRecordDecl> | hasMethod | Matcher<CXXMethodDecl> InnerMatcher

    Matches the first method of a class or struct that satisfies InnerMatcher.

    Given:
      class A { void func(); };
      class B { void member(); };

    recordDecl(hasMethod(hasName("func"))) matches the declaration of A
    but not B.

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 not 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;
      typedef A B;
      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

Matcher<CXXRecordDecl> | isSameOrDerivedFrom | Matcher<NamedDecl> Base

    Similar to isDerivedFrom(), but also matches classes that directly
    match Base.

Matcher<CallExpr> | callee | Matcher<Decl> InnerMatcher

    Matches if the call expression's callee's declaration matches the
    given matcher.

    Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x")))))
      class Y { public: void x(); };
      void z() { Y y; y.x(); }

Matcher<CallExpr> | callee | Matcher<Stmt> InnerMatcher

    Matches if the call expression's callee expression matches.

    Given
      class Y { void x() { this->x(); x(); Y y; y.x(); } };
      void f() { f(); }
    callExpr(callee(expr()))
      matches this->x(), x(), y.x(), f()
    with callee(...)
      matching this->x, x, y.x, f respectively

    Note: Callee cannot take the more general internal::Matcher<Expr>
    because this introduces ambiguous overloads with calls to Callee taking a
    internal::Matcher<Decl>, as the matcher hierarchy is purely
    implemented in terms of implicit casts.

Matcher<CallExpr> | hasAnyArgument | Matcher<Expr> InnerMatcher

    Matches any argument of a call expression or a constructor call
    expression.

    Given
      void x(int, int, int) { int y; x(1, y, 42); }
    callExpr(hasAnyArgument(declRefExpr()))
      matches x(1, y, 42)
    with hasAnyArgument(...)
      matching y

    FIXME: Currently this will ignore parentheses and implicit casts on
    the argument before applying the inner matcher. We'll want to remove
    this to allow for greater control by the user once ignoreImplicit()
    has been implemented.

Matcher<CallExpr> | hasArgument | unsigned N, Matcher<Expr> InnerMatcher

    Matches the n'th argument of a call expression or a constructor
    call expression.

    Example matches y in x(y)
        (matcher = callExpr(hasArgument(0, declRefExpr())))
      void x(int) { int y; x(y); }

Matcher<CallExpr> | hasDeclaration | Matcher<Decl> InnerMatcher

    Matches a node if the declaration associated with that node
    matches the given matcher.

    The associated declaration is:
    - for type nodes, the declaration of the underlying type
    - for CallExpr, the declaration of the callee
    - for MemberExpr, the declaration of the referenced member
    - for CXXConstructExpr, the declaration of the constructor

    Also usable as Matcher<T> for any T supporting the getDecl() member
    function. e.g. various subtypes of clang::Type and various expressions.

    Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>,
      Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>,
      Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>,
      Matcher<RecordType>, Matcher<TagType>,
      Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>,
      Matcher<TypedefType>, Matcher<UnresolvedUsingType>

Matcher<CaseStmt> | hasCaseConstant | Matcher<Expr> InnerMatcher

    If the given case statement does not use the GNU case range
    extension, matches the constant given in the statement.

    Given
      switch (1) { case 1: case 1+1: case 3 ... 4: ; }
    caseStmt(hasCaseConstant(integerLiteral()))
      matches "case 1:"

Matcher<CastExpr> | hasSourceExpression | Matcher<Expr> InnerMatcher

    Matches if the cast's source expression matches the given matcher.

    Example: matches "a string" (matcher =
                                     hasSourceExpression(constructExpr()))
    class URL { URL(string); };
    URL url = "a string";

Matcher<ClassTemplateSpecializationDecl> | hasAnyTemplateArgument | Matcher<TemplateArgument> InnerMatcher

    Matches classTemplateSpecializations that have at least one
    TemplateArgument matching the given InnerMatcher.

    Given
      template<typename T> class A {};
      template<> class A<double> {};
      A<int> a;
    classTemplateSpecializationDecl(hasAnyTemplateArgument(
        refersToType(asString("int"))))
      matches the specialization A<int>

Matcher<ClassTemplateSpecializationDecl> | hasTemplateArgument | unsigned N, Matcher<TemplateArgument> InnerMatcher

    Matches classTemplateSpecializations where the n'th TemplateArgument
    matches the given InnerMatcher.

    Given
      template<typename T, typename U> class A {};
      A<bool, int> b;
      A<int, bool> c;
    classTemplateSpecializationDecl(hasTemplateArgument(
        1, refersToType(asString("int"))))
      matches the specialization A<bool, int>

Matcher<ComplexTypeLoc> | hasElementTypeLoc | Matcher<TypeLoc>

    Matches arrays and C99 complex types that have a specific element
    type.

    Given
      struct A {};
      A a[7];
      int b[7];
    arrayType(hasElementType(builtinType()))
      matches "int b[7]"

    Usable as: Matcher<ArrayType>, Matcher<ComplexType>

Matcher<ComplexType> | hasElementType | Matcher<Type>

    Matches arrays and C99 complex types that have a specific element
    type.

    Given
      struct A {};
      A a[7];
      int b[7];
    arrayType(hasElementType(builtinType()))
      matches "int b[7]"

    Usable as: Matcher<ArrayType>, Matcher<ComplexType>

Matcher<CompoundStmt> | hasAnySubstatement | Matcher<Stmt> InnerMatcher

    Matches compound statements where at least one substatement matches
    a given matcher.

    Given
      { {}; 1+2; }
    hasAnySubstatement(compoundStmt())
      matches '{ {}; 1+2; }'
    with compoundStmt()
      matching '{}'

Matcher<ConditionalOperator> | hasCondition | Matcher<Expr> InnerMatcher

    Matches the condition expression of an if statement, for loop,
    or conditional operator.

    Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
      if (true) {}

Matcher<ConditionalOperator> | hasFalseExpression | Matcher<Expr> InnerMatcher

    Matches the false branch expression of a conditional operator.

    Example matches b
      condition ? a : b

Matcher<ConditionalOperator> | hasTrueExpression | Matcher<Expr> InnerMatcher

    Matches the true branch expression of a conditional operator.

    Example matches a
      condition ? a : b

Matcher<DeclRefExpr> | hasDeclaration | Matcher<Decl> InnerMatcher

    Matches a node if the declaration associated with that node
    matches the given matcher.

    The associated declaration is:
    - for type nodes, the declaration of the underlying type
    - for CallExpr, the declaration of the callee
    - for MemberExpr, the declaration of the referenced member
    - for CXXConstructExpr, the declaration of the constructor

    Also usable as Matcher<T> for any T supporting the getDecl() member
    function. e.g. various subtypes of clang::Type and various expressions.

    Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>,
      Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>,
      Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>,
      Matcher<RecordType>, Matcher<TagType>,
      Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>,
      Matcher<TypedefType>, Matcher<UnresolvedUsingType>

Matcher<DeclRefExpr> | throughUsingDecl | Matcher<UsingShadowDecl> InnerMatcher

    Matches a DeclRefExpr that refers to a declaration through a
    specific using shadow declaration.

    FIXME: This currently only works for functions. Fix.

    Given
      namespace a { void f() {} }
      using a::f;
      void g() {
        f();     Matches this ..
        a::f();  .. but not this.
      }
    declRefExpr(throughUsingDeclaration(anything()))
      matches f()

Matcher<DeclRefExpr> | to | Matcher<Decl> InnerMatcher

    Matches a DeclRefExpr that refers to a declaration that matches the
    specified matcher.

    Example matches x in if(x)
        (matcher = declRefExpr(to(varDecl(hasName("x")))))
      bool x;
      if (x) {}

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
    breaks up multiple-declaration DeclStmt's into multiple single-declaration
    DeclStmt's.
    Example: Given non-global declarations
      int a, b = 0;
      int c;
      int d = 2, e;
    declStmt(containsDeclaration(
          0, varDecl(hasInitializer(anything()))))
      matches only 'int d = 2, e;', and
    declStmt(containsDeclaration(1, varDecl()))
      matches 'int a, b = 0' as well as 'int d = 2, e;'
      but 'int c;' is not matched.

Matcher<DeclStmt> | hasSingleDecl | Matcher<Decl> InnerMatcher

    Matches the Decl of a DeclStmt which has a single declaration.

    Given
      int a, b;
      int c;
    declStmt(hasSingleDecl(anything()))
      matches 'int c;' but not 'int a, b;'.

Matcher<DeclaratorDecl> | hasTypeLoc | Matcher<TypeLoc> Inner

    Matches if the type location of the declarator decl's type matches
    the inner matcher.

    Given
      int x;
    declaratorDecl(hasTypeLoc(loc(asString("int"))))
      matches int x

Matcher<Decl> | hasDeclContext | Matcher<Decl> InnerMatcher

    Matches declarations whose declaration context, interpreted as a
    Decl, matches InnerMatcher.

    Given
      namespace N {
        namespace M {
          class D {};
        }
      }

    recordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
    declaration of class D.

Matcher<DoStmt> | hasBody | Matcher<Stmt> InnerMatcher

    Matches a 'for', 'while', or 'do while' statement that has
    a given body.

    Given
      for (;;) {}
    hasBody(compoundStmt())
      matches 'for (;;) {}'
    with compoundStmt()
      matching '{}'

Matcher<DoStmt> | hasCondition | Matcher<Expr> InnerMatcher

    Matches the condition expression of an if statement, for loop,
    or conditional operator.

    Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
      if (true) {}

Matcher<ElaboratedType> | hasQualifier | Matcher<NestedNameSpecifier> InnerMatcher

    Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
    matches InnerMatcher if the qualifier exists.

    Given
      namespace N {
        namespace M {
          class D {};
        }
      }
      N::M::D d;

    elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N"))))
    matches the type of the variable declaration of d.

Matcher<ElaboratedType> | namesType | Matcher<QualType> InnerMatcher

    Matches ElaboratedTypes whose named type matches InnerMatcher.

    Given
      namespace N {
        namespace M {
          class D {};
        }
      }
      N::M::D d;

    elaboratedType(namesType(recordType(
    hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable
    declaration of d.

Matcher<EnumType> | hasDeclaration | Matcher<Decl> InnerMatcher

    Matches a node if the declaration associated with that node
    matches the given matcher.

    The associated declaration is:
    - for type nodes, the declaration of the underlying type
    - for CallExpr, the declaration of the callee
    - for MemberExpr, the declaration of the referenced member
    - for CXXConstructExpr, the declaration of the constructor

    Also usable as Matcher<T> for any T supporting the getDecl() member
    function. e.g. various subtypes of clang::Type and various expressions.

    Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>,
      Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>,
      Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>,
      Matcher<RecordType>, Matcher<TagType>,
      Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>,
      Matcher<TypedefType>, Matcher<UnresolvedUsingType>

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
    actual casts "explicit" casts.)

Matcher<Expr> | hasType | Matcher<Decl> InnerMatcher

    Overloaded to match the declaration of the expression's or value
    declaration's type.

    In case of a value declaration (for example a variable declaration),
    this resolves one layer of indirection. For example, in the value
    declaration "X x;", recordDecl(hasName("X")) matches the declaration of X,
    while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration
    of x."

    Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
                and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
     class X {};
     void y(X &x) { x; X z; }

    Usable as: Matcher<Expr>, Matcher<ValueDecl>

Matcher<Expr> | hasType | Matcher<QualType> InnerMatcher

    Matches if the expression's or declaration's type matches a type
    matcher.

    Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
                and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
     class X {};
     void y(X &x) { x; X z; }

Matcher<Expr> | ignoringImpCasts | Matcher<Expr> InnerMatcher

    Matches expressions that match InnerMatcher after any implicit casts
    are stripped off.

    Parentheses and explicit casts are not discarded.
    Given
      int arr[5];
      int a = 0;
      char b = 0;
      const int c = a;
      int *d = arr;
      long e = (long) 0l;
    The matchers
       varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
       varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
    would match the declarations for a, b, c, and d, but not e.
    While
       varDecl(hasInitializer(integerLiteral()))
       varDecl(hasInitializer(declRefExpr()))
    only match the declarations for b, c, and d.

Matcher<Expr> | ignoringParenCasts | Matcher<Expr> InnerMatcher

    Matches expressions that match InnerMatcher after parentheses and
    casts are stripped off.

    Implicit and non-C Style casts are also discarded.
    Given
      int a = 0;
      char b = (0);
      void* c = reinterpret_cast<char*>(0);
      char d = char(0);
    The matcher
       varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
    would match the declarations for a, b, c, and d.
    while
       varDecl(hasInitializer(integerLiteral()))
    only match the declaration for a.

Matcher<Expr> | ignoringParenImpCasts | Matcher<Expr> InnerMatcher

    Matches expressions that match InnerMatcher after implicit casts and
    parentheses are stripped off.

    Explicit casts are not discarded.
    Given
      int arr[5];
      int a = 0;
      char b = (0);
      const int c = a;
      int *d = (arr);
      long e = ((long) 0l);
    The matchers
       varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
       varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
    would match the declarations for a, b, c, and d, but not e.
    while
       varDecl(hasInitializer(integerLiteral()))
       varDecl(hasInitializer(declRefExpr()))
    would only match the declaration for a.

Matcher<ForStmt> | hasBody | Matcher<Stmt> InnerMatcher

    Matches a 'for', 'while', or 'do while' statement that has
    a given body.

    Given
      for (;;) {}
    hasBody(compoundStmt())
      matches 'for (;;) {}'
    with compoundStmt()
      matching '{}'

Matcher<ForStmt> | hasCondition | Matcher<Expr> InnerMatcher

    Matches the condition expression of an if statement, for loop,
    or conditional operator.

    Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
      if (true) {}

Matcher<ForStmt> | hasIncrement | Matcher<Stmt> InnerMatcher

    Matches the increment statement of a for loop.

    Example:
        forStmt(hasIncrement(unaryOperator(hasOperatorName("++"))))
    matches '++x' in
        for (x; x < N; ++x) { }

Matcher<ForStmt> | hasLoopInit | Matcher<Stmt> InnerMatcher

    Matches the initialization statement of a for loop.

    Example:
        forStmt(hasLoopInit(declStmt()))
    matches 'int x = 0' in
        for (int x = 0; x < N; ++x) { }

Matcher<FunctionDecl> | hasAnyParameter | Matcher<ParmVarDecl> InnerMatcher

    Matches any parameter of a function declaration.

    Does not match the 'this' parameter of a method.

    Given
      class X { void f(int x, int y, int z) {} };
    methodDecl(hasAnyParameter(hasName("y")))
      matches f(int x, int y, int z) {}
    with hasAnyParameter(...)
      matching int y

Matcher<FunctionDecl> | hasParameter | unsigned N, Matcher<ParmVarDecl> InnerMatcher

    Matches the n'th parameter of a function declaration.

    Given
      class X { void f(int x) {} };
    methodDecl(hasParameter(0, hasType(varDecl())))
      matches f(int x) {}
    with hasParameter(...)
      matching int x

Matcher<FunctionDecl> | returns | Matcher<QualType> InnerMatcher

    Matches the return type of a function declaration.

    Given:
      class X { int f() { return 1; } };
    methodDecl(returns(asString("int")))
      matches int f() { return 1; }

Matcher<IfStmt> | hasCondition | Matcher<Expr> InnerMatcher

    Matches the condition expression of an if statement, for loop,
    or conditional operator.

    Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
      if (true) {}

Matcher<IfStmt> | hasConditionVariableStatement | Matcher<DeclStmt> InnerMatcher

    Matches the condition variable statement in an if statement.

    Given
      if (A* a = GetAPointer()) {}
    hasConditionVariableStatement(...)
      matches 'A* a = GetAPointer()'.

Matcher<IfStmt> | hasElse | Matcher<Stmt> InnerMatcher

    Matches the else-statement of an if statement.

    Examples matches the if statement
      (matcher = ifStmt(hasElse(boolLiteral(equals(true)))))
      if (false) false; else true;

Matcher<IfStmt> | hasThen | Matcher<Stmt> InnerMatcher

    Matches the then-statement of an if statement.

    Examples matches the if statement
      (matcher = ifStmt(hasThen(boolLiteral(equals(true)))))
      if (false) true; else false;

Matcher<ImplicitCastExpr> | hasImplicitDestinationType | Matcher<QualType> InnerMatcher

    Matches implicit casts whose destination type matches a given
    matcher.

    FIXME: Unit test this matcher

Matcher<InjectedClassNameType> | hasDeclaration | Matcher<Decl> InnerMatcher

    Matches a node if the declaration associated with that node
    matches the given matcher.

    The associated declaration is:
    - for type nodes, the declaration of the underlying type
    - for CallExpr, the declaration of the callee
    - for MemberExpr, the declaration of the referenced member
    - for CXXConstructExpr, the declaration of the constructor

    Also usable as Matcher<T> for any T supporting the getDecl() member
    function. e.g. various subtypes of clang::Type and various expressions.

    Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>,
      Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>,
      Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>,
      Matcher<RecordType>, Matcher<TagType>,
      Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>,
      Matcher<TypedefType>, Matcher<UnresolvedUsingType>

Matcher<LabelStmt> | hasDeclaration | Matcher<Decl> InnerMatcher

    Matches a node if the declaration associated with that node
    matches the given matcher.

    The associated declaration is:
    - for type nodes, the declaration of the underlying type
    - for CallExpr, the declaration of the callee
    - for MemberExpr, the declaration of the referenced member
    - for CXXConstructExpr, the declaration of the constructor

    Also usable as Matcher<T> for any T supporting the getDecl() member
    function. e.g. various subtypes of clang::Type and various expressions.

    Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>,
      Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>,
      Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>,
      Matcher<RecordType>, Matcher<TagType>,
      Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>,
      Matcher<TypedefType>, Matcher<UnresolvedUsingType>

Matcher<MemberExpr> | hasDeclaration | Matcher<Decl> InnerMatcher

    Matches a node if the declaration associated with that node
    matches the given matcher.

    The associated declaration is:
    - for type nodes, the declaration of the underlying type
    - for CallExpr, the declaration of the callee
    - for MemberExpr, the declaration of the referenced member
    - for CXXConstructExpr, the declaration of the constructor

    Also usable as Matcher<T> for any T supporting the getDecl() member
    function. e.g. various subtypes of clang::Type and various expressions.

    Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>,
      Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>,
      Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>,
      Matcher<RecordType>, Matcher<TagType>,
      Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>,
      Matcher<TypedefType>, Matcher<UnresolvedUsingType>

Matcher<MemberExpr> | hasObjectExpression | Matcher<Expr> InnerMatcher

    Matches a member expression where the object expression is
    matched by a given matcher.

    Given
      struct X { int m; };
      void f(X x) { x.m; m; }
    memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))))
      matches "x.m" and "m"
    with hasObjectExpression(...)
      matching "x" and the implicit object expression of "m" which has type X*.

Matcher<MemberExpr> | member | Matcher<ValueDecl> InnerMatcher

    Matches a member expression where the member is matched by a
    given matcher.

    Given
      struct { int first, second; } first, second;
      int i(second.first);
      int j(first.second);
    memberExpr(member(hasName("first")))
      matches second.first
      but not first.second (because the member name there is "second").

Matcher<MemberPointerTypeLoc> | pointeeLoc | Matcher<TypeLoc>

    Narrows PointerType (and similar) matchers to those where the
    pointee matches a given matcher.

    Given
      int *a;
      int const *b;
      float const *f;
    pointerType(pointee(isConstQualified(), isInteger()))
      matches "int const *b"

    Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
      Matcher<PointerType>, Matcher<ReferenceType>

Matcher<MemberPointerType> | pointee | Matcher<Type>

    Narrows PointerType (and similar) matchers to those where the
    pointee matches a given matcher.

    Given
      int *a;
      int const *b;
      float const *f;
    pointerType(pointee(isConstQualified(), isInteger()))
      matches "int const *b"

    Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
      Matcher<PointerType>, Matcher<ReferenceType>

Matcher<NestedNameSpecifierLoc> | hasPrefix | Matcher<NestedNameSpecifierLoc> InnerMatcher

    Matches on the prefix of a NestedNameSpecifierLoc.

    Given
      struct A { struct B { struct C {}; }; };
      A::B::C c;
    nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A")))))
      matches "A::"

Matcher<NestedNameSpecifierLoc> | specifiesTypeLoc | Matcher<TypeLoc> InnerMatcher

    Matches nested name specifier locs that specify a type matching the
    given TypeLoc.

    Given
      struct A { struct B { struct C {}; }; };
      A::B::C c;
    nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
      hasDeclaration(recordDecl(hasName("A")))))))
      matches "A::"

Matcher<NestedNameSpecifier> | hasPrefix | Matcher<NestedNameSpecifier> InnerMatcher

    Matches on the prefix of a NestedNameSpecifier.

    Given
      struct A { struct B { struct C {}; }; };
      A::B::C c;
    nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and
      matches "A::"

Matcher<NestedNameSpecifier> | specifiesNamespace | Matcher<NamespaceDecl> InnerMatcher

    Matches nested name specifiers that specify a namespace matching the
    given namespace matcher.

    Given
      namespace ns { struct A {}; }
      ns::A a;
    nestedNameSpecifier(specifiesNamespace(hasName("ns")))
      matches "ns::"

Matcher<NestedNameSpecifier> | specifiesType | Matcher<QualType> InnerMatcher

    Matches nested name specifiers that specify a type matching the
    given QualType matcher without qualifiers.

    Given
      struct A { struct B { struct C {}; }; };
      A::B::C c;
    nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A")))))
      matches "A::"

Matcher<ParenType> | innerType | Matcher<Type>

    Matches ParenType nodes where the inner type is a specific type.

    Given
      int (*ptr_to_array)[4];
      int (*ptr_to_func)(int);

    varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches
    ptr_to_func but not ptr_to_array.

    Usable as: Matcher<ParenType>

Matcher<PointerTypeLoc> | pointeeLoc | Matcher<TypeLoc>

    Narrows PointerType (and similar) matchers to those where the
    pointee matches a given matcher.

    Given
      int *a;
      int const *b;
      float const *f;
    pointerType(pointee(isConstQualified(), isInteger()))
      matches "int const *b"

    Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
      Matcher<PointerType>, Matcher<ReferenceType>

Matcher<PointerType> | pointee | Matcher<Type>

    Narrows PointerType (and similar) matchers to those where the
    pointee matches a given matcher.

    Given
      int *a;
      int const *b;
      float const *f;
    pointerType(pointee(isConstQualified(), isInteger()))
      matches "int const *b"

    Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
      Matcher<PointerType>, Matcher<ReferenceType>

Matcher<QualType> | hasCanonicalType | Matcher<QualType> InnerMatcher

    Matches QualTypes whose canonical type matches InnerMatcher.

    Given:
      typedef int &int_ref;
      int a;
      int_ref b = a;

    varDecl(hasType(qualType(referenceType()))))) will not match the
    declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does.

Matcher<QualType> | hasDeclaration | Matcher<Decl> InnerMatcher

    Matches a node if the declaration associated with that node
    matches the given matcher.

    The associated declaration is:
    - for type nodes, the declaration of the underlying type
    - for CallExpr, the declaration of the callee
    - for MemberExpr, the declaration of the referenced member
    - for CXXConstructExpr, the declaration of the constructor

    Also usable as Matcher<T> for any T supporting the getDecl() member
    function. e.g. various subtypes of clang::Type and various expressions.

    Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>,
      Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>,
      Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>,
      Matcher<RecordType>, Matcher<TagType>,
      Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>,
      Matcher<TypedefType>, Matcher<UnresolvedUsingType>

Matcher<QualType> | pointsTo | Matcher<Decl> InnerMatcher

    Overloaded to match the pointee type's declaration.

Matcher<QualType> | pointsTo | Matcher<QualType> InnerMatcher

    Matches if the matched type is a pointer type and the pointee type
    matches the specified matcher.

    Example matches y->x()
        (matcher = callExpr(on(hasType(pointsTo(recordDecl(hasName("Y")))))))
      class Y { public: void x(); };
      void z() { Y *y; y->x(); }

Matcher<QualType> | references | Matcher<Decl> InnerMatcher

    Overloaded to match the referenced type's declaration.

Matcher<QualType> | references | Matcher<QualType> InnerMatcher

    Matches if the matched type is a reference type and the referenced
    type matches the specified matcher.

    Example matches X &x and const X &y
        (matcher = varDecl(hasType(references(recordDecl(hasName("X"))))))
      class X {
        void a(X b) {
          X &x = b;
          const X &y = b;
        }
      };

Matcher<RecordType> | hasDeclaration | Matcher<Decl> InnerMatcher

    Matches a node if the declaration associated with that node
    matches the given matcher.

    The associated declaration is:
    - for type nodes, the declaration of the underlying type
    - for CallExpr, the declaration of the callee
    - for MemberExpr, the declaration of the referenced member
    - for CXXConstructExpr, the declaration of the constructor

    Also usable as Matcher<T> for any T supporting the getDecl() member
    function. e.g. various subtypes of clang::Type and various expressions.

    Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>,
      Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>,
      Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>,
      Matcher<RecordType>, Matcher<TagType>,
      Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>,
      Matcher<TypedefType>, Matcher<UnresolvedUsingType>

Matcher<ReferenceTypeLoc> | pointeeLoc | Matcher<TypeLoc>

    Narrows PointerType (and similar) matchers to those where the
    pointee matches a given matcher.

    Given
      int *a;
      int const *b;
      float const *f;
    pointerType(pointee(isConstQualified(), isInteger()))
      matches "int const *b"

    Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
      Matcher<PointerType>, Matcher<ReferenceType>

Matcher<ReferenceType> | pointee | Matcher<Type>

    Narrows PointerType (and similar) matchers to those where the
    pointee matches a given matcher.

    Given
      int *a;
      int const *b;
      float const *f;
    pointerType(pointee(isConstQualified(), isInteger()))
      matches "int const *b"

    Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
      Matcher<PointerType>, Matcher<ReferenceType>

Matcher<Stmt> | alignOfExpr | Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher

    Same as unaryExprOrTypeTraitExpr, but only matching
    alignof.

Matcher<Stmt> | sizeOfExpr | Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher

    Same as unaryExprOrTypeTraitExpr, but only matching
    sizeof.

Matcher<SwitchStmt> | forEachSwitchCase | Matcher<SwitchCase> InnerMatcher

    Matches each case or default statement belonging to the given switch
    statement. This matcher may produce multiple matches.

    Given
      switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } }
    switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s")
      matches four times, with "c" binding each of "case 1:", "case 2:",
    "case 3:" and "case 4:", and "s" respectively binding "switch (1)",
    "switch (1)", "switch (2)" and "switch (2)".

Matcher<TagType> | hasDeclaration | Matcher<Decl> InnerMatcher

    Matches a node if the declaration associated with that node
    matches the given matcher.

    The associated declaration is:
    - for type nodes, the declaration of the underlying type
    - for CallExpr, the declaration of the callee
    - for MemberExpr, the declaration of the referenced member
    - for CXXConstructExpr, the declaration of the constructor

    Also usable as Matcher<T> for any T supporting the getDecl() member
    function. e.g. various subtypes of clang::Type and various expressions.

    Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>,
      Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>,
      Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>,
      Matcher<RecordType>, Matcher<TagType>,
      Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>,
      Matcher<TypedefType>, Matcher<UnresolvedUsingType>

Matcher<TemplateArgument> | isExpr | Matcher<Expr> InnerMatcher

    Matches a sugar TemplateArgument that refers to a certain expression.

    Given
      template<typename T> struct A {};
      struct B { B* next; };
      A<&B::next> a;
    templateSpecializationType(hasAnyTemplateArgument(
      isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next"))))))))
      matches the specialization A<&B::next> with fieldDecl(...) matching
        B::next

Matcher<TemplateArgument> | refersToDeclaration | Matcher<Decl> InnerMatcher

    Matches a canonical TemplateArgument that refers to a certain
    declaration.

    Given
      template<typename T> struct A {};
      struct B { B* next; };
      A<&B::next> a;
    classTemplateSpecializationDecl(hasAnyTemplateArgument(
        refersToDeclaration(fieldDecl(hasName("next"))))
      matches the specialization A<&B::next> with fieldDecl(...) matching
        B::next

Matcher<TemplateArgument> | refersToIntegralType | Matcher<QualType> InnerMatcher

    Matches a TemplateArgument that referes to an integral type.

    Given
      template<int T> struct A {};
      C<42> c;
    classTemplateSpecializationDecl(
      hasAnyTemplateArgument(refersToIntegralType(asString("int"))))
      matches the implicit instantiation of C in C<42>.

Matcher<TemplateArgument> | refersToType | Matcher<QualType> InnerMatcher

    Matches a TemplateArgument that refers to a certain type.

    Given
      struct X {};
      template<typename T> struct A {};
      A<X> a;
    classTemplateSpecializationDecl(hasAnyTemplateArgument(
        refersToType(class(hasName("X")))))
      matches the specialization A<X>

Matcher<TemplateSpecializationType> | hasAnyTemplateArgument | Matcher<TemplateArgument> InnerMatcher

    Matches classTemplateSpecializations that have at least one
    TemplateArgument matching the given InnerMatcher.

    Given
      template<typename T> class A {};
      template<> class A<double> {};
      A<int> a;
    classTemplateSpecializationDecl(hasAnyTemplateArgument(
        refersToType(asString("int"))))
      matches the specialization A<int>

Matcher<TemplateSpecializationType> | hasDeclaration | Matcher<Decl> InnerMatcher

    Matches a node if the declaration associated with that node
    matches the given matcher.

    The associated declaration is:
    - for type nodes, the declaration of the underlying type
    - for CallExpr, the declaration of the callee
    - for MemberExpr, the declaration of the referenced member
    - for CXXConstructExpr, the declaration of the constructor

    Also usable as Matcher<T> for any T supporting the getDecl() member
    function. e.g. various subtypes of clang::Type and various expressions.

    Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>,
      Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>,
      Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>,
      Matcher<RecordType>, Matcher<TagType>,
      Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>,
      Matcher<TypedefType>, Matcher<UnresolvedUsingType>

Matcher<TemplateSpecializationType> | hasTemplateArgument | unsigned N, Matcher<TemplateArgument> InnerMatcher

    Matches classTemplateSpecializations where the n'th TemplateArgument
    matches the given InnerMatcher.

    Given
      template<typename T, typename U> class A {};
      A<bool, int> b;
      A<int, bool> c;
    classTemplateSpecializationDecl(hasTemplateArgument(
        1, refersToType(asString("int"))))
      matches the specialization A<bool, int>

Matcher<TemplateTypeParmType> | hasDeclaration | Matcher<Decl> InnerMatcher

    Matches a node if the declaration associated with that node
    matches the given matcher.

    The associated declaration is:
    - for type nodes, the declaration of the underlying type
    - for CallExpr, the declaration of the callee
    - for MemberExpr, the declaration of the referenced member
    - for CXXConstructExpr, the declaration of the constructor

    Also usable as Matcher<T> for any T supporting the getDecl() member
    function. e.g. various subtypes of clang::Type and various expressions.

    Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>,
      Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>,
      Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>,
      Matcher<RecordType>, Matcher<TagType>,
      Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>,
      Matcher<TypedefType>, Matcher<UnresolvedUsingType>

Matcher<T> | findAll | Matcher<T> Matcher

    Matches if the node or any descendant matches.

    Generates results for each match.

    For example, in:
      class A { class B {}; class C {}; };
    The matcher:
      recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("m")))
    will generate results for A, B and C.

    Usable as: Any Matcher

Matcher<TypedefType> | hasDeclaration | Matcher<Decl> InnerMatcher

    Matches a node if the declaration associated with that node
    matches the given matcher.

    The associated declaration is:
    - for type nodes, the declaration of the underlying type
    - for CallExpr, the declaration of the callee
    - for MemberExpr, the declaration of the referenced member
    - for CXXConstructExpr, the declaration of the constructor

    Also usable as Matcher<T> for any T supporting the getDecl() member
    function. e.g. various subtypes of clang::Type and various expressions.

    Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>,
      Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>,
      Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>,
      Matcher<RecordType>, Matcher<TagType>,
      Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>,
      Matcher<TypedefType>, Matcher<UnresolvedUsingType>

Matcher<UnaryExprOrTypeTraitExpr> | hasArgumentOfType | Matcher<QualType> InnerMatcher

    Matches unary expressions that have a specific type of argument.

    Given
      int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
    unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))
      matches sizeof(a) and alignof(c)

Matcher<UnaryOperator> | hasUnaryOperand | Matcher<Expr> InnerMatcher

    Matches if the operand of a unary operator matches.

    Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true))))
      !true

Matcher<UnresolvedUsingType> | hasDeclaration | Matcher<Decl> InnerMatcher

    Matches a node if the declaration associated with that node
    matches the given matcher.

    The associated declaration is:
    - for type nodes, the declaration of the underlying type
    - for CallExpr, the declaration of the callee
    - for MemberExpr, the declaration of the referenced member
    - for CXXConstructExpr, the declaration of the constructor

    Also usable as Matcher<T> for any T supporting the getDecl() member
    function. e.g. various subtypes of clang::Type and various expressions.

    Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>,
      Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>,
      Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>,
      Matcher<RecordType>, Matcher<TagType>,
      Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>,
      Matcher<TypedefType>, Matcher<UnresolvedUsingType>

Matcher<UsingDecl> | hasAnyUsingShadowDecl | Matcher<UsingShadowDecl> InnerMatcher

    Matches any using shadow declaration.

    Given
      namespace X { void b(); }
      using X::b;
    usingDecl(hasAnyUsingShadowDecl(hasName("b"))))
      matches using X::b

Matcher<UsingShadowDecl> | hasTargetDecl | Matcher<NamedDecl> InnerMatcher

    Matches a using shadow declaration where the target declaration is
    matched by the given matcher.

    Given
      namespace X { int a; void b(); }
      using X::a;
      using X::b;
    usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
      matches using X::b but not using X::a

Matcher<ValueDecl> | hasType | Matcher<Decl> InnerMatcher

    Overloaded to match the declaration of the expression's or value
    declaration's type.

    In case of a value declaration (for example a variable declaration),
    this resolves one layer of indirection. For example, in the value
    declaration "X x;", recordDecl(hasName("X")) matches the declaration of X,
    while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration
    of x."

    Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
                and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
     class X {};
     void y(X &x) { x; X z; }

    Usable as: Matcher<Expr>, Matcher<ValueDecl>

Matcher<ValueDecl> | hasType | Matcher<QualType> InnerMatcher

    Matches if the expression's or declaration's type matches a type
    matcher.

    Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
                and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
     class X {};
     void y(X &x) { x; X z; }

Matcher<VarDecl> | hasInitializer | Matcher<Expr> InnerMatcher

    Matches a variable declaration that has an initializer expression
    that matches the given matcher.

    Example matches x (matcher = varDecl(hasInitializer(callExpr())))
      bool y() { return true; }
      bool x = y();

Matcher<VariableArrayType> | hasSizeExpr | Matcher<Expr> InnerMatcher

    Matches VariableArrayType nodes that have a specific size
    expression.

    Given
      void f(int b) {
        int a[b];
      }
    variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
      varDecl(hasName("b")))))))
      matches "int a[b]"

Matcher<WhileStmt> | hasBody | Matcher<Stmt> InnerMatcher

    Matches a 'for', 'while', or 'do while' statement that has
    a given body.

    Given
      for (;;) {}
    hasBody(compoundStmt())
      matches 'for (;;) {}'
    with compoundStmt()
      matching '{}'

Matcher<WhileStmt> | hasCondition | Matcher<Expr> InnerMatcher

    Matches the condition expression of an if statement, for loop,
    or conditional operator.

    Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
      if (true) {}

Matcher<internal::BindableMatcher<NestedNameSpecifierLoc>> | loc | Matcher<NestedNameSpecifier> InnerMatcher

    Matches NestedNameSpecifierLocs for which the given inner
    NestedNameSpecifier-matcher matches.

Matcher<internal::BindableMatcher<TypeLoc>> | loc | Matcher<QualType> InnerMatcher

    Matches TypeLocs for which the given inner
    QualType-matcher matches.