head 1.1; branch 1.1.1; access; symbols netbsd-11-0-RC4:1.1.1.10 netbsd-11-0-RC3:1.1.1.10 netbsd-11-0-RC2:1.1.1.10 netbsd-11-0-RC1:1.1.1.10 perseant-exfatfs-base-20250801:1.1.1.10 netbsd-11:1.1.1.10.0.10 netbsd-11-base:1.1.1.10 netbsd-10-1-RELEASE:1.1.1.10 perseant-exfatfs-base-20240630:1.1.1.10 perseant-exfatfs:1.1.1.10.0.8 perseant-exfatfs-base:1.1.1.10 netbsd-8-3-RELEASE:1.1.1.7 netbsd-9-4-RELEASE:1.1.1.9 netbsd-10-0-RELEASE:1.1.1.10 netbsd-10-0-RC6:1.1.1.10 netbsd-10-0-RC5:1.1.1.10 netbsd-10-0-RC4:1.1.1.10 netbsd-10-0-RC3:1.1.1.10 netbsd-10-0-RC2:1.1.1.10 netbsd-10-0-RC1:1.1.1.10 netbsd-10:1.1.1.10.0.6 netbsd-10-base:1.1.1.10 netbsd-9-3-RELEASE:1.1.1.9 cjep_sun2x:1.1.1.10.0.4 cjep_sun2x-base:1.1.1.10 cjep_staticlib_x-base1:1.1.1.10 netbsd-9-2-RELEASE:1.1.1.9 cjep_staticlib_x:1.1.1.10.0.2 cjep_staticlib_x-base:1.1.1.10 netbsd-9-1-RELEASE:1.1.1.9 phil-wifi-20200421:1.1.1.10 phil-wifi-20200411:1.1.1.10 phil-wifi-20200406:1.1.1.10 netbsd-8-2-RELEASE:1.1.1.7 netbsd-9-0-RELEASE:1.1.1.9 netbsd-9-0-RC2:1.1.1.9 netbsd-9-0-RC1:1.1.1.9 netbsd-9:1.1.1.9.0.2 netbsd-9-base:1.1.1.9 phil-wifi-20190609:1.1.1.9 netbsd-8-1-RELEASE:1.1.1.7 netbsd-8-1-RC1:1.1.1.7 pgoyette-compat-merge-20190127:1.1.1.8.2.1 pgoyette-compat-20190127:1.1.1.9 pgoyette-compat-20190118:1.1.1.9 pgoyette-compat-1226:1.1.1.9 pgoyette-compat-1126:1.1.1.9 pgoyette-compat-1020:1.1.1.9 pgoyette-compat-0930:1.1.1.9 pgoyette-compat-0906:1.1.1.9 netbsd-7-2-RELEASE:1.1.1.4.2.1 pgoyette-compat-0728:1.1.1.9 clang-337282:1.1.1.9 netbsd-8-0-RELEASE:1.1.1.7 phil-wifi:1.1.1.8.0.4 phil-wifi-base:1.1.1.8 pgoyette-compat-0625:1.1.1.8 netbsd-8-0-RC2:1.1.1.7 pgoyette-compat-0521:1.1.1.8 pgoyette-compat-0502:1.1.1.8 pgoyette-compat-0422:1.1.1.8 netbsd-8-0-RC1:1.1.1.7 pgoyette-compat-0415:1.1.1.8 pgoyette-compat-0407:1.1.1.8 pgoyette-compat-0330:1.1.1.8 pgoyette-compat-0322:1.1.1.8 pgoyette-compat-0315:1.1.1.8 netbsd-7-1-2-RELEASE:1.1.1.4.2.1 pgoyette-compat:1.1.1.8.0.2 pgoyette-compat-base:1.1.1.8 netbsd-7-1-1-RELEASE:1.1.1.4.2.1 clang-319952:1.1.1.8 matt-nb8-mediatek:1.1.1.7.0.10 matt-nb8-mediatek-base:1.1.1.7 clang-309604:1.1.1.8 perseant-stdc-iso10646:1.1.1.7.0.8 perseant-stdc-iso10646-base:1.1.1.7 netbsd-8:1.1.1.7.0.6 netbsd-8-base:1.1.1.7 prg-localcount2-base3:1.1.1.7 prg-localcount2-base2:1.1.1.7 prg-localcount2-base1:1.1.1.7 prg-localcount2:1.1.1.7.0.4 prg-localcount2-base:1.1.1.7 pgoyette-localcount-20170426:1.1.1.7 bouyer-socketcan-base1:1.1.1.7 pgoyette-localcount-20170320:1.1.1.7 netbsd-7-1:1.1.1.4.2.1.0.6 netbsd-7-1-RELEASE:1.1.1.4.2.1 netbsd-7-1-RC2:1.1.1.4.2.1 clang-294123:1.1.1.7 netbsd-7-nhusb-base-20170116:1.1.1.4.2.1 bouyer-socketcan:1.1.1.7.0.2 bouyer-socketcan-base:1.1.1.7 clang-291444:1.1.1.7 pgoyette-localcount-20170107:1.1.1.6 netbsd-7-1-RC1:1.1.1.4.2.1 pgoyette-localcount-20161104:1.1.1.6 netbsd-7-0-2-RELEASE:1.1.1.4.2.1 localcount-20160914:1.1.1.6 netbsd-7-nhusb:1.1.1.4.2.1.0.4 netbsd-7-nhusb-base:1.1.1.4.2.1 clang-280599:1.1.1.6 pgoyette-localcount-20160806:1.1.1.6 pgoyette-localcount-20160726:1.1.1.6 pgoyette-localcount:1.1.1.6.0.2 pgoyette-localcount-base:1.1.1.6 netbsd-7-0-1-RELEASE:1.1.1.4.2.1 clang-261930:1.1.1.6 netbsd-7-0:1.1.1.4.2.1.0.2 netbsd-7-0-RELEASE:1.1.1.4.2.1 netbsd-7-0-RC3:1.1.1.4.2.1 netbsd-7-0-RC2:1.1.1.4.2.1 netbsd-7-0-RC1:1.1.1.4.2.1 clang-237755:1.1.1.5 clang-232565:1.1.1.5 clang-227398:1.1.1.5 tls-maxphys-base:1.1.1.4 tls-maxphys:1.1.1.4.0.4 netbsd-7:1.1.1.4.0.2 netbsd-7-base:1.1.1.4 clang-215315:1.1.1.4 clang-209886:1.1.1.3 yamt-pagecache:1.1.1.2.0.4 yamt-pagecache-base9:1.1.1.2 tls-earlyentropy:1.1.1.2.0.2 tls-earlyentropy-base:1.1.1.3 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.2 riastradh-drm2-base3:1.1.1.2 clang-202566:1.1.1.2 clang-201163:1.1.1.1 clang-199312:1.1.1.1 clang-198450:1.1.1.1 clang-196603:1.1.1.1 clang-195771:1.1.1.1 LLVM:1.1.1; locks; strict; comment @# @; 1.1 date 2013.11.28.14.14.47; author joerg; state Exp; branches 1.1.1.1; next ; commitid ow8OybrawrB1f3fx; 1.1.1.1 date 2013.11.28.14.14.47; author joerg; state Exp; branches; next 1.1.1.2; commitid ow8OybrawrB1f3fx; 1.1.1.2 date 2014.03.04.19.53.10; author joerg; state Exp; branches 1.1.1.2.2.1 1.1.1.2.4.1; next 1.1.1.3; commitid 29z1hJonZISIXprx; 1.1.1.3 date 2014.05.30.18.14.38; author joerg; state Exp; branches; next 1.1.1.4; commitid 8q0kdlBlCn09GACx; 1.1.1.4 date 2014.08.10.17.08.24; author joerg; state Exp; branches 1.1.1.4.2.1 1.1.1.4.4.1; next 1.1.1.5; commitid N85tXAN6Ex9VZPLx; 1.1.1.5 date 2015.01.29.19.57.42; author joerg; state Exp; branches; next 1.1.1.6; commitid mlISSizlPKvepX7y; 1.1.1.6 date 2016.02.27.22.10.42; author joerg; state Exp; branches 1.1.1.6.2.1; next 1.1.1.7; commitid tIimz3oDlh1NpBWy; 1.1.1.7 date 2017.01.11.10.40.48; author joerg; state Exp; branches; next 1.1.1.8; commitid CNnUNfII1jgNmxBz; 1.1.1.8 date 2017.08.01.19.38.00; author joerg; state Exp; branches 1.1.1.8.2.1 1.1.1.8.4.1; next 1.1.1.9; commitid pMuDy65V0VicSx1A; 1.1.1.9 date 2018.07.17.18.32.09; author joerg; state Exp; branches; next 1.1.1.10; commitid wDzL46ALjrCZgwKA; 1.1.1.10 date 2019.11.13.22.19.10; author joerg; state dead; branches; next ; commitid QD8YATxuNG34YJKB; 1.1.1.2.2.1 date 2014.08.10.07.08.03; author tls; state Exp; branches; next ; commitid t01A1TLTYxkpGMLx; 1.1.1.2.4.1 date 2014.03.04.19.53.10; author yamt; state dead; branches; next 1.1.1.2.4.2; commitid WSrDtL5nYAUyiyBx; 1.1.1.2.4.2 date 2014.05.22.16.18.19; author yamt; state Exp; branches; next ; commitid WSrDtL5nYAUyiyBx; 1.1.1.4.2.1 date 2015.06.04.20.04.23; author snj; state Exp; branches; next ; commitid yRnjq9fueSo6n9oy; 1.1.1.4.4.1 date 2014.08.10.17.08.24; author tls; state dead; branches; next 1.1.1.4.4.2; commitid jTnpym9Qu0o4R1Nx; 1.1.1.4.4.2 date 2014.08.19.23.47.19; author tls; state Exp; branches; next ; commitid jTnpym9Qu0o4R1Nx; 1.1.1.6.2.1 date 2017.03.20.06.52.30; author pgoyette; state Exp; branches; next ; commitid jjw7cAwgyKq7RfKz; 1.1.1.8.2.1 date 2018.07.28.04.33.07; author pgoyette; state Exp; branches; next ; commitid 1UP1xAIUxv1ZgRLA; 1.1.1.8.4.1 date 2019.06.10.21.45.09; author christos; state Exp; branches; next 1.1.1.8.4.2; commitid jtc8rnCzWiEEHGqB; 1.1.1.8.4.2 date 2020.04.13.07.46.20; author martin; state dead; branches; next ; commitid X01YhRUPVUDaec4C; desc @@ 1.1 log @Initial revision @ text @ AST Matcher Reference

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:

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 typeNameParameters
Matcher<CXXCtorInitializer>ctorInitializerMatcher<CXXCtorInitializer>...
Matches constructor initializers.

Examples matches i(42).
  class C {
    C() : i(42) {}
    int i;
  };
Matcher<Decl>accessSpecDeclMatcher<AccessSpecDecl>...
Matches C++ access specifier declarations.

Given
  class C {
  public:
    int a;
  };
accessSpecDecl()
  matches 'public:'
Matcher<Decl>classTemplateDeclMatcher<ClassTemplateDecl>...
Matches C++ class template declarations.

Example matches Z
  template<class T> class Z {};
Matcher<Decl>classTemplateSpecializationDeclMatcher<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>constructorDeclMatcher<CXXConstructorDecl>...
Matches C++ constructor declarations.

Example matches Foo::Foo() and Foo::Foo(int)
  class Foo {
   public:
    Foo();
    Foo(int);
    int DoSomething();
  };
Matcher<Decl>declMatcher<Decl>...
Matches declarations.

Examples matches X, C, and the friend declaration inside C;
  void X();
  class C {
    friend X;
  };
Matcher<Decl>declaratorDeclMatcher<DeclaratorDecl>...
Matches declarator declarations (field, variable, function
and non-type template parameter declarations).

Given
  class X { int y; };
declaratorDecl()
  matches int y.
Matcher<Decl>destructorDeclMatcher<CXXDestructorDecl>...
Matches explicit C++ destructor declarations.

Example matches Foo::~Foo()
  class Foo {
   public:
    virtual ~Foo();
  };
Matcher<Decl>enumConstantDeclMatcher<EnumConstantDecl>...
Matches enum constants.

Example matches A, B, C
  enum X {
    A, B, C
  };
Matcher<Decl>enumDeclMatcher<EnumDecl>...
Matches enum declarations.

Example matches X
  enum X {
    A, B, C
  };
Matcher<Decl>fieldDeclMatcher<FieldDecl>...
Matches field declarations.

Given
  class X { int m; };
fieldDecl()
  matches 'm'.
Matcher<Decl>friendDeclMatcher<FriendDecl>...
Matches friend declarations.

Given
  class X { friend void foo(); };
friendDecl()
  matches 'friend void foo()'.
Matcher<Decl>functionDeclMatcher<FunctionDecl>...
Matches function declarations.

Example matches f
  void f();
Matcher<Decl>functionTemplateDeclMatcher<FunctionTemplateDecl>...
Matches C++ function template declarations.

Example matches f
  template<class T> void f(T t) {}
Matcher<Decl>methodDeclMatcher<CXXMethodDecl>...
Matches method declarations.

Example matches y
  class X { void y() };
Matcher<Decl>namedDeclMatcher<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>namespaceDeclMatcher<NamespaceDecl>...
Matches a declaration of a namespace.

Given
  namespace {}
  namespace test {}
namespaceDecl()
  matches "namespace {}" and "namespace test {}"
Matcher<Decl>parmVarDeclMatcher<ParmVarDecl>...
Matches parameter variable declarations.

Given
  void f(int x);
parmVarDecl()
  matches int x.
Matcher<Decl>recordDeclMatcher<CXXRecordDecl>...
Matches C++ class declarations.

Example matches X, Z
  class X;
  template<class T> class Z {};
Matcher<Decl>unresolvedUsingValueDeclMatcher<UnresolvedUsingValueDecl>...
Matches unresolved using value declarations.

Given
  template<typename X>
  class C : private X {
    using X::x;
  };
unresolvedUsingValueDecl()
  matches using X::x 
Matcher<Decl>usingDeclMatcher<UsingDecl>...
Matches using declarations.

Given
  namespace X { int x; }
  using X::x;
usingDecl()
  matches using X::x 
Matcher<Decl>varDeclMatcher<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>nestedNameSpecifierLocMatcher<NestedNameSpecifierLoc>...
Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
Matcher<NestedNameSpecifier>nestedNameSpecifierMatcher<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>qualTypeMatcher<QualType>...
Matches QualTypes in the clang AST.
Matcher<Stmt>arraySubscriptExprMatcher<ArraySubscriptExpr>...
Matches array subscript expressions.

Given
  int i = a[1];
arraySubscriptExpr()
  matches "a[1]"
Matcher<Stmt>asmStmtMatcher<AsmStmt>...
Matches asm statements.

 int i = 100;
  __asm("mov al, 2");
asmStmt()
  matches '__asm("mov al, 2")'
Matcher<Stmt>binaryOperatorMatcher<BinaryOperator>...
Matches binary operator expressions.

Example matches a || b
  !(a || b)
Matcher<Stmt>bindTemporaryExprMatcher<CXXBindTemporaryExpr>...
Matches nodes where temporaries are created.

Example matches FunctionTakesString(GetStringByValue())
    (matcher = bindTemporaryExpr())
  FunctionTakesString(GetStringByValue());
  FunctionTakesStringByPointer(GetStringPointer());
Matcher<Stmt>boolLiteralMatcher<CXXBoolLiteralExpr>...
Matches bool literals.

Example matches true
  true
Matcher<Stmt>breakStmtMatcher<BreakStmt>...
Matches break statements.

Given
  while (true) { break; }
breakStmt()
  matches 'break'
Matcher<Stmt>cStyleCastExprMatcher<CStyleCastExpr>...
Matches a C-style cast expression.

Example: Matches (int*) 2.2f in
  int i = (int) 2.2f;
Matcher<Stmt>callExprMatcher<CallExpr>...
Matches call expressions.

Example matches x.y() and y()
  X x;
  x.y();
  y();
Matcher<Stmt>caseStmtMatcher<CaseStmt>...
Matches case statements inside switch statements.

Given
  switch(a) { case 42: break; default: break; }
caseStmt()
  matches 'case 42: break;'.
Matcher<Stmt>castExprMatcher<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>catchStmtMatcher<CXXCatchStmt>...
Matches catch statements.

  try {} catch(int i) {}
catchStmt()
  matches 'catch(int i)'
Matcher<Stmt>characterLiteralMatcher<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>compoundLiteralExprMatcher<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>compoundStmtMatcher<CompoundStmt>...
Matches compound statements.

Example matches '{}' and '{{}}'in 'for (;;) {{}}'
  for (;;) {{}}
Matcher<Stmt>conditionalOperatorMatcher<ConditionalOperator>...
Matches conditional operator expressions.

Example matches a ? b : c
  (a ? b : c) + 42
Matcher<Stmt>constCastExprMatcher<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>constructExprMatcher<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>continueStmtMatcher<ContinueStmt>...
Matches continue statements.

Given
  while (true) { continue; }
continueStmt()
  matches 'continue'
Matcher<Stmt>declRefExprMatcher<DeclRefExpr>...
Matches expressions that refer to declarations.

Example matches x in if (x)
  bool x;
  if (x) {}
Matcher<Stmt>declStmtMatcher<DeclStmt>...
Matches declaration statements.

Given
  int a;
declStmt()
  matches 'int a'.
Matcher<Stmt>defaultArgExprMatcher<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>defaultStmtMatcher<DefaultStmt>...
Matches default statements inside switch statements.

Given
  switch(a) { case 42: break; default: break; }
defaultStmt()
  matches 'default: break;'.
Matcher<Stmt>deleteExprMatcher<CXXDeleteExpr>...
Matches delete expressions.

Given
  delete X;
deleteExpr()
  matches 'delete X'.
Matcher<Stmt>doStmtMatcher<DoStmt>...
Matches do statements.

Given
  do {} while (true);
doStmt()
  matches 'do {} while(true)'
Matcher<Stmt>dynamicCastExprMatcher<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>explicitCastExprMatcher<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>exprMatcher<Expr>...
Matches expressions.

Example matches x()
  void f() { x(); }
Matcher<Stmt>floatLiteralMatcher<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>forRangeStmtMatcher<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>forStmtMatcher<ForStmt>...
Matches for statements.

Example matches 'for (;;) {}'
  for (;;) {}
  int i[] =  {1, 2, 3}; for (auto a : i);
Matcher<Stmt>functionalCastExprMatcher<CXXFunctionalCastExpr>...
Matches functional cast expressions

Example: Matches Foo(bar);
  Foo f = bar;
  Foo g = (Foo) bar;
  Foo h = Foo(bar);
Matcher<Stmt>gotoStmtMatcher<GotoStmt>...
Matches goto statements.

Given
  goto FOO;
  FOO: bar();
gotoStmt()
  matches 'goto FOO'
Matcher<Stmt>ifStmtMatcher<IfStmt>...
Matches if statements.

Example matches 'if (x) {}'
  if (x) {}
Matcher<Stmt>implicitCastExprMatcher<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>initListExprMatcher<InitListExpr>...
Matches init list expressions.

Given
  int a[] = { 1, 2 };
  struct B { int x, y; };
  B b = { 5, 6 };
initList()
  matches "{ 1, 2 }" and "{ 5, 6 }"
Matcher<Stmt>integerLiteralMatcher<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>labelStmtMatcher<LabelStmt>...
Matches label statements.

Given
  goto FOO;
  FOO: bar();
labelStmt()
  matches 'FOO:'
Matcher<Stmt>lambdaExprMatcher<LambdaExpr>...
Matches lambda expressions.

Example matches [&](){return 5;}
  [&](){return 5;}
Matcher<Stmt>materializeTemporaryExprMatcher<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>memberCallExprMatcher<CXXMemberCallExpr>...
Matches member call expressions.

Example matches x.y()
  X x;
  x.y();
Matcher<Stmt>memberExprMatcher<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>newExprMatcher<CXXNewExpr>...
Matches new expressions.

Given
  new X;
newExpr()
  matches 'new X'.
Matcher<Stmt>nullPtrLiteralExprMatcher<CXXNullPtrLiteralExpr>...
Matches nullptr literal.
Matcher<Stmt>nullStmtMatcher<NullStmt>...
Matches null statements.

  foo();;
nullStmt()
  matches the second ';'
Matcher<Stmt>operatorCallExprMatcher<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>reinterpretCastExprMatcher<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>returnStmtMatcher<ReturnStmt>...
Matches return statements.

Given
  return 1;
returnStmt()
  matches 'return 1'
Matcher<Stmt>staticCastExprMatcher<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>stmtMatcher<Stmt>...
Matches statements.

Given
  { ++a; }
stmt()
  matches both the compound statement '{ ++a; }' and '++a'.
Matcher<Stmt>stringLiteralMatcher<StringLiteral>...
Matches string literals (also matches wide string literals).

Example matches "abcd", L"abcd"
  char *s = "abcd"; wchar_t *ws = L"abcd"
Matcher<Stmt>switchCaseMatcher<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>switchStmtMatcher<SwitchStmt>...
Matches switch statements.

Given
  switch(a) { case 42: break; default: break; }
switchStmt()
  matches 'switch(a)'.
Matcher<Stmt>temporaryObjectExprMatcher<CXXTemporaryObjectExpr>...
Matches functional cast expressions having N != 1 arguments

Example: Matches Foo(bar, bar)
  Foo h = Foo(bar, bar);
Matcher<Stmt>thisExprMatcher<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>throwExprMatcher<CXXThrowExpr>...
Matches throw expressions.

  try { throw 5; } catch(int i) {}
throwExpr()
  matches 'throw 5'
Matcher<Stmt>tryStmtMatcher<CXXTryStmt>...
Matches try statements.

  try {} catch(int i) {}
tryStmt()
  matches 'try {}'
Matcher<Stmt>unaryExprOrTypeTraitExprMatcher<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>unaryOperatorMatcher<UnaryOperator>...
Matches unary operator expressions.

Example matches !a
  !a || b
Matcher<Stmt>unresolvedConstructExprMatcher<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>userDefinedLiteralMatcher<UserDefinedLiteral>...
Matches user defined literal operator call.

Example match: "foo"_suffix
Matcher<Stmt>whileStmtMatcher<WhileStmt>...
Matches while statements.

Given
  while (true) {}
whileStmt()
  matches 'while (true) {}'.
Matcher<TypeLoc>typeLocMatcher<TypeLoc>...
Matches TypeLocs in the clang AST.
Matcher<Type>arrayTypeMatcher<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>atomicTypeMatcher<AtomicType>...
Matches atomic types.

Given
  _Atomic(int) i;
atomicType()
  matches "_Atomic(int) i"
Matcher<Type>autoTypeMatcher<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>blockPointerTypeMatcher<BlockPointerType>...
Matches block pointer types, i.e. types syntactically represented as
"void (^)(int)".

The pointee is always required to be a FunctionType.
Matcher<Type>builtinTypeMatcher<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>complexTypeMatcher<ComplexType>...
Matches C99 complex types.

Given
  _Complex float f;
complexType()
  matches "_Complex float f"
Matcher<Type>constantArrayTypeMatcher<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>dependentSizedArrayTypeMatcher<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>elaboratedTypeMatcher<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>functionTypeMatcher<FunctionType>...
Matches FunctionType nodes.

Given
  int (*f)(int);
  void g();
functionType()
  matches "int (*f)(int)" and the type of "g".
Matcher<Type>incompleteArrayTypeMatcher<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>lValueReferenceTypeMatcher<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>memberPointerTypeMatcher<MemberPointerType>...
Matches member pointer types.
Given
  struct A { int i; }
  A::* ptr = A::i;
memberPointerType()
  matches "A::* ptr"
Matcher<Type>parenTypeMatcher<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>pointerTypeMatcher<PointerType>...
Matches pointer types.

Given
  int *a;
  int &b = *a;
  int c = 5;
pointerType()
  matches "int *a"
Matcher<Type>rValueReferenceTypeMatcher<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>recordTypeMatcher<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>referenceTypeMatcher<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>templateSpecializationTypeMatcher<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>typeMatcher<Type>...
Matches Types in the clang AST.
Matcher<Type>typedefTypeMatcher<TypedefType>...
Matches typedef types.

Given
  typedef int X;
typedefType()
  matches "typedef int X"
Matcher<Type>unaryTransformTypeMatcher<UnaryTransformType>...
Matches types nodes representing unary type transformations.

Given:
  typedef __underlying_type(T) type;
unaryTransformType()
  matches "__underlying_type(T)"
Matcher<Type>variableArrayTypeMatcher<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 typeNameParameters
Matcher<*>allOfMatcher<*>, ..., Matcher<*>
Matches if all given matchers match.

Usable as: Any Matcher
Matcher<*>anyOfMatcher<*>, ..., 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<*>unlessMatcher<*> InnerMatcher
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>hasOperatorNamestd::string Name
Matches the operator Name of operator expressions (binary or
unary).

Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
  !(a || b)
Matcher<CXXBoolLiteral>equalsValueT 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>argumentCountIsunsigned 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<CXXConstructorDecl>isImplicit
Matches a constructor declaration that has been implicitly added
by the compiler (eg. implicit defaultcopy constructors).
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>hasOverloadedOperatorNameStringRef 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<CXXMethodDecl>
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>isVirtual
Matches if the given method declaration is virtual.

Given
  class A {
   public:
    virtual void x();
  };
  matches A::x
Matcher<CXXOperatorCallExpr>hasOverloadedOperatorNameStringRef 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<CXXMethodDecl>
Matcher<CXXRecordDecl>isDerivedFromStringRef 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>isSameOrDerivedFromStringRef 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>argumentCountIsunsigned 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>equalsValueT 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<CompoundStmt>statementCountIsunsigned 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>hasSizeunsigned 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>declCountIsunsigned 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>equalsBoundNodestd::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>equalsNodeDecl* Other
Matches if a node equals another node.

Decl has pointer identity in the AST.
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>equalsValueT 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>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>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>parameterCountIsunsigned 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>equalsValueT 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>hasNamestd::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>matchesNamestd::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>asStringstd::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>equalsBoundNodestd::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>equalsBoundNodestd::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>equalsNodeStmt* Other
Matches if a node equals another node.

Stmt has pointer identity in the AST.

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<Type>equalsBoundNodestd::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>ofKindUnaryExprOrTypeTrait 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>hasOperatorNamestd::string Name
Matches the operator Name of operator expressions (binary or
unary).

Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
  !(a || b)
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 typeNameParameters
Matcher<*>eachOfMatcher<*>, ..., 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<*>forEachMatcher<*>
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<*>forEachDescendantMatcher<*>
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<*>hasMatcher<*>
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<*>hasAncestorMatcher<*>
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<*>hasDescendantMatcher<*>
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<*>hasParentMatcher<*>
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>hasBaseMatcher<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>hasIndexMatcher<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>hasElementTypeLocMatcher<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>hasElementTypeMatcher<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>hasValueTypeLocMatcher<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>hasValueTypeMatcher<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>hasDeducedTypeMatcher<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>hasEitherOperandMatcher<Expr> InnerMatcher
Matches if either the left hand side or the right hand side of a
binary operator matches.
Matcher<BinaryOperator>hasLHSMatcher<Expr> InnerMatcher
Matches the left hand side of binary operator expressions.

Example matches a (matcher = binaryOperator(hasLHS()))
  a || b
Matcher<BinaryOperator>hasRHSMatcher<Expr> InnerMatcher
Matches the right hand side of binary operator expressions.

Example matches b (matcher = binaryOperator(hasRHS()))
  a || b
Matcher<BlockPointerTypeLoc>pointeeLocMatcher<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>pointeeMatcher<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>hasAnyArgumentMatcher<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>hasArgumentunsigned 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>hasDeclarationMatcher<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.
FIXME: Add all node types for which this is matcher is usable due to
getDecl().

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>forEachConstructorInitializerMatcher<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>hasAnyConstructorInitializerMatcher<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>forFieldMatcher<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>withInitializerMatcher<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<CXXMemberCallExpr>onMatcher<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>onImplicitObjectArgumentMatcher<Expr> InnerMatcher
Matcher<CXXMemberCallExpr>thisPointerTypeMatcher<Decl> InnerMatcher
Overloaded to match the type's declaration.
Matcher<CXXMethodDecl>ofClassMatcher<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>hasMethodMatcher<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>isDerivedFromMatcher<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>isSameOrDerivedFromMatcher<NamedDecl> Base
Similar to isDerivedFrom(), but also matches classes that directly
match Base.
Matcher<CallExpr>calleeMatcher<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>hasAnyArgumentMatcher<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>hasArgumentunsigned 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>hasDeclarationMatcher<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.
FIXME: Add all node types for which this is matcher is usable due to
getDecl().

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>hasCaseConstantMatcher<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>hasSourceExpressionMatcher<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>hasAnyTemplateArgumentMatcher<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>hasTemplateArgumentunsigned 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>hasElementTypeLocMatcher<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>hasElementTypeMatcher<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>hasAnySubstatementMatcher<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>hasConditionMatcher<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>hasFalseExpressionMatcher<Expr> InnerMatcher
Matches the false branch expression of a conditional operator.

Example matches b
  condition ? a : b
Matcher<ConditionalOperator>hasTrueExpressionMatcher<Expr> InnerMatcher
Matches the true branch expression of a conditional operator.

Example matches a
  condition ? a : b
Matcher<DeclRefExpr>hasDeclarationMatcher<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.
FIXME: Add all node types for which this is matcher is usable due to
getDecl().

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>throughUsingDeclMatcher<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>toMatcher<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>containsDeclarationunsigned 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>hasSingleDeclMatcher<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>hasTypeLocMatcher<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>hasDeclContextMatcher<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>hasBodyMatcher<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>hasConditionMatcher<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>hasQualifierMatcher<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>namesTypeMatcher<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>hasDeclarationMatcher<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.
FIXME: Add all node types for which this is matcher is usable due to
getDecl().

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>hasDestinationTypeMatcher<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>hasTypeMatcher<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>ignoringImpCastsMatcher<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>ignoringParenCastsMatcher<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>ignoringParenImpCastsMatcher<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>hasBodyMatcher<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>hasConditionMatcher<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>hasIncrementMatcher<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>hasLoopInitMatcher<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>hasAnyParameterMatcher<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>hasParameterunsigned 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>returnsMatcher<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>hasConditionMatcher<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>hasConditionVariableStatementMatcher<DeclStmt> InnerMatcher
Matches the condition variable statement in an if statement.

Given
  if (A* a = GetAPointer()) {}
hasConditionVariableStatement(...)
  matches 'A* a = GetAPointer()'.
Matcher<ImplicitCastExpr>hasImplicitDestinationTypeMatcher<QualType> InnerMatcher
Matches implicit casts whose destination type matches a given
matcher.

FIXME: Unit test this matcher
Matcher<InjectedClassNameType>hasDeclarationMatcher<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.
FIXME: Add all node types for which this is matcher is usable due to
getDecl().

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>hasDeclarationMatcher<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.
FIXME: Add all node types for which this is matcher is usable due to
getDecl().

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>hasDeclarationMatcher<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.
FIXME: Add all node types for which this is matcher is usable due to
getDecl().

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>hasObjectExpressionMatcher<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>memberMatcher<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>pointeeLocMatcher<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>pointeeMatcher<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>hasPrefixMatcher<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>locMatcher<NestedNameSpecifier> InnerMatcher
Matches NestedNameSpecifierLocs for which the given inner
NestedNameSpecifier-matcher matches.
Matcher<NestedNameSpecifierLoc>specifiesTypeLocMatcher<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>hasPrefixMatcher<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>specifiesNamespaceMatcher<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>specifiesTypeMatcher<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>innerTypeMatcher<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>pointeeLocMatcher<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>pointeeMatcher<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>hasCanonicalTypeMatcher<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>hasDeclarationMatcher<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.
FIXME: Add all node types for which this is matcher is usable due to
getDecl().

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>pointsToMatcher<Decl> InnerMatcher
Overloaded to match the pointee type's declaration.
Matcher<QualType>referencesMatcher<Decl> InnerMatcher
Overloaded to match the referenced type's declaration.
Matcher<RecordType>hasDeclarationMatcher<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.
FIXME: Add all node types for which this is matcher is usable due to
getDecl().

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>pointeeLocMatcher<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>pointeeMatcher<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>alignOfExprMatcher<UnaryExprOrTypeTraitExpr> InnerMatcher
Same as unaryExprOrTypeTraitExpr, but only matching
alignof.
Matcher<Stmt>sizeOfExprMatcher<UnaryExprOrTypeTraitExpr> InnerMatcher
Same as unaryExprOrTypeTraitExpr, but only matching
sizeof.
Matcher<SwitchStmt>forEachSwitchCaseMatcher<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>hasDeclarationMatcher<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.
FIXME: Add all node types for which this is matcher is usable due to
getDecl().

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>refersToDeclarationMatcher<Decl> InnerMatcher
Matches a 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>refersToTypeMatcher<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>hasDeclarationMatcher<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.
FIXME: Add all node types for which this is matcher is usable due to
getDecl().

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<TemplateTypeParmType>hasDeclarationMatcher<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.
FIXME: Add all node types for which this is matcher is usable due to
getDecl().

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>findAllMatcher<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<TypeLoc>locMatcher<QualType> InnerMatcher
Matches TypeLocs for which the given inner
QualType-matcher matches.
Matcher<TypedefType>hasDeclarationMatcher<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.
FIXME: Add all node types for which this is matcher is usable due to
getDecl().

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>hasArgumentOfTypeMatcher<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>hasUnaryOperandMatcher<Expr> InnerMatcher
Matches if the operand of a unary operator matches.

Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true))))
  !true
Matcher<UnresolvedUsingType>hasDeclarationMatcher<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.
FIXME: Add all node types for which this is matcher is usable due to
getDecl().

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>hasAnyUsingShadowDeclMatcher<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>hasTargetDeclMatcher<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>hasTypeMatcher<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<VarDecl>hasInitializerMatcher<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>hasSizeExprMatcher<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>hasBodyMatcher<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>hasConditionMatcher<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) {}
@ 1.1.1.1 log @Import Clang 3.4rc1 r195771. @ text @@ 1.1.1.2 log @Import Clang 3.5svn r202566. @ text @d253 1 a253 1 class X { void y(); }; d1314 1 a1314 1 Matcher<*>unlessMatcher<*> a1354 5 Matcher<CXXConstructExpr>isListInitialization
Matches a constructor call expression which uses list initialization.
a1424 12 Matcher<CXXMethodDecl>isPure
Matches if the given method declaration is pure.

Given
  class A {
   public:
    virtual void x() = 0;
  };
  matches A::x
d2029 18 d2071 2 a2072 2 Matcher<*>forEachMatcher<*>
Matches AST nodes that have child AST nodes that match the
d2075 1
a2075 1
Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X")))
a2081 3
As opposed to 'has', 'forEach' will cause a match for each result that
matches instead of only on the first one.

a2114 15
Matcher<*>hasMatcher<*>
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
d2316 2 a2380 14 Matcher<CXXForRangeStmt>hasLoopVariableMatcher<VarDecl> InnerMatcher
Matches the initialization statement of a for loop.

Example:
    forStmt(hasLoopVariable(anything()))
matches 'int x' in
    for (int x : a) { }
Matcher<CXXMemberCallExpr>onImplicitObjectArgumentMatcher<Expr> InnerMatcher



d2392 4
a2400 6
Matcher<CXXMemberCallExpr>thisPointerTypeMatcher<QualType> InnerMatcher
Matches if the expression's type either matches the specified
matcher, or is a pointer to a type that matches the InnerMatcher.
a2468 18 Matcher<CallExpr>calleeMatcher<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.
d2509 2 d2650 2 d2816 2 a2854 11 Matcher<Expr>hasTypeMatcher<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; }
d3037 2 d3061 2 d3085 2 d3293 2 a3309 11 Matcher<QualType>pointsToMatcher<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(); }
a3314 14 Matcher<QualType>referencesMatcher<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;
  };
d3327 2 d3408 2 a3419 14 Matcher<TemplateArgument>isExprMatcher<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
d3421 1 a3421 2
Matches a canonical TemplateArgument that refers to a certain
declaration.
a3446 14
Matcher<TemplateSpecializationType>hasAnyTemplateArgumentMatcher<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>
d3459 2 a3470 14 Matcher<TemplateSpecializationType>hasTemplateArgumentunsigned 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>
d3483 2 d3528 2 d3570 2 a3622 11 Matcher<ValueDecl>hasTypeMatcher<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; }
@ 1.1.1.2.2.1 log @Rebase. @ text @a633 9 Matcher<Stmt>exprWithCleanupsMatcher<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();
d1360 6 d1601 1 a1601 1 Matcher<Decl>equalsNodeDecl *Node a1607 6 Matcher<Decl>isImplicit
Matches a declaration that has been implicitly added
by the compiler (eg. implicit defaultcopy constructors).
d1894 1 a1894 1 Matcher<Stmt>equalsNodeStmt *Node a2395 13 Matcher<CXXForRangeStmt>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', or 'do while' statement that has
a given body.

Given
  for (;;) {}
hasBody(compoundStmt())
  matches 'for (;;) {}'
with compoundStmt()
  matching '{}'
a2405 10 Matcher<CXXForRangeStmt>hasRangeInitMatcher<Expr> InnerMatcher
Matches the range initialization statement of a for loop.

Example:
    forStmt(hasRangeInit(anything()))
matches 'a' in
    for (int x : a) { }
a3070 18 Matcher<IfStmt>hasElseMatcher<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>hasThenMatcher<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;
d3216 6 d3616 6 a3780 12 Matcher<internal::BindableMatcher<NestedNameSpecifierLoc>>locMatcher<NestedNameSpecifier> InnerMatcher
Matches NestedNameSpecifierLocs for which the given inner
NestedNameSpecifier-matcher matches.
Matcher<internal::BindableMatcher<TypeLoc>>locMatcher<QualType> InnerMatcher
Matches TypeLocs for which the given inner
QualType-matcher matches.
@ 1.1.1.3 log @Import Clang 3.5svn r209886. @ text @a633 9 Matcher<Stmt>exprWithCleanupsMatcher<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();
d1360 6 d1601 1 a1601 1 Matcher<Decl>equalsNodeDecl *Node a1607 6 Matcher<Decl>isImplicit
Matches a declaration that has been implicitly added
by the compiler (eg. implicit defaultcopy constructors).
d1894 1 a1894 1 Matcher<Stmt>equalsNodeStmt *Node a2395 13 Matcher<CXXForRangeStmt>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', or 'do while' statement that has
a given body.

Given
  for (;;) {}
hasBody(compoundStmt())
  matches 'for (;;) {}'
with compoundStmt()
  matching '{}'
a2405 10 Matcher<CXXForRangeStmt>hasRangeInitMatcher<Expr> InnerMatcher
Matches the range initialization statement of a for loop.

Example:
    forStmt(hasRangeInit(anything()))
matches 'a' in
    for (int x : a) { }
a3070 18 Matcher<IfStmt>hasElseMatcher<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>hasThenMatcher<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;
d3216 6 d3616 6 a3780 12 Matcher<internal::BindableMatcher<NestedNameSpecifierLoc>>locMatcher<NestedNameSpecifier> InnerMatcher
Matches NestedNameSpecifierLocs for which the given inner
NestedNameSpecifier-matcher matches.
Matcher<internal::BindableMatcher<TypeLoc>>locMatcher<QualType> InnerMatcher
Matches TypeLocs for which the given inner
QualType-matcher matches.
@ 1.1.1.4 log @Import clang 3.6svn r215315. @ text @a321 10 Matcher<Decl>usingDirectiveDeclMatcher<UsingDirectiveDecl>...
Matches using namespace declarations.

Given
  namespace X { int x; }
  using namespace X;
usingDirectiveDecl()
  matches using namespace X 
a357 8 Matcher<Stmt>CUDAKernelCallExprMatcher<CUDAKernelCallExpr>...
Matches CUDA kernel call expression.

Example matches kernel<<<i,j>>>()
  kernel<<<i,j>>>();
d714 1 a714 1 initListExpr() a878 12 Matcher<Stmt>substNonTypeTemplateParmExprMatcher<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;"
a1271 1 } d1384 20 d1473 1 a1473 1 Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl> d1604 2 a1605 2 Matcher<Decl>hasCudaDeviceAttr
Matches declaration that has CUDA device attribute.
d1607 1
a1607 21
Given
  __attribute__((device)) void f() { ... }
matches the function declaration of f.
Matcher<Decl>hasCudaGlobalAttr
Matches declaration that has CUDA global attribute.

Given
  __attribute__((global)) void f() { ... }
matches the function declaration of f.
Matcher<Decl>hasCudaHostAttr
Matches declaration that has CUDA host attribute.

Given
  __attribute__((host)) void f() { ... }
matches the function declaration of f.
a1669 20
Matcher<FunctionDecl>hasOverloadedOperatorNameStringRef 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>
d1903 8 a1968 25 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;
d2528 1 a2528 1 void z() { Y y; y.x(); } a3425 1 } @ 1.1.1.4.2.1 log @Update LLVM to 3.6.1, requested by joerg in ticket 824. @ text @a248 10 Matcher<Decl>linkageSpecDeclMatcher<LinkageSpecDecl>...
Matches a declaration of a linkage specification.

Given
  extern "C" {}
linkageSpecDecl()
  matches "extern "C" {}"
a299 10 Matcher<Decl>typedefDeclMatcher<TypedefDecl>...
Matches typedef declarations.

Given
  typedef int X;
typedefDecl()
  matches "typedef int X"
a331 9 Matcher<Decl>valueDeclMatcher<ValueDecl>...
Matches any value declaration.

Example matches A, B, C and F
  enum X { A, B, C };
  void F();
d371 1 a371 1 Example matches, a1012 11 Matcher<TemplateArgument>templateArgumentMatcher<TemplateArgument>...
Matches template arguments.

Given
  template <typename T> struct C {};
  C<int> c;
templateArgument()
  matches 'int' in C<int>.
a1554 11 Matcher<ClassTemplateSpecializationDecl>templateArgumentCountIsunsigned 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>.
d1615 2 a1616 2 Matcher<Decl>hasAttrattr::Kind AttrKind
Matches declaration that has a given attribute.
d1620 1
a1620 2
decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
f.
d1624 2
a1625 3
Matcher<Decl>isExpansionInFileMatchingstd::string RegExp
Matches AST nodes that were expanded within files whose name is
partially matching a given regex.
d1627 3
a1629 8
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>
d1633 2
a1634 2
Matcher<Decl>isExpansionInMainFile
Matches AST nodes that were expanded within the main-file.
d1636 3
a1638 21
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>
a1647 13
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) {...}'.
a1735 11 Matcher<FunctionDecl>isDeleted
Matches deleted function declarations.

Given:
  void Func();
  void DeletedFunc() = delete;
functionDecl(isDeleted())
  matches the declaration of DeletedFunc, but not Func.
d1822 1 a1822 1 Matcher<NamedDecl>hasNamestd::string Name a1953 58 Matcher<Stmt>isExpansionInFileMatchingstd::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.
a1968 82 Matcher<TemplateArgument>equalsIntegralValuestd::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>templateArgumentCountIsunsigned 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>isExpansionInFileMatchingstd::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>
a3628 12 Matcher<TemplateArgument>refersToIntegralTypeMatcher<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>.
@ 1.1.1.5 log @Import Clang 3.6RC1 r227398. @ text @a248 10 Matcher<Decl>linkageSpecDeclMatcher<LinkageSpecDecl>...
Matches a declaration of a linkage specification.

Given
  extern "C" {}
linkageSpecDecl()
  matches "extern "C" {}"
a299 10 Matcher<Decl>typedefDeclMatcher<TypedefDecl>...
Matches typedef declarations.

Given
  typedef int X;
typedefDecl()
  matches "typedef int X"
a331 9 Matcher<Decl>valueDeclMatcher<ValueDecl>...
Matches any value declaration.

Example matches A, B, C and F
  enum X { A, B, C };
  void F();
d371 1 a371 1 Example matches, a1012 11 Matcher<TemplateArgument>templateArgumentMatcher<TemplateArgument>...
Matches template arguments.

Given
  template <typename T> struct C {};
  C<int> c;
templateArgument()
  matches 'int' in C<int>.
a1554 11 Matcher<ClassTemplateSpecializationDecl>templateArgumentCountIsunsigned 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>.
d1615 2 a1616 2 Matcher<Decl>hasAttrattr::Kind AttrKind
Matches declaration that has a given attribute.
d1620 1
a1620 2
decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
f.
d1624 2
a1625 3
Matcher<Decl>isExpansionInFileMatchingstd::string RegExp
Matches AST nodes that were expanded within files whose name is
partially matching a given regex.
d1627 3
a1629 8
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>
d1633 2
a1634 2
Matcher<Decl>isExpansionInMainFile
Matches AST nodes that were expanded within the main-file.
d1636 3
a1638 21
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>
a1647 13
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) {...}'.
a1735 11 Matcher<FunctionDecl>isDeleted
Matches deleted function declarations.

Given:
  void Func();
  void DeletedFunc() = delete;
functionDecl(isDeleted())
  matches the declaration of DeletedFunc, but not Func.
d1822 1 a1822 1 Matcher<NamedDecl>hasNamestd::string Name a1953 58 Matcher<Stmt>isExpansionInFileMatchingstd::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.
a1968 82 Matcher<TemplateArgument>equalsIntegralValuestd::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>templateArgumentCountIsunsigned 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>isExpansionInFileMatchingstd::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>
a3628 12 Matcher<TemplateArgument>refersToIntegralTypeMatcher<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>.
@ 1.1.1.6 log @Import Clang 3.8.0rc3 r261930. @ text @d103 2 a104 2 Matcher<CXXCtorInitializer>cxxCtorInitializerMatcher<CXXCtorInitializer>...
Matches constructor initializers.
d147 2
a148 2
Matcher<Decl>cxxConstructorDeclMatcher<CXXConstructorDecl>...
Matches C++ constructor declarations.
a159 36
Matcher<Decl>cxxConversionDeclMatcher<CXXConversionDecl>...
Matches conversion operator declarations.

Example matches the operator.
  class X { operator int() const; };
Matcher<Decl>cxxDestructorDeclMatcher<CXXDestructorDecl>...
Matches explicit C++ destructor declarations.

Example matches Foo::~Foo()
  class Foo {
   public:
    virtual ~Foo();
  };
Matcher<Decl>cxxMethodDeclMatcher<CXXMethodDecl>...
Matches method declarations.

Example matches y
  class X { void y(); };
Matcher<Decl>cxxRecordDeclMatcher<CXXRecordDecl>...
Matches C++ class declarations.

Example matches X, Z
  class X;
  template<class T> class Z {};
d182 11 d259 8 a279 11 Matcher<Decl>namespaceAliasDeclMatcher<NamespaceAliasDecl>...
Matches a declaration of a namespace alias.

Given
  namespace test {}
  namespace alias = ::test;
namespaceAliasDecl()
  matches "namespace alias" but not "namespace test"
a290 19 Matcher<Decl>nonTypeTemplateParmDeclMatcher<NonTypeTemplateParmDecl>...
Matches non-type template parameter declarations.

Given
  template <typename T, int N> struct C {};
nonTypeTemplateParmDecl()
  matches 'N', but not 'T'.
Matcher<Decl>objcInterfaceDeclMatcher<ObjCInterfaceDecl>...
Matches Objective-C interface declarations.

Example matches Foo
  @@interface Foo
  @@end
d301 2 a302 2 Matcher<Decl>recordDeclMatcher<RecordDecl>...
Matches class, struct, and union declarations.
d304 1
a304 1
Example matches X, Z, U, and S
a306 40
  struct S {};
  union U {};
Matcher<Decl>staticAssertDeclMatcher<StaticAssertDecl>...
Matches a C++ static_assert declaration.

Example:
  staticAssertExpr()
matches
  static_assert(sizeof(S) == sizeof(int))
in
  struct S {
    int x;
  };
  static_assert(sizeof(S) == sizeof(int));
Matcher<Decl>templateTypeParmDeclMatcher<TemplateTypeParmDecl>...
Matches template type parameter declarations.

Given
  template <typename T, int N> struct C {};
templateTypeParmDecl()
  matches 'T', but not 'N'.
Matcher<Decl>translationUnitDeclMatcher<TranslationUnitDecl>...
Matches the top declaration context.

Given
  int X;
  namespace NS {
  int Y;
  }  namespace NS
decl(hasDeclContext(translationUnitDecl()))
  matches "int X", but not "int Y".
a319 16
Matcher<Decl>unresolvedUsingTypenameDeclMatcher<UnresolvedUsingTypenameDecl>...
Matches unresolved using value declarations that involve the
typename.

Given
  template <typename T>
  struct Base { typedef T Foo; };

  template<typename T>
  struct S : private Base<T> {
    using typename Base<T>::Foo;
  };
unresolvedUsingTypenameDecl()
  matches using Base<T>::Foo 
d397 8 d433 18 d502 9 d546 2 a547 47 Matcher<Stmt>continueStmtMatcher<ContinueStmt>...
Matches continue statements.

Given
  while (true) { continue; }
continueStmt()
  matches 'continue'
Matcher<Stmt>cudaKernelCallExprMatcher<CUDAKernelCallExpr>...
Matches CUDA kernel call expression.

Example matches,
  kernel<<<i,j>>>();
Matcher<Stmt>cxxBindTemporaryExprMatcher<CXXBindTemporaryExpr>...
Matches nodes where temporaries are created.

Example matches FunctionTakesString(GetStringByValue())
    (matcher = cxxBindTemporaryExpr())
  FunctionTakesString(GetStringByValue());
  FunctionTakesStringByPointer(GetStringPointer());
Matcher<Stmt>cxxBoolLiteralMatcher<CXXBoolLiteralExpr>...
Matches bool literals.

Example matches true
  true
Matcher<Stmt>cxxCatchStmtMatcher<CXXCatchStmt>...
Matches catch statements.

  try {} catch(int i) {}
cxxCatchStmt()
  matches 'catch(int i)'
Matcher<Stmt>cxxConstCastExprMatcher<CXXConstCastExpr>...
Matches a const_cast expression.
d556 2
a557 2
Matcher<Stmt>cxxConstructExprMatcher<CXXConstructExpr>...
Matches constructor call expressions (including implicit ones).
d560 1
a560 1
    (matcher = cxxConstructExpr())
d568 2
a569 13
Matcher<Stmt>cxxDefaultArgExprMatcher<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 = cxxDefaultArgExpr())
  void f(int x, int y = 0);
  f(42);
Matcher<Stmt>cxxDeleteExprMatcher<CXXDeleteExpr>...
Matches delete expressions.
d572 3
a574 151
  delete X;
cxxDeleteExpr()
  matches 'delete X'.
Matcher<Stmt>cxxDynamicCastExprMatcher<CXXDynamicCastExpr>...
Matches a dynamic_cast expression.

Example:
  cxxDynamicCastExpr()
matches
  dynamic_cast<D*>(&b);
in
  struct B { virtual ~B() {} }; struct D : B {};
  B b;
  D* p = dynamic_cast<D*>(&b);
Matcher<Stmt>cxxForRangeStmtMatcher<CXXForRangeStmt>...
Matches range-based for statements.

cxxForRangeStmt() matches 'for (auto a : i)'
  int i[] =  {1, 2, 3}; for (auto a : i);
  for(int j = 0; j < 5; ++j);
Matcher<Stmt>cxxFunctionalCastExprMatcher<CXXFunctionalCastExpr>...
Matches functional cast expressions

Example: Matches Foo(bar);
  Foo f = bar;
  Foo g = (Foo) bar;
  Foo h = Foo(bar);
Matcher<Stmt>cxxMemberCallExprMatcher<CXXMemberCallExpr>...
Matches member call expressions.

Example matches x.y()
  X x;
  x.y();
Matcher<Stmt>cxxNewExprMatcher<CXXNewExpr>...
Matches new expressions.

Given
  new X;
cxxNewExpr()
  matches 'new X'.
Matcher<Stmt>cxxNullPtrLiteralExprMatcher<CXXNullPtrLiteralExpr>...
Matches nullptr literal.
Matcher<Stmt>cxxOperatorCallExprMatcher<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 = cxxOperatorCallExpr())
  ostream &operator<< (ostream &out, int i) { };
  ostream &o; int b = 1, c = 1;
  o << b << c;
Matcher<Stmt>cxxReinterpretCastExprMatcher<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>cxxStaticCastExprMatcher<CXXStaticCastExpr>...
Matches a C++ static_cast expression.

hasDestinationType
reinterpretCast

Example:
  cxxStaticCastExpr()
matches
  static_cast<long>(8)
in
  long eight(static_cast<long>(8));
Matcher<Stmt>cxxTemporaryObjectExprMatcher<CXXTemporaryObjectExpr>...
Matches functional cast expressions having N != 1 arguments

Example: Matches Foo(bar, bar)
  Foo h = Foo(bar, bar);
Matcher<Stmt>cxxThisExprMatcher<CXXThisExpr>...
Matches implicit and explicit this expressions.

Example matches the implicit this expression in "return i".
    (matcher = cxxThisExpr())
struct foo {
  int i;
  int f() { return i; }
};
Matcher<Stmt>cxxThrowExprMatcher<CXXThrowExpr>...
Matches throw expressions.

  try { throw 5; } catch(int i) {}
cxxThrowExpr()
  matches 'throw 5'
Matcher<Stmt>cxxTryStmtMatcher<CXXTryStmt>...
Matches try statements.

  try {} catch(int i) {}
cxxTryStmt()
  matches 'try {}'
Matcher<Stmt>cxxUnresolvedConstructExprMatcher<CXXUnresolvedConstructExpr>...
Matches unresolved constructor call expressions.

Example matches T(t) in return statement of f
    (matcher = cxxUnresolvedConstructExpr())
  template <typename T>
  void f(const T& t) { return T(t); }
d597 11
d618 10
d638 14
d699 9
d717 7
a723 2
Matcher<Stmt>gnuNullExprMatcher<GNUNullExpr>...
Matches GNU __null expression.
d809 9
d831 15
d855 2
a856 2
Matcher<Stmt>objcMessageExprMatcher<ObjCMessageExpr>...
Matches ObjectiveC Message invocation expressions.
d858 22
a879 5
The innermost message send invokes the "alloc" class method on the
NSString class, while the outermost message send invokes the
"initWithString" instance method on the object returned from
NSString's "alloc". This matcher should match both message sends.
  [[NSString alloc] initWithString:@@"Hello"]
d893 15
d958 38
d1015 10
a1137 12
Matcher<Type>decayedTypeMatcher<DecayedType>...
Matches decayed type
Example matches i[] in declaration of f.
    (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())))))
Example matches i[1].
    (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())))))
  void f(int i[]) {
    i[1] = 0;
  }
a1193 12 Matcher<Type>injectedClassNameTypeMatcher<InjectedClassNameType>...
Matches injected class name types.

Example matches S s, but not S<T> s.
    (matcher = parmVarDecl(hasType(injectedClassNameType())))
  template <typename T> struct S {
    void f(S s);
    void g(S<T> s);
  };
a1220 15 Matcher<Type>objcObjectPointerTypeMatcher<ObjCObjectPointerType>...
Matches an Objective-C object pointer type, which is different from
a pointer type, despite being syntactically similar.

Given
  int *a;

  @@interface Foo
  @@end
  Foo *f;
pointerType()
  matches "Foo *f", but does not match "int *a".
d1234 1 a1234 2
Matches pointer types, but does not match Objective-C object pointer
types.
a1239 4

  @@interface Foo
  @@end
  Foo *f;
d1241 1
a1241 1
  matches "int *a", but does not match "Foo *f".
a1292 14
Matcher<Type>substTemplateTypeParmTypeMatcher<SubstTemplateTypeParmType>...
Matches types that represent the result of substituting a type for a
template type parameter.

Given
  template <typename T>
  void F(T t) {
    int i = 1 + t;
  }

substTemplateTypeParmType() matches the type of 't' but not '1'
a1307 9 Matcher<Type>templateTypeParmTypeMatcher<TemplateTypeParmType>...
Matches template type parameter types.

Example matches T, but not int.
    (matcher = templateTypeParmType())
  template <typename T> void f(int i);
d1397 1 a1397 1 Example matches Y (matcher = cxxRecordDecl(unless(hasName("X")))) d1417 1 a1417 1 Example matches true (matcher = cxxBoolLiteral(equals(true))) a1424 16 Matcher<CXXCatchStmt>isCatchAll
Matches a C++ catch statement that has a catch-all handler.

Given
  try {
    ...
  } catch (int) {
    ...
  } catch (...) {
    ...
  }
endcode
cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
d1435 2 a1436 109 Matcher<CXXConstructExpr>isListInitialization
Matches a constructor call expression which uses list initialization.
Matcher<CXXConstructorDecl>isCopyConstructor
Matches constructor declarations that are copy constructors.

Given
  struct S {
    S(); #1
    S(const S &); #2
    S(S &&); #3
  };
cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.
Matcher<CXXConstructorDecl>isDefaultConstructor
Matches constructor declarations that are default constructors.

Given
  struct S {
    S(); #1
    S(const S &); #2
    S(S &&); #3
  };
cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.
Matcher<CXXConstructorDecl>isExplicit
Matches constructor and conversion declarations that are marked with
the explicit keyword.

Given
  struct S {
    S(int); #1
    explicit S(double); #2
    operator int(); #3
    explicit operator bool(); #4
  };
cxxConstructorDecl(isExplicit()) will match #2, but not #1.
cxxConversionDecl(isExplicit()) will match #4, but not #3.
Matcher<CXXConstructorDecl>isMoveConstructor
Matches constructor declarations that are move constructors.

Given
  struct S {
    S(); #1
    S(const S &); #2
    S(S &&); #3
  };
cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.
Matcher<CXXConversionDecl>isExplicit
Matches constructor and conversion declarations that are marked with
the explicit keyword.

Given
  struct S {
    S(int); #1
    explicit S(double); #2
    operator int(); #3
    explicit operator bool(); #4
  };
cxxConstructorDecl(isExplicit()) will match #2, but not #1.
cxxConversionDecl(isExplicit()) will match #4, but not #3.
Matcher<CXXCtorInitializer>isBaseInitializer
Matches a constructor initializer if it is initializing a base, as
opposed to a member.

Given
  struct B {};
  struct D : B {
    int I;
    D(int i) : I(i) {}
  };
  struct E : B {
    E() : B() {}
  };
cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
  will match E(), but not match D(int).
Matcher<CXXCtorInitializer>isMemberInitializer
Matches a constructor initializer if it is initializing a member, as
opposed to a base.

Given
  struct B {};
  struct D : B {
    int I;
    D(int i) : I(i) {}
  };
  struct E : B {
    E() : B() {}
  };
cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
  will match D(int), but not match E().
d1450 1
a1450 1
cxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
d1464 1
a1464 33
cxxMethodDecl(isConst()) matches A::foo() but not A::bar()
Matcher<CXXMethodDecl>isCopyAssignmentOperator
Matches if the given method declaration declares a copy assignment
operator.

Given
struct A {
  A &operator=(const A &);
  A &operator=(A &&);
};

cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not
the second one.
Matcher<CXXMethodDecl>isFinal
Matches if the given method or class declaration is final.

Given:
  class A final {};

  struct B {
    virtual void f();
  };

  struct C : B {
    void f() final;
  };
matches A and C::f, but not B, C, or B::f
d1520 3
a1522 4
cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the
specified line and
cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
matches the declaration of A.
d1528 1
a1528 1
Matcher<CXXRecordDecl>isDerivedFromstd::string BaseName
d1547 1
a1547 18
Matcher<CXXRecordDecl>isFinal
Matches if the given method or class declaration is final.

Given:
  class A final {};

  struct B {
    virtual void f();
  };

  struct C : B {
    void f() final;
  };
matches A and C::f, but not B, C, or B::f
Matcher<CXXRecordDecl>isSameOrDerivedFromstd::string BaseName d1561 1 a1561 1 cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) d1567 1 a1567 1 cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) d1587 1 a1587 1 Example matches true (matcher = cxxBoolLiteral(equals(true))) d1650 1 a1650 1 cxxRecordDecl( d1672 1 a1672 2 f. If the matcher is use from clang-query, attr::Kind parameter should be passed as a quoted string. e.g., hasAttr("attr::CUDADevice"). d1681 1 a1681 1 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) d1694 1 a1694 2 Example matches X but not Y (matcher = cxxRecordDecl(isExpansionInMainFile()) d1708 1 a1708 1 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) d1724 13 d1782 1 a1782 1 Example matches true (matcher = cxxBoolLiteral(equals(true))) d1802 3 a1804 4 cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified line and cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches the declaration of A. a1809 13 Matcher<FunctionDecl>isConstexpr
Matches constexpr variable and function declarations.

Given:
  constexpr int foo = 42;
  constexpr int bar();
varDecl(isConstexpr())
  matches the declaration of foo.
functionDecl(isConstexpr())
  matches the declaration of bar.
a1861 29 Matcher<FunctionDecl>isInline
Matches function and namespace declarations that are marked with
the inline keyword.

Given
  inline void f();
  void g();
  namespace n {
  inline namespace m {}
  }
functionDecl(isInline()) will match ::f().
namespaceDecl(isInline()) will match n::m.
Matcher<FunctionDecl>isNoThrow
Matches functions that have a non-throwing exception specification.

Given:
  void f();
  void g() noexcept;
  void h() throw();
  void i() throw(int);
  void j() noexcept(false);
functionDecl(isNoThrow())
  matches the declarations of g, and h, but not f, i or j.
d1870 1 a1870 1 cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) d1876 1 a1876 1 cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) a1882 12 Matcher<FunctionDecl>isVariadic
Matches if a function declaration is variadic.

Example matches f, but not g or h. The function i will not match, even when
compiled in C mode.
  void f(...);
  void g(int);
  template <typename... Ts> void h(Ts...);
  void i();
d1897 1 a1897 1 Example matches true (matcher = cxxBoolLiteral(equals(true))) a1952 100 Matcher<NamespaceDecl>isAnonymous
Matches anonymous namespace declarations.

Given
  namespace n {
  namespace {} #1
  }
namespaceDecl(isAnonymous()) will match #1 but not ::n.
Matcher<NamespaceDecl>isInline
Matches function and namespace declarations that are marked with
the inline keyword.

Given
  inline void f();
  void g();
  namespace n {
  inline namespace m {}
  }
functionDecl(isInline()) will match ::f().
namespaceDecl(isInline()) will match n::m.
Matcher<ObjCMessageExpr>argumentCountIsunsigned 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<ObjCMessageExpr>hasKeywordSelector
Matches when the selector is a keyword selector

objCMessageExpr(hasKeywordSelector()) matches the generated setFrame
message expression in

  UIWebView *webView = ...;
  CGRect bodyFrame = webView.frame;
  bodyFrame.size.height = self.bodyContentHeight;
  webView.frame = bodyFrame;
      ^---- matches here
Matcher<ObjCMessageExpr>hasNullSelector
Matches when the selector is the empty selector

Matches only when the selector of the objCMessageExpr is NULL. This may
represent an error condition in the tree!
Matcher<ObjCMessageExpr>hasSelectorstd::string BaseName
Matches when BaseName == Selector.getAsString()

 matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:"));
 matches the outer message expr in the code below, but NOT the message
 invocation for self.bodyView.
    [self.bodyView loadHTMLString:html baseURL:NULL];
Matcher<ObjCMessageExpr>hasUnarySelector
Matches when the selector is a Unary Selector

 matcher = objCMessageExpr(matchesSelector(hasUnarySelector());
 matches self.bodyView in the code below, but NOT the outer message
 invocation of "loadHTMLString:baseURL:".
    [self.bodyView loadHTMLString:html baseURL:NULL];
Matcher<ObjCMessageExpr>matchesSelectorstd::string RegExp
Matches ObjC selectors whose name contains
a substring matched by the given RegExp.
 matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message
 invocation for self.bodyView.
    [self.bodyView loadHTMLString:html baseURL:NULL];
Matcher<ObjCMessageExpr>numSelectorArgsunsigned N
Matches when the selector has the specified number of arguments

 matcher = objCMessageExpr(numSelectorArgs(0));
 matches self.bodyView in the code below

 matcher = objCMessageExpr(numSelectorArgs(2));
 matches the invocation of "loadHTMLString:baseURL:" but not that
 of self.bodyView
    [self.bodyView loadHTMLString:html baseURL:NULL];
d1959 1 a1959 1 cxxMemberCallExpr(on(hasType(asString("class Y *")))) d1971 1 a1971 1 cxxRecordDecl( a2001 12 Matcher<QualType>isAnyCharacter
Matches QualType nodes that are of character type.

Given
  void a(char);
  void b(wchar_t);
  void c(double);
functionDecl(hasAnyParameter(hasType(isAnyCharacter())))
matches "a(char)", "b(wchar_t)", but not "c(double)".
a2030 47 Matcher<QualType>isVolatileQualified
Matches QualType nodes that are volatile-qualified, i.e., that
include "top-level" volatile.

Given
  void a(int);
  void b(int volatile);
  void c(volatile int);
  void d(volatile int*);
  void e(int volatile) {};
functionDecl(hasAnyParameter(hasType(isVolatileQualified())))
  matches "void b(int volatile)", "void c(volatile int)" and
  "void e(int volatile) {}". It does not match d as there
  is no top-level volatile on the parameter type "volatile int *".
Matcher<RecordDecl>isClass
Matches RecordDecl object that are spelled with "class."

Example matches C, but not S or U.
  struct S {};
  class C {};
  union U {};
Matcher<RecordDecl>isStruct
Matches RecordDecl object that are spelled with "struct."

Example matches S, but not C or U.
  struct S {};
  class C {};
  union U {};
Matcher<RecordDecl>isUnion
Matches RecordDecl object that are spelled with "union."

Example matches U, but not C or S.
  struct S {};
  class C {};
  union U {};
d2038 1 a2038 1 cxxRecordDecl( d2059 1 a2059 1 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) d2072 1 a2072 2 Example matches X but not Y (matcher = cxxRecordDecl(isExpansionInMainFile()) d2086 1 a2086 1 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) d2096 16 d2172 1 a2172 1 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) d2185 1 a2185 2 Example matches X but not Y (matcher = cxxRecordDecl(isExpansionInMainFile()) d2199 1 a2199 1 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) a2208 10 Matcher<Type>booleanType
Matches type bool.

Given
 struct S { bool func(); };
functionDecl(returns(booleanType()))
  matches "bool func();"
d2216 1 a2216 1 cxxRecordDecl( a2231 10 Matcher<Type>voidType
Matches type void.

Given
 struct S { void func(); };
functionDecl(returns(voidType()))
  matches "void func();"
a2251 14 Matcher<VarDecl>hasAutomaticStorageDuration
Matches a variable declaration that has automatic storage duration.

Example matches x, but not y, z, or a.
(matcher = varDecl(hasAutomaticStorageDuration())
void f() {
  int x;
  static int y;
  thread_local int z;
}
int a;
a2276 41 Matcher<VarDecl>hasStaticStorageDuration
Matches a variable declaration that has static storage duration.

Example matches y and a, but not x or z.
(matcher = varDecl(hasStaticStorageDuration())
void f() {
  int x;
  static int y;
  thread_local int z;
}
int a;
Matcher<VarDecl>hasThreadStorageDuration
Matches a variable declaration that has thread storage duration.

Example matches z, but not x, z, or a.
(matcher = varDecl(hasThreadStorageDuration())
void f() {
  int x;
  static int y;
  thread_local int z;
}
int a;
Matcher<VarDecl>isConstexpr
Matches constexpr variable and function declarations.

Given:
  constexpr int foo = 42;
  constexpr int bar();
varDecl(isConstexpr())
  matches the declaration of foo.
functionDecl(isConstexpr())
  matches the declaration of bar.
a2291 13 Matcher<VarDecl>isExceptionVariable
Matches a variable declaration that is an exception variable from
a C++ catch block, or an Objective-C statement.

Example matches x (matcher = varDecl(isExceptionVariable())
void f(int y) {
  try {
  } catch (int x) {
  }
}
d2314 1 a2314 1 cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) d2320 1 a2320 1 cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) a2325 29 Matcher<internal::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<internal::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.
d2353 2 a2354 2 cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), has(fieldDecl(hasName("b")).bind("v")))) d2368 1 a2368 1 (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X"))))) d2379 1 a2379 3 cxxRecordDecl(forEachDescendant(cxxRecordDecl( forEachDescendant(cxxRecordDecl()) ))) d2391 1 a2391 2 Example matches X, Y (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X"))) d2423 1 a2423 1 (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X"))))) d2438 1 a2438 2 Example matches X, Y (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X"))) a2483 16 Matcher<ArraySubscriptExpr>hasLHSMatcher<Expr> InnerMatcher
Matches the left hand side of binary operator expressions.

Example matches a (matcher = binaryOperator(hasLHS()))
  a || b
Matcher<ArraySubscriptExpr>hasRHSMatcher<Expr> InnerMatcher
Matches the right hand side of binary operator expressions.

Example matches b (matcher = binaryOperator(hasRHS()))
  a || b
d2665 1 a2665 3 cxxConstructorDecl(forEachConstructorInitializer( forField(decl().bind("x")) )) d2678 1 a2678 3 cxxRecordDecl(has(cxxConstructorDecl( hasAnyConstructorInitializer(anything()) ))) d2691 1 a2691 1 cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( d2706 1 a2706 1 cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( d2753 1 a2753 2 Example matches y.x() (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")))))) d2781 1 a2781 1 (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl( d2798 2 a2799 2 cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of A but not B. d2834 1 a2834 2 Example matches y.x() (matcher = callExpr(callee( cxxMethodDecl(hasName("x"))))) d2923 1 a2923 1 hasSourceExpression(cxxConstructExpr())) d3004 1 a3004 1 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) a3024 5 Matcher<DecayedType>hasDecayedTypeMatcher<QualType> InnerType
Matches the decayed type, whos decayed type matches InnerMatcher
d3051 2 d3060 1 a3060 1 declRefExpr(throughUsingDecl(anything())) d3128 1 a3128 1 cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the d3150 1 a3150 1 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) d3225 3 a3227 3 declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the declaration of x. d3229 2 a3230 2 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) d3242 2 a3243 2 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) d3331 1 a3331 1 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) d3363 1 a3363 1 cxxMethodDecl(hasAnyParameter(hasName("y"))) d3375 1 a3375 1 cxxMethodDecl(hasParameter(0, hasType(varDecl()))) d3387 1 a3387 1 cxxMethodDecl(returns(asString("int"))) d3396 1 a3396 1 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) d3415 1 a3415 1 (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true))))) d3424 1 a3424 1 (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true))))) d3510 1 a3510 1 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))))) d3582 1 a3582 1 hasDeclaration(cxxRecordDecl(hasName("A"))))))) d3617 1 a3617 3 nestedNameSpecifier(specifiesType( hasDeclaration(cxxRecordDecl(hasName("A"))) )) a3621 22 Matcher<ObjCMessageExpr>hasArgumentunsigned 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<ObjCMessageExpr>hasReceiverTypeMatcher<QualType> InnerMatcher
Matches on the receiver of an ObjectiveC Message expression.

Example
matcher = objCMessageExpr(hasRecieverType(asString("UIWebView *")));
matches the [webView ...] message invocation.
  NSString *webViewJavaScript = ...
  UIWebView *webView = ...
  [webView stringByEvaluatingJavaScriptFromString:webViewJavascript];
d3713 1 a3713 2 (matcher = cxxMemberCallExpr(on(hasType(pointsTo cxxRecordDecl(hasName("Y"))))))) d3729 1 a3729 1 (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X")))))) d3974 1 a3974 2 cxxRecordDecl(hasName("::A"), findAll(cxxRecordDecl(isDefinition()).bind("m"))) d4016 1 a4016 2 Example matches true (matcher = hasUnaryOperand( cxxBoolLiteral(equals(true)))) d4071 3 a4073 3 declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the declaration of x. d4075 2 a4076 2 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) d4088 2 a4089 2 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) d4136 1 a4136 1 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) @ 1.1.1.6.2.1 log @Sync with HEAD @ text @d103 1 a103 1 Matcher<CXXCtorInitializer>cxxCtorInitializerMatcher<CXXCtorInitializer>... d114 1 a114 1 Matcher<Decl>accessSpecDeclMatcher<AccessSpecDecl>... d127 1 a127 1 Matcher<Decl>classTemplateDeclMatcher<ClassTemplateDecl>... d135 1 a135 1 Matcher<Decl>classTemplateSpecializationDeclMatcher<ClassTemplateSpecializationDecl>... d147 1 a147 1 Matcher<Decl>cxxConstructorDeclMatcher<CXXConstructorDecl>... d160 1 a160 1 Matcher<Decl>cxxConversionDeclMatcher<CXXConversionDecl>... d168 1 a168 1 Matcher<Decl>cxxDestructorDeclMatcher<CXXDestructorDecl>... d179 1 a179 1 Matcher<Decl>cxxMethodDeclMatcher<CXXMethodDecl>... d187 1 a187 1 Matcher<Decl>cxxRecordDeclMatcher<CXXRecordDecl>... d196 1 a196 1 Matcher<Decl>declMatcher<Decl>... d207 1 a207 1 Matcher<Decl>declaratorDeclMatcher<DeclaratorDecl>... d218 1 a218 1 Matcher<Decl>enumConstantDeclMatcher<EnumConstantDecl>... d228 1 a228 1 Matcher<Decl>enumDeclMatcher<EnumDecl>... d238 1 a238 1 Matcher<Decl>fieldDeclMatcher<FieldDecl>... d248 1 a248 1 Matcher<Decl>friendDeclMatcher<FriendDecl>... d258 1 a258 1 Matcher<Decl>functionDeclMatcher<FunctionDecl>... d266 1 a266 1 Matcher<Decl>functionTemplateDeclMatcher<FunctionTemplateDecl>... d274 1 a274 12 Matcher<Decl>labelDeclMatcher<LabelDecl>...
Matches a declaration of label.

Given
  goto FOO;
  FOO: bar();
labelDecl()
  matches 'FOO:'
Matcher<Decl>linkageSpecDeclMatcher<LinkageSpecDecl>... d284 1 a284 1 Matcher<Decl>namedDeclMatcher<NamedDecl>... d297 1 a297 1 Matcher<Decl>namespaceAliasDeclMatcher<NamespaceAliasDecl>... d308 1 a308 1 Matcher<Decl>namespaceDeclMatcher<NamespaceDecl>... d319 1 a319 1 Matcher<Decl>nonTypeTemplateParmDeclMatcher<NonTypeTemplateParmDecl>... d329 1 a329 1 Matcher<Decl>objcInterfaceDeclMatcher<ObjCInterfaceDecl>... d338 1 a338 1 Matcher<Decl>parmVarDeclMatcher<ParmVarDecl>... d348 1 a348 1 Matcher<Decl>recordDeclMatcher<RecordDecl>... d359 1 a359 1 Matcher<Decl>staticAssertDeclMatcher<StaticAssertDecl>... d374 1 a374 1 Matcher<Decl>templateTypeParmDeclMatcher<TemplateTypeParmDecl>... d384 1 a384 1 Matcher<Decl>translationUnitDeclMatcher<TranslationUnitDecl>... d397 1 a397 12 Matcher<Decl>typeAliasDeclMatcher<TypeAliasDecl>...
Matches type alias declarations.

Given
  typedef int X;
  using Y = int;
typeAliasDecl()
  matches "using Y = int", but not "typedef int X"
Matcher<Decl>typedefDeclMatcher<TypedefDecl>... a401 1 using Y = int; d403 1 a403 12 matches "typedef int X", but not "using Y = int"
Matcher<Decl>typedefNameDeclMatcher<TypedefNameDecl>...
Matches typedef name declarations.

Given
  typedef int X;
  using Y = int;
typedefNameDecl()
  matches "typedef int X" and "using Y = int"
d407 1
a407 1
Matcher<Decl>unresolvedUsingTypenameDeclMatcher<UnresolvedUsingTypenameDecl>...
d423 1
a423 1
Matcher<Decl>unresolvedUsingValueDeclMatcher<UnresolvedUsingValueDecl>...
d435 1
a435 1
Matcher<Decl>usingDeclMatcher<UsingDecl>...
d445 1
a445 1
Matcher<Decl>usingDirectiveDeclMatcher<UsingDirectiveDecl>...
d455 1
a455 1
Matcher<Decl>valueDeclMatcher<ValueDecl>...
d464 1
a464 1
Matcher<Decl>varDeclMatcher<VarDecl>...
d475 1
a475 1
Matcher<NestedNameSpecifierLoc>nestedNameSpecifierLocMatcher<NestedNameSpecifierLoc>...
d480 1
a480 1
Matcher<NestedNameSpecifier>nestedNameSpecifierMatcher<NestedNameSpecifier>...
d495 1
a495 1
Matcher<QualType>qualTypeMatcher<QualType>...
d500 1
a500 13
Matcher<Stmt>addrLabelExprMatcher<AddrLabelExpr>...
Matches address of label statements (GNU extension).

Given
  FOO: bar();
  void *ptr = &&FOO;
  goto *bar;
addrLabelExpr()
  matches '&&FOO'
Matcher<Stmt>arraySubscriptExprMatcher<ArraySubscriptExpr>... d510 1 a510 1 Matcher<Stmt>asmStmtMatcher<AsmStmt>... d520 1 a520 16 Matcher<Stmt>atomicExprMatcher<AtomicExpr>...
Matches atomic builtins.
Example matches __atomic_load_n(ptr, 1)
  void foo() { int *ptr; __atomic_load_n(ptr, 1); }
Matcher<Stmt>binaryConditionalOperatorMatcher<BinaryConditionalOperator>...
Matches binary conditional operator expressions (GNU extension).

Example matches a ?: b
  (a ?: b) + 42;
Matcher<Stmt>binaryOperatorMatcher<BinaryOperator>... d528 1 a528 1 Matcher<Stmt>breakStmtMatcher<BreakStmt>... d538 1 a538 1 Matcher<Stmt>cStyleCastExprMatcher<CStyleCastExpr>... d541 1 a541 1 Example: Matches (int) 2.2f in d546 1 a546 1 Matcher<Stmt>callExprMatcher<CallExpr>... d556 1 a556 1 Matcher<Stmt>caseStmtMatcher<CaseStmt>... d566 1 a566 1 Matcher<Stmt>castExprMatcher<CastExpr>... d579 1 a579 1 Matcher<Stmt>characterLiteralMatcher<CharacterLiteral>... d586 1 a586 2 char ch = 'a'; wchar_t chw = L'a'; d590 1 a590 1 Matcher<Stmt>compoundLiteralExprMatcher<CompoundLiteralExpr>... d594 1 a594 2 int array[4] = {1}; vector int myvec = (vector int)(1, 2); d598 1 a598 1 Matcher<Stmt>compoundStmtMatcher<CompoundStmt>... d606 1 a606 1 Matcher<Stmt>conditionalOperatorMatcher<ConditionalOperator>... d614 1 a614 1 Matcher<Stmt>continueStmtMatcher<ContinueStmt>... d624 1 a624 1 Matcher<Stmt>cudaKernelCallExprMatcher<CUDAKernelCallExpr>... d632 1 a632 1 Matcher<Stmt>cxxBindTemporaryExprMatcher<CXXBindTemporaryExpr>... d642 1 a642 1 Matcher<Stmt>cxxBoolLiteralMatcher<CXXBoolLiteralExpr>... d650 1 a650 1 Matcher<Stmt>cxxCatchStmtMatcher<CXXCatchStmt>... d659 1 a659 1 Matcher<Stmt>cxxConstCastExprMatcher<CXXConstCastExpr>... d669 1 a669 1 Matcher<Stmt>cxxConstructExprMatcher<CXXConstructExpr>... d681 1 a681 1 Matcher<Stmt>cxxDefaultArgExprMatcher<CXXDefaultArgExpr>... d692 1 a692 1 Matcher<Stmt>cxxDeleteExprMatcher<CXXDeleteExpr>... d702 1 a702 1 Matcher<Stmt>cxxDynamicCastExprMatcher<CXXDynamicCastExpr>... d716 1 a716 1 Matcher<Stmt>cxxForRangeStmtMatcher<CXXForRangeStmt>... d725 1 a725 1 Matcher<Stmt>cxxFunctionalCastExprMatcher<CXXFunctionalCastExpr>... d735 1 a735 1 Matcher<Stmt>cxxMemberCallExprMatcher<CXXMemberCallExpr>... d744 1 a744 1 Matcher<Stmt>cxxNewExprMatcher<CXXNewExpr>... d754 1 a754 1 Matcher<Stmt>cxxNullPtrLiteralExprMatcher<CXXNullPtrLiteralExpr>... d759 1 a759 1 Matcher<Stmt>cxxOperatorCallExprMatcher<CXXOperatorCallExpr>... d775 1 a775 1 Matcher<Stmt>cxxReinterpretCastExprMatcher<CXXReinterpretCastExpr>... d787 1 a787 1 Matcher<Stmt>cxxStaticCastExprMatcher<CXXStaticCastExpr>... d790 2 a791 2 See also: hasDestinationType See also: reinterpretCast d802 1 a802 1 Matcher<Stmt>cxxTemporaryObjectExprMatcher<CXXTemporaryObjectExpr>... d810 1 a810 1 Matcher<Stmt>cxxThisExprMatcher<CXXThisExpr>... d822 1 a822 1 Matcher<Stmt>cxxThrowExprMatcher<CXXThrowExpr>... d831 1 a831 1 Matcher<Stmt>cxxTryStmtMatcher<CXXTryStmt>... d840 1 a840 1 Matcher<Stmt>cxxUnresolvedConstructExprMatcher<CXXUnresolvedConstructExpr>... d850 1 a850 1 Matcher<Stmt>declRefExprMatcher<DeclRefExpr>... d859 1 a859 1 Matcher<Stmt>declStmtMatcher<DeclStmt>... d869 1 a869 1 Matcher<Stmt>defaultStmtMatcher<DefaultStmt>... d879 1 a879 9 Matcher<Stmt>designatedInitExprMatcher<DesignatedInitExpr>...
Matches C99 designated initializer expressions [C99 6.7.8].

Example: Matches { [2].y = 1.0, [0].x = 1.0 }
  point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
Matcher<Stmt>doStmtMatcher<DoStmt>... d889 1 a889 1 Matcher<Stmt>explicitCastExprMatcher<ExplicitCastExpr>... d901 1 a901 1 See also: hasDestinationType. d910 1 a910 1 Matcher<Stmt>exprMatcher<Expr>... d918 1 a918 1 Matcher<Stmt>exprWithCleanupsMatcher<ExprWithCleanups>... d927 1 a927 1 Matcher<Stmt>floatLiteralMatcher<FloatingLiteral>... d936 1 a936 1 Matcher<Stmt>forStmtMatcher<ForStmt>... d945 1 a945 1 Matcher<Stmt>gnuNullExprMatcher<GNUNullExpr>... d950 1 a950 1 Matcher<Stmt>gotoStmtMatcher<GotoStmt>... d961 1 a961 1 Matcher<Stmt>ifStmtMatcher<IfStmt>... d969 1 a969 1 Matcher<Stmt>implicitCastExprMatcher<ImplicitCastExpr>... d977 1 a977 11 Matcher<Stmt>implicitValueInitExprMatcher<ImplicitValueInitExpr>...
Matches implicit initializers of init list expressions.

Given
  point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 };
implicitValueInitExpr()
  matches "[0].y" (implicitly)
Matcher<Stmt>initListExprMatcher<InitListExpr>... d989 1 a989 1 Matcher<Stmt>integerLiteralMatcher<IntegerLiteral>... d997 1 a997 1 Matcher<Stmt>labelStmtMatcher<LabelStmt>... d1008 1 a1008 1 Matcher<Stmt>lambdaExprMatcher<LambdaExpr>... d1016 1 a1016 1 Matcher<Stmt>materializeTemporaryExprMatcher<MaterializeTemporaryExpr>... d1032 1 a1032 1 Matcher<Stmt>memberExprMatcher<MemberExpr>... d1045 1 a1045 1 Matcher<Stmt>nullStmtMatcher<NullStmt>... d1054 1 a1054 1 Matcher<Stmt>objcMessageExprMatcher<ObjCMessageExpr>... d1065 1 a1065 45 Matcher<Stmt>opaqueValueExprMatcher<OpaqueValueExpr>...
Matches opaque value expressions. They are used as helpers
to reference another expressions and can be met
in BinaryConditionalOperators, for example.

Example matches 'a'
  (a ?: c) + 42;
Matcher<Stmt>parenExprMatcher<ParenExpr>...
Matches parentheses used in expressions.

Example matches (foo() + 1)
  int foo() { return 1; }
  int a = (foo() + 1);
Matcher<Stmt>parenListExprMatcher<ParenListExpr>...
Matches paren list expressions.
ParenListExprs don't have a predefined type and are used for late parsing.
In the final AST, they can be met in template declarations.

Given
  template<typename T> class X {
    void f() {
      X x(*this);
      int a = 0, b = 1; int i = (a, b);
    }
  };
parenListExpr() matches "*this" but NOT matches (a, b) because (a, b)
has a predefined type and is a ParenExpr, not a ParenListExpr.
Matcher<Stmt>predefinedExprMatcher<PredefinedExpr>...
Matches predefined identifier expressions [C99 6.4.2.2].

Example: Matches __func__
  printf("%s", __func__);
Matcher<Stmt>returnStmtMatcher<ReturnStmt>... d1075 1 a1075 1 Matcher<Stmt>stmtMatcher<Stmt>... d1085 1 a1085 9 Matcher<Stmt>stmtExprMatcher<StmtExpr>...
Matches statement expression (GNU extension).

Example match: ({ int X = 4; X; })
  int C = ({ int X = 4; X; });
Matcher<Stmt>stringLiteralMatcher<StringLiteral>... d1089 1 a1089 2 char *s = "abcd"; wchar_t *ws = L"abcd"; d1093 1 a1093 1 Matcher<Stmt>substNonTypeTemplateParmExprMatcher<SubstNonTypeTemplateParmExpr>... d1105 1 a1105 1 Matcher<Stmt>switchCaseMatcher<SwitchCase>... d1115 1 a1115 1 Matcher<Stmt>switchStmtMatcher<SwitchStmt>... d1125 1 a1125 1 Matcher<Stmt>unaryExprOrTypeTraitExprMatcher<UnaryExprOrTypeTraitExpr>... d1136 1 a1136 1 Matcher<Stmt>unaryOperatorMatcher<UnaryOperator>... d1144 1 a1144 16 Matcher<Stmt>unresolvedLookupExprMatcher<UnresolvedLookupExpr>...
Matches reference to a name that can be looked up during parsing
but could not be resolved to a specific declaration.

Given
  template<typename T>
  T foo() { T a; return a; }
  template<typename T>
  void bar() {
    foo<T>();
  }
unresolvedLookupExpr()
  matches foo<T>() 
Matcher<Stmt>userDefinedLiteralMatcher<UserDefinedLiteral>... d1151 1 a1151 1 Matcher<Stmt>whileStmtMatcher<WhileStmt>... d1161 1 a1161 1 Matcher<TemplateArgument>templateArgumentMatcher<TemplateArgument>... d1172 1 a1172 12 Matcher<TemplateName>templateNameMatcher<TemplateName>...
Matches template name.

Given
  template <typename T> class X { };
  X<int> xi;
templateName()
  matches 'X' in X<int>.
Matcher<TypeLoc>typeLocMatcher<TypeLoc>... d1177 1 a1177 1 Matcher<Type>arrayTypeMatcher<ArrayType>... d1189 1 a1189 1 Matcher<Type>atomicTypeMatcher<AtomicType>... d1199 1 a1199 1 Matcher<Type>autoTypeMatcher<AutoType>... d1211 1 a1211 1 Matcher<Type>blockPointerTypeMatcher<BlockPointerType>... d1219 1 a1219 1 Matcher<Type>builtinTypeMatcher<BuiltinType>... d1233 1 a1233 1 Matcher<Type>complexTypeMatcher<ComplexType>... d1243 1 a1243 1 Matcher<Type>constantArrayTypeMatcher<ConstantArrayType>... d1257 1 a1257 1 Matcher<Type>decayedTypeMatcher<DecayedType>... d1269 1 a1269 1 Matcher<Type>dependentSizedArrayTypeMatcher<DependentSizedArrayType>... d1282 1 a1282 1 Matcher<Type>elaboratedTypeMatcher<ElaboratedType>... d1302 1 a1302 28 Matcher<Type>enumTypeMatcher<EnumType>...
Matches enum types.

Given
  enum C { Green };
  enum class S { Red };

  C c;
  S s;

enumType() matches the type of the variable declarations of both c and
s.
Matcher<Type>functionProtoTypeMatcher<FunctionProtoType>...
Matches FunctionProtoType nodes.

Given
  int (*f)(int);
  void g();
functionProtoType()
  matches "int (*f)(int)" and the type of "g" in C++ mode.
  In C mode, "g" is not matched because it does not contain a prototype.
Matcher<Type>functionTypeMatcher<FunctionType>... d1313 1 a1313 1 Matcher<Type>incompleteArrayTypeMatcher<IncompleteArrayType>... d1325 1 a1325 1 Matcher<Type>injectedClassNameTypeMatcher<InjectedClassNameType>... d1337 1 a1337 1 Matcher<Type>lValueReferenceTypeMatcher<LValueReferenceType>... d1354 1 a1354 1 Matcher<Type>memberPointerTypeMatcher<MemberPointerType>... d1364 1 a1364 1 Matcher<Type>objcObjectPointerTypeMatcher<ObjCObjectPointerType>... d1379 1 a1379 1 Matcher<Type>parenTypeMatcher<ParenType>... d1391 1 a1391 1 Matcher<Type>pointerTypeMatcher<PointerType>... d1408 1 a1408 1 Matcher<Type>rValueReferenceTypeMatcher<RValueReferenceType>... d1425 1 a1425 1 Matcher<Type>recordTypeMatcher<RecordType>... d1440 1 a1440 1 Matcher<Type>referenceTypeMatcher<ReferenceType>... d1456 1 a1456 1 Matcher<Type>substTemplateTypeParmTypeMatcher<SubstTemplateTypeParmType>... d1470 1 a1470 1 Matcher<Type>templateSpecializationTypeMatcher<TemplateSpecializationType>... d1485 1 a1485 1 Matcher<Type>templateTypeParmTypeMatcher<TemplateTypeParmType>... d1494 1 a1494 1 Matcher<Type>typeMatcher<Type>... d1499 1 a1499 1 Matcher<Type>typedefTypeMatcher<TypedefType>... d1509 1 a1509 1 Matcher<Type>unaryTransformTypeMatcher<UnaryTransformType>... d1519 1 a1519 1 Matcher<Type>variableArrayTypeMatcher<VariableArrayType>... d1591 1 a1591 1 Matcher<BinaryOperator>hasOperatorNamestd::string Name d1606 2 a1607 2 Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteral>, Matcher<FloatingLiteral>, Matcher<IntegerLiteral> d1611 1 a1611 1 Matcher<CXXCatchStmt>isCatchAll d1627 1 a1627 1 Matcher<CXXConstructExpr>argumentCountIsunsigned N d1637 1 a1637 1 Matcher<CXXConstructExpr>isListInitialization d1642 1 a1642 15 Matcher<CXXConstructExpr>requiresZeroInitialization
Matches a constructor call expression which requires
zero initialization.

Given
void foo() {
  struct point { double x; double y; };
  point pt[2] = { { 1.0, 2.0 } };
}
initListExpr(has(cxxConstructExpr(requiresZeroInitialization()))
will match the implicit array filler for pt[1].
Matcher<CXXConstructorDecl>isCopyConstructor d1655 1 a1655 1 Matcher<CXXConstructorDecl>isDefaultConstructor d1668 1 a1668 16 Matcher<CXXConstructorDecl>isDelegatingConstructor
Matches constructors that delegate to another constructor.

Given
  struct S {
    S(); #1
    S(int) {} #2
    S(S &&) : S() {} #3
  };
  S::S() : S(0) {} #4
cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not
#1 or #2.
Matcher<CXXConstructorDecl>isExplicit d1684 1 a1684 1 Matcher<CXXConstructorDecl>isMoveConstructor d1697 1 a1697 1 Matcher<CXXConversionDecl>isExplicit d1713 1 a1713 1 Matcher<CXXCtorInitializer>isBaseInitializer d1731 1 a1731 1 Matcher<CXXCtorInitializer>isMemberInitializer d1749 1 a1749 1 Matcher<CXXCtorInitializer>isWritten d1764 1 a1764 1 Matcher<CXXMethodDecl>isConst d1777 1 a1777 1 Matcher<CXXMethodDecl>isCopyAssignmentOperator d1792 1 a1792 1 Matcher<CXXMethodDecl>isFinal d1809 1 a1809 16 Matcher<CXXMethodDecl>isMoveAssignmentOperator
Matches if the given method declaration declares a move assignment
operator.

Given
struct A {
  A &operator=(const A &);
  A &operator=(A &&);
};

cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not
the first one.
Matcher<CXXMethodDecl>isOverride d1825 1 a1825 1 Matcher<CXXMethodDecl>isPure d1837 1 a1837 14 Matcher<CXXMethodDecl>isUserProvided
Matches method declarations that are user-provided.

Given
  struct S {
    S(); #1
    S(const S &) = default; #2
    S(S &&) = delete; #3
  };
cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.
Matcher<CXXMethodDecl>isVirtual d1849 1 a1849 17 Matcher<CXXMethodDecl>isVirtualAsWritten
Matches if the given method declaration has an explicit "virtual".

Given
  class A {
   public:
    virtual void x();
  };
  class B : public A {
   public:
    void x();
  };
  matches A::x but not B::x
Matcher<CXXOperatorCallExpr>hasOverloadedOperatorNameStringRef Name d1866 1 a1866 1 Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl> d1870 1 a1870 1 Matcher<CXXRecordDecl>isDerivedFromstd::string BaseName d1875 1 a1875 1 Matcher<CXXRecordDecl>isExplicitTemplateSpecialization d1885 1 a1885 1 Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl> d1889 1 a1889 1 Matcher<CXXRecordDecl>isFinal d1906 1 a1906 12 Matcher<CXXRecordDecl>isLambda
Matches the generated class of lambda expressions.

Given:
  auto x = []{};

cxxRecordDecl(isLambda()) matches the implicit class declaration of
decltype(x)
Matcher<CXXRecordDecl>isSameOrDerivedFromstd::string BaseName d1912 1 a1912 1 Matcher<CXXRecordDecl>isTemplateInstantiation d1929 1 a1929 1 Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl> d1933 1 a1933 1 Matcher<CallExpr>argumentCountIsunsigned N d1943 1 a1943 10 Matcher<CastExpr>hasCastKindCastKind Kind
Matches casts that has a given cast kind.

Example: matches the implicit cast around 0
(matcher = castExpr(hasCastKind(CK_NullToPointer)))
  int *p = 0;
Matcher<CharacterLiteral>equalsValueT Value d1949 2 a1950 2 Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteral>, Matcher<FloatingLiteral>, Matcher<IntegerLiteral> d1954 1 a1954 1 Matcher<ClassTemplateSpecializationDecl>templateArgumentCountIsunsigned N d1965 1 a1965 1 Matcher<CompoundStmt>statementCountIsunsigned N d1977 2 a1978 2 Matcher<ConstantArrayType>hasSizeunsigned N
Matches nodes that have the specified size.
a1983 3
  char *s = "abcd";
  wchar_t *ws = L"abcd";
  char *w = "a";
a1985 2
stringLiteral(hasSize(4))
  matches "abcd", L"abcd"
d1989 1
a1989 1
Matcher<DeclStmt>declCountIsunsigned N
d2002 1
a2002 1
Matcher<Decl>equalsBoundNodestd::string ID
d2025 1
a2025 8
Matcher<Decl>equalsNodeconst Decl* Other
Matches if a node equals another node.

Decl has pointer identity in the AST.
Matcher<Decl>hasAttrattr::Kind AttrKind d2036 1 a2036 1 Matcher<Decl>isExpansionInFileMatchingstd::string RegExp d2047 1 a2047 1 Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc> d2051 1 a2051 1 Matcher<Decl>isExpansionInMainFile d2061 1 a2061 1 Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc> d2065 1 a2065 1 Matcher<Decl>isExpansionInSystemHeader d2075 1 a2075 1 Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc> d2079 1 a2079 1 Matcher<Decl>isImplicit d2085 1 a2085 1 Matcher<Decl>isPrivate d2095 1 a2095 1 matches 'int c;' d2099 1 a2099 1 Matcher<Decl>isProtected d2109 1 a2109 1 matches 'int b;' d2113 1 a2113 1 Matcher<Decl>isPublic d2123 1 a2123 42 matches 'int a;'
Matcher<DesignatedInitExpr>designatorCountIsunsigned N
Matches designated initializer expressions that contain
a specific number of designators.

Example: Given
  point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
  point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 };
designatorCountIs(2)
  matches '{ [2].y = 1.0, [0].x = 1.0 }',
  but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'.
Matcher<FieldDecl>hasBitWidthunsigned Width
Matches non-static data members that are bit-fields of the specified
bit width.

Given
  class C {
    int a : 2;
    int b : 4;
    int c : 2;
  };
fieldDecl(hasBitWidth(2))
  matches 'int a;' and 'int c;' but not 'int b;'.
Matcher<FieldDecl>isBitField
Matches non-static data members that are bit-fields.

Given
  class C {
    int a : 2;
    int b;
  };
fieldDecl(isBitField())
  matches 'int a;' but not 'int b;'.
d2127 1
a2127 1
Matcher<FloatingLiteral>equalsValueT  Value
d2133 2
a2134 19
Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteral>,
           Matcher<FloatingLiteral>, Matcher<IntegerLiteral>
Matcher<FunctionDecl>hasDynamicExceptionSpec
Matches functions that have a dynamic exception specification.

Given:
  void f();
  void g() noexcept;
  void h() noexcept(true);
  void i() noexcept(false);
  void j() throw();
  void k() throw(int);
  void l() throw(...);
functionDecl(hasDynamicExceptionSpec()) and
  functionProtoType(hasDynamicExceptionSpec())
  match the declarations of j, k, and l, but not f, g, h, or i.
d2138 1
a2138 1
Matcher<FunctionDecl>hasOverloadedOperatorNameStringRef Name
d2155 1
a2155 1
Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl>
d2159 1
a2159 1
Matcher<FunctionDecl>isConstexpr
d2172 1
a2172 12
Matcher<FunctionDecl>isDefaulted
Matches defaulted function declarations.

Given:
  class A { ~A(); };
  class B { ~B() = default; };
functionDecl(isDefaulted())
  matches the declaration of ~B, but not ~A.
Matcher<FunctionDecl>isDefinition d2183 1 a2183 1 Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl> d2187 1 a2187 1 Matcher<FunctionDecl>isDeleted d2198 1 a2198 1 Matcher<FunctionDecl>isExplicitTemplateSpecialization d2208 1 a2208 1 Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl> d2212 1 a2212 1 Matcher<FunctionDecl>isExternC d2224 1 a2224 1 Matcher<FunctionDecl>isInline d2239 1 a2239 1 Matcher<FunctionDecl>isNoThrow d2248 2 a2249 2 functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) match the declarations of g, and h, but not f, i or j. d2253 1 a2253 17 Matcher<FunctionDecl>isStaticStorageClass
Matches variablefunction declarations that have "static" storage
class specifier ("static" keyword) written in the source.

Given:
  static void f() {}
  static int i = 0;
  extern int j;
  int k;
functionDecl(isStaticStorageClass())
  matches the function declaration f.
varDecl(isStaticStorageClass())
  matches the variable declaration i.
Matcher<FunctionDecl>isTemplateInstantiation d2270 1 a2270 1 Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl> d2274 1 a2274 1 Matcher<FunctionDecl>isVariadic d2286 2 a2287 53 Matcher<FunctionDecl>parameterCountIsunsigned N
Matches FunctionDecls and FunctionProtoTypes that have a
specific parameter count.

Given
  void f(int i) {}
  void g(int i, int j) {}
  void h(int i, int j);
  void j(int i);
  void k(int x, int y, int z, ...);
functionDecl(parameterCountIs(2))
  matches void g(int i, int j) {}
functionProtoType(parameterCountIs(2))
  matches void h(int i, int j)
functionProtoType(parameterCountIs(3))
  matches void k(int x, int y, int z, ...);
Matcher<FunctionProtoType>hasDynamicExceptionSpec
Matches functions that have a dynamic exception specification.

Given:
  void f();
  void g() noexcept;
  void h() noexcept(true);
  void i() noexcept(false);
  void j() throw();
  void k() throw(int);
  void l() throw(...);
functionDecl(hasDynamicExceptionSpec()) and
  functionProtoType(hasDynamicExceptionSpec())
  match the declarations of j, k, and l, but not f, g, h, or i.
Matcher<FunctionProtoType>isNoThrow
Matches functions that have a non-throwing exception specification.

Given:
  void f();
  void g() noexcept;
  void h() throw();
  void i() throw(int);
  void j() noexcept(false);
functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
  match the declarations of g, and h, but not f, i or j.
Matcher<FunctionProtoType>parameterCountIsunsigned N
Matches FunctionDecls and FunctionProtoTypes that have a
specific parameter count.
a2291 3
  void h(int i, int j);
  void j(int i);
  void k(int x, int y, int z, ...);
d2293 1
a2293 5
  matches void g(int i, int j) {}
functionProtoType(parameterCountIs(2))
  matches void h(int i, int j)
functionProtoType(parameterCountIs(3))
  matches void k(int x, int y, int z, ...);
d2297 1
a2297 1
Matcher<IntegerLiteral>equalsValueT  Value
d2303 2
a2304 2
Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteral>,
           Matcher<FloatingLiteral>, Matcher<IntegerLiteral>
d2308 1
a2308 1
Matcher<MemberExpr>isArrow
d2325 1
a2325 21
Matcher<NamedDecl>hasExternalFormalLinkage
Matches a declaration that has external formal linkage.

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

Example matches f() because it has external formal linkage despite being
unique to the translation unit as though it has internal likage
(matcher = functionDecl(hasExternalFormalLinkage()))

namespace {
void f() {}
}
Matcher<NamedDecl>hasNamestd::string Name d2340 1 a2340 1 Matcher<NamedDecl>matchesNamestd::string RegExp d2356 1 a2356 1 Matcher<NamespaceDecl>isAnonymous d2367 1 a2367 1 Matcher<NamespaceDecl>isInline d2382 1 a2382 1 Matcher<ObjCMessageExpr>argumentCountIsunsigned N d2392 1 a2392 1 Matcher<ObjCMessageExpr>hasKeywordSelector d2406 1 a2406 1 Matcher<ObjCMessageExpr>hasNullSelector d2414 1 a2414 1 Matcher<ObjCMessageExpr>hasSelectorstd::string BaseName d2424 1 a2424 1 Matcher<ObjCMessageExpr>hasUnarySelector d2434 1 a2434 1 Matcher<ObjCMessageExpr>matchesSelectorstd::string RegExp d2443 1 a2443 1 Matcher<ObjCMessageExpr>numSelectorArgsunsigned N d2456 1 a2456 1 Matcher<QualType>asStringstd::string Name d2467 1 a2467 1 Matcher<QualType>equalsBoundNodestd::string ID d2490 1 a2490 1 Matcher<QualType>hasLocalQualifiers d2505 1 a2505 1 Matcher<QualType>isAnyCharacter d2517 1 a2517 19 Matcher<QualType>isAnyPointer
Matches QualType nodes that are of any pointer type; this includes
the Objective-C object pointer type, which is different despite being
syntactically similar.

Given
  int *i = nullptr;

  @@interface Foo
  @@end
  Foo *f;

  int j;
varDecl(hasType(isAnyPointer()))
  matches "int *i" and "Foo *f", but not "int j".
Matcher<QualType>isConstQualified d2534 1 a2534 1 Matcher<QualType>isInteger d2546 1 a2546 25 Matcher<QualType>isSignedInteger
Matches QualType nodes that are of signed integer type.

Given
  void a(int);
  void b(unsigned long);
  void c(double);
functionDecl(hasAnyParameter(hasType(isSignedInteger())))
matches "a(int)", but not "b(unsigned long)" and "c(double)".
Matcher<QualType>isUnsignedInteger
Matches QualType nodes that are of unsigned integer type.

Given
  void a(int);
  void b(unsigned long);
  void c(double);
functionDecl(hasAnyParameter(hasType(isUnsignedInteger())))
matches "b(unsigned long)", but not "a(int)" and "c(double)".
Matcher<QualType>isVolatileQualified d2563 1 a2563 1 Matcher<RecordDecl>isClass d2573 1 a2573 1 Matcher<RecordDecl>isStruct d2583 1 a2583 1 Matcher<RecordDecl>isUnion d2593 1 a2593 1 Matcher<Stmt>equalsBoundNodestd::string ID d2616 1 a2616 8 Matcher<Stmt>equalsNodeconst Stmt* Other
Matches if a node equals another node.

Stmt has pointer identity in the AST.
Matcher<Stmt>isExpansionInFileMatchingstd::string RegExp d2627 1 a2627 1 Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc> d2631 1 a2631 1 Matcher<Stmt>isExpansionInMainFile d2641 1 a2641 1 Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc> d2645 1 a2645 1 Matcher<Stmt>isExpansionInSystemHeader d2655 1 a2655 1 Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc> d2659 2 a2660 19 Matcher<StringLiteral>hasSizeunsigned N
Matches nodes that have the specified size.

Given
  int a[42];
  int b[2 * 21];
  int c[41], d[43];
  char *s = "abcd";
  wchar_t *ws = L"abcd";
  char *w = "a";
constantArrayType(hasSize(42))
  matches "int a[42]" and "int b[2 * 21]"
stringLiteral(hasSize(4))
  matches "abcd", L"abcd"
Matcher<TagDecl>isDefinition
Matches if a declaration has a body attached.
d2670 1
a2670 1
Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>
d2674 1
a2674 1
Matcher<TemplateArgument>equalsIntegralValuestd::string Value
d2690 1
a2690 1
Matcher<TemplateArgument>isIntegral
d2703 1
a2703 1
Matcher<TemplateSpecializationType>templateArgumentCountIsunsigned N
d2714 1
a2714 1
Matcher<TypeLoc>isExpansionInFileMatchingstd::string RegExp
d2725 1
a2725 1
Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
d2729 1
a2729 1
Matcher<TypeLoc>isExpansionInMainFile
d2739 1
a2739 1
Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
d2743 1
a2743 1
Matcher<TypeLoc>isExpansionInSystemHeader
d2753 1
a2753 1
Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
d2757 1
a2757 1
Matcher<Type>booleanType
d2767 1
a2767 1
Matcher<Type>equalsBoundNodestd::string ID
d2790 1
a2790 19
Matcher<Type>equalsNodeconst Type* Other
Matches if a node equals another node.

Type has pointer identity in the AST.
Matcher<Type>realFloatingPointType
Matches any real floating-point type (float, double, long double).

Given
  int i;
  float f;
realFloatingPointType()
  matches "float f" but not "int i"
Matcher<Type>voidType d2800 1 a2800 1 Matcher<UnaryExprOrTypeTraitExpr>ofKindUnaryExprOrTypeTrait Kind d2811 1 a2811 1 Matcher<UnaryOperator>hasOperatorNamestd::string Name d2820 1 a2820 1 Matcher<VarDecl>hasAutomaticStorageDuration d2834 1 a2834 1 Matcher<VarDecl>hasGlobalStorage d2846 1 a2846 1 Matcher<VarDecl>hasLocalStorage d2859 1 a2859 1 Matcher<VarDecl>hasStaticStorageDuration a2860 2 It includes the variable declared at namespace scope and those declared with "static" and "extern" storage class specifiers. d2862 2 a2869 4 static int b; extern int c; varDecl(hasStaticStorageDuration()) matches the function declaration y, a, b and c. d2873 1 a2873 1 Matcher<VarDecl>hasThreadStorageDuration d2887 1 a2887 1 Matcher<VarDecl>isConstexpr d2900 1 a2900 1 Matcher<VarDecl>isDefinition d2911 1 a2911 1 Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl> d2915 1 a2915 1 Matcher<VarDecl>isExceptionVariable d2928 1 a2928 1 Matcher<VarDecl>isExplicitTemplateSpecialization d2938 1 a2938 29 Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
Matcher<VarDecl>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<VarDecl>isStaticStorageClass
Matches variablefunction declarations that have "static" storage
class specifier ("static" keyword) written in the source.

Given:
  static void f() {}
  static int i = 0;
  extern int j;
  int k;
functionDecl(isStaticStorageClass())
  matches the function declaration f.
varDecl(isStaticStorageClass())
  matches the variable declaration i.
d2942 1
a2942 1
Matcher<VarDecl>isTemplateInstantiation
d2959 1
a2959 1
Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
d2963 1
a2963 1
Matcher<internal::Matcher<Decl>>isInstantiated
d2976 1
a2976 28
Matcher<internal::Matcher<Expr>>nullPointerConstant
Matches expressions that resolve to a null pointer constant, such as
GNU's __null, C++11's nullptr, or C's NULL macro.

Given:
  void *v1 = NULL;
  void *v2 = nullptr;
  void *v3 = __null; GNU extension
  char *cp = (char *)0;
  int *ip = 0;
  int i = 0;
expr(nullPointerConstant())
  matches the initializer for v1, v2, v3, cp, and ip. Does not match the
  initializer for i.
Matcher<internal::Matcher<NamedDecl>>hasAnyNameStringRef, ..., StringRef
Matches NamedDecl nodes that have any of the specified names.

This matcher is only provided as a performance optimization of hasName.
    hasAnyName(a, b, c)
 is equivalent to, but faster than
    anyOf(hasName(a), hasName(b), hasName(c))
Matcher<internal::Matcher<Stmt>>isInTemplateInstantiation a3114 4 Note that has is direct matcher, so it also matches things like implicit casts and paren casts. If you are matching with expr then you should probably consider using ignoringParenImpCasts like: has(ignoringParenImpCasts(expr())). d3130 1 a3130 55 Matcher<AbstractConditionalOperator>hasConditionMatcher<Expr> InnerMatcher
Matches the condition expression of an if statement, for loop,
switch statement or conditional operator.

Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
  if (true) {}
Matcher<AbstractConditionalOperator>hasFalseExpressionMatcher<Expr> InnerMatcher
Matches the false branch expression of a conditional operator
(binary or ternary).

Example matches b
  condition ? a : b
  condition ?: b
Matcher<AbstractConditionalOperator>hasTrueExpressionMatcher<Expr> InnerMatcher
Matches the true branch expression of a conditional operator.

Example 1 (conditional ternary operator): matches a
  condition ? a : b

Example 2 (conditional binary operator): matches opaqueValueExpr(condition)
  condition ?: b
Matcher<AddrLabelExpr>hasDeclarationMatcher<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
- for CXXNewExpr, the declaration of the operator new

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<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, 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<ArraySubscriptExpr>hasBaseMatcher<Expr> InnerMatcher d3142 1 a3142 1 Matcher<ArraySubscriptExpr>hasIndexMatcher<Expr> InnerMatcher d3153 1 a3153 1 Matcher<ArraySubscriptExpr>hasLHSMatcher<Expr> InnerMatcher d3161 1 a3161 1 Matcher<ArraySubscriptExpr>hasRHSMatcher<Expr> InnerMatcher d3169 1 a3169 1 Matcher<ArrayTypeLoc>hasElementTypeLocMatcher<TypeLoc> d3180 1 a3180 1 Usable as: Matcher<ArrayType>, Matcher<ComplexType> d3184 1 a3184 1 Matcher<ArrayType>hasElementTypeMatcher<Type> d3195 1 a3195 1 Usable as: Matcher<ArrayType>, Matcher<ComplexType> d3199 1 a3199 1 Matcher<AtomicTypeLoc>hasValueTypeLocMatcher<TypeLoc> d3208 1 a3208 1 Usable as: Matcher<AtomicType> d3212 1 a3212 1 Matcher<AtomicType>hasValueTypeMatcher<Type> d3221 1 a3221 1 Usable as: Matcher<AtomicType> d3225 1 a3225 1 Matcher<AutoType>hasDeducedTypeMatcher<Type> d3237 1 a3237 1 Usable as: Matcher<AutoType> d3241 1 a3241 1 Matcher<BinaryOperator>hasEitherOperandMatcher<Expr> InnerMatcher d3247 1 a3247 1 Matcher<BinaryOperator>hasLHSMatcher<Expr> InnerMatcher d3255 1 a3255 1 Matcher<BinaryOperator>hasRHSMatcher<Expr> InnerMatcher d3263 1 a3263 1 Matcher<BlockPointerTypeLoc>pointeeLocMatcher<TypeLoc> d3274 2 a3275 2 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType> d3279 1 a3279 1 Matcher<BlockPointerType>pointeeMatcher<Type> d3290 2 a3291 22 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType>
Matcher<CXXConstructExpr>forEachArgumentWithParamMatcher<Expr> ArgMatcher, Matcher<ParmVarDecl> ParamMatcher
Matches all arguments and their respective ParmVarDecl.

Given
  void f(int i);
  int y;
  f(y);
callExpr(
  forEachArgumentWithParam(
    declRefExpr(to(varDecl(hasName("y")))),
    parmVarDecl(hasType(isInteger()))
))
  matches f(y);
with declRefExpr(...)
  matching int y
and parmVarDecl(...)
  matching int i
d3295 1
a3295 1
Matcher<CXXConstructExpr>hasAnyArgumentMatcher<Expr> InnerMatcher
d3305 5
d3313 1
a3313 1
Matcher<CXXConstructExpr>hasArgumentunsigned N, Matcher<Expr> InnerMatcher
d3323 2
a3324 2
Matcher<CXXConstructExpr>hasDeclarationMatcher<Decl>  InnerMatcher
Matches a node if the declaration associated with that node
a3331 1
- for CXXNewExpr, the declaration of the operator new
d3336 6
a3341 7
Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
  Matcher<TagType>, Matcher<TemplateSpecializationType>,
  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
  Matcher<UnresolvedUsingType>
d3345 1
a3345 1
Matcher<CXXConstructorDecl>forEachConstructorInitializerMatcher<CXXCtorInitializer> InnerMatcher
d3357 1
a3357 1
Matcher<CXXConstructorDecl>hasAnyConstructorInitializerMatcher<CXXCtorInitializer> InnerMatcher
d3372 1
a3372 1
Matcher<CXXCtorInitializer>forFieldMatcher<FieldDecl> InnerMatcher
d3387 1
a3387 1
Matcher<CXXCtorInitializer>withInitializerMatcher<Expr> InnerMatcher
d3402 3
a3404 3
Matcher<CXXForRangeStmt>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
definition that has a given body.
d3415 1
a3415 1
Matcher<CXXForRangeStmt>hasLoopVariableMatcher<VarDecl> InnerMatcher
d3425 1
a3425 1
Matcher<CXXForRangeStmt>hasRangeInitMatcher<Expr> InnerMatcher
d3435 1
a3435 1
Matcher<CXXMemberCallExpr>onImplicitObjectArgumentMatcher<Expr> InnerMatcher
d3439 1
a3439 1
Matcher<CXXMemberCallExpr>onMatcher<Expr> InnerMatcher
d3451 1
a3451 1
Matcher<CXXMemberCallExpr>thisPointerTypeMatcher<Decl> InnerMatcher
d3456 1
a3456 1
Matcher<CXXMemberCallExpr>thisPointerTypeMatcher<QualType> InnerMatcher
d3462 1
a3462 25
Matcher<CXXMethodDecl>forEachOverriddenMatcher<CXXMethodDecl> InnerMatcher
Matches each method overriden by the given method. This matcher may
produce multiple matches.

Given
  class A { virtual void f(); };
  class B : public A { void f(); };
  class C : public B { void f(); };
cxxMethodDecl(ofClass(hasName("C")),
              forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
  matches once, with "b" binding "A::f" and "d" binding "C::f" (Note
  that B::f is not overridden by C::f).

The check can produce multiple matches in case of multiple inheritance, e.g.
  class A1 { virtual void f(); };
  class A2 { virtual void f(); };
  class C : public A1, public A2 { void f(); };
cxxMethodDecl(ofClass(hasName("C")),
              forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
  matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and
  once with "b" binding "A2::f" and "d" binding "C::f".
Matcher<CXXMethodDecl>ofClassMatcher<CXXRecordDecl> InnerMatcher d3481 1 a3481 25 Matcher<CXXNewExpr>hasDeclarationMatcher<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
- for CXXNewExpr, the declaration of the operator new

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<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, 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<CXXRecordDecl>hasMethodMatcher<CXXMethodDecl> InnerMatcher d3493 1 a3493 1 Matcher<CXXRecordDecl>isDerivedFromMatcher<NamedDecl> Base d3514 1 a3514 1 Matcher<CXXRecordDecl>isSameOrDerivedFromMatcher<NamedDecl> Base d3520 1 a3520 1 Matcher<CallExpr>calleeMatcher<Decl> InnerMatcher d3531 1 a3531 1 Matcher<CallExpr>calleeMatcher<Stmt> InnerMatcher d3542 1 a3542 1 Note: Callee cannot take the more general internal::Matcher<Expr> d3544 1 a3544 1 internal::Matcher<Decl>, as the matcher hierarchy is purely d3549 1 a3549 21 Matcher<CallExpr>forEachArgumentWithParamMatcher<Expr> ArgMatcher, Matcher<ParmVarDecl> ParamMatcher
Matches all arguments and their respective ParmVarDecl.

Given
  void f(int i);
  int y;
  f(y);
callExpr(
  forEachArgumentWithParam(
    declRefExpr(to(varDecl(hasName("y")))),
    parmVarDecl(hasType(isInteger()))
))
  matches f(y);
with declRefExpr(...)
  matching int y
and parmVarDecl(...)
  matching int i
Matcher<CallExpr>hasAnyArgumentMatcher<Expr> InnerMatcher d3559 5 d3567 1 a3567 1 Matcher<CallExpr>hasArgumentunsigned N, Matcher<Expr> InnerMatcher d3577 2 a3578 2 Matcher<CallExpr>hasDeclarationMatcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
a3585 1
- for CXXNewExpr, the declaration of the operator new
d3590 6
a3595 7
Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
  Matcher<TagType>, Matcher<TemplateSpecializationType>,
  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
  Matcher<UnresolvedUsingType>
d3599 1
a3599 1
Matcher<CaseStmt>hasCaseConstantMatcher<Expr> InnerMatcher
d3610 8
a3617 2
Matcher<CastExpr>hasSourceExpressionMatcher<Expr> InnerMatcher

d3620 3
a3622 4
Matcher<ClassTemplateSpecializationDecl>hasAnyTemplateArgumentMatcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
functionDecl that have at least one TemplateArgument matching the given
InnerMatcher.
a3627 4

  template<typename T> f() {};
  void func() { f<int>(); };

a3630 3

functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
  matches the specialization f<int>
d3634 3
a3636 3
Matcher<ClassTemplateSpecializationDecl>hasTemplateArgumentunsigned N, Matcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
a3641 3

  template<typename T> f() {};
  void func() { f<int>(); };
a3644 3

functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
  matches the specialization f<int>
d3648 1
a3648 1
Matcher<ComplexTypeLoc>hasElementTypeLocMatcher<TypeLoc>
d3659 1
a3659 1
Usable as: Matcher<ArrayType>, Matcher<ComplexType>
d3663 1
a3663 1
Matcher<ComplexType>hasElementTypeMatcher<Type>
d3674 1
a3674 1
Usable as: Matcher<ArrayType>, Matcher<ComplexType>
d3678 1
a3678 1
Matcher<CompoundStmt>hasAnySubstatementMatcher<Stmt> InnerMatcher
d3680 1
a3680 1
a given matcher. Also matches StmtExprs that have CompoundStmt as children.
d3691 26
a3716 1
Matcher<DecayedType>hasDecayedTypeMatcher<QualType> InnerType
d3721 1
a3721 1
Matcher<DeclRefExpr>hasDeclarationMatcher<Decl>  InnerMatcher
a3729 1
- for CXXNewExpr, the declaration of the operator new
d3734 6
a3739 7
Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
  Matcher<TagType>, Matcher<TemplateSpecializationType>,
  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
  Matcher<UnresolvedUsingType>
d3743 1
a3743 1
Matcher<DeclRefExpr>throughUsingDeclMatcher<UsingShadowDecl> InnerMatcher
d3759 1
a3759 1
Matcher<DeclRefExpr>toMatcher<Decl> InnerMatcher
d3770 1
a3770 1
Matcher<DeclStmt>containsDeclarationunsigned N, Matcher<Decl> InnerMatcher
d3789 1
a3789 1
Matcher<DeclStmt>hasSingleDeclMatcher<Decl> InnerMatcher
d3800 1
a3800 1
Matcher<DeclaratorDecl>hasTypeLocMatcher<TypeLoc> Inner
d3811 1
a3811 1
Matcher<Decl>hasDeclContextMatcher<Decl> InnerMatcher
d3827 3
a3829 3
Matcher<DoStmt>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
definition that has a given body.
d3840 1
a3840 1
Matcher<DoStmt>hasConditionMatcher<Expr> InnerMatcher
d3842 1
a3842 1
switch statement or conditional operator.
d3849 1
a3849 1
Matcher<ElaboratedType>hasQualifierMatcher<NestedNameSpecifier> InnerMatcher
d3866 1
a3866 1
Matcher<ElaboratedType>namesTypeMatcher<QualType> InnerMatcher
d3883 1
a3883 1
Matcher<EnumType>hasDeclarationMatcher<Decl>  InnerMatcher
a3891 1
- for CXXNewExpr, the declaration of the operator new
d3896 6
a3901 7
Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
  Matcher<TagType>, Matcher<TemplateSpecializationType>,
  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
  Matcher<UnresolvedUsingType>
d3905 1
a3905 1
Matcher<ExplicitCastExpr>hasDestinationTypeMatcher<QualType> InnerMatcher
d3913 2
a3914 2
Matcher<Expr>hasTypeMatcher<Decl> InnerMatcher
Overloaded to match the declaration of the expression's or value
d3928 1
a3928 1
Usable as: Matcher<Expr>, Matcher<ValueDecl>
d3932 1
a3932 1
Matcher<Expr>hasTypeMatcher<QualType> InnerMatcher
a3937 1
            and U (matcher = typedefDecl(hasType(asString("int")))
a3939 1
 typedef int U;
d3943 1
a3943 1
Matcher<Expr>ignoringImpCastsMatcher<Expr> InnerMatcher
d3966 1
a3966 20
Matcher<Expr>ignoringImplicitast_matchers::Matcher<Expr> InnerMatcher
Matches expressions that match InnerMatcher after any implicit AST
nodes are stripped off.

Parentheses and explicit casts are not discarded.
Given
  class C {};
  C a = C();
  C b;
  C c = b;
The matchers
   varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr())))
would match the declarations for a, b, and c.
While
   varDecl(hasInitializer(cxxConstructExpr()))
only match the declarations for b and c.
Matcher<Expr>ignoringParenCastsMatcher<Expr> InnerMatcher d3985 1 a3985 1 Matcher<Expr>ignoringParenImpCastsMatcher<Expr> InnerMatcher d4008 3 a4010 19 Matcher<FieldDecl>hasInClassInitializerMatcher<Expr> InnerMatcher
Matches non-static data members that have an in-class initializer.

Given
  class C {
    int a = 2;
    int b = 3;
    int c;
  };
fieldDecl(hasInClassInitializer(integerLiteral(equals(2))))
  matches 'int a;' but not 'int b;'.
fieldDecl(hasInClassInitializer(anything()))
  matches 'int a;' and 'int b;' but not 'int c;'.
Matcher<ForStmt>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
definition that has a given body.
d4021 1
a4021 1
Matcher<ForStmt>hasConditionMatcher<Expr> InnerMatcher
d4023 1
a4023 1
switch statement or conditional operator.
d4030 1
a4030 1
Matcher<ForStmt>hasIncrementMatcher<Stmt> InnerMatcher
d4040 1
a4040 1
Matcher<ForStmt>hasLoopInitMatcher<Stmt> InnerMatcher
d4050 1
a4050 1
Matcher<FunctionDecl>hasAnyParameterMatcher<ParmVarDecl> InnerMatcher
d4064 1
a4064 36
Matcher<FunctionDecl>hasAnyTemplateArgumentMatcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
functionDecl that have at least one TemplateArgument matching the given
InnerMatcher.

Given
  template<typename T> class A {};
  template<> class A<double> {};
  A<int> a;

  template<typename T> f() {};
  void func() { f<int>(); };

classTemplateSpecializationDecl(hasAnyTemplateArgument(
    refersToType(asString("int"))))
  matches the specialization A<int>

functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
  matches the specialization f<int>
Matcher<FunctionDecl>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
definition that has a given body.

Given
  for (;;) {}
hasBody(compoundStmt())
  matches 'for (;;) {}'
with compoundStmt()
  matching '{}'
Matcher<FunctionDecl>hasParameterunsigned N, Matcher<ParmVarDecl> InnerMatcher d4076 1 a4076 21 Matcher<FunctionDecl>hasTemplateArgumentunsigned N, Matcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
functionDecl 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;

  template<typename T> f() {};
  void func() { f<int>(); };
classTemplateSpecializationDecl(hasTemplateArgument(
    1, refersToType(asString("int"))))
  matches the specialization A<bool, int>

functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
  matches the specialization f<int>
Matcher<FunctionDecl>returnsMatcher<QualType> InnerMatcher d4086 1 a4086 1 Matcher<IfStmt>hasConditionMatcher<Expr> InnerMatcher d4088 1 a4088 1 switch statement or conditional operator. d4095 1 a4095 1 Matcher<IfStmt>hasConditionVariableStatementMatcher<DeclStmt> InnerMatcher d4105 1 a4105 1 Matcher<IfStmt>hasElseMatcher<Stmt> InnerMatcher d4114 1 a4114 1 Matcher<IfStmt>hasThenMatcher<Stmt> InnerMatcher d4123 1 a4123 1 Matcher<ImplicitCastExpr>hasImplicitDestinationTypeMatcher<QualType> InnerMatcher d4131 1 a4131 7 Matcher<InitListExpr>hasSyntacticFormMatcher<Expr> InnerMatcher
Matches the syntactic form of init list expressions
(if expression have it).
Matcher<InjectedClassNameType>hasDeclarationMatcher<Decl> InnerMatcher a4139 1 - for CXXNewExpr, the declaration of the operator new d4144 6 a4149 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4153 1 a4153 1 Matcher<LabelStmt>hasDeclarationMatcher<Decl> InnerMatcher a4161 1 - for CXXNewExpr, the declaration of the operator new d4166 6 a4171 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4175 1 a4175 1 Matcher<MemberExpr>hasDeclarationMatcher<Decl> InnerMatcher a4183 1 - for CXXNewExpr, the declaration of the operator new d4188 6 a4193 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4197 1 a4197 1 Matcher<MemberExpr>hasObjectExpressionMatcher<Expr> InnerMatcher d4211 1 a4211 1 Matcher<MemberExpr>memberMatcher<ValueDecl> InnerMatcher d4225 1 a4225 1 Matcher<MemberPointerTypeLoc>pointeeLocMatcher<TypeLoc> d4236 2 a4237 2 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType> d4241 1 a4241 1 Matcher<MemberPointerType>pointeeMatcher<Type> d4252 2 a4253 15 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType>
Matcher<NamedDecl>hasUnderlyingDeclMatcher<NamedDecl> InnerMatcher
Matches a NamedDecl whose underlying declaration matches the given
matcher.

Given
  namespace N { template<class T> void f(T t); }
  template <class T> void g() { using N::f; f(T()); }
unresolvedLookupExpr(hasAnyDeclaration(
    namedDecl(hasUnderlyingDecl(hasName("::N::f")))))
  matches the use of f in g() .
d4257 1
a4257 1
Matcher<NestedNameSpecifierLoc>hasPrefixMatcher<NestedNameSpecifierLoc> InnerMatcher
d4268 1
a4268 1
Matcher<NestedNameSpecifierLoc>specifiesTypeLocMatcher<TypeLoc> InnerMatcher
d4281 1
a4281 1
Matcher<NestedNameSpecifier>hasPrefixMatcher<NestedNameSpecifier> InnerMatcher
d4292 1
a4292 1
Matcher<NestedNameSpecifier>specifiesNamespaceMatcher<NamespaceDecl> InnerMatcher
d4304 1
a4304 1
Matcher<NestedNameSpecifier>specifiesTypeMatcher<QualType> InnerMatcher
d4318 1
a4318 1
Matcher<ObjCMessageExpr>hasArgumentunsigned N, Matcher<Expr> InnerMatcher
d4328 1
a4328 1
Matcher<ObjCMessageExpr>hasReceiverTypeMatcher<QualType> InnerMatcher
d4340 1
a4340 22
Matcher<OpaqueValueExpr>hasSourceExpressionMatcher<Expr> InnerMatcher



Matcher<OverloadExpr>hasAnyDeclarationMatcher<Decl> InnerMatcher
Matches an OverloadExpr if any of the declarations in the set of
overloads matches the given matcher.

Given
  template <typename T> void foo(T);
  template <typename T> void bar(T);
  template <typename T> void baz(T t) {
    foo(t);
    bar(t);
  }
unresolvedLookupExpr(hasAnyDeclaration(
    functionTemplateDecl(hasName("foo"))))
  matches foo in foo(t); but not bar in bar(t);
Matcher<ParenType>innerTypeMatcher<Type> d4350 1 a4350 1 Usable as: Matcher<ParenType> d4354 1 a4354 1 Matcher<PointerTypeLoc>pointeeLocMatcher<TypeLoc> d4365 2 a4366 2 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType> d4370 1 a4370 1 Matcher<PointerType>pointeeMatcher<Type> d4381 2 a4382 2 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType> d4386 1 a4386 1 Matcher<QualType>hasCanonicalTypeMatcher<QualType> InnerMatcher d4399 1 a4399 1 Matcher<QualType>hasDeclarationMatcher<Decl> InnerMatcher a4407 1 - for CXXNewExpr, the declaration of the operator new d4412 6 a4417 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4421 1 a4421 12 Matcher<QualType>ignoringParensMatcher<QualType> InnerMatcher
Matches types that match InnerMatcher after any parens are stripped.

Given
  void (*fp)(void);
The matcher
  varDecl(hasType(pointerType(pointee(ignoringParens(functionType())))))
would match the declaration for fp.
Matcher<QualType>pointsToMatcher<Decl> InnerMatcher d4426 1 a4426 1 Matcher<QualType>pointsToMatcher<QualType> InnerMatcher d4438 1 a4438 1 Matcher<QualType>referencesMatcher<Decl> InnerMatcher d4443 1 a4443 1 Matcher<QualType>referencesMatcher<QualType> InnerMatcher d4458 1 a4458 1 Matcher<RecordType>hasDeclarationMatcher<Decl> InnerMatcher a4466 1 - for CXXNewExpr, the declaration of the operator new d4471 6 a4476 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4480 1 a4480 1 Matcher<ReferenceTypeLoc>pointeeLocMatcher<TypeLoc> d4491 2 a4492 2 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType> d4496 1 a4496 1 Matcher<ReferenceType>pointeeMatcher<Type> d4507 2 a4508 27 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType>
Matcher<ReturnStmt>hasReturnValueMatcher<Expr> InnerMatcher
Matches the return value expression of a return statement

Given
  return a + b;
hasReturnValue(binaryOperator())
  matches 'return a + b'
with binaryOperator()
  matching 'a + b'
Matcher<StmtExpr>hasAnySubstatementMatcher<Stmt> InnerMatcher
Matches compound statements where at least one substatement matches
a given matcher. Also matches StmtExprs that have CompoundStmt as children.

Given
  { {}; 1+2; }
hasAnySubstatement(compoundStmt())
  matches '{ {}; 1+2; }'
with compoundStmt()
  matching '{}'
d4512 1
a4512 1
Matcher<Stmt>alignOfExprMatcher<UnaryExprOrTypeTraitExpr>  InnerMatcher
d4518 1
a4518 15
Matcher<Stmt>forFunctionMatcher<FunctionDecl> InnerMatcher
Matches declaration of the function the statemenet belongs to

Given:
F& operator=(const F& o) {
  std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
  return *this;
}
returnStmt(forFunction(hasName("operator=")))
  matches 'return *this'
  but does match 'return > 0'
Matcher<Stmt>sizeOfExprMatcher<UnaryExprOrTypeTraitExpr> InnerMatcher d4524 1 a4524 15 Matcher<SubstTemplateTypeParmType>hasReplacementTypeMatcher<Type>
Matches template type parameter substitutions that have a replacement
type that matches the provided matcher.

Given
  template <typename T>
  double F(T t);
  int i;
  double j = F(i);

substTemplateTypeParmType(hasReplacementType(type())) matches int
Matcher<SwitchStmt>forEachSwitchCaseMatcher<SwitchCase> InnerMatcher d4537 1 a4537 10 Matcher<SwitchStmt>hasConditionMatcher<Expr> InnerMatcher
Matches the condition expression of an if statement, for loop,
switch statement or conditional operator.

Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
  if (true) {}
Matcher<TagType>hasDeclarationMatcher<Decl> InnerMatcher a4545 1 - for CXXNewExpr, the declaration of the operator new d4550 6 a4555 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4559 1 a4559 1 Matcher<TemplateArgument>isExprMatcher<Expr> InnerMatcher d4573 1 a4573 1 Matcher<TemplateArgument>refersToDeclarationMatcher<Decl> InnerMatcher d4588 1 a4588 1 Matcher<TemplateArgument>refersToIntegralTypeMatcher<QualType> InnerMatcher d4600 1 a4600 14 Matcher<TemplateArgument>refersToTemplateMatcher<TemplateName> InnerMatcher
Matches a TemplateArgument that refers to a certain template.

Given
  template<template <typename> class S> class X {};
  template<typename T> class Y {};"
  X<Y> xi;
classTemplateSpecializationDecl(hasAnyTemplateArgument(
    refersToTemplate(templateName())))
  matches the specialization X<Y>
Matcher<TemplateArgument>refersToTypeMatcher<QualType> InnerMatcher d4613 3 a4615 4 Matcher<TemplateSpecializationType>hasAnyTemplateArgumentMatcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
functionDecl that have at least one TemplateArgument matching the given
InnerMatcher.
a4620 4

  template<typename T> f() {};
  void func() { f<int>(); };

a4623 3

functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
  matches the specialization f<int>
d4627 1
a4627 1
Matcher<TemplateSpecializationType>hasDeclarationMatcher<Decl>  InnerMatcher
a4635 1
- for CXXNewExpr, the declaration of the operator new
d4640 6
a4645 7
Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
  Matcher<TagType>, Matcher<TemplateSpecializationType>,
  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
  Matcher<UnresolvedUsingType>
d4649 3
a4651 3
Matcher<TemplateSpecializationType>hasTemplateArgumentunsigned N, Matcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
a4656 3

  template<typename T> f() {};
  void func() { f<int>(); };
a4659 3

functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
  matches the specialization f<int>
d4663 1
a4663 1
Matcher<TemplateTypeParmType>hasDeclarationMatcher<Decl>  InnerMatcher
a4671 1
- for CXXNewExpr, the declaration of the operator new
d4676 6
a4681 7
Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
  Matcher<TagType>, Matcher<TemplateSpecializationType>,
  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
  Matcher<UnresolvedUsingType>
d4701 1
a4701 14
Matcher<TypedefNameDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
matcher.

Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
            and U (matcher = typedefDecl(hasType(asString("int")))
 class X {};
 void y(X &x) { x; X z; }
 typedef int U;
Matcher<TypedefType>hasDeclarationMatcher<Decl> InnerMatcher a4709 1 - for CXXNewExpr, the declaration of the operator new d4714 6 a4719 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4723 1 a4723 13 Matcher<Type>hasUnqualifiedDesugaredTypeMatcher<Type> InnerMatcher
Matches if the matched type matches the unqualified desugared
type of the matched node.

For example, in:
  class A {};
  using B = A;
The matcher type(hasUniqualifeidDesugaredType(recordType())) matches
both B and A.
Matcher<UnaryExprOrTypeTraitExpr>hasArgumentOfTypeMatcher<QualType> InnerMatcher d4733 1 a4733 1 Matcher<UnaryOperator>hasUnaryOperandMatcher<Expr> InnerMatcher d4742 1 a4742 1 Matcher<UnresolvedUsingType>hasDeclarationMatcher<Decl> InnerMatcher a4750 1 - for CXXNewExpr, the declaration of the operator new d4755 6 a4760 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4764 1 a4764 1 Matcher<UsingDecl>hasAnyUsingShadowDeclMatcher<UsingShadowDecl> InnerMatcher d4774 1 a4774 1 Matcher<UsingShadowDecl>hasTargetDeclMatcher<NamedDecl> InnerMatcher d4786 2 a4787 2 Matcher<ValueDecl>hasTypeMatcher<Decl> InnerMatcher
Overloaded to match the declaration of the expression's or value
d4801 1
a4801 1
Usable as: Matcher<Expr>, Matcher<ValueDecl>
d4805 2
a4806 2
Matcher<ValueDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
a4810 1
            and U (matcher = typedefDecl(hasType(asString("int")))
a4812 1
 typedef int U;
d4816 1
a4816 1
Matcher<VarDecl>hasInitializerMatcher<Expr> InnerMatcher
d4826 1
a4826 1
Matcher<VariableArrayType>hasSizeExprMatcher<Expr> InnerMatcher
d4840 3
a4842 3
Matcher<WhileStmt>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
definition that has a given body.
d4853 1
a4853 1
Matcher<WhileStmt>hasConditionMatcher<Expr> InnerMatcher
d4855 1
a4855 1
switch statement or conditional operator.
d4862 1
a4862 1
Matcher<internal::BindableMatcher<NestedNameSpecifierLoc>>locMatcher<NestedNameSpecifier> InnerMatcher
d4868 1
a4868 1
Matcher<internal::BindableMatcher<TypeLoc>>locMatcher<QualType> InnerMatcher
@


1.1.1.7
log
@Import Clang pre-4.0.0 r291444.
@
text
@d103 1
a103 1
Matcher<CXXCtorInitializer>cxxCtorInitializerMatcher<CXXCtorInitializer>...
d114 1
a114 1
Matcher<Decl>accessSpecDeclMatcher<AccessSpecDecl>...
d127 1
a127 1
Matcher<Decl>classTemplateDeclMatcher<ClassTemplateDecl>...
d135 1
a135 1
Matcher<Decl>classTemplateSpecializationDeclMatcher<ClassTemplateSpecializationDecl>...
d147 1
a147 1
Matcher<Decl>cxxConstructorDeclMatcher<CXXConstructorDecl>...
d160 1
a160 1
Matcher<Decl>cxxConversionDeclMatcher<CXXConversionDecl>...
d168 1
a168 1
Matcher<Decl>cxxDestructorDeclMatcher<CXXDestructorDecl>...
d179 1
a179 1
Matcher<Decl>cxxMethodDeclMatcher<CXXMethodDecl>...
d187 1
a187 1
Matcher<Decl>cxxRecordDeclMatcher<CXXRecordDecl>...
d196 1
a196 1
Matcher<Decl>declMatcher<Decl>...
d207 1
a207 1
Matcher<Decl>declaratorDeclMatcher<DeclaratorDecl>...
d218 1
a218 1
Matcher<Decl>enumConstantDeclMatcher<EnumConstantDecl>...
d228 1
a228 1
Matcher<Decl>enumDeclMatcher<EnumDecl>...
d238 1
a238 1
Matcher<Decl>fieldDeclMatcher<FieldDecl>...
d248 1
a248 1
Matcher<Decl>friendDeclMatcher<FriendDecl>...
d258 1
a258 1
Matcher<Decl>functionDeclMatcher<FunctionDecl>...
d266 1
a266 1
Matcher<Decl>functionTemplateDeclMatcher<FunctionTemplateDecl>...
d274 1
a274 12
Matcher<Decl>labelDeclMatcher<LabelDecl>...
Matches a declaration of label.

Given
  goto FOO;
  FOO: bar();
labelDecl()
  matches 'FOO:'
Matcher<Decl>linkageSpecDeclMatcher<LinkageSpecDecl>... d284 1 a284 1 Matcher<Decl>namedDeclMatcher<NamedDecl>... d297 1 a297 1 Matcher<Decl>namespaceAliasDeclMatcher<NamespaceAliasDecl>... d308 1 a308 1 Matcher<Decl>namespaceDeclMatcher<NamespaceDecl>... d319 1 a319 1 Matcher<Decl>nonTypeTemplateParmDeclMatcher<NonTypeTemplateParmDecl>... d329 1 a329 1 Matcher<Decl>objcInterfaceDeclMatcher<ObjCInterfaceDecl>... d338 1 a338 1 Matcher<Decl>parmVarDeclMatcher<ParmVarDecl>... d348 1 a348 1 Matcher<Decl>recordDeclMatcher<RecordDecl>... d359 1 a359 1 Matcher<Decl>staticAssertDeclMatcher<StaticAssertDecl>... d374 1 a374 1 Matcher<Decl>templateTypeParmDeclMatcher<TemplateTypeParmDecl>... d384 1 a384 1 Matcher<Decl>translationUnitDeclMatcher<TranslationUnitDecl>... d397 1 a397 12 Matcher<Decl>typeAliasDeclMatcher<TypeAliasDecl>...
Matches type alias declarations.

Given
  typedef int X;
  using Y = int;
typeAliasDecl()
  matches "using Y = int", but not "typedef int X"
Matcher<Decl>typedefDeclMatcher<TypedefDecl>... a401 1 using Y = int; d403 1 a403 12 matches "typedef int X", but not "using Y = int"
Matcher<Decl>typedefNameDeclMatcher<TypedefNameDecl>...
Matches typedef name declarations.

Given
  typedef int X;
  using Y = int;
typedefNameDecl()
  matches "typedef int X" and "using Y = int"
d407 1
a407 1
Matcher<Decl>unresolvedUsingTypenameDeclMatcher<UnresolvedUsingTypenameDecl>...
d423 1
a423 1
Matcher<Decl>unresolvedUsingValueDeclMatcher<UnresolvedUsingValueDecl>...
d435 1
a435 1
Matcher<Decl>usingDeclMatcher<UsingDecl>...
d445 1
a445 1
Matcher<Decl>usingDirectiveDeclMatcher<UsingDirectiveDecl>...
d455 1
a455 1
Matcher<Decl>valueDeclMatcher<ValueDecl>...
d464 1
a464 1
Matcher<Decl>varDeclMatcher<VarDecl>...
d475 1
a475 1
Matcher<NestedNameSpecifierLoc>nestedNameSpecifierLocMatcher<NestedNameSpecifierLoc>...
d480 1
a480 1
Matcher<NestedNameSpecifier>nestedNameSpecifierMatcher<NestedNameSpecifier>...
d495 1
a495 1
Matcher<QualType>qualTypeMatcher<QualType>...
d500 1
a500 13
Matcher<Stmt>addrLabelExprMatcher<AddrLabelExpr>...
Matches address of label statements (GNU extension).

Given
  FOO: bar();
  void *ptr = &&FOO;
  goto *bar;
addrLabelExpr()
  matches '&&FOO'
Matcher<Stmt>arraySubscriptExprMatcher<ArraySubscriptExpr>... d510 1 a510 1 Matcher<Stmt>asmStmtMatcher<AsmStmt>... d520 1 a520 16 Matcher<Stmt>atomicExprMatcher<AtomicExpr>...
Matches atomic builtins.
Example matches __atomic_load_n(ptr, 1)
  void foo() { int *ptr; __atomic_load_n(ptr, 1); }
Matcher<Stmt>binaryConditionalOperatorMatcher<BinaryConditionalOperator>...
Matches binary conditional operator expressions (GNU extension).

Example matches a ?: b
  (a ?: b) + 42;
Matcher<Stmt>binaryOperatorMatcher<BinaryOperator>... d528 1 a528 1 Matcher<Stmt>breakStmtMatcher<BreakStmt>... d538 1 a538 1 Matcher<Stmt>cStyleCastExprMatcher<CStyleCastExpr>... d541 1 a541 1 Example: Matches (int) 2.2f in d546 1 a546 1 Matcher<Stmt>callExprMatcher<CallExpr>... d556 1 a556 1 Matcher<Stmt>caseStmtMatcher<CaseStmt>... d566 1 a566 1 Matcher<Stmt>castExprMatcher<CastExpr>... d579 1 a579 1 Matcher<Stmt>characterLiteralMatcher<CharacterLiteral>... d586 1 a586 2 char ch = 'a'; wchar_t chw = L'a'; d590 1 a590 1 Matcher<Stmt>compoundLiteralExprMatcher<CompoundLiteralExpr>... d594 1 a594 2 int array[4] = {1}; vector int myvec = (vector int)(1, 2); d598 1 a598 1 Matcher<Stmt>compoundStmtMatcher<CompoundStmt>... d606 1 a606 1 Matcher<Stmt>conditionalOperatorMatcher<ConditionalOperator>... d614 1 a614 1 Matcher<Stmt>continueStmtMatcher<ContinueStmt>... d624 1 a624 1 Matcher<Stmt>cudaKernelCallExprMatcher<CUDAKernelCallExpr>... d632 1 a632 1 Matcher<Stmt>cxxBindTemporaryExprMatcher<CXXBindTemporaryExpr>... d642 1 a642 1 Matcher<Stmt>cxxBoolLiteralMatcher<CXXBoolLiteralExpr>... d650 1 a650 1 Matcher<Stmt>cxxCatchStmtMatcher<CXXCatchStmt>... d659 1 a659 1 Matcher<Stmt>cxxConstCastExprMatcher<CXXConstCastExpr>... d669 1 a669 1 Matcher<Stmt>cxxConstructExprMatcher<CXXConstructExpr>... d681 1 a681 1 Matcher<Stmt>cxxDefaultArgExprMatcher<CXXDefaultArgExpr>... d692 1 a692 1 Matcher<Stmt>cxxDeleteExprMatcher<CXXDeleteExpr>... d702 1 a702 1 Matcher<Stmt>cxxDynamicCastExprMatcher<CXXDynamicCastExpr>... d716 1 a716 1 Matcher<Stmt>cxxForRangeStmtMatcher<CXXForRangeStmt>... d725 1 a725 1 Matcher<Stmt>cxxFunctionalCastExprMatcher<CXXFunctionalCastExpr>... d735 1 a735 1 Matcher<Stmt>cxxMemberCallExprMatcher<CXXMemberCallExpr>... d744 1 a744 1 Matcher<Stmt>cxxNewExprMatcher<CXXNewExpr>... d754 1 a754 1 Matcher<Stmt>cxxNullPtrLiteralExprMatcher<CXXNullPtrLiteralExpr>... d759 1 a759 1 Matcher<Stmt>cxxOperatorCallExprMatcher<CXXOperatorCallExpr>... d775 1 a775 1 Matcher<Stmt>cxxReinterpretCastExprMatcher<CXXReinterpretCastExpr>... d787 1 a787 1 Matcher<Stmt>cxxStaticCastExprMatcher<CXXStaticCastExpr>... d790 2 a791 2 See also: hasDestinationType See also: reinterpretCast d802 1 a802 1 Matcher<Stmt>cxxTemporaryObjectExprMatcher<CXXTemporaryObjectExpr>... d810 1 a810 1 Matcher<Stmt>cxxThisExprMatcher<CXXThisExpr>... d822 1 a822 1 Matcher<Stmt>cxxThrowExprMatcher<CXXThrowExpr>... d831 1 a831 1 Matcher<Stmt>cxxTryStmtMatcher<CXXTryStmt>... d840 1 a840 1 Matcher<Stmt>cxxUnresolvedConstructExprMatcher<CXXUnresolvedConstructExpr>... d850 1 a850 1 Matcher<Stmt>declRefExprMatcher<DeclRefExpr>... d859 1 a859 1 Matcher<Stmt>declStmtMatcher<DeclStmt>... d869 1 a869 1 Matcher<Stmt>defaultStmtMatcher<DefaultStmt>... d879 1 a879 9 Matcher<Stmt>designatedInitExprMatcher<DesignatedInitExpr>...
Matches C99 designated initializer expressions [C99 6.7.8].

Example: Matches { [2].y = 1.0, [0].x = 1.0 }
  point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
Matcher<Stmt>doStmtMatcher<DoStmt>... d889 1 a889 1 Matcher<Stmt>explicitCastExprMatcher<ExplicitCastExpr>... d901 1 a901 1 See also: hasDestinationType. d910 1 a910 1 Matcher<Stmt>exprMatcher<Expr>... d918 1 a918 1 Matcher<Stmt>exprWithCleanupsMatcher<ExprWithCleanups>... d927 1 a927 1 Matcher<Stmt>floatLiteralMatcher<FloatingLiteral>... d936 1 a936 1 Matcher<Stmt>forStmtMatcher<ForStmt>... d945 1 a945 1 Matcher<Stmt>gnuNullExprMatcher<GNUNullExpr>... d950 1 a950 1 Matcher<Stmt>gotoStmtMatcher<GotoStmt>... d961 1 a961 1 Matcher<Stmt>ifStmtMatcher<IfStmt>... d969 1 a969 1 Matcher<Stmt>implicitCastExprMatcher<ImplicitCastExpr>... d977 1 a977 11 Matcher<Stmt>implicitValueInitExprMatcher<ImplicitValueInitExpr>...
Matches implicit initializers of init list expressions.

Given
  point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 };
implicitValueInitExpr()
  matches "[0].y" (implicitly)
Matcher<Stmt>initListExprMatcher<InitListExpr>... d989 1 a989 1 Matcher<Stmt>integerLiteralMatcher<IntegerLiteral>... d997 1 a997 1 Matcher<Stmt>labelStmtMatcher<LabelStmt>... d1008 1 a1008 1 Matcher<Stmt>lambdaExprMatcher<LambdaExpr>... d1016 1 a1016 1 Matcher<Stmt>materializeTemporaryExprMatcher<MaterializeTemporaryExpr>... d1032 1 a1032 1 Matcher<Stmt>memberExprMatcher<MemberExpr>... d1045 1 a1045 1 Matcher<Stmt>nullStmtMatcher<NullStmt>... d1054 1 a1054 1 Matcher<Stmt>objcMessageExprMatcher<ObjCMessageExpr>... d1065 1 a1065 45 Matcher<Stmt>opaqueValueExprMatcher<OpaqueValueExpr>...
Matches opaque value expressions. They are used as helpers
to reference another expressions and can be met
in BinaryConditionalOperators, for example.

Example matches 'a'
  (a ?: c) + 42;
Matcher<Stmt>parenExprMatcher<ParenExpr>...
Matches parentheses used in expressions.

Example matches (foo() + 1)
  int foo() { return 1; }
  int a = (foo() + 1);
Matcher<Stmt>parenListExprMatcher<ParenListExpr>...
Matches paren list expressions.
ParenListExprs don't have a predefined type and are used for late parsing.
In the final AST, they can be met in template declarations.

Given
  template<typename T> class X {
    void f() {
      X x(*this);
      int a = 0, b = 1; int i = (a, b);
    }
  };
parenListExpr() matches "*this" but NOT matches (a, b) because (a, b)
has a predefined type and is a ParenExpr, not a ParenListExpr.
Matcher<Stmt>predefinedExprMatcher<PredefinedExpr>...
Matches predefined identifier expressions [C99 6.4.2.2].

Example: Matches __func__
  printf("%s", __func__);
Matcher<Stmt>returnStmtMatcher<ReturnStmt>... d1075 1 a1075 1 Matcher<Stmt>stmtMatcher<Stmt>... d1085 1 a1085 9 Matcher<Stmt>stmtExprMatcher<StmtExpr>...
Matches statement expression (GNU extension).

Example match: ({ int X = 4; X; })
  int C = ({ int X = 4; X; });
Matcher<Stmt>stringLiteralMatcher<StringLiteral>... d1089 1 a1089 2 char *s = "abcd"; wchar_t *ws = L"abcd"; d1093 1 a1093 1 Matcher<Stmt>substNonTypeTemplateParmExprMatcher<SubstNonTypeTemplateParmExpr>... d1105 1 a1105 1 Matcher<Stmt>switchCaseMatcher<SwitchCase>... d1115 1 a1115 1 Matcher<Stmt>switchStmtMatcher<SwitchStmt>... d1125 1 a1125 1 Matcher<Stmt>unaryExprOrTypeTraitExprMatcher<UnaryExprOrTypeTraitExpr>... d1136 1 a1136 1 Matcher<Stmt>unaryOperatorMatcher<UnaryOperator>... d1144 1 a1144 16 Matcher<Stmt>unresolvedLookupExprMatcher<UnresolvedLookupExpr>...
Matches reference to a name that can be looked up during parsing
but could not be resolved to a specific declaration.

Given
  template<typename T>
  T foo() { T a; return a; }
  template<typename T>
  void bar() {
    foo<T>();
  }
unresolvedLookupExpr()
  matches foo<T>() 
Matcher<Stmt>userDefinedLiteralMatcher<UserDefinedLiteral>... d1151 1 a1151 1 Matcher<Stmt>whileStmtMatcher<WhileStmt>... d1161 1 a1161 1 Matcher<TemplateArgument>templateArgumentMatcher<TemplateArgument>... d1172 1 a1172 12 Matcher<TemplateName>templateNameMatcher<TemplateName>...
Matches template name.

Given
  template <typename T> class X { };
  X<int> xi;
templateName()
  matches 'X' in X<int>.
Matcher<TypeLoc>typeLocMatcher<TypeLoc>... d1177 1 a1177 1 Matcher<Type>arrayTypeMatcher<ArrayType>... d1189 1 a1189 1 Matcher<Type>atomicTypeMatcher<AtomicType>... d1199 1 a1199 1 Matcher<Type>autoTypeMatcher<AutoType>... d1211 1 a1211 1 Matcher<Type>blockPointerTypeMatcher<BlockPointerType>... d1219 1 a1219 1 Matcher<Type>builtinTypeMatcher<BuiltinType>... d1233 1 a1233 1 Matcher<Type>complexTypeMatcher<ComplexType>... d1243 1 a1243 1 Matcher<Type>constantArrayTypeMatcher<ConstantArrayType>... d1257 1 a1257 1 Matcher<Type>decayedTypeMatcher<DecayedType>... d1269 1 a1269 1 Matcher<Type>dependentSizedArrayTypeMatcher<DependentSizedArrayType>... d1282 1 a1282 1 Matcher<Type>elaboratedTypeMatcher<ElaboratedType>... d1302 1 a1302 28 Matcher<Type>enumTypeMatcher<EnumType>...
Matches enum types.

Given
  enum C { Green };
  enum class S { Red };

  C c;
  S s;

enumType() matches the type of the variable declarations of both c and
s.
Matcher<Type>functionProtoTypeMatcher<FunctionProtoType>...
Matches FunctionProtoType nodes.

Given
  int (*f)(int);
  void g();
functionProtoType()
  matches "int (*f)(int)" and the type of "g" in C++ mode.
  In C mode, "g" is not matched because it does not contain a prototype.
Matcher<Type>functionTypeMatcher<FunctionType>... d1313 1 a1313 1 Matcher<Type>incompleteArrayTypeMatcher<IncompleteArrayType>... d1325 1 a1325 1 Matcher<Type>injectedClassNameTypeMatcher<InjectedClassNameType>... d1337 1 a1337 1 Matcher<Type>lValueReferenceTypeMatcher<LValueReferenceType>... d1354 1 a1354 1 Matcher<Type>memberPointerTypeMatcher<MemberPointerType>... d1364 1 a1364 1 Matcher<Type>objcObjectPointerTypeMatcher<ObjCObjectPointerType>... d1379 1 a1379 1 Matcher<Type>parenTypeMatcher<ParenType>... d1391 1 a1391 1 Matcher<Type>pointerTypeMatcher<PointerType>... d1408 1 a1408 1 Matcher<Type>rValueReferenceTypeMatcher<RValueReferenceType>... d1425 1 a1425 1 Matcher<Type>recordTypeMatcher<RecordType>... d1440 1 a1440 1 Matcher<Type>referenceTypeMatcher<ReferenceType>... d1456 1 a1456 1 Matcher<Type>substTemplateTypeParmTypeMatcher<SubstTemplateTypeParmType>... d1470 1 a1470 1 Matcher<Type>templateSpecializationTypeMatcher<TemplateSpecializationType>... d1485 1 a1485 1 Matcher<Type>templateTypeParmTypeMatcher<TemplateTypeParmType>... d1494 1 a1494 1 Matcher<Type>typeMatcher<Type>... d1499 1 a1499 1 Matcher<Type>typedefTypeMatcher<TypedefType>... d1509 1 a1509 1 Matcher<Type>unaryTransformTypeMatcher<UnaryTransformType>... d1519 1 a1519 1 Matcher<Type>variableArrayTypeMatcher<VariableArrayType>... d1591 1 a1591 1 Matcher<BinaryOperator>hasOperatorNamestd::string Name d1606 2 a1607 2 Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteral>, Matcher<FloatingLiteral>, Matcher<IntegerLiteral> d1611 1 a1611 1 Matcher<CXXCatchStmt>isCatchAll d1627 1 a1627 1 Matcher<CXXConstructExpr>argumentCountIsunsigned N d1637 1 a1637 1 Matcher<CXXConstructExpr>isListInitialization d1642 1 a1642 15 Matcher<CXXConstructExpr>requiresZeroInitialization
Matches a constructor call expression which requires
zero initialization.

Given
void foo() {
  struct point { double x; double y; };
  point pt[2] = { { 1.0, 2.0 } };
}
initListExpr(has(cxxConstructExpr(requiresZeroInitialization()))
will match the implicit array filler for pt[1].
Matcher<CXXConstructorDecl>isCopyConstructor d1655 1 a1655 1 Matcher<CXXConstructorDecl>isDefaultConstructor d1668 1 a1668 16 Matcher<CXXConstructorDecl>isDelegatingConstructor
Matches constructors that delegate to another constructor.

Given
  struct S {
    S(); #1
    S(int) {} #2
    S(S &&) : S() {} #3
  };
  S::S() : S(0) {} #4
cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not
#1 or #2.
Matcher<CXXConstructorDecl>isExplicit d1684 1 a1684 1 Matcher<CXXConstructorDecl>isMoveConstructor d1697 1 a1697 1 Matcher<CXXConversionDecl>isExplicit d1713 1 a1713 1 Matcher<CXXCtorInitializer>isBaseInitializer d1731 1 a1731 1 Matcher<CXXCtorInitializer>isMemberInitializer d1749 1 a1749 1 Matcher<CXXCtorInitializer>isWritten d1764 1 a1764 1 Matcher<CXXMethodDecl>isConst d1777 1 a1777 1 Matcher<CXXMethodDecl>isCopyAssignmentOperator d1792 1 a1792 1 Matcher<CXXMethodDecl>isFinal d1809 1 a1809 16 Matcher<CXXMethodDecl>isMoveAssignmentOperator
Matches if the given method declaration declares a move assignment
operator.

Given
struct A {
  A &operator=(const A &);
  A &operator=(A &&);
};

cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not
the first one.
Matcher<CXXMethodDecl>isOverride d1825 1 a1825 1 Matcher<CXXMethodDecl>isPure d1837 1 a1837 14 Matcher<CXXMethodDecl>isUserProvided
Matches method declarations that are user-provided.

Given
  struct S {
    S(); #1
    S(const S &) = default; #2
    S(S &&) = delete; #3
  };
cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.
Matcher<CXXMethodDecl>isVirtual d1849 1 a1849 17 Matcher<CXXMethodDecl>isVirtualAsWritten
Matches if the given method declaration has an explicit "virtual".

Given
  class A {
   public:
    virtual void x();
  };
  class B : public A {
   public:
    void x();
  };
  matches A::x but not B::x
Matcher<CXXOperatorCallExpr>hasOverloadedOperatorNameStringRef Name d1866 1 a1866 1 Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl> d1870 1 a1870 1 Matcher<CXXRecordDecl>isDerivedFromstd::string BaseName d1875 1 a1875 1 Matcher<CXXRecordDecl>isExplicitTemplateSpecialization d1885 1 a1885 1 Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl> d1889 1 a1889 1 Matcher<CXXRecordDecl>isFinal d1906 1 a1906 12 Matcher<CXXRecordDecl>isLambda
Matches the generated class of lambda expressions.

Given:
  auto x = []{};

cxxRecordDecl(isLambda()) matches the implicit class declaration of
decltype(x)
Matcher<CXXRecordDecl>isSameOrDerivedFromstd::string BaseName d1912 1 a1912 1 Matcher<CXXRecordDecl>isTemplateInstantiation d1929 1 a1929 1 Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl> d1933 1 a1933 1 Matcher<CallExpr>argumentCountIsunsigned N d1943 1 a1943 10 Matcher<CastExpr>hasCastKindCastKind Kind
Matches casts that has a given cast kind.

Example: matches the implicit cast around 0
(matcher = castExpr(hasCastKind(CK_NullToPointer)))
  int *p = 0;
Matcher<CharacterLiteral>equalsValueT Value d1949 2 a1950 2 Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteral>, Matcher<FloatingLiteral>, Matcher<IntegerLiteral> d1954 1 a1954 1 Matcher<ClassTemplateSpecializationDecl>templateArgumentCountIsunsigned N d1965 1 a1965 1 Matcher<CompoundStmt>statementCountIsunsigned N d1977 2 a1978 2 Matcher<ConstantArrayType>hasSizeunsigned N
Matches nodes that have the specified size.
a1983 3
  char *s = "abcd";
  wchar_t *ws = L"abcd";
  char *w = "a";
a1985 2
stringLiteral(hasSize(4))
  matches "abcd", L"abcd"
d1989 1
a1989 1
Matcher<DeclStmt>declCountIsunsigned N
d2002 1
a2002 1
Matcher<Decl>equalsBoundNodestd::string ID
d2025 1
a2025 8
Matcher<Decl>equalsNodeconst Decl* Other
Matches if a node equals another node.

Decl has pointer identity in the AST.
Matcher<Decl>hasAttrattr::Kind AttrKind d2036 1 a2036 1 Matcher<Decl>isExpansionInFileMatchingstd::string RegExp d2047 1 a2047 1 Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc> d2051 1 a2051 1 Matcher<Decl>isExpansionInMainFile d2061 1 a2061 1 Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc> d2065 1 a2065 1 Matcher<Decl>isExpansionInSystemHeader d2075 1 a2075 1 Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc> d2079 1 a2079 1 Matcher<Decl>isImplicit d2085 1 a2085 1 Matcher<Decl>isPrivate d2095 1 a2095 1 matches 'int c;' d2099 1 a2099 1 Matcher<Decl>isProtected d2109 1 a2109 1 matches 'int b;' d2113 1 a2113 1 Matcher<Decl>isPublic d2123 1 a2123 42 matches 'int a;'
Matcher<DesignatedInitExpr>designatorCountIsunsigned N
Matches designated initializer expressions that contain
a specific number of designators.

Example: Given
  point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
  point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 };
designatorCountIs(2)
  matches '{ [2].y = 1.0, [0].x = 1.0 }',
  but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'.
Matcher<FieldDecl>hasBitWidthunsigned Width
Matches non-static data members that are bit-fields of the specified
bit width.

Given
  class C {
    int a : 2;
    int b : 4;
    int c : 2;
  };
fieldDecl(hasBitWidth(2))
  matches 'int a;' and 'int c;' but not 'int b;'.
Matcher<FieldDecl>isBitField
Matches non-static data members that are bit-fields.

Given
  class C {
    int a : 2;
    int b;
  };
fieldDecl(isBitField())
  matches 'int a;' but not 'int b;'.
d2127 1
a2127 1
Matcher<FloatingLiteral>equalsValueT  Value
d2133 2
a2134 19
Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteral>,
           Matcher<FloatingLiteral>, Matcher<IntegerLiteral>
Matcher<FunctionDecl>hasDynamicExceptionSpec
Matches functions that have a dynamic exception specification.

Given:
  void f();
  void g() noexcept;
  void h() noexcept(true);
  void i() noexcept(false);
  void j() throw();
  void k() throw(int);
  void l() throw(...);
functionDecl(hasDynamicExceptionSpec()) and
  functionProtoType(hasDynamicExceptionSpec())
  match the declarations of j, k, and l, but not f, g, h, or i.
d2138 1
a2138 1
Matcher<FunctionDecl>hasOverloadedOperatorNameStringRef Name
d2155 1
a2155 1
Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl>
d2159 1
a2159 1
Matcher<FunctionDecl>isConstexpr
d2172 1
a2172 12
Matcher<FunctionDecl>isDefaulted
Matches defaulted function declarations.

Given:
  class A { ~A(); };
  class B { ~B() = default; };
functionDecl(isDefaulted())
  matches the declaration of ~B, but not ~A.
Matcher<FunctionDecl>isDefinition d2183 1 a2183 1 Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl> d2187 1 a2187 1 Matcher<FunctionDecl>isDeleted d2198 1 a2198 1 Matcher<FunctionDecl>isExplicitTemplateSpecialization d2208 1 a2208 1 Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl> d2212 1 a2212 1 Matcher<FunctionDecl>isExternC d2224 1 a2224 1 Matcher<FunctionDecl>isInline d2239 1 a2239 1 Matcher<FunctionDecl>isNoThrow d2248 2 a2249 2 functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) match the declarations of g, and h, but not f, i or j. d2253 1 a2253 17 Matcher<FunctionDecl>isStaticStorageClass
Matches variablefunction declarations that have "static" storage
class specifier ("static" keyword) written in the source.

Given:
  static void f() {}
  static int i = 0;
  extern int j;
  int k;
functionDecl(isStaticStorageClass())
  matches the function declaration f.
varDecl(isStaticStorageClass())
  matches the variable declaration i.
Matcher<FunctionDecl>isTemplateInstantiation d2270 1 a2270 1 Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl> d2274 1 a2274 1 Matcher<FunctionDecl>isVariadic d2286 2 a2287 53 Matcher<FunctionDecl>parameterCountIsunsigned N
Matches FunctionDecls and FunctionProtoTypes that have a
specific parameter count.

Given
  void f(int i) {}
  void g(int i, int j) {}
  void h(int i, int j);
  void j(int i);
  void k(int x, int y, int z, ...);
functionDecl(parameterCountIs(2))
  matches void g(int i, int j) {}
functionProtoType(parameterCountIs(2))
  matches void h(int i, int j)
functionProtoType(parameterCountIs(3))
  matches void k(int x, int y, int z, ...);
Matcher<FunctionProtoType>hasDynamicExceptionSpec
Matches functions that have a dynamic exception specification.

Given:
  void f();
  void g() noexcept;
  void h() noexcept(true);
  void i() noexcept(false);
  void j() throw();
  void k() throw(int);
  void l() throw(...);
functionDecl(hasDynamicExceptionSpec()) and
  functionProtoType(hasDynamicExceptionSpec())
  match the declarations of j, k, and l, but not f, g, h, or i.
Matcher<FunctionProtoType>isNoThrow
Matches functions that have a non-throwing exception specification.

Given:
  void f();
  void g() noexcept;
  void h() throw();
  void i() throw(int);
  void j() noexcept(false);
functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
  match the declarations of g, and h, but not f, i or j.
Matcher<FunctionProtoType>parameterCountIsunsigned N
Matches FunctionDecls and FunctionProtoTypes that have a
specific parameter count.
a2291 3
  void h(int i, int j);
  void j(int i);
  void k(int x, int y, int z, ...);
d2293 1
a2293 5
  matches void g(int i, int j) {}
functionProtoType(parameterCountIs(2))
  matches void h(int i, int j)
functionProtoType(parameterCountIs(3))
  matches void k(int x, int y, int z, ...);
d2297 1
a2297 1
Matcher<IntegerLiteral>equalsValueT  Value
d2303 2
a2304 2
Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteral>,
           Matcher<FloatingLiteral>, Matcher<IntegerLiteral>
d2308 1
a2308 1
Matcher<MemberExpr>isArrow
d2325 1
a2325 21
Matcher<NamedDecl>hasExternalFormalLinkage
Matches a declaration that has external formal linkage.

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

Example matches f() because it has external formal linkage despite being
unique to the translation unit as though it has internal likage
(matcher = functionDecl(hasExternalFormalLinkage()))

namespace {
void f() {}
}
Matcher<NamedDecl>hasNamestd::string Name d2340 1 a2340 1 Matcher<NamedDecl>matchesNamestd::string RegExp d2356 1 a2356 1 Matcher<NamespaceDecl>isAnonymous d2367 1 a2367 1 Matcher<NamespaceDecl>isInline d2382 1 a2382 1 Matcher<ObjCMessageExpr>argumentCountIsunsigned N d2392 1 a2392 1 Matcher<ObjCMessageExpr>hasKeywordSelector d2406 1 a2406 1 Matcher<ObjCMessageExpr>hasNullSelector d2414 1 a2414 1 Matcher<ObjCMessageExpr>hasSelectorstd::string BaseName d2424 1 a2424 1 Matcher<ObjCMessageExpr>hasUnarySelector d2434 1 a2434 1 Matcher<ObjCMessageExpr>matchesSelectorstd::string RegExp d2443 1 a2443 1 Matcher<ObjCMessageExpr>numSelectorArgsunsigned N d2456 1 a2456 1 Matcher<QualType>asStringstd::string Name d2467 1 a2467 1 Matcher<QualType>equalsBoundNodestd::string ID d2490 1 a2490 1 Matcher<QualType>hasLocalQualifiers d2505 1 a2505 1 Matcher<QualType>isAnyCharacter d2517 1 a2517 19 Matcher<QualType>isAnyPointer
Matches QualType nodes that are of any pointer type; this includes
the Objective-C object pointer type, which is different despite being
syntactically similar.

Given
  int *i = nullptr;

  @@interface Foo
  @@end
  Foo *f;

  int j;
varDecl(hasType(isAnyPointer()))
  matches "int *i" and "Foo *f", but not "int j".
Matcher<QualType>isConstQualified d2534 1 a2534 1 Matcher<QualType>isInteger d2546 1 a2546 25 Matcher<QualType>isSignedInteger
Matches QualType nodes that are of signed integer type.

Given
  void a(int);
  void b(unsigned long);
  void c(double);
functionDecl(hasAnyParameter(hasType(isSignedInteger())))
matches "a(int)", but not "b(unsigned long)" and "c(double)".
Matcher<QualType>isUnsignedInteger
Matches QualType nodes that are of unsigned integer type.

Given
  void a(int);
  void b(unsigned long);
  void c(double);
functionDecl(hasAnyParameter(hasType(isUnsignedInteger())))
matches "b(unsigned long)", but not "a(int)" and "c(double)".
Matcher<QualType>isVolatileQualified d2563 1 a2563 1 Matcher<RecordDecl>isClass d2573 1 a2573 1 Matcher<RecordDecl>isStruct d2583 1 a2583 1 Matcher<RecordDecl>isUnion d2593 1 a2593 1 Matcher<Stmt>equalsBoundNodestd::string ID d2616 1 a2616 8 Matcher<Stmt>equalsNodeconst Stmt* Other
Matches if a node equals another node.

Stmt has pointer identity in the AST.
Matcher<Stmt>isExpansionInFileMatchingstd::string RegExp d2627 1 a2627 1 Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc> d2631 1 a2631 1 Matcher<Stmt>isExpansionInMainFile d2641 1 a2641 1 Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc> d2645 1 a2645 1 Matcher<Stmt>isExpansionInSystemHeader d2655 1 a2655 1 Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc> d2659 2 a2660 19 Matcher<StringLiteral>hasSizeunsigned N
Matches nodes that have the specified size.

Given
  int a[42];
  int b[2 * 21];
  int c[41], d[43];
  char *s = "abcd";
  wchar_t *ws = L"abcd";
  char *w = "a";
constantArrayType(hasSize(42))
  matches "int a[42]" and "int b[2 * 21]"
stringLiteral(hasSize(4))
  matches "abcd", L"abcd"
Matcher<TagDecl>isDefinition
Matches if a declaration has a body attached.
d2670 1
a2670 1
Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>
d2674 1
a2674 1
Matcher<TemplateArgument>equalsIntegralValuestd::string Value
d2690 1
a2690 1
Matcher<TemplateArgument>isIntegral
d2703 1
a2703 1
Matcher<TemplateSpecializationType>templateArgumentCountIsunsigned N
d2714 1
a2714 1
Matcher<TypeLoc>isExpansionInFileMatchingstd::string RegExp
d2725 1
a2725 1
Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
d2729 1
a2729 1
Matcher<TypeLoc>isExpansionInMainFile
d2739 1
a2739 1
Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
d2743 1
a2743 1
Matcher<TypeLoc>isExpansionInSystemHeader
d2753 1
a2753 1
Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
d2757 1
a2757 1
Matcher<Type>booleanType
d2767 1
a2767 1
Matcher<Type>equalsBoundNodestd::string ID
d2790 1
a2790 19
Matcher<Type>equalsNodeconst Type* Other
Matches if a node equals another node.

Type has pointer identity in the AST.
Matcher<Type>realFloatingPointType
Matches any real floating-point type (float, double, long double).

Given
  int i;
  float f;
realFloatingPointType()
  matches "float f" but not "int i"
Matcher<Type>voidType d2800 1 a2800 1 Matcher<UnaryExprOrTypeTraitExpr>ofKindUnaryExprOrTypeTrait Kind d2811 1 a2811 1 Matcher<UnaryOperator>hasOperatorNamestd::string Name d2820 1 a2820 1 Matcher<VarDecl>hasAutomaticStorageDuration d2834 1 a2834 1 Matcher<VarDecl>hasGlobalStorage d2846 1 a2846 1 Matcher<VarDecl>hasLocalStorage d2859 1 a2859 1 Matcher<VarDecl>hasStaticStorageDuration a2860 2 It includes the variable declared at namespace scope and those declared with "static" and "extern" storage class specifiers. d2862 2 a2869 4 static int b; extern int c; varDecl(hasStaticStorageDuration()) matches the function declaration y, a, b and c. d2873 1 a2873 1 Matcher<VarDecl>hasThreadStorageDuration d2887 1 a2887 1 Matcher<VarDecl>isConstexpr d2900 1 a2900 1 Matcher<VarDecl>isDefinition d2911 1 a2911 1 Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl> d2915 1 a2915 1 Matcher<VarDecl>isExceptionVariable d2928 1 a2928 1 Matcher<VarDecl>isExplicitTemplateSpecialization d2938 1 a2938 29 Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
Matcher<VarDecl>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<VarDecl>isStaticStorageClass
Matches variablefunction declarations that have "static" storage
class specifier ("static" keyword) written in the source.

Given:
  static void f() {}
  static int i = 0;
  extern int j;
  int k;
functionDecl(isStaticStorageClass())
  matches the function declaration f.
varDecl(isStaticStorageClass())
  matches the variable declaration i.
d2942 1
a2942 1
Matcher<VarDecl>isTemplateInstantiation
d2959 1
a2959 1
Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
d2963 1
a2963 1
Matcher<internal::Matcher<Decl>>isInstantiated
d2976 1
a2976 28
Matcher<internal::Matcher<Expr>>nullPointerConstant
Matches expressions that resolve to a null pointer constant, such as
GNU's __null, C++11's nullptr, or C's NULL macro.

Given:
  void *v1 = NULL;
  void *v2 = nullptr;
  void *v3 = __null; GNU extension
  char *cp = (char *)0;
  int *ip = 0;
  int i = 0;
expr(nullPointerConstant())
  matches the initializer for v1, v2, v3, cp, and ip. Does not match the
  initializer for i.
Matcher<internal::Matcher<NamedDecl>>hasAnyNameStringRef, ..., StringRef
Matches NamedDecl nodes that have any of the specified names.

This matcher is only provided as a performance optimization of hasName.
    hasAnyName(a, b, c)
 is equivalent to, but faster than
    anyOf(hasName(a), hasName(b), hasName(c))
Matcher<internal::Matcher<Stmt>>isInTemplateInstantiation a3114 4 Note that has is direct matcher, so it also matches things like implicit casts and paren casts. If you are matching with expr then you should probably consider using ignoringParenImpCasts like: has(ignoringParenImpCasts(expr())). d3130 1 a3130 55 Matcher<AbstractConditionalOperator>hasConditionMatcher<Expr> InnerMatcher
Matches the condition expression of an if statement, for loop,
switch statement or conditional operator.

Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
  if (true) {}
Matcher<AbstractConditionalOperator>hasFalseExpressionMatcher<Expr> InnerMatcher
Matches the false branch expression of a conditional operator
(binary or ternary).

Example matches b
  condition ? a : b
  condition ?: b
Matcher<AbstractConditionalOperator>hasTrueExpressionMatcher<Expr> InnerMatcher
Matches the true branch expression of a conditional operator.

Example 1 (conditional ternary operator): matches a
  condition ? a : b

Example 2 (conditional binary operator): matches opaqueValueExpr(condition)
  condition ?: b
Matcher<AddrLabelExpr>hasDeclarationMatcher<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
- for CXXNewExpr, the declaration of the operator new

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<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, 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<ArraySubscriptExpr>hasBaseMatcher<Expr> InnerMatcher d3142 1 a3142 1 Matcher<ArraySubscriptExpr>hasIndexMatcher<Expr> InnerMatcher d3153 1 a3153 1 Matcher<ArraySubscriptExpr>hasLHSMatcher<Expr> InnerMatcher d3161 1 a3161 1 Matcher<ArraySubscriptExpr>hasRHSMatcher<Expr> InnerMatcher d3169 1 a3169 1 Matcher<ArrayTypeLoc>hasElementTypeLocMatcher<TypeLoc> d3180 1 a3180 1 Usable as: Matcher<ArrayType>, Matcher<ComplexType> d3184 1 a3184 1 Matcher<ArrayType>hasElementTypeMatcher<Type> d3195 1 a3195 1 Usable as: Matcher<ArrayType>, Matcher<ComplexType> d3199 1 a3199 1 Matcher<AtomicTypeLoc>hasValueTypeLocMatcher<TypeLoc> d3208 1 a3208 1 Usable as: Matcher<AtomicType> d3212 1 a3212 1 Matcher<AtomicType>hasValueTypeMatcher<Type> d3221 1 a3221 1 Usable as: Matcher<AtomicType> d3225 1 a3225 1 Matcher<AutoType>hasDeducedTypeMatcher<Type> d3237 1 a3237 1 Usable as: Matcher<AutoType> d3241 1 a3241 1 Matcher<BinaryOperator>hasEitherOperandMatcher<Expr> InnerMatcher d3247 1 a3247 1 Matcher<BinaryOperator>hasLHSMatcher<Expr> InnerMatcher d3255 1 a3255 1 Matcher<BinaryOperator>hasRHSMatcher<Expr> InnerMatcher d3263 1 a3263 1 Matcher<BlockPointerTypeLoc>pointeeLocMatcher<TypeLoc> d3274 2 a3275 2 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType> d3279 1 a3279 1 Matcher<BlockPointerType>pointeeMatcher<Type> d3290 2 a3291 22 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType>
Matcher<CXXConstructExpr>forEachArgumentWithParamMatcher<Expr> ArgMatcher, Matcher<ParmVarDecl> ParamMatcher
Matches all arguments and their respective ParmVarDecl.

Given
  void f(int i);
  int y;
  f(y);
callExpr(
  forEachArgumentWithParam(
    declRefExpr(to(varDecl(hasName("y")))),
    parmVarDecl(hasType(isInteger()))
))
  matches f(y);
with declRefExpr(...)
  matching int y
and parmVarDecl(...)
  matching int i
d3295 1
a3295 1
Matcher<CXXConstructExpr>hasAnyArgumentMatcher<Expr> InnerMatcher
d3305 5
d3313 1
a3313 1
Matcher<CXXConstructExpr>hasArgumentunsigned N, Matcher<Expr> InnerMatcher
d3323 2
a3324 2
Matcher<CXXConstructExpr>hasDeclarationMatcher<Decl>  InnerMatcher
Matches a node if the declaration associated with that node
a3331 1
- for CXXNewExpr, the declaration of the operator new
d3336 6
a3341 7
Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
  Matcher<TagType>, Matcher<TemplateSpecializationType>,
  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
  Matcher<UnresolvedUsingType>
d3345 1
a3345 1
Matcher<CXXConstructorDecl>forEachConstructorInitializerMatcher<CXXCtorInitializer> InnerMatcher
d3357 1
a3357 1
Matcher<CXXConstructorDecl>hasAnyConstructorInitializerMatcher<CXXCtorInitializer> InnerMatcher
d3372 1
a3372 1
Matcher<CXXCtorInitializer>forFieldMatcher<FieldDecl> InnerMatcher
d3387 1
a3387 1
Matcher<CXXCtorInitializer>withInitializerMatcher<Expr> InnerMatcher
d3402 3
a3404 3
Matcher<CXXForRangeStmt>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
definition that has a given body.
d3415 1
a3415 1
Matcher<CXXForRangeStmt>hasLoopVariableMatcher<VarDecl> InnerMatcher
d3425 1
a3425 1
Matcher<CXXForRangeStmt>hasRangeInitMatcher<Expr> InnerMatcher
d3435 1
a3435 1
Matcher<CXXMemberCallExpr>onImplicitObjectArgumentMatcher<Expr> InnerMatcher
d3439 1
a3439 1
Matcher<CXXMemberCallExpr>onMatcher<Expr> InnerMatcher
d3451 1
a3451 1
Matcher<CXXMemberCallExpr>thisPointerTypeMatcher<Decl> InnerMatcher
d3456 1
a3456 1
Matcher<CXXMemberCallExpr>thisPointerTypeMatcher<QualType> InnerMatcher
d3462 1
a3462 25
Matcher<CXXMethodDecl>forEachOverriddenMatcher<CXXMethodDecl> InnerMatcher
Matches each method overriden by the given method. This matcher may
produce multiple matches.

Given
  class A { virtual void f(); };
  class B : public A { void f(); };
  class C : public B { void f(); };
cxxMethodDecl(ofClass(hasName("C")),
              forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
  matches once, with "b" binding "A::f" and "d" binding "C::f" (Note
  that B::f is not overridden by C::f).

The check can produce multiple matches in case of multiple inheritance, e.g.
  class A1 { virtual void f(); };
  class A2 { virtual void f(); };
  class C : public A1, public A2 { void f(); };
cxxMethodDecl(ofClass(hasName("C")),
              forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
  matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and
  once with "b" binding "A2::f" and "d" binding "C::f".
Matcher<CXXMethodDecl>ofClassMatcher<CXXRecordDecl> InnerMatcher d3481 1 a3481 25 Matcher<CXXNewExpr>hasDeclarationMatcher<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
- for CXXNewExpr, the declaration of the operator new

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<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, 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<CXXRecordDecl>hasMethodMatcher<CXXMethodDecl> InnerMatcher d3493 1 a3493 1 Matcher<CXXRecordDecl>isDerivedFromMatcher<NamedDecl> Base d3514 1 a3514 1 Matcher<CXXRecordDecl>isSameOrDerivedFromMatcher<NamedDecl> Base d3520 1 a3520 1 Matcher<CallExpr>calleeMatcher<Decl> InnerMatcher d3531 1 a3531 1 Matcher<CallExpr>calleeMatcher<Stmt> InnerMatcher d3542 1 a3542 1 Note: Callee cannot take the more general internal::Matcher<Expr> d3544 1 a3544 1 internal::Matcher<Decl>, as the matcher hierarchy is purely d3549 1 a3549 21 Matcher<CallExpr>forEachArgumentWithParamMatcher<Expr> ArgMatcher, Matcher<ParmVarDecl> ParamMatcher
Matches all arguments and their respective ParmVarDecl.

Given
  void f(int i);
  int y;
  f(y);
callExpr(
  forEachArgumentWithParam(
    declRefExpr(to(varDecl(hasName("y")))),
    parmVarDecl(hasType(isInteger()))
))
  matches f(y);
with declRefExpr(...)
  matching int y
and parmVarDecl(...)
  matching int i
Matcher<CallExpr>hasAnyArgumentMatcher<Expr> InnerMatcher d3559 5 d3567 1 a3567 1 Matcher<CallExpr>hasArgumentunsigned N, Matcher<Expr> InnerMatcher d3577 2 a3578 2 Matcher<CallExpr>hasDeclarationMatcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
a3585 1
- for CXXNewExpr, the declaration of the operator new
d3590 6
a3595 7
Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
  Matcher<TagType>, Matcher<TemplateSpecializationType>,
  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
  Matcher<UnresolvedUsingType>
d3599 1
a3599 1
Matcher<CaseStmt>hasCaseConstantMatcher<Expr> InnerMatcher
d3610 8
a3617 2
Matcher<CastExpr>hasSourceExpressionMatcher<Expr> InnerMatcher

d3620 3
a3622 4
Matcher<ClassTemplateSpecializationDecl>hasAnyTemplateArgumentMatcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
functionDecl that have at least one TemplateArgument matching the given
InnerMatcher.
a3627 4

  template<typename T> f() {};
  void func() { f<int>(); };

a3630 3

functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
  matches the specialization f<int>
d3634 3
a3636 3
Matcher<ClassTemplateSpecializationDecl>hasTemplateArgumentunsigned N, Matcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
a3641 3

  template<typename T> f() {};
  void func() { f<int>(); };
a3644 3

functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
  matches the specialization f<int>
d3648 1
a3648 1
Matcher<ComplexTypeLoc>hasElementTypeLocMatcher<TypeLoc>
d3659 1
a3659 1
Usable as: Matcher<ArrayType>, Matcher<ComplexType>
d3663 1
a3663 1
Matcher<ComplexType>hasElementTypeMatcher<Type>
d3674 1
a3674 1
Usable as: Matcher<ArrayType>, Matcher<ComplexType>
d3678 1
a3678 1
Matcher<CompoundStmt>hasAnySubstatementMatcher<Stmt> InnerMatcher
d3680 1
a3680 1
a given matcher. Also matches StmtExprs that have CompoundStmt as children.
d3691 26
a3716 1
Matcher<DecayedType>hasDecayedTypeMatcher<QualType> InnerType
d3721 1
a3721 1
Matcher<DeclRefExpr>hasDeclarationMatcher<Decl>  InnerMatcher
a3729 1
- for CXXNewExpr, the declaration of the operator new
d3734 6
a3739 7
Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
  Matcher<TagType>, Matcher<TemplateSpecializationType>,
  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
  Matcher<UnresolvedUsingType>
d3743 1
a3743 1
Matcher<DeclRefExpr>throughUsingDeclMatcher<UsingShadowDecl> InnerMatcher
d3759 1
a3759 1
Matcher<DeclRefExpr>toMatcher<Decl> InnerMatcher
d3770 1
a3770 1
Matcher<DeclStmt>containsDeclarationunsigned N, Matcher<Decl> InnerMatcher
d3789 1
a3789 1
Matcher<DeclStmt>hasSingleDeclMatcher<Decl> InnerMatcher
d3800 1
a3800 1
Matcher<DeclaratorDecl>hasTypeLocMatcher<TypeLoc> Inner
d3811 1
a3811 1
Matcher<Decl>hasDeclContextMatcher<Decl> InnerMatcher
d3827 3
a3829 3
Matcher<DoStmt>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
definition that has a given body.
d3840 1
a3840 1
Matcher<DoStmt>hasConditionMatcher<Expr> InnerMatcher
d3842 1
a3842 1
switch statement or conditional operator.
d3849 1
a3849 1
Matcher<ElaboratedType>hasQualifierMatcher<NestedNameSpecifier> InnerMatcher
d3866 1
a3866 1
Matcher<ElaboratedType>namesTypeMatcher<QualType> InnerMatcher
d3883 1
a3883 1
Matcher<EnumType>hasDeclarationMatcher<Decl>  InnerMatcher
a3891 1
- for CXXNewExpr, the declaration of the operator new
d3896 6
a3901 7
Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
  Matcher<TagType>, Matcher<TemplateSpecializationType>,
  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
  Matcher<UnresolvedUsingType>
d3905 1
a3905 1
Matcher<ExplicitCastExpr>hasDestinationTypeMatcher<QualType> InnerMatcher
d3913 2
a3914 2
Matcher<Expr>hasTypeMatcher<Decl> InnerMatcher
Overloaded to match the declaration of the expression's or value
d3928 1
a3928 1
Usable as: Matcher<Expr>, Matcher<ValueDecl>
d3932 1
a3932 1
Matcher<Expr>hasTypeMatcher<QualType> InnerMatcher
a3937 1
            and U (matcher = typedefDecl(hasType(asString("int")))
a3939 1
 typedef int U;
d3943 1
a3943 1
Matcher<Expr>ignoringImpCastsMatcher<Expr> InnerMatcher
d3966 1
a3966 20
Matcher<Expr>ignoringImplicitast_matchers::Matcher<Expr> InnerMatcher
Matches expressions that match InnerMatcher after any implicit AST
nodes are stripped off.

Parentheses and explicit casts are not discarded.
Given
  class C {};
  C a = C();
  C b;
  C c = b;
The matchers
   varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr())))
would match the declarations for a, b, and c.
While
   varDecl(hasInitializer(cxxConstructExpr()))
only match the declarations for b and c.
Matcher<Expr>ignoringParenCastsMatcher<Expr> InnerMatcher d3985 1 a3985 1 Matcher<Expr>ignoringParenImpCastsMatcher<Expr> InnerMatcher d4008 3 a4010 19 Matcher<FieldDecl>hasInClassInitializerMatcher<Expr> InnerMatcher
Matches non-static data members that have an in-class initializer.

Given
  class C {
    int a = 2;
    int b = 3;
    int c;
  };
fieldDecl(hasInClassInitializer(integerLiteral(equals(2))))
  matches 'int a;' but not 'int b;'.
fieldDecl(hasInClassInitializer(anything()))
  matches 'int a;' and 'int b;' but not 'int c;'.
Matcher<ForStmt>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
definition that has a given body.
d4021 1
a4021 1
Matcher<ForStmt>hasConditionMatcher<Expr> InnerMatcher
d4023 1
a4023 1
switch statement or conditional operator.
d4030 1
a4030 1
Matcher<ForStmt>hasIncrementMatcher<Stmt> InnerMatcher
d4040 1
a4040 1
Matcher<ForStmt>hasLoopInitMatcher<Stmt> InnerMatcher
d4050 1
a4050 1
Matcher<FunctionDecl>hasAnyParameterMatcher<ParmVarDecl> InnerMatcher
d4064 1
a4064 36
Matcher<FunctionDecl>hasAnyTemplateArgumentMatcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
functionDecl that have at least one TemplateArgument matching the given
InnerMatcher.

Given
  template<typename T> class A {};
  template<> class A<double> {};
  A<int> a;

  template<typename T> f() {};
  void func() { f<int>(); };

classTemplateSpecializationDecl(hasAnyTemplateArgument(
    refersToType(asString("int"))))
  matches the specialization A<int>

functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
  matches the specialization f<int>
Matcher<FunctionDecl>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
definition that has a given body.

Given
  for (;;) {}
hasBody(compoundStmt())
  matches 'for (;;) {}'
with compoundStmt()
  matching '{}'
Matcher<FunctionDecl>hasParameterunsigned N, Matcher<ParmVarDecl> InnerMatcher d4076 1 a4076 21 Matcher<FunctionDecl>hasTemplateArgumentunsigned N, Matcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
functionDecl 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;

  template<typename T> f() {};
  void func() { f<int>(); };
classTemplateSpecializationDecl(hasTemplateArgument(
    1, refersToType(asString("int"))))
  matches the specialization A<bool, int>

functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
  matches the specialization f<int>
Matcher<FunctionDecl>returnsMatcher<QualType> InnerMatcher d4086 1 a4086 1 Matcher<IfStmt>hasConditionMatcher<Expr> InnerMatcher d4088 1 a4088 1 switch statement or conditional operator. d4095 1 a4095 1 Matcher<IfStmt>hasConditionVariableStatementMatcher<DeclStmt> InnerMatcher d4105 1 a4105 1 Matcher<IfStmt>hasElseMatcher<Stmt> InnerMatcher d4114 1 a4114 1 Matcher<IfStmt>hasThenMatcher<Stmt> InnerMatcher d4123 1 a4123 1 Matcher<ImplicitCastExpr>hasImplicitDestinationTypeMatcher<QualType> InnerMatcher d4131 1 a4131 7 Matcher<InitListExpr>hasSyntacticFormMatcher<Expr> InnerMatcher
Matches the syntactic form of init list expressions
(if expression have it).
Matcher<InjectedClassNameType>hasDeclarationMatcher<Decl> InnerMatcher a4139 1 - for CXXNewExpr, the declaration of the operator new d4144 6 a4149 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4153 1 a4153 1 Matcher<LabelStmt>hasDeclarationMatcher<Decl> InnerMatcher a4161 1 - for CXXNewExpr, the declaration of the operator new d4166 6 a4171 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4175 1 a4175 1 Matcher<MemberExpr>hasDeclarationMatcher<Decl> InnerMatcher a4183 1 - for CXXNewExpr, the declaration of the operator new d4188 6 a4193 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4197 1 a4197 1 Matcher<MemberExpr>hasObjectExpressionMatcher<Expr> InnerMatcher d4211 1 a4211 1 Matcher<MemberExpr>memberMatcher<ValueDecl> InnerMatcher d4225 1 a4225 1 Matcher<MemberPointerTypeLoc>pointeeLocMatcher<TypeLoc> d4236 2 a4237 2 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType> d4241 1 a4241 1 Matcher<MemberPointerType>pointeeMatcher<Type> d4252 2 a4253 15 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType>
Matcher<NamedDecl>hasUnderlyingDeclMatcher<NamedDecl> InnerMatcher
Matches a NamedDecl whose underlying declaration matches the given
matcher.

Given
  namespace N { template<class T> void f(T t); }
  template <class T> void g() { using N::f; f(T()); }
unresolvedLookupExpr(hasAnyDeclaration(
    namedDecl(hasUnderlyingDecl(hasName("::N::f")))))
  matches the use of f in g() .
d4257 1
a4257 1
Matcher<NestedNameSpecifierLoc>hasPrefixMatcher<NestedNameSpecifierLoc> InnerMatcher
d4268 1
a4268 1
Matcher<NestedNameSpecifierLoc>specifiesTypeLocMatcher<TypeLoc> InnerMatcher
d4281 1
a4281 1
Matcher<NestedNameSpecifier>hasPrefixMatcher<NestedNameSpecifier> InnerMatcher
d4292 1
a4292 1
Matcher<NestedNameSpecifier>specifiesNamespaceMatcher<NamespaceDecl> InnerMatcher
d4304 1
a4304 1
Matcher<NestedNameSpecifier>specifiesTypeMatcher<QualType> InnerMatcher
d4318 1
a4318 1
Matcher<ObjCMessageExpr>hasArgumentunsigned N, Matcher<Expr> InnerMatcher
d4328 1
a4328 1
Matcher<ObjCMessageExpr>hasReceiverTypeMatcher<QualType> InnerMatcher
d4340 1
a4340 22
Matcher<OpaqueValueExpr>hasSourceExpressionMatcher<Expr> InnerMatcher



Matcher<OverloadExpr>hasAnyDeclarationMatcher<Decl> InnerMatcher
Matches an OverloadExpr if any of the declarations in the set of
overloads matches the given matcher.

Given
  template <typename T> void foo(T);
  template <typename T> void bar(T);
  template <typename T> void baz(T t) {
    foo(t);
    bar(t);
  }
unresolvedLookupExpr(hasAnyDeclaration(
    functionTemplateDecl(hasName("foo"))))
  matches foo in foo(t); but not bar in bar(t);
Matcher<ParenType>innerTypeMatcher<Type> d4350 1 a4350 1 Usable as: Matcher<ParenType> d4354 1 a4354 1 Matcher<PointerTypeLoc>pointeeLocMatcher<TypeLoc> d4365 2 a4366 2 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType> d4370 1 a4370 1 Matcher<PointerType>pointeeMatcher<Type> d4381 2 a4382 2 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType> d4386 1 a4386 1 Matcher<QualType>hasCanonicalTypeMatcher<QualType> InnerMatcher d4399 1 a4399 1 Matcher<QualType>hasDeclarationMatcher<Decl> InnerMatcher a4407 1 - for CXXNewExpr, the declaration of the operator new d4412 6 a4417 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4421 1 a4421 12 Matcher<QualType>ignoringParensMatcher<QualType> InnerMatcher
Matches types that match InnerMatcher after any parens are stripped.

Given
  void (*fp)(void);
The matcher
  varDecl(hasType(pointerType(pointee(ignoringParens(functionType())))))
would match the declaration for fp.
Matcher<QualType>pointsToMatcher<Decl> InnerMatcher d4426 1 a4426 1 Matcher<QualType>pointsToMatcher<QualType> InnerMatcher d4438 1 a4438 1 Matcher<QualType>referencesMatcher<Decl> InnerMatcher d4443 1 a4443 1 Matcher<QualType>referencesMatcher<QualType> InnerMatcher d4458 1 a4458 1 Matcher<RecordType>hasDeclarationMatcher<Decl> InnerMatcher a4466 1 - for CXXNewExpr, the declaration of the operator new d4471 6 a4476 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4480 1 a4480 1 Matcher<ReferenceTypeLoc>pointeeLocMatcher<TypeLoc> d4491 2 a4492 2 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType> d4496 1 a4496 1 Matcher<ReferenceType>pointeeMatcher<Type> d4507 2 a4508 27 Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType>
Matcher<ReturnStmt>hasReturnValueMatcher<Expr> InnerMatcher
Matches the return value expression of a return statement

Given
  return a + b;
hasReturnValue(binaryOperator())
  matches 'return a + b'
with binaryOperator()
  matching 'a + b'
Matcher<StmtExpr>hasAnySubstatementMatcher<Stmt> InnerMatcher
Matches compound statements where at least one substatement matches
a given matcher. Also matches StmtExprs that have CompoundStmt as children.

Given
  { {}; 1+2; }
hasAnySubstatement(compoundStmt())
  matches '{ {}; 1+2; }'
with compoundStmt()
  matching '{}'
d4512 1
a4512 1
Matcher<Stmt>alignOfExprMatcher<UnaryExprOrTypeTraitExpr>  InnerMatcher
d4518 1
a4518 15
Matcher<Stmt>forFunctionMatcher<FunctionDecl> InnerMatcher
Matches declaration of the function the statemenet belongs to

Given:
F& operator=(const F& o) {
  std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
  return *this;
}
returnStmt(forFunction(hasName("operator=")))
  matches 'return *this'
  but does match 'return > 0'
Matcher<Stmt>sizeOfExprMatcher<UnaryExprOrTypeTraitExpr> InnerMatcher d4524 1 a4524 15 Matcher<SubstTemplateTypeParmType>hasReplacementTypeMatcher<Type>
Matches template type parameter substitutions that have a replacement
type that matches the provided matcher.

Given
  template <typename T>
  double F(T t);
  int i;
  double j = F(i);

substTemplateTypeParmType(hasReplacementType(type())) matches int
Matcher<SwitchStmt>forEachSwitchCaseMatcher<SwitchCase> InnerMatcher d4537 1 a4537 10 Matcher<SwitchStmt>hasConditionMatcher<Expr> InnerMatcher
Matches the condition expression of an if statement, for loop,
switch statement or conditional operator.

Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
  if (true) {}
Matcher<TagType>hasDeclarationMatcher<Decl> InnerMatcher a4545 1 - for CXXNewExpr, the declaration of the operator new d4550 6 a4555 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4559 1 a4559 1 Matcher<TemplateArgument>isExprMatcher<Expr> InnerMatcher d4573 1 a4573 1 Matcher<TemplateArgument>refersToDeclarationMatcher<Decl> InnerMatcher d4588 1 a4588 1 Matcher<TemplateArgument>refersToIntegralTypeMatcher<QualType> InnerMatcher d4600 1 a4600 14 Matcher<TemplateArgument>refersToTemplateMatcher<TemplateName> InnerMatcher
Matches a TemplateArgument that refers to a certain template.

Given
  template<template <typename> class S> class X {};
  template<typename T> class Y {};"
  X<Y> xi;
classTemplateSpecializationDecl(hasAnyTemplateArgument(
    refersToTemplate(templateName())))
  matches the specialization X<Y>
Matcher<TemplateArgument>refersToTypeMatcher<QualType> InnerMatcher d4613 3 a4615 4 Matcher<TemplateSpecializationType>hasAnyTemplateArgumentMatcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
functionDecl that have at least one TemplateArgument matching the given
InnerMatcher.
a4620 4

  template<typename T> f() {};
  void func() { f<int>(); };

a4623 3

functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
  matches the specialization f<int>
d4627 1
a4627 1
Matcher<TemplateSpecializationType>hasDeclarationMatcher<Decl>  InnerMatcher
a4635 1
- for CXXNewExpr, the declaration of the operator new
d4640 6
a4645 7
Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
  Matcher<TagType>, Matcher<TemplateSpecializationType>,
  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
  Matcher<UnresolvedUsingType>
d4649 3
a4651 3
Matcher<TemplateSpecializationType>hasTemplateArgumentunsigned N, Matcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
a4656 3

  template<typename T> f() {};
  void func() { f<int>(); };
a4659 3

functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
  matches the specialization f<int>
d4663 1
a4663 1
Matcher<TemplateTypeParmType>hasDeclarationMatcher<Decl>  InnerMatcher
a4671 1
- for CXXNewExpr, the declaration of the operator new
d4676 6
a4681 7
Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
  Matcher<TagType>, Matcher<TemplateSpecializationType>,
  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
  Matcher<UnresolvedUsingType>
d4701 1
a4701 14
Matcher<TypedefNameDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
matcher.

Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
            and U (matcher = typedefDecl(hasType(asString("int")))
 class X {};
 void y(X &x) { x; X z; }
 typedef int U;
Matcher<TypedefType>hasDeclarationMatcher<Decl> InnerMatcher a4709 1 - for CXXNewExpr, the declaration of the operator new d4714 6 a4719 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4723 1 a4723 13 Matcher<Type>hasUnqualifiedDesugaredTypeMatcher<Type> InnerMatcher
Matches if the matched type matches the unqualified desugared
type of the matched node.

For example, in:
  class A {};
  using B = A;
The matcher type(hasUniqualifeidDesugaredType(recordType())) matches
both B and A.
Matcher<UnaryExprOrTypeTraitExpr>hasArgumentOfTypeMatcher<QualType> InnerMatcher d4733 1 a4733 1 Matcher<UnaryOperator>hasUnaryOperandMatcher<Expr> InnerMatcher d4742 1 a4742 1 Matcher<UnresolvedUsingType>hasDeclarationMatcher<Decl> InnerMatcher a4750 1 - for CXXNewExpr, the declaration of the operator new d4755 6 a4760 7 Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType> d4764 1 a4764 1 Matcher<UsingDecl>hasAnyUsingShadowDeclMatcher<UsingShadowDecl> InnerMatcher d4774 1 a4774 1 Matcher<UsingShadowDecl>hasTargetDeclMatcher<NamedDecl> InnerMatcher d4786 2 a4787 2 Matcher<ValueDecl>hasTypeMatcher<Decl> InnerMatcher
Overloaded to match the declaration of the expression's or value
d4801 1
a4801 1
Usable as: Matcher<Expr>, Matcher<ValueDecl>
d4805 2
a4806 2
Matcher<ValueDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
a4810 1
            and U (matcher = typedefDecl(hasType(asString("int")))
a4812 1
 typedef int U;
d4816 1
a4816 1
Matcher<VarDecl>hasInitializerMatcher<Expr> InnerMatcher
d4826 1
a4826 1
Matcher<VariableArrayType>hasSizeExprMatcher<Expr> InnerMatcher
d4840 3
a4842 3
Matcher<WhileStmt>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
definition that has a given body.
d4853 1
a4853 1
Matcher<WhileStmt>hasConditionMatcher<Expr> InnerMatcher
d4855 1
a4855 1
switch statement or conditional operator.
d4862 1
a4862 1
Matcher<internal::BindableMatcher<NestedNameSpecifierLoc>>locMatcher<NestedNameSpecifier> InnerMatcher
d4868 1
a4868 1
Matcher<internal::BindableMatcher<TypeLoc>>locMatcher<QualType> InnerMatcher
@


1.1.1.8
log
@Import clang r309604 from branches/release_50
@
text
@a339 9
Matcher<Decl>objcCategoryDeclMatcher<ObjCCategoryDecl>...
Matches Objective-C category declarations.

Example matches Foo (Additions)
  @@interface Foo (Additions)
  @@end
a348 44 Matcher<Decl>objcIvarDeclMatcher<ObjCIvarDecl>...
Matches Objective-C instance variable declarations.

Example matches _enabled
  @@implementation Foo {
    BOOL _enabled;
  }
  @@end
Matcher<Decl>objcMethodDeclMatcher<ObjCMethodDecl>...
Matches Objective-C method declarations.

Example matches both declaration and definition of -[Foo method]
  @@interface Foo
  - (void)method;
  @@end

  @@implementation Foo
  - (void)method {}
  @@end
Matcher<Decl>objcPropertyDeclMatcher<ObjCPropertyDecl>...
Matches Objective-C property declarations.

Example matches enabled
  @@interface Foo
  @@property BOOL enabled;
  @@end
Matcher<Decl>objcProtocolDeclMatcher<ObjCProtocolDecl>...
Matches Objective-C protocol declarations.

Example matches FooDelegate
  @@protocol FooDelegate
  @@end
a418 9 Matcher<Decl>typeAliasTemplateDeclMatcher<TypeAliasTemplateDecl>...
Matches type alias template declarations.

typeAliasTemplateDecl() matches
  template <typename T>
  using Y = X<T>;
a864 13 Matcher<Stmt>cxxStdInitializerListExprMatcher<CXXStdInitializerListExpr>...
Matches C++ initializer list expressions.

Given
  std::vector<int> a({ 1, 2, 3 });
  std::vector<int> b = { 4, 5 };
  int c[] = { 6, 7 };
  std::pair<int, int> d = { 8, 9 };
cxxStdInitializerListExpr()
  matches "{ 1, 2, 3 }" and "{ 4, 5 }"
d1101 1 a1101 1 struct T {void func();}; d1787 2 a1788 2 Matcher<CXXBoolLiteralExpr>equalsValueT Value
Matches literals that are equal to the given value of type ValueT.
d1790 2
a1791 17
Given
  f('false, 3.14, 42);
characterLiteral(equals(0))
  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
  match false
floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
  match 3.14
integerLiteral(equals(42))
  matches 42

Note that you cannot directly match a negative numeric literal because the
minus sign is not part of the literal: It is a unary operator whose operand
is the positive numeric literal. Instead, you must use a unaryOperator()
matcher to match the minus sign:

unaryOperator(hasOperatorName("-"),
              hasUnaryOperand(integerLiteral(equals(13))))
d1793 1
a1793 1
Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>,
a1797 12
Matcher<CXXBoolLiteralExpr>equalsbool Value



Matcher<CXXBoolLiteralExpr>equalsdouble Value



Matcher<CXXBoolLiteralExpr>equalsunsigned Value



d2224 1
a2224 1
Matches literals that are equal to the given value of type ValueT.
d2226 2
a2227 17
Given
  f('false, 3.14, 42);
characterLiteral(equals(0))
  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
  match false
floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
  match 3.14
integerLiteral(equals(42))
  matches 42

Note that you cannot directly match a negative numeric literal because the
minus sign is not part of the literal: It is a unary operator whose operand
is the positive numeric literal. Instead, you must use a unaryOperator()
matcher to match the minus sign:

unaryOperator(hasOperatorName("-"),
              hasUnaryOperand(integerLiteral(equals(13))))
d2229 1
a2229 1
Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>,
a2233 12
Matcher<CharacterLiteral>equalsbool Value



Matcher<CharacterLiteral>equalsdouble Value



Matcher<CharacterLiteral>equalsunsigned Value



d2461 1
a2461 1
Matches literals that are equal to the given value of type ValueT.
d2463 2
a2464 17
Given
  f('false, 3.14, 42);
characterLiteral(equals(0))
  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
  match false
floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
  match 3.14
integerLiteral(equals(42))
  matches 42

Note that you cannot directly match a negative numeric literal because the
minus sign is not part of the literal: It is a unary operator whose operand
is the positive numeric literal. Instead, you must use a unaryOperator()
matcher to match the minus sign:

unaryOperator(hasOperatorName("-"),
              hasUnaryOperand(integerLiteral(equals(13))))
d2466 1
a2466 1
Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>,
a2470 4
Matcher<FloatingLiteral>equalsdouble Value



d2733 1
a2733 1
Matches literals that are equal to the given value of type ValueT.
d2735 2
a2736 17
Given
  f('false, 3.14, 42);
characterLiteral(equals(0))
  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
  match false
floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
  match 3.14
integerLiteral(equals(42))
  matches 42

Note that you cannot directly match a negative numeric literal because the
minus sign is not part of the literal: It is a unary operator whose operand
is the positive numeric literal. Instead, you must use a unaryOperator()
matcher to match the minus sign:

unaryOperator(hasOperatorName("-"),
              hasUnaryOperand(integerLiteral(equals(13))))
d2738 1
a2738 1
Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>,
a2742 12
Matcher<IntegerLiteral>equalsbool Value



Matcher<IntegerLiteral>equalsdouble Value



Matcher<IntegerLiteral>equalsunsigned Value



d5174 1
a5174 1
matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *")));
d5422 1
a5422 1
Matches declaration of the function the statement belongs to
@


1.1.1.8.4.1
log
@Sync with HEAD
@
text
@a126 12
Matcher<Decl>blockDeclMatcher<BlockDecl>...
Matches block declarations.

Example matches the declaration of the nameless block printing an input
integer.

  myFunc(^(int p) {
    printf("%d", p);
  })
a348 18 Matcher<Decl>objcCategoryImplDeclMatcher<ObjCCategoryImplDecl>...
Matches Objective-C category definitions.

Example matches Foo (Additions)
  @@implementation Foo (Additions)
  @@end
Matcher<Decl>objcImplementationDeclMatcher<ObjCImplementationDecl>...
Matches Objective-C implementation declarations.

Example matches Foo
  @@implementation Foo
  @@end
a634 12 Matcher<Stmt>autoreleasePoolStmtMatcher<ObjCAutoreleasePoolStmt>...
Matches an Objective-C autorelease pool statement.

Given
  @@autoreleasepool {
    int x = 0;
  }
autoreleasePoolStmt(stmt()) matches the declaration of "x"
inside the autorelease pool.
d685 1 a685 1 matches 'case 42:'. d726 1 a726 1 Example matches '{}' and '{{}}' in 'for (;;) {{}}' d1013 1 a1013 1 matches 'default:'. a1181 1 f().func(); d1184 1 a1209 18 Matcher<Stmt>objcCatchStmtMatcher<ObjCAtCatchStmt>...
Matches Objective-C @@catch statements.

Example matches @@catch
  @@try {}
  @@catch (...) {}
Matcher<Stmt>objcFinallyStmtMatcher<ObjCAtFinallyStmt>...
Matches Objective-C @@finally statements.

Example matches @@finally
  @@try {}
  @@finally {}
a1220 16 Matcher<Stmt>objcThrowStmtMatcher<ObjCAtThrowStmt>...
Matches Objective-C statements.

Example matches @@throw obj;
Matcher<Stmt>objcTryStmtMatcher<ObjCAtTryStmt>...
Matches Objective-C @@try statements.

Example matches @@try
  @@try {}
  @@catch (...) {}
d1320 1 a1320 1 matches 'case 42:' and 'default:'. a1731 15 Matcher<Type>tagTypeMatcher<TagType>...
Matches tag types (record and enum types).

Given
  enum E {};
  class C {};

  E e;
  C c;

tagType() matches the type of the variable declarations of both e
and c.
d1862 1 a1862 19 Matcher<BinaryOperator>isAssignmentOperator
Matches all kinds of assignment operators.

Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
  if (a == b)
    a += b;

Example 2: matches s1 = s2
           (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
  struct S { S& operator=(const S&); };
  void x() { S s1, s2; s1 = s2; })
Matcher<CXXBoolLiteralExpr>equalsbool Value



Matcher<CXXBoolLiteralExpr>equalsconst ValueT  Value
d1888 4
a2210 10
Matcher<CXXNewExpr>isArray
Matches array new expressions.

Given:
  MyClass *p1 = new MyClass[10];
cxxNewExpr(isArray())
  matches the expression 'new MyClass[10]'.
a2231 23 Matcher<CXXOperatorCallExpr>isAssignmentOperator
Matches all kinds of assignment operators.

Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
  if (a == b)
    a += b;

Example 2: matches s1 = s2
           (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
  struct S { S& operator=(const S&); };
  void x() { S s1, s2; s1 = s2; })
Matcher<CXXRecordDecl>hasDefinition
Matches a class declaration that is defined.

Example matches x (matcher = cxxRecordDecl(hasDefinition()))
class x {};
class y;
a2292 2 or template <typename T> class X {}; class A {}; extern template class X<A>; d2325 1 a2325 5 Matcher<CharacterLiteral>equalsbool Value



Matcher<CharacterLiteral>equalsconst ValueT  Value
d2351 4
a2560 9
Matcher<EnumDecl>isScoped
Matches C++11 scoped enum declaration.

Example matches Y (matcher = enumDecl(isScoped()))
enum X {};
enum class Y {};
d2589 1 a2589 1 Matcher<FloatingLiteral>equalsconst ValueT Value a2656 9 Matcher<FunctionDecl>hasTrailingReturn
Matches a function declared with a trailing return type.

Example matches Y (matcher = functionDecl(hasTrailingReturn()))
int X() {}
auto Y() -> int {}
d2658 1 a2658 2
Matches constexpr variable and function declarations,
       and if constexpr.
a2662 1
  void baz() { if constexpr(1 > 0) {} }
a2666 2
ifStmt(isConstexpr())
  matches the if statement in baz.
d2681 2
a2682 2
Matcher<FunctionDecl>isDefinition
Matches if a declaration has a body attached.
a2690 6
  @@interface X
  - (void)ma; Doesn't match, interface is declaration.
  @@end
  @@implementation X
  - (void)ma {}
  @@end
d2692 1
a2692 2
Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
  Matcher<ObjCMethodDecl>
d2722 1
a2722 1
Matches extern "C" function or variable declarations.
a2727 3
  extern "C" int x = 1;
  extern "C" int y = 2;
  int z = 3;
d2729 1
a2729 3
  matches the declaration of f and g, but not the declaration of h.
varDecl(isExternC())
  matches the declaration of x and y, but not the declaration of z.
a2747 14
Matcher<FunctionDecl>isNoReturn
Matches FunctionDecls that have a noreturn attribute.

Given
  void nope();
  [[noreturn]] void a();
  __attribute__((noreturn)) void b();
  struct c { [[noreturn]] c(); };
functionDecl(isNoReturn())
  matches all of those except
  void nope();
a2785 2 or template <typename T> class X {}; class A {}; extern template class X<A>; d2822 1 a2822 1 matches g and h d2824 1 a2824 1 matches g and h d2826 1 a2826 1 matches k d2872 1 a2872 1 matches g and h d2874 1 a2874 1 matches g and h d2876 1 a2876 1 matches k d2880 1 a2880 22 Matcher<IfStmt>isConstexpr
Matches constexpr variable and function declarations,
       and if constexpr.

Given:
  constexpr int foo = 42;
  constexpr int bar();
  void baz() { if constexpr(1 > 0) {} }
varDecl(isConstexpr())
  matches the declaration of foo.
functionDecl(isConstexpr())
  matches the declaration of bar.
ifStmt(isConstexpr())
  matches the if statement in baz.
Matcher<IntegerLiteral>equalsbool Value



Matcher<IntegerLiteral>equalsconst ValueT  Value
d2906 4
d2955 1
a2955 1
Matcher<NamedDecl>hasNameconst std::string  Name
a3063 13
Matcher<ObjCMessageExpr>isInstanceMessage
Returns true when the Objective-C message is sent to an instance.

Example
matcher = objcMessagaeExpr(isInstanceMessage())
matches
  NSString *x = @@"hello";
  [x containsString:@@"h"]
but not
  [NSString stringWithFormat:@@"format"]
a3085 31 Matcher<ObjCMethodDecl>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.
  @@interface X
  - (void)ma; Doesn't match, interface is declaration.
  @@end
  @@implementation X
  - (void)ma {}
  @@end

Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
  Matcher<ObjCMethodDecl>
Matcher<ParmVarDecl>hasDefaultArgument
Matches a declaration that has default arguments.

Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
void x(int val) {}
void y(int val = 0) {}
a3364 6 @@interface X - (void)ma; Doesn't match, interface is declaration. @@end @@implementation X - (void)ma {} @@end d3366 1 a3366 2 Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>, Matcher<ObjCMethodDecl> d3378 1 a3378 1 template<int T> struct C {}; d3390 1 a3390 1 template<int T> struct C {}; d3606 1 a3606 2
Matches constexpr variable and function declarations,
       and if constexpr.
a3610 1
  void baz() { if constexpr(1 > 0) {} }
a3614 2
ifStmt(isConstexpr())
  matches the if statement in baz.
a3627 6
  @@interface X
  - (void)ma; Doesn't match, interface is declaration.
  @@end
  @@implementation X
  - (void)ma {}
  @@end
d3629 1
a3629 2
Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
  Matcher<ObjCMethodDecl>
d3661 1
a3661 1
Matches extern "C" function or variable declarations.
a3666 3
  extern "C" int x = 1;
  extern "C" int y = 2;
  int z = 3;
d3668 1
a3668 3
  matches the declaration of f and g, but not the declaration of h.
varDecl(isExternC())
  matches the declaration of x and y, but not the declaration of z.
a3695 2
or
  template <typename T> class X {}; class A {}; extern template class X<A>;
a3748 11
Matcher<internal::Matcher<ObjCMessageExpr>>hasAnySelectorStringRef, ..., StringRef
Matches when at least one of the supplied string equals to the
Selector.getAsString()

 matcher = objCMessageExpr(hasSelector("methodA:", "methodB:"));
 matches both of the expressions below:
    [myObj methodA:argA];
    [myObj methodB:argB];
d3805 1 a3805 1 Example matches X, A, A::X, B, B::C, B::C::X d3807 2 a3808 3 class X {}; class A { class X {}; }; Matches A, because A::X is a class of name X inside A. d3831 1 a3831 1 Example matches X, Y, Y::X, Z::Y, Z::Y::X d3833 2 a3834 3 class X {}; class Y { class X {}; }; Matches Y, because Y::X is a class of name X inside Y. d3937 1 a3937 1 Matcher<AddrLabelExpr>hasDeclarationconst Matcher<Decl> InnerMatcher d3948 2 a3949 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4072 1 a4072 1 Matcher<BinaryOperator>hasEitherOperandconst Matcher<Expr> InnerMatcher a4093 49 Matcher<BlockDecl>hasAnyParameterMatcher<ParmVarDecl> InnerMatcher
Matches any parameter of a function or an ObjC method declaration or a
block.

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

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

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
matches the declaration of method f with hasParameter
matching y.

For blocks, given
  b = ^(int y) { printf("%d", y) };

the matcher blockDecl(hasAnyParameter(hasName("y")))
matches the declaration of the block b with hasParameter
matching y.
Matcher<BlockDecl>hasParameterunsigned N, Matcher<ParmVarDecl> InnerMatcher
Matches the n'th parameter of a function or an ObjC method
declaration or a block.

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

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasParameter(0, hasName("y")))
matches the declaration of method f with hasParameter
matching y.
d4148 1 a4148 1 expression, or an ObjC-message-send expression. a4155 6 For ObjectiveC, given @@interface I - (void) f:(int) y; @@end void foo(I *i) { [i f:12]; } objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) matches [i f:12] d4169 1 a4169 1 Matcher<CXXConstructExpr>hasDeclarationconst Matcher<Decl> InnerMatcher d4180 2 a4181 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4293 1 a4293 1 void z() { Y y; y.x(); } d4311 1 a4311 1
Matches each method overridden by the given method. This matcher may
d4353 1
a4353 11
Matcher<CXXNewExpr>hasArraySizeMatcher<Expr> InnerMatcher
Matches array new expressions with a given array size.

Given:
  MyClass *p1 = new MyClass[10];
cxxNewExpr(hasArraySize(intgerLiteral(equals(10))))
  matches the expression 'new MyClass[10]'.
Matcher<CXXNewExpr>hasDeclarationconst Matcher<Decl> InnerMatcher d4364 2 a4365 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4467 1 a4467 1 expression, or an ObjC-message-send expression. a4474 6 For ObjectiveC, given @@interface I - (void) f:(int) y; @@end void foo(I *i) { [i f:12]; } objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) matches [i f:12] d4488 1 a4488 1 Matcher<CallExpr>hasDeclarationconst Matcher<Decl> InnerMatcher d4499 2 a4500 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4524 1 a4524 12
Matches if the cast's source expression
or opaque value's source expression matches the given matcher.

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

Example 2: matches 'b' (matcher =
opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
int a = b ?: 1;
a4548 12 Matcher<ClassTemplateSpecializationDecl>hasSpecializedTemplateMatcher<ClassTemplateDecl> InnerMatcher
Matches the specialized template of a specialization declaration.

Given
  tempalate<typename T> class A {};
  typedef A<int> B;
classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl()))
  matches 'B' with classTemplateDecl() matching the class template
  declaration of 'A'.
d4558 1 a4558 1 template<typename T> void f() {} d4617 1 a4617 1 Matcher<DeclRefExpr>hasDeclarationconst Matcher<Decl> InnerMatcher d4628 2 a4629 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4781 1 a4781 1 Matcher<EnumType>hasDeclarationconst Matcher<Decl> InnerMatcher d4792 2 a4793 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4813 2 a4814 2 Matcher<Expr>hasTypeMatcher<Decl> InnerMatcher
Overloaded to match the declaration of the expression's or value
a4824 1
            and friend class X (matcher = friendDecl(hasType("X"))
a4826 1
 class Y { friend class X; };
a4838 1
            and friend class X (matcher = friendDecl(hasType("X"))
a4841 1
 class Y { friend class X; };
d4868 1
a4868 1
Matcher<Expr>ignoringImplicitMatcher<Expr> InnerMatcher
a4986 36
Matcher<FriendDecl>hasTypeMatcher<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;", cxxRecordDecl(hasName("X")) matches the declaration of
X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
declaration of x.

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

Usable as: Matcher<Expr>, Matcher<ValueDecl>
Matcher<FriendDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
matcher.

Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
            and U (matcher = typedefDecl(hasType(asString("int")))
            and friend class X (matcher = friendDecl(hasType("X"))
 class X {};
 void y(X &x) { x; X z; }
 typedef int U;
 class Y { friend class X; };
d4988 1 a4988 2
Matches any parameter of a function or an ObjC method declaration or a
block.
a4997 14

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
matches the declaration of method f with hasParameter
matching y.

For blocks, given
  b = ^(int y) { printf("%d", y) };

the matcher blockDecl(hasAnyParameter(hasName("y")))
matches the declaration of the block b with hasParameter
matching y.
d5037 1
a5037 2
Matches the n'th parameter of a function or an ObjC method
declaration or a block.
a5044 7

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasParameter(0, hasName("y")))
matches the declaration of method f with hasParameter
matching y.
d5057 1
a5057 1
  template<typename T> void f() {}
d5129 1
a5129 1
Matcher<InjectedClassNameType>hasDeclarationconst Matcher<Decl>  InnerMatcher
d5140 2
a5141 11
For type nodes, hasDeclaration will generally match the declaration of the
sugared type. Given
  class X {};
  typedef X Y;
  Y y;
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
typedefDecl. A common use case is to match the underlying, desugared type.
This can be achieved by using the hasUnqualifiedDesugaredType matcher:
  varDecl(hasType(hasUnqualifiedDesugaredType(
      recordType(hasDeclaration(decl())))))
In this matcher, the decl will match the CXXRecordDecl of class X.
d5153 1
a5153 1
Matcher<LabelStmt>hasDeclarationconst Matcher<Decl>  InnerMatcher
d5164 2
a5165 11
For type nodes, hasDeclaration will generally match the declaration of the
sugared type. Given
  class X {};
  typedef X Y;
  Y y;
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
typedefDecl. A common use case is to match the underlying, desugared type.
This can be achieved by using the hasUnqualifiedDesugaredType matcher:
  varDecl(hasType(hasUnqualifiedDesugaredType(
      recordType(hasDeclaration(decl())))))
In this matcher, the decl will match the CXXRecordDecl of class X.
d5177 1
a5177 1
Matcher<MemberExpr>hasDeclarationconst Matcher<Decl>  InnerMatcher
d5188 2
a5189 11
For type nodes, hasDeclaration will generally match the declaration of the
sugared type. Given
  class X {};
  typedef X Y;
  Y y;
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
typedefDecl. A common use case is to match the underlying, desugared type.
This can be achieved by using the hasUnqualifiedDesugaredType matcher:
  varDecl(hasType(hasUnqualifiedDesugaredType(
      recordType(hasDeclaration(decl())))))
In this matcher, the decl will match the CXXRecordDecl of class X.
a5334 19
Matcher<ObjCMessageExpr>hasAnyArgumentMatcher<Expr> InnerMatcher
Matches any argument of a call expression or a constructor call
expression, or an ObjC-message-send 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

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end
  void foo(I *i) { [i f:12]; }
objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
  matches [i f:12]
a5344 12 Matcher<ObjCMessageExpr>hasReceiverMatcher<Expr> InnerMatcher
Matches if the Objective-C message is sent to an instance,
and the inner matcher matches on that instance.

For example the method call in
  NSString *x = @@"hello";
  [x containsString:@@"h"]
is matched by
objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x"))))))
a5356 49 Matcher<ObjCMethodDecl>hasAnyParameterMatcher<ParmVarDecl> InnerMatcher
Matches any parameter of a function or an ObjC method declaration or a
block.

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

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

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
matches the declaration of method f with hasParameter
matching y.

For blocks, given
  b = ^(int y) { printf("%d", y) };

the matcher blockDecl(hasAnyParameter(hasName("y")))
matches the declaration of the block b with hasParameter
matching y.
Matcher<ObjCMethodDecl>hasParameterunsigned N, Matcher<ParmVarDecl> InnerMatcher
Matches the n'th parameter of a function or an ObjC method
declaration or a block.

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

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasParameter(0, hasName("y")))
matches the declaration of method f with hasParameter
matching y.
d5358 1 a5358 12
Matches if the cast's source expression
or opaque value's source expression matches the given matcher.

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

Example 2: matches 'b' (matcher =
opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
int a = b ?: 1;
d5437 1 a5437 1 Matcher<QualType>hasDeclarationconst Matcher<Decl> InnerMatcher d5448 2 a5449 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d5509 1 a5509 1 Matcher<RecordType>hasDeclarationconst Matcher<Decl> InnerMatcher d5520 2 a5521 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d5590 1 a5590 1 Matcher<Stmt>alignOfExprconst Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher d5610 1 a5610 1 Matcher<Stmt>sizeOfExprconst Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher d5652 1 a5652 1 Matcher<TagType>hasDeclarationconst Matcher<Decl> InnerMatcher d5663 2 a5664 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d5680 2 a5681 2 struct B { int next; }; template<int(B::*next_ptr)> struct A {}; d5695 2 a5696 2 struct B { int next; }; template<int(B::*next_ptr)> struct A {}; d5699 1 a5699 1 refersToDeclaration(fieldDecl(hasName("next"))))) d5709 1 a5709 1 template<int T> struct C {}; d5765 1 a5765 1 Matcher<TemplateSpecializationType>hasDeclarationconst Matcher<Decl> InnerMatcher d5776 2 a5777 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d5798 1 a5798 1 template<typename T> void f() {} d5809 1 a5809 1 Matcher<TemplateTypeParmType>hasDeclarationconst Matcher<Decl> InnerMatcher d5820 2 a5821 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d5833 1 a5833 1 Matcher<T>findAllconst Matcher<T> Matcher d5849 2 a5850 2 Matcher<TypedefNameDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
a5855 1
            and friend class X (matcher = friendDecl(hasType("X"))
a5858 1
 class Y { friend class X; };
d5862 1
a5862 1
Matcher<TypedefType>hasDeclarationconst Matcher<Decl>  InnerMatcher
d5873 2
a5874 11
For type nodes, hasDeclaration will generally match the declaration of the
sugared type. Given
  class X {};
  typedef X Y;
  Y y;
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
typedefDecl. A common use case is to match the underlying, desugared type.
This can be achieved by using the hasUnqualifiedDesugaredType matcher:
  varDecl(hasType(hasUnqualifiedDesugaredType(
      recordType(hasDeclaration(decl())))))
In this matcher, the decl will match the CXXRecordDecl of class X.
d5893 1
a5893 1
The matcher type(hasUnqualifeidDesugaredType(recordType())) matches
d5917 1
a5917 1
Matcher<UnresolvedUsingType>hasDeclarationconst Matcher<Decl>  InnerMatcher
d5928 2
a5929 11
For type nodes, hasDeclaration will generally match the declaration of the
sugared type. Given
  class X {};
  typedef X Y;
  Y y;
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
typedefDecl. A common use case is to match the underlying, desugared type.
This can be achieved by using the hasUnqualifiedDesugaredType matcher:
  varDecl(hasType(hasUnqualifiedDesugaredType(
      recordType(hasDeclaration(decl())))))
In this matcher, the decl will match the CXXRecordDecl of class X.
d5963 2
a5964 2
Matcher<ValueDecl>hasTypeMatcher<Decl> InnerMatcher
Overloaded to match the declaration of the expression's or value
a5974 1
            and friend class X (matcher = friendDecl(hasType("X"))
a5976 1
 class Y { friend class X; };
d5982 2
a5983 2
Matcher<ValueDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
a5988 1
            and friend class X (matcher = friendDecl(hasType("X"))
a5991 1
 class Y { friend class X; };
@


1.1.1.8.4.2
log
@Mostly merge changes from HEAD upto 20200411
@
text
@@


1.1.1.8.2.1
log
@Sync with HEAD
@
text
@a126 12
Matcher<Decl>blockDeclMatcher<BlockDecl>...
Matches block declarations.

Example matches the declaration of the nameless block printing an input
integer.

  myFunc(^(int p) {
    printf("%d", p);
  })
a348 18 Matcher<Decl>objcCategoryImplDeclMatcher<ObjCCategoryImplDecl>...
Matches Objective-C category definitions.

Example matches Foo (Additions)
  @@implementation Foo (Additions)
  @@end
Matcher<Decl>objcImplementationDeclMatcher<ObjCImplementationDecl>...
Matches Objective-C implementation declarations.

Example matches Foo
  @@implementation Foo
  @@end
a634 12 Matcher<Stmt>autoreleasePoolStmtMatcher<ObjCAutoreleasePoolStmt>...
Matches an Objective-C autorelease pool statement.

Given
  @@autoreleasepool {
    int x = 0;
  }
autoreleasePoolStmt(stmt()) matches the declaration of "x"
inside the autorelease pool.
d685 1 a685 1 matches 'case 42:'. d726 1 a726 1 Example matches '{}' and '{{}}' in 'for (;;) {{}}' d1013 1 a1013 1 matches 'default:'. a1181 1 f().func(); d1184 1 a1209 18 Matcher<Stmt>objcCatchStmtMatcher<ObjCAtCatchStmt>...
Matches Objective-C @@catch statements.

Example matches @@catch
  @@try {}
  @@catch (...) {}
Matcher<Stmt>objcFinallyStmtMatcher<ObjCAtFinallyStmt>...
Matches Objective-C @@finally statements.

Example matches @@finally
  @@try {}
  @@finally {}
a1220 16 Matcher<Stmt>objcThrowStmtMatcher<ObjCAtThrowStmt>...
Matches Objective-C statements.

Example matches @@throw obj;
Matcher<Stmt>objcTryStmtMatcher<ObjCAtTryStmt>...
Matches Objective-C @@try statements.

Example matches @@try
  @@try {}
  @@catch (...) {}
d1320 1 a1320 1 matches 'case 42:' and 'default:'. a1731 15 Matcher<Type>tagTypeMatcher<TagType>...
Matches tag types (record and enum types).

Given
  enum E {};
  class C {};

  E e;
  C c;

tagType() matches the type of the variable declarations of both e
and c.
d1862 1 a1862 19 Matcher<BinaryOperator>isAssignmentOperator
Matches all kinds of assignment operators.

Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
  if (a == b)
    a += b;

Example 2: matches s1 = s2
           (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
  struct S { S& operator=(const S&); };
  void x() { S s1, s2; s1 = s2; })
Matcher<CXXBoolLiteralExpr>equalsbool Value



Matcher<CXXBoolLiteralExpr>equalsconst ValueT  Value
d1888 4
a2210 10
Matcher<CXXNewExpr>isArray
Matches array new expressions.

Given:
  MyClass *p1 = new MyClass[10];
cxxNewExpr(isArray())
  matches the expression 'new MyClass[10]'.
a2231 23 Matcher<CXXOperatorCallExpr>isAssignmentOperator
Matches all kinds of assignment operators.

Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
  if (a == b)
    a += b;

Example 2: matches s1 = s2
           (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
  struct S { S& operator=(const S&); };
  void x() { S s1, s2; s1 = s2; })
Matcher<CXXRecordDecl>hasDefinition
Matches a class declaration that is defined.

Example matches x (matcher = cxxRecordDecl(hasDefinition()))
class x {};
class y;
a2292 2 or template <typename T> class X {}; class A {}; extern template class X<A>; d2325 1 a2325 5 Matcher<CharacterLiteral>equalsbool Value



Matcher<CharacterLiteral>equalsconst ValueT  Value
d2351 4
a2560 9
Matcher<EnumDecl>isScoped
Matches C++11 scoped enum declaration.

Example matches Y (matcher = enumDecl(isScoped()))
enum X {};
enum class Y {};
d2589 1 a2589 1 Matcher<FloatingLiteral>equalsconst ValueT Value a2656 9 Matcher<FunctionDecl>hasTrailingReturn
Matches a function declared with a trailing return type.

Example matches Y (matcher = functionDecl(hasTrailingReturn()))
int X() {}
auto Y() -> int {}
d2658 1 a2658 2
Matches constexpr variable and function declarations,
       and if constexpr.
a2662 1
  void baz() { if constexpr(1 > 0) {} }
a2666 2
ifStmt(isConstexpr())
  matches the if statement in baz.
d2681 2
a2682 2
Matcher<FunctionDecl>isDefinition
Matches if a declaration has a body attached.
a2690 6
  @@interface X
  - (void)ma; Doesn't match, interface is declaration.
  @@end
  @@implementation X
  - (void)ma {}
  @@end
d2692 1
a2692 2
Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
  Matcher<ObjCMethodDecl>
d2722 1
a2722 1
Matches extern "C" function or variable declarations.
a2727 3
  extern "C" int x = 1;
  extern "C" int y = 2;
  int z = 3;
d2729 1
a2729 3
  matches the declaration of f and g, but not the declaration of h.
varDecl(isExternC())
  matches the declaration of x and y, but not the declaration of z.
a2747 14
Matcher<FunctionDecl>isNoReturn
Matches FunctionDecls that have a noreturn attribute.

Given
  void nope();
  [[noreturn]] void a();
  __attribute__((noreturn)) void b();
  struct c { [[noreturn]] c(); };
functionDecl(isNoReturn())
  matches all of those except
  void nope();
a2785 2 or template <typename T> class X {}; class A {}; extern template class X<A>; d2822 1 a2822 1 matches g and h d2824 1 a2824 1 matches g and h d2826 1 a2826 1 matches k d2872 1 a2872 1 matches g and h d2874 1 a2874 1 matches g and h d2876 1 a2876 1 matches k d2880 1 a2880 22 Matcher<IfStmt>isConstexpr
Matches constexpr variable and function declarations,
       and if constexpr.

Given:
  constexpr int foo = 42;
  constexpr int bar();
  void baz() { if constexpr(1 > 0) {} }
varDecl(isConstexpr())
  matches the declaration of foo.
functionDecl(isConstexpr())
  matches the declaration of bar.
ifStmt(isConstexpr())
  matches the if statement in baz.
Matcher<IntegerLiteral>equalsbool Value



Matcher<IntegerLiteral>equalsconst ValueT  Value
d2906 4
d2955 1
a2955 1
Matcher<NamedDecl>hasNameconst std::string  Name
a3063 13
Matcher<ObjCMessageExpr>isInstanceMessage
Returns true when the Objective-C message is sent to an instance.

Example
matcher = objcMessagaeExpr(isInstanceMessage())
matches
  NSString *x = @@"hello";
  [x containsString:@@"h"]
but not
  [NSString stringWithFormat:@@"format"]
a3085 31 Matcher<ObjCMethodDecl>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.
  @@interface X
  - (void)ma; Doesn't match, interface is declaration.
  @@end
  @@implementation X
  - (void)ma {}
  @@end

Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
  Matcher<ObjCMethodDecl>
Matcher<ParmVarDecl>hasDefaultArgument
Matches a declaration that has default arguments.

Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
void x(int val) {}
void y(int val = 0) {}
a3364 6 @@interface X - (void)ma; Doesn't match, interface is declaration. @@end @@implementation X - (void)ma {} @@end d3366 1 a3366 2 Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>, Matcher<ObjCMethodDecl> d3378 1 a3378 1 template<int T> struct C {}; d3390 1 a3390 1 template<int T> struct C {}; d3606 1 a3606 2
Matches constexpr variable and function declarations,
       and if constexpr.
a3610 1
  void baz() { if constexpr(1 > 0) {} }
a3614 2
ifStmt(isConstexpr())
  matches the if statement in baz.
a3627 6
  @@interface X
  - (void)ma; Doesn't match, interface is declaration.
  @@end
  @@implementation X
  - (void)ma {}
  @@end
d3629 1
a3629 2
Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
  Matcher<ObjCMethodDecl>
d3661 1
a3661 1
Matches extern "C" function or variable declarations.
a3666 3
  extern "C" int x = 1;
  extern "C" int y = 2;
  int z = 3;
d3668 1
a3668 3
  matches the declaration of f and g, but not the declaration of h.
varDecl(isExternC())
  matches the declaration of x and y, but not the declaration of z.
a3695 2
or
  template <typename T> class X {}; class A {}; extern template class X<A>;
a3748 11
Matcher<internal::Matcher<ObjCMessageExpr>>hasAnySelectorStringRef, ..., StringRef
Matches when at least one of the supplied string equals to the
Selector.getAsString()

 matcher = objCMessageExpr(hasSelector("methodA:", "methodB:"));
 matches both of the expressions below:
    [myObj methodA:argA];
    [myObj methodB:argB];
d3805 1 a3805 1 Example matches X, A, A::X, B, B::C, B::C::X d3807 2 a3808 3 class X {}; class A { class X {}; }; Matches A, because A::X is a class of name X inside A. d3831 1 a3831 1 Example matches X, Y, Y::X, Z::Y, Z::Y::X d3833 2 a3834 3 class X {}; class Y { class X {}; }; Matches Y, because Y::X is a class of name X inside Y. d3937 1 a3937 1 Matcher<AddrLabelExpr>hasDeclarationconst Matcher<Decl> InnerMatcher d3948 2 a3949 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4072 1 a4072 1 Matcher<BinaryOperator>hasEitherOperandconst Matcher<Expr> InnerMatcher a4093 49 Matcher<BlockDecl>hasAnyParameterMatcher<ParmVarDecl> InnerMatcher
Matches any parameter of a function or an ObjC method declaration or a
block.

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

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

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
matches the declaration of method f with hasParameter
matching y.

For blocks, given
  b = ^(int y) { printf("%d", y) };

the matcher blockDecl(hasAnyParameter(hasName("y")))
matches the declaration of the block b with hasParameter
matching y.
Matcher<BlockDecl>hasParameterunsigned N, Matcher<ParmVarDecl> InnerMatcher
Matches the n'th parameter of a function or an ObjC method
declaration or a block.

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

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasParameter(0, hasName("y")))
matches the declaration of method f with hasParameter
matching y.
d4148 1 a4148 1 expression, or an ObjC-message-send expression. a4155 6 For ObjectiveC, given @@interface I - (void) f:(int) y; @@end void foo(I *i) { [i f:12]; } objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) matches [i f:12] d4169 1 a4169 1 Matcher<CXXConstructExpr>hasDeclarationconst Matcher<Decl> InnerMatcher d4180 2 a4181 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4293 1 a4293 1 void z() { Y y; y.x(); } d4311 1 a4311 1
Matches each method overridden by the given method. This matcher may
d4353 1
a4353 11
Matcher<CXXNewExpr>hasArraySizeMatcher<Expr> InnerMatcher
Matches array new expressions with a given array size.

Given:
  MyClass *p1 = new MyClass[10];
cxxNewExpr(hasArraySize(intgerLiteral(equals(10))))
  matches the expression 'new MyClass[10]'.
Matcher<CXXNewExpr>hasDeclarationconst Matcher<Decl> InnerMatcher d4364 2 a4365 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4467 1 a4467 1 expression, or an ObjC-message-send expression. a4474 6 For ObjectiveC, given @@interface I - (void) f:(int) y; @@end void foo(I *i) { [i f:12]; } objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) matches [i f:12] d4488 1 a4488 1 Matcher<CallExpr>hasDeclarationconst Matcher<Decl> InnerMatcher d4499 2 a4500 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4524 1 a4524 12
Matches if the cast's source expression
or opaque value's source expression matches the given matcher.

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

Example 2: matches 'b' (matcher =
opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
int a = b ?: 1;
a4548 12 Matcher<ClassTemplateSpecializationDecl>hasSpecializedTemplateMatcher<ClassTemplateDecl> InnerMatcher
Matches the specialized template of a specialization declaration.

Given
  tempalate<typename T> class A {};
  typedef A<int> B;
classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl()))
  matches 'B' with classTemplateDecl() matching the class template
  declaration of 'A'.
d4558 1 a4558 1 template<typename T> void f() {} d4617 1 a4617 1 Matcher<DeclRefExpr>hasDeclarationconst Matcher<Decl> InnerMatcher d4628 2 a4629 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4781 1 a4781 1 Matcher<EnumType>hasDeclarationconst Matcher<Decl> InnerMatcher d4792 2 a4793 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4813 2 a4814 2 Matcher<Expr>hasTypeMatcher<Decl> InnerMatcher
Overloaded to match the declaration of the expression's or value
a4824 1
            and friend class X (matcher = friendDecl(hasType("X"))
a4826 1
 class Y { friend class X; };
a4838 1
            and friend class X (matcher = friendDecl(hasType("X"))
a4841 1
 class Y { friend class X; };
d4868 1
a4868 1
Matcher<Expr>ignoringImplicitMatcher<Expr> InnerMatcher
a4986 36
Matcher<FriendDecl>hasTypeMatcher<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;", cxxRecordDecl(hasName("X")) matches the declaration of
X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
declaration of x.

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

Usable as: Matcher<Expr>, Matcher<ValueDecl>
Matcher<FriendDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
matcher.

Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
            and U (matcher = typedefDecl(hasType(asString("int")))
            and friend class X (matcher = friendDecl(hasType("X"))
 class X {};
 void y(X &x) { x; X z; }
 typedef int U;
 class Y { friend class X; };
d4988 1 a4988 2
Matches any parameter of a function or an ObjC method declaration or a
block.
a4997 14

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
matches the declaration of method f with hasParameter
matching y.

For blocks, given
  b = ^(int y) { printf("%d", y) };

the matcher blockDecl(hasAnyParameter(hasName("y")))
matches the declaration of the block b with hasParameter
matching y.
d5037 1
a5037 2
Matches the n'th parameter of a function or an ObjC method
declaration or a block.
a5044 7

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasParameter(0, hasName("y")))
matches the declaration of method f with hasParameter
matching y.
d5057 1
a5057 1
  template<typename T> void f() {}
d5129 1
a5129 1
Matcher<InjectedClassNameType>hasDeclarationconst Matcher<Decl>  InnerMatcher
d5140 2
a5141 11
For type nodes, hasDeclaration will generally match the declaration of the
sugared type. Given
  class X {};
  typedef X Y;
  Y y;
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
typedefDecl. A common use case is to match the underlying, desugared type.
This can be achieved by using the hasUnqualifiedDesugaredType matcher:
  varDecl(hasType(hasUnqualifiedDesugaredType(
      recordType(hasDeclaration(decl())))))
In this matcher, the decl will match the CXXRecordDecl of class X.
d5153 1
a5153 1
Matcher<LabelStmt>hasDeclarationconst Matcher<Decl>  InnerMatcher
d5164 2
a5165 11
For type nodes, hasDeclaration will generally match the declaration of the
sugared type. Given
  class X {};
  typedef X Y;
  Y y;
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
typedefDecl. A common use case is to match the underlying, desugared type.
This can be achieved by using the hasUnqualifiedDesugaredType matcher:
  varDecl(hasType(hasUnqualifiedDesugaredType(
      recordType(hasDeclaration(decl())))))
In this matcher, the decl will match the CXXRecordDecl of class X.
d5177 1
a5177 1
Matcher<MemberExpr>hasDeclarationconst Matcher<Decl>  InnerMatcher
d5188 2
a5189 11
For type nodes, hasDeclaration will generally match the declaration of the
sugared type. Given
  class X {};
  typedef X Y;
  Y y;
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
typedefDecl. A common use case is to match the underlying, desugared type.
This can be achieved by using the hasUnqualifiedDesugaredType matcher:
  varDecl(hasType(hasUnqualifiedDesugaredType(
      recordType(hasDeclaration(decl())))))
In this matcher, the decl will match the CXXRecordDecl of class X.
a5334 19
Matcher<ObjCMessageExpr>hasAnyArgumentMatcher<Expr> InnerMatcher
Matches any argument of a call expression or a constructor call
expression, or an ObjC-message-send 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

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end
  void foo(I *i) { [i f:12]; }
objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
  matches [i f:12]
a5344 12 Matcher<ObjCMessageExpr>hasReceiverMatcher<Expr> InnerMatcher
Matches if the Objective-C message is sent to an instance,
and the inner matcher matches on that instance.

For example the method call in
  NSString *x = @@"hello";
  [x containsString:@@"h"]
is matched by
objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x"))))))
a5356 49 Matcher<ObjCMethodDecl>hasAnyParameterMatcher<ParmVarDecl> InnerMatcher
Matches any parameter of a function or an ObjC method declaration or a
block.

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

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

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
matches the declaration of method f with hasParameter
matching y.

For blocks, given
  b = ^(int y) { printf("%d", y) };

the matcher blockDecl(hasAnyParameter(hasName("y")))
matches the declaration of the block b with hasParameter
matching y.
Matcher<ObjCMethodDecl>hasParameterunsigned N, Matcher<ParmVarDecl> InnerMatcher
Matches the n'th parameter of a function or an ObjC method
declaration or a block.

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

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasParameter(0, hasName("y")))
matches the declaration of method f with hasParameter
matching y.
d5358 1 a5358 12
Matches if the cast's source expression
or opaque value's source expression matches the given matcher.

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

Example 2: matches 'b' (matcher =
opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
int a = b ?: 1;
d5437 1 a5437 1 Matcher<QualType>hasDeclarationconst Matcher<Decl> InnerMatcher d5448 2 a5449 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d5509 1 a5509 1 Matcher<RecordType>hasDeclarationconst Matcher<Decl> InnerMatcher d5520 2 a5521 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d5590 1 a5590 1 Matcher<Stmt>alignOfExprconst Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher d5610 1 a5610 1 Matcher<Stmt>sizeOfExprconst Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher d5652 1 a5652 1 Matcher<TagType>hasDeclarationconst Matcher<Decl> InnerMatcher d5663 2 a5664 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d5680 2 a5681 2 struct B { int next; }; template<int(B::*next_ptr)> struct A {}; d5695 2 a5696 2 struct B { int next; }; template<int(B::*next_ptr)> struct A {}; d5699 1 a5699 1 refersToDeclaration(fieldDecl(hasName("next"))))) d5709 1 a5709 1 template<int T> struct C {}; d5765 1 a5765 1 Matcher<TemplateSpecializationType>hasDeclarationconst Matcher<Decl> InnerMatcher d5776 2 a5777 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d5798 1 a5798 1 template<typename T> void f() {} d5809 1 a5809 1 Matcher<TemplateTypeParmType>hasDeclarationconst Matcher<Decl> InnerMatcher d5820 2 a5821 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d5833 1 a5833 1 Matcher<T>findAllconst Matcher<T> Matcher d5849 2 a5850 2 Matcher<TypedefNameDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
a5855 1
            and friend class X (matcher = friendDecl(hasType("X"))
a5858 1
 class Y { friend class X; };
d5862 1
a5862 1
Matcher<TypedefType>hasDeclarationconst Matcher<Decl>  InnerMatcher
d5873 2
a5874 11
For type nodes, hasDeclaration will generally match the declaration of the
sugared type. Given
  class X {};
  typedef X Y;
  Y y;
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
typedefDecl. A common use case is to match the underlying, desugared type.
This can be achieved by using the hasUnqualifiedDesugaredType matcher:
  varDecl(hasType(hasUnqualifiedDesugaredType(
      recordType(hasDeclaration(decl())))))
In this matcher, the decl will match the CXXRecordDecl of class X.
d5893 1
a5893 1
The matcher type(hasUnqualifeidDesugaredType(recordType())) matches
d5917 1
a5917 1
Matcher<UnresolvedUsingType>hasDeclarationconst Matcher<Decl>  InnerMatcher
d5928 2
a5929 11
For type nodes, hasDeclaration will generally match the declaration of the
sugared type. Given
  class X {};
  typedef X Y;
  Y y;
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
typedefDecl. A common use case is to match the underlying, desugared type.
This can be achieved by using the hasUnqualifiedDesugaredType matcher:
  varDecl(hasType(hasUnqualifiedDesugaredType(
      recordType(hasDeclaration(decl())))))
In this matcher, the decl will match the CXXRecordDecl of class X.
d5963 2
a5964 2
Matcher<ValueDecl>hasTypeMatcher<Decl> InnerMatcher
Overloaded to match the declaration of the expression's or value
a5974 1
            and friend class X (matcher = friendDecl(hasType("X"))
a5976 1
 class Y { friend class X; };
d5982 2
a5983 2
Matcher<ValueDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
a5988 1
            and friend class X (matcher = friendDecl(hasType("X"))
a5991 1
 class Y { friend class X; };
@


1.1.1.9
log
@Import clang r337282 from trunk
@
text
@a126 12
Matcher<Decl>blockDeclMatcher<BlockDecl>...
Matches block declarations.

Example matches the declaration of the nameless block printing an input
integer.

  myFunc(^(int p) {
    printf("%d", p);
  })
a348 18 Matcher<Decl>objcCategoryImplDeclMatcher<ObjCCategoryImplDecl>...
Matches Objective-C category definitions.

Example matches Foo (Additions)
  @@implementation Foo (Additions)
  @@end
Matcher<Decl>objcImplementationDeclMatcher<ObjCImplementationDecl>...
Matches Objective-C implementation declarations.

Example matches Foo
  @@implementation Foo
  @@end
a634 12 Matcher<Stmt>autoreleasePoolStmtMatcher<ObjCAutoreleasePoolStmt>...
Matches an Objective-C autorelease pool statement.

Given
  @@autoreleasepool {
    int x = 0;
  }
autoreleasePoolStmt(stmt()) matches the declaration of "x"
inside the autorelease pool.
d685 1 a685 1 matches 'case 42:'. d726 1 a726 1 Example matches '{}' and '{{}}' in 'for (;;) {{}}' d1013 1 a1013 1 matches 'default:'. a1181 1 f().func(); d1184 1 a1209 18 Matcher<Stmt>objcCatchStmtMatcher<ObjCAtCatchStmt>...
Matches Objective-C @@catch statements.

Example matches @@catch
  @@try {}
  @@catch (...) {}
Matcher<Stmt>objcFinallyStmtMatcher<ObjCAtFinallyStmt>...
Matches Objective-C @@finally statements.

Example matches @@finally
  @@try {}
  @@finally {}
a1220 16 Matcher<Stmt>objcThrowStmtMatcher<ObjCAtThrowStmt>...
Matches Objective-C statements.

Example matches @@throw obj;
Matcher<Stmt>objcTryStmtMatcher<ObjCAtTryStmt>...
Matches Objective-C @@try statements.

Example matches @@try
  @@try {}
  @@catch (...) {}
d1320 1 a1320 1 matches 'case 42:' and 'default:'. a1731 15 Matcher<Type>tagTypeMatcher<TagType>...
Matches tag types (record and enum types).

Given
  enum E {};
  class C {};

  E e;
  C c;

tagType() matches the type of the variable declarations of both e
and c.
d1862 1 a1862 19 Matcher<BinaryOperator>isAssignmentOperator
Matches all kinds of assignment operators.

Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
  if (a == b)
    a += b;

Example 2: matches s1 = s2
           (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
  struct S { S& operator=(const S&); };
  void x() { S s1, s2; s1 = s2; })
Matcher<CXXBoolLiteralExpr>equalsbool Value



Matcher<CXXBoolLiteralExpr>equalsconst ValueT  Value
d1888 4
a2210 10
Matcher<CXXNewExpr>isArray
Matches array new expressions.

Given:
  MyClass *p1 = new MyClass[10];
cxxNewExpr(isArray())
  matches the expression 'new MyClass[10]'.
a2231 23 Matcher<CXXOperatorCallExpr>isAssignmentOperator
Matches all kinds of assignment operators.

Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
  if (a == b)
    a += b;

Example 2: matches s1 = s2
           (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
  struct S { S& operator=(const S&); };
  void x() { S s1, s2; s1 = s2; })
Matcher<CXXRecordDecl>hasDefinition
Matches a class declaration that is defined.

Example matches x (matcher = cxxRecordDecl(hasDefinition()))
class x {};
class y;
a2292 2 or template <typename T> class X {}; class A {}; extern template class X<A>; d2325 1 a2325 5 Matcher<CharacterLiteral>equalsbool Value



Matcher<CharacterLiteral>equalsconst ValueT  Value
d2351 4
a2560 9
Matcher<EnumDecl>isScoped
Matches C++11 scoped enum declaration.

Example matches Y (matcher = enumDecl(isScoped()))
enum X {};
enum class Y {};
d2589 1 a2589 1 Matcher<FloatingLiteral>equalsconst ValueT Value a2656 9 Matcher<FunctionDecl>hasTrailingReturn
Matches a function declared with a trailing return type.

Example matches Y (matcher = functionDecl(hasTrailingReturn()))
int X() {}
auto Y() -> int {}
d2658 1 a2658 2
Matches constexpr variable and function declarations,
       and if constexpr.
a2662 1
  void baz() { if constexpr(1 > 0) {} }
a2666 2
ifStmt(isConstexpr())
  matches the if statement in baz.
d2681 2
a2682 2
Matcher<FunctionDecl>isDefinition
Matches if a declaration has a body attached.
a2690 6
  @@interface X
  - (void)ma; Doesn't match, interface is declaration.
  @@end
  @@implementation X
  - (void)ma {}
  @@end
d2692 1
a2692 2
Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
  Matcher<ObjCMethodDecl>
d2722 1
a2722 1
Matches extern "C" function or variable declarations.
a2727 3
  extern "C" int x = 1;
  extern "C" int y = 2;
  int z = 3;
d2729 1
a2729 3
  matches the declaration of f and g, but not the declaration of h.
varDecl(isExternC())
  matches the declaration of x and y, but not the declaration of z.
a2747 14
Matcher<FunctionDecl>isNoReturn
Matches FunctionDecls that have a noreturn attribute.

Given
  void nope();
  [[noreturn]] void a();
  __attribute__((noreturn)) void b();
  struct c { [[noreturn]] c(); };
functionDecl(isNoReturn())
  matches all of those except
  void nope();
a2785 2 or template <typename T> class X {}; class A {}; extern template class X<A>; d2822 1 a2822 1 matches g and h d2824 1 a2824 1 matches g and h d2826 1 a2826 1 matches k d2872 1 a2872 1 matches g and h d2874 1 a2874 1 matches g and h d2876 1 a2876 1 matches k d2880 1 a2880 22 Matcher<IfStmt>isConstexpr
Matches constexpr variable and function declarations,
       and if constexpr.

Given:
  constexpr int foo = 42;
  constexpr int bar();
  void baz() { if constexpr(1 > 0) {} }
varDecl(isConstexpr())
  matches the declaration of foo.
functionDecl(isConstexpr())
  matches the declaration of bar.
ifStmt(isConstexpr())
  matches the if statement in baz.
Matcher<IntegerLiteral>equalsbool Value



Matcher<IntegerLiteral>equalsconst ValueT  Value
d2906 4
d2955 1
a2955 1
Matcher<NamedDecl>hasNameconst std::string  Name
a3063 13
Matcher<ObjCMessageExpr>isInstanceMessage
Returns true when the Objective-C message is sent to an instance.

Example
matcher = objcMessagaeExpr(isInstanceMessage())
matches
  NSString *x = @@"hello";
  [x containsString:@@"h"]
but not
  [NSString stringWithFormat:@@"format"]
a3085 31 Matcher<ObjCMethodDecl>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.
  @@interface X
  - (void)ma; Doesn't match, interface is declaration.
  @@end
  @@implementation X
  - (void)ma {}
  @@end

Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
  Matcher<ObjCMethodDecl>
Matcher<ParmVarDecl>hasDefaultArgument
Matches a declaration that has default arguments.

Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
void x(int val) {}
void y(int val = 0) {}
a3364 6 @@interface X - (void)ma; Doesn't match, interface is declaration. @@end @@implementation X - (void)ma {} @@end d3366 1 a3366 2 Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>, Matcher<ObjCMethodDecl> d3378 1 a3378 1 template<int T> struct C {}; d3390 1 a3390 1 template<int T> struct C {}; d3606 1 a3606 2
Matches constexpr variable and function declarations,
       and if constexpr.
a3610 1
  void baz() { if constexpr(1 > 0) {} }
a3614 2
ifStmt(isConstexpr())
  matches the if statement in baz.
a3627 6
  @@interface X
  - (void)ma; Doesn't match, interface is declaration.
  @@end
  @@implementation X
  - (void)ma {}
  @@end
d3629 1
a3629 2
Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
  Matcher<ObjCMethodDecl>
d3661 1
a3661 1
Matches extern "C" function or variable declarations.
a3666 3
  extern "C" int x = 1;
  extern "C" int y = 2;
  int z = 3;
d3668 1
a3668 3
  matches the declaration of f and g, but not the declaration of h.
varDecl(isExternC())
  matches the declaration of x and y, but not the declaration of z.
a3695 2
or
  template <typename T> class X {}; class A {}; extern template class X<A>;
a3748 11
Matcher<internal::Matcher<ObjCMessageExpr>>hasAnySelectorStringRef, ..., StringRef
Matches when at least one of the supplied string equals to the
Selector.getAsString()

 matcher = objCMessageExpr(hasSelector("methodA:", "methodB:"));
 matches both of the expressions below:
    [myObj methodA:argA];
    [myObj methodB:argB];
d3805 1 a3805 1 Example matches X, A, A::X, B, B::C, B::C::X d3807 2 a3808 3 class X {}; class A { class X {}; }; Matches A, because A::X is a class of name X inside A. d3831 1 a3831 1 Example matches X, Y, Y::X, Z::Y, Z::Y::X d3833 2 a3834 3 class X {}; class Y { class X {}; }; Matches Y, because Y::X is a class of name X inside Y. d3937 1 a3937 1 Matcher<AddrLabelExpr>hasDeclarationconst Matcher<Decl> InnerMatcher d3948 2 a3949 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4072 1 a4072 1 Matcher<BinaryOperator>hasEitherOperandconst Matcher<Expr> InnerMatcher a4093 49 Matcher<BlockDecl>hasAnyParameterMatcher<ParmVarDecl> InnerMatcher
Matches any parameter of a function or an ObjC method declaration or a
block.

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

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

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
matches the declaration of method f with hasParameter
matching y.

For blocks, given
  b = ^(int y) { printf("%d", y) };

the matcher blockDecl(hasAnyParameter(hasName("y")))
matches the declaration of the block b with hasParameter
matching y.
Matcher<BlockDecl>hasParameterunsigned N, Matcher<ParmVarDecl> InnerMatcher
Matches the n'th parameter of a function or an ObjC method
declaration or a block.

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

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasParameter(0, hasName("y")))
matches the declaration of method f with hasParameter
matching y.
d4148 1 a4148 1 expression, or an ObjC-message-send expression. a4155 6 For ObjectiveC, given @@interface I - (void) f:(int) y; @@end void foo(I *i) { [i f:12]; } objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) matches [i f:12] d4169 1 a4169 1 Matcher<CXXConstructExpr>hasDeclarationconst Matcher<Decl> InnerMatcher d4180 2 a4181 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4293 1 a4293 1 void z() { Y y; y.x(); } d4311 1 a4311 1
Matches each method overridden by the given method. This matcher may
d4353 1
a4353 11
Matcher<CXXNewExpr>hasArraySizeMatcher<Expr> InnerMatcher
Matches array new expressions with a given array size.

Given:
  MyClass *p1 = new MyClass[10];
cxxNewExpr(hasArraySize(intgerLiteral(equals(10))))
  matches the expression 'new MyClass[10]'.
Matcher<CXXNewExpr>hasDeclarationconst Matcher<Decl> InnerMatcher d4364 2 a4365 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4467 1 a4467 1 expression, or an ObjC-message-send expression. a4474 6 For ObjectiveC, given @@interface I - (void) f:(int) y; @@end void foo(I *i) { [i f:12]; } objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) matches [i f:12] d4488 1 a4488 1 Matcher<CallExpr>hasDeclarationconst Matcher<Decl> InnerMatcher d4499 2 a4500 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4524 1 a4524 12
Matches if the cast's source expression
or opaque value's source expression matches the given matcher.

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

Example 2: matches 'b' (matcher =
opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
int a = b ?: 1;
a4548 12 Matcher<ClassTemplateSpecializationDecl>hasSpecializedTemplateMatcher<ClassTemplateDecl> InnerMatcher
Matches the specialized template of a specialization declaration.

Given
  tempalate<typename T> class A {};
  typedef A<int> B;
classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl()))
  matches 'B' with classTemplateDecl() matching the class template
  declaration of 'A'.
d4558 1 a4558 1 template<typename T> void f() {} d4617 1 a4617 1 Matcher<DeclRefExpr>hasDeclarationconst Matcher<Decl> InnerMatcher d4628 2 a4629 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4781 1 a4781 1 Matcher<EnumType>hasDeclarationconst Matcher<Decl> InnerMatcher d4792 2 a4793 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d4813 2 a4814 2 Matcher<Expr>hasTypeMatcher<Decl> InnerMatcher
Overloaded to match the declaration of the expression's or value
a4824 1
            and friend class X (matcher = friendDecl(hasType("X"))
a4826 1
 class Y { friend class X; };
a4838 1
            and friend class X (matcher = friendDecl(hasType("X"))
a4841 1
 class Y { friend class X; };
d4868 1
a4868 1
Matcher<Expr>ignoringImplicitMatcher<Expr> InnerMatcher
a4986 36
Matcher<FriendDecl>hasTypeMatcher<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;", cxxRecordDecl(hasName("X")) matches the declaration of
X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
declaration of x.

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

Usable as: Matcher<Expr>, Matcher<ValueDecl>
Matcher<FriendDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
matcher.

Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
            and U (matcher = typedefDecl(hasType(asString("int")))
            and friend class X (matcher = friendDecl(hasType("X"))
 class X {};
 void y(X &x) { x; X z; }
 typedef int U;
 class Y { friend class X; };
d4988 1 a4988 2
Matches any parameter of a function or an ObjC method declaration or a
block.
a4997 14

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
matches the declaration of method f with hasParameter
matching y.

For blocks, given
  b = ^(int y) { printf("%d", y) };

the matcher blockDecl(hasAnyParameter(hasName("y")))
matches the declaration of the block b with hasParameter
matching y.
d5037 1
a5037 2
Matches the n'th parameter of a function or an ObjC method
declaration or a block.
a5044 7

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasParameter(0, hasName("y")))
matches the declaration of method f with hasParameter
matching y.
d5057 1
a5057 1
  template<typename T> void f() {}
d5129 1
a5129 1
Matcher<InjectedClassNameType>hasDeclarationconst Matcher<Decl>  InnerMatcher
d5140 2
a5141 11
For type nodes, hasDeclaration will generally match the declaration of the
sugared type. Given
  class X {};
  typedef X Y;
  Y y;
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
typedefDecl. A common use case is to match the underlying, desugared type.
This can be achieved by using the hasUnqualifiedDesugaredType matcher:
  varDecl(hasType(hasUnqualifiedDesugaredType(
      recordType(hasDeclaration(decl())))))
In this matcher, the decl will match the CXXRecordDecl of class X.
d5153 1
a5153 1
Matcher<LabelStmt>hasDeclarationconst Matcher<Decl>  InnerMatcher
d5164 2
a5165 11
For type nodes, hasDeclaration will generally match the declaration of the
sugared type. Given
  class X {};
  typedef X Y;
  Y y;
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
typedefDecl. A common use case is to match the underlying, desugared type.
This can be achieved by using the hasUnqualifiedDesugaredType matcher:
  varDecl(hasType(hasUnqualifiedDesugaredType(
      recordType(hasDeclaration(decl())))))
In this matcher, the decl will match the CXXRecordDecl of class X.
d5177 1
a5177 1
Matcher<MemberExpr>hasDeclarationconst Matcher<Decl>  InnerMatcher
d5188 2
a5189 11
For type nodes, hasDeclaration will generally match the declaration of the
sugared type. Given
  class X {};
  typedef X Y;
  Y y;
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
typedefDecl. A common use case is to match the underlying, desugared type.
This can be achieved by using the hasUnqualifiedDesugaredType matcher:
  varDecl(hasType(hasUnqualifiedDesugaredType(
      recordType(hasDeclaration(decl())))))
In this matcher, the decl will match the CXXRecordDecl of class X.
a5334 19
Matcher<ObjCMessageExpr>hasAnyArgumentMatcher<Expr> InnerMatcher
Matches any argument of a call expression or a constructor call
expression, or an ObjC-message-send 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

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end
  void foo(I *i) { [i f:12]; }
objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
  matches [i f:12]
a5344 12 Matcher<ObjCMessageExpr>hasReceiverMatcher<Expr> InnerMatcher
Matches if the Objective-C message is sent to an instance,
and the inner matcher matches on that instance.

For example the method call in
  NSString *x = @@"hello";
  [x containsString:@@"h"]
is matched by
objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x"))))))
a5356 49 Matcher<ObjCMethodDecl>hasAnyParameterMatcher<ParmVarDecl> InnerMatcher
Matches any parameter of a function or an ObjC method declaration or a
block.

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

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

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
matches the declaration of method f with hasParameter
matching y.

For blocks, given
  b = ^(int y) { printf("%d", y) };

the matcher blockDecl(hasAnyParameter(hasName("y")))
matches the declaration of the block b with hasParameter
matching y.
Matcher<ObjCMethodDecl>hasParameterunsigned N, Matcher<ParmVarDecl> InnerMatcher
Matches the n'th parameter of a function or an ObjC method
declaration or a block.

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

For ObjectiveC, given
  @@interface I - (void) f:(int) y; @@end

the matcher objcMethodDecl(hasParameter(0, hasName("y")))
matches the declaration of method f with hasParameter
matching y.
d5358 1 a5358 12
Matches if the cast's source expression
or opaque value's source expression matches the given matcher.

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

Example 2: matches 'b' (matcher =
opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
int a = b ?: 1;
d5437 1 a5437 1 Matcher<QualType>hasDeclarationconst Matcher<Decl> InnerMatcher d5448 2 a5449 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d5509 1 a5509 1 Matcher<RecordType>hasDeclarationconst Matcher<Decl> InnerMatcher d5520 2 a5521 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d5590 1 a5590 1 Matcher<Stmt>alignOfExprconst Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher d5610 1 a5610 1 Matcher<Stmt>sizeOfExprconst Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher d5652 1 a5652 1 Matcher<TagType>hasDeclarationconst Matcher<Decl> InnerMatcher d5663 2 a5664 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d5680 2 a5681 2 struct B { int next; }; template<int(B::*next_ptr)> struct A {}; d5695 2 a5696 2 struct B { int next; }; template<int(B::*next_ptr)> struct A {}; d5699 1 a5699 1 refersToDeclaration(fieldDecl(hasName("next"))))) d5709 1 a5709 1 template<int T> struct C {}; d5765 1 a5765 1 Matcher<TemplateSpecializationType>hasDeclarationconst Matcher<Decl> InnerMatcher d5776 2 a5777 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d5798 1 a5798 1 template<typename T> void f() {} d5809 1 a5809 1 Matcher<TemplateTypeParmType>hasDeclarationconst Matcher<Decl> InnerMatcher d5820 2 a5821 11 For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given class X {}; typedef X Y; Y y; in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration(decl()))))) In this matcher, the decl will match the CXXRecordDecl of class X. d5833 1 a5833 1 Matcher<T>findAllconst Matcher<T> Matcher d5849 2 a5850 2 Matcher<TypedefNameDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
a5855 1
            and friend class X (matcher = friendDecl(hasType("X"))
a5858 1
 class Y { friend class X; };
d5862 1
a5862 1
Matcher<TypedefType>hasDeclarationconst Matcher<Decl>  InnerMatcher
d5873 2
a5874 11
For type nodes, hasDeclaration will generally match the declaration of the
sugared type. Given
  class X {};
  typedef X Y;
  Y y;
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
typedefDecl. A common use case is to match the underlying, desugared type.
This can be achieved by using the hasUnqualifiedDesugaredType matcher:
  varDecl(hasType(hasUnqualifiedDesugaredType(
      recordType(hasDeclaration(decl())))))
In this matcher, the decl will match the CXXRecordDecl of class X.
d5893 1
a5893 1
The matcher type(hasUnqualifeidDesugaredType(recordType())) matches
d5917 1
a5917 1
Matcher<UnresolvedUsingType>hasDeclarationconst Matcher<Decl>  InnerMatcher
d5928 2
a5929 11
For type nodes, hasDeclaration will generally match the declaration of the
sugared type. Given
  class X {};
  typedef X Y;
  Y y;
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
typedefDecl. A common use case is to match the underlying, desugared type.
This can be achieved by using the hasUnqualifiedDesugaredType matcher:
  varDecl(hasType(hasUnqualifiedDesugaredType(
      recordType(hasDeclaration(decl())))))
In this matcher, the decl will match the CXXRecordDecl of class X.
d5963 2
a5964 2
Matcher<ValueDecl>hasTypeMatcher<Decl> InnerMatcher
Overloaded to match the declaration of the expression's or value
a5974 1
            and friend class X (matcher = friendDecl(hasType("X"))
a5976 1
 class Y { friend class X; };
d5982 2
a5983 2
Matcher<ValueDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
a5988 1
            and friend class X (matcher = friendDecl(hasType("X"))
a5991 1
 class Y { friend class X; };
@


1.1.1.10
log
@Mark old LLVM instance as dead.
@
text
@@


1.1.1.4.4.1
log
@file LibASTMatchersReference.html was added on branch tls-maxphys on 2014-08-19 23:47:19 +0000
@
text
@d1 3907
@


1.1.1.4.4.2
log
@Rebase to HEAD as of a few days ago.
@
text
@a0 3907



AST Matcher Reference









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:

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 typeNameParameters
Matcher<CXXCtorInitializer>ctorInitializerMatcher<CXXCtorInitializer>...
Matches constructor initializers.

Examples matches i(42).
  class C {
    C() : i(42) {}
    int i;
  };
Matcher<Decl>accessSpecDeclMatcher<AccessSpecDecl>...
Matches C++ access specifier declarations.

Given
  class C {
  public:
    int a;
  };
accessSpecDecl()
  matches 'public:'
Matcher<Decl>classTemplateDeclMatcher<ClassTemplateDecl>...
Matches C++ class template declarations.

Example matches Z
  template<class T> class Z {};
Matcher<Decl>classTemplateSpecializationDeclMatcher<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>constructorDeclMatcher<CXXConstructorDecl>...
Matches C++ constructor declarations.

Example matches Foo::Foo() and Foo::Foo(int)
  class Foo {
   public:
    Foo();
    Foo(int);
    int DoSomething();
  };
Matcher<Decl>declMatcher<Decl>...
Matches declarations.

Examples matches X, C, and the friend declaration inside C;
  void X();
  class C {
    friend X;
  };
Matcher<Decl>declaratorDeclMatcher<DeclaratorDecl>...
Matches declarator declarations (field, variable, function
and non-type template parameter declarations).

Given
  class X { int y; };
declaratorDecl()
  matches int y.
Matcher<Decl>destructorDeclMatcher<CXXDestructorDecl>...
Matches explicit C++ destructor declarations.

Example matches Foo::~Foo()
  class Foo {
   public:
    virtual ~Foo();
  };
Matcher<Decl>enumConstantDeclMatcher<EnumConstantDecl>...
Matches enum constants.

Example matches A, B, C
  enum X {
    A, B, C
  };
Matcher<Decl>enumDeclMatcher<EnumDecl>...
Matches enum declarations.

Example matches X
  enum X {
    A, B, C
  };
Matcher<Decl>fieldDeclMatcher<FieldDecl>...
Matches field declarations.

Given
  class X { int m; };
fieldDecl()
  matches 'm'.
Matcher<Decl>friendDeclMatcher<FriendDecl>...
Matches friend declarations.

Given
  class X { friend void foo(); };
friendDecl()
  matches 'friend void foo()'.
Matcher<Decl>functionDeclMatcher<FunctionDecl>...
Matches function declarations.

Example matches f
  void f();
Matcher<Decl>functionTemplateDeclMatcher<FunctionTemplateDecl>...
Matches C++ function template declarations.

Example matches f
  template<class T> void f(T t) {}
Matcher<Decl>methodDeclMatcher<CXXMethodDecl>...
Matches method declarations.

Example matches y
  class X { void y(); };
Matcher<Decl>namedDeclMatcher<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>namespaceDeclMatcher<NamespaceDecl>...
Matches a declaration of a namespace.

Given
  namespace {}
  namespace test {}
namespaceDecl()
  matches "namespace {}" and "namespace test {}"
Matcher<Decl>parmVarDeclMatcher<ParmVarDecl>...
Matches parameter variable declarations.

Given
  void f(int x);
parmVarDecl()
  matches int x.
Matcher<Decl>recordDeclMatcher<CXXRecordDecl>...
Matches C++ class declarations.

Example matches X, Z
  class X;
  template<class T> class Z {};
Matcher<Decl>unresolvedUsingValueDeclMatcher<UnresolvedUsingValueDecl>...
Matches unresolved using value declarations.

Given
  template<typename X>
  class C : private X {
    using X::x;
  };
unresolvedUsingValueDecl()
  matches using X::x 
Matcher<Decl>usingDeclMatcher<UsingDecl>...
Matches using declarations.

Given
  namespace X { int x; }
  using X::x;
usingDecl()
  matches using X::x 
Matcher<Decl>usingDirectiveDeclMatcher<UsingDirectiveDecl>...
Matches using namespace declarations.

Given
  namespace X { int x; }
  using namespace X;
usingDirectiveDecl()
  matches using namespace X 
Matcher<Decl>varDeclMatcher<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>nestedNameSpecifierLocMatcher<NestedNameSpecifierLoc>...
Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
Matcher<NestedNameSpecifier>nestedNameSpecifierMatcher<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>qualTypeMatcher<QualType>...
Matches QualTypes in the clang AST.
Matcher<Stmt>CUDAKernelCallExprMatcher<CUDAKernelCallExpr>...
Matches CUDA kernel call expression.

Example matches kernel<<<i,j>>>()
  kernel<<<i,j>>>();
Matcher<Stmt>arraySubscriptExprMatcher<ArraySubscriptExpr>...
Matches array subscript expressions.

Given
  int i = a[1];
arraySubscriptExpr()
  matches "a[1]"
Matcher<Stmt>asmStmtMatcher<AsmStmt>...
Matches asm statements.

 int i = 100;
  __asm("mov al, 2");
asmStmt()
  matches '__asm("mov al, 2")'
Matcher<Stmt>binaryOperatorMatcher<BinaryOperator>...
Matches binary operator expressions.

Example matches a || b
  !(a || b)
Matcher<Stmt>bindTemporaryExprMatcher<CXXBindTemporaryExpr>...
Matches nodes where temporaries are created.

Example matches FunctionTakesString(GetStringByValue())
    (matcher = bindTemporaryExpr())
  FunctionTakesString(GetStringByValue());
  FunctionTakesStringByPointer(GetStringPointer());
Matcher<Stmt>boolLiteralMatcher<CXXBoolLiteralExpr>...
Matches bool literals.

Example matches true
  true
Matcher<Stmt>breakStmtMatcher<BreakStmt>...
Matches break statements.

Given
  while (true) { break; }
breakStmt()
  matches 'break'
Matcher<Stmt>cStyleCastExprMatcher<CStyleCastExpr>...
Matches a C-style cast expression.

Example: Matches (int*) 2.2f in
  int i = (int) 2.2f;
Matcher<Stmt>callExprMatcher<CallExpr>...
Matches call expressions.

Example matches x.y() and y()
  X x;
  x.y();
  y();
Matcher<Stmt>caseStmtMatcher<CaseStmt>...
Matches case statements inside switch statements.

Given
  switch(a) { case 42: break; default: break; }
caseStmt()
  matches 'case 42: break;'.
Matcher<Stmt>castExprMatcher<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>catchStmtMatcher<CXXCatchStmt>...
Matches catch statements.

  try {} catch(int i) {}
catchStmt()
  matches 'catch(int i)'
Matcher<Stmt>characterLiteralMatcher<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>compoundLiteralExprMatcher<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>compoundStmtMatcher<CompoundStmt>...
Matches compound statements.

Example matches '{}' and '{{}}'in 'for (;;) {{}}'
  for (;;) {{}}
Matcher<Stmt>conditionalOperatorMatcher<ConditionalOperator>...
Matches conditional operator expressions.

Example matches a ? b : c
  (a ? b : c) + 42
Matcher<Stmt>constCastExprMatcher<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>constructExprMatcher<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>continueStmtMatcher<ContinueStmt>...
Matches continue statements.

Given
  while (true) { continue; }
continueStmt()
  matches 'continue'
Matcher<Stmt>declRefExprMatcher<DeclRefExpr>...
Matches expressions that refer to declarations.

Example matches x in if (x)
  bool x;
  if (x) {}
Matcher<Stmt>declStmtMatcher<DeclStmt>...
Matches declaration statements.

Given
  int a;
declStmt()
  matches 'int a'.
Matcher<Stmt>defaultArgExprMatcher<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>defaultStmtMatcher<DefaultStmt>...
Matches default statements inside switch statements.

Given
  switch(a) { case 42: break; default: break; }
defaultStmt()
  matches 'default: break;'.
Matcher<Stmt>deleteExprMatcher<CXXDeleteExpr>...
Matches delete expressions.

Given
  delete X;
deleteExpr()
  matches 'delete X'.
Matcher<Stmt>doStmtMatcher<DoStmt>...
Matches do statements.

Given
  do {} while (true);
doStmt()
  matches 'do {} while(true)'
Matcher<Stmt>dynamicCastExprMatcher<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>explicitCastExprMatcher<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>exprMatcher<Expr>...
Matches expressions.

Example matches x()
  void f() { x(); }
Matcher<Stmt>exprWithCleanupsMatcher<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>floatLiteralMatcher<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>forRangeStmtMatcher<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>forStmtMatcher<ForStmt>...
Matches for statements.

Example matches 'for (;;) {}'
  for (;;) {}
  int i[] =  {1, 2, 3}; for (auto a : i);
Matcher<Stmt>functionalCastExprMatcher<CXXFunctionalCastExpr>...
Matches functional cast expressions

Example: Matches Foo(bar);
  Foo f = bar;
  Foo g = (Foo) bar;
  Foo h = Foo(bar);
Matcher<Stmt>gotoStmtMatcher<GotoStmt>...
Matches goto statements.

Given
  goto FOO;
  FOO: bar();
gotoStmt()
  matches 'goto FOO'
Matcher<Stmt>ifStmtMatcher<IfStmt>...
Matches if statements.

Example matches 'if (x) {}'
  if (x) {}
Matcher<Stmt>implicitCastExprMatcher<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>initListExprMatcher<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>integerLiteralMatcher<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>labelStmtMatcher<LabelStmt>...
Matches label statements.

Given
  goto FOO;
  FOO: bar();
labelStmt()
  matches 'FOO:'
Matcher<Stmt>lambdaExprMatcher<LambdaExpr>...
Matches lambda expressions.

Example matches [&](){return 5;}
  [&](){return 5;}
Matcher<Stmt>materializeTemporaryExprMatcher<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>memberCallExprMatcher<CXXMemberCallExpr>...
Matches member call expressions.

Example matches x.y()
  X x;
  x.y();
Matcher<Stmt>memberExprMatcher<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>newExprMatcher<CXXNewExpr>...
Matches new expressions.

Given
  new X;
newExpr()
  matches 'new X'.
Matcher<Stmt>nullPtrLiteralExprMatcher<CXXNullPtrLiteralExpr>...
Matches nullptr literal.
Matcher<Stmt>nullStmtMatcher<NullStmt>...
Matches null statements.

  foo();;
nullStmt()
  matches the second ';'
Matcher<Stmt>operatorCallExprMatcher<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>reinterpretCastExprMatcher<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>returnStmtMatcher<ReturnStmt>...
Matches return statements.

Given
  return 1;
returnStmt()
  matches 'return 1'
Matcher<Stmt>staticCastExprMatcher<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>stmtMatcher<Stmt>...
Matches statements.

Given
  { ++a; }
stmt()
  matches both the compound statement '{ ++a; }' and '++a'.
Matcher<Stmt>stringLiteralMatcher<StringLiteral>...
Matches string literals (also matches wide string literals).

Example matches "abcd", L"abcd"
  char *s = "abcd"; wchar_t *ws = L"abcd"
Matcher<Stmt>substNonTypeTemplateParmExprMatcher<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>switchCaseMatcher<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>switchStmtMatcher<SwitchStmt>...
Matches switch statements.

Given
  switch(a) { case 42: break; default: break; }
switchStmt()
  matches 'switch(a)'.
Matcher<Stmt>temporaryObjectExprMatcher<CXXTemporaryObjectExpr>...
Matches functional cast expressions having N != 1 arguments

Example: Matches Foo(bar, bar)
  Foo h = Foo(bar, bar);
Matcher<Stmt>thisExprMatcher<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>throwExprMatcher<CXXThrowExpr>...
Matches throw expressions.

  try { throw 5; } catch(int i) {}
throwExpr()
  matches 'throw 5'
Matcher<Stmt>tryStmtMatcher<CXXTryStmt>...
Matches try statements.

  try {} catch(int i) {}
tryStmt()
  matches 'try {}'
Matcher<Stmt>unaryExprOrTypeTraitExprMatcher<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>unaryOperatorMatcher<UnaryOperator>...
Matches unary operator expressions.

Example matches !a
  !a || b
Matcher<Stmt>unresolvedConstructExprMatcher<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>userDefinedLiteralMatcher<UserDefinedLiteral>...
Matches user defined literal operator call.

Example match: "foo"_suffix
Matcher<Stmt>whileStmtMatcher<WhileStmt>...
Matches while statements.

Given
  while (true) {}
whileStmt()
  matches 'while (true) {}'.
Matcher<TypeLoc>typeLocMatcher<TypeLoc>...
Matches TypeLocs in the clang AST.
Matcher<Type>arrayTypeMatcher<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>atomicTypeMatcher<AtomicType>...
Matches atomic types.

Given
  _Atomic(int) i;
atomicType()
  matches "_Atomic(int) i"
Matcher<Type>autoTypeMatcher<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>blockPointerTypeMatcher<BlockPointerType>...
Matches block pointer types, i.e. types syntactically represented as
"void (^)(int)".

The pointee is always required to be a FunctionType.
Matcher<Type>builtinTypeMatcher<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>complexTypeMatcher<ComplexType>...
Matches C99 complex types.

Given
  _Complex float f;
complexType()
  matches "_Complex float f"
Matcher<Type>constantArrayTypeMatcher<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>dependentSizedArrayTypeMatcher<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>elaboratedTypeMatcher<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>functionTypeMatcher<FunctionType>...
Matches FunctionType nodes.

Given
  int (*f)(int);
  void g();
functionType()
  matches "int (*f)(int)" and the type of "g".
Matcher<Type>incompleteArrayTypeMatcher<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>lValueReferenceTypeMatcher<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>memberPointerTypeMatcher<MemberPointerType>...
Matches member pointer types.
Given
  struct A { int i; }
  A::* ptr = A::i;
memberPointerType()
  matches "A::* ptr"
Matcher<Type>parenTypeMatcher<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>pointerTypeMatcher<PointerType>...
Matches pointer types.

Given
  int *a;
  int &b = *a;
  int c = 5;
pointerType()
  matches "int *a"
Matcher<Type>rValueReferenceTypeMatcher<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>recordTypeMatcher<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>referenceTypeMatcher<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>templateSpecializationTypeMatcher<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>typeMatcher<Type>...
Matches Types in the clang AST.
Matcher<Type>typedefTypeMatcher<TypedefType>...
Matches typedef types.

Given
  typedef int X;
typedefType()
  matches "typedef int X"
Matcher<Type>unaryTransformTypeMatcher<UnaryTransformType>...
Matches types nodes representing unary type transformations.

Given:
  typedef __underlying_type(T) type;
unaryTransformType()
  matches "__underlying_type(T)"
Matcher<Type>variableArrayTypeMatcher<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 typeNameParameters
Matcher<*>allOfMatcher<*>, ..., Matcher<*>
Matches if all given matchers match.

Usable as: Any Matcher
Matcher<*>anyOfMatcher<*>, ..., 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<*>unlessMatcher<*>
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>hasOperatorNamestd::string Name
Matches the operator Name of operator expressions (binary or
unary).

Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
  !(a || b)
Matcher<CXXBoolLiteral>equalsValueT 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>argumentCountIsunsigned 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>hasOverloadedOperatorNameStringRef 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>isDerivedFromStringRef 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>isSameOrDerivedFromStringRef 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>argumentCountIsunsigned 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>equalsValueT 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<CompoundStmt>statementCountIsunsigned 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>hasSizeunsigned 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>declCountIsunsigned 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>equalsBoundNodestd::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>hasCudaDeviceAttr
Matches declaration that has CUDA device attribute.

Given
  __attribute__((device)) void f() { ... }
matches the function declaration of f.
Matcher<Decl>hasCudaGlobalAttr
Matches declaration that has CUDA global attribute.

Given
  __attribute__((global)) void f() { ... }
matches the function declaration of f.
Matcher<Decl>hasCudaHostAttr
Matches declaration that has CUDA host attribute.

Given
  __attribute__((host)) void f() { ... }
matches the function declaration of f.
Matcher<Decl>isImplicit
Matches a declaration that has been implicitly added
by the compiler (eg. implicit defaultcopy constructors).
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>equalsValueT 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>hasOverloadedOperatorNameStringRef 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>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>parameterCountIsunsigned 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>equalsValueT 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>hasNamestd::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>matchesNamestd::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>asStringstd::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>equalsBoundNodestd::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>equalsBoundNodestd::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<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<Type>equalsBoundNodestd::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>ofKindUnaryExprOrTypeTrait 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>hasOperatorNamestd::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 typeNameParameters
Matcher<*>eachOfMatcher<*>, ..., 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<*>forEachDescendantMatcher<*>
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<*>forEachMatcher<*>
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<*>hasAncestorMatcher<*>
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<*>hasDescendantMatcher<*>
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<*>hasMatcher<*>
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<*>hasParentMatcher<*>
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>hasBaseMatcher<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>hasIndexMatcher<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>hasElementTypeLocMatcher<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>hasElementTypeMatcher<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>hasValueTypeLocMatcher<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>hasValueTypeMatcher<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>hasDeducedTypeMatcher<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>hasEitherOperandMatcher<Expr> InnerMatcher
Matches if either the left hand side or the right hand side of a
binary operator matches.
Matcher<BinaryOperator>hasLHSMatcher<Expr> InnerMatcher
Matches the left hand side of binary operator expressions.

Example matches a (matcher = binaryOperator(hasLHS()))
  a || b
Matcher<BinaryOperator>hasRHSMatcher<Expr> InnerMatcher
Matches the right hand side of binary operator expressions.

Example matches b (matcher = binaryOperator(hasRHS()))
  a || b
Matcher<BlockPointerTypeLoc>pointeeLocMatcher<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>pointeeMatcher<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>hasAnyArgumentMatcher<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>hasArgumentunsigned 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>hasDeclarationMatcher<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>forEachConstructorInitializerMatcher<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>hasAnyConstructorInitializerMatcher<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>forFieldMatcher<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>withInitializerMatcher<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>hasBodyMatcher<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>hasLoopVariableMatcher<VarDecl> InnerMatcher
Matches the initialization statement of a for loop.

Example:
    forStmt(hasLoopVariable(anything()))
matches 'int x' in
    for (int x : a) { }
Matcher<CXXForRangeStmt>hasRangeInitMatcher<Expr> InnerMatcher
Matches the range initialization statement of a for loop.

Example:
    forStmt(hasRangeInit(anything()))
matches 'a' in
    for (int x : a) { }
Matcher<CXXMemberCallExpr>onImplicitObjectArgumentMatcher<Expr> InnerMatcher
Matcher<CXXMemberCallExpr>onMatcher<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>thisPointerTypeMatcher<Decl> InnerMatcher
Overloaded to match the type's declaration.
Matcher<CXXMemberCallExpr>thisPointerTypeMatcher<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>ofClassMatcher<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>hasMethodMatcher<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>isDerivedFromMatcher<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>isSameOrDerivedFromMatcher<NamedDecl> Base
Similar to isDerivedFrom(), but also matches classes that directly
match Base.
Matcher<CallExpr>calleeMatcher<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>calleeMatcher<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>hasAnyArgumentMatcher<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>hasArgumentunsigned 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>hasDeclarationMatcher<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>hasCaseConstantMatcher<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>hasSourceExpressionMatcher<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>hasAnyTemplateArgumentMatcher<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>hasTemplateArgumentunsigned 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>hasElementTypeLocMatcher<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>hasElementTypeMatcher<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>hasAnySubstatementMatcher<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>hasConditionMatcher<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>hasFalseExpressionMatcher<Expr> InnerMatcher
Matches the false branch expression of a conditional operator.

Example matches b
  condition ? a : b
Matcher<ConditionalOperator>hasTrueExpressionMatcher<Expr> InnerMatcher
Matches the true branch expression of a conditional operator.

Example matches a
  condition ? a : b
Matcher<DeclRefExpr>hasDeclarationMatcher<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>throughUsingDeclMatcher<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>toMatcher<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>containsDeclarationunsigned 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>hasSingleDeclMatcher<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>hasTypeLocMatcher<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>hasDeclContextMatcher<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>hasBodyMatcher<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>hasConditionMatcher<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>hasQualifierMatcher<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>namesTypeMatcher<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>hasDeclarationMatcher<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>hasDestinationTypeMatcher<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>hasTypeMatcher<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>hasTypeMatcher<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>ignoringImpCastsMatcher<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>ignoringParenCastsMatcher<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>ignoringParenImpCastsMatcher<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>hasBodyMatcher<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>hasConditionMatcher<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>hasIncrementMatcher<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>hasLoopInitMatcher<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>hasAnyParameterMatcher<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>hasParameterunsigned 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>returnsMatcher<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>hasConditionMatcher<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>hasConditionVariableStatementMatcher<DeclStmt> InnerMatcher
Matches the condition variable statement in an if statement.

Given
  if (A* a = GetAPointer()) {}
hasConditionVariableStatement(...)
  matches 'A* a = GetAPointer()'.
Matcher<IfStmt>hasElseMatcher<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>hasThenMatcher<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>hasImplicitDestinationTypeMatcher<QualType> InnerMatcher
Matches implicit casts whose destination type matches a given
matcher.

FIXME: Unit test this matcher
Matcher<InjectedClassNameType>hasDeclarationMatcher<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>hasDeclarationMatcher<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>hasDeclarationMatcher<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>hasObjectExpressionMatcher<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>memberMatcher<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>pointeeLocMatcher<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>pointeeMatcher<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>hasPrefixMatcher<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>specifiesTypeLocMatcher<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>hasPrefixMatcher<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>specifiesNamespaceMatcher<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>specifiesTypeMatcher<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>innerTypeMatcher<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>pointeeLocMatcher<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>pointeeMatcher<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>hasCanonicalTypeMatcher<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>hasDeclarationMatcher<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>pointsToMatcher<Decl> InnerMatcher
Overloaded to match the pointee type's declaration.
Matcher<QualType>pointsToMatcher<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>referencesMatcher<Decl> InnerMatcher
Overloaded to match the referenced type's declaration.
Matcher<QualType>referencesMatcher<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>hasDeclarationMatcher<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>pointeeLocMatcher<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>pointeeMatcher<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>alignOfExprMatcher<UnaryExprOrTypeTraitExpr> InnerMatcher
Same as unaryExprOrTypeTraitExpr, but only matching
alignof.
Matcher<Stmt>sizeOfExprMatcher<UnaryExprOrTypeTraitExpr> InnerMatcher
Same as unaryExprOrTypeTraitExpr, but only matching
sizeof.
Matcher<SwitchStmt>forEachSwitchCaseMatcher<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>hasDeclarationMatcher<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>isExprMatcher<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>refersToDeclarationMatcher<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>refersToTypeMatcher<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>hasAnyTemplateArgumentMatcher<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>hasDeclarationMatcher<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>hasTemplateArgumentunsigned 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>hasDeclarationMatcher<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>findAllMatcher<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>hasDeclarationMatcher<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>hasArgumentOfTypeMatcher<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>hasUnaryOperandMatcher<Expr> InnerMatcher
Matches if the operand of a unary operator matches.

Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true))))
  !true
Matcher<UnresolvedUsingType>hasDeclarationMatcher<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>hasAnyUsingShadowDeclMatcher<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>hasTargetDeclMatcher<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>hasTypeMatcher<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>hasTypeMatcher<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>hasInitializerMatcher<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>hasSizeExprMatcher<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>hasBodyMatcher<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>hasConditionMatcher<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>>locMatcher<NestedNameSpecifier> InnerMatcher
Matches NestedNameSpecifierLocs for which the given inner
NestedNameSpecifier-matcher matches.
Matcher<internal::BindableMatcher<TypeLoc>>locMatcher<QualType> InnerMatcher
Matches TypeLocs for which the given inner
QualType-matcher matches.
@ 1.1.1.2.4.1 log @file LibASTMatchersReference.html was added on branch yamt-pagecache on 2014-05-22 16:18:19 +0000 @ text @d1 3788 @ 1.1.1.2.4.2 log @sync with head. for a reference, the tree before this commit was tagged as yamt-pagecache-tag8. this commit was splitted into small chunks to avoid a limitation of cvs. ("Protocol error: too many arguments") @ text @a0 3788 AST Matcher Reference

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:

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 typeNameParameters
Matcher<CXXCtorInitializer>ctorInitializerMatcher<CXXCtorInitializer>...
Matches constructor initializers.

Examples matches i(42).
  class C {
    C() : i(42) {}
    int i;
  };
Matcher<Decl>accessSpecDeclMatcher<AccessSpecDecl>...
Matches C++ access specifier declarations.

Given
  class C {
  public:
    int a;
  };
accessSpecDecl()
  matches 'public:'
Matcher<Decl>classTemplateDeclMatcher<ClassTemplateDecl>...
Matches C++ class template declarations.

Example matches Z
  template<class T> class Z {};
Matcher<Decl>classTemplateSpecializationDeclMatcher<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>constructorDeclMatcher<CXXConstructorDecl>...
Matches C++ constructor declarations.

Example matches Foo::Foo() and Foo::Foo(int)
  class Foo {
   public:
    Foo();
    Foo(int);
    int DoSomething();
  };
Matcher<Decl>declMatcher<Decl>...
Matches declarations.

Examples matches X, C, and the friend declaration inside C;
  void X();
  class C {
    friend X;
  };
Matcher<Decl>declaratorDeclMatcher<DeclaratorDecl>...
Matches declarator declarations (field, variable, function
and non-type template parameter declarations).

Given
  class X { int y; };
declaratorDecl()
  matches int y.
Matcher<Decl>destructorDeclMatcher<CXXDestructorDecl>...
Matches explicit C++ destructor declarations.

Example matches Foo::~Foo()
  class Foo {
   public:
    virtual ~Foo();
  };
Matcher<Decl>enumConstantDeclMatcher<EnumConstantDecl>...
Matches enum constants.

Example matches A, B, C
  enum X {
    A, B, C
  };
Matcher<Decl>enumDeclMatcher<EnumDecl>...
Matches enum declarations.

Example matches X
  enum X {
    A, B, C
  };
Matcher<Decl>fieldDeclMatcher<FieldDecl>...
Matches field declarations.

Given
  class X { int m; };
fieldDecl()
  matches 'm'.
Matcher<Decl>friendDeclMatcher<FriendDecl>...
Matches friend declarations.

Given
  class X { friend void foo(); };
friendDecl()
  matches 'friend void foo()'.
Matcher<Decl>functionDeclMatcher<FunctionDecl>...
Matches function declarations.

Example matches f
  void f();
Matcher<Decl>functionTemplateDeclMatcher<FunctionTemplateDecl>...
Matches C++ function template declarations.

Example matches f
  template<class T> void f(T t) {}
Matcher<Decl>methodDeclMatcher<CXXMethodDecl>...
Matches method declarations.

Example matches y
  class X { void y(); };
Matcher<Decl>namedDeclMatcher<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>namespaceDeclMatcher<NamespaceDecl>...
Matches a declaration of a namespace.

Given
  namespace {}
  namespace test {}
namespaceDecl()
  matches "namespace {}" and "namespace test {}"
Matcher<Decl>parmVarDeclMatcher<ParmVarDecl>...
Matches parameter variable declarations.

Given
  void f(int x);
parmVarDecl()
  matches int x.
Matcher<Decl>recordDeclMatcher<CXXRecordDecl>...
Matches C++ class declarations.

Example matches X, Z
  class X;
  template<class T> class Z {};
Matcher<Decl>unresolvedUsingValueDeclMatcher<UnresolvedUsingValueDecl>...
Matches unresolved using value declarations.

Given
  template<typename X>
  class C : private X {
    using X::x;
  };
unresolvedUsingValueDecl()
  matches using X::x 
Matcher<Decl>usingDeclMatcher<UsingDecl>...
Matches using declarations.

Given
  namespace X { int x; }
  using X::x;
usingDecl()
  matches using X::x 
Matcher<Decl>varDeclMatcher<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>nestedNameSpecifierLocMatcher<NestedNameSpecifierLoc>...
Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
Matcher<NestedNameSpecifier>nestedNameSpecifierMatcher<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>qualTypeMatcher<QualType>...
Matches QualTypes in the clang AST.
Matcher<Stmt>arraySubscriptExprMatcher<ArraySubscriptExpr>...
Matches array subscript expressions.

Given
  int i = a[1];
arraySubscriptExpr()
  matches "a[1]"
Matcher<Stmt>asmStmtMatcher<AsmStmt>...
Matches asm statements.

 int i = 100;
  __asm("mov al, 2");
asmStmt()
  matches '__asm("mov al, 2")'
Matcher<Stmt>binaryOperatorMatcher<BinaryOperator>...
Matches binary operator expressions.

Example matches a || b
  !(a || b)
Matcher<Stmt>bindTemporaryExprMatcher<CXXBindTemporaryExpr>...
Matches nodes where temporaries are created.

Example matches FunctionTakesString(GetStringByValue())
    (matcher = bindTemporaryExpr())
  FunctionTakesString(GetStringByValue());
  FunctionTakesStringByPointer(GetStringPointer());
Matcher<Stmt>boolLiteralMatcher<CXXBoolLiteralExpr>...
Matches bool literals.

Example matches true
  true
Matcher<Stmt>breakStmtMatcher<BreakStmt>...
Matches break statements.

Given
  while (true) { break; }
breakStmt()
  matches 'break'
Matcher<Stmt>cStyleCastExprMatcher<CStyleCastExpr>...
Matches a C-style cast expression.

Example: Matches (int*) 2.2f in
  int i = (int) 2.2f;
Matcher<Stmt>callExprMatcher<CallExpr>...
Matches call expressions.

Example matches x.y() and y()
  X x;
  x.y();
  y();
Matcher<Stmt>caseStmtMatcher<CaseStmt>...
Matches case statements inside switch statements.

Given
  switch(a) { case 42: break; default: break; }
caseStmt()
  matches 'case 42: break;'.
Matcher<Stmt>castExprMatcher<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>catchStmtMatcher<CXXCatchStmt>...
Matches catch statements.

  try {} catch(int i) {}
catchStmt()
  matches 'catch(int i)'
Matcher<Stmt>characterLiteralMatcher<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>compoundLiteralExprMatcher<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>compoundStmtMatcher<CompoundStmt>...
Matches compound statements.

Example matches '{}' and '{{}}'in 'for (;;) {{}}'
  for (;;) {{}}
Matcher<Stmt>conditionalOperatorMatcher<ConditionalOperator>...
Matches conditional operator expressions.

Example matches a ? b : c
  (a ? b : c) + 42
Matcher<Stmt>constCastExprMatcher<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>constructExprMatcher<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>continueStmtMatcher<ContinueStmt>...
Matches continue statements.

Given
  while (true) { continue; }
continueStmt()
  matches 'continue'
Matcher<Stmt>declRefExprMatcher<DeclRefExpr>...
Matches expressions that refer to declarations.

Example matches x in if (x)
  bool x;
  if (x) {}
Matcher<Stmt>declStmtMatcher<DeclStmt>...
Matches declaration statements.

Given
  int a;
declStmt()
  matches 'int a'.
Matcher<Stmt>defaultArgExprMatcher<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>defaultStmtMatcher<DefaultStmt>...
Matches default statements inside switch statements.

Given
  switch(a) { case 42: break; default: break; }
defaultStmt()
  matches 'default: break;'.
Matcher<Stmt>deleteExprMatcher<CXXDeleteExpr>...
Matches delete expressions.

Given
  delete X;
deleteExpr()
  matches 'delete X'.
Matcher<Stmt>doStmtMatcher<DoStmt>...
Matches do statements.

Given
  do {} while (true);
doStmt()
  matches 'do {} while(true)'
Matcher<Stmt>dynamicCastExprMatcher<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>explicitCastExprMatcher<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>exprMatcher<Expr>...
Matches expressions.

Example matches x()
  void f() { x(); }
Matcher<Stmt>floatLiteralMatcher<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>forRangeStmtMatcher<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>forStmtMatcher<ForStmt>...
Matches for statements.

Example matches 'for (;;) {}'
  for (;;) {}
  int i[] =  {1, 2, 3}; for (auto a : i);
Matcher<Stmt>functionalCastExprMatcher<CXXFunctionalCastExpr>...
Matches functional cast expressions

Example: Matches Foo(bar);
  Foo f = bar;
  Foo g = (Foo) bar;
  Foo h = Foo(bar);
Matcher<Stmt>gotoStmtMatcher<GotoStmt>...
Matches goto statements.

Given
  goto FOO;
  FOO: bar();
gotoStmt()
  matches 'goto FOO'
Matcher<Stmt>ifStmtMatcher<IfStmt>...
Matches if statements.

Example matches 'if (x) {}'
  if (x) {}
Matcher<Stmt>implicitCastExprMatcher<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>initListExprMatcher<InitListExpr>...
Matches init list expressions.

Given
  int a[] = { 1, 2 };
  struct B { int x, y; };
  B b = { 5, 6 };
initList()
  matches "{ 1, 2 }" and "{ 5, 6 }"
Matcher<Stmt>integerLiteralMatcher<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>labelStmtMatcher<LabelStmt>...
Matches label statements.

Given
  goto FOO;
  FOO: bar();
labelStmt()
  matches 'FOO:'
Matcher<Stmt>lambdaExprMatcher<LambdaExpr>...
Matches lambda expressions.

Example matches [&](){return 5;}
  [&](){return 5;}
Matcher<Stmt>materializeTemporaryExprMatcher<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>memberCallExprMatcher<CXXMemberCallExpr>...
Matches member call expressions.

Example matches x.y()
  X x;
  x.y();
Matcher<Stmt>memberExprMatcher<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>newExprMatcher<CXXNewExpr>...
Matches new expressions.

Given
  new X;
newExpr()
  matches 'new X'.
Matcher<Stmt>nullPtrLiteralExprMatcher<CXXNullPtrLiteralExpr>...
Matches nullptr literal.
Matcher<Stmt>nullStmtMatcher<NullStmt>...
Matches null statements.

  foo();;
nullStmt()
  matches the second ';'
Matcher<Stmt>operatorCallExprMatcher<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>reinterpretCastExprMatcher<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>returnStmtMatcher<ReturnStmt>...
Matches return statements.

Given
  return 1;
returnStmt()
  matches 'return 1'
Matcher<Stmt>staticCastExprMatcher<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>stmtMatcher<Stmt>...
Matches statements.

Given
  { ++a; }
stmt()
  matches both the compound statement '{ ++a; }' and '++a'.
Matcher<Stmt>stringLiteralMatcher<StringLiteral>...
Matches string literals (also matches wide string literals).

Example matches "abcd", L"abcd"
  char *s = "abcd"; wchar_t *ws = L"abcd"
Matcher<Stmt>switchCaseMatcher<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>switchStmtMatcher<SwitchStmt>...
Matches switch statements.

Given
  switch(a) { case 42: break; default: break; }
switchStmt()
  matches 'switch(a)'.
Matcher<Stmt>temporaryObjectExprMatcher<CXXTemporaryObjectExpr>...
Matches functional cast expressions having N != 1 arguments

Example: Matches Foo(bar, bar)
  Foo h = Foo(bar, bar);
Matcher<Stmt>thisExprMatcher<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>throwExprMatcher<CXXThrowExpr>...
Matches throw expressions.

  try { throw 5; } catch(int i) {}
throwExpr()
  matches 'throw 5'
Matcher<Stmt>tryStmtMatcher<CXXTryStmt>...
Matches try statements.

  try {} catch(int i) {}
tryStmt()
  matches 'try {}'
Matcher<Stmt>unaryExprOrTypeTraitExprMatcher<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>unaryOperatorMatcher<UnaryOperator>...
Matches unary operator expressions.

Example matches !a
  !a || b
Matcher<Stmt>unresolvedConstructExprMatcher<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>userDefinedLiteralMatcher<UserDefinedLiteral>...
Matches user defined literal operator call.

Example match: "foo"_suffix
Matcher<Stmt>whileStmtMatcher<WhileStmt>...
Matches while statements.

Given
  while (true) {}
whileStmt()
  matches 'while (true) {}'.
Matcher<TypeLoc>typeLocMatcher<TypeLoc>...
Matches TypeLocs in the clang AST.
Matcher<Type>arrayTypeMatcher<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>atomicTypeMatcher<AtomicType>...
Matches atomic types.

Given
  _Atomic(int) i;
atomicType()
  matches "_Atomic(int) i"
Matcher<Type>autoTypeMatcher<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>blockPointerTypeMatcher<BlockPointerType>...
Matches block pointer types, i.e. types syntactically represented as
"void (^)(int)".

The pointee is always required to be a FunctionType.
Matcher<Type>builtinTypeMatcher<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>complexTypeMatcher<ComplexType>...
Matches C99 complex types.

Given
  _Complex float f;
complexType()
  matches "_Complex float f"
Matcher<Type>constantArrayTypeMatcher<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>dependentSizedArrayTypeMatcher<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>elaboratedTypeMatcher<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>functionTypeMatcher<FunctionType>...
Matches FunctionType nodes.

Given
  int (*f)(int);
  void g();
functionType()
  matches "int (*f)(int)" and the type of "g".
Matcher<Type>incompleteArrayTypeMatcher<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>lValueReferenceTypeMatcher<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>memberPointerTypeMatcher<MemberPointerType>...
Matches member pointer types.
Given
  struct A { int i; }
  A::* ptr = A::i;
memberPointerType()
  matches "A::* ptr"
Matcher<Type>parenTypeMatcher<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>pointerTypeMatcher<PointerType>...
Matches pointer types.

Given
  int *a;
  int &b = *a;
  int c = 5;
pointerType()
  matches "int *a"
Matcher<Type>rValueReferenceTypeMatcher<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>recordTypeMatcher<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>referenceTypeMatcher<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>templateSpecializationTypeMatcher<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>typeMatcher<Type>...
Matches Types in the clang AST.
Matcher<Type>typedefTypeMatcher<TypedefType>...
Matches typedef types.

Given
  typedef int X;
typedefType()
  matches "typedef int X"
Matcher<Type>unaryTransformTypeMatcher<UnaryTransformType>...
Matches types nodes representing unary type transformations.

Given:
  typedef __underlying_type(T) type;
unaryTransformType()
  matches "__underlying_type(T)"
Matcher<Type>variableArrayTypeMatcher<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 typeNameParameters
Matcher<*>allOfMatcher<*>, ..., Matcher<*>
Matches if all given matchers match.

Usable as: Any Matcher
Matcher<*>anyOfMatcher<*>, ..., 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<*>unlessMatcher<*>
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>hasOperatorNamestd::string Name
Matches the operator Name of operator expressions (binary or
unary).

Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
  !(a || b)
Matcher<CXXBoolLiteral>equalsValueT 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>argumentCountIsunsigned 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<CXXConstructorDecl>isImplicit
Matches a constructor declaration that has been implicitly added
by the compiler (eg. implicit defaultcopy constructors).
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>hasOverloadedOperatorNameStringRef 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<CXXMethodDecl>
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>hasOverloadedOperatorNameStringRef 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<CXXMethodDecl>
Matcher<CXXRecordDecl>isDerivedFromStringRef 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>isSameOrDerivedFromStringRef 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>argumentCountIsunsigned 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>equalsValueT 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<CompoundStmt>statementCountIsunsigned 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>hasSizeunsigned 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>declCountIsunsigned 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>equalsBoundNodestd::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>equalsNodeDecl* Other
Matches if a node equals another node.

Decl has pointer identity in the AST.
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>equalsValueT 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>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>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>parameterCountIsunsigned 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>equalsValueT 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>hasNamestd::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>matchesNamestd::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>asStringstd::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>equalsBoundNodestd::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>equalsBoundNodestd::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>equalsNodeStmt* Other
Matches if a node equals another node.

Stmt has pointer identity in the AST.

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<Type>equalsBoundNodestd::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>ofKindUnaryExprOrTypeTrait 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>hasOperatorNamestd::string Name
Matches the operator Name of operator expressions (binary or
unary).

Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
  !(a || b)
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 typeNameParameters
Matcher<*>eachOfMatcher<*>, ..., 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<*>forEachDescendantMatcher<*>
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<*>forEachMatcher<*>
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<*>hasAncestorMatcher<*>
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<*>hasDescendantMatcher<*>
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<*>hasMatcher<*>
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<*>hasParentMatcher<*>
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>hasBaseMatcher<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>hasIndexMatcher<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>hasElementTypeLocMatcher<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>hasElementTypeMatcher<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>hasValueTypeLocMatcher<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>hasValueTypeMatcher<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>hasDeducedTypeMatcher<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>hasEitherOperandMatcher<Expr> InnerMatcher
Matches if either the left hand side or the right hand side of a
binary operator matches.
Matcher<BinaryOperator>hasLHSMatcher<Expr> InnerMatcher
Matches the left hand side of binary operator expressions.

Example matches a (matcher = binaryOperator(hasLHS()))
  a || b
Matcher<BinaryOperator>hasRHSMatcher<Expr> InnerMatcher
Matches the right hand side of binary operator expressions.

Example matches b (matcher = binaryOperator(hasRHS()))
  a || b
Matcher<BlockPointerTypeLoc>pointeeLocMatcher<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>pointeeMatcher<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>hasAnyArgumentMatcher<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>hasArgumentunsigned 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>hasDeclarationMatcher<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>forEachConstructorInitializerMatcher<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>hasAnyConstructorInitializerMatcher<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>forFieldMatcher<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>withInitializerMatcher<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>hasLoopVariableMatcher<VarDecl> InnerMatcher
Matches the initialization statement of a for loop.

Example:
    forStmt(hasLoopVariable(anything()))
matches 'int x' in
    for (int x : a) { }
Matcher<CXXMemberCallExpr>onImplicitObjectArgumentMatcher<Expr> InnerMatcher
Matcher<CXXMemberCallExpr>onMatcher<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>thisPointerTypeMatcher<Decl> InnerMatcher
Overloaded to match the type's declaration.
Matcher<CXXMemberCallExpr>thisPointerTypeMatcher<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>ofClassMatcher<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>hasMethodMatcher<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>isDerivedFromMatcher<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>isSameOrDerivedFromMatcher<NamedDecl> Base
Similar to isDerivedFrom(), but also matches classes that directly
match Base.
Matcher<CallExpr>calleeMatcher<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>calleeMatcher<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>hasAnyArgumentMatcher<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>hasArgumentunsigned 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>hasDeclarationMatcher<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>hasCaseConstantMatcher<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>hasSourceExpressionMatcher<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>hasAnyTemplateArgumentMatcher<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>hasTemplateArgumentunsigned 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>hasElementTypeLocMatcher<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>hasElementTypeMatcher<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>hasAnySubstatementMatcher<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>hasConditionMatcher<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>hasFalseExpressionMatcher<Expr> InnerMatcher
Matches the false branch expression of a conditional operator.

Example matches b
  condition ? a : b
Matcher<ConditionalOperator>hasTrueExpressionMatcher<Expr> InnerMatcher
Matches the true branch expression of a conditional operator.

Example matches a
  condition ? a : b
Matcher<DeclRefExpr>hasDeclarationMatcher<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>throughUsingDeclMatcher<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>toMatcher<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>containsDeclarationunsigned 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>hasSingleDeclMatcher<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>hasTypeLocMatcher<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>hasDeclContextMatcher<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>hasBodyMatcher<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>hasConditionMatcher<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>hasQualifierMatcher<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>namesTypeMatcher<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>hasDeclarationMatcher<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>hasDestinationTypeMatcher<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>hasTypeMatcher<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>hasTypeMatcher<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>ignoringImpCastsMatcher<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>ignoringParenCastsMatcher<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>ignoringParenImpCastsMatcher<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>hasBodyMatcher<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>hasConditionMatcher<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>hasIncrementMatcher<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>hasLoopInitMatcher<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>hasAnyParameterMatcher<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>hasParameterunsigned 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>returnsMatcher<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>hasConditionMatcher<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>hasConditionVariableStatementMatcher<DeclStmt> InnerMatcher
Matches the condition variable statement in an if statement.

Given
  if (A* a = GetAPointer()) {}
hasConditionVariableStatement(...)
  matches 'A* a = GetAPointer()'.
Matcher<ImplicitCastExpr>hasImplicitDestinationTypeMatcher<QualType> InnerMatcher
Matches implicit casts whose destination type matches a given
matcher.

FIXME: Unit test this matcher
Matcher<InjectedClassNameType>hasDeclarationMatcher<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>hasDeclarationMatcher<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>hasDeclarationMatcher<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>hasObjectExpressionMatcher<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>memberMatcher<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>pointeeLocMatcher<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>pointeeMatcher<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>hasPrefixMatcher<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>locMatcher<NestedNameSpecifier> InnerMatcher
Matches NestedNameSpecifierLocs for which the given inner
NestedNameSpecifier-matcher matches.
Matcher<NestedNameSpecifierLoc>specifiesTypeLocMatcher<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>hasPrefixMatcher<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>specifiesNamespaceMatcher<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>specifiesTypeMatcher<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>innerTypeMatcher<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>pointeeLocMatcher<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>pointeeMatcher<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>hasCanonicalTypeMatcher<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>hasDeclarationMatcher<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>pointsToMatcher<Decl> InnerMatcher
Overloaded to match the pointee type's declaration.
Matcher<QualType>pointsToMatcher<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>referencesMatcher<Decl> InnerMatcher
Overloaded to match the referenced type's declaration.
Matcher<QualType>referencesMatcher<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>hasDeclarationMatcher<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>pointeeLocMatcher<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>pointeeMatcher<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>alignOfExprMatcher<UnaryExprOrTypeTraitExpr> InnerMatcher
Same as unaryExprOrTypeTraitExpr, but only matching
alignof.
Matcher<Stmt>sizeOfExprMatcher<UnaryExprOrTypeTraitExpr> InnerMatcher
Same as unaryExprOrTypeTraitExpr, but only matching
sizeof.
Matcher<SwitchStmt>forEachSwitchCaseMatcher<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>hasDeclarationMatcher<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>isExprMatcher<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>refersToDeclarationMatcher<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>refersToTypeMatcher<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>hasAnyTemplateArgumentMatcher<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>hasDeclarationMatcher<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>hasTemplateArgumentunsigned 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>hasDeclarationMatcher<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>findAllMatcher<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<TypeLoc>locMatcher<QualType> InnerMatcher
Matches TypeLocs for which the given inner
QualType-matcher matches.
Matcher<TypedefType>hasDeclarationMatcher<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>hasArgumentOfTypeMatcher<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>hasUnaryOperandMatcher<Expr> InnerMatcher
Matches if the operand of a unary operator matches.

Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true))))
  !true
Matcher<UnresolvedUsingType>hasDeclarationMatcher<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>hasAnyUsingShadowDeclMatcher<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>hasTargetDeclMatcher<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>hasTypeMatcher<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>hasTypeMatcher<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>hasInitializerMatcher<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>hasSizeExprMatcher<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>hasBodyMatcher<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>hasConditionMatcher<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) {}
@