clang-format can now format #defines.

llvm-svn: 171865
This commit is contained in:
Manuel Klimek 2013-01-08 16:33:20 +00:00
parent 650648fa57
commit 6e67bed48c
1 changed files with 111 additions and 113 deletions

View File

@ -50,12 +50,11 @@
/// The code should return true if 'Node' matches.
#define AST_MATCHER(Type, DefineMatcher) \
namespace internal { \
class matcher_##DefineMatcher##Matcher \
: public MatcherInterface<Type> { \
class matcher_##DefineMatcher##Matcher : public MatcherInterface<Type> { \
public: \
explicit matcher_##DefineMatcher##Matcher() {} \
virtual bool matches( \
const Type &Node, ASTMatchFinder *Finder, \
explicit matcher_##DefineMatcher##Matcher() { \
} \
virtual bool matches(const Type &Node, ASTMatchFinder *Finder, \
BoundNodesTreeBuilder *Builder) const; \
}; \
} \
@ -82,13 +81,12 @@
/// The code should return true if 'Node' matches.
#define AST_MATCHER_P(Type, DefineMatcher, ParamType, Param) \
namespace internal { \
class matcher_##DefineMatcher##Matcher \
: public MatcherInterface<Type> { \
class matcher_##DefineMatcher##Matcher : public MatcherInterface<Type> { \
public: \
explicit matcher_##DefineMatcher##Matcher( \
const ParamType &A##Param) : Param(A##Param) {} \
virtual bool matches( \
const Type &Node, ASTMatchFinder *Finder, \
explicit matcher_##DefineMatcher##Matcher(const ParamType &A##Param) \
: Param(A##Param) { \
} \
virtual bool matches(const Type &Node, ASTMatchFinder *Finder, \
BoundNodesTreeBuilder *Builder) const; \
private: \
const ParamType Param; \
@ -116,28 +114,26 @@
/// Builder: a BoundNodesTreeBuilder*.
///
/// The code should return true if 'Node' matches.
#define AST_MATCHER_P2( \
Type, DefineMatcher, ParamType1, Param1, ParamType2, Param2) \
#define AST_MATCHER_P2(Type, DefineMatcher, ParamType1, Param1, ParamType2, \
Param2) \
namespace internal { \
class matcher_##DefineMatcher##Matcher \
: public MatcherInterface<Type> { \
class matcher_##DefineMatcher##Matcher : public MatcherInterface<Type> { \
public: \
matcher_##DefineMatcher##Matcher( \
const ParamType1 &A##Param1, const ParamType2 &A##Param2) \
: Param1(A##Param1), Param2(A##Param2) {} \
virtual bool matches( \
const Type &Node, ASTMatchFinder *Finder, \
matcher_##DefineMatcher##Matcher(const ParamType1 &A##Param1, \
const ParamType2 &A##Param2) \
: Param1(A##Param1), Param2(A##Param2) { \
} \
virtual bool matches(const Type &Node, ASTMatchFinder *Finder, \
BoundNodesTreeBuilder *Builder) const; \
private: \
const ParamType1 Param1; \
const ParamType2 Param2; \
}; \
} \
inline internal::Matcher<Type> DefineMatcher( \
const ParamType1 &Param1, const ParamType2 &Param2) { \
inline internal::Matcher<Type> DefineMatcher(const ParamType1 &Param1, \
const ParamType2 &Param2) { \
return internal::makeMatcher( \
new internal::matcher_##DefineMatcher##Matcher( \
Param1, Param2)); \
new internal::matcher_##DefineMatcher##Matcher(Param1, Param2)); \
} \
inline bool internal::matcher_##DefineMatcher##Matcher::matches( \
const Type &Node, ASTMatchFinder *Finder, \
@ -155,13 +151,12 @@
#define AST_POLYMORPHIC_MATCHER_P(DefineMatcher, ParamType, Param) \
namespace internal { \
template <typename NodeType, typename ParamT> \
class matcher_##DefineMatcher##Matcher \
: public MatcherInterface<NodeType> { \
class matcher_##DefineMatcher##Matcher : public MatcherInterface<NodeType> { \
public: \
explicit matcher_##DefineMatcher##Matcher( \
const ParamType &A##Param) : Param(A##Param) {} \
virtual bool matches( \
const NodeType &Node, ASTMatchFinder *Finder, \
explicit matcher_##DefineMatcher##Matcher(const ParamType &A##Param) \
: Param(A##Param) { \
} \
virtual bool matches(const NodeType &Node, ASTMatchFinder *Finder, \
BoundNodesTreeBuilder *Builder) const; \
private: \
const ParamType Param; \
@ -169,11 +164,9 @@
} \
inline internal::PolymorphicMatcherWithParam1< \
internal::matcher_##DefineMatcher##Matcher, \
ParamType > \
DefineMatcher(const ParamType &Param) { \
ParamType> DefineMatcher(const ParamType &Param) { \
return internal::PolymorphicMatcherWithParam1< \
internal::matcher_##DefineMatcher##Matcher, \
ParamType >(Param); \
internal::matcher_##DefineMatcher##Matcher, ParamType>(Param); \
} \
template <typename NodeType, typename ParamT> \
bool internal::matcher_##DefineMatcher##Matcher<NodeType, ParamT>::matches( \
@ -188,18 +181,17 @@
/// 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().
#define AST_POLYMORPHIC_MATCHER_P2( \
DefineMatcher, ParamType1, Param1, ParamType2, Param2) \
#define AST_POLYMORPHIC_MATCHER_P2(DefineMatcher, ParamType1, Param1, \
ParamType2, Param2) \
namespace internal { \
template <typename NodeType, typename ParamT1, typename ParamT2> \
class matcher_##DefineMatcher##Matcher \
: public MatcherInterface<NodeType> { \
class matcher_##DefineMatcher##Matcher : public MatcherInterface<NodeType> { \
public: \
matcher_##DefineMatcher##Matcher( \
const ParamType1 &A##Param1, const ParamType2 &A##Param2) \
: Param1(A##Param1), Param2(A##Param2) {} \
virtual bool matches( \
const NodeType &Node, ASTMatchFinder *Finder, \
matcher_##DefineMatcher##Matcher(const ParamType1 &A##Param1, \
const ParamType2 &A##Param2) \
: Param1(A##Param1), Param2(A##Param2) { \
} \
virtual bool matches(const NodeType &Node, ASTMatchFinder *Finder, \
BoundNodesTreeBuilder *Builder) const; \
private: \
const ParamType1 Param1; \
@ -207,18 +199,17 @@
}; \
} \
inline internal::PolymorphicMatcherWithParam2< \
internal::matcher_##DefineMatcher##Matcher, \
ParamType1, ParamType2 > \
DefineMatcher(const ParamType1 &Param1, const ParamType2 &Param2) { \
internal::matcher_##DefineMatcher##Matcher, ParamType1, \
ParamType2> DefineMatcher(const ParamType1 &Param1, \
const ParamType2 &Param2) { \
return internal::PolymorphicMatcherWithParam2< \
internal::matcher_##DefineMatcher##Matcher, \
ParamType1, ParamType2 >( \
Param1, Param2); \
internal::matcher_##DefineMatcher##Matcher, ParamType1, \
ParamType2>(Param1, Param2); \
} \
template <typename NodeType, typename ParamT1, typename ParamT2> \
bool internal::matcher_##DefineMatcher##Matcher< \
NodeType, ParamT1, ParamT2>::matches( \
const NodeType &Node, ASTMatchFinder *Finder, \
NodeType, ParamT1, \
ParamT2>::matches(const NodeType &Node, ASTMatchFinder *Finder, \
BoundNodesTreeBuilder *Builder) const
/// \brief Creates a variadic matcher for both a specific \c Type as well as
@ -240,23 +231,26 @@ class Polymorphic##MatcherName##TypeMatcher { \
public: \
Polymorphic##MatcherName##TypeMatcher( \
const internal::Matcher<QualType> &InnerMatcher) \
: InnerMatcher(InnerMatcher) {} \
: InnerMatcher(InnerMatcher) { \
} \
template <typename T> operator internal:: Matcher< T>() { \
return internal::Matcher<T>(new internal::TypeTraverseMatcher<T>( \
InnerMatcher, &T::FunctionName)); \
} \
private: \
const internal::Matcher<QualType> InnerMatcher; \
}; \
} \
; \
class Variadic##MatcherName##TypeTraverseMatcher \
: public llvm::VariadicFunction< \
Polymorphic##MatcherName##TypeMatcher, \
internal::Matcher<QualType>, \
Polymorphic##MatcherName##TypeMatcher, internal::Matcher<QualType>, \
internal::makeTypeAllOfComposite< \
Polymorphic##MatcherName##TypeMatcher, QualType> > { \
public: \
Variadic##MatcherName##TypeTraverseMatcher() {} \
}; \
Variadic##MatcherName##TypeTraverseMatcher() { \
} \
} \
; \
const Variadic##MatcherName##TypeTraverseMatcher MatcherName
/// \brief AST_TYPELOC_TRAVERSE_MATCHER(MatcherName, FunctionName) works
@ -266,23 +260,27 @@ class Polymorphic##MatcherName##TypeLocMatcher { \
public: \
Polymorphic##MatcherName##TypeLocMatcher( \
const internal::Matcher<TypeLoc> &InnerMatcher) \
: InnerMatcher(InnerMatcher) {} \
: InnerMatcher(InnerMatcher) { \
} \
template <typename T> operator internal:: Matcher< T>() { \
return internal::Matcher<T>(new internal::TypeLocTraverseMatcher<T>( \
InnerMatcher, &T::FunctionName##Loc)); \
return internal::Matcher<T>( \
new internal::TypeLocTraverseMatcher<T>(InnerMatcher, \
&T::FunctionName##Loc)); \
} \
private: \
const internal::Matcher<TypeLoc> InnerMatcher; \
}; \
} \
; \
class Variadic##MatcherName##TypeLocTraverseMatcher \
: public llvm::VariadicFunction< \
Polymorphic##MatcherName##TypeLocMatcher, \
internal::Matcher<TypeLoc>, \
Polymorphic##MatcherName##TypeLocMatcher, internal::Matcher<TypeLoc>,\
internal::makeTypeAllOfComposite< \
Polymorphic##MatcherName##TypeLocMatcher, TypeLoc> > { \
public: \
Variadic##MatcherName##TypeLocTraverseMatcher() {} \
}; \
Variadic##MatcherName##TypeLocTraverseMatcher() { \
} \
} \
; \
const Variadic##MatcherName##TypeLocTraverseMatcher MatcherName##Loc; \
AST_TYPE_TRAVERSE_MATCHER(MatcherName, FunctionName##Type)