LLVM 22.0.0git
YAMLTraits.h File Reference
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/SMLoc.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/YAMLParser.h"
#include "llvm/Support/raw_ostream.h"
#include <array>
#include <cassert>
#include <map>
#include <memory>
#include <new>
#include <optional>
#include <string>
#include <system_error>
#include <type_traits>
#include <vector>

Go to the source code of this file.

Classes

struct  llvm::yaml::EmptyContext
struct  llvm::yaml::MappingTraits< T >
 This class should be specialized by any type that needs to be converted to/from a YAML mapping. More...
struct  llvm::yaml::MappingContextTraits< T, Context >
 This class is similar to MappingTraits<T> but allows you to pass in additional context for each map operation. More...
struct  llvm::yaml::ScalarEnumerationTraits< T, Enable >
 This class should be specialized by any integral type that converts to/from a YAML scalar where there is a one-to-one mapping between in-memory values and a string in YAML. More...
struct  llvm::yaml::ScalarBitSetTraits< T, Enable >
 This class should be specialized by any integer type that is a union of bit values and the YAML representation is a flow sequence of strings. More...
struct  llvm::yaml::ScalarTraits< T, Enable >
 This class should be specialized by type that requires custom conversion to/from a yaml scalar. More...
struct  llvm::yaml::BlockScalarTraits< T >
 This class should be specialized by type that requires custom conversion to/from a YAML literal block scalar. More...
struct  llvm::yaml::TaggedScalarTraits< T >
 This class should be specialized by type that requires custom conversion to/from a YAML scalar with optional tags. More...
struct  llvm::yaml::SequenceTraits< T, EnableIf >
 This class should be specialized by any type that needs to be converted to/from a YAML sequence. More...
struct  llvm::yaml::SequenceElementTraits< T, EnableIf >
 This class should be specialized by any type for which vectors of that type need to be converted to/from a YAML sequence. More...
struct  llvm::yaml::DocumentListTraits< T >
 This class should be specialized by any type that needs to be converted to/from a list of YAML documents. More...
struct  llvm::yaml::CustomMappingTraits< T >
 This class should be specialized by any type that needs to be converted to/from a YAML mapping in the case where the names of the keys are not known in advance, e.g. More...
struct  llvm::yaml::PolymorphicTraits< T >
 This class should be specialized by any type that can be represented as a scalar, map, or sequence, decided dynamically. More...
struct  llvm::yaml::has_ScalarEnumerationTraits< T >
struct  llvm::yaml::has_ScalarBitSetTraits< T >
struct  llvm::yaml::has_ScalarTraits< T >
struct  llvm::yaml::has_BlockScalarTraits< T >
struct  llvm::yaml::has_TaggedScalarTraits< T >
struct  llvm::yaml::has_MappingTraits< T, Context >
struct  llvm::yaml::has_MappingTraits< T, EmptyContext >
struct  llvm::yaml::has_MappingValidateTraits< T, Context >
struct  llvm::yaml::has_MappingValidateTraits< T, EmptyContext >
struct  llvm::yaml::has_MappingEnumInputTraits< T, Context >
struct  llvm::yaml::has_MappingEnumInputTraits< T, EmptyContext >
struct  llvm::yaml::has_SequenceMethodTraits< T >
struct  llvm::yaml::has_CustomMappingTraits< T >
struct  llvm::yaml::has_FlowTraits< T >
struct  llvm::yaml::has_SequenceTraits< T >
struct  llvm::yaml::has_DocumentListTraits< T >
struct  llvm::yaml::has_PolymorphicTraits< T >
struct  llvm::yaml::missingTraits< T, Context >
struct  llvm::yaml::validatedMappingTraits< T, Context >
struct  llvm::yaml::unvalidatedMappingTraits< T, Context >
class  llvm::yaml::IO
struct  llvm::yaml::ScalarTraits< bool >
struct  llvm::yaml::ScalarTraits< StringRef >
struct  llvm::yaml::ScalarTraits< std::string >
struct  llvm::yaml::ScalarTraits< uint8_t >
struct  llvm::yaml::ScalarTraits< uint16_t >
struct  llvm::yaml::ScalarTraits< uint32_t >
struct  llvm::yaml::ScalarTraits< uint64_t >
struct  llvm::yaml::ScalarTraits< int8_t >
struct  llvm::yaml::ScalarTraits< int16_t >
struct  llvm::yaml::ScalarTraits< int32_t >
struct  llvm::yaml::ScalarTraits< int64_t >
struct  llvm::yaml::ScalarTraits< float >
struct  llvm::yaml::ScalarTraits< double >
struct  llvm::yaml::ScalarTraits< support::detail::packed_endian_specific_integral< value_type, endian, alignment >, std::enable_if_t< has_ScalarTraits< value_type >::value > >
struct  llvm::yaml::ScalarEnumerationTraits< support::detail::packed_endian_specific_integral< value_type, endian, alignment >, std::enable_if_t< has_ScalarEnumerationTraits< value_type >::value > >
struct  llvm::yaml::ScalarBitSetTraits< support::detail::packed_endian_specific_integral< value_type, endian, alignment >, std::enable_if_t< has_ScalarBitSetTraits< value_type >::value > >
struct  llvm::yaml::MappingNormalization< TNorm, TFinal >
struct  llvm::yaml::MappingNormalizationHeap< TNorm, TFinal >
class  llvm::yaml::Input
 The Input class is used to parse a yaml document into in-memory structs and vectors. More...
class  llvm::yaml::Output
 The Output class is used to generate a yaml document from in-memory structs and vectors. More...
struct  llvm::yaml::ScalarTraits< Hex8 >
 Use these types instead of uintXX_t in any mapping to have its yaml output formatted as hexadecimal. More...
struct  llvm::yaml::ScalarTraits< Hex16 >
struct  llvm::yaml::ScalarTraits< Hex32 >
struct  llvm::yaml::ScalarTraits< Hex64 >
struct  llvm::yaml::ScalarTraits< VersionTuple >
struct  llvm::yaml::IsFlowSequenceBase< B >
struct  llvm::yaml::IsFlowSequenceBase< true >
struct  llvm::yaml::IsResizableBase< T >
struct  llvm::yaml::SequenceTraitsImpl< T, Flow >
struct  llvm::yaml::CheckIsBool< bool >
struct  llvm::yaml::SequenceTraits< std::vector< T >, std::enable_if_t< CheckIsBool< SequenceElementTraits< T >::flow >::value > >
struct  llvm::yaml::SequenceTraits< std::array< T, N >, std::enable_if_t< CheckIsBool< SequenceElementTraits< T >::flow >::value > >
struct  llvm::yaml::SequenceTraits< SmallVector< T, N >, std::enable_if_t< CheckIsBool< SequenceElementTraits< T >::flow >::value > >
struct  llvm::yaml::SequenceTraits< SmallVectorImpl< T >, std::enable_if_t< CheckIsBool< SequenceElementTraits< T >::flow >::value > >
struct  llvm::yaml::SequenceTraits< MutableArrayRef< T >, std::enable_if_t< CheckIsBool< SequenceElementTraits< T >::flow >::value > >
struct  llvm::yaml::SequenceElementTraits< T, std::enable_if_t< std::is_fundamental_v< T > > >
struct  llvm::yaml::SequenceElementTraits< std::string >
struct  llvm::yaml::SequenceElementTraits< StringRef >
struct  llvm::yaml::SequenceElementTraits< std::pair< std::string, std::string > >
struct  llvm::yaml::StdMapStringCustomMappingTraitsImpl< T >
 Implementation of CustomMappingTraits for std::map<std::string, T>. More...

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
namespace  llvm::yaml
namespace  llvm::yaml::detail

Macros

#define LLVM_YAML_STRONG_TYPEDEF(_base, _type)
 YAML I/O does conversion based on types. But often native data types are just a typedef of built in intergral types (e.g. int). But the C++ type matching system sees through the typedef and all the typedefed types look like a built in type. This will cause the generic YAML I/O conversion to be used. To provide better control over the YAML conversion, you can use this macro instead of typedef. It will create a class with one field and automatic conversion operators to and from the base type. Based on BOOST_STRONG_TYPEDEF.
#define LLVM_YAML_IS_SEQUENCE_VECTOR_IMPL(TYPE, FLOW)
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
 Utility for declaring that a std::vector of a particular type should be considered a YAML sequence.
#define LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(type)
 Utility for declaring that a std::vector of a particular type should be considered a YAML flow sequence.
#define LLVM_YAML_DECLARE_MAPPING_TRAITS(Type)
#define LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(Type)
#define LLVM_YAML_DECLARE_ENUM_TRAITS(Type)
#define LLVM_YAML_DECLARE_BITSET_TRAITS(Type)
#define LLVM_YAML_DECLARE_SCALAR_TRAITS(Type, MustQuote)
#define LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(_type)
 Utility for declaring that a std::vector of a particular type should be considered a YAML document list.
#define LLVM_YAML_IS_STRING_MAP(_type)
 Utility for declaring that std::map<std::string, _type> should be considered a YAML map.

Typedefs

template<typename T>
using llvm::yaml::check_resize_t = decltype(std::declval<T>().resize(0))

Enumerations

enum class  llvm::yaml::NodeKind : uint8_t { llvm::yaml::Scalar , llvm::yaml::Map , llvm::yaml::Sequence }
enum class  llvm::yaml::QuotingType { llvm::yaml::None , llvm::yaml::Single , llvm::yaml::Double }
 Describe which type of quotes should be used when quoting is necessary. More...

Functions

bool llvm::yaml::isNumeric (StringRef S)
bool llvm::yaml::isNull (StringRef S)
bool llvm::yaml::isBool (StringRef S)
QuotingType llvm::yaml::needsQuotes (StringRef S, bool ForcePreserveAsString=true)
template<typename T, typename Context>
void llvm::yaml::detail::doMapping (IO &io, T &Val, Context &Ctx)
template<typename T>
void llvm::yaml::detail::doMapping (IO &io, T &Val, EmptyContext &Ctx)
template<typename T>
std::enable_if_t< has_ScalarEnumerationTraits< T >::value, void > llvm::yaml::yamlize (IO &io, T &Val, bool, EmptyContext &Ctx)
template<typename T>
std::enable_if_t< has_ScalarBitSetTraits< T >::value, void > llvm::yaml::yamlize (IO &io, T &Val, bool, EmptyContext &Ctx)
template<typename T>
std::enable_if_t< has_ScalarTraits< T >::value, void > llvm::yaml::yamlize (IO &io, T &Val, bool, EmptyContext &Ctx)
template<typename T>
std::enable_if_t< has_BlockScalarTraits< T >::value, void > llvm::yaml::yamlize (IO &YamlIO, T &Val, bool, EmptyContext &Ctx)
template<typename T>
std::enable_if_t< has_TaggedScalarTraits< T >::value, void > llvm::yaml::yamlize (IO &io, T &Val, bool, EmptyContext &Ctx)
template<typename T, typename Context>
std::string llvm::yaml::detail::doValidate (IO &io, T &Val, Context &Ctx)
template<typename T>
std::string llvm::yaml::detail::doValidate (IO &io, T &Val, EmptyContext &)
template<typename T, typename Context>
std::enable_if_t< validatedMappingTraits< T, Context >::value, void > llvm::yaml::yamlize (IO &io, T &Val, bool, Context &Ctx)
template<typename T, typename Context>
bool llvm::yaml::yamlizeMappingEnumInput (IO &io, T &Val)
template<typename T, typename Context>
std::enable_if_t< unvalidatedMappingTraits< T, Context >::value, void > llvm::yaml::yamlize (IO &io, T &Val, bool, Context &Ctx)
template<typename T>
std::enable_if_t< has_CustomMappingTraits< T >::value, void > llvm::yaml::yamlize (IO &io, T &Val, bool, EmptyContext &Ctx)
template<typename T>
std::enable_if_t< has_PolymorphicTraits< T >::value, void > llvm::yaml::yamlize (IO &io, T &Val, bool, EmptyContext &Ctx)
template<typename T>
std::enable_if_t< missingTraits< T, EmptyContext >::value, void > llvm::yaml::yamlize (IO &io, T &Val, bool, EmptyContext &Ctx)
template<typename T, typename Context>
std::enable_if_t< has_SequenceTraits< T >::value, void > llvm::yaml::yamlize (IO &io, T &Seq, bool, Context &Ctx)
template<typename T>
std::enable_if_t< has_DocumentListTraits< T >::value, Input & > llvm::yaml::operator>> (Input &yin, T &docList)
template<typename T>
std::enable_if_t< has_MappingTraits< T, EmptyContext >::value, Input & > llvm::yaml::operator>> (Input &yin, T &docMap)
template<typename T>
std::enable_if_t< has_SequenceTraits< T >::value, Input & > llvm::yaml::operator>> (Input &yin, T &docSeq)
template<typename T>
std::enable_if_t< has_BlockScalarTraits< T >::value, Input & > llvm::yaml::operator>> (Input &In, T &Val)
template<typename T>
std::enable_if_t< has_CustomMappingTraits< T >::value, Input & > llvm::yaml::operator>> (Input &In, T &Val)
template<typename T>
std::enable_if_t< has_PolymorphicTraits< T >::value, Input & > llvm::yaml::operator>> (Input &In, T &Val)
template<typename T>
std::enable_if_t< missingTraits< T, EmptyContext >::value, Input & > llvm::yaml::operator>> (Input &yin, T &docSeq)
template<typename T>
std::enable_if_t< has_DocumentListTraits< T >::value, Output & > llvm::yaml::operator<< (Output &yout, T &docList)
template<typename T>
std::enable_if_t< has_MappingTraits< T, EmptyContext >::value, Output & > llvm::yaml::operator<< (Output &yout, T &map)
template<typename T>
std::enable_if_t< has_SequenceTraits< T >::value, Output & > llvm::yaml::operator<< (Output &yout, T &seq)
template<typename T>
std::enable_if_t< has_BlockScalarTraits< T >::value, Output & > llvm::yaml::operator<< (Output &Out, T &Val)
template<typename T>
std::enable_if_t< has_CustomMappingTraits< T >::value, Output & > llvm::yaml::operator<< (Output &Out, T &Val)
template<typename T>
std::enable_if_t< has_PolymorphicTraits< T >::value, Output & > llvm::yaml::operator<< (Output &Out, T &Val)
template<typename T>
std::enable_if_t< missingTraits< T, EmptyContext >::value, Output & > llvm::yaml::operator<< (Output &yout, T &seq)

Macro Definition Documentation

◆ LLVM_YAML_DECLARE_BITSET_TRAITS

#define LLVM_YAML_DECLARE_BITSET_TRAITS ( Type)
Value:
namespace llvm { \
namespace yaml { \
template <> struct LLVM_ABI ScalarBitSetTraits<Type> { \
static void bitset(IO &IO, Type &Options); \
}; \
} \
}
#define LLVM_ABI
Definition Compiler.h:213
static LVOptions Options
Definition LVOptions.cpp:25
This is an optimization pass for GlobalISel generic memory operations.

Definition at line 1987 of file YAMLTraits.h.

◆ LLVM_YAML_DECLARE_ENUM_TRAITS

#define LLVM_YAML_DECLARE_ENUM_TRAITS ( Type)
Value:
namespace llvm { \
namespace yaml { \
template <> struct LLVM_ABI ScalarEnumerationTraits<Type> { \
static void enumeration(IO &io, Type &Value); \
}; \
} \
}

Definition at line 1978 of file YAMLTraits.h.

◆ LLVM_YAML_DECLARE_MAPPING_TRAITS

#define LLVM_YAML_DECLARE_MAPPING_TRAITS ( Type)
Value:
namespace llvm { \
namespace yaml { \
template <> struct LLVM_ABI MappingTraits<Type> { \
static void mapping(IO &IO, Type &Obj); \
}; \
} \
}

Definition at line 1960 of file YAMLTraits.h.

◆ LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE

#define LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE ( Type)
Value:
namespace llvm { \
namespace yaml { \
template <> struct MappingTraits<Type> { \
static void mapping(IO &IO, Type &Obj); \
}; \
} \
}

Definition at line 1969 of file YAMLTraits.h.

◆ LLVM_YAML_DECLARE_SCALAR_TRAITS

#define LLVM_YAML_DECLARE_SCALAR_TRAITS ( Type,
MustQuote )
Value:
namespace llvm { \
namespace yaml { \
template <> struct LLVM_ABI ScalarTraits<Type> { \
static void output(const Type &Value, void *ctx, raw_ostream &Out); \
static StringRef input(StringRef Scalar, void *ctxt, Type &Value); \
static QuotingType mustQuote(StringRef) { return MustQuote; } \
}; \
} \
}

Definition at line 1996 of file YAMLTraits.h.

◆ LLVM_YAML_IS_DOCUMENT_LIST_VECTOR

#define LLVM_YAML_IS_DOCUMENT_LIST_VECTOR ( _type)
Value:
namespace llvm { \
namespace yaml { \
template <unsigned N> \
struct DocumentListTraits<SmallVector<_type, N>> \
: public SequenceTraitsImpl<SmallVector<_type, N>, false> {}; \
template <> \
struct DocumentListTraits<std::vector<_type>> \
: public SequenceTraitsImpl<std::vector<_type>, false> {}; \
} \
}
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:851
#define N

Utility for declaring that a std::vector of a particular type should be considered a YAML document list.

Definition at line 2009 of file YAMLTraits.h.

◆ LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR

#define LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR ( type)
Value:
#define LLVM_YAML_IS_SEQUENCE_VECTOR_IMPL(TYPE, FLOW)

Utility for declaring that a std::vector of a particular type should be considered a YAML flow sequence.

Definition at line 1957 of file YAMLTraits.h.

◆ LLVM_YAML_IS_SEQUENCE_VECTOR

#define LLVM_YAML_IS_SEQUENCE_VECTOR ( type)
Value:

Utility for declaring that a std::vector of a particular type should be considered a YAML sequence.

Definition at line 1952 of file YAMLTraits.h.

Referenced by LLVM_YAML_IS_SEQUENCE_VECTOR().

◆ LLVM_YAML_IS_SEQUENCE_VECTOR_IMPL

#define LLVM_YAML_IS_SEQUENCE_VECTOR_IMPL ( TYPE,
FLOW )
Value:
namespace llvm { \
namespace yaml { \
static_assert( \
!std::is_fundamental_v<TYPE> && !std::is_same_v<TYPE, std::string> && \
!std::is_same_v<TYPE, llvm::StringRef>, \
"only use LLVM_YAML_IS_SEQUENCE_VECTOR for types you control"); \
template <> struct SequenceElementTraits<TYPE> { \
static const bool flow = FLOW; \
}; \
} \
}

Definition at line 1937 of file YAMLTraits.h.

◆ LLVM_YAML_IS_STRING_MAP

#define LLVM_YAML_IS_STRING_MAP ( _type)
Value:
namespace llvm { \
namespace yaml { \
template <> \
struct CustomMappingTraits<std::map<std::string, _type>> \
: public StdMapStringCustomMappingTraitsImpl<_type> {}; \
} \
}

Utility for declaring that std::map<std::string, _type> should be considered a YAML map.

Definition at line 2023 of file YAMLTraits.h.

◆ LLVM_YAML_STRONG_TYPEDEF

#define LLVM_YAML_STRONG_TYPEDEF ( _base,
_type )
Value:
struct _type { \
_type() = default; \
_type(const _base v) : value(v) {} \
_type(const _type &v) = default; \
_type &operator=(const _type &rhs) = default; \
_type &operator=(const _base &rhs) { \
value = rhs; \
return *this; \
} \
operator const _base &() const { return value; } \
bool operator==(const _type &rhs) const { return value == rhs.value; } \
bool operator==(const _base &rhs) const { return value == rhs; } \
bool operator<(const _type &rhs) const { return value < rhs.value; } \
_base value; \
using BaseType = _base; \
};
bool operator<(const DeltaInfo &LHS, int64_t Delta)
Definition LineTable.cpp:30
bool operator==(const MergedFunctionsInfo &LHS, const MergedFunctionsInfo &RHS)
BaseType
A given derived pointer can have multiple base pointers through phi/selects.

YAML I/O does conversion based on types. But often native data types are just a typedef of built in intergral types (e.g. int). But the C++ type matching system sees through the typedef and all the typedefed types look like a built in type. This will cause the generic YAML I/O conversion to be used. To provide better control over the YAML conversion, you can use this macro instead of typedef. It will create a class with one field and automatic conversion operators to and from the base type. Based on BOOST_STRONG_TYPEDEF.

Definition at line 1604 of file YAMLTraits.h.