clang 20.0.0git
Classes | Namespaces | Macros | Functions
Marshallers.h File Reference

Functions templates and classes to wrap matcher construct functions. More...

#include "clang/AST/ASTTypeTraits.h"
#include "clang/AST/OperationKinds.h"
#include "clang/ASTMatchers/ASTMatchersInternal.h"
#include "clang/ASTMatchers/Dynamic/Diagnostics.h"
#include "clang/ASTMatchers/Dynamic/VariantValue.h"
#include "clang/Basic/AttrKinds.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/OpenMPKinds.h"
#include "clang/Basic/TypeTraits.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/Regex.h"
#include <cassert>
#include <cstddef>
#include <iterator>
#include <limits>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "clang/Basic/AttrList.inc"
#include "clang/AST/OperationKinds.def"
#include "llvm/Frontend/OpenMP/OMP.inc"
#include "clang/Basic/TokenKinds.def"

Go to the source code of this file.

Classes

struct  clang::ast_matchers::dynamic::internal::ArgTypeTraits< const T & >
 
struct  clang::ast_matchers::dynamic::internal::ArgTypeTraits< std::string >
 
struct  clang::ast_matchers::dynamic::internal::ArgTypeTraits< StringRef >
 
struct  clang::ast_matchers::dynamic::internal::ArgTypeTraits< ast_matchers::internal::Matcher< T > >
 
struct  clang::ast_matchers::dynamic::internal::ArgTypeTraits< bool >
 
struct  clang::ast_matchers::dynamic::internal::ArgTypeTraits< double >
 
struct  clang::ast_matchers::dynamic::internal::ArgTypeTraits< unsigned >
 
struct  clang::ast_matchers::dynamic::internal::ArgTypeTraits< attr::Kind >
 
struct  clang::ast_matchers::dynamic::internal::ArgTypeTraits< CastKind >
 
struct  clang::ast_matchers::dynamic::internal::ArgTypeTraits< llvm::Regex::RegexFlags >
 
struct  clang::ast_matchers::dynamic::internal::ArgTypeTraits< OpenMPClauseKind >
 
struct  clang::ast_matchers::dynamic::internal::ArgTypeTraits< UnaryExprOrTypeTrait >
 
class  clang::ast_matchers::dynamic::internal::MatcherDescriptor
 Matcher descriptor interface. More...
 
class  clang::ast_matchers::dynamic::internal::FixedArgCountMatcherDescriptor
 Simple callback implementation. More...
 
struct  clang::ast_matchers::dynamic::internal::BuildReturnTypeVector< T >
 
struct  clang::ast_matchers::dynamic::internal::BuildReturnTypeVector< ast_matchers::internal::Matcher< T > >
 
struct  clang::ast_matchers::dynamic::internal::BuildReturnTypeVector< ast_matchers::internal::BindableMatcher< T > >
 
class  clang::ast_matchers::dynamic::internal::VariadicFuncMatcherDescriptor
 Matcher descriptor for variadic functions. More...
 
class  clang::ast_matchers::dynamic::internal::DynCastAllOfMatcherDescriptor
 Return CK_Trivial when appropriate for VariadicDynCastAllOfMatchers. More...
 
class  clang::ast_matchers::dynamic::internal::AdaptativeOverloadCollector< ArgumentAdapterT, FromTypes, ToTypes >
 Helper class used to collect all the possible overloads of an argument adaptative matcher function. More...
 
class  clang::ast_matchers::dynamic::internal::OverloadedMatcherDescriptor
 MatcherDescriptor that wraps multiple "overloads" of the same matcher. More...
 
class  clang::ast_matchers::dynamic::internal::RegexMatcherDescriptor< ReturnType >
 
class  clang::ast_matchers::dynamic::internal::VariadicOperatorMatcherDescriptor
 Variadic operator marshaller function. More...
 
class  clang::ast_matchers::dynamic::internal::MapAnyOfMatcherDescriptor
 
class  clang::ast_matchers::dynamic::internal::MapAnyOfBuilderDescriptor
 

Namespaces

namespace  clang
 The JSON file list parser is used to communicate input to InstallAPI.
 
namespace  clang::ast_matchers
 
namespace  clang::ast_matchers::dynamic
 
namespace  clang::ast_matchers::dynamic::internal
 

Macros

#define ATTR(X)   .Case(#X, attr::X)
 
#define CAST_OPERATION(Name)   .Case(#Name, CK_##Name)
 
#define GEN_CLANG_CLAUSE_CLASS
 
#define CLAUSE_CLASS(Enum, Str, Class)   .Case(#Enum, llvm::omp::Clause::Enum)
 
#define UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key)   .Case(#Name, UETT_##Name)
 
#define CXX11_UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key)    .Case(#Name, UETT_##Name)
 
#define CHECK_ARG_COUNT(count)
 Helper macros to check the arguments on all marshaller functions.
 
#define CHECK_ARG_TYPE(index, type)
 

Functions

bool clang::ast_matchers::dynamic::internal::isRetKindConvertibleTo (ArrayRef< ASTNodeKind > RetKinds, ASTNodeKind Kind, unsigned *Specificity, ASTNodeKind *LeastDerivedKind)
 
template<class PolyMatcher >
static void clang::ast_matchers::dynamic::internal::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.
 
template<class PolyMatcher , class TypeList >
static void clang::ast_matchers::dynamic::internal::mergePolyMatchers (const PolyMatcher &Poly, std::vector< DynTypedMatcher > &Out, TypeList)
 
VariantMatcher clang::ast_matchers::dynamic::internal::outvalueToVariantMatcher (const DynTypedMatcher &Matcher)
 Convert the return values of the functions into a VariantMatcher.
 
template<typename T >
static VariantMatcher clang::ast_matchers::dynamic::internal::outvalueToVariantMatcher (const T &PolyMatcher, typename T::ReturnTypes *=nullptr)
 
template<typename T >
void clang::ast_matchers::dynamic::internal::buildReturnTypeVectorFromTypeList (std::vector< ASTNodeKind > &RetTypes)
 
template<>
void clang::ast_matchers::dynamic::internal::buildReturnTypeVectorFromTypeList< ast_matchers::internal::EmptyTypeList > (std::vector< ASTNodeKind > &RetTypes)
 
template<typename ResultT , typename ArgT , ResultT(*)(ArrayRef< const ArgT * >) Func>
VariantMatcher clang::ast_matchers::dynamic::internal::variadicMatcherDescriptor (StringRef MatcherName, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error)
 Variadic marshaller function.
 
template<typename ReturnType >
static VariantMatcher clang::ast_matchers::dynamic::internal::matcherMarshall0 (void(*Func)(), StringRef MatcherName, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error)
 0-arg marshaller function.
 
template<typename ReturnType , typename ArgType1 >
static VariantMatcher clang::ast_matchers::dynamic::internal::matcherMarshall1 (void(*Func)(), StringRef MatcherName, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error)
 1-arg marshaller function.
 
template<typename ReturnType , typename ArgType1 , typename ArgType2 >
static VariantMatcher clang::ast_matchers::dynamic::internal::matcherMarshall2 (void(*Func)(), StringRef MatcherName, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error)
 2-arg marshaller function.
 
template<typename ReturnType >
std::unique_ptr< MatcherDescriptor > clang::ast_matchers::dynamic::internal::makeMatcherAutoMarshall (ReturnType(*Func)(), StringRef MatcherName)
 Helper functions to select the appropriate marshaller functions.
 
template<typename ReturnType , typename ArgType1 >
std::unique_ptr< MatcherDescriptor > clang::ast_matchers::dynamic::internal::makeMatcherAutoMarshall (ReturnType(*Func)(ArgType1), StringRef MatcherName)
 1-arg overload
 
template<typename ReturnType , typename ArgType1 , typename ArgType2 >
std::unique_ptr< MatcherDescriptor > clang::ast_matchers::dynamic::internal::makeMatcherAutoMarshall (ReturnType(*Func)(ArgType1, ArgType2), StringRef MatcherName)
 2-arg overload
 
template<typename ReturnType >
std::unique_ptr< MatcherDescriptor > clang::ast_matchers::dynamic::internal::makeMatcherRegexMarshall (ReturnType(*FuncFlags)(llvm::StringRef, llvm::Regex::RegexFlags), ReturnType(*Func)(llvm::StringRef))
 
template<typename ResultT , typename ArgT , ResultT(*)(ArrayRef< const ArgT * >) Func>
std::unique_ptr< MatcherDescriptor > clang::ast_matchers::dynamic::internal::makeMatcherAutoMarshall (ast_matchers::internal::VariadicFunction< ResultT, ArgT, Func > VarFunc, StringRef MatcherName)
 Variadic overload.
 
template<typename BaseT , typename DerivedT >
std::unique_ptr< MatcherDescriptor > clang::ast_matchers::dynamic::internal::makeMatcherAutoMarshall (ast_matchers::internal::VariadicDynCastAllOfMatcher< BaseT, DerivedT > VarFunc, StringRef MatcherName)
 Overload for VariadicDynCastAllOfMatchers.
 
template<template< typename ToArg, typename FromArg > class ArgumentAdapterT, typename FromTypes , typename ToTypes >
std::unique_ptr< MatcherDescriptor > clang::ast_matchers::dynamic::internal::makeMatcherAutoMarshall (ast_matchers::internal::ArgumentAdaptingMatcherFunc< ArgumentAdapterT, FromTypes, ToTypes >, StringRef MatcherName)
 Argument adaptative overload.
 
template<unsigned MinCount, unsigned MaxCount>
std::unique_ptr< MatcherDescriptor > clang::ast_matchers::dynamic::internal::makeMatcherAutoMarshall (ast_matchers::internal::VariadicOperatorMatcherFunc< MinCount, MaxCount > Func, StringRef MatcherName)
 Variadic operator overload.
 
template<typename CladeType , typename... MatcherT>
std::unique_ptr< MatcherDescriptor > clang::ast_matchers::dynamic::internal::makeMatcherAutoMarshall (ast_matchers::internal::MapAnyOfMatcherImpl< CladeType, MatcherT... >, StringRef MatcherName)
 

Detailed Description

Functions templates and classes to wrap matcher construct functions.

A collection of template function and classes that provide a generic marshalling layer on top of matcher construct functions. These are used by the registry to export all marshaller constructors with the same generic interface.

Definition in file Marshallers.h.

Macro Definition Documentation

◆ ATTR

#define ATTR (   X)    .Case(#X, attr::X)

◆ CAST_OPERATION

#define CAST_OPERATION (   Name)    .Case(#Name, CK_##Name)

◆ CHECK_ARG_COUNT

#define CHECK_ARG_COUNT (   count)
Value:
if (Args.size() != count) { \
Error->addError(NameRange, Error->ET_RegistryWrongArgCount) \
<< count << Args.size(); \
return VariantMatcher(); \
}

Helper macros to check the arguments on all marshaller functions.

Definition at line 623 of file Marshallers.h.

◆ CHECK_ARG_TYPE

#define CHECK_ARG_TYPE (   index,
  type 
)
Value:
if (!ArgTypeTraits<type>::hasCorrectType(Args[index].Value)) { \
Error->addError(Args[index].Range, Error->ET_RegistryWrongArgType) \
<< (index + 1) << ArgTypeTraits<type>::getKind().asString() \
<< Args[index].Value.getTypeAsString(); \
return VariantMatcher(); \
} \
if (!ArgTypeTraits<type>::hasCorrectValue(Args[index].Value)) { \
if (std::optional<std::string> BestGuess = \
ArgTypeTraits<type>::getBestGuess(Args[index].Value)) { \
Error->addError(Args[index].Range, \
Error->ET_RegistryUnknownEnumWithReplace) \
<< index + 1 << Args[index].Value.getString() << *BestGuess; \
} else if (Args[index].Value.isString()) { \
Error->addError(Args[index].Range, Error->ET_RegistryValueNotFound) \
<< Args[index].Value.getString(); \
} \
return VariantMatcher(); \
}
SourceRange Range
Definition: SemaObjC.cpp:758

Definition at line 630 of file Marshallers.h.

◆ CLAUSE_CLASS

#define CLAUSE_CLASS (   Enum,
  Str,
  Class 
)    .Case(#Enum, llvm::omp::Clause::Enum)

◆ CXX11_UNARY_EXPR_OR_TYPE_TRAIT

#define CXX11_UNARY_EXPR_OR_TYPE_TRAIT (   Spelling,
  Name,
  Key 
)     .Case(#Name, UETT_##Name)

◆ GEN_CLANG_CLAUSE_CLASS

#define GEN_CLANG_CLAUSE_CLASS

◆ UNARY_EXPR_OR_TYPE_TRAIT

#define UNARY_EXPR_OR_TYPE_TRAIT (   Spelling,
  Name,
  Key 
)    .Case(#Name, UETT_##Name)