clang  13.0.0git
Marshallers.h
Go to the documentation of this file.
1 //===- Marshallers.h - Generic matcher function marshallers -----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file
10 /// Functions templates and classes to wrap matcher construct functions.
11 ///
12 /// A collection of template function and classes that provide a generic
13 /// marshalling layer on top of matcher construct functions.
14 /// These are used by the registry to export all marshaller constructors with
15 /// the same generic interface.
16 //
17 //===----------------------------------------------------------------------===//
18 
19 #ifndef LLVM_CLANG_LIB_ASTMATCHERS_DYNAMIC_MARSHALLERS_H
20 #define LLVM_CLANG_LIB_ASTMATCHERS_DYNAMIC_MARSHALLERS_H
21 
27 #include "clang/Basic/AttrKinds.h"
28 #include "clang/Basic/LLVM.h"
30 #include "clang/Basic/TypeTraits.h"
31 #include "llvm/ADT/ArrayRef.h"
32 #include "llvm/ADT/None.h"
33 #include "llvm/ADT/Optional.h"
34 #include "llvm/ADT/STLExtras.h"
35 #include "llvm/ADT/StringRef.h"
36 #include "llvm/ADT/StringSwitch.h"
37 #include "llvm/ADT/Twine.h"
38 #include "llvm/Support/Regex.h"
39 #include <cassert>
40 #include <cstddef>
41 #include <iterator>
42 #include <limits>
43 #include <memory>
44 #include <string>
45 #include <utility>
46 #include <vector>
47 
48 namespace clang {
49 namespace ast_matchers {
50 namespace dynamic {
51 namespace internal {
52 
53 /// Helper template class to just from argument type to the right is/get
54 /// functions in VariantValue.
55 /// Used to verify and extract the matcher arguments below.
56 template <class T> struct ArgTypeTraits;
57 template <class T> struct ArgTypeTraits<const T &> : public ArgTypeTraits<T> {
58 };
59 
60 template <> struct ArgTypeTraits<std::string> {
61  static bool hasCorrectType(const VariantValue &Value) {
62  return Value.isString();
63  }
64  static bool hasCorrectValue(const VariantValue &Value) { return true; }
65 
66  static const std::string &get(const VariantValue &Value) {
67  return Value.getString();
68  }
69 
70  static ArgKind getKind() {
72  }
73 
75  return llvm::None;
76  }
77 };
78 
79 template <>
80 struct ArgTypeTraits<StringRef> : public ArgTypeTraits<std::string> {
81 };
82 
83 template <class T> struct ArgTypeTraits<ast_matchers::internal::Matcher<T>> {
84  static bool hasCorrectType(const VariantValue& Value) {
85  return Value.isMatcher();
86  }
87  static bool hasCorrectValue(const VariantValue &Value) {
88  return Value.getMatcher().hasTypedMatcher<T>();
89  }
90 
91  static ast_matchers::internal::Matcher<T> get(const VariantValue &Value) {
92  return Value.getMatcher().getTypedMatcher<T>();
93  }
94 
95  static ArgKind getKind() {
96  return ArgKind::MakeMatcherArg(ASTNodeKind::getFromNodeKind<T>());
97  }
98 
100  return llvm::None;
101  }
102 };
103 
104 template <> struct ArgTypeTraits<bool> {
105  static bool hasCorrectType(const VariantValue &Value) {
106  return Value.isBoolean();
107  }
108  static bool hasCorrectValue(const VariantValue &Value) { return true; }
109 
110  static bool get(const VariantValue &Value) {
111  return Value.getBoolean();
112  }
113 
114  static ArgKind getKind() {
116  }
117 
119  return llvm::None;
120  }
121 };
122 
123 template <> struct ArgTypeTraits<double> {
124  static bool hasCorrectType(const VariantValue &Value) {
125  return Value.isDouble();
126  }
127  static bool hasCorrectValue(const VariantValue &Value) { return true; }
128 
129  static double get(const VariantValue &Value) {
130  return Value.getDouble();
131  }
132 
133  static ArgKind getKind() {
134  return ArgKind(ArgKind::AK_Double);
135  }
136 
138  return llvm::None;
139  }
140 };
141 
142 template <> struct ArgTypeTraits<unsigned> {
143  static bool hasCorrectType(const VariantValue &Value) {
144  return Value.isUnsigned();
145  }
146  static bool hasCorrectValue(const VariantValue &Value) { return true; }
147 
148  static unsigned get(const VariantValue &Value) {
149  return Value.getUnsigned();
150  }
151 
152  static ArgKind getKind() {
154  }
155 
157  return llvm::None;
158  }
159 };
160 
161 template <> struct ArgTypeTraits<attr::Kind> {
162 private:
163  static Optional<attr::Kind> getAttrKind(llvm::StringRef AttrKind) {
164  if (!AttrKind.consume_front("attr::"))
165  return llvm::None;
166  return llvm::StringSwitch<Optional<attr::Kind>>(AttrKind)
167 #define ATTR(X) .Case(#X, attr::X)
168 #include "clang/Basic/AttrList.inc"
169  .Default(llvm::None);
170  }
171 
172 public:
173  static bool hasCorrectType(const VariantValue &Value) {
174  return Value.isString();
175  }
176  static bool hasCorrectValue(const VariantValue& Value) {
177  return getAttrKind(Value.getString()).hasValue();
178  }
179 
180  static attr::Kind get(const VariantValue &Value) {
181  return *getAttrKind(Value.getString());
182  }
183 
184  static ArgKind getKind() {
185  return ArgKind(ArgKind::AK_String);
186  }
187 
189 };
190 
191 template <> struct ArgTypeTraits<CastKind> {
192 private:
193  static Optional<CastKind> getCastKind(llvm::StringRef AttrKind) {
194  if (!AttrKind.consume_front("CK_"))
195  return llvm::None;
196  return llvm::StringSwitch<Optional<CastKind>>(AttrKind)
197 #define CAST_OPERATION(Name) .Case(#Name, CK_##Name)
198 #include "clang/AST/OperationKinds.def"
199  .Default(llvm::None);
200  }
201 
202 public:
203  static bool hasCorrectType(const VariantValue &Value) {
204  return Value.isString();
205  }
206  static bool hasCorrectValue(const VariantValue& Value) {
207  return getCastKind(Value.getString()).hasValue();
208  }
209 
210  static CastKind get(const VariantValue &Value) {
211  return *getCastKind(Value.getString());
212  }
213 
214  static ArgKind getKind() {
215  return ArgKind(ArgKind::AK_String);
216  }
217 
219 };
220 
221 template <> struct ArgTypeTraits<llvm::Regex::RegexFlags> {
222 private:
223  static Optional<llvm::Regex::RegexFlags> getFlags(llvm::StringRef Flags);
224 
225 public:
226  static bool hasCorrectType(const VariantValue &Value) {
227  return Value.isString();
228  }
229  static bool hasCorrectValue(const VariantValue& Value) {
230  return getFlags(Value.getString()).hasValue();
231  }
232 
233  static llvm::Regex::RegexFlags get(const VariantValue &Value) {
234  return *getFlags(Value.getString());
235  }
236 
238 
240 };
241 
242 template <> struct ArgTypeTraits<OpenMPClauseKind> {
243 private:
244  static Optional<OpenMPClauseKind> getClauseKind(llvm::StringRef ClauseKind) {
245  return llvm::StringSwitch<Optional<OpenMPClauseKind>>(ClauseKind)
247 #define CLAUSE_CLASS(Enum, Str, Class) .Case(#Enum, llvm::omp::Clause::Enum)
248 #include "llvm/Frontend/OpenMP/OMP.inc"
249  .Default(llvm::None);
250  }
251 
252 public:
253  static bool hasCorrectType(const VariantValue &Value) {
254  return Value.isString();
255  }
256  static bool hasCorrectValue(const VariantValue& Value) {
257  return getClauseKind(Value.getString()).hasValue();
258  }
259 
261  return *getClauseKind(Value.getString());
262  }
263 
265 
267 };
268 
269 template <> struct ArgTypeTraits<UnaryExprOrTypeTrait> {
270 private:
272  getUnaryOrTypeTraitKind(llvm::StringRef ClauseKind) {
273  if (!ClauseKind.consume_front("UETT_"))
274  return llvm::None;
275  return llvm::StringSwitch<Optional<UnaryExprOrTypeTrait>>(ClauseKind)
276 #define UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key) .Case(#Name, UETT_##Name)
277 #define CXX11_UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key) \
278  .Case(#Name, UETT_##Name)
279 #include "clang/Basic/TokenKinds.def"
280  .Default(llvm::None);
281  }
282 
283 public:
284  static bool hasCorrectType(const VariantValue &Value) {
285  return Value.isString();
286  }
287  static bool hasCorrectValue(const VariantValue& Value) {
288  return getUnaryOrTypeTraitKind(Value.getString()).hasValue();
289  }
290 
292  return *getUnaryOrTypeTraitKind(Value.getString());
293  }
294 
296 
298 };
299 
300 /// Matcher descriptor interface.
301 ///
302 /// Provides a \c create() method that constructs the matcher from the provided
303 /// arguments, and various other methods for type introspection.
305 public:
306  virtual ~MatcherDescriptor() = default;
307 
308  virtual VariantMatcher create(SourceRange NameRange,
310  Diagnostics *Error) const = 0;
311 
312  virtual ASTNodeKind nodeMatcherType() const { return ASTNodeKind(); }
313 
314  virtual bool isBuilderMatcher() const { return false; }
315 
316  virtual std::unique_ptr<MatcherDescriptor>
318  Diagnostics *Error) const {
319  return {};
320  }
321 
322  /// Returns whether the matcher is variadic. Variadic matchers can take any
323  /// number of arguments, but they must be of the same type.
324  virtual bool isVariadic() const = 0;
325 
326  /// Returns the number of arguments accepted by the matcher if not variadic.
327  virtual unsigned getNumArgs() const = 0;
328 
329  /// Given that the matcher is being converted to type \p ThisKind, append the
330  /// set of argument types accepted for argument \p ArgNo to \p ArgKinds.
331  // FIXME: We should provide the ability to constrain the output of this
332  // function based on the types of other matcher arguments.
333  virtual void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo,
334  std::vector<ArgKind> &ArgKinds) const = 0;
335 
336  /// Returns whether this matcher is convertible to the given type. If it is
337  /// so convertible, store in *Specificity a value corresponding to the
338  /// "specificity" of the converted matcher to the given context, and in
339  /// *LeastDerivedKind the least derived matcher kind which would result in the
340  /// same matcher overload. Zero specificity indicates that this conversion
341  /// would produce a trivial matcher that will either always or never match.
342  /// Such matchers are excluded from code completion results.
343  virtual bool
344  isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity = nullptr,
345  ASTNodeKind *LeastDerivedKind = nullptr) const = 0;
346 
347  /// Returns whether the matcher will, given a matcher of any type T, yield a
348  /// matcher of type T.
349  virtual bool isPolymorphic() const { return false; }
350 };
351 
353  ASTNodeKind Kind, unsigned *Specificity,
354  ASTNodeKind *LeastDerivedKind) {
355  for (const ASTNodeKind &NodeKind : RetKinds) {
356  if (ArgKind::MakeMatcherArg(NodeKind).isConvertibleTo(
357  ArgKind::MakeMatcherArg(Kind), Specificity)) {
358  if (LeastDerivedKind)
359  *LeastDerivedKind = NodeKind;
360  return true;
361  }
362  }
363  return false;
364 }
365 
366 /// Simple callback implementation. Marshaller and function are provided.
367 ///
368 /// This class wraps a function of arbitrary signature and a marshaller
369 /// function into a MatcherDescriptor.
370 /// The marshaller is in charge of taking the VariantValue arguments, checking
371 /// their types, unpacking them and calling the underlying function.
373 public:
374  using MarshallerType = VariantMatcher (*)(void (*Func)(),
375  StringRef MatcherName,
376  SourceRange NameRange,
378  Diagnostics *Error);
379 
380  /// \param Marshaller Function to unpack the arguments and call \c Func
381  /// \param Func Matcher construct function. This is the function that
382  /// compile-time matcher expressions would use to create the matcher.
383  /// \param RetKinds The list of matcher types to which the matcher is
384  /// convertible.
385  /// \param ArgKinds The types of the arguments this matcher takes.
386  FixedArgCountMatcherDescriptor(MarshallerType Marshaller, void (*Func)(),
387  StringRef MatcherName,
388  ArrayRef<ASTNodeKind> RetKinds,
389  ArrayRef<ArgKind> ArgKinds)
390  : Marshaller(Marshaller), Func(Func), MatcherName(MatcherName),
391  RetKinds(RetKinds.begin(), RetKinds.end()),
392  ArgKinds(ArgKinds.begin(), ArgKinds.end()) {}
393 
396  Diagnostics *Error) const override {
397  return Marshaller(Func, MatcherName, NameRange, Args, Error);
398  }
399 
400  bool isVariadic() const override { return false; }
401  unsigned getNumArgs() const override { return ArgKinds.size(); }
402 
403  void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo,
404  std::vector<ArgKind> &Kinds) const override {
405  Kinds.push_back(ArgKinds[ArgNo]);
406  }
407 
408  bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity,
409  ASTNodeKind *LeastDerivedKind) const override {
410  return isRetKindConvertibleTo(RetKinds, Kind, Specificity,
411  LeastDerivedKind);
412  }
413 
414 private:
415  const MarshallerType Marshaller;
416  void (* const Func)();
417  const std::string MatcherName;
418  const std::vector<ASTNodeKind> RetKinds;
419  const std::vector<ArgKind> ArgKinds;
420 };
421 
422 /// Helper methods to extract and merge all possible typed matchers
423 /// out of the polymorphic object.
424 template <class PolyMatcher>
425 static void mergePolyMatchers(const PolyMatcher &Poly,
426  std::vector<DynTypedMatcher> &Out,
427  ast_matchers::internal::EmptyTypeList) {}
428 
429 template <class PolyMatcher, class TypeList>
430 static void mergePolyMatchers(const PolyMatcher &Poly,
431  std::vector<DynTypedMatcher> &Out, TypeList) {
432  Out.push_back(ast_matchers::internal::Matcher<typename TypeList::head>(Poly));
433  mergePolyMatchers(Poly, Out, typename TypeList::tail());
434 }
435 
436 /// Convert the return values of the functions into a VariantMatcher.
437 ///
438 /// There are 2 cases right now: The return value is a Matcher<T> or is a
439 /// polymorphic matcher. For the former, we just construct the VariantMatcher.
440 /// For the latter, we instantiate all the possible Matcher<T> of the poly
441 /// matcher.
442 inline VariantMatcher outvalueToVariantMatcher(const DynTypedMatcher &Matcher) {
443  return VariantMatcher::SingleMatcher(Matcher);
444 }
445 
446 template <typename T>
447 static VariantMatcher outvalueToVariantMatcher(const T &PolyMatcher,
448  typename T::ReturnTypes * =
449  nullptr) {
450  std::vector<DynTypedMatcher> Matchers;
451  mergePolyMatchers(PolyMatcher, Matchers, typename T::ReturnTypes());
452  VariantMatcher Out = VariantMatcher::PolymorphicMatcher(std::move(Matchers));
453  return Out;
454 }
455 
456 template <typename T>
457 inline void
458 buildReturnTypeVectorFromTypeList(std::vector<ASTNodeKind> &RetTypes) {
459  RetTypes.push_back(ASTNodeKind::getFromNodeKind<typename T::head>());
460  buildReturnTypeVectorFromTypeList<typename T::tail>(RetTypes);
461 }
462 
463 template <>
464 inline void
465 buildReturnTypeVectorFromTypeList<ast_matchers::internal::EmptyTypeList>(
466  std::vector<ASTNodeKind> &RetTypes) {}
467 
468 template <typename T>
470  static void build(std::vector<ASTNodeKind> &RetTypes) {
471  buildReturnTypeVectorFromTypeList<typename T::ReturnTypes>(RetTypes);
472  }
473 };
474 
475 template <typename T>
476 struct BuildReturnTypeVector<ast_matchers::internal::Matcher<T>> {
477  static void build(std::vector<ASTNodeKind> &RetTypes) {
478  RetTypes.push_back(ASTNodeKind::getFromNodeKind<T>());
479  }
480 };
481 
482 template <typename T>
483 struct BuildReturnTypeVector<ast_matchers::internal::BindableMatcher<T>> {
484  static void build(std::vector<ASTNodeKind> &RetTypes) {
485  RetTypes.push_back(ASTNodeKind::getFromNodeKind<T>());
486  }
487 };
488 
489 /// Variadic marshaller function.
490 template <typename ResultT, typename ArgT,
491  ResultT (*Func)(ArrayRef<const ArgT *>)>
493 variadicMatcherDescriptor(StringRef MatcherName, SourceRange NameRange,
494  ArrayRef<ParserValue> Args, Diagnostics *Error) {
495  SmallVector<ArgT *, 8> InnerArgsPtr;
496  InnerArgsPtr.resize_for_overwrite(Args.size());
497  SmallVector<ArgT, 8> InnerArgs;
498  InnerArgs.reserve(Args.size());
499 
500  for (size_t i = 0, e = Args.size(); i != e; ++i) {
501  using ArgTraits = ArgTypeTraits<ArgT>;
502 
503  const ParserValue &Arg = Args[i];
504  const VariantValue &Value = Arg.Value;
505  if (!ArgTraits::hasCorrectType(Value)) {
506  Error->addError(Arg.Range, Error->ET_RegistryWrongArgType)
507  << (i + 1) << ArgTraits::getKind().asString() << Value.getTypeAsString();
508  return {};
509  }
510  if (!ArgTraits::hasCorrectValue(Value)) {
511  if (llvm::Optional<std::string> BestGuess =
513  Error->addError(Arg.Range, Error->ET_RegistryUnknownEnumWithReplace)
514  << i + 1 << Value.getString() << *BestGuess;
515  } else if (Value.isString()) {
516  Error->addError(Arg.Range, Error->ET_RegistryValueNotFound)
517  << Value.getString();
518  } else {
519  // This isn't ideal, but it's better than reporting an empty string as
520  // the error in this case.
521  Error->addError(Arg.Range, Error->ET_RegistryWrongArgType)
522  << (i + 1) << ArgTraits::getKind().asString()
523  << Value.getTypeAsString();
524  }
525  return {};
526  }
527  InnerArgs.set_size(i + 1);
528  InnerArgsPtr[i] = new (&InnerArgs[i]) ArgT(ArgTraits::get(Value));
529  }
530  return outvalueToVariantMatcher(Func(InnerArgsPtr));
531 }
532 
533 /// Matcher descriptor for variadic functions.
534 ///
535 /// This class simply wraps a VariadicFunction with the right signature to export
536 /// it as a MatcherDescriptor.
537 /// This allows us to have one implementation of the interface for as many free
538 /// functions as we want, reducing the number of symbols and size of the
539 /// object file.
541 public:
542  using RunFunc = VariantMatcher (*)(StringRef MatcherName,
543  SourceRange NameRange,
546 
547  template <typename ResultT, typename ArgT,
548  ResultT (*F)(ArrayRef<const ArgT *>)>
550  ast_matchers::internal::VariadicFunction<ResultT, ArgT, F> Func,
551  StringRef MatcherName)
552  : Func(&variadicMatcherDescriptor<ResultT, ArgT, F>),
553  MatcherName(MatcherName.str()),
554  ArgsKind(ArgTypeTraits<ArgT>::getKind()) {
556  }
557 
560  Diagnostics *Error) const override {
561  return Func(MatcherName, NameRange, Args, Error);
562  }
563 
564  bool isVariadic() const override { return true; }
565  unsigned getNumArgs() const override { return 0; }
566 
567  void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo,
568  std::vector<ArgKind> &Kinds) const override {
569  Kinds.push_back(ArgsKind);
570  }
571 
572  bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity,
573  ASTNodeKind *LeastDerivedKind) const override {
574  return isRetKindConvertibleTo(RetKinds, Kind, Specificity,
575  LeastDerivedKind);
576  }
577 
578  ASTNodeKind nodeMatcherType() const override { return RetKinds[0]; }
579 
580 private:
581  const RunFunc Func;
582  const std::string MatcherName;
583  std::vector<ASTNodeKind> RetKinds;
584  const ArgKind ArgsKind;
585 };
586 
587 /// Return CK_Trivial when appropriate for VariadicDynCastAllOfMatchers.
589 public:
590  template <typename BaseT, typename DerivedT>
592  ast_matchers::internal::VariadicDynCastAllOfMatcher<BaseT, DerivedT> Func,
593  StringRef MatcherName)
594  : VariadicFuncMatcherDescriptor(Func, MatcherName),
595  DerivedKind(ASTNodeKind::getFromNodeKind<DerivedT>()) {}
596 
597  bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity,
598  ASTNodeKind *LeastDerivedKind) const override {
599  // If Kind is not a base of DerivedKind, either DerivedKind is a base of
600  // Kind (in which case the match will always succeed) or Kind and
601  // DerivedKind are unrelated (in which case it will always fail), so set
602  // Specificity to 0.
604  LeastDerivedKind)) {
605  if (Kind.isSame(DerivedKind) || !Kind.isBaseOf(DerivedKind)) {
606  if (Specificity)
607  *Specificity = 0;
608  }
609  return true;
610  } else {
611  return false;
612  }
613  }
614 
615  ASTNodeKind nodeMatcherType() const override { return DerivedKind; }
616 
617 private:
618  const ASTNodeKind DerivedKind;
619 };
620 
621 /// Helper macros to check the arguments on all marshaller functions.
622 #define CHECK_ARG_COUNT(count) \
623  if (Args.size() != count) { \
624  Error->addError(NameRange, Error->ET_RegistryWrongArgCount) \
625  << count << Args.size(); \
626  return VariantMatcher(); \
627  }
628 
629 #define CHECK_ARG_TYPE(index, type) \
630  if (!ArgTypeTraits<type>::hasCorrectType(Args[index].Value)) { \
631  Error->addError(Args[index].Range, Error->ET_RegistryWrongArgType) \
632  << (index + 1) << ArgTypeTraits<type>::getKind().asString() \
633  << Args[index].Value.getTypeAsString(); \
634  return VariantMatcher(); \
635  } \
636  if (!ArgTypeTraits<type>::hasCorrectValue(Args[index].Value)) { \
637  if (llvm::Optional<std::string> BestGuess = \
638  ArgTypeTraits<type>::getBestGuess(Args[index].Value)) { \
639  Error->addError(Args[index].Range, \
640  Error->ET_RegistryUnknownEnumWithReplace) \
641  << index + 1 << Args[index].Value.getString() << *BestGuess; \
642  } else if (Args[index].Value.isString()) { \
643  Error->addError(Args[index].Range, Error->ET_RegistryValueNotFound) \
644  << Args[index].Value.getString(); \
645  } \
646  return VariantMatcher(); \
647  }
648 
649 /// 0-arg marshaller function.
650 template <typename ReturnType>
651 static VariantMatcher matcherMarshall0(void (*Func)(), StringRef MatcherName,
652  SourceRange NameRange,
654  Diagnostics *Error) {
655  using FuncType = ReturnType (*)();
656  CHECK_ARG_COUNT(0);
657  return outvalueToVariantMatcher(reinterpret_cast<FuncType>(Func)());
658 }
659 
660 /// 1-arg marshaller function.
661 template <typename ReturnType, typename ArgType1>
662 static VariantMatcher matcherMarshall1(void (*Func)(), StringRef MatcherName,
663  SourceRange NameRange,
665  Diagnostics *Error) {
666  using FuncType = ReturnType (*)(ArgType1);
667  CHECK_ARG_COUNT(1);
668  CHECK_ARG_TYPE(0, ArgType1);
669  return outvalueToVariantMatcher(reinterpret_cast<FuncType>(Func)(
671 }
672 
673 /// 2-arg marshaller function.
674 template <typename ReturnType, typename ArgType1, typename ArgType2>
675 static VariantMatcher matcherMarshall2(void (*Func)(), StringRef MatcherName,
676  SourceRange NameRange,
678  Diagnostics *Error) {
679  using FuncType = ReturnType (*)(ArgType1, ArgType2);
680  CHECK_ARG_COUNT(2);
681  CHECK_ARG_TYPE(0, ArgType1);
682  CHECK_ARG_TYPE(1, ArgType2);
683  return outvalueToVariantMatcher(reinterpret_cast<FuncType>(Func)(
686 }
687 
688 #undef CHECK_ARG_COUNT
689 #undef CHECK_ARG_TYPE
690 
691 /// Helper class used to collect all the possible overloads of an
692 /// argument adaptative matcher function.
693 template <template <typename ToArg, typename FromArg> class ArgumentAdapterT,
694  typename FromTypes, typename ToTypes>
696 public:
698  StringRef Name, std::vector<std::unique_ptr<MatcherDescriptor>> &Out)
699  : Name(Name), Out(Out) {
700  collect(FromTypes());
701  }
702 
703 private:
704  using AdaptativeFunc = ast_matchers::internal::ArgumentAdaptingMatcherFunc<
705  ArgumentAdapterT, FromTypes, ToTypes>;
706 
707  /// End case for the recursion
708  static void collect(ast_matchers::internal::EmptyTypeList) {}
709 
710  /// Recursive case. Get the overload for the head of the list, and
711  /// recurse to the tail.
712  template <typename FromTypeList>
713  inline void collect(FromTypeList);
714 
715  StringRef Name;
716  std::vector<std::unique_ptr<MatcherDescriptor>> &Out;
717 };
718 
719 /// MatcherDescriptor that wraps multiple "overloads" of the same
720 /// matcher.
721 ///
722 /// It will try every overload and generate appropriate errors for when none or
723 /// more than one overloads match the arguments.
725 public:
727  MutableArrayRef<std::unique_ptr<MatcherDescriptor>> Callbacks)
728  : Overloads(std::make_move_iterator(Callbacks.begin()),
729  std::make_move_iterator(Callbacks.end())) {}
730 
731  ~OverloadedMatcherDescriptor() override = default;
732 
735  Diagnostics *Error) const override {
736  std::vector<VariantMatcher> Constructed;
738  for (const auto &O : Overloads) {
739  VariantMatcher SubMatcher = O->create(NameRange, Args, Error);
740  if (!SubMatcher.isNull()) {
741  Constructed.push_back(SubMatcher);
742  }
743  }
744 
745  if (Constructed.empty()) return VariantMatcher(); // No overload matched.
746  // We ignore the errors if any matcher succeeded.
747  Ctx.revertErrors();
748  if (Constructed.size() > 1) {
749  // More than one constructed. It is ambiguous.
750  Error->addError(NameRange, Error->ET_RegistryAmbiguousOverload);
751  return VariantMatcher();
752  }
753  return Constructed[0];
754  }
755 
756  bool isVariadic() const override {
757  bool Overload0Variadic = Overloads[0]->isVariadic();
758 #ifndef NDEBUG
759  for (const auto &O : Overloads) {
760  assert(Overload0Variadic == O->isVariadic());
761  }
762 #endif
763  return Overload0Variadic;
764  }
765 
766  unsigned getNumArgs() const override {
767  unsigned Overload0NumArgs = Overloads[0]->getNumArgs();
768 #ifndef NDEBUG
769  for (const auto &O : Overloads) {
770  assert(Overload0NumArgs == O->getNumArgs());
771  }
772 #endif
773  return Overload0NumArgs;
774  }
775 
776  void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo,
777  std::vector<ArgKind> &Kinds) const override {
778  for (const auto &O : Overloads) {
779  if (O->isConvertibleTo(ThisKind))
780  O->getArgKinds(ThisKind, ArgNo, Kinds);
781  }
782  }
783 
784  bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity,
785  ASTNodeKind *LeastDerivedKind) const override {
786  for (const auto &O : Overloads) {
787  if (O->isConvertibleTo(Kind, Specificity, LeastDerivedKind))
788  return true;
789  }
790  return false;
791  }
792 
793 private:
794  std::vector<std::unique_ptr<MatcherDescriptor>> Overloads;
795 };
796 
797 template <typename ReturnType>
799 public:
800  RegexMatcherDescriptor(ReturnType (*WithFlags)(StringRef,
801  llvm::Regex::RegexFlags),
802  ReturnType (*NoFlags)(StringRef),
803  ArrayRef<ASTNodeKind> RetKinds)
804  : WithFlags(WithFlags), NoFlags(NoFlags),
805  RetKinds(RetKinds.begin(), RetKinds.end()) {}
806  bool isVariadic() const override { return true; }
807  unsigned getNumArgs() const override { return 0; }
808 
809  void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo,
810  std::vector<ArgKind> &Kinds) const override {
811  assert(ArgNo < 2);
812  Kinds.push_back(ArgKind::AK_String);
813  }
814 
815  bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity,
816  ASTNodeKind *LeastDerivedKind) const override {
817  return isRetKindConvertibleTo(RetKinds, Kind, Specificity,
818  LeastDerivedKind);
819  }
820 
822  Diagnostics *Error) const override {
823  if (Args.size() < 1 || Args.size() > 2) {
824  Error->addError(NameRange, Diagnostics::ET_RegistryWrongArgCount)
825  << "1 or 2" << Args.size();
826  return VariantMatcher();
827  }
829  Error->addError(Args[0].Range, Error->ET_RegistryWrongArgType)
830  << 1 << ArgTypeTraits<StringRef>::getKind().asString()
831  << Args[0].Value.getTypeAsString();
832  return VariantMatcher();
833  }
834  if (Args.size() == 1) {
836  NoFlags(ArgTypeTraits<StringRef>::get(Args[0].Value)));
837  }
839  Args[1].Value)) {
840  Error->addError(Args[1].Range, Error->ET_RegistryWrongArgType)
842  << Args[1].Value.getTypeAsString();
843  return VariantMatcher();
844  }
846  Args[1].Value)) {
847  if (llvm::Optional<std::string> BestGuess =
849  Args[1].Value)) {
850  Error->addError(Args[1].Range, Error->ET_RegistryUnknownEnumWithReplace)
851  << 2 << Args[1].Value.getString() << *BestGuess;
852  } else {
853  Error->addError(Args[1].Range, Error->ET_RegistryValueNotFound)
854  << Args[1].Value.getString();
855  }
856  return VariantMatcher();
857  }
859  WithFlags(ArgTypeTraits<StringRef>::get(Args[0].Value),
861  }
862 
863 private:
864  ReturnType (*const WithFlags)(StringRef, llvm::Regex::RegexFlags);
865  ReturnType (*const NoFlags)(StringRef);
866  const std::vector<ASTNodeKind> RetKinds;
867 };
868 
869 /// Variadic operator marshaller function.
871 public:
872  using VarOp = DynTypedMatcher::VariadicOperator;
873 
874  VariadicOperatorMatcherDescriptor(unsigned MinCount, unsigned MaxCount,
875  VarOp Op, StringRef MatcherName)
876  : MinCount(MinCount), MaxCount(MaxCount), Op(Op),
877  MatcherName(MatcherName) {}
878 
881  Diagnostics *Error) const override {
882  if (Args.size() < MinCount || MaxCount < Args.size()) {
883  const std::string MaxStr =
884  (MaxCount == std::numeric_limits<unsigned>::max() ? ""
885  : Twine(MaxCount))
886  .str();
887  Error->addError(NameRange, Error->ET_RegistryWrongArgCount)
888  << ("(" + Twine(MinCount) + ", " + MaxStr + ")") << Args.size();
889  return VariantMatcher();
890  }
891 
892  std::vector<VariantMatcher> InnerArgs;
893  for (size_t i = 0, e = Args.size(); i != e; ++i) {
894  const ParserValue &Arg = Args[i];
895  const VariantValue &Value = Arg.Value;
896  if (!Value.isMatcher()) {
897  Error->addError(Arg.Range, Error->ET_RegistryWrongArgType)
898  << (i + 1) << "Matcher<>" << Value.getTypeAsString();
899  return VariantMatcher();
900  }
901  InnerArgs.push_back(Value.getMatcher());
902  }
903  return VariantMatcher::VariadicOperatorMatcher(Op, std::move(InnerArgs));
904  }
905 
906  bool isVariadic() const override { return true; }
907  unsigned getNumArgs() const override { return 0; }
908 
909  void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo,
910  std::vector<ArgKind> &Kinds) const override {
911  Kinds.push_back(ArgKind::MakeMatcherArg(ThisKind));
912  }
913 
914  bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity,
915  ASTNodeKind *LeastDerivedKind) const override {
916  if (Specificity)
917  *Specificity = 1;
918  if (LeastDerivedKind)
919  *LeastDerivedKind = Kind;
920  return true;
921  }
922 
923  bool isPolymorphic() const override { return true; }
924 
925 private:
926  const unsigned MinCount;
927  const unsigned MaxCount;
928  const VarOp Op;
929  const StringRef MatcherName;
930 };
931 
933  ASTNodeKind CladeNodeKind;
934  std::vector<ASTNodeKind> NodeKinds;
935 
936 public:
938  std::vector<ASTNodeKind> NodeKinds)
939  : CladeNodeKind(CladeNodeKind), NodeKinds(NodeKinds) {}
940 
942  Diagnostics *Error) const override {
943 
944  std::vector<DynTypedMatcher> NodeArgs;
945 
946  for (auto NK : NodeKinds) {
947  std::vector<DynTypedMatcher> InnerArgs;
948 
949  for (const auto &Arg : Args) {
950  if (!Arg.Value.isMatcher())
951  return {};
952  const VariantMatcher &VM = Arg.Value.getMatcher();
953  if (VM.hasTypedMatcher(NK)) {
954  auto DM = VM.getTypedMatcher(NK);
955  InnerArgs.push_back(DM);
956  }
957  }
958 
959  if (InnerArgs.empty()) {
960  NodeArgs.push_back(
961  DynTypedMatcher::trueMatcher(NK).dynCastTo(CladeNodeKind));
962  } else {
963  NodeArgs.push_back(
964  DynTypedMatcher::constructVariadic(
965  ast_matchers::internal::DynTypedMatcher::VO_AllOf, NK,
966  InnerArgs)
967  .dynCastTo(CladeNodeKind));
968  }
969  }
970 
971  auto Result = DynTypedMatcher::constructVariadic(
972  ast_matchers::internal::DynTypedMatcher::VO_AnyOf, CladeNodeKind,
973  NodeArgs);
974  Result.setAllowBind(true);
975  return VariantMatcher::SingleMatcher(Result);
976  }
977 
978  bool isVariadic() const override { return true; }
979  unsigned getNumArgs() const override { return 0; }
980 
981  void getArgKinds(ASTNodeKind ThisKind, unsigned,
982  std::vector<ArgKind> &Kinds) const override {
983  Kinds.push_back(ArgKind::MakeMatcherArg(ThisKind));
984  }
985 
986  bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity,
987  ASTNodeKind *LeastDerivedKind) const override {
988  if (Specificity)
989  *Specificity = 1;
990  if (LeastDerivedKind)
991  *LeastDerivedKind = CladeNodeKind;
992  return true;
993  }
994 };
995 
997 public:
999  Diagnostics *) const override {
1000  return {};
1001  }
1002 
1003  bool isBuilderMatcher() const override { return true; }
1004 
1005  std::unique_ptr<MatcherDescriptor>
1007  Diagnostics *) const override {
1008 
1009  std::vector<ASTNodeKind> NodeKinds;
1010  for (auto Arg : Args) {
1011  if (!Arg.Value.isNodeKind())
1012  return {};
1013  NodeKinds.push_back(Arg.Value.getNodeKind());
1014  }
1015 
1016  if (NodeKinds.empty())
1017  return {};
1018 
1019  ASTNodeKind CladeNodeKind = NodeKinds.front().getCladeKind();
1020 
1021  for (auto NK : NodeKinds)
1022  {
1023  if (!NK.getCladeKind().isSame(CladeNodeKind))
1024  return {};
1025  }
1026 
1027  return std::make_unique<MapAnyOfMatcherDescriptor>(CladeNodeKind,
1028  NodeKinds);
1029  }
1030 
1031  bool isVariadic() const override { return true; }
1032 
1033  unsigned getNumArgs() const override { return 0; }
1034 
1035  void getArgKinds(ASTNodeKind ThisKind, unsigned,
1036  std::vector<ArgKind> &ArgKinds) const override {
1037  ArgKinds.push_back(ArgKind::MakeNodeArg(ThisKind));
1038  return;
1039  }
1040  bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity = nullptr,
1041  ASTNodeKind *LeastDerivedKind = nullptr) const override {
1042  if (Specificity)
1043  *Specificity = 1;
1044  if (LeastDerivedKind)
1045  *LeastDerivedKind = Kind;
1046  return true;
1047  }
1048 
1049  bool isPolymorphic() const override { return false; }
1050 };
1051 
1052 /// Helper functions to select the appropriate marshaller functions.
1053 /// They detect the number of arguments, arguments types and return type.
1054 
1055 /// 0-arg overload
1056 template <typename ReturnType>
1057 std::unique_ptr<MatcherDescriptor>
1058 makeMatcherAutoMarshall(ReturnType (*Func)(), StringRef MatcherName) {
1059  std::vector<ASTNodeKind> RetTypes;
1061  return std::make_unique<FixedArgCountMatcherDescriptor>(
1062  matcherMarshall0<ReturnType>, reinterpret_cast<void (*)()>(Func),
1063  MatcherName, RetTypes, None);
1064 }
1065 
1066 /// 1-arg overload
1067 template <typename ReturnType, typename ArgType1>
1068 std::unique_ptr<MatcherDescriptor>
1069 makeMatcherAutoMarshall(ReturnType (*Func)(ArgType1), StringRef MatcherName) {
1070  std::vector<ASTNodeKind> RetTypes;
1073  return std::make_unique<FixedArgCountMatcherDescriptor>(
1074  matcherMarshall1<ReturnType, ArgType1>,
1075  reinterpret_cast<void (*)()>(Func), MatcherName, RetTypes, AK);
1076 }
1077 
1078 /// 2-arg overload
1079 template <typename ReturnType, typename ArgType1, typename ArgType2>
1080 std::unique_ptr<MatcherDescriptor>
1081 makeMatcherAutoMarshall(ReturnType (*Func)(ArgType1, ArgType2),
1082  StringRef MatcherName) {
1083  std::vector<ASTNodeKind> RetTypes;
1087  return std::make_unique<FixedArgCountMatcherDescriptor>(
1088  matcherMarshall2<ReturnType, ArgType1, ArgType2>,
1089  reinterpret_cast<void (*)()>(Func), MatcherName, RetTypes, AKs);
1090 }
1091 
1092 template <typename ReturnType>
1093 std::unique_ptr<MatcherDescriptor> makeMatcherRegexMarshall(
1094  ReturnType (*FuncFlags)(llvm::StringRef, llvm::Regex::RegexFlags),
1095  ReturnType (*Func)(llvm::StringRef)) {
1096  std::vector<ASTNodeKind> RetTypes;
1098  return std::make_unique<RegexMatcherDescriptor<ReturnType>>(FuncFlags, Func,
1099  RetTypes);
1100 }
1101 
1102 /// Variadic overload.
1103 template <typename ResultT, typename ArgT,
1104  ResultT (*Func)(ArrayRef<const ArgT *>)>
1105 std::unique_ptr<MatcherDescriptor> makeMatcherAutoMarshall(
1106  ast_matchers::internal::VariadicFunction<ResultT, ArgT, Func> VarFunc,
1107  StringRef MatcherName) {
1108  return std::make_unique<VariadicFuncMatcherDescriptor>(VarFunc, MatcherName);
1109 }
1110 
1111 /// Overload for VariadicDynCastAllOfMatchers.
1112 ///
1113 /// Not strictly necessary, but DynCastAllOfMatcherDescriptor gives us better
1114 /// completion results for that type of matcher.
1115 template <typename BaseT, typename DerivedT>
1116 std::unique_ptr<MatcherDescriptor> makeMatcherAutoMarshall(
1117  ast_matchers::internal::VariadicDynCastAllOfMatcher<BaseT, DerivedT>
1118  VarFunc,
1119  StringRef MatcherName) {
1120  return std::make_unique<DynCastAllOfMatcherDescriptor>(VarFunc, MatcherName);
1121 }
1122 
1123 /// Argument adaptative overload.
1124 template <template <typename ToArg, typename FromArg> class ArgumentAdapterT,
1125  typename FromTypes, typename ToTypes>
1126 std::unique_ptr<MatcherDescriptor> makeMatcherAutoMarshall(
1127  ast_matchers::internal::ArgumentAdaptingMatcherFunc<ArgumentAdapterT,
1128  FromTypes, ToTypes>,
1129  StringRef MatcherName) {
1130  std::vector<std::unique_ptr<MatcherDescriptor>> Overloads;
1132  Overloads);
1133  return std::make_unique<OverloadedMatcherDescriptor>(Overloads);
1134 }
1135 
1136 template <template <typename ToArg, typename FromArg> class ArgumentAdapterT,
1137  typename FromTypes, typename ToTypes>
1138 template <typename FromTypeList>
1139 inline void AdaptativeOverloadCollector<ArgumentAdapterT, FromTypes,
1140  ToTypes>::collect(FromTypeList) {
1141  Out.push_back(makeMatcherAutoMarshall(
1142  &AdaptativeFunc::template create<typename FromTypeList::head>, Name));
1143  collect(typename FromTypeList::tail());
1144 }
1145 
1146 /// Variadic operator overload.
1147 template <unsigned MinCount, unsigned MaxCount>
1148 std::unique_ptr<MatcherDescriptor> makeMatcherAutoMarshall(
1149  ast_matchers::internal::VariadicOperatorMatcherFunc<MinCount, MaxCount>
1150  Func,
1151  StringRef MatcherName) {
1152  return std::make_unique<VariadicOperatorMatcherDescriptor>(
1153  MinCount, MaxCount, Func.Op, MatcherName);
1154 }
1155 
1156 template <typename CladeType, typename... MatcherT>
1157 std::unique_ptr<MatcherDescriptor> makeMatcherAutoMarshall(
1158  ast_matchers::internal::MapAnyOfMatcherImpl<CladeType, MatcherT...>,
1159  StringRef MatcherName) {
1160  return std::make_unique<MapAnyOfMatcherDescriptor>(
1161  ASTNodeKind::getFromNodeKind<CladeType>(),
1162  std::vector<ASTNodeKind>{ASTNodeKind::getFromNodeKind<MatcherT>()...});
1163 }
1164 
1165 } // namespace internal
1166 } // namespace dynamic
1167 } // namespace ast_matchers
1168 } // namespace clang
1169 
1170 #endif // LLVM_CLANG_AST_MATCHERS_DYNAMIC_MARSHALLERS_H
clang::ast_matchers::dynamic::ParserValue
A VariantValue instance annotated with its parser context.
Definition: Diagnostics.h:42
clang::ast_matchers::dynamic::internal::makeMatcherAutoMarshall
std::unique_ptr< MatcherDescriptor > makeMatcherAutoMarshall(ReturnType(*Func)(), StringRef MatcherName)
Helper functions to select the appropriate marshaller functions.
Definition: Marshallers.h:1058
clang::ast_matchers::dynamic::internal::MatcherDescriptor::isBuilderMatcher
virtual bool isBuilderMatcher() const
Definition: Marshallers.h:314
clang::ast_matchers::dynamic::VariantMatcher::isNull
bool isNull() const
Whether the matcher is null.
Definition: VariantValue.h:167
max
__DEVICE__ int max(int __a, int __b)
Definition: __clang_cuda_math.h:194
clang::ast_matchers::dynamic::internal::OverloadedMatcherDescriptor::getArgKinds
void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo, std::vector< ArgKind > &Kinds) const override
Given that the matcher is being converted to type ThisKind, append the set of argument types accepted...
Definition: Marshallers.h:776
llvm
Definition: Dominators.h:30
clang::ast_matchers::dynamic::internal::MapAnyOfMatcherDescriptor::getNumArgs
unsigned getNumArgs() const override
Returns the number of arguments accepted by the matcher if not variadic.
Definition: Marshallers.h:979
clang::ast_matchers::dynamic::internal::ArgTypeTraits< unsigned >::hasCorrectValue
static bool hasCorrectValue(const VariantValue &Value)
Definition: Marshallers.h:146
clang::ast_matchers::dynamic::internal::MapAnyOfMatcherDescriptor::MapAnyOfMatcherDescriptor
MapAnyOfMatcherDescriptor(ASTNodeKind CladeNodeKind, std::vector< ASTNodeKind > NodeKinds)
Definition: Marshallers.h:937
clang::ast_matchers::dynamic::internal::BuildReturnTypeVector< ast_matchers::internal::BindableMatcher< T > >::build
static void build(std::vector< ASTNodeKind > &RetTypes)
Definition: Marshallers.h:484
clang::ast_matchers::dynamic::internal::RegexMatcherDescriptor::RegexMatcherDescriptor
RegexMatcherDescriptor(ReturnType(*WithFlags)(StringRef, llvm::Regex::RegexFlags), ReturnType(*NoFlags)(StringRef), ArrayRef< ASTNodeKind > RetKinds)
Definition: Marshallers.h:800
clang::ast_matchers::dynamic::internal::ArgTypeTraits< llvm::Regex::RegexFlags >::hasCorrectValue
static bool hasCorrectValue(const VariantValue &Value)
Definition: Marshallers.h:229
CHECK_ARG_COUNT
#define CHECK_ARG_COUNT(count)
Helper macros to check the arguments on all marshaller functions.
Definition: Marshallers.h:622
clang::ast_matchers::dynamic::internal::ArgTypeTraits< OpenMPClauseKind >::get
static OpenMPClauseKind get(const VariantValue &Value)
Definition: Marshallers.h:260
clang::ast_matchers::dynamic::internal::ArgTypeTraits
Helper template class to just from argument type to the right is/get functions in VariantValue.
Definition: Marshallers.h:56
Error
llvm::Error Error
Definition: ByteCodeEmitter.cpp:19
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::ast_matchers::dynamic::internal::ArgTypeTraits< std::string >::getBestGuess
static llvm::Optional< std::string > getBestGuess(const VariantValue &)
Definition: Marshallers.h:74
clang::ast_matchers::dynamic::internal::VariadicOperatorMatcherDescriptor::isConvertibleTo
bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity, ASTNodeKind *LeastDerivedKind) const override
Returns whether this matcher is convertible to the given type.
Definition: Marshallers.h:914
clang::ast_matchers::dynamic::Diagnostics::OverloadContext::revertErrors
void revertErrors()
Revert all errors that happened within this context.
Definition: Diagnostics.cpp:55
clang::ast_matchers::dynamic::internal::ArgTypeTraits< attr::Kind >::hasCorrectValue
static bool hasCorrectValue(const VariantValue &Value)
Definition: Marshallers.h:176
clang::ast_matchers::dynamic::internal::ArgTypeTraits< CastKind >::hasCorrectType
static bool hasCorrectType(const VariantValue &Value)
Definition: Marshallers.h:203
clang::ast_matchers::dynamic::internal::ArgTypeTraits< llvm::Regex::RegexFlags >::getKind
static ArgKind getKind()
Definition: Marshallers.h:237
clang::ast_matchers::dynamic::internal::ArgTypeTraits< ast_matchers::internal::Matcher< T > >::get
static ast_matchers::internal::Matcher< T > get(const VariantValue &Value)
Definition: Marshallers.h:91
llvm::SmallVector
Definition: LLVM.h:38
GEN_CLANG_CLAUSE_CLASS
#define GEN_CLANG_CLAUSE_CLASS
clang::ast_matchers::dynamic::internal::DynCastAllOfMatcherDescriptor::isConvertibleTo
bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity, ASTNodeKind *LeastDerivedKind) const override
Returns whether this matcher is convertible to the given type.
Definition: Marshallers.h:597
clang::ast_matchers::dynamic::internal::OverloadedMatcherDescriptor::create
VariantMatcher create(SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const override
Definition: Marshallers.h:733
clang::ast_matchers::dynamic::internal::VariadicFuncMatcherDescriptor::isConvertibleTo
bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity, ASTNodeKind *LeastDerivedKind) const override
Returns whether this matcher is convertible to the given type.
Definition: Marshallers.h:572
clang::ast_matchers::dynamic::internal::ArgTypeTraits< bool >::getBestGuess
static llvm::Optional< std::string > getBestGuess(const VariantValue &)
Definition: Marshallers.h:118
clang::ast_matchers::dynamic::internal::ArgTypeTraits< ast_matchers::internal::Matcher< T > >::getKind
static ArgKind getKind()
Definition: Marshallers.h:95
clang::ast_matchers::dynamic::VariantMatcher::hasTypedMatcher
bool hasTypedMatcher() const
Determines if the contained matcher can be converted to Matcher<T>.
Definition: VariantValue.h:185
clang::ast_matchers::dynamic::internal::ArgTypeTraits< bool >::hasCorrectValue
static bool hasCorrectValue(const VariantValue &Value)
Definition: Marshallers.h:108
clang::ast_matchers::dynamic::internal::MapAnyOfBuilderDescriptor::buildMatcherCtor
std::unique_ptr< MatcherDescriptor > buildMatcherCtor(SourceRange, ArrayRef< ParserValue > Args, Diagnostics *) const override
Definition: Marshallers.h:1006
clang::ast_matchers::dynamic::internal::VariadicFuncMatcherDescriptor::create
VariantMatcher create(SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const override
Definition: Marshallers.h:558
clang::ast_matchers::dynamic::internal::OverloadedMatcherDescriptor
MatcherDescriptor that wraps multiple "overloads" of the same matcher.
Definition: Marshallers.h:724
clang::ast_matchers::dynamic::internal::FixedArgCountMatcherDescriptor::isVariadic
bool isVariadic() const override
Returns whether the matcher is variadic.
Definition: Marshallers.h:400
clang::ast_matchers::dynamic::VariantMatcher::VariadicOperatorMatcher
static VariantMatcher VariadicOperatorMatcher(DynTypedMatcher::VariadicOperator Op, std::vector< VariantMatcher > Args)
Creates a 'variadic' operator matcher.
Definition: VariantValue.cpp:236
clang::ast_matchers::dynamic::internal::mergePolyMatchers
static void mergePolyMatchers(const PolyMatcher &Poly, std::vector< DynTypedMatcher > &Out, ast_matchers::internal::EmptyTypeList)
Helper methods to extract and merge all possible typed matchers out of the polymorphic object.
Definition: Marshallers.h:425
clang::ast_matchers::dynamic::internal::ArgTypeTraits< OpenMPClauseKind >::hasCorrectValue
static bool hasCorrectValue(const VariantValue &Value)
Definition: Marshallers.h:256
clang::ast_matchers::dynamic::internal::MapAnyOfMatcherDescriptor
Definition: Marshallers.h:932
clang::ast_matchers::dynamic::internal::OverloadedMatcherDescriptor::isVariadic
bool isVariadic() const override
Returns whether the matcher is variadic.
Definition: Marshallers.h:756
llvm::Optional< std::string >
clang::ast_matchers::dynamic::internal::VariadicOperatorMatcherDescriptor::isPolymorphic
bool isPolymorphic() const override
Returns whether the matcher will, given a matcher of any type T, yield a matcher of type T.
Definition: Marshallers.h:923
clang::ast_matchers::dynamic::internal::BuildReturnTypeVector::build
static void build(std::vector< ASTNodeKind > &RetTypes)
Definition: Marshallers.h:470
clang::ast_matchers::dynamic::internal::OverloadedMatcherDescriptor::isConvertibleTo
bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity, ASTNodeKind *LeastDerivedKind) const override
Returns whether this matcher is convertible to the given type.
Definition: Marshallers.h:784
clang::ast_matchers::dynamic::internal::MatcherDescriptor::getNumArgs
virtual unsigned getNumArgs() const =0
Returns the number of arguments accepted by the matcher if not variadic.
clang::tooling::X
static ToolExecutorPluginRegistry::Add< AllTUsToolExecutorPlugin > X("all-TUs", "Runs FrontendActions on all TUs in the compilation database. " "Tool results are stored in memory.")
clang::ast_matchers::dynamic::internal::VariadicOperatorMatcherDescriptor::VarOp
DynTypedMatcher::VariadicOperator VarOp
Definition: Marshallers.h:872
clang::ast_matchers::dynamic::internal::MapAnyOfMatcherDescriptor::create
VariantMatcher create(SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const override
Definition: Marshallers.h:941
clang::ast_matchers::dynamic::internal::makeMatcherRegexMarshall
std::unique_ptr< MatcherDescriptor > makeMatcherRegexMarshall(ReturnType(*FuncFlags)(llvm::StringRef, llvm::Regex::RegexFlags), ReturnType(*Func)(llvm::StringRef))
Definition: Marshallers.h:1093
clang::ast_matchers::dynamic::internal::MatcherDescriptor::getArgKinds
virtual void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo, std::vector< ArgKind > &ArgKinds) const =0
Given that the matcher is being converted to type ThisKind, append the set of argument types accepted...
clang::ast_matchers::dynamic::internal::ArgTypeTraits< OpenMPClauseKind >::hasCorrectType
static bool hasCorrectType(const VariantValue &Value)
Definition: Marshallers.h:253
clang::ast_matchers::dynamic::internal::MatcherDescriptor::nodeMatcherType
virtual ASTNodeKind nodeMatcherType() const
Definition: Marshallers.h:312
clang::ast_matchers::dynamic::internal::RegexMatcherDescriptor::getArgKinds
void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo, std::vector< ArgKind > &Kinds) const override
Given that the matcher is being converted to type ThisKind, append the set of argument types accepted...
Definition: Marshallers.h:809
clang::ast_matchers::dynamic::internal::VariadicOperatorMatcherDescriptor::getArgKinds
void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo, std::vector< ArgKind > &Kinds) const override
Given that the matcher is being converted to type ThisKind, append the set of argument types accepted...
Definition: Marshallers.h:909
clang::ast_matchers::dynamic::internal::matcherMarshall2
static VariantMatcher matcherMarshall2(void(*Func)(), StringRef MatcherName, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error)
2-arg marshaller function.
Definition: Marshallers.h:675
clang::ast_matchers::dynamic::internal::ArgTypeTraits< double >::getBestGuess
static llvm::Optional< std::string > getBestGuess(const VariantValue &)
Definition: Marshallers.h:137
clang::ast_matchers::dynamic::internal::FixedArgCountMatcherDescriptor::getNumArgs
unsigned getNumArgs() const override
Returns the number of arguments accepted by the matcher if not variadic.
Definition: Marshallers.h:401
clang::ast_matchers::dynamic::internal::ArgTypeTraits< ast_matchers::internal::Matcher< T > >::hasCorrectValue
static bool hasCorrectValue(const VariantValue &Value)
Definition: Marshallers.h:87
CAST_OPERATION
#define CAST_OPERATION(Name)
llvm::MutableArrayRef
Definition: LLVM.h:35
clang::ast_matchers::dynamic::internal::ArgTypeTraits< double >::hasCorrectType
static bool hasCorrectType(const VariantValue &Value)
Definition: Marshallers.h:124
clang::ast_matchers::dynamic::internal::ArgTypeTraits< std::string >::hasCorrectType
static bool hasCorrectType(const VariantValue &Value)
Definition: Marshallers.h:61
clang::ast_matchers::dynamic::internal::FixedArgCountMatcherDescriptor::MarshallerType
VariantMatcher(*)(void(*Func)(), StringRef MatcherName, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) MarshallerType
Definition: Marshallers.h:378
clang::ast_matchers::dynamic::internal::ArgTypeTraits< unsigned >::getKind
static ArgKind getKind()
Definition: Marshallers.h:152
clang::ast_matchers::dynamic::internal::ArgTypeTraits< OpenMPClauseKind >::getKind
static ArgKind getKind()
Definition: Marshallers.h:264
clang::ast_matchers::dynamic::ParserValue::Range
SourceRange Range
Definition: Diagnostics.h:45
clang::ast_matchers::dynamic::internal::VariadicFuncMatcherDescriptor::nodeMatcherType
ASTNodeKind nodeMatcherType() const override
Definition: Marshallers.h:578
clang::ast_matchers::dynamic::internal::matcherMarshall0
static VariantMatcher matcherMarshall0(void(*Func)(), StringRef MatcherName, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error)
0-arg marshaller function.
Definition: Marshallers.h:651
clang::ast_matchers::dynamic::internal::MapAnyOfMatcherDescriptor::isConvertibleTo
bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity, ASTNodeKind *LeastDerivedKind) const override
Returns whether this matcher is convertible to the given type.
Definition: Marshallers.h:986
clang::ast_matchers::dynamic::internal::MapAnyOfBuilderDescriptor::create
VariantMatcher create(SourceRange, ArrayRef< ParserValue >, Diagnostics *) const override
Definition: Marshallers.h:998
clang::ast_matchers::dynamic::internal::FixedArgCountMatcherDescriptor
Simple callback implementation.
Definition: Marshallers.h:372
clang::ast_matchers::dynamic::internal::ArgTypeTraits< ast_matchers::internal::Matcher< T > >::hasCorrectType
static bool hasCorrectType(const VariantValue &Value)
Definition: Marshallers.h:84
TypeTraits.h
clang::ast_matchers::dynamic::internal::ArgTypeTraits< CastKind >::hasCorrectValue
static bool hasCorrectValue(const VariantValue &Value)
Definition: Marshallers.h:206
clang::ast_matchers::dynamic::internal::ArgTypeTraits< std::string >::hasCorrectValue
static bool hasCorrectValue(const VariantValue &Value)
Definition: Marshallers.h:64
OpenMPKinds.h
clang::ast_matchers::dynamic::internal::ArgTypeTraits< UnaryExprOrTypeTrait >::get
static UnaryExprOrTypeTrait get(const VariantValue &Value)
Definition: Marshallers.h:291
clang::ast_matchers::dynamic::internal::AdaptativeOverloadCollector
Helper class used to collect all the possible overloads of an argument adaptative matcher function.
Definition: Marshallers.h:695
clang::ast_matchers::dynamic::internal::ArgTypeTraits< double >::get
static double get(const VariantValue &Value)
Definition: Marshallers.h:129
VariantValue.h
clang::ast_matchers::dynamic::internal::ArgTypeTraits< unsigned >::getBestGuess
static llvm::Optional< std::string > getBestGuess(const VariantValue &)
Definition: Marshallers.h:156
clang::OpenMPClauseKind
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
Definition: OpenMPKinds.h:26
bool
#define bool
Definition: stdbool.h:15
clang::ast_matchers::dynamic::internal::OverloadedMatcherDescriptor::OverloadedMatcherDescriptor
OverloadedMatcherDescriptor(MutableArrayRef< std::unique_ptr< MatcherDescriptor >> Callbacks)
Definition: Marshallers.h:726
clang::ast_matchers::dynamic::internal::RegexMatcherDescriptor::isVariadic
bool isVariadic() const override
Returns whether the matcher is variadic.
Definition: Marshallers.h:806
ASTMatchersInternal.h
clang::ast_matchers::dynamic::internal::RegexMatcherDescriptor::isConvertibleTo
bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity, ASTNodeKind *LeastDerivedKind) const override
Returns whether this matcher is convertible to the given type.
Definition: Marshallers.h:815
OperationKinds.h
clang::ast_matchers::dynamic::internal::MapAnyOfMatcherDescriptor::isVariadic
bool isVariadic() const override
Returns whether the matcher is variadic.
Definition: Marshallers.h:978
clang::ast_matchers::dynamic::internal::ArgTypeTraits< llvm::Regex::RegexFlags >::get
static llvm::Regex::RegexFlags get(const VariantValue &Value)
Definition: Marshallers.h:233
clang::ast_matchers::dynamic::internal::VariadicFuncMatcherDescriptor::getNumArgs
unsigned getNumArgs() const override
Returns the number of arguments accepted by the matcher if not variadic.
Definition: Marshallers.h:565
clang::ast_matchers::dynamic::internal::ArgTypeTraits< bool >::hasCorrectType
static bool hasCorrectType(const VariantValue &Value)
Definition: Marshallers.h:105
clang::ast_matchers::dynamic::internal::matcherMarshall1
static VariantMatcher matcherMarshall1(void(*Func)(), StringRef MatcherName, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error)
1-arg marshaller function.
Definition: Marshallers.h:662
double
__device__ double
Definition: __clang_hip_libdevice_declares.h:165
clang::ast_matchers::dynamic::internal::VariadicFuncMatcherDescriptor::VariadicFuncMatcherDescriptor
VariadicFuncMatcherDescriptor(ast_matchers::internal::VariadicFunction< ResultT, ArgT, F > Func, StringRef MatcherName)
Definition: Marshallers.h:549
getKind
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:994
clang::ast_matchers::dynamic::internal::MatcherDescriptor::isConvertibleTo
virtual bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity=nullptr, ASTNodeKind *LeastDerivedKind=nullptr) const =0
Returns whether this matcher is convertible to the given type.
clang::ast_matchers::dynamic::internal::FixedArgCountMatcherDescriptor::create
VariantMatcher create(SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const override
Definition: Marshallers.h:394
clang::ast_matchers::dynamic::internal::ArgTypeTraits< double >::getKind
static ArgKind getKind()
Definition: Marshallers.h:133
Diagnostics.h
clang::ast_matchers::dynamic::internal::ArgTypeTraits< unsigned >::get
static unsigned get(const VariantValue &Value)
Definition: Marshallers.h:148
clang::ast_matchers::dynamic::internal::ArgTypeTraits< std::string >::getKind
static ArgKind getKind()
Definition: Marshallers.h:70
clang::ast_matchers::dynamic::internal::ArgTypeTraits< attr::Kind >::getKind
static ArgKind getKind()
Definition: Marshallers.h:184
clang::ast_matchers::dynamic::ArgKind::AK_Double
@ AK_Double
Definition: VariantValue.h:40
clang::ast_matchers::dynamic::internal::variadicMatcherDescriptor
VariantMatcher variadicMatcherDescriptor(StringRef MatcherName, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error)
Variadic marshaller function.
Definition: Marshallers.h:493
clang::ast_matchers::dynamic::internal::RegexMatcherDescriptor
Definition: Marshallers.h:798
clang::ast_matchers::dynamic::internal::VariadicOperatorMatcherDescriptor::getNumArgs
unsigned getNumArgs() const override
Returns the number of arguments accepted by the matcher if not variadic.
Definition: Marshallers.h:907
clang::ast_matchers::dynamic::Diagnostics::ET_RegistryWrongArgCount
@ ET_RegistryWrongArgCount
Definition: Diagnostics.h:63
clang::ast_matchers::dynamic::internal::outvalueToVariantMatcher
VariantMatcher outvalueToVariantMatcher(const DynTypedMatcher &Matcher)
Convert the return values of the functions into a VariantMatcher.
Definition: Marshallers.h:442
clang::ast_matchers::dynamic::ArgKind
Kind identifier.
Definition: VariantValue.h:34
clang::attr::Kind
Kind
Definition: AttrKinds.h:22
clang::ast_matchers::dynamic::internal::MapAnyOfBuilderDescriptor
Definition: Marshallers.h:996
clang::ast_matchers::dynamic::internal::MatcherDescriptor::buildMatcherCtor
virtual std::unique_ptr< MatcherDescriptor > buildMatcherCtor(SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const
Definition: Marshallers.h:317
clang::ast_matchers::dynamic::VariantMatcher
A variant matcher object.
Definition: VariantValue.h:105
llvm::ArrayRef
Definition: LLVM.h:34
clang::ast_matchers::dynamic::internal::ArgTypeTraits< bool >::get
static bool get(const VariantValue &Value)
Definition: Marshallers.h:110
clang::ast_matchers::dynamic::internal::ArgTypeTraits< unsigned >::hasCorrectType
static bool hasCorrectType(const VariantValue &Value)
Definition: Marshallers.h:143
Value
Value
Definition: UninitializedValues.cpp:102
clang::ast_matchers::dynamic::internal::isRetKindConvertibleTo
bool isRetKindConvertibleTo(ArrayRef< ASTNodeKind > RetKinds, ASTNodeKind Kind, unsigned *Specificity, ASTNodeKind *LeastDerivedKind)
Definition: Marshallers.h:352
clang::ast_matchers::dynamic::internal::DynCastAllOfMatcherDescriptor::DynCastAllOfMatcherDescriptor
DynCastAllOfMatcherDescriptor(ast_matchers::internal::VariadicDynCastAllOfMatcher< BaseT, DerivedT > Func, StringRef MatcherName)
Definition: Marshallers.h:591
clang::ast_matchers::dynamic::ParserValue::Value
VariantValue Value
Definition: Diagnostics.h:46
clang::ast_matchers::dynamic::internal::DynCastAllOfMatcherDescriptor::nodeMatcherType
ASTNodeKind nodeMatcherType() const override
Definition: Marshallers.h:615
clang::ast_matchers::dynamic::internal::ArgTypeTraits< UnaryExprOrTypeTrait >::hasCorrectType
static bool hasCorrectType(const VariantValue &Value)
Definition: Marshallers.h:284
clang::ast_matchers::dynamic::internal::MatcherDescriptor
Matcher descriptor interface.
Definition: Marshallers.h:304
LLVM.h
clang::ast_matchers::dynamic::SourceRange
Definition: Diagnostics.h:36
clang::ast_matchers::dynamic::internal::ArgTypeTraits< UnaryExprOrTypeTrait >::getKind
static ArgKind getKind()
Definition: Marshallers.h:295
clang::ast_matchers::dynamic::internal::ArgTypeTraits< CastKind >::get
static CastKind get(const VariantValue &Value)
Definition: Marshallers.h:210
clang::ast_matchers::dynamic::internal::BuildReturnTypeVector
Definition: Marshallers.h:469
UNARY_EXPR_OR_TYPE_TRAIT
#define UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key)
clang::ast_matchers::dynamic::internal::MatcherDescriptor::~MatcherDescriptor
virtual ~MatcherDescriptor()=default
clang::ast_matchers::dynamic::internal::ArgTypeTraits< UnaryExprOrTypeTrait >::hasCorrectValue
static bool hasCorrectValue(const VariantValue &Value)
Definition: Marshallers.h:287
clang::ast_matchers::dynamic::VariantValue
Variant value class.
Definition: VariantValue.h:254
clang::ast_matchers::dynamic::ArgKind::AK_Unsigned
@ AK_Unsigned
Definition: VariantValue.h:41
ASTTypeTraits.h
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::ast_matchers::dynamic::VariantMatcher::PolymorphicMatcher
static VariantMatcher PolymorphicMatcher(std::vector< DynTypedMatcher > Matchers)
Clones the provided matchers.
Definition: VariantValue.cpp:231
clang::ast_matchers::dynamic::internal::ArgTypeTraits< CastKind >::getKind
static ArgKind getKind()
Definition: Marshallers.h:214
std
Definition: Format.h:3679
clang::ASTNodeKind
Kind identifier.
Definition: ASTTypeTraits.h:52
clang::ast_matchers::dynamic::internal::MapAnyOfBuilderDescriptor::getNumArgs
unsigned getNumArgs() const override
Returns the number of arguments accepted by the matcher if not variadic.
Definition: Marshallers.h:1033
clang::ast_matchers::dynamic::internal::buildReturnTypeVectorFromTypeList
void buildReturnTypeVectorFromTypeList(std::vector< ASTNodeKind > &RetTypes)
Definition: Marshallers.h:458
clang::ast_matchers::dynamic::VariantMatcher::getTypedMatcher
ast_matchers::internal::Matcher< T > getTypedMatcher() const
Return this matcher as a Matcher<T>.
Definition: VariantValue.h:211
clang::ast_matchers::dynamic::internal::VariadicFuncMatcherDescriptor::isVariadic
bool isVariadic() const override
Returns whether the matcher is variadic.
Definition: Marshallers.h:564
clang::ast_matchers::dynamic::internal::FixedArgCountMatcherDescriptor::getArgKinds
void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo, std::vector< ArgKind > &Kinds) const override
Given that the matcher is being converted to type ThisKind, append the set of argument types accepted...
Definition: Marshallers.h:403
clang::ast_matchers::dynamic::internal::VariadicOperatorMatcherDescriptor
Variadic operator marshaller function.
Definition: Marshallers.h:870
clang::ast_matchers::dynamic::Diagnostics
Helper class to manage error messages.
Definition: Diagnostics.h:50
clang::ast_matchers::dynamic::internal::MatcherDescriptor::isPolymorphic
virtual bool isPolymorphic() const
Returns whether the matcher will, given a matcher of any type T, yield a matcher of type T.
Definition: Marshallers.h:349
clang::ast_matchers::dynamic::internal::MapAnyOfBuilderDescriptor::isVariadic
bool isVariadic() const override
Returns whether the matcher is variadic.
Definition: Marshallers.h:1031
clang::ast_matchers::dynamic::internal::DynCastAllOfMatcherDescriptor
Return CK_Trivial when appropriate for VariadicDynCastAllOfMatchers.
Definition: Marshallers.h:588
clang
Definition: CalledOnceCheck.h:17
clang::syntax::NodeKind
NodeKind
A kind of a syntax node, used for implementing casts.
Definition: Nodes.h:37
clang::ast_matchers::dynamic::internal::VariadicFuncMatcherDescriptor::getArgKinds
void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo, std::vector< ArgKind > &Kinds) const override
Given that the matcher is being converted to type ThisKind, append the set of argument types accepted...
Definition: Marshallers.h:567
clang::ast_matchers::dynamic::internal::MatcherDescriptor::create
virtual VariantMatcher create(SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const =0
clang::ast_matchers::dynamic::internal::VariadicFuncMatcherDescriptor
Matcher descriptor for variadic functions.
Definition: Marshallers.h:540
clang::ast_matchers::dynamic::internal::VariadicOperatorMatcherDescriptor::create
VariantMatcher create(SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const override
Definition: Marshallers.h:879
clang::ast_matchers::dynamic::internal::OverloadedMatcherDescriptor::getNumArgs
unsigned getNumArgs() const override
Returns the number of arguments accepted by the matcher if not variadic.
Definition: Marshallers.h:766
clang::ast_matchers::dynamic::internal::RegexMatcherDescriptor::getNumArgs
unsigned getNumArgs() const override
Returns the number of arguments accepted by the matcher if not variadic.
Definition: Marshallers.h:807
clang::ast_matchers::dynamic::internal::MapAnyOfBuilderDescriptor::isBuilderMatcher
bool isBuilderMatcher() const override
Definition: Marshallers.h:1003
clang::ast_matchers::dynamic::internal::ArgTypeTraits< attr::Kind >::hasCorrectType
static bool hasCorrectType(const VariantValue &Value)
Definition: Marshallers.h:173
ATTR
#define ATTR(X)
unsigned
clang::ast_matchers::dynamic::internal::RegexMatcherDescriptor::create
VariantMatcher create(SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const override
Definition: Marshallers.h:821
clang::ast_matchers::dynamic::Diagnostics::OverloadContext
Context for overloaded matcher construction.
Definition: Diagnostics.h:126
clang::ast_matchers::dynamic::internal::FixedArgCountMatcherDescriptor::isConvertibleTo
bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity, ASTNodeKind *LeastDerivedKind) const override
Returns whether this matcher is convertible to the given type.
Definition: Marshallers.h:408
clang::ast_matchers::dynamic::ArgKind::MakeNodeArg
static ArgKind MakeNodeArg(ASTNodeKind MatcherKind)
Definition: VariantValue.h:52
clang::ast_matchers::dynamic::VariantMatcher::SingleMatcher
static VariantMatcher SingleMatcher(const DynTypedMatcher &Matcher)
Clones the provided matcher.
Definition: VariantValue.cpp:226
clang::ast_matchers::dynamic::internal::OverloadedMatcherDescriptor::~OverloadedMatcherDescriptor
~OverloadedMatcherDescriptor() override=default
clang::ast_matchers::dynamic::internal::ArgTypeTraits< double >::hasCorrectValue
static bool hasCorrectValue(const VariantValue &Value)
Definition: Marshallers.h:127
clang::ast_matchers::dynamic::internal::VariadicOperatorMatcherDescriptor::isVariadic
bool isVariadic() const override
Returns whether the matcher is variadic.
Definition: Marshallers.h:906
clang::ast_matchers::dynamic::internal::MapAnyOfBuilderDescriptor::isPolymorphic
bool isPolymorphic() const override
Returns whether the matcher will, given a matcher of any type T, yield a matcher of type T.
Definition: Marshallers.h:1049
clang::ast_matchers::dynamic::internal::ArgTypeTraits< ast_matchers::internal::Matcher< T > >::getBestGuess
static llvm::Optional< std::string > getBestGuess(const VariantValue &)
Definition: Marshallers.h:99
clang::ast_matchers::dynamic::ArgKind::MakeMatcherArg
static ArgKind MakeMatcherArg(ASTNodeKind MatcherKind)
Constructor for matcher types.
Definition: VariantValue.h:48
AttrKinds.h
clang::CastKind
CastKind
CastKind - The kind of operation required for a conversion.
Definition: OperationKinds.h:20
clang::ast_matchers::dynamic::internal::MatcherDescriptor::isVariadic
virtual bool isVariadic() const =0
Returns whether the matcher is variadic.
clang::ast_matchers::dynamic::ArgKind::AK_Boolean
@ AK_Boolean
Definition: VariantValue.h:39
clang::ast_matchers::dynamic::internal::BuildReturnTypeVector< ast_matchers::internal::Matcher< T > >::build
static void build(std::vector< ASTNodeKind > &RetTypes)
Definition: Marshallers.h:477
clang::ast_matchers::dynamic::internal::ArgTypeTraits< attr::Kind >::get
static attr::Kind get(const VariantValue &Value)
Definition: Marshallers.h:180
CLAUSE_CLASS
#define CLAUSE_CLASS(Enum, Str, Class)
clang::ast_matchers::dynamic::internal::MapAnyOfBuilderDescriptor::getArgKinds
void getArgKinds(ASTNodeKind ThisKind, unsigned, std::vector< ArgKind > &ArgKinds) const override
Given that the matcher is being converted to type ThisKind, append the set of argument types accepted...
Definition: Marshallers.h:1035
clang::ast_matchers::dynamic::internal::ArgTypeTraits< std::string >::get
static const std::string & get(const VariantValue &Value)
Definition: Marshallers.h:66
clang::ast_matchers::dynamic::internal::FixedArgCountMatcherDescriptor::FixedArgCountMatcherDescriptor
FixedArgCountMatcherDescriptor(MarshallerType Marshaller, void(*Func)(), StringRef MatcherName, ArrayRef< ASTNodeKind > RetKinds, ArrayRef< ArgKind > ArgKinds)
Definition: Marshallers.h:386
clang::ASTNodeKind::getCladeKind
ASTNodeKind getCladeKind() const
Definition: ASTTypeTraits.cpp:66
clang::ast_matchers::dynamic::internal::ArgTypeTraits< bool >::getKind
static ArgKind getKind()
Definition: Marshallers.h:114
clang::ast_matchers::dynamic::internal::VariadicFuncMatcherDescriptor::RunFunc
VariantMatcher(*)(StringRef MatcherName, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) RunFunc
Definition: Marshallers.h:545
clang::ast_matchers::dynamic::internal::MapAnyOfBuilderDescriptor::isConvertibleTo
bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity=nullptr, ASTNodeKind *LeastDerivedKind=nullptr) const override
Returns whether this matcher is convertible to the given type.
Definition: Marshallers.h:1040
CHECK_ARG_TYPE
#define CHECK_ARG_TYPE(index, type)
Definition: Marshallers.h:629
getBestGuess
static llvm::Optional< std::string > getBestGuess(llvm::StringRef Search, llvm::ArrayRef< llvm::StringRef > Allowed, llvm::StringRef DropPrefix="", unsigned MaxEditDistance=3)
Definition: Marshallers.cpp:17
clang::ast_matchers::dynamic::ArgKind::AK_String
@ AK_String
Definition: VariantValue.h:42
clang::ast_matchers::dynamic::internal::ArgTypeTraits< llvm::Regex::RegexFlags >::hasCorrectType
static bool hasCorrectType(const VariantValue &Value)
Definition: Marshallers.h:226
clang::ast_matchers::dynamic::internal::VariadicOperatorMatcherDescriptor::VariadicOperatorMatcherDescriptor
VariadicOperatorMatcherDescriptor(unsigned MinCount, unsigned MaxCount, VarOp Op, StringRef MatcherName)
Definition: Marshallers.h:874
clang::UnaryExprOrTypeTrait
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition: TypeTraits.h:51
clang::ast_matchers::dynamic::internal::AdaptativeOverloadCollector::AdaptativeOverloadCollector
AdaptativeOverloadCollector(StringRef Name, std::vector< std::unique_ptr< MatcherDescriptor >> &Out)
Definition: Marshallers.h:697
clang::ast_matchers::dynamic::internal::MapAnyOfMatcherDescriptor::getArgKinds
void getArgKinds(ASTNodeKind ThisKind, unsigned, std::vector< ArgKind > &Kinds) const override
Given that the matcher is being converted to type ThisKind, append the set of argument types accepted...
Definition: Marshallers.h:981