clang  6.0.0svn
Macros
ASTMatchersMacros.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define AST_MATCHER_FUNCTION(ReturnType, DefineMatcher)
 AST_MATCHER_FUNCTION(ReturnType, DefineMatcher) { ... More...
 
#define AST_MATCHER_FUNCTION_P(ReturnType, DefineMatcher, ParamType, Param)
 AST_MATCHER_FUNCTION_P(ReturnType, DefineMatcher, ParamType, Param) { ... More...
 
#define AST_MATCHER_FUNCTION_P_OVERLOAD(ReturnType, DefineMatcher, ParamType, Param, OverloadId)
 
#define AST_MATCHER(Type, DefineMatcher)
 AST_MATCHER(Type, DefineMatcher) { ... More...
 
#define AST_MATCHER_P(Type, DefineMatcher, ParamType, Param)   AST_MATCHER_P_OVERLOAD(Type, DefineMatcher, ParamType, Param, 0)
 AST_MATCHER_P(Type, DefineMatcher, ParamType, Param) { ... More...
 
#define AST_MATCHER_P_OVERLOAD(Type, DefineMatcher, ParamType, Param, OverloadId)
 
#define AST_MATCHER_P2(Type, DefineMatcher, ParamType1, Param1, ParamType2, Param2)
 AST_MATCHER_P2( Type, DefineMatcher, ParamType1, Param1, ParamType2, Param2) { ... More...
 
#define AST_MATCHER_P2_OVERLOAD(Type, DefineMatcher, ParamType1, Param1, ParamType2, Param2, OverloadId)
 
#define AST_POLYMORPHIC_SUPPORTED_TYPES(...)   void(::clang::ast_matchers::internal::TypeList<__VA_ARGS__>)
 Construct a type-list to be passed to the AST_POLYMORPHIC_MATCHER* macros. More...
 
#define AST_POLYMORPHIC_MATCHER(DefineMatcher, ReturnTypesF)
 AST_POLYMORPHIC_MATCHER(DefineMatcher) { ... More...
 
#define AST_POLYMORPHIC_MATCHER_P(DefineMatcher, ReturnTypesF, ParamType, Param)
 AST_POLYMORPHIC_MATCHER_P(DefineMatcher, ParamType, Param) { ... More...
 
#define AST_POLYMORPHIC_MATCHER_P_OVERLOAD(DefineMatcher, ReturnTypesF, ParamType, Param, OverloadId)
 
#define AST_POLYMORPHIC_MATCHER_P2(DefineMatcher, ReturnTypesF, ParamType1, Param1, ParamType2, Param2)
 AST_POLYMORPHIC_MATCHER_P2( DefineMatcher, ParamType1, Param1, ParamType2, Param2) { ... More...
 
#define AST_POLYMORPHIC_MATCHER_P2_OVERLOAD(DefineMatcher, ReturnTypesF, ParamType1, Param1, ParamType2, Param2, OverloadId)
 
#define AST_TYPE_MATCHER(NodeType, MatcherName)
 Creates a variadic matcher for both a specific Type as well as the corresponding TypeLoc. More...
 
#define AST_TYPE_TRAVERSE_MATCHER(MatcherName, FunctionName, ReturnTypesF)
 AST_TYPE_TRAVERSE_MATCHER(MatcherName, FunctionName) defines the matcher MatcherName that can be used to traverse from one Type to another. More...
 
#define AST_TYPELOC_TRAVERSE_MATCHER(MatcherName, FunctionName, ReturnTypesF)
 AST_TYPELOC_TRAVERSE_MATCHER(MatcherName, FunctionName) works identical to AST_TYPE_TRAVERSE_MATCHER but operates on TypeLocs. More...
 

Macro Definition Documentation

◆ AST_MATCHER

#define AST_MATCHER (   Type,
  DefineMatcher 
)
Value:
namespace internal { \
class matcher_##DefineMatcher##Matcher \
: public ::clang::ast_matchers::internal::MatcherInterface<Type> { \
public: \
explicit matcher_##DefineMatcher##Matcher() = default; \
bool matches(const Type &Node, \
::clang::ast_matchers::internal::ASTMatchFinder *Finder, \
::clang::ast_matchers::internal::BoundNodesTreeBuilder \
*Builder) const override; \
}; \
} \
inline ::clang::ast_matchers::internal::Matcher<Type> DefineMatcher() { \
return ::clang::ast_matchers::internal::makeMatcher( \
new internal::matcher_##DefineMatcher##Matcher()); \
} \
inline bool internal::matcher_##DefineMatcher##Matcher::matches( \
const Type &Node, \
::clang::ast_matchers::internal::ASTMatchFinder *Finder, \
::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
ast_type_traits::DynTypedNode Node
bool matches(const til::SExpr *E1, const til::SExpr *E2)

AST_MATCHER(Type, DefineMatcher) { ...

} defines a zero parameter function named DefineMatcher() that returns a Matcher<Type> object.

The code between the curly braces has access to the following variables:

Node: the AST node being matched; its type is Type. Finder: an ASTMatchFinder*. Builder: a BoundNodesTreeBuilder*.

The code should return true if 'Node' matches.

Definition at line 95 of file ASTMatchersMacros.h.

◆ AST_MATCHER_FUNCTION

#define AST_MATCHER_FUNCTION (   ReturnType,
  DefineMatcher 
)
Value:
inline ReturnType DefineMatcher##_getInstance(); \
inline ReturnType DefineMatcher() { \
return ::clang::ast_matchers::internal::MemoizedMatcher< \
ReturnType, DefineMatcher##_getInstance>::getInstance(); \
} \
inline ReturnType DefineMatcher##_getInstance()

AST_MATCHER_FUNCTION(ReturnType, DefineMatcher) { ...

} defines a zero parameter function named DefineMatcher() that returns a ReturnType object.

Definition at line 56 of file ASTMatchersMacros.h.

◆ AST_MATCHER_FUNCTION_P

#define AST_MATCHER_FUNCTION_P (   ReturnType,
  DefineMatcher,
  ParamType,
  Param 
)
Value:
AST_MATCHER_FUNCTION_P_OVERLOAD(ReturnType, DefineMatcher, ParamType, Param, \
0)
#define AST_MATCHER_FUNCTION_P_OVERLOAD(ReturnType, DefineMatcher, ParamType, Param, OverloadId)

AST_MATCHER_FUNCTION_P(ReturnType, DefineMatcher, ParamType, Param) { ...

} defines a single-parameter function named DefineMatcher() that returns a ReturnType object.

The code between the curly braces has access to the following variables:

Param: the parameter passed to the function; its type is ParamType.

The code should return an instance of ReturnType.

Definition at line 75 of file ASTMatchersMacros.h.

◆ AST_MATCHER_FUNCTION_P_OVERLOAD

#define AST_MATCHER_FUNCTION_P_OVERLOAD (   ReturnType,
  DefineMatcher,
  ParamType,
  Param,
  OverloadId 
)
Value:
inline ReturnType DefineMatcher(ParamType const &Param); \
typedef ReturnType (&DefineMatcher##_Type##OverloadId)(ParamType const &); \
inline ReturnType DefineMatcher(ParamType const &Param)

Definition at line 78 of file ASTMatchersMacros.h.

◆ AST_MATCHER_P

#define AST_MATCHER_P (   Type,
  DefineMatcher,
  ParamType,
  Param 
)    AST_MATCHER_P_OVERLOAD(Type, DefineMatcher, ParamType, Param, 0)

AST_MATCHER_P(Type, DefineMatcher, ParamType, Param) { ...

} defines a single-parameter function named DefineMatcher() that returns a Matcher<Type> object.

The code between the curly braces has access to the following variables:

Node: the AST node being matched; its type is Type. Param: the parameter passed to the function; its type is ParamType. Finder: an ASTMatchFinder*. Builder: a BoundNodesTreeBuilder*.

The code should return true if 'Node' matches.

Definition at line 129 of file ASTMatchersMacros.h.

◆ AST_MATCHER_P2

#define AST_MATCHER_P2 (   Type,
  DefineMatcher,
  ParamType1,
  Param1,
  ParamType2,
  Param2 
)
Value:
AST_MATCHER_P2_OVERLOAD(Type, DefineMatcher, ParamType1, Param1, ParamType2, \
Param2, 0)
#define AST_MATCHER_P2_OVERLOAD(Type, DefineMatcher, ParamType1, Param1, ParamType2, Param2, OverloadId)

AST_MATCHER_P2( Type, DefineMatcher, ParamType1, Param1, ParamType2, Param2) { ...

} defines a two-parameter function named DefineMatcher() that returns a Matcher<Type> object.

The code between the curly braces has access to the following variables:

Node: the AST node being matched; its type is Type. Param1, Param2: the parameters passed to the function; their types are ParamType1 and ParamType2. Finder: an ASTMatchFinder*. Builder: a BoundNodesTreeBuilder*.

The code should return true if 'Node' matches.

Definition at line 176 of file ASTMatchersMacros.h.

◆ AST_MATCHER_P2_OVERLOAD

#define AST_MATCHER_P2_OVERLOAD (   Type,
  DefineMatcher,
  ParamType1,
  Param1,
  ParamType2,
  Param2,
  OverloadId 
)
Value:
namespace internal { \
class matcher_##DefineMatcher##OverloadId##Matcher \
: public ::clang::ast_matchers::internal::MatcherInterface<Type> { \
public: \
matcher_##DefineMatcher##OverloadId##Matcher(ParamType1 const &A##Param1, \
ParamType2 const &A##Param2) \
: Param1(A##Param1), Param2(A##Param2) {} \
bool matches(const Type &Node, \
::clang::ast_matchers::internal::ASTMatchFinder *Finder, \
::clang::ast_matchers::internal::BoundNodesTreeBuilder \
*Builder) const override; \
\
private: \
ParamType1 const Param1; \
ParamType2 const Param2; \
}; \
} \
inline ::clang::ast_matchers::internal::Matcher<Type> DefineMatcher( \
ParamType1 const &Param1, ParamType2 const &Param2) { \
return ::clang::ast_matchers::internal::makeMatcher( \
new internal::matcher_##DefineMatcher##OverloadId##Matcher(Param1, \
Param2)); \
} \
typedef ::clang::ast_matchers::internal::Matcher<Type>( \
&DefineMatcher##_Type##OverloadId)(ParamType1 const &Param1, \
ParamType2 const &Param2); \
inline bool internal::matcher_##DefineMatcher##OverloadId##Matcher::matches( \
const Type &Node, \
::clang::ast_matchers::internal::ASTMatchFinder *Finder, \
::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
ast_type_traits::DynTypedNode Node
bool matches(const til::SExpr *E1, const til::SExpr *E2)

Definition at line 181 of file ASTMatchersMacros.h.

◆ AST_MATCHER_P_OVERLOAD

#define AST_MATCHER_P_OVERLOAD (   Type,
  DefineMatcher,
  ParamType,
  Param,
  OverloadId 
)
Value:
namespace internal { \
class matcher_##DefineMatcher##OverloadId##Matcher \
: public ::clang::ast_matchers::internal::MatcherInterface<Type> { \
public: \
explicit matcher_##DefineMatcher##OverloadId##Matcher( \
ParamType const &A##Param) \
: Param(A##Param) {} \
bool matches(const Type &Node, \
::clang::ast_matchers::internal::ASTMatchFinder *Finder, \
::clang::ast_matchers::internal::BoundNodesTreeBuilder \
*Builder) const override; \
\
private: \
ParamType const Param; \
}; \
} \
inline ::clang::ast_matchers::internal::Matcher<Type> DefineMatcher( \
ParamType const &Param) { \
return ::clang::ast_matchers::internal::makeMatcher( \
new internal::matcher_##DefineMatcher##OverloadId##Matcher(Param)); \
} \
typedef ::clang::ast_matchers::internal::Matcher<Type>( \
&DefineMatcher##_Type##OverloadId)(ParamType const &Param); \
inline bool internal::matcher_##DefineMatcher##OverloadId##Matcher::matches( \
const Type &Node, \
::clang::ast_matchers::internal::ASTMatchFinder *Finder, \
::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
ast_type_traits::DynTypedNode Node
bool matches(const til::SExpr *E1, const til::SExpr *E2)

Definition at line 132 of file ASTMatchersMacros.h.

◆ AST_POLYMORPHIC_MATCHER

#define AST_POLYMORPHIC_MATCHER (   DefineMatcher,
  ReturnTypesF 
)
Value:
namespace internal { \
template <typename NodeType> \
class matcher_##DefineMatcher##Matcher \
: public ::clang::ast_matchers::internal::MatcherInterface<NodeType> { \
public: \
bool matches(const NodeType &Node, \
::clang::ast_matchers::internal::ASTMatchFinder *Finder, \
::clang::ast_matchers::internal::BoundNodesTreeBuilder \
*Builder) const override; \
}; \
} \
inline ::clang::ast_matchers::internal::PolymorphicMatcherWithParam0< \
internal::matcher_##DefineMatcher##Matcher, ReturnTypesF> \
DefineMatcher() { \
return ::clang::ast_matchers::internal::PolymorphicMatcherWithParam0< \
internal::matcher_##DefineMatcher##Matcher, ReturnTypesF>(); \
} \
template <typename NodeType> \
bool internal::matcher_##DefineMatcher##Matcher<NodeType>::matches( \
const NodeType &Node, \
::clang::ast_matchers::internal::ASTMatchFinder *Finder, \
::clang::ast_matchers::internal::BoundNodesTreeBuilder *Builder) const
ast_type_traits::DynTypedNode Node
bool matches(const til::SExpr *E1, const til::SExpr *E2)

AST_POLYMORPHIC_MATCHER(DefineMatcher) { ...

} defines a single-parameter function named DefineMatcher() that is polymorphic in the return type.

The variables are the same as for AST_MATCHER, but NodeType will be deduced from the calling context.

Definition at line 231 of file ASTMatchersMacros.h.

◆ AST_POLYMORPHIC_MATCHER_P

#define AST_POLYMORPHIC_MATCHER_P (   DefineMatcher,
  ReturnTypesF,
  ParamType,
  Param 
)
Value:
AST_POLYMORPHIC_MATCHER_P_OVERLOAD(DefineMatcher, ReturnTypesF, ParamType, \
Param, 0)
#define AST_POLYMORPHIC_MATCHER_P_OVERLOAD(DefineMatcher, ReturnTypesF, ParamType, Param, OverloadId)

AST_POLYMORPHIC_MATCHER_P(DefineMatcher, ParamType, Param) { ...

} defines a single-parameter function named DefineMatcher() that is polymorphic in the return type.

The variables are the same as for AST_MATCHER_P, with the addition of NodeType, which specifies the node type of the matcher Matcher<NodeType> returned by the function matcher().

FIXME: Pull out common code with above macro?

Definition at line 264 of file ASTMatchersMacros.h.

◆ AST_POLYMORPHIC_MATCHER_P2

#define AST_POLYMORPHIC_MATCHER_P2 (   DefineMatcher,
  ReturnTypesF,
  ParamType1,
  Param1,
  ParamType2,
  Param2 
)
Value:
AST_POLYMORPHIC_MATCHER_P2_OVERLOAD(DefineMatcher, ReturnTypesF, ParamType1, \
Param1, ParamType2, Param2, 0)
#define AST_POLYMORPHIC_MATCHER_P2_OVERLOAD(DefineMatcher, ReturnTypesF, ParamType1, Param1, ParamType2, Param2, OverloadId)

AST_POLYMORPHIC_MATCHER_P2( DefineMatcher, ParamType1, Param1, ParamType2, Param2) { ...

} defines a two-parameter function named matcher() that is polymorphic in the return type.

The variables are the same as for AST_MATCHER_P2, with the addition of NodeType, which specifies the node type of the matcher Matcher<NodeType> returned by the function DefineMatcher().

Definition at line 316 of file ASTMatchersMacros.h.

◆ AST_POLYMORPHIC_MATCHER_P2_OVERLOAD

#define AST_POLYMORPHIC_MATCHER_P2_OVERLOAD (   DefineMatcher,
  ReturnTypesF,
  ParamType1,
  Param1,
  ParamType2,
  Param2,
  OverloadId 
)

Definition at line 321 of file ASTMatchersMacros.h.

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD

#define AST_POLYMORPHIC_MATCHER_P_OVERLOAD (   DefineMatcher,
  ReturnTypesF,
  ParamType,
  Param,
  OverloadId 
)

Definition at line 269 of file ASTMatchersMacros.h.

◆ AST_POLYMORPHIC_SUPPORTED_TYPES

#define AST_POLYMORPHIC_SUPPORTED_TYPES (   ...)    void(::clang::ast_matchers::internal::TypeList<__VA_ARGS__>)

Construct a type-list to be passed to the AST_POLYMORPHIC_MATCHER* macros.

You can't pass something like TypeList<Foo, Bar> to a macro, because it will look at that as two arguments. However, you can pass void(TypeList<Foo, Bar>), which works thanks to the parenthesis. The PolymorphicMatcherWithParam* classes will unpack the function type to extract the TypeList object.

Definition at line 222 of file ASTMatchersMacros.h.

Referenced by clang::ast_matchers::AST_MATCHER(), and clang::ast_matchers::AST_MATCHER_P().

◆ AST_TYPE_MATCHER

#define AST_TYPE_MATCHER (   NodeType,
  MatcherName 
)
Value:
const ::clang::ast_matchers::internal::VariadicDynCastAllOfMatcher< \
Type, NodeType> MatcherName

Creates a variadic matcher for both a specific Type as well as the corresponding TypeLoc.

Definition at line 364 of file ASTMatchersMacros.h.

◆ AST_TYPE_TRAVERSE_MATCHER

#define AST_TYPE_TRAVERSE_MATCHER (   MatcherName,
  FunctionName,
  ReturnTypesF 
)
Value:
namespace internal { \
template <typename T> struct TypeMatcher##MatcherName##Getter { \
static QualType (T::*value())() const { return &T::FunctionName; } \
}; \
} \
const ::clang::ast_matchers::internal::TypeTraversePolymorphicMatcher< \
QualType, \
::clang::ast_matchers::internal::TypeTraverseMatcher, \
ReturnTypesF>::Func MatcherName
internal::Matcher< QualType > TypeMatcher
Definition: ASTMatchers.h:112

AST_TYPE_TRAVERSE_MATCHER(MatcherName, FunctionName) defines the matcher MatcherName that can be used to traverse from one Type to another.

For a specific SpecificType, the traversal is done using SpecificType::FunctionName. The existence of such a function determines whether a corresponding matcher can be used on SpecificType.

Definition at line 377 of file ASTMatchersMacros.h.

◆ AST_TYPELOC_TRAVERSE_MATCHER

#define AST_TYPELOC_TRAVERSE_MATCHER (   MatcherName,
  FunctionName,
  ReturnTypesF 
)
Value:
namespace internal { \
template <typename T> struct TypeLocMatcher##MatcherName##Getter { \
static TypeLoc (T::*value())() const { return &T::FunctionName##Loc; } \
}; \
} \
const ::clang::ast_matchers::internal::TypeTraversePolymorphicMatcher< \
TypeLoc, \
::clang::ast_matchers::internal::TypeLocTraverseMatcher, \
ReturnTypesF>::Func MatcherName##Loc; \
AST_TYPE_TRAVERSE_MATCHER(MatcherName, FunctionName##Type, ReturnTypesF)
internal::Matcher< TypeLoc > TypeLocMatcher
Definition: ASTMatchers.h:113

AST_TYPELOC_TRAVERSE_MATCHER(MatcherName, FunctionName) works identical to AST_TYPE_TRAVERSE_MATCHER but operates on TypeLocs.

Definition at line 391 of file ASTMatchersMacros.h.