10 #ifndef LLVM_SUPPORT_YAMLTRAITS_H
11 #define LLVM_SUPPORT_YAMLTRAITS_H
33 #include <system_error>
34 #include <type_traits>
167 template <
typename T>
193 template<
typename T,
typename EnableIf =
void>
206 template<
typename T,
typename EnableIf =
void>
224 template <
typename T>
231 template <
typename T>
240 template <
typename U>
243 template <
typename U>
244 static double test(...);
248 (
sizeof(test<ScalarEnumerationTraits<T>>(
nullptr)) == 1);
257 template <
typename U>
260 template <
typename U>
261 static double test(...);
264 static bool const value = (
sizeof(test<ScalarBitSetTraits<T>>(
nullptr)) == 1);
275 template <
typename U>
280 template <
typename U>
281 static double test(...);
285 (
sizeof(test<ScalarTraits<T>>(
nullptr,
nullptr,
nullptr)) == 1);
295 template <
typename U>
299 template <
typename U>
300 static double test(...);
304 (
sizeof(test<BlockScalarTraits<T>>(
nullptr,
nullptr)) == 1);
311 template <
typename U>
314 template <
typename U>
315 static double test(...);
319 (
sizeof(test<MappingContextTraits<T, Context>>(
nullptr)) == 1);
326 template <
typename U>
329 template <
typename U>
static double test(...);
332 static bool const value = (
sizeof(test<MappingTraits<T>>(
nullptr)) == 1);
339 template <
typename U>
342 template <
typename U>
343 static double test(...);
347 (
sizeof(test<MappingContextTraits<T, Context>>(
nullptr)) == 1);
354 template <
typename U>
357 template <
typename U>
static double test(...);
360 static bool const value = (
sizeof(test<MappingTraits<T>>(
nullptr)) == 1);
369 template <
typename U>
372 template <
typename U>
373 static double test(...);
376 static bool const value = (
sizeof(test<SequenceTraits<T>>(
nullptr)) == 1);
385 template <
typename U>
388 template <
typename U>
389 static double test(...);
393 (
sizeof(test<CustomMappingTraits<T>>(
nullptr)) == 1);
399 template <typename T, bool Enabled = std::is_class<T>::value>
412 struct Fallback {
bool flow; };
413 struct Derived :
T, Fallback { };
419 static char (&f(...))[2];
422 static bool const value =
sizeof(f<Derived>(
nullptr)) == 2;
428 has_SequenceMethodTraits<T>::value > { };
436 template <
typename U>
439 template <
typename U>
440 static double test(...);
443 static bool const value = (
sizeof(test<DocumentListTraits<T>>(
nullptr))==1);
447 static const char OctalChars[] =
"01234567";
456 static const char HexChars[] =
"0123456789abcdefABCDEF";
461 static const char DecChars[] =
"0123456789";
468 Regex FloatMatcher(
"^(\\.[0-9]+|[0-9]+(\\.[0-9]*)?)([eE][-+]?[0-9]+)?$");
469 if (FloatMatcher.
match(S))
501 if (isspace(S.
front()) || isspace(S.
back()))
503 if (S.
front() ==
',')
506 static const char ScalarSafeChars[] =
507 "abcdefghijklmnopqrstuvwxyz"
508 "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-/^., \t";
522 template <
typename T,
typename Context>
524 :
public std::integral_constant<bool,
525 !has_ScalarEnumerationTraits<T>::value &&
526 !has_ScalarBitSetTraits<T>::value &&
527 !has_ScalarTraits<T>::value &&
528 !has_BlockScalarTraits<T>::value &&
529 !has_MappingTraits<T, Context>::value &&
530 !has_SequenceTraits<T>::value &&
531 !has_CustomMappingTraits<T>::value &&
532 !has_DocumentListTraits<T>::value> {};
534 template <
typename T,
typename Context>
536 :
public std::integral_constant<
537 bool, has_MappingTraits<T, Context>::value &&
538 has_MappingValidateTraits<T, Context>::value> {};
540 template <
typename T,
typename Context>
542 :
public std::integral_constant<
543 bool, has_MappingTraits<T, Context>::value &&
544 !has_MappingValidateTraits<T, Context>::value> {};
549 IO(
void *Ctxt =
nullptr);
568 virtual bool preflightKey(
const char*,
bool,
bool,
bool &,
void *&) = 0;
570 virtual std::vector<StringRef>
keys() = 0;
589 template <
typename T>
597 template <
typename T>
604 template <
typename FBT,
typename T>
610 yamlize(*
this, Res,
true, Context);
615 template <
typename T>
618 Val =
static_cast<T>(Val | ConstVal);
623 template <
typename T>
626 Val =
static_cast<T>(Val | ConstVal);
630 template <
typename T>
633 Val = Val | ConstVal;
636 template <
typename T>
640 Val = Val | ConstVal;
648 this->processKey(Key, Val,
true, Ctx);
651 template <
typename T,
typename Context>
653 this->processKey(Key, Val,
true, Ctx);
661 template <
typename T>
667 template <
typename T,
typename Context>
668 typename std::enable_if<has_SequenceTraits<T>::value,
void>::type
673 this->processKey(Key, Val,
false, Ctx);
676 template <
typename T,
typename Context>
678 this->processKeyWithDefault(Key, Val,
Optional<T>(),
false,
682 template <
typename T,
typename Context>
683 typename std::enable_if<!has_SequenceTraits<T>::value,
void>::type
685 this->processKey(Key, Val,
false, Ctx);
688 template <
typename T,
typename Context>
691 this->processKeyWithDefault(Key, Val, Default,
false, Ctx);
695 template <
typename T,
typename Context>
696 void processKeyWithDefault(
const char *Key,
Optional<T> &Val,
700 "Optional<T> shouldn't have a value!");
702 bool UseDefault =
true;
707 this->
preflightKey(Key, Required, sameAsDefault, UseDefault,
717 template <
typename T,
typename Context>
718 void processKeyWithDefault(
const char *Key,
T &Val,
const T &DefaultValue,
722 const bool sameAsDefault =
outputting() && Val == DefaultValue;
723 if ( this->
preflightKey(Key, Required, sameAsDefault, UseDefault,
725 yamlize(*
this, Val, Required, Ctx);
734 template <
typename T,
typename Context>
735 void processKey(
const char *Key,
T &Val,
bool Required,
Context &Ctx) {
738 if ( this->
preflightKey(Key, Required,
false, UseDefault, SaveInfo) ) {
739 yamlize(*
this, Val, Required, Ctx);
750 template <
typename T,
typename Context>
761 template <
typename T>
762 typename std::enable_if<has_ScalarEnumerationTraits<T>::value,
void>::type
769 template <
typename T>
770 typename std::enable_if<has_ScalarBitSetTraits<T>::value,
void>::type
775 Val =
static_cast<T>(0);
781 template <
typename T>
782 typename std::enable_if<has_ScalarTraits<T>::value,
void>::type
795 if ( !Result.
empty() ) {
801 template <
typename T>
802 typename std::enable_if<has_BlockScalarTraits<T>::value,
void>::type
820 template <
typename T,
typename Context>
821 typename std::enable_if<validatedMappingTraits<T, Context>::value,
void>::type
830 errs() << Err <<
"\n";
831 assert(Err.
empty() &&
"invalid struct trying to be written as yaml");
846 template <
typename T,
typename Context>
847 typename std::enable_if<unvalidatedMappingTraits<T, Context>::value,
void>::type
860 template <
typename T>
861 typename std::enable_if<has_CustomMappingTraits<T>::value,
void>::type
875 template <
typename T>
876 typename std::enable_if<missingTraits<T, EmptyContext>::value,
void>::type
881 template <
typename T,
typename Context>
882 typename std::enable_if<has_SequenceTraits<T>::value,
void>::type
887 for(
unsigned i=0; i <
count; ++i) {
899 for(
unsigned i=0; i <
count; ++i) {
912 static void output(
const bool &,
void* ,
raw_ostream &);
926 static void output(
const std::string &,
void *,
raw_ostream &);
933 static void output(
const uint8_t &,
void *,
raw_ostream &);
940 static void output(
const uint16_t &,
void *,
raw_ostream &);
954 static void output(
const uint64_t &,
void *,
raw_ostream &);
961 static void output(
const int8_t &,
void *,
raw_ostream &);
968 static void output(
const int16_t &,
void *,
raw_ostream &);
975 static void output(
const int32_t &,
void *,
raw_ostream &);
982 static void output(
const int64_t &,
void *,
raw_ostream &);
989 static void output(
const float &,
void *,
raw_ostream &);
996 static void output(
const double &,
void *,
raw_ostream &);
1004 template <
typename value_type, support::endianness endian,
size_t alignment>
1006 value_type, endian, alignment>> {
1029 template <
typename TNorm,
typename TFinal>
1032 : io(i_o), BufPtr(nullptr), Result(Obj) {
1034 BufPtr =
new (&Buffer) TNorm(io, Obj);
1037 BufPtr =
new (&Buffer) TNorm(io);
1043 Result = BufPtr->denormalize(io);
1061 template <
typename TNorm,
typename TFinal>
1064 : io(i_o), Result(Obj) {
1066 BufPtr =
new (&Buffer) TNorm(io, Obj);
1068 else if (allocator) {
1069 BufPtr = allocator->
Allocate<TNorm>();
1070 new (BufPtr) TNorm(io);
1072 BufPtr =
new TNorm(io);
1081 Result = BufPtr->denormalize(io);
1092 TNorm *BufPtr =
nullptr;
1114 void *Ctxt =
nullptr,
1116 void *DiagHandlerCtxt =
nullptr);
1118 void *Ctxt =
nullptr,
1120 void *DiagHandlerCtxt =
nullptr);
1124 std::error_code
error();
1127 bool outputting()
override;
1129 void beginMapping()
override;
1130 void endMapping()
override;
1131 bool preflightKey(
const char *,
bool,
bool,
bool &,
void *&)
override;
1132 void postflightKey(
void *)
override;
1133 std::vector<StringRef> keys()
override;
1134 void beginFlowMapping()
override;
1135 void endFlowMapping()
override;
1136 unsigned beginSequence()
override;
1137 void endSequence()
override;
1138 bool preflightElement(
unsigned index,
void *&)
override;
1139 void postflightElement(
void *)
override;
1140 unsigned beginFlowSequence()
override;
1141 bool preflightFlowElement(
unsigned ,
void *&)
override;
1142 void postflightFlowElement(
void *)
override;
1143 void endFlowSequence()
override;
1144 void beginEnumScalar()
override;
1145 bool matchEnumScalar(
const char*,
bool)
override;
1146 bool matchEnumFallback()
override;
1147 void endEnumScalar()
override;
1148 bool beginBitSetScalar(
bool &)
override;
1149 bool bitSetMatch(
const char *,
bool )
override;
1150 void endBitSetScalar()
override;
1151 void scalarString(
StringRef &,
bool)
override;
1152 void blockScalarString(
StringRef &)
override;
1153 void setError(
const Twine &message)
override;
1154 bool canElideEmptySequence()
override;
1157 virtual void anchor();
1160 HNode(
Node *n) : _node(n) { }
1161 virtual ~HNode() =
default;
1163 static bool classof(
const HNode *) {
return true; }
1168 class EmptyHNode :
public HNode {
1169 void anchor()
override;
1172 EmptyHNode(
Node *n) : HNode(n) { }
1176 static bool classof(
const EmptyHNode *) {
return true; }
1179 class ScalarHNode :
public HNode {
1180 void anchor()
override;
1185 StringRef value()
const {
return _value; }
1187 static bool classof(
const HNode *n) {
1192 static bool classof(
const ScalarHNode *) {
return true; }
1198 class MapHNode :
public HNode {
1199 void anchor()
override;
1202 MapHNode(
Node *n) : HNode(n) { }
1204 static bool classof(
const HNode *n) {
1208 static bool classof(
const MapHNode *) {
return true; }
1216 class SequenceHNode :
public HNode {
1217 void anchor()
override;
1220 SequenceHNode(
Node *n) : HNode(n) { }
1222 static bool classof(
const HNode *n) {
1226 static bool classof(
const SequenceHNode *) {
return true; }
1228 std::vector<std::unique_ptr<HNode>> Entries;
1231 std::unique_ptr<Input::HNode> createHNodes(
Node *node);
1232 void setError(HNode *hnode,
const Twine &message);
1233 void setError(
Node *node,
const Twine &message);
1246 std::unique_ptr<llvm::yaml::Stream> Strm;
1247 std::unique_ptr<HNode> TopNode;
1251 std::vector<bool> BitValuesUsed;
1252 HNode *CurrentNode =
nullptr;
1253 bool ScalarMatchFound;
1276 bool preflightKey(
const char *key,
bool,
bool,
bool &,
void *&)
override;
1278 std::vector<StringRef>
keys()
override;
1311 void newLineCheck();
1312 void outputNewLine();
1329 int ColumnAtFlowStart = 0;
1330 int ColumnAtMapFlowStart = 0;
1331 bool NeedBitValueComma =
false;
1332 bool NeedFlowSequenceComma =
false;
1333 bool EnumerationMatchFound =
false;
1334 bool NeedsNewLine =
false;
1335 bool WriteDefaultValues =
false;
1346 #define LLVM_YAML_STRONG_TYPEDEF(_base, _type) \
1348 _type() = default; \
1349 _type(const _base v) : value(v) {} \
1350 _type(const _type &v) = default; \
1351 _type &operator=(const _type &rhs) = default; \
1352 _type &operator=(const _base &rhs) { value = rhs; return *this; } \
1353 operator const _base & () const { return value; } \
1354 bool operator==(const _type &rhs) const { return value == rhs.value; } \
1355 bool operator==(const _base &rhs) const { return value == rhs; } \
1356 bool operator<(const _type &rhs) const { return value < rhs.value; } \
1358 using BaseType = _base; \
1372 static void output(
const Hex8 &,
void *,
raw_ostream &);
1379 static void output(
const Hex16 &,
void *,
raw_ostream &);
1386 static void output(
const Hex32 &,
void *,
raw_ostream &);
1393 static void output(
const Hex64 &,
void *,
raw_ostream &);
1399 template <
typename T>
1401 typename std::enable_if<has_DocumentListTraits<T>::value, Input &>::type
1416 template <
typename T>
1417 inline typename std::enable_if<has_MappingTraits<T, EmptyContext>::value,
1422 yamlize(yin, docMap,
true, Ctx);
1428 template <
typename T>
1430 typename std::enable_if<has_SequenceTraits<T>::value, Input &>::type
1434 yamlize(yin, docSeq,
true, Ctx);
1439 template <
typename T>
1441 typename std::enable_if<has_BlockScalarTraits<T>::value, Input &>::type
1450 template <
typename T>
1452 typename std::enable_if<has_CustomMappingTraits<T>::value, Input &>::type
1461 template <
typename T>
1462 inline typename std::enable_if<missingTraits<T, EmptyContext>::value,
1470 template <
typename T>
1472 typename std::enable_if<has_DocumentListTraits<T>::value, Output &>::type
1477 for(
size_t i=0; i <
count; ++i) {
1489 template <
typename T>
1490 inline typename std::enable_if<has_MappingTraits<T, EmptyContext>::value,
1496 yamlize(yout, map,
true, Ctx);
1504 template <
typename T>
1506 typename std::enable_if<has_SequenceTraits<T>::value, Output &>::type
1511 yamlize(yout, seq,
true, Ctx);
1519 template <
typename T>
1521 typename std::enable_if<has_BlockScalarTraits<T>::value, Output &>::type
1534 template <
typename T>
1536 typename std::enable_if<has_CustomMappingTraits<T>::value, Output &>::type
1549 template <
typename T>
1550 inline typename std::enable_if<missingTraits<T, EmptyContext>::value,
1560 template <
typename T,
bool Flow>
1563 using type =
typename T::value_type;
1569 if (index >= seq.size())
1570 seq.resize(index + 1);
1581 template <
typename T>
1583 typename std::enable_if<CheckIsBool<
1584 SequenceElementTraits<T>::flow>::value>::type>
1586 template <
typename T,
unsigned N>
1588 typename std::enable_if<CheckIsBool<
1589 SequenceElementTraits<T>::flow>::value>::type>
1593 template <
typename T>
1595 T, typename std::enable_if<std::is_fundamental<T>::value>::type> {
1596 static const bool flow =
true;
1601 static const bool flow =
false;
1604 static const bool flow =
false;
1607 static const bool flow =
false;
1627 #define LLVM_YAML_IS_SEQUENCE_VECTOR_IMPL(TYPE, FLOW) \
1631 !std::is_fundamental<TYPE>::value && \
1632 !std::is_same<TYPE, std::string>::value && \
1633 !std::is_same<TYPE, llvm::StringRef>::value, \
1634 "only use LLVM_YAML_IS_SEQUENCE_VECTOR for types you control"); \
1635 template <> struct SequenceElementTraits<TYPE> { \
1636 static const bool flow = FLOW; \
1643 #define LLVM_YAML_IS_SEQUENCE_VECTOR(type) \
1644 LLVM_YAML_IS_SEQUENCE_VECTOR_IMPL(type, false)
1648 #define LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(type) \
1649 LLVM_YAML_IS_SEQUENCE_VECTOR_IMPL(type, true)
1651 #define LLVM_YAML_DECLARE_MAPPING_TRAITS(Type) \
1654 template <> struct MappingTraits<Type> { \
1655 static void mapping(IO &IO, Type &Obj); \
1660 #define LLVM_YAML_DECLARE_ENUM_TRAITS(Type) \
1663 template <> struct ScalarEnumerationTraits<Type> { \
1664 static void enumeration(IO &io, Type &Value); \
1669 #define LLVM_YAML_DECLARE_BITSET_TRAITS(Type) \
1672 template <> struct ScalarBitSetTraits<Type> { \
1673 static void bitset(IO &IO, Type &Options); \
1678 #define LLVM_YAML_DECLARE_SCALAR_TRAITS(Type, MustQuote) \
1681 template <> struct ScalarTraits<Type> { \
1682 static void output(const Type &Value, void *ctx, raw_ostream &Out); \
1683 static StringRef input(StringRef Scalar, void *ctxt, Type &Value); \
1684 static bool mustQuote(StringRef) { return MustQuote; } \
1691 #define LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(_type) \
1694 template <unsigned N> \
1695 struct DocumentListTraits<SmallVector<_type, N>> \
1696 : public SequenceTraitsImpl<SmallVector<_type, N>, false> {}; \
1698 struct DocumentListTraits<std::vector<_type>> \
1699 : public SequenceTraitsImpl<std::vector<_type>, false> {}; \
1705 #define LLVM_YAML_IS_STRING_MAP(_type) \
1709 struct CustomMappingTraits<std::map<std::string, _type>> \
1710 : public StdMapStringCustomMappingTraitsImpl<_type> {}; \
1714 #endif // LLVM_SUPPORT_YAMLTRAITS_H
static type & element(IO &io, T &seq, size_t index)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
static bool classof(const Node *N)
void setError(const Twine &message) override
static char test(SameType< Signature_input,&U::input > *, SameType< Signature_output,&U::output > *)
static bool mustQuote(StringRef)
static bool mustQuote(StringRef Str)
static void output(IO &io, map_type &v)
static char test(SameType< Signature_enumeration,&U::enumeration > *)
void bitSetCase(T &Val, const char *Str, const T ConstVal)
bool preflightElement(unsigned, void *&) override
bool preflightDocument(unsigned)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
static bool mustQuote(StringRef S)
void mapOptional(const char *Key, T &Val)
static bool mustQuote(StringRef)
virtual bool beginBitSetScalar(bool &)=0
void maskedBitSetCase(T &Val, const char *Str, T ConstVal, T Mask)
static char test(SameType< Signature_input,&U::input > *, SameType< Signature_output,&U::output > *, SameType< Signature_mustQuote,&U::mustQuote > *)
void(*)(const T &, void *, raw_ostream &) Signature_output
virtual bool preflightFlowElement(unsigned, void *&)=0
static bool mustQuote(StringRef)
size_t(*)(class IO &, T &) Signature_size
void beginMapping() override
virtual void endFlowMapping()=0
void(*)(class IO &, T &) Signature_enumeration
virtual void scalarString(StringRef &, bool)=0
void endFlowMapping() override
size_t(*)(class IO &, T &) Signature_size
void endSequence() override
void enumCase(T &Val, const char *Str, const uint32_t ConstVal)
virtual void endEnumScalar()=0
static char test(SameType< Signature_size,&U::size > *)
bool needsQuotes(StringRef S)
static bool mustQuote(StringRef)
static bool classof(const Node *N)
LLVM_NODISCARD char back() const
back - Get the last character in the string.
static char test(SameType< Signature_validate,&U::validate > *)
virtual void setError(const Twine &)=0
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
static void output(const endian_type &E, void *Ctx, raw_ostream &Stream)
virtual bool matchEnumFallback()=0
void(*)(IO &io, StringRef key, T &v) Signature_input
virtual void postflightElement(void *)=0
virtual unsigned beginSequence()=0
This class should be specialized by any type that needs to be converted to/from a YAML sequence...
void beginFlowMapping() override
static bool mustQuote(StringRef)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void postflightElement(void *) override
void maskedBitSetCase(T &Val, const char *Str, uint32_t ConstVal, uint32_t Mask)
static bool classof(const Node *N)
bool matchEnumScalar(const char *, bool) override
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
std::enable_if< has_SequenceTraits< T >::value, void >::type mapOptionalWithContext(const char *Key, T &Val, Context &Ctx)
virtual bool preflightElement(unsigned, void *&)=0
void scalarString(StringRef &, bool) override
bool matchEnumFallback() override
void enumFallback(T &Val)
bool beginBitSetScalar(bool &) override
static StringRef input(StringRef Str, void *Ctx, endian_type &E)
This class should be specialized by any type that needs to be converted to/from a YAML mapping...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
const T & getValue() const LLVM_LVALUE_FUNCTION
bool outputting() override
void bitSetCase(T &Val, const char *Str, const uint32_t ConstVal)
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(std::begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
LLVM_NODISCARD char front() const
front - Get the first character in the string.
std::vector< StringRef > keys() override
static bool mustQuote(StringRef)
std::enable_if< has_DocumentListTraits< T >::value, Output & >::type operator<<(Output &yout, T &docList)
virtual bool mapTag(StringRef Tag, bool Default=false)=0
bool mapTag(StringRef, bool) override
static bool classof(const Node *N)
static bool mustQuote(StringRef)
std::enable_if< has_DocumentListTraits< T >::value, Input & >::type operator>>(Input &yin, T &docList)
void endMapping() override
void enumCase(T &Val, const char *Str, const T ConstVal)
virtual void endFlowSequence()=0
void postflightDocument()
Allocate memory in an ever growing pool, as if by bump-pointer.
virtual void beginEnumScalar()=0
void postflightFlowElement(void *) override
This class should be specialized by any type that needs to be converted to/from a list of YAML docume...
static char test(SameType< Signature_input,&U::inputOne > *)
static bool mustQuote(StringRef)
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
This class is similar to MappingTraits<T> but allows you to pass in additional context for each map o...
This class should be specialized by any type that needs to be converted to/from a YAML mapping in the...
static bool mustQuote(StringRef)
virtual bool preflightKey(const char *, bool, bool, bool &, void *&)=0
virtual bool canElideEmptySequence()=0
static char test(SameType< Signature_mapping,&U::mapping > *)
void doMapping(IO &io, T &Val, Context &Ctx)
virtual void blockScalarString(StringRef &)=0
virtual void endBitSetScalar()=0
void endFlowSequence() override
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
bool preflightKey(const char *key, bool, bool, bool &, void *&) override
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
void(*)(const SMDiagnostic &, void *Context) DiagHandlerTy
Clients that want to handle their own diagnostics in a custom way can register a function pointer+con...
The Output class is used to generate a yaml document from in-memory structs and vectors.
LLVM_NODISCARD size_t find_first_not_of(char C, size_t From=0) const
Find the first character in the string that is not C or npos if not found.
StringRef(*)(StringRef, void *, T &) Signature_input
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
Output(raw_ostream &, void *Ctxt=nullptr, int WrapColumn=70)
void mapOptionalWithContext(const char *Key, T &Val, const T &Default, Context &Ctx)
virtual void beginMapping()=0
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
void setWriteDefaultValues(bool Write)
Set whether or not to output optional values which are equal to the default value.
MappingNormalization(IO &i_o, TFinal &Obj)
void(*)(const T &, void *, raw_ostream &) Signature_output
static bool mustQuote(StringRef)
StringRef(*)(class IO &, T &) Signature_validate
This class should be specialized by any integral type that converts to/from a YAML scalar where there...
bool(*)(StringRef) Signature_mustQuote
#define LLVM_YAML_STRONG_TYPEDEF(_base, _type)
YAML I/O does conversion based on types.
bool preflightFlowElement(unsigned, void *&) override
virtual std::vector< StringRef > keys()=0
MappingNormalizationHeap(IO &i_o, TFinal &Obj, BumpPtrAllocator *allocator)
static size_t size(IO &io, T &seq)
static void inputOne(IO &io, StringRef key, map_type &v)
This class represents a YAML stream potentially containing multiple documents.
virtual bool bitSetMatch(const char *, bool)=0
This class should be specialized by type that requires custom conversion to/from a yaml scalar...
void endBitSetScalar() override
bool bitSetMatch(const char *, bool) override
static bool mustQuote(StringRef)
iterator_range< detail::value_sequence_iterator< ValueT > > seq(ValueT Begin, ValueT End)
virtual void postflightKey(void *)=0
StringRef(*)(class IO &, T &, Context &) Signature_validate
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
virtual void beginFlowMapping()=0
static bool mustQuote(StringRef S)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
virtual unsigned beginFlowSequence()=0
unsigned beginFlowSequence() override
This class should be specialized by any type for which vectors of that type need to be converted to/f...
static char test(SameType< Signature_bitset,&U::bitset > *)
bool isNumber(StringRef S)
static bool classof(const Node *N)
This class should be specialized by type that requires custom conversion to/from a YAML literal block...
virtual void endMapping()=0
virtual void postflightFlowElement(void *)=0
std::enable_if< has_ScalarEnumerationTraits< T >::value, void >::type yamlize(IO &io, T &Val, bool, EmptyContext &Ctx)
virtual bool matchEnumScalar(const char *, bool)=0
void mapOptionalWithContext(const char *Key, Optional< T > &Val, Context &Ctx)
virtual bool outputting()=0
void(*)(class IO &, T &) Signature_mapping
~MappingNormalizationHeap()
This class should be specialized by any integer type that is a union of bit values and the YAML repre...
Iterator abstraction for Documents over a Stream.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool mustQuote(StringRef)
std::map< std::string, T > map_type
static bool mustQuote(StringRef)
static bool mustQuote(StringRef)
void mapOptional(const char *Key, T &Val, const T &Default)
A raw_ostream that writes to an std::string.
virtual void endSequence()=0
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
void beginEnumScalar() override
unsigned beginSequence() override
This class implements an extremely fast bulk output stream that can only output to a stream...
Implementation of CustomMappingTraits for std::map<std::string, T>.
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr)
matches - Match the regex against a given String.
void mapRequired(const char *Key, T &Val, Context &Ctx)
StringRef - Represent a constant reference to a string, i.e.
void mapRequired(const char *Key, T &Val)
std::enable_if<!has_SequenceTraits< T >::value, void >::type mapOptionalWithContext(const char *Key, T &Val, Context &Ctx)
void endEnumScalar() override
StringRef(*)(StringRef, void *, T &) Signature_input
void(*)(class IO &, T &) Signature_bitset
static bool mustQuote(StringRef)
void postflightKey(void *) override
void(*)(class IO &, T &, Context &) Signature_mapping
void blockScalarString(StringRef &) override
static char test(SameType< Signature_size,&U::size > *)
bool canElideEmptySequence() override
bool isNumeric(StringRef S)
Abstract base class for all Nodes.