clang  16.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()).has_value();
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()).has_value();
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()).has_value();
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()).has_value();
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()).has_value();
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  assert(InnerArgs.size() < InnerArgs.capacity());
528  InnerArgs.emplace_back(ArgTraits::get(Value));
529  InnerArgsPtr[i] = &InnerArgs[i];
530  }
531  return outvalueToVariantMatcher(Func(InnerArgsPtr));
532 }
533 
534 /// Matcher descriptor for variadic functions.
535 ///
536 /// This class simply wraps a VariadicFunction with the right signature to export
537 /// it as a MatcherDescriptor.
538 /// This allows us to have one implementation of the interface for as many free
539 /// functions as we want, reducing the number of symbols and size of the
540 /// object file.
542 public:
543  using RunFunc = VariantMatcher (*)(StringRef MatcherName,
544  SourceRange NameRange,
547 
548  template <typename ResultT, typename ArgT,
549  ResultT (*F)(ArrayRef<const ArgT *>)>
551  ast_matchers::internal::VariadicFunction<ResultT, ArgT, F> Func,
552  StringRef MatcherName)
553  : Func(&variadicMatcherDescriptor<ResultT, ArgT, F>),
554  MatcherName(MatcherName.str()),
555  ArgsKind(ArgTypeTraits<ArgT>::getKind()) {
557  }
558 
561  Diagnostics *Error) const override {
562  return Func(MatcherName, NameRange, Args, Error);
563  }
564 
565  bool isVariadic() const override { return true; }
566  unsigned getNumArgs() const override { return 0; }
567 
568  void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo,
569  std::vector<ArgKind> &Kinds) const override {
570  Kinds.push_back(ArgsKind);
571  }
572 
573  bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity,
574  ASTNodeKind *LeastDerivedKind) const override {
575  return isRetKindConvertibleTo(RetKinds, Kind, Specificity,
576  LeastDerivedKind);
577  }
578 
579  ASTNodeKind nodeMatcherType() const override { return RetKinds[0]; }
580 
581 private:
582  const RunFunc Func;
583  const std::string MatcherName;
584  std::vector<ASTNodeKind> RetKinds;
585  const ArgKind ArgsKind;
586 };
587 
588 /// Return CK_Trivial when appropriate for VariadicDynCastAllOfMatchers.
590 public:
591  template <typename BaseT, typename DerivedT>
593  ast_matchers::internal::VariadicDynCastAllOfMatcher<BaseT, DerivedT> Func,
594  StringRef MatcherName)
595  : VariadicFuncMatcherDescriptor(Func, MatcherName),
596  DerivedKind(ASTNodeKind::getFromNodeKind<DerivedT>()) {}
597 
598  bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity,
599  ASTNodeKind *LeastDerivedKind) const override {
600  // If Kind is not a base of DerivedKind, either DerivedKind is a base of
601  // Kind (in which case the match will always succeed) or Kind and
602  // DerivedKind are unrelated (in which case it will always fail), so set
603  // Specificity to 0.
605  LeastDerivedKind)) {
606  if (Kind.isSame(DerivedKind) || !Kind.isBaseOf(DerivedKind)) {
607  if (Specificity)
608  *Specificity = 0;
609  }
610  return true;
611  } else {
612  return false;
613  }
614  }
615 
616  ASTNodeKind nodeMatcherType() const override { return DerivedKind; }
617 
618 private:
619  const ASTNodeKind DerivedKind;
620 };
621 
622 /// Helper macros to check the arguments on all marshaller functions.
623 #define CHECK_ARG_COUNT(count) \
624  if (Args.size() != count) { \
625  Error->addError(NameRange, Error->ET_RegistryWrongArgCount) \
626  << count << Args.size(); \
627  return VariantMatcher(); \
628  }
629 
630 #define CHECK_ARG_TYPE(index, type) \
631  if (!ArgTypeTraits<type>::hasCorrectType(Args[index].Value)) { \
632  Error->addError(Args[index].Range, Error->ET_RegistryWrongArgType) \
633  << (index + 1) << ArgTypeTraits<type>::getKind().asString() \
634  << Args[index].Value.getTypeAsString(); \
635  return VariantMatcher(); \
636  } \
637  if (!ArgTypeTraits<type>::hasCorrectValue(Args[index].Value)) { \
638  if (llvm::Optional<std::string> BestGuess = \
639  ArgTypeTraits<type>::getBestGuess(Args[index].Value)) { \
640  Error->addError(Args[index].Range, \
641  Error->ET_RegistryUnknownEnumWithReplace) \
642  << index + 1 << Args[index].Value.getString() << *BestGuess; \
643  } else if (Args[index].Value.isString()) { \
644  Error->addError(Args[index].Range, Error->ET_RegistryValueNotFound) \
645  << Args[index].Value.getString(); \
646  } \
647  return VariantMatcher(); \
648  }
649 
650 /// 0-arg marshaller function.
651 template <typename ReturnType>
652 static VariantMatcher matcherMarshall0(void (*Func)(), StringRef MatcherName,
653  SourceRange NameRange,
655  Diagnostics *Error) {
656  using FuncType = ReturnType (*)();
657  CHECK_ARG_COUNT(0);
658  return outvalueToVariantMatcher(reinterpret_cast<FuncType>(Func)());
659 }
660 
661 /// 1-arg marshaller function.
662 template <typename ReturnType, typename ArgType1>
663 static VariantMatcher matcherMarshall1(void (*Func)(), StringRef MatcherName,
664  SourceRange NameRange,
666  Diagnostics *Error) {
667  using FuncType = ReturnType (*)(ArgType1);
668  CHECK_ARG_COUNT(1);
669  CHECK_ARG_TYPE(0, ArgType1);
670  return outvalueToVariantMatcher(reinterpret_cast<FuncType>(Func)(
672 }
673 
674 /// 2-arg marshaller function.
675 template <typename ReturnType, typename ArgType1, typename ArgType2>
676 static VariantMatcher matcherMarshall2(void (*Func)(), StringRef MatcherName,
677  SourceRange NameRange,
679  Diagnostics *Error) {
680  using FuncType = ReturnType (*)(ArgType1, ArgType2);
681  CHECK_ARG_COUNT(2);
682  CHECK_ARG_TYPE(0, ArgType1);
683  CHECK_ARG_TYPE(1, ArgType2);
684  return outvalueToVariantMatcher(reinterpret_cast<FuncType>(Func)(
687 }
688 
689 #undef CHECK_ARG_COUNT
690 #undef CHECK_ARG_TYPE
691 
692 /// Helper class used to collect all the possible overloads of an
693 /// argument adaptative matcher function.
694 template <template <typename ToArg, typename FromArg> class ArgumentAdapterT,
695  typename FromTypes, typename ToTypes>
697 public:
699  StringRef Name, std::vector<std::unique_ptr<MatcherDescriptor>> &Out)
700  : Name(Name), Out(Out) {
701  collect(FromTypes());
702  }
703 
704 private:
705  using AdaptativeFunc = ast_matchers::internal::ArgumentAdaptingMatcherFunc<
706  ArgumentAdapterT, FromTypes, ToTypes>;
707 
708  /// End case for the recursion
709  static void collect(ast_matchers::internal::EmptyTypeList) {}
710 
711  /// Recursive case. Get the overload for the head of the list, and
712  /// recurse to the tail.
713  template <typename FromTypeList>
714  inline void collect(FromTypeList);
715 
716  StringRef Name;
717  std::vector<std::unique_ptr<MatcherDescriptor>> &Out;
718 };
719 
720 /// MatcherDescriptor that wraps multiple "overloads" of the same
721 /// matcher.
722 ///
723 /// It will try every overload and generate appropriate errors for when none or
724 /// more than one overloads match the arguments.
726 public:
728  MutableArrayRef<std::unique_ptr<MatcherDescriptor>> Callbacks)
729  : Overloads(std::make_move_iterator(Callbacks.begin()),
730  std::make_move_iterator(Callbacks.end())) {}
731 
732  ~OverloadedMatcherDescriptor() override = default;
733 
736  Diagnostics *Error) const override {
737  std::vector<VariantMatcher> Constructed;
739  for (const auto &O : Overloads) {
740  VariantMatcher SubMatcher = O->create(NameRange, Args, Error);
741  if (!SubMatcher.isNull()) {
742  Constructed.push_back(SubMatcher);
743  }
744  }
745 
746  if (Constructed.empty()) return VariantMatcher(); // No overload matched.
747  // We ignore the errors if any matcher succeeded.
748  Ctx.revertErrors();
749  if (Constructed.size() > 1) {
750  // More than one constructed. It is ambiguous.
751  Error->addError(NameRange, Error->ET_RegistryAmbiguousOverload);
752  return VariantMatcher();
753  }
754  return Constructed[0];
755  }
756 
757  bool isVariadic() const override {
758  bool Overload0Variadic = Overloads[0]->isVariadic();
759 #ifndef NDEBUG
760  for (const auto &O : Overloads) {
761  assert(Overload0Variadic == O->isVariadic());
762  }
763 #endif
764  return Overload0Variadic;
765  }
766 
767  unsigned getNumArgs() const override {
768  unsigned Overload0NumArgs = Overloads[0]->getNumArgs();
769 #ifndef NDEBUG
770  for (const auto &O : Overloads) {
771  assert(Overload0NumArgs == O->getNumArgs());
772  }
773 #endif
774  return Overload0NumArgs;
775  }
776 
777  void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo,
778  std::vector<ArgKind> &Kinds) const override {
779  for (const auto &O : Overloads) {
780  if (O->isConvertibleTo(ThisKind))
781  O->getArgKinds(ThisKind, ArgNo, Kinds);
782  }
783  }
784 
785  bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity,
786  ASTNodeKind *LeastDerivedKind) const override {
787  for (const auto &O : Overloads) {
788  if (O->isConvertibleTo(Kind, Specificity, LeastDerivedKind))
789  return true;
790  }
791  return false;
792  }
793 
794 private:
795  std::vector<std::unique_ptr<MatcherDescriptor>> Overloads;
796 };
797 
798 template <typename ReturnType>
800 public:
801  RegexMatcherDescriptor(ReturnType (*WithFlags)(StringRef,
802  llvm::Regex::RegexFlags),
803  ReturnType (*NoFlags)(StringRef),
804  ArrayRef<ASTNodeKind> RetKinds)
805  : WithFlags(WithFlags), NoFlags(NoFlags),
806  RetKinds(RetKinds.begin(), RetKinds.end()) {}
807  bool isVariadic() const override { return true; }
808  unsigned getNumArgs() const override { return 0; }
809 
810  void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo,
811  std::vector<ArgKind> &Kinds) const override {
812  assert(ArgNo < 2);
813  Kinds.push_back(ArgKind::AK_String);
814  }
815 
816  bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity,
817  ASTNodeKind *LeastDerivedKind) const override {
818  return isRetKindConvertibleTo(RetKinds, Kind, Specificity,
819  LeastDerivedKind);
820  }
821 
823  Diagnostics *Error) const override {
824  if (Args.size() < 1 || Args.size() > 2) {
825  Error->addError(NameRange, Diagnostics::ET_RegistryWrongArgCount)
826  << "1 or 2" << Args.size();
827  return VariantMatcher();
828  }
830  Error->addError(Args[0].Range, Error->ET_RegistryWrongArgType)
831  << 1 << ArgTypeTraits<StringRef>::getKind().asString()
832  << Args[0].Value.getTypeAsString();
833  return VariantMatcher();
834  }
835  if (Args.size() == 1) {
837  NoFlags(ArgTypeTraits<StringRef>::get(Args[0].Value)));
838  }
840  Args[1].Value)) {
841  Error->addError(Args[1].Range, Error->ET_RegistryWrongArgType)
843  << Args[1].Value.getTypeAsString();
844  return VariantMatcher();
845  }
847  Args[1].Value)) {
848  if (llvm::Optional<std::string> BestGuess =
850  Args[1].Value)) {
851  Error->addError(Args[1].Range, Error->ET_RegistryUnknownEnumWithReplace)
852  << 2 << Args[1].Value.getString() << *BestGuess;
853  } else {
854  Error->addError(Args[1].Range, Error->ET_RegistryValueNotFound)
855  << Args[1].Value.getString();
856  }
857  return VariantMatcher();
858  }
860  WithFlags(ArgTypeTraits<StringRef>::get(Args[0].Value),
862  }
863 
864 private:
865  ReturnType (*const WithFlags)(StringRef, llvm::Regex::RegexFlags);
866  ReturnType (*const NoFlags)(StringRef);
867  const std::vector<ASTNodeKind> RetKinds;
868 };
869 
870 /// Variadic operator marshaller function.
872 public:
873  using VarOp = DynTypedMatcher::VariadicOperator;
874 
875  VariadicOperatorMatcherDescriptor(unsigned MinCount, unsigned MaxCount,
876  VarOp Op, StringRef MatcherName)
877  : MinCount(MinCount), MaxCount(MaxCount), Op(Op),
878  MatcherName(MatcherName) {}
879 
882  Diagnostics *Error) const override {
883  if (Args.size() < MinCount || MaxCount < Args.size()) {
884  const std::string MaxStr =
885  (MaxCount == std::numeric_limits<unsigned>::max() ? ""
886  : Twine(MaxCount))
887  .str();
888  Error->addError(NameRange, Error->ET_RegistryWrongArgCount)
889  << ("(" + Twine(MinCount) + ", " + MaxStr + ")") << Args.size();
890  return VariantMatcher();
891  }
892 
893  std::vector<VariantMatcher> InnerArgs;
894  for (size_t i = 0, e = Args.size(); i != e; ++i) {
895  const ParserValue &Arg = Args[i];
896  const VariantValue &Value = Arg.Value;
897  if (!Value.isMatcher()) {
898  Error->addError(Arg.Range, Error->ET_RegistryWrongArgType)
899  << (i + 1) << "Matcher<>" << Value.getTypeAsString();
900  return VariantMatcher();
901  }
902  InnerArgs.push_back(Value.getMatcher());
903  }
904  return VariantMatcher::VariadicOperatorMatcher(Op, std::move(InnerArgs));
905  }
906 
907  bool isVariadic() const override { return true; }
908  unsigned getNumArgs() const override { return 0; }
909 
910  void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo,
911  std::vector<ArgKind> &Kinds) const override {
912  Kinds.push_back(ArgKind::MakeMatcherArg(ThisKind));
913  }
914 
915  bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity,
916  ASTNodeKind *LeastDerivedKind) const override {
917  if (Specificity)
918  *Specificity = 1;
919  if (LeastDerivedKind)
920  *LeastDerivedKind = Kind;
921  return true;
922  }
923 
924  bool isPolymorphic() const override { return true; }
925 
926 private:
927  const unsigned MinCount;
928  const unsigned MaxCount;
929  const VarOp Op;
930  const StringRef MatcherName;
931 };
932 
934  ASTNodeKind CladeNodeKind;
935  std::vector<ASTNodeKind> NodeKinds;
936 
937 public:
939  std::vector<ASTNodeKind> NodeKinds)
940  : CladeNodeKind(CladeNodeKind), NodeKinds(NodeKinds) {}
941 
943  Diagnostics *Error) const override {
944 
945  std::vector<DynTypedMatcher> NodeArgs;
946 
947  for (auto NK : NodeKinds) {
948  std::vector<DynTypedMatcher> InnerArgs;
949 
950  for (const auto &Arg : Args) {
951  if (!Arg.Value.isMatcher())
952  return {};
953  const VariantMatcher &VM = Arg.Value.getMatcher();
954  if (VM.hasTypedMatcher(NK)) {
955  auto DM = VM.getTypedMatcher(NK);
956  InnerArgs.push_back(DM);
957  }
958  }
959 
960  if (InnerArgs.empty()) {
961  NodeArgs.push_back(
962  DynTypedMatcher::trueMatcher(NK).dynCastTo(CladeNodeKind));
963  } else {
964  NodeArgs.push_back(
965  DynTypedMatcher::constructVariadic(
966  ast_matchers::internal::DynTypedMatcher::VO_AllOf, NK,
967  InnerArgs)
968  .dynCastTo(CladeNodeKind));
969  }
970  }
971 
972  auto Result = DynTypedMatcher::constructVariadic(
973  ast_matchers::internal::DynTypedMatcher::VO_AnyOf, CladeNodeKind,
974  NodeArgs);
975  Result.setAllowBind(true);
976  return VariantMatcher::SingleMatcher(Result);
977  }
978 
979  bool isVariadic() const override { return true; }
980  unsigned getNumArgs() const override { return 0; }
981 
982  void getArgKinds(ASTNodeKind ThisKind, unsigned,
983  std::vector<ArgKind> &Kinds) const override {
984  Kinds.push_back(ArgKind::MakeMatcherArg(ThisKind));
985  }
986 
987  bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity,
988  ASTNodeKind *LeastDerivedKind) const override {
989  if (Specificity)
990  *Specificity = 1;
991  if (LeastDerivedKind)
992  *LeastDerivedKind = CladeNodeKind;
993  return true;
994  }
995 };
996 
998 public:
1000  Diagnostics *) const override {
1001  return {};
1002  }
1003 
1004  bool isBuilderMatcher() const override { return true; }
1005 
1006  std::unique_ptr<MatcherDescriptor>
1008  Diagnostics *) const override {
1009 
1010  std::vector<ASTNodeKind> NodeKinds;
1011  for (auto Arg : Args) {
1012  if (!Arg.Value.isNodeKind())
1013  return {};
1014  NodeKinds.push_back(Arg.Value.getNodeKind());
1015  }
1016 
1017  if (NodeKinds.empty())
1018  return {};
1019 
1020  ASTNodeKind CladeNodeKind = NodeKinds.front().getCladeKind();
1021 
1022  for (auto NK : NodeKinds)
1023  {
1024  if (!NK.getCladeKind().isSame(CladeNodeKind))
1025  return {};
1026  }
1027 
1028  return std::make_unique<MapAnyOfMatcherDescriptor>(CladeNodeKind,
1029  NodeKinds);
1030  }
1031 
1032  bool isVariadic() const override { return true; }
1033 
1034  unsigned getNumArgs() const override { return 0; }
1035 
1036  void getArgKinds(ASTNodeKind ThisKind, unsigned,
1037  std::vector<ArgKind> &ArgKinds) const override {
1038  ArgKinds.push_back(ArgKind::MakeNodeArg(ThisKind));
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_LIB_ASTMATCHERS_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:196
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:777
llvm
YAML serialization mapping.
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:980
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:938
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:801
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:623
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:20
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:915
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:598
clang::ast_matchers::dynamic::internal::OverloadedMatcherDescriptor::create
VariantMatcher create(SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const override
Definition: Marshallers.h:734
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:573
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:1007
clang::ast_matchers::dynamic::internal::VariadicFuncMatcherDescriptor::create
VariantMatcher create(SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const override
Definition: Marshallers.h:559
clang::ast_matchers::dynamic::internal::OverloadedMatcherDescriptor
MatcherDescriptor that wraps multiple "overloads" of the same matcher.
Definition: Marshallers.h:725
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:933
clang::ast_matchers::dynamic::internal::OverloadedMatcherDescriptor::isVariadic
bool isVariadic() const override
Returns whether the matcher is variadic.
Definition: Marshallers.h:757
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:924
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:785
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:873
clang::ast_matchers::dynamic::internal::MapAnyOfMatcherDescriptor::create
VariantMatcher create(SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const override
Definition: Marshallers.h:942
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:810
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:910
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:676
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::attr
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
Definition: ASTMatchersInternal.cpp:1031
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:579
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:652
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:987
clang::ast_matchers::dynamic::internal::MapAnyOfBuilderDescriptor::create
VariantMatcher create(SourceRange, ArrayRef< ParserValue >, Diagnostics *) const override
Definition: Marshallers.h:999
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:696
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:27
bool
#define bool
Definition: stdbool.h:20
clang::ast_matchers::dynamic::internal::OverloadedMatcherDescriptor::OverloadedMatcherDescriptor
OverloadedMatcherDescriptor(MutableArrayRef< std::unique_ptr< MatcherDescriptor >> Callbacks)
Definition: Marshallers.h:727
clang::ast_matchers::dynamic::internal::RegexMatcherDescriptor::isVariadic
bool isVariadic() const override
Returns whether the matcher is variadic.
Definition: Marshallers.h:807
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:816
OperationKinds.h
clang::ast_matchers::dynamic::internal::MapAnyOfMatcherDescriptor::isVariadic
bool isVariadic() const override
Returns whether the matcher is variadic.
Definition: Marshallers.h:979
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:566
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:663
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:550
getKind
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:1024
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:799
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:908
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:997
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:103
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:592
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:616
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:4477
clang::ASTNodeKind
Kind identifier.
Definition: ASTTypeTraits.h:51
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:1034
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:565
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:871
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:1032
clang::ast_matchers::dynamic::internal::DynCastAllOfMatcherDescriptor
Return CK_Trivial when appropriate for VariadicDynCastAllOfMatchers.
Definition: Marshallers.h:589
clang
Definition: CalledOnceCheck.h:17
clang::syntax::NodeKind
NodeKind
A kind of a syntax node, used for implementing casts.
Definition: Nodes.h:32
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:568
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:541
clang::ast_matchers::dynamic::internal::VariadicOperatorMatcherDescriptor::create
VariantMatcher create(SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const override
Definition: Marshallers.h:880
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:767
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:808
clang::ast_matchers::dynamic::internal::MapAnyOfBuilderDescriptor::isBuilderMatcher
bool isBuilderMatcher() const override
Definition: Marshallers.h:1004
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:822
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:907
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:1036
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:76
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:546
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:630
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:875
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:698
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:982