Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 1 | //===--- Marshallers.h - Generic matcher function marshallers -*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// |
| 10 | /// \file |
| 11 | /// \brief Functions templates and classes to wrap matcher construct functions. |
| 12 | /// |
| 13 | /// A collection of template function and classes that provide a generic |
| 14 | /// marshalling layer on top of matcher construct functions. |
| 15 | /// These are used by the registry to export all marshaller constructors with |
| 16 | /// the same generic interface. |
| 17 | /// |
| 18 | //===----------------------------------------------------------------------===// |
| 19 | |
| 20 | #ifndef LLVM_CLANG_AST_MATCHERS_DYNAMIC_MARSHALLERS_H |
| 21 | #define LLVM_CLANG_AST_MATCHERS_DYNAMIC_MARSHALLERS_H |
| 22 | |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 23 | #include <string> |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 24 | |
| 25 | #include "clang/ASTMatchers/ASTMatchers.h" |
| 26 | #include "clang/ASTMatchers/Dynamic/Diagnostics.h" |
| 27 | #include "clang/ASTMatchers/Dynamic/VariantValue.h" |
| 28 | #include "clang/Basic/LLVM.h" |
| 29 | #include "llvm/Support/type_traits.h" |
| 30 | |
| 31 | namespace clang { |
| 32 | namespace ast_matchers { |
| 33 | namespace dynamic { |
| 34 | |
| 35 | namespace internal { |
| 36 | |
| 37 | /// \brief Helper template class to just from argument type to the right is/get |
| 38 | /// functions in VariantValue. |
| 39 | /// Used to verify and extract the matcher arguments below. |
| 40 | template <class T> struct ArgTypeTraits; |
| 41 | template <class T> struct ArgTypeTraits<const T &> : public ArgTypeTraits<T> { |
| 42 | }; |
| 43 | |
| 44 | template <> struct ArgTypeTraits<std::string> { |
Samuel Benzaquen | 81ef929 | 2013-06-20 14:28:32 +0000 | [diff] [blame] | 45 | static StringRef asString() { return "String"; } |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 46 | static bool is(const VariantValue &Value) { return Value.isString(); } |
| 47 | static const std::string &get(const VariantValue &Value) { |
| 48 | return Value.getString(); |
| 49 | } |
| 50 | }; |
| 51 | |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 52 | template <> |
| 53 | struct ArgTypeTraits<StringRef> : public ArgTypeTraits<std::string> { |
| 54 | }; |
| 55 | |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 56 | template <class T> struct ArgTypeTraits<ast_matchers::internal::Matcher<T> > { |
Samuel Benzaquen | 81ef929 | 2013-06-20 14:28:32 +0000 | [diff] [blame] | 57 | static std::string asString() { |
| 58 | return (Twine("Matcher<") + |
| 59 | ast_type_traits::ASTNodeKind::getFromNodeKind<T>().asStringRef() + |
| 60 | ">").str(); |
| 61 | } |
| 62 | static bool is(const VariantValue &Value) { |
| 63 | return Value.hasTypedMatcher<T>(); |
| 64 | } |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 65 | static ast_matchers::internal::Matcher<T> get(const VariantValue &Value) { |
| 66 | return Value.getTypedMatcher<T>(); |
| 67 | } |
Samuel Benzaquen | c31b352 | 2013-06-04 15:46:22 +0000 | [diff] [blame] | 68 | }; |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 69 | |
Samuel Benzaquen | c31b352 | 2013-06-04 15:46:22 +0000 | [diff] [blame] | 70 | template <> struct ArgTypeTraits<unsigned> { |
Samuel Benzaquen | 81ef929 | 2013-06-20 14:28:32 +0000 | [diff] [blame] | 71 | static std::string asString() { return "Unsigned"; } |
Samuel Benzaquen | c31b352 | 2013-06-04 15:46:22 +0000 | [diff] [blame] | 72 | static bool is(const VariantValue &Value) { return Value.isUnsigned(); } |
| 73 | static unsigned get(const VariantValue &Value) { |
| 74 | return Value.getUnsigned(); |
| 75 | } |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | /// \brief Generic MatcherCreate interface. |
| 79 | /// |
| 80 | /// Provides a \c run() method that constructs the matcher from the provided |
| 81 | /// arguments. |
| 82 | class MatcherCreateCallback { |
| 83 | public: |
| 84 | virtual ~MatcherCreateCallback() {} |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 85 | virtual MatcherList run(const SourceRange &NameRange, |
| 86 | ArrayRef<ParserValue> Args, |
| 87 | Diagnostics *Error) const = 0; |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | /// \brief Simple callback implementation. Marshaller and function are provided. |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 91 | /// |
| 92 | /// This class wraps a function of arbitrary signature and a marshaller |
| 93 | /// function into a MatcherCreateCallback. |
| 94 | /// The marshaller is in charge of taking the VariantValue arguments, checking |
| 95 | /// their types, unpacking them and calling the underlying function. |
| 96 | template <typename FuncType> |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 97 | class FixedArgCountMatcherCreateCallback : public MatcherCreateCallback { |
| 98 | public: |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 99 | /// FIXME: Use void(*)() as FuncType on this interface to remove the template |
| 100 | /// argument of this class. The marshaller can cast the function pointer back |
| 101 | /// to the original type. |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 102 | typedef MatcherList (*MarshallerType)(FuncType, StringRef, |
| 103 | const SourceRange &, |
| 104 | ArrayRef<ParserValue>, |
| 105 | Diagnostics *); |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 106 | |
Dmitri Gribenko | cb63baf | 2013-05-17 17:50:16 +0000 | [diff] [blame] | 107 | /// \param Marshaller Function to unpack the arguments and call \c Func |
| 108 | /// \param Func Matcher construct function. This is the function that |
| 109 | /// compile-time matcher expressions would use to create the matcher. |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 110 | FixedArgCountMatcherCreateCallback(MarshallerType Marshaller, FuncType Func, |
| 111 | StringRef MatcherName) |
| 112 | : Marshaller(Marshaller), Func(Func), MatcherName(MatcherName.str()) {} |
| 113 | |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 114 | MatcherList run(const SourceRange &NameRange, ArrayRef<ParserValue> Args, |
| 115 | Diagnostics *Error) const { |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 116 | return Marshaller(Func, MatcherName, NameRange, Args, Error); |
| 117 | } |
| 118 | |
| 119 | private: |
| 120 | const MarshallerType Marshaller; |
| 121 | const FuncType Func; |
| 122 | const std::string MatcherName; |
| 123 | }; |
| 124 | |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 125 | /// \brief Simple callback implementation. Free function is wrapped. |
| 126 | /// |
| 127 | /// This class simply wraps a free function with the right signature to export |
| 128 | /// it as a MatcherCreateCallback. |
| 129 | /// This allows us to have one implementation of the interface for as many free |
| 130 | /// functions as we want, reducing the number of symbols and size of the |
| 131 | /// object file. |
| 132 | class FreeFuncMatcherCreateCallback : public MatcherCreateCallback { |
| 133 | public: |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 134 | typedef MatcherList (*RunFunc)(StringRef MatcherName, |
| 135 | const SourceRange &NameRange, |
| 136 | ArrayRef<ParserValue> Args, |
| 137 | Diagnostics *Error); |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 138 | |
| 139 | FreeFuncMatcherCreateCallback(RunFunc Func, StringRef MatcherName) |
| 140 | : Func(Func), MatcherName(MatcherName.str()) {} |
| 141 | |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 142 | MatcherList run(const SourceRange &NameRange, ArrayRef<ParserValue> Args, |
| 143 | Diagnostics *Error) const { |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 144 | return Func(MatcherName, NameRange, Args, Error); |
| 145 | } |
| 146 | |
| 147 | private: |
| 148 | const RunFunc Func; |
| 149 | const std::string MatcherName; |
| 150 | }; |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 151 | |
| 152 | /// \brief Helper macros to check the arguments on all marshaller functions. |
| 153 | #define CHECK_ARG_COUNT(count) \ |
| 154 | if (Args.size() != count) { \ |
| 155 | Error->pushErrorFrame(NameRange, Error->ET_RegistryWrongArgCount) \ |
| 156 | << count << Args.size(); \ |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 157 | return MatcherList(); \ |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | #define CHECK_ARG_TYPE(index, type) \ |
| 161 | if (!ArgTypeTraits<type>::is(Args[index].Value)) { \ |
| 162 | Error->pushErrorFrame(Args[index].Range, Error->ET_RegistryWrongArgType) \ |
Samuel Benzaquen | 81ef929 | 2013-06-20 14:28:32 +0000 | [diff] [blame] | 163 | << (index + 1) << ArgTypeTraits<type>::asString() \ |
| 164 | << Args[index].Value.getTypeAsString(); \ |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 165 | return MatcherList(); \ |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 166 | } |
| 167 | |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 168 | /// \brief Helper methods to extract and merge all possible typed matchers |
| 169 | /// out of the polymorphic object. |
| 170 | template <class PolyMatcher> |
| 171 | static void mergePolyMatchers(const PolyMatcher &Poly, MatcherList *Out, |
| 172 | ast_matchers::internal::EmptyTypeList) {} |
| 173 | |
| 174 | template <class PolyMatcher, class TypeList> |
| 175 | static void mergePolyMatchers(const PolyMatcher &Poly, MatcherList *Out, |
| 176 | TypeList) { |
| 177 | Out->add(ast_matchers::internal::Matcher<typename TypeList::head>(Poly)); |
| 178 | mergePolyMatchers(Poly, Out, typename TypeList::tail()); |
| 179 | } |
| 180 | |
| 181 | /// \brief Convert the return values of the functions into a MatcherList. |
| 182 | /// |
| 183 | /// There are 2 cases right now: The return value is a Matcher<T> or is a |
| 184 | /// polymorphic matcher. For the former, we just construct the MatcherList. For |
| 185 | /// the latter, we instantiate all the possible Matcher<T> of the poly matcher. |
| 186 | template <typename T> |
| 187 | static MatcherList |
| 188 | outvalueToMatcherList(const ast_matchers::internal::Matcher<T> &Matcher) { |
| 189 | return MatcherList(Matcher); |
| 190 | } |
| 191 | |
| 192 | template <typename T> |
| 193 | static MatcherList |
| 194 | outvalueToMatcherList(const T& PolyMatcher, typename T::ReturnTypes* = NULL) { |
| 195 | MatcherList Matchers; |
| 196 | mergePolyMatchers(PolyMatcher, &Matchers, typename T::ReturnTypes()); |
| 197 | return Matchers; |
| 198 | } |
| 199 | |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 200 | /// \brief 0-arg marshaller function. |
| 201 | template <typename ReturnType> |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 202 | static MatcherList matcherMarshall0(ReturnType (*Func)(), |
| 203 | StringRef MatcherName, |
| 204 | const SourceRange &NameRange, |
| 205 | ArrayRef<ParserValue> Args, |
| 206 | Diagnostics *Error) { |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 207 | CHECK_ARG_COUNT(0); |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 208 | return outvalueToMatcherList(Func()); |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | /// \brief 1-arg marshaller function. |
Samuel Benzaquen | c31b352 | 2013-06-04 15:46:22 +0000 | [diff] [blame] | 212 | template <typename ReturnType, typename ArgType1> |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 213 | static MatcherList matcherMarshall1(ReturnType (*Func)(ArgType1), |
| 214 | StringRef MatcherName, |
| 215 | const SourceRange &NameRange, |
| 216 | ArrayRef<ParserValue> Args, |
| 217 | Diagnostics *Error) { |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 218 | CHECK_ARG_COUNT(1); |
| 219 | CHECK_ARG_TYPE(0, ArgType1); |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 220 | return outvalueToMatcherList( |
| 221 | Func(ArgTypeTraits<ArgType1>::get(Args[0].Value))); |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 222 | } |
| 223 | |
Samuel Benzaquen | c31b352 | 2013-06-04 15:46:22 +0000 | [diff] [blame] | 224 | /// \brief 2-arg marshaller function. |
| 225 | template <typename ReturnType, typename ArgType1, typename ArgType2> |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 226 | static MatcherList matcherMarshall2(ReturnType (*Func)(ArgType1, ArgType2), |
| 227 | StringRef MatcherName, |
| 228 | const SourceRange &NameRange, |
| 229 | ArrayRef<ParserValue> Args, |
| 230 | Diagnostics *Error) { |
Samuel Benzaquen | c31b352 | 2013-06-04 15:46:22 +0000 | [diff] [blame] | 231 | CHECK_ARG_COUNT(2); |
| 232 | CHECK_ARG_TYPE(0, ArgType1); |
| 233 | CHECK_ARG_TYPE(1, ArgType2); |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 234 | return outvalueToMatcherList( |
| 235 | Func(ArgTypeTraits<ArgType1>::get(Args[0].Value), |
| 236 | ArgTypeTraits<ArgType2>::get(Args[1].Value))); |
Samuel Benzaquen | c31b352 | 2013-06-04 15:46:22 +0000 | [diff] [blame] | 237 | } |
| 238 | |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 239 | #undef CHECK_ARG_COUNT |
| 240 | #undef CHECK_ARG_TYPE |
| 241 | |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 242 | /// \brief Variadic marshaller function. |
| 243 | template <typename BaseType, typename DerivedType> |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 244 | MatcherList VariadicMatcherCreateCallback(StringRef MatcherName, |
| 245 | const SourceRange &NameRange, |
| 246 | ArrayRef<ParserValue> Args, |
| 247 | Diagnostics *Error) { |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 248 | typedef ast_matchers::internal::Matcher<DerivedType> DerivedMatcherType; |
| 249 | DerivedMatcherType **InnerArgs = new DerivedMatcherType *[Args.size()](); |
| 250 | |
| 251 | bool HasError = false; |
| 252 | for (size_t i = 0, e = Args.size(); i != e; ++i) { |
Samuel Benzaquen | 81ef929 | 2013-06-20 14:28:32 +0000 | [diff] [blame] | 253 | typedef ArgTypeTraits<DerivedMatcherType> DerivedTraits; |
| 254 | const ParserValue &Arg = Args[i]; |
| 255 | const VariantValue &Value = Arg.Value; |
| 256 | if (!DerivedTraits::is(Value)) { |
| 257 | Error->pushErrorFrame(Arg.Range, Error->ET_RegistryWrongArgType) |
| 258 | << (i + 1) << DerivedTraits::asString() << Value.getTypeAsString(); |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 259 | HasError = true; |
| 260 | break; |
| 261 | } |
Samuel Benzaquen | 81ef929 | 2013-06-20 14:28:32 +0000 | [diff] [blame] | 262 | InnerArgs[i] = new DerivedMatcherType(DerivedTraits::get(Value)); |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 263 | } |
| 264 | |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 265 | MatcherList Out; |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 266 | if (!HasError) { |
| 267 | Out = ast_matchers::internal::makeDynCastAllOfComposite<BaseType>( |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 268 | ArrayRef<const DerivedMatcherType *>(InnerArgs, Args.size())); |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | for (size_t i = 0, e = Args.size(); i != e; ++i) { |
| 272 | delete InnerArgs[i]; |
| 273 | } |
| 274 | delete[] InnerArgs; |
| 275 | return Out; |
| 276 | } |
| 277 | |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 278 | /// Helper functions to select the appropriate marshaller functions. |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 279 | /// They detect the number of arguments, arguments types and return type. |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 280 | |
| 281 | /// \brief 0-arg overload |
| 282 | template <typename ReturnType> |
| 283 | MatcherCreateCallback *makeMatcherAutoMarshall(ReturnType (*Func)(), |
| 284 | StringRef MatcherName) { |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 285 | return new FixedArgCountMatcherCreateCallback<ReturnType (*)()>( |
| 286 | matcherMarshall0, Func, MatcherName); |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | /// \brief 1-arg overload |
| 290 | template <typename ReturnType, typename ArgType1> |
| 291 | MatcherCreateCallback *makeMatcherAutoMarshall(ReturnType (*Func)(ArgType1), |
| 292 | StringRef MatcherName) { |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 293 | return new FixedArgCountMatcherCreateCallback<ReturnType (*)(ArgType1)>( |
| 294 | matcherMarshall1, Func, MatcherName); |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 295 | } |
| 296 | |
Samuel Benzaquen | c31b352 | 2013-06-04 15:46:22 +0000 | [diff] [blame] | 297 | /// \brief 2-arg overload |
| 298 | template <typename ReturnType, typename ArgType1, typename ArgType2> |
| 299 | MatcherCreateCallback *makeMatcherAutoMarshall(ReturnType (*Func)(ArgType1, |
| 300 | ArgType2), |
| 301 | StringRef MatcherName) { |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 302 | return new FixedArgCountMatcherCreateCallback< |
| 303 | ReturnType (*)(ArgType1, ArgType2)>(matcherMarshall2, Func, MatcherName); |
Samuel Benzaquen | c31b352 | 2013-06-04 15:46:22 +0000 | [diff] [blame] | 304 | } |
| 305 | |
Samuel Benzaquen | c6f2c9b | 2013-06-21 15:51:31 +0000 | [diff] [blame^] | 306 | /// \brief Variadic overloads. |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 307 | template <typename MatcherType> |
| 308 | MatcherCreateCallback *makeMatcherAutoMarshall( |
| 309 | ast_matchers::internal::VariadicAllOfMatcher<MatcherType> Func, |
| 310 | StringRef MatcherName) { |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 311 | return new FreeFuncMatcherCreateCallback( |
| 312 | &VariadicMatcherCreateCallback<MatcherType, MatcherType>, MatcherName); |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | template <typename BaseType, typename MatcherType> |
| 316 | MatcherCreateCallback * |
| 317 | makeMatcherAutoMarshall(ast_matchers::internal::VariadicDynCastAllOfMatcher< |
| 318 | BaseType, MatcherType> Func, |
| 319 | StringRef MatcherName) { |
Samuel Benzaquen | b5dd69f | 2013-06-11 18:51:07 +0000 | [diff] [blame] | 320 | return new FreeFuncMatcherCreateCallback( |
| 321 | &VariadicMatcherCreateCallback<BaseType, MatcherType>, MatcherName); |
Manuel Klimek | 24db0f0 | 2013-05-14 09:13:00 +0000 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | } // namespace internal |
| 325 | } // namespace dynamic |
| 326 | } // namespace ast_matchers |
| 327 | } // namespace clang |
| 328 | |
| 329 | #endif // LLVM_CLANG_AST_MATCHERS_DYNAMIC_MARSHALLERS_H |