14da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//===--- ASTMatchers.h - Structural query framework -------------*- C++ -*-===//
24da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//
34da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//                     The LLVM Compiler Infrastructure
44da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//
54da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek// This file is distributed under the University of Illinois Open Source
64da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek// License. See LICENSE.TXT for details.
74da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//
84da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//===----------------------------------------------------------------------===//
94da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//
104da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  This file implements matchers to be used together with the MatchFinder to
114da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  match AST nodes.
124da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//
134da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  Matchers are created by generator functions, which can be combined in
144da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  a functional in-language DSL to express queries over the C++ AST.
154da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//
164da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  For example, to match a class with a certain name, one would call:
172dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper//    recordDecl(hasName("MyClass"))
184da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  which returns a matcher that can be used to find all AST nodes that declare
194da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  a class named 'MyClass'.
204da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//
214da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  For more complicated match expressions we're often interested in accessing
224da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  multiple parts of the matched AST nodes once a match is found. In that case,
234da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  use the id(...) matcher around the match expressions that match the nodes
244da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  you want to access.
254da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//
264da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  For example, when we're interested in child classes of a certain class, we
274da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  would write:
282dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper//    recordDecl(hasName("MyClass"), hasChild(id("child", recordDecl())))
294da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  When the match is found via the MatchFinder, a user provided callback will
304da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  be called with a BoundNodes instance that contains a mapping from the
314da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  strings that we provided for the id(...) calls to the nodes that were
324da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  matched.
334da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  In the given example, each time our matcher finds a match we get a callback
344da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  where "child" is bound to the CXXRecordDecl node of the matching child
354da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  class declaration.
364da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//
374da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  See ASTMatchersInternal.h for a more in-depth explanation of the
384da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  implementation details of the matcher framework.
394da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//
404da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  See ASTMatchFinder.h for how to use the generated matchers to run over
414da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//  an AST.
424da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//
434da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek//===----------------------------------------------------------------------===//
444da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
454da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek#ifndef LLVM_CLANG_AST_MATCHERS_AST_MATCHERS_H
464da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek#define LLVM_CLANG_AST_MATCHERS_AST_MATCHERS_H
474da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
48de9ed71c696bee936a21323f61548164de0eda13Enea Zaffanella#include "clang/AST/DeclFriend.h"
49e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper#include "clang/AST/DeclTemplate.h"
504da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek#include "clang/ASTMatchers/ASTMatchersInternal.h"
514da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek#include "clang/ASTMatchers/ASTMatchersMacros.h"
524da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek#include "llvm/ADT/Twine.h"
53e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper#include "llvm/Support/Regex.h"
54425f41b370a8795fbca9ffc3b35e9b0ccbb15d97Sam Panzer#include <iterator>
554da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
564da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimeknamespace clang {
574da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimeknamespace ast_matchers {
584da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
594da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Maps string IDs to AST nodes matched by parts of a matcher.
604da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
6125466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// The bound nodes are generated by calling \c bind("id") on the node matchers
6225466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// of the nodes we want to access later.
634da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
6425466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// The instances of BoundNodes are created by \c MatchFinder when the user's
654da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// callbacks are executed every time a match is found.
664da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimekclass BoundNodes {
674da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimekpublic:
6825466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek  /// \brief Returns the AST node bound to \c ID.
69a78d0d6203a990b88c9c3e4c4f2a277001e8bd46Manuel Klimek  ///
7025466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek  /// Returns NULL if there was no node bound to \c ID or if there is a node but
714da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek  /// it cannot be converted to the specified type.
72ec2a396c6f11b4017e30f1865f7b62c5a42425b8Manuel Klimek  template <typename T>
73a78d0d6203a990b88c9c3e4c4f2a277001e8bd46Manuel Klimek  const T *getNodeAs(StringRef ID) const {
74ec2a396c6f11b4017e30f1865f7b62c5a42425b8Manuel Klimek    return MyBoundNodes.getNodeAs<T>(ID);
75ec2a396c6f11b4017e30f1865f7b62c5a42425b8Manuel Klimek  }
76ec2a396c6f11b4017e30f1865f7b62c5a42425b8Manuel Klimek
77ec2a396c6f11b4017e30f1865f7b62c5a42425b8Manuel Klimek  /// \brief Deprecated. Please use \c getNodeAs instead.
784da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek  /// @{
794da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek  template <typename T>
804da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek  const T *getDeclAs(StringRef ID) const {
81a78d0d6203a990b88c9c3e4c4f2a277001e8bd46Manuel Klimek    return getNodeAs<T>(ID);
824da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek  }
834da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek  template <typename T>
844da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek  const T *getStmtAs(StringRef ID) const {
85a78d0d6203a990b88c9c3e4c4f2a277001e8bd46Manuel Klimek    return getNodeAs<T>(ID);
864da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek  }
874da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek  /// @}
884da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
893f0e0402d8cd40b428f975f1a3607dbbd94d2ca6Peter Collingbourne  /// \brief Type of mapping from binding identifiers to bound nodes. This type
903f0e0402d8cd40b428f975f1a3607dbbd94d2ca6Peter Collingbourne  /// is an associative container with a key type of \c std::string and a value
913f0e0402d8cd40b428f975f1a3607dbbd94d2ca6Peter Collingbourne  /// type of \c clang::ast_type_traits::DynTypedNode
923f0e0402d8cd40b428f975f1a3607dbbd94d2ca6Peter Collingbourne  typedef internal::BoundNodesMap::IDToNodeMap IDToNodeMap;
933f0e0402d8cd40b428f975f1a3607dbbd94d2ca6Peter Collingbourne
943f0e0402d8cd40b428f975f1a3607dbbd94d2ca6Peter Collingbourne  /// \brief Retrieve mapping from binding identifiers to bound nodes.
953f0e0402d8cd40b428f975f1a3607dbbd94d2ca6Peter Collingbourne  const IDToNodeMap &getMap() const {
963f0e0402d8cd40b428f975f1a3607dbbd94d2ca6Peter Collingbourne    return MyBoundNodes.getMap();
973f0e0402d8cd40b428f975f1a3607dbbd94d2ca6Peter Collingbourne  }
983f0e0402d8cd40b428f975f1a3607dbbd94d2ca6Peter Collingbourne
994da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimekprivate:
1004da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek  /// \brief Create BoundNodes from a pre-filled map of bindings.
101ec2a396c6f11b4017e30f1865f7b62c5a42425b8Manuel Klimek  BoundNodes(internal::BoundNodesMap &MyBoundNodes)
102ec2a396c6f11b4017e30f1865f7b62c5a42425b8Manuel Klimek      : MyBoundNodes(MyBoundNodes) {}
1034da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
104ec2a396c6f11b4017e30f1865f7b62c5a42425b8Manuel Klimek  internal::BoundNodesMap MyBoundNodes;
1054da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
106054d049174eb1ec8e93a4a0831c0d8caac00cb3aManuel Klimek  friend class internal::BoundNodesTreeBuilder;
1074da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek};
1084da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
10925466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \brief If the provided matcher matches a node, binds the node to \c ID.
1104da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
11125466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// FIXME: Do we want to support this now that we have bind()?
1124da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimektemplate <typename T>
1134da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimekinternal::Matcher<T> id(const std::string &ID,
1149f17408d50c1d76c5eab435e4ceb924cc10757abManuel Klimek                        const internal::BindableMatcher<T> &InnerMatcher) {
1159f17408d50c1d76c5eab435e4ceb924cc10757abManuel Klimek  return InnerMatcher.bind(ID);
1164da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek}
1174da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
1184da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Types of matchers for the top-level classes in the AST class
1194da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// hierarchy.
1204da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// @{
121e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jaspertypedef internal::Matcher<Decl> DeclarationMatcher;
122e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jaspertypedef internal::Matcher<Stmt> StatementMatcher;
123ce62007526cdf718faed10df5e9fc7c3cd160cdeDaniel Jaspertypedef internal::Matcher<QualType> TypeMatcher;
124ce62007526cdf718faed10df5e9fc7c3cd160cdeDaniel Jaspertypedef internal::Matcher<TypeLoc> TypeLocMatcher;
125a7564433191601cb8851196b8dde39392c9c05eeDaniel Jaspertypedef internal::Matcher<NestedNameSpecifier> NestedNameSpecifierMatcher;
126a7564433191601cb8851196b8dde39392c9c05eeDaniel Jaspertypedef internal::Matcher<NestedNameSpecifierLoc> NestedNameSpecifierLocMatcher;
1274da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// @}
1284da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
1294da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches any node.
1304da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
1314da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Useful when another matcher requires a child matcher, but there's no
1324da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// additional constraint. This will often be used with an explicit conversion
13325466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// to an \c internal::Matcher<> type such as \c TypeMatcher.
1344da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
13525466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// Example: \c DeclarationMatcher(anything()) matches all declarations, e.g.,
13625466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
1374da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// "int* p" and "void f()" in
1384da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   int* p;
1394da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   void f();
14025466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
14125466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek///
14225466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// Usable as: Any Matcher
143abe922342d67d4ffe05b366a5a2af972185272f8Daniel Jasperinline internal::PolymorphicMatcherWithParam0<internal::TrueMatcher>
144abe922342d67d4ffe05b366a5a2af972185272f8Daniel Jasperanything() {
1454da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek  return internal::PolymorphicMatcherWithParam0<internal::TrueMatcher>();
1464da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek}
1474da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
148715c9568ee5d75f25dab98229c87bcec880daf5dManuel Klimek/// \brief Matches declarations.
149715c9568ee5d75f25dab98229c87bcec880daf5dManuel Klimek///
150715c9568ee5d75f25dab98229c87bcec880daf5dManuel Klimek/// Examples matches \c X, \c C, and the friend declaration inside \c C;
151715c9568ee5d75f25dab98229c87bcec880daf5dManuel Klimek/// \code
152715c9568ee5d75f25dab98229c87bcec880daf5dManuel Klimek///   void X();
153715c9568ee5d75f25dab98229c87bcec880daf5dManuel Klimek///   class C {
154715c9568ee5d75f25dab98229c87bcec880daf5dManuel Klimek///     friend X;
155715c9568ee5d75f25dab98229c87bcec880daf5dManuel Klimek///   };
156715c9568ee5d75f25dab98229c87bcec880daf5dManuel Klimek/// \endcode
15706b247f0ffb69854e32150c80f347a9376d3709bManuel Klimekconst internal::VariadicAllOfMatcher<Decl> decl;
158715c9568ee5d75f25dab98229c87bcec880daf5dManuel Klimek
1594da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches a declaration of anything that could have a name.
1604da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
16125466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// Example matches \c X, \c S, the anonymous union type, \c i, and \c U;
16225466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
1634da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   typedef int X;
1644da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   struct S {
1654da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///     union {
1664da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///       int i;
1674da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///     } U;
1684da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   };
16925466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
1702dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasperconst internal::VariadicDynCastAllOfMatcher<Decl, NamedDecl> namedDecl;
1714da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
172abe922342d67d4ffe05b366a5a2af972185272f8Daniel Jasper/// \brief Matches a declaration of a namespace.
173abe922342d67d4ffe05b366a5a2af972185272f8Daniel Jasper///
174abe922342d67d4ffe05b366a5a2af972185272f8Daniel Jasper/// Given
175abe922342d67d4ffe05b366a5a2af972185272f8Daniel Jasper/// \code
176abe922342d67d4ffe05b366a5a2af972185272f8Daniel Jasper///   namespace {}
177abe922342d67d4ffe05b366a5a2af972185272f8Daniel Jasper///   namespace test {}
178abe922342d67d4ffe05b366a5a2af972185272f8Daniel Jasper/// \endcode
179abe922342d67d4ffe05b366a5a2af972185272f8Daniel Jasper/// namespaceDecl()
180abe922342d67d4ffe05b366a5a2af972185272f8Daniel Jasper///   matches "namespace {}" and "namespace test {}"
181abe922342d67d4ffe05b366a5a2af972185272f8Daniel Jasperconst internal::VariadicDynCastAllOfMatcher<Decl, NamespaceDecl> namespaceDecl;
182abe922342d67d4ffe05b366a5a2af972185272f8Daniel Jasper
1834da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches C++ class declarations.
1844da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
18525466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// Example matches \c X, \c Z
18625466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
1874da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   class X;
1884da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   template<class T> class Z {};
18925466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
1904da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimekconst internal::VariadicDynCastAllOfMatcher<
191e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper  Decl,
1922dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper  CXXRecordDecl> recordDecl;
193e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper
1948456ae602783b615019a42f7d5c6f0e71639b11bDmitri Gribenko/// \brief Matches C++ class template declarations.
1958456ae602783b615019a42f7d5c6f0e71639b11bDmitri Gribenko///
19625466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// Example matches \c Z
19725466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
1988456ae602783b615019a42f7d5c6f0e71639b11bDmitri Gribenko///   template<class T> class Z {};
19925466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
2008456ae602783b615019a42f7d5c6f0e71639b11bDmitri Gribenkoconst internal::VariadicDynCastAllOfMatcher<
2018456ae602783b615019a42f7d5c6f0e71639b11bDmitri Gribenko  Decl,
2022dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper  ClassTemplateDecl> classTemplateDecl;
2038456ae602783b615019a42f7d5c6f0e71639b11bDmitri Gribenko
204e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// \brief Matches C++ class template specializations.
205e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///
206e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// Given
20725466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
208e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   template<typename T> class A {};
209e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   template<> class A<double> {};
210e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   A<int> a;
21125466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
2122dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper/// classTemplateSpecializationDecl()
213e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   matches the specializations \c A<int> and \c A<double>
214e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasperconst internal::VariadicDynCastAllOfMatcher<
215e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper  Decl,
2162dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper  ClassTemplateSpecializationDecl> classTemplateSpecializationDecl;
217e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper
2181a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek/// \brief Matches declarator declarations (field, variable, function
2191a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek/// and non-type template parameter declarations).
2201a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek///
2211a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek/// Given
2221a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek/// \code
2231a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek///   class X { int y; };
2241a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek/// \endcode
2251a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek/// declaratorDecl()
2261a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek///   matches \c int y.
2271a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimekconst internal::VariadicDynCastAllOfMatcher<Decl, DeclaratorDecl>
2281a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek    declaratorDecl;
2291a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek
2301a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek/// \brief Matches parameter variable declarations.
2311a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek///
2321a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek/// Given
2331a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek/// \code
2341a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek///   void f(int x);
2351a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek/// \endcode
2361a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek/// parmVarDecl()
2371a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek///   matches \c int x.
2381a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimekconst internal::VariadicDynCastAllOfMatcher<Decl, ParmVarDecl> parmVarDecl;
2391a68afd5bbecd05a3bb22854954aa4e5448c4470Manuel Klimek
240f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// \brief Matches C++ access specifier declarations.
241f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///
242f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// Given
243f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// \code
244f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   class C {
245f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   public:
246f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///     int a;
247f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   };
248f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// \endcode
249f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// accessSpecDecl()
250f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   matches 'public:'
251f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasperconst internal::VariadicDynCastAllOfMatcher<
252f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper  Decl,
253f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper  AccessSpecDecl> accessSpecDecl;
254f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper
25506963013d1972f1f7a58875bb40976b60522700bManuel Klimek/// \brief Matches constructor initializers.
25606963013d1972f1f7a58875bb40976b60522700bManuel Klimek///
25706963013d1972f1f7a58875bb40976b60522700bManuel Klimek/// Examples matches \c i(42).
25806963013d1972f1f7a58875bb40976b60522700bManuel Klimek/// \code
25906963013d1972f1f7a58875bb40976b60522700bManuel Klimek///   class C {
26006963013d1972f1f7a58875bb40976b60522700bManuel Klimek///     C() : i(42) {}
26106963013d1972f1f7a58875bb40976b60522700bManuel Klimek///     int i;
26206963013d1972f1f7a58875bb40976b60522700bManuel Klimek///   };
26306963013d1972f1f7a58875bb40976b60522700bManuel Klimek/// \endcode
26406963013d1972f1f7a58875bb40976b60522700bManuel Klimekconst internal::VariadicAllOfMatcher<CXXCtorInitializer> ctorInitializer;
26506963013d1972f1f7a58875bb40976b60522700bManuel Klimek
266f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// \brief Matches public C++ declarations.
267f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///
268f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// Given
269f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// \code
270f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   class C {
271f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   public:    int a;
272f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   protected: int b;
273f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   private:   int c;
274f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   };
275f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// \endcode
276f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// fieldDecl(isPublic())
277f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   matches 'int a;'
278f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel JasperAST_MATCHER(Decl, isPublic) {
279f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper  return Node.getAccess() == AS_public;
280f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper}
281f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper
282f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// \brief Matches protected C++ declarations.
283f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///
284f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// Given
285f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// \code
286f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   class C {
287f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   public:    int a;
288f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   protected: int b;
289f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   private:   int c;
290f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   };
291f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// \endcode
292f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// fieldDecl(isProtected())
293f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   matches 'int b;'
294f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel JasperAST_MATCHER(Decl, isProtected) {
295f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper  return Node.getAccess() == AS_protected;
296f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper}
297f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper
298f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// \brief Matches private C++ declarations.
299f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///
300f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// Given
301f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// \code
302f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   class C {
303f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   public:    int a;
304f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   protected: int b;
305f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   private:   int c;
306f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   };
307f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// \endcode
308f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper/// fieldDecl(isPrivate())
309f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper///   matches 'int c;'
310f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel JasperAST_MATCHER(Decl, isPrivate) {
311f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper  return Node.getAccess() == AS_private;
312f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper}
313f3197e9eb02120522c1f60f88dacc1cfe5b210f0Daniel Jasper
3146bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines/// \brief Matches a declaration that has been implicitly added
3156bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines/// by the compiler (eg. implicit default/copy constructors).
3166bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen HinesAST_MATCHER(Decl, isImplicit) {
3176bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines  return Node.isImplicit();
3186bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines}
3196bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines
320e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// \brief Matches classTemplateSpecializations that have at least one
32125466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// TemplateArgument matching the given InnerMatcher.
322e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///
323e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// Given
32425466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
325e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   template<typename T> class A {};
326e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   template<> class A<double> {};
327e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   A<int> a;
32825466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
3292dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper/// classTemplateSpecializationDecl(hasAnyTemplateArgument(
330e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///     refersToType(asString("int"))))
331e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   matches the specialization \c A<int>
332651f13cea278ec967336033dd032faef0e9fc2ecStephen HinesAST_POLYMORPHIC_MATCHER_P(
333651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    hasAnyTemplateArgument,
334651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    AST_POLYMORPHIC_SUPPORTED_TYPES_2(ClassTemplateSpecializationDecl,
335651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                                      TemplateSpecializationType),
336651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    internal::Matcher<TemplateArgument>, InnerMatcher) {
337ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  ArrayRef<TemplateArgument> List =
338651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines      internal::getTemplateSpecializationArgs(Node);
339054d049174eb1ec8e93a4a0831c0d8caac00cb3aManuel Klimek  return matchesFirstInRange(InnerMatcher, List.begin(), List.end(), Finder,
340054d049174eb1ec8e93a4a0831c0d8caac00cb3aManuel Klimek                             Builder);
341e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper}
342e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper
343089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// \brief Matches expressions that match InnerMatcher after any implicit casts
344089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// are stripped off.
345089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///
346089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// Parentheses and explicit casts are not discarded.
347089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// Given
34825466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
349089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   int arr[5];
350089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   int a = 0;
351089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   char b = 0;
352089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   const int c = a;
353089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   int *d = arr;
354089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   long e = (long) 0l;
35525466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
356089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// The matchers
35725466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
3582dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper///    varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
3592dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper///    varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
36025466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
361089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// would match the declarations for a, b, c, and d, but not e.
36225466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// While
36325466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
3642dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper///    varDecl(hasInitializer(integerLiteral()))
3652dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper///    varDecl(hasInitializer(declRefExpr()))
36625466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
367089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// only match the declarations for b, c, and d.
368089e5b3bf2e57da0173b170ad501867b43395385Sam PanzerAST_MATCHER_P(Expr, ignoringImpCasts,
369089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer              internal::Matcher<Expr>, InnerMatcher) {
370089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer  return InnerMatcher.matches(*Node.IgnoreImpCasts(), Finder, Builder);
371089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer}
372089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer
373089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// \brief Matches expressions that match InnerMatcher after parentheses and
374089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// casts are stripped off.
375089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///
376089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// Implicit and non-C Style casts are also discarded.
377089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// Given
37825466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
379089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   int a = 0;
380089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   char b = (0);
381089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   void* c = reinterpret_cast<char*>(0);
382089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   char d = char(0);
38325466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
384089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// The matcher
3852dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper///    varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
386089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// would match the declarations for a, b, c, and d.
387089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// while
3882dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper///    varDecl(hasInitializer(integerLiteral()))
389089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// only match the declaration for a.
390089e5b3bf2e57da0173b170ad501867b43395385Sam PanzerAST_MATCHER_P(Expr, ignoringParenCasts, internal::Matcher<Expr>, InnerMatcher) {
391089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer  return InnerMatcher.matches(*Node.IgnoreParenCasts(), Finder, Builder);
392089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer}
393089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer
394089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// \brief Matches expressions that match InnerMatcher after implicit casts and
395089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// parentheses are stripped off.
396089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///
397089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// Explicit casts are not discarded.
398089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// Given
39925466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
400089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   int arr[5];
401089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   int a = 0;
402089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   char b = (0);
403089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   const int c = a;
404089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   int *d = (arr);
405089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer///   long e = ((long) 0l);
40625466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
407089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// The matchers
4082dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper///    varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
4092dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper///    varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
410089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// would match the declarations for a, b, c, and d, but not e.
411089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// while
4122dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper///    varDecl(hasInitializer(integerLiteral()))
4132dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper///    varDecl(hasInitializer(declRefExpr()))
414089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer/// would only match the declaration for a.
415089e5b3bf2e57da0173b170ad501867b43395385Sam PanzerAST_MATCHER_P(Expr, ignoringParenImpCasts,
416089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer              internal::Matcher<Expr>, InnerMatcher) {
417089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer  return InnerMatcher.matches(*Node.IgnoreParenImpCasts(), Finder, Builder);
418089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer}
419089e5b3bf2e57da0173b170ad501867b43395385Sam Panzer
420e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// \brief Matches classTemplateSpecializations where the n'th TemplateArgument
42125466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// matches the given InnerMatcher.
422e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///
423e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// Given
42425466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
425e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   template<typename T, typename U> class A {};
426e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   A<bool, int> b;
427e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   A<int, bool> c;
42825466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
4292dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper/// classTemplateSpecializationDecl(hasTemplateArgument(
430e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///     1, refersToType(asString("int"))))
431e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   matches the specialization \c A<bool, int>
432651f13cea278ec967336033dd032faef0e9fc2ecStephen HinesAST_POLYMORPHIC_MATCHER_P2(
433651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    hasTemplateArgument,
434651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    AST_POLYMORPHIC_SUPPORTED_TYPES_2(ClassTemplateSpecializationDecl,
435651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                                      TemplateSpecializationType),
436651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    unsigned, N, internal::Matcher<TemplateArgument>, InnerMatcher) {
437ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  ArrayRef<TemplateArgument> List =
438651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines      internal::getTemplateSpecializationArgs(Node);
439e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper  if (List.size() <= N)
440e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper    return false;
441651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  return InnerMatcher.matches(List[N], Finder, Builder);
442e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper}
443e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper
444e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// \brief Matches a TemplateArgument that refers to a certain type.
445e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///
446e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// Given
44725466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
448e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   struct X {};
449e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   template<typename T> struct A {};
450e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   A<X> a;
45125466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
4522dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper/// classTemplateSpecializationDecl(hasAnyTemplateArgument(
453e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///     refersToType(class(hasName("X")))))
454e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   matches the specialization \c A<X>
455e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel JasperAST_MATCHER_P(TemplateArgument, refersToType,
45625466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek              internal::Matcher<QualType>, InnerMatcher) {
457e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper  if (Node.getKind() != TemplateArgument::Type)
458e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper    return false;
45925466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek  return InnerMatcher.matches(Node.getAsType(), Finder, Builder);
460e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper}
461e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper
462651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines/// \brief Matches a canonical TemplateArgument that refers to a certain
463651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines/// declaration.
464e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///
465e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// Given
46625466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
467e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   template<typename T> struct A {};
468e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   struct B { B* next; };
469e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   A<&B::next> a;
47025466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
4712dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper/// classTemplateSpecializationDecl(hasAnyTemplateArgument(
4722dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper///     refersToDeclaration(fieldDecl(hasName("next"))))
4732dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper///   matches the specialization \c A<&B::next> with \c fieldDecl(...) matching
474e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///     \c B::next
475e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel JasperAST_MATCHER_P(TemplateArgument, refersToDeclaration,
47625466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek              internal::Matcher<Decl>, InnerMatcher) {
477aaa8e45b8e392a1f1b7498e2f00c6ed66d41119aDaniel Jasper  if (Node.getKind() == TemplateArgument::Declaration)
478aaa8e45b8e392a1f1b7498e2f00c6ed66d41119aDaniel Jasper    return InnerMatcher.matches(*Node.getAsDecl(), Finder, Builder);
479e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper  return false;
480e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper}
4814da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
482651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines/// \brief Matches a sugar TemplateArgument that refers to a certain expression.
483651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines///
484651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines/// Given
485651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines/// \code
486651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines///   template<typename T> struct A {};
487651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines///   struct B { B* next; };
488651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines///   A<&B::next> a;
489651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines/// \endcode
490651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines/// templateSpecializationType(hasAnyTemplateArgument(
491651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines///   isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next"))))))))
492651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines///   matches the specialization \c A<&B::next> with \c fieldDecl(...) matching
493651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines///     \c B::next
494651f13cea278ec967336033dd032faef0e9fc2ecStephen HinesAST_MATCHER_P(TemplateArgument, isExpr, internal::Matcher<Expr>, InnerMatcher) {
495651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  if (Node.getKind() == TemplateArgument::Expression)
496651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    return InnerMatcher.matches(*Node.getAsExpr(), Finder, Builder);
497651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  return false;
498651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines}
499651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines
5004da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches C++ constructor declarations.
5014da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
5024da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Example matches Foo::Foo() and Foo::Foo(int)
50325466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
5044da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   class Foo {
5054da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///    public:
5064da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///     Foo();
5074da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///     Foo(int);
5084da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///     int DoSomething();
5094da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   };
51025466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
5114da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimekconst internal::VariadicDynCastAllOfMatcher<
512e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper  Decl,
5132dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper  CXXConstructorDecl> constructorDecl;
514e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper
515e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// \brief Matches explicit C++ destructor declarations.
516e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///
517e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// Example matches Foo::~Foo()
51825466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
519e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   class Foo {
520e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///    public:
521e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///     virtual ~Foo();
522e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   };
52325466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
5242dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasperconst internal::VariadicDynCastAllOfMatcher<
5252dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper  Decl,
5262dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper  CXXDestructorDecl> destructorDecl;
527e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper
528e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// \brief Matches enum declarations.
529e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///
530e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// Example matches X
53125466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
532e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   enum X {
533e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///     A, B, C
534e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   };
53525466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
536e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasperconst internal::VariadicDynCastAllOfMatcher<Decl, EnumDecl> enumDecl;
537e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper
538e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// \brief Matches enum constants.
539e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///
540e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// Example matches A, B, C
54125466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
542e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   enum X {
543e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///     A, B, C
544e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   };
54525466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
546e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasperconst internal::VariadicDynCastAllOfMatcher<
547e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper  Decl,
5482dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper  EnumConstantDecl> enumConstantDecl;
5494da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
5504da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches method declarations.
5514da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
5524da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Example matches y
55325466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
554651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines///   class X { void y(); };
55525466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
5562dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasperconst internal::VariadicDynCastAllOfMatcher<Decl, CXXMethodDecl> methodDecl;
5574da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
5584da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches variable declarations.
5594da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
5604da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Note: this does not match declarations of member variables, which are
5614da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// "field" declarations in Clang parlance.
5624da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
5634da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Example matches a
56425466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
5654da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   int a;
56625466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
5672dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasperconst internal::VariadicDynCastAllOfMatcher<Decl, VarDecl> varDecl;
5684da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
5694da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches field declarations.
5704da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
5714da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Given
57225466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
5734da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   class X { int m; };
57425466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
5752dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper/// fieldDecl()
5764da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   matches 'm'.
5772dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasperconst internal::VariadicDynCastAllOfMatcher<Decl, FieldDecl> fieldDecl;
5784da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
5794da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches function declarations.
5804da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
5814da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Example matches f
58225466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
5834da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   void f();
58425466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
5852dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasperconst internal::VariadicDynCastAllOfMatcher<Decl, FunctionDecl> functionDecl;
5864da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
5878456ae602783b615019a42f7d5c6f0e71639b11bDmitri Gribenko/// \brief Matches C++ function template declarations.
5888456ae602783b615019a42f7d5c6f0e71639b11bDmitri Gribenko///
5898456ae602783b615019a42f7d5c6f0e71639b11bDmitri Gribenko/// Example matches f
59025466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
5918456ae602783b615019a42f7d5c6f0e71639b11bDmitri Gribenko///   template<class T> void f(T t) {}
59225466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
5938456ae602783b615019a42f7d5c6f0e71639b11bDmitri Gribenkoconst internal::VariadicDynCastAllOfMatcher<
5948456ae602783b615019a42f7d5c6f0e71639b11bDmitri Gribenko  Decl,
5952dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper  FunctionTemplateDecl> functionTemplateDecl;
5964da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
597de9ed71c696bee936a21323f61548164de0eda13Enea Zaffanella/// \brief Matches friend declarations.
598de9ed71c696bee936a21323f61548164de0eda13Enea Zaffanella///
599de9ed71c696bee936a21323f61548164de0eda13Enea Zaffanella/// Given
600de9ed71c696bee936a21323f61548164de0eda13Enea Zaffanella/// \code
601de9ed71c696bee936a21323f61548164de0eda13Enea Zaffanella///   class X { friend void foo(); };
602de9ed71c696bee936a21323f61548164de0eda13Enea Zaffanella/// \endcode
603de9ed71c696bee936a21323f61548164de0eda13Enea Zaffanella/// friendDecl()
604de9ed71c696bee936a21323f61548164de0eda13Enea Zaffanella///   matches 'friend void foo()'.
605de9ed71c696bee936a21323f61548164de0eda13Enea Zaffanellaconst internal::VariadicDynCastAllOfMatcher<Decl, FriendDecl> friendDecl;
606de9ed71c696bee936a21323f61548164de0eda13Enea Zaffanella
6074da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches statements.
6084da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
6094da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Given
61025466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
6114da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   { ++a; }
61225466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
6132dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper/// stmt()
6144da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   matches both the compound statement '{ ++a; }' and '++a'.
61506b247f0ffb69854e32150c80f347a9376d3709bManuel Klimekconst internal::VariadicAllOfMatcher<Stmt> stmt;
6164da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
6174da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches declaration statements.
6184da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
6194da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Given
62025466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
6214da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   int a;
62225466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
6232dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper/// declStmt()
6244da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   matches 'int a'.
6254da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimekconst internal::VariadicDynCastAllOfMatcher<
626e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper  Stmt,
6272dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper  DeclStmt> declStmt;
6284da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
6294da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches member expressions.
6304da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
6314da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Given
63225466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
6334da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   class Y {
6344da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///     void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
6354da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///     int a; static int b;
6364da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   };
63725466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
6382dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper/// memberExpr()
6394da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   matches this->x, x, y.x, a, this->b
6402dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasperconst internal::VariadicDynCastAllOfMatcher<Stmt, MemberExpr> memberExpr;
6414da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
6424da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches call expressions.
6434da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
6449f17408d50c1d76c5eab435e4ceb924cc10757abManuel Klimek/// Example matches x.y() and y()
64525466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
6464da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   X x;
6474da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   x.y();
6489f17408d50c1d76c5eab435e4ceb924cc10757abManuel Klimek///   y();
64925466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
6502dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasperconst internal::VariadicDynCastAllOfMatcher<Stmt, CallExpr> callExpr;
651e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper
65231f7c08a0d2b140bf31a08894d1948649de53c15Daniel Jasper/// \brief Matches lambda expressions.
65331f7c08a0d2b140bf31a08894d1948649de53c15Daniel Jasper///
65431f7c08a0d2b140bf31a08894d1948649de53c15Daniel Jasper/// Example matches [&](){return 5;}
65531f7c08a0d2b140bf31a08894d1948649de53c15Daniel Jasper/// \code
65631f7c08a0d2b140bf31a08894d1948649de53c15Daniel Jasper///   [&](){return 5;}
65731f7c08a0d2b140bf31a08894d1948649de53c15Daniel Jasper/// \endcode
65831f7c08a0d2b140bf31a08894d1948649de53c15Daniel Jasperconst internal::VariadicDynCastAllOfMatcher<Stmt, LambdaExpr> lambdaExpr;
65931f7c08a0d2b140bf31a08894d1948649de53c15Daniel Jasper
6609f17408d50c1d76c5eab435e4ceb924cc10757abManuel Klimek/// \brief Matches member call expressions.
6619f17408d50c1d76c5eab435e4ceb924cc10757abManuel Klimek///
6629f17408d50c1d76c5eab435e4ceb924cc10757abManuel Klimek/// Example matches x.y()
66325466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
6649f17408d50c1d76c5eab435e4ceb924cc10757abManuel Klimek///   X x;
6659f17408d50c1d76c5eab435e4ceb924cc10757abManuel Klimek///   x.y();
66625466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
6672dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasperconst internal::VariadicDynCastAllOfMatcher<
6682dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper  Stmt,
6692dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper  CXXMemberCallExpr> memberCallExpr;
6709f17408d50c1d76c5eab435e4ceb924cc10757abManuel Klimek
671651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines/// \brief Matches expressions that introduce cleanups to be run at the end
672651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines/// of the sub-expression's evaluation.
673651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines///
674651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines/// Example matches std::string()
675651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines/// \code
676651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines///   const std::string str = std::string();
677651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines/// \endcode
678651f13cea278ec967336033dd032faef0e9fc2ecStephen Hinesconst internal::VariadicDynCastAllOfMatcher<Stmt, ExprWithCleanups>
679651f13cea278ec967336033dd032faef0e9fc2ecStephen HinesexprWithCleanups;
680651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines
681e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// \brief Matches init list expressions.
682e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///
683e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// Given
68425466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
685e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   int a[] = { 1, 2 };
686e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   struct B { int x, y; };
687e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   B b = { 5, 6 };
68825466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
689ef8225444452a1486bd721f3285301fe84643b00Stephen Hines/// initListExpr()
690e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   matches "{ 1, 2 }" and "{ 5, 6 }"
691e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasperconst internal::VariadicDynCastAllOfMatcher<Stmt, InitListExpr> initListExpr;
692e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper
693ef8225444452a1486bd721f3285301fe84643b00Stephen Hines/// \brief Matches substitutions of non-type template parameters.
694ef8225444452a1486bd721f3285301fe84643b00Stephen Hines///
695ef8225444452a1486bd721f3285301fe84643b00Stephen Hines/// Given
696ef8225444452a1486bd721f3285301fe84643b00Stephen Hines/// \code
697ef8225444452a1486bd721f3285301fe84643b00Stephen Hines///   template <int N>
698ef8225444452a1486bd721f3285301fe84643b00Stephen Hines///   struct A { static const int n = N; };
699ef8225444452a1486bd721f3285301fe84643b00Stephen Hines///   struct B : public A<42> {};
700ef8225444452a1486bd721f3285301fe84643b00Stephen Hines/// \endcode
701ef8225444452a1486bd721f3285301fe84643b00Stephen Hines/// substNonTypeTemplateParmExpr()
702ef8225444452a1486bd721f3285301fe84643b00Stephen Hines///   matches "N" in the right-hand side of "static const int n = N;"
703ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesconst internal::VariadicDynCastAllOfMatcher<Stmt, SubstNonTypeTemplateParmExpr>
704ef8225444452a1486bd721f3285301fe84643b00Stephen HinessubstNonTypeTemplateParmExpr;
705ef8225444452a1486bd721f3285301fe84643b00Stephen Hines
706e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// \brief Matches using declarations.
707e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///
708e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// Given
70925466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
710e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   namespace X { int x; }
711e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   using X::x;
71225466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
713e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// usingDecl()
714e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   matches \code using X::x \endcode
715e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasperconst internal::VariadicDynCastAllOfMatcher<Decl, UsingDecl> usingDecl;
7164da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
717d4de59d3e54421ef88316d650e35802ba9c572cfEnea Zaffanella/// \brief Matches unresolved using value declarations.
718d4de59d3e54421ef88316d650e35802ba9c572cfEnea Zaffanella///
719d4de59d3e54421ef88316d650e35802ba9c572cfEnea Zaffanella/// Given
720d4de59d3e54421ef88316d650e35802ba9c572cfEnea Zaffanella/// \code
721d4de59d3e54421ef88316d650e35802ba9c572cfEnea Zaffanella///   template<typename X>
722d4de59d3e54421ef88316d650e35802ba9c572cfEnea Zaffanella///   class C : private X {
723d4de59d3e54421ef88316d650e35802ba9c572cfEnea Zaffanella///     using X::x;
724d4de59d3e54421ef88316d650e35802ba9c572cfEnea Zaffanella///   };
725d4de59d3e54421ef88316d650e35802ba9c572cfEnea Zaffanella/// \endcode
726d4de59d3e54421ef88316d650e35802ba9c572cfEnea Zaffanella/// unresolvedUsingValueDecl()
727d4de59d3e54421ef88316d650e35802ba9c572cfEnea Zaffanella///   matches \code using X::x \endcode
728d4de59d3e54421ef88316d650e35802ba9c572cfEnea Zaffanellaconst internal::VariadicDynCastAllOfMatcher<
729d4de59d3e54421ef88316d650e35802ba9c572cfEnea Zaffanella  Decl,
730d4de59d3e54421ef88316d650e35802ba9c572cfEnea Zaffanella  UnresolvedUsingValueDecl> unresolvedUsingValueDecl;
731d4de59d3e54421ef88316d650e35802ba9c572cfEnea Zaffanella
7324da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches constructor call expressions (including implicit ones).
7334da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
7344da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Example matches string(ptr, n) and ptr within arguments of f
7352dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper///     (matcher = constructExpr())
73625466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
7374da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   void f(const string &a, const string &b);
7384da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   char *ptr;
7394da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   int n;
7404da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   f(string(ptr, n), ptr);
74125466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
7424da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimekconst internal::VariadicDynCastAllOfMatcher<
743e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper  Stmt,
7442dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper  CXXConstructExpr> constructExpr;
7454da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
746bd9cbd22b832ce65a085801259cf2d3df77830e4Enea Zaffanella/// \brief Matches unresolved constructor call expressions.
747bd9cbd22b832ce65a085801259cf2d3df77830e4Enea Zaffanella///
748bd9cbd22b832ce65a085801259cf2d3df77830e4Enea Zaffanella/// Example matches T(t) in return statement of f
749bd9cbd22b832ce65a085801259cf2d3df77830e4Enea Zaffanella///     (matcher = unresolvedConstructExpr())
750bd9cbd22b832ce65a085801259cf2d3df77830e4Enea Zaffanella/// \code
751bd9cbd22b832ce65a085801259cf2d3df77830e4Enea Zaffanella///   template <typename T>
752bd9cbd22b832ce65a085801259cf2d3df77830e4Enea Zaffanella///   void f(const T& t) { return T(t); }
753bd9cbd22b832ce65a085801259cf2d3df77830e4Enea Zaffanella/// \endcode
754bd9cbd22b832ce65a085801259cf2d3df77830e4Enea Zaffanellaconst internal::VariadicDynCastAllOfMatcher<
755bd9cbd22b832ce65a085801259cf2d3df77830e4Enea Zaffanella  Stmt,
756bd9cbd22b832ce65a085801259cf2d3df77830e4Enea Zaffanella  CXXUnresolvedConstructExpr> unresolvedConstructExpr;
757bd9cbd22b832ce65a085801259cf2d3df77830e4Enea Zaffanella
75870b9db9879c1cb8b8ca7d6c9809e35361cab83dcManuel Klimek/// \brief Matches implicit and explicit this expressions.
75970b9db9879c1cb8b8ca7d6c9809e35361cab83dcManuel Klimek///
76070b9db9879c1cb8b8ca7d6c9809e35361cab83dcManuel Klimek/// Example matches the implicit this expression in "return i".
76170b9db9879c1cb8b8ca7d6c9809e35361cab83dcManuel Klimek///     (matcher = thisExpr())
76270b9db9879c1cb8b8ca7d6c9809e35361cab83dcManuel Klimek/// \code
76370b9db9879c1cb8b8ca7d6c9809e35361cab83dcManuel Klimek/// struct foo {
76470b9db9879c1cb8b8ca7d6c9809e35361cab83dcManuel Klimek///   int i;
76570b9db9879c1cb8b8ca7d6c9809e35361cab83dcManuel Klimek///   int f() { return i; }
76670b9db9879c1cb8b8ca7d6c9809e35361cab83dcManuel Klimek/// };
76770b9db9879c1cb8b8ca7d6c9809e35361cab83dcManuel Klimek/// \endcode
76870b9db9879c1cb8b8ca7d6c9809e35361cab83dcManuel Klimekconst internal::VariadicDynCastAllOfMatcher<Stmt, CXXThisExpr> thisExpr;
76970b9db9879c1cb8b8ca7d6c9809e35361cab83dcManuel Klimek
7704da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches nodes where temporaries are created.
7714da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
7724da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Example matches FunctionTakesString(GetStringByValue())
7732dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper///     (matcher = bindTemporaryExpr())
77425466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
7754da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   FunctionTakesString(GetStringByValue());
7764da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   FunctionTakesStringByPointer(GetStringPointer());
77725466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
7784da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimekconst internal::VariadicDynCastAllOfMatcher<
779e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper  Stmt,
7802dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper  CXXBindTemporaryExpr> bindTemporaryExpr;
7814da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
782e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer/// \brief Matches nodes where temporaries are materialized.
783e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer///
784e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer/// Example: Given
785e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer/// \code
786e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer///   struct T {void func()};
787e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer///   T f();
788e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer///   void g(T);
789e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer/// \endcode
790e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer/// materializeTemporaryExpr() matches 'f()' in these statements
791e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer/// \code
792e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer///   T u(f());
793e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer///   g(f());
794e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer/// \endcode
795e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer/// but does not match
796e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer/// \code
797e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer///   f();
798e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer///   f().func();
799e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer/// \endcode
800e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzerconst internal::VariadicDynCastAllOfMatcher<
801e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer  Stmt,
802e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer  MaterializeTemporaryExpr> materializeTemporaryExpr;
803e16acd3817e501ee2bcf5f631b6911021fa88ba7Sam Panzer
8044da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches new expressions.
8054da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
8064da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Given
80725466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
8084da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   new X;
80925466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
8102dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper/// newExpr()
8114da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   matches 'new X'.
8122dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasperconst internal::VariadicDynCastAllOfMatcher<Stmt, CXXNewExpr> newExpr;
813e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper
814e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// \brief Matches delete expressions.
815e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///
816e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// Given
81725466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
818e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   delete X;
81925466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
8202dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper/// deleteExpr()
821e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   matches 'delete X'.
8222dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasperconst internal::VariadicDynCastAllOfMatcher<Stmt, CXXDeleteExpr> deleteExpr;
823e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper
824e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// \brief Matches array subscript expressions.
825e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///
826e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// Given
82725466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
828e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   int i = a[1];
82925466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
830e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper/// arraySubscriptExpr()
831e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper///   matches "a[1]"
832e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasperconst internal::VariadicDynCastAllOfMatcher<
833e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper  Stmt,
834e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper  ArraySubscriptExpr> arraySubscriptExpr;
8354da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
8364da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches the value of a default argument at the call site.
8374da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
8384da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Example matches the CXXDefaultArgExpr placeholder inserted for the
8394da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///     default value of the second parameter in the call expression f(42)
8402dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper///     (matcher = defaultArgExpr())
84125466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \code
8424da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   void f(int x, int y = 0);
8434da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///   f(42);
84425466496a2ace2aa533abc7bac1e92a4f425e2b1Manuel Klimek/// \endcode
8454da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimekconst internal::VariadicDynCastAllOfMatcher<
846e0e6b9e79a0c4edae92abd3928263875c78e23aaDaniel Jasper  Stmt,
8472dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9Daniel Jasper  CXXDefaultArgExpr> defaultArgExpr;
8484da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek
8494da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// \brief Matches overloaded operator calls.
8504da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
8514da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Note that if an operator isn't overloaded, it won't match. Instead, use
8524da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// binaryOperator matcher.
8534da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Currently it does not match operators such as new delete.
8544da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// FIXME: figure out why these do not match?
8554da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek///
8564da216637fa1ad4bdfd31bc265edb57ca35c2c12Manuel Klimek/// Example matches both operator<<((o << b), c) and operator<<(o, b)
857