9#ifndef LLVM_SUPPORT_YAMLTRAITS_H 10#define LLVM_SUPPORT_YAMLTRAITS_H 33#include <system_error> 49struct EmptyContext {};
85template <
class T,
class Context>
struct MappingContextTraits {
107template <
typename T,
typename Enable =
void>
struct ScalarEnumerationTraits {
123template <
typename T,
typename Enable =
void>
struct ScalarBitSetTraits {
149template <
typename T,
typename Enable =
void>
struct ScalarTraits {
180struct BlockScalarTraits {
216template <
typename T>
struct TaggedScalarTraits {
246template<
typename T,
typename EnableIf =
void>
247struct SequenceTraits {
259template<
typename T,
typename EnableIf =
void>
260struct SequenceElementTraits {
268struct DocumentListTraits {
278struct CustomMappingTraits {
300template <
typename T>
struct PolymorphicTraits {
314struct has_ScalarEnumerationTraits
316using Signature_enumeration = void (*)(
class IO&,
T&);
319staticchartest(SameType<Signature_enumeration, &U::enumeration>*);
322staticdoubletest(...);
324staticboolconstvalue =
325 (
sizeof(test<ScalarEnumerationTraits<T>>(
nullptr)) == 1);
330struct has_ScalarBitSetTraits
332using Signature_bitset = void (*)(
class IO&,
T&);
335staticchartest(SameType<Signature_bitset, &U::bitset>*);
338staticdoubletest(...);
340staticboolconstvalue = (
sizeof(test<ScalarBitSetTraits<T>>(
nullptr)) == 1);
345struct has_ScalarTraits
347using Signature_input = StringRef (*)(StringRef,
void*,
T&);
348using Signature_output = void (*)(
constT&,
void*, raw_ostream&);
349using Signature_mustQuote = QuotingType (*)(StringRef);
352staticchartest(SameType<Signature_input, &U::input> *,
353 SameType<Signature_output, &U::output> *,
354 SameType<Signature_mustQuote, &U::mustQuote> *);
357staticdoubletest(...);
359staticboolconstvalue =
360 (
sizeof(test<ScalarTraits<T>>(
nullptr,
nullptr,
nullptr)) == 1);
365struct has_BlockScalarTraits
367using Signature_input = StringRef (*)(StringRef,
void *,
T &);
368using Signature_output = void (*)(
constT &,
void *, raw_ostream &);
371staticchartest(SameType<Signature_input, &U::input> *,
372 SameType<Signature_output, &U::output> *);
375staticdoubletest(...);
377staticboolconstvalue =
378 (
sizeof(test<BlockScalarTraits<T>>(
nullptr,
nullptr)) == 1);
382template <
class T>
struct has_TaggedScalarTraits {
383using Signature_input = StringRef (*)(StringRef, StringRef,
void *,
T &);
384using Signature_output = void (*)(
constT &,
void *, raw_ostream &,
386using Signature_mustQuote = QuotingType (*)(
constT &, StringRef);
389staticchartest(SameType<Signature_input, &U::input> *,
390 SameType<Signature_output, &U::output> *,
391 SameType<Signature_mustQuote, &U::mustQuote> *);
393template <
typename U>
staticdoubletest(...);
395staticboolconstvalue =
396 (
sizeof(test<TaggedScalarTraits<T>>(
nullptr,
nullptr,
nullptr)) == 1);
400template <
class T,
class Context>
struct has_MappingTraits {
401using Signature_mapping = void (*)(
class IO &,
T &, Context &);
404staticchartest(SameType<Signature_mapping, &U::mapping>*);
407staticdoubletest(...);
409staticboolconstvalue =
410 (
sizeof(test<MappingContextTraits<T, Context>>(
nullptr)) == 1);
414template <
class T>
struct has_MappingTraits<
T, EmptyContext> {
415using Signature_mapping = void (*)(
class IO &,
T &);
418staticchartest(SameType<Signature_mapping, &U::mapping> *);
420template <
typename U>
staticdoubletest(...);
422staticboolconstvalue = (
sizeof(test<MappingTraits<T>>(
nullptr)) == 1);
426template <
class T,
class Context>
struct has_MappingValidateTraits {
427using Signature_validate = std::string (*)(
class IO &,
T &, Context &);
430staticchartest(SameType<Signature_validate, &U::validate>*);
433staticdoubletest(...);
435staticboolconstvalue =
436 (
sizeof(test<MappingContextTraits<T, Context>>(
nullptr)) == 1);
440template <
class T>
struct has_MappingValidateTraits<
T, EmptyContext> {
441using Signature_validate = std::string (*)(
class IO &,
T &);
444staticchartest(SameType<Signature_validate, &U::validate> *);
446template <
typename U>
staticdoubletest(...);
448staticboolconstvalue = (
sizeof(test<MappingTraits<T>>(
nullptr)) == 1);
452template <
class T,
class Context>
struct has_MappingEnumInputTraits {
453using Signature_validate = void (*)(
class IO &,
T &);
456staticchartest(SameType<Signature_validate, &U::enumInput> *);
458template <
typename U>
staticdoubletest(...);
460staticboolconstvalue =
461 (
sizeof(test<MappingContextTraits<T, Context>>(
nullptr)) == 1);
465template <
class T>
struct has_MappingEnumInputTraits<
T, EmptyContext> {
466using Signature_validate = void (*)(
class IO &,
T &);
469staticchartest(SameType<Signature_validate, &U::enumInput> *);
471template <
typename U>
staticdoubletest(...);
473staticboolconstvalue = (
sizeof(test<MappingTraits<T>>(
nullptr)) == 1);
478struct has_SequenceMethodTraits
480using Signature_size = size_t (*)(
class IO&,
T&);
483staticchartest(SameType<Signature_size, &U::size>*);
486staticdoubletest(...);
488staticboolconstvalue = (
sizeof(test<SequenceTraits<T>>(
nullptr)) == 1);
493struct has_CustomMappingTraits
495using Signature_input = void (*)(IO &io, StringRef key,
T &
v);
498staticchartest(SameType<Signature_input, &U::inputOne>*);
501staticdoubletest(...);
503staticboolconstvalue =
504 (
sizeof(test<CustomMappingTraits<T>>(
nullptr)) == 1);
510template <
typename T,
bool Enabled = std::is_
class_v<T>>
class has_FlowTraits {
512staticconstboolvalue =
false;
519struct has_FlowTraits<
T,
true>
525staticchar (&
f(SameType<bool Fallback::*, &C::flow>*))[1];
528staticchar (&
f(...))[2];
530staticboolconstvalue =
sizeof(f<Derived>(
nullptr)) == 2;
535struct has_SequenceTraits :
public std::integral_constant<bool,
536 has_SequenceMethodTraits<T>::value > { };
540struct has_DocumentListTraits
542using Signature_size = size_t (*)(
class IO &,
T &);
545staticchartest(SameType<Signature_size, &U::size>*);
548staticdoubletest(...);
550staticboolconstvalue = (
sizeof(test<DocumentListTraits<T>>(
nullptr))==1);
553template <
class T>
struct has_PolymorphicTraits {
554using Signature_getKind =
NodeKind (*)(
constT &);
557staticchartest(SameType<Signature_getKind, &U::getKind> *);
559template <
typename U>
staticdoubletest(...);
561staticboolconstvalue = (
sizeof(test<PolymorphicTraits<T>>(
nullptr)) == 1);
564inlinebool isNumeric(StringRef S) {
565constauto skipDigits = [](StringRef Input) {
566return Input.ltrim(
"0123456789");
571if (S.empty() || S ==
"+" || S ==
"-")
574if (S ==
".nan" || S ==
".NaN" || S ==
".NAN")
578 StringRef
Tail = (S.front() ==
'-' || S.front() ==
'+') ? S.drop_front() : S;
588if (S.starts_with(
"0o"))
589return S.size() > 2 &&
592if (S.starts_with(
"0x"))
593return S.size() > 2 && S.drop_front(2).find_first_not_of(
602if (S.starts_with(
".") &&
604 (S.size() > 1 && std::strchr(
"0123456789", S[1]) ==
nullptr)))
607if (S.starts_with(
"E") || S.starts_with(
"e"))
623if (S.front() ==
'.') {
626 }
elseif (S.front() ==
'e' || S.front() ==
'E') {
627 State = FoundExponent;
633if (State == FoundDot) {
638if (S.front() ==
'e' || S.front() ==
'E') {
639 State = FoundExponent;
646assert(State == FoundExponent &&
"Should have found exponent at this point.");
650if (S.front() ==
'+' || S.front() ==
'-') {
656return skipDigits(S).empty();
659inlinebool isNull(StringRef S) {
660return S ==
"null" || S ==
"Null" || S ==
"NULL" || S ==
"~";
663inlinebool isBool(StringRef S) {
665return S ==
"true" || S ==
"True" || S ==
"TRUE" || S ==
"false" ||
666 S ==
"False" || S ==
"FALSE";
678inline QuotingType needsQuotes(StringRef S,
bool ForcePreserveAsString =
true) {
680return QuotingType::Single;
682 QuotingType MaxQuotingNeeded = QuotingType::None;
683if (isSpace(
static_cast<unsignedchar>(S.front())) ||
684 isSpace(
static_cast<unsignedchar>(S.back())))
685 MaxQuotingNeeded = QuotingType::Single;
686if (ForcePreserveAsString) {
688 MaxQuotingNeeded = QuotingType::Single;
690 MaxQuotingNeeded = QuotingType::Single;
692 MaxQuotingNeeded = QuotingType::Single;
698if (std::strchr(R
"(-?:\,[]{}#&*!|>'"%@`)", S[0]) != nullptr)
699 MaxQuotingNeeded = QuotingType::Single;
701for (
unsignedcharC : S) {
722return QuotingType::Double;
725return QuotingType::Double;
736return QuotingType::Double;
740return QuotingType::Double;
743 MaxQuotingNeeded = QuotingType::Single;
748return MaxQuotingNeeded;
751template <
typename T,
typename Context>
753 :
public std::integral_constant<bool,
754 !has_ScalarEnumerationTraits<T>::value &&
755 !has_ScalarBitSetTraits<T>::value &&
756 !has_ScalarTraits<T>::value &&
757 !has_BlockScalarTraits<T>::value &&
758 !has_TaggedScalarTraits<T>::value &&
759 !has_MappingTraits<T, Context>::value &&
760 !has_SequenceTraits<T>::value &&
761 !has_CustomMappingTraits<T>::value &&
762 !has_DocumentListTraits<T>::value &&
763 !has_PolymorphicTraits<T>::value> {};
765template <
typename T,
typename Context>
766struct validatedMappingTraits
767 :
public std::integral_constant<
768 bool, has_MappingTraits<T, Context>::value &&
769 has_MappingValidateTraits<T, Context>::value> {};
771template <
typename T,
typename Context>
772struct unvalidatedMappingTraits
773 :
public std::integral_constant<
774 bool, has_MappingTraits<T, Context>::value &&
775 !has_MappingValidateTraits<T, Context>::value> {};
780 IO(
void *Ctxt =
nullptr);
783virtualbool outputting()
const = 0;
785virtualunsigned beginSequence() = 0;
786virtualbool preflightElement(
unsigned,
void *&) = 0;
787virtualvoid postflightElement(
void*) = 0;
788virtualvoid endSequence() = 0;
789virtualbool canElideEmptySequence() = 0;
791virtualunsigned beginFlowSequence() = 0;
792virtualbool preflightFlowElement(
unsigned,
void *&) = 0;
793virtualvoid postflightFlowElement(
void*) = 0;
794virtualvoid endFlowSequence() = 0;
796virtualbool mapTag(StringRef Tag,
boolDefault=
false) = 0;
797virtualvoid beginMapping() = 0;
798virtualvoid endMapping() = 0;
799virtualbool preflightKey(
constchar*,
bool,
bool,
bool &,
void *&) = 0;
800virtualvoid postflightKey(
void*) = 0;
801virtual std::vector<StringRef> keys() = 0;
803virtualvoid beginFlowMapping() = 0;
804virtualvoid endFlowMapping() = 0;
806virtualvoid beginEnumScalar() = 0;
807virtualbool matchEnumScalar(
constchar*,
bool) = 0;
808virtualbool matchEnumFallback() = 0;
809virtualvoid endEnumScalar() = 0;
811virtualbool beginBitSetScalar(
bool &) = 0;
812virtualbool bitSetMatch(
constchar*,
bool) = 0;
813virtualvoid endBitSetScalar() = 0;
815virtualvoid scalarString(StringRef &, QuotingType) = 0;
816virtualvoid blockScalarString(StringRef &) = 0;
817virtualvoid scalarTag(std::string &) = 0;
821virtualvoid setError(
const Twine &) = 0;
822virtualvoid setAllowUnknownKeys(
bool Allow);
825void enumCase(
T &Val,
constchar* Str,
constT ConstVal) {
826if ( matchEnumScalar(Str, outputting() && Val == ConstVal) ) {
833void enumCase(
T &Val,
constchar* Str,
constuint32_t ConstVal) {
834if ( matchEnumScalar(Str, outputting() && Val ==
static_cast<T>(ConstVal)) ) {
839template <
typename FBT,
typename T>
840void enumFallback(
T &Val) {
841if (matchEnumFallback()) {
842 EmptyContext Context;
844 FBT Res =
static_cast<typename FBT::BaseType
>(Val);
845 yamlize(*
this, Res,
true, Context);
846 Val =
static_cast<T>(
static_cast<typename FBT::BaseType
>(Res));
851void bitSetCase(
T &Val,
constchar* Str,
constT ConstVal) {
852if ( bitSetMatch(Str, outputting() && (Val & ConstVal) == ConstVal) ) {
853 Val =
static_cast<T>(Val | ConstVal);
859void bitSetCase(
T &Val,
constchar* Str,
constuint32_t ConstVal) {
860if ( bitSetMatch(Str, outputting() && (Val & ConstVal) == ConstVal) ) {
861 Val =
static_cast<T>(Val | ConstVal);
866void maskedBitSetCase(
T &Val,
constchar *Str,
T ConstVal,
T Mask) {
867if (bitSetMatch(Str, outputting() && (Val & Mask) == ConstVal))
868 Val = Val | ConstVal;
872void maskedBitSetCase(
T &Val,
constchar *Str,
uint32_t ConstVal,
874if (bitSetMatch(Str, outputting() && (Val & Mask) == ConstVal))
875 Val = Val | ConstVal;
878void *getContext()
const;
879void setContext(
void *);
881template <
typename T>
void mapRequired(
constchar *Key,
T &Val) {
883 this->processKey(Key, Val,
true, Ctx);
886template <
typename T,
typename Context>
887void mapRequired(
constchar *Key,
T &Val, Context &Ctx) {
888 this->processKey(Key, Val,
true, Ctx);
891template <
typename T>
voidmapOptional(
constchar *Key,
T &Val) {
893 mapOptionalWithContext(Key, Val, Ctx);
896template <
typename T,
typename DefaultT>
899 mapOptionalWithContext(Key, Val,
Default, Ctx);
902template <
typename T,
typename Context>
903 std::enable_if_t<has_SequenceTraits<T>::value,
void>
904 mapOptionalWithContext(
constchar *Key,
T &Val, Context &Ctx) {
906if (this->canElideEmptySequence() && !(Val.begin() != Val.end()))
908 this->processKey(Key, Val,
false, Ctx);
911template <
typename T,
typename Context>
912void mapOptionalWithContext(
constchar *Key, std::optional<T> &Val,
914 this->processKeyWithDefault(Key, Val, std::optional<T>(),
918template <
typename T,
typename Context>
919 std::enable_if_t<!has_SequenceTraits<T>::value,
void>
920 mapOptionalWithContext(
constchar *Key,
T &Val, Context &Ctx) {
921 this->processKey(Key, Val,
false, Ctx);
924template <
typename T,
typename Context,
typename DefaultT>
925void mapOptionalWithContext(
constchar *Key,
T &Val,
const DefaultT &
Default,
927static_assert(std::is_convertible<DefaultT, T>::value,
928"Default type must be implicitly convertible to value type!");
929 this->processKeyWithDefault(Key, Val,
static_cast<const T &
>(
Default),
934template <
typename T,
typename Context>
935void processKeyWithDefault(
constchar *Key, std::optional<T> &Val,
936const std::optional<T> &DefaultValue,
937bool Required, Context &Ctx);
939template <
typename T,
typename Context>
940void processKeyWithDefault(
constchar *Key,
T &Val,
constT &DefaultValue,
941bool Required, Context &Ctx) {
944constbool sameAsDefault = outputting() && Val == DefaultValue;
945if ( this->preflightKey(Key, Required, sameAsDefault, UseDefault,
947 yamlize(*
this, Val, Required, Ctx);
948 this->postflightKey(SaveInfo);
956template <
typename T,
typename Context>
957void processKey(
constchar *Key,
T &Val,
bool Required, Context &Ctx) {
960if ( this->preflightKey(Key, Required,
false, UseDefault, SaveInfo) ) {
961 yamlize(*
this, Val, Required, Ctx);
962 this->postflightKey(SaveInfo);
972template <
typename T,
typename Context>
973void doMapping(IO &io,
T &Val, Context &Ctx) {
974 MappingContextTraits<T, Context>::mapping(io, Val, Ctx);
977template <
typename T>
void doMapping(IO &io,
T &Val, EmptyContext &Ctx) {
978 MappingTraits<T>::mapping(io, Val);
984std::enable_if_t<has_ScalarEnumerationTraits<T>::value,
void>
985yamlize(IO &io,
T &Val,
bool, EmptyContext &Ctx) {
986 io.beginEnumScalar();
987 ScalarEnumerationTraits<T>::enumeration(io, Val);
992std::enable_if_t<has_ScalarBitSetTraits<T>::value,
void>
993yamlize(IO &io,
T &Val,
bool, EmptyContext &Ctx) {
995if ( io.beginBitSetScalar(DoClear) ) {
998 ScalarBitSetTraits<T>::bitset(io, Val);
999 io.endBitSetScalar();
1003template <
typename T>
1004std::enable_if_t<has_ScalarTraits<T>::value,
void> yamlize(IO &io,
T &Val,
bool,
1005 EmptyContext &Ctx) {
1006if ( io.outputting() ) {
1007 SmallString<128> Storage;
1008 raw_svector_ostream Buffer(Storage);
1009 ScalarTraits<T>::output(Val, io.getContext(), Buffer);
1010 StringRef Str = Buffer.str();
1011 io.scalarString(Str, ScalarTraits<T>::mustQuote(Str));
1015 io.scalarString(Str, ScalarTraits<T>::mustQuote(Str));
1016 StringRef
Result = ScalarTraits<T>::input(Str, io.getContext(), Val);
1018 io.setError(Twine(Result));
1023template <
typename T>
1024std::enable_if_t<has_BlockScalarTraits<T>::value,
void>
1025yamlize(IO &
YamlIO,
T &Val,
bool, EmptyContext &Ctx) {
1026if (
YamlIO.outputting()) {
1027 std::string Storage;
1028 raw_string_ostream Buffer(Storage);
1029 BlockScalarTraits<T>::output(Val,
YamlIO.getContext(), Buffer);
1030 StringRef Str(Storage);
1031YamlIO.blockScalarString(Str);
1034YamlIO.blockScalarString(Str);
1036 BlockScalarTraits<T>::input(Str,
YamlIO.getContext(), Val);
1038YamlIO.setError(Twine(Result));
1042template <
typename T>
1043std::enable_if_t<has_TaggedScalarTraits<T>::value,
void>
1044yamlize(IO &io,
T &Val,
bool, EmptyContext &Ctx) {
1045if (io.outputting()) {
1046 std::string ScalarStorage, TagStorage;
1047 raw_string_ostream ScalarBuffer(ScalarStorage), TagBuffer(TagStorage);
1048 TaggedScalarTraits<T>::output(Val, io.getContext(), ScalarBuffer,
1050 io.scalarTag(TagStorage);
1051 StringRef ScalarStr(ScalarStorage);
1052 io.scalarString(ScalarStr,
1053 TaggedScalarTraits<T>::mustQuote(Val, ScalarStr));
1058 io.scalarString(Str, QuotingType::None);
1060 TaggedScalarTraits<T>::input(Str,
Tag, io.getContext(), Val);
1062 io.setError(Twine(Result));
1069template <
typename T,
typename Context>
1070std::string doValidate(IO &io,
T &Val, Context &Ctx) {
1071return MappingContextTraits<T, Context>::validate(io, Val, Ctx);
1074template <
typename T> std::string doValidate(IO &io,
T &Val, EmptyContext &) {
1075return MappingTraits<T>::validate(io, Val);
1080template <
typename T,
typename Context>
1081std::enable_if_t<validatedMappingTraits<T, Context>::value,
void>
1082yamlize(IO &io,
T &Val,
bool, Context &Ctx) {
1083if (has_FlowTraits<MappingTraits<T>>
::value)
1084 io.beginFlowMapping();
1087if (io.outputting()) {
1088 std::string Err = detail::doValidate(io, Val, Ctx);
1090errs() << Err <<
"\n";
1091assert(Err.empty() &&
"invalid struct trying to be written as yaml");
1094 detail::doMapping(io, Val, Ctx);
1095if (!io.outputting()) {
1096 std::string Err = detail::doValidate(io, Val, Ctx);
1100if (has_FlowTraits<MappingTraits<T>>
::value)
1101 io.endFlowMapping();
1106template <
typename T,
typename Context>
1107std::enable_if_t<!has_MappingEnumInputTraits<T, Context>::value,
bool>
1108yamlizeMappingEnumInput(IO &io,
T &Val) {
1112template <
typename T,
typename Context>
1113std::enable_if_t<has_MappingEnumInputTraits<T, Context>::value,
bool>
1114yamlizeMappingEnumInput(IO &io,
T &Val) {
1118 io.beginEnumScalar();
1119 MappingTraits<T>::enumInput(io, Val);
1120bool Matched = !io.matchEnumFallback();
1125template <
typename T,
typename Context>
1126std::enable_if_t<unvalidatedMappingTraits<T, Context>::value,
void>
1127yamlize(IO &io,
T &Val,
bool, Context &Ctx) {
1128if (yamlizeMappingEnumInput<T, Context>(io, Val))
1130if (has_FlowTraits<MappingTraits<T>>
::value) {
1131 io.beginFlowMapping();
1132 detail::doMapping(io, Val, Ctx);
1133 io.endFlowMapping();
1136 detail::doMapping(io, Val, Ctx);
1141template <
typename T>
1142std::enable_if_t<has_CustomMappingTraits<T>::value,
void>
1143yamlize(IO &io,
T &Val,
bool, EmptyContext &Ctx) {
1144if ( io.outputting() ) {
1146 CustomMappingTraits<T>::output(io, Val);
1150for (StringRef key : io.keys())
1151 CustomMappingTraits<T>::inputOne(io, key, Val);
1156template <
typename T>
1157std::enable_if_t<has_PolymorphicTraits<T>::value,
void>
1158yamlize(IO &io,
T &Val,
bool, EmptyContext &Ctx) {
1159switch (io.outputting() ? PolymorphicTraits<T>::getKind(Val)
1160 : io.getNodeKind()) {
1161case NodeKind::Scalar:
1162return yamlize(io, PolymorphicTraits<T>::getAsScalar(Val),
true, Ctx);
1164return yamlize(io, PolymorphicTraits<T>::getAsMap(Val),
true, Ctx);
1165case NodeKind::Sequence:
1166return yamlize(io, PolymorphicTraits<T>::getAsSequence(Val),
true, Ctx);
1170template <
typename T>
1171std::enable_if_t<missingTraits<T, EmptyContext>::value,
void>
1172yamlize(IO &io,
T &Val,
bool, EmptyContext &Ctx) {
1173char missing_yaml_trait_for_type[
sizeof(MissingTrait<T>)];
1176template <
typename T,
typename Context>
1177std::enable_if_t<has_SequenceTraits<T>::value,
void>
1178yamlize(IO &io,
T &Seq,
bool, Context &Ctx) {
1179if ( has_FlowTraits< SequenceTraits<T>>
::value ) {
1180unsigned incnt = io.beginFlowSequence();
1181unsignedcount = io.outputting() ? SequenceTraits<T>::size(io, Seq) : incnt;
1182for(
unsigned i=0; i <
count; ++i) {
1184if ( io.preflightFlowElement(i, SaveInfo) ) {
1185 yamlize(io, SequenceTraits<T>::element(io, Seq, i),
true, Ctx);
1186 io.postflightFlowElement(SaveInfo);
1189 io.endFlowSequence();
1192unsigned incnt = io.beginSequence();
1193unsignedcount = io.outputting() ? SequenceTraits<T>::size(io, Seq) : incnt;
1194for(
unsigned i=0; i <
count; ++i) {
1196if ( io.preflightElement(i, SaveInfo) ) {
1197 yamlize(io, SequenceTraits<T>::element(io, Seq, i),
true, Ctx);
1198 io.postflightElement(SaveInfo);
1206struct ScalarTraits<
bool> {
1207staticvoid output(
constbool &,
void* , raw_ostream &);
1208static StringRef input(StringRef,
void *,
bool &);
1209static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1213struct ScalarTraits<StringRef> {
1214staticvoid output(
const StringRef &,
void *, raw_ostream &);
1215static StringRef input(StringRef,
void *, StringRef &);
1216static QuotingType mustQuote(StringRef S) {
return needsQuotes(S); }
1221staticvoid output(
const std::string &,
void *, raw_ostream &);
1222static StringRef input(StringRef,
void *, std::string &);
1223static QuotingType mustQuote(StringRef S) {
return needsQuotes(S); }
1228staticvoid output(
constuint8_t &,
void *, raw_ostream &);
1229static StringRef input(StringRef,
void *,
uint8_t &);
1230static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1235staticvoid output(
constuint16_t &,
void *, raw_ostream &);
1236static StringRef input(StringRef,
void *,
uint16_t &);
1237static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1242staticvoid output(
constuint32_t &,
void *, raw_ostream &);
1243static StringRef input(StringRef,
void *,
uint32_t &);
1244static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1249staticvoid output(
constuint64_t &,
void *, raw_ostream &);
1250static StringRef input(StringRef,
void *,
uint64_t &);
1251static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1255struct ScalarTraits<int8_t> {
1256staticvoid output(
const int8_t &,
void *, raw_ostream &);
1257static StringRef input(StringRef,
void *, int8_t &);
1258static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1262struct ScalarTraits<int16_t> {
1263staticvoid output(
const int16_t &,
void *, raw_ostream &);
1264static StringRef input(StringRef,
void *, int16_t &);
1265static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1269struct ScalarTraits<int32_t> {
1270staticvoid output(
const int32_t &,
void *, raw_ostream &);
1271static StringRef input(StringRef,
void *, int32_t &);
1272static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1276struct ScalarTraits<int64_t> {
1277staticvoid output(
const int64_t &,
void *, raw_ostream &);
1278static StringRef input(StringRef,
void *, int64_t &);
1279static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1283struct ScalarTraits<float> {
1284staticvoid output(
constfloat &,
void *, raw_ostream &);
1285static StringRef input(StringRef,
void *,
float &);
1286static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1290struct ScalarTraits<double> {
1291staticvoid output(
constdouble &,
void *, raw_ostream &);
1292static StringRef input(StringRef,
void *,
double &);
1293static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1299template <
typename value_type, llvm::endianness endian,
size_t alignment>
1300struct ScalarTraits<support::detail::packed_endian_specific_integral<
1301 value_type, endian, alignment>,
1302 std::enable_if_t<has_ScalarTraits<value_type>::value>> {
1304 support::detail::packed_endian_specific_integral<value_type,
endian,
1307staticvoid output(
const endian_type &
E,
void *Ctx, raw_ostream &Stream) {
1308 ScalarTraits<value_type>::output(
static_cast<value_type
>(
E), Ctx, Stream);
1311static StringRef input(StringRef Str,
void *Ctx, endian_type &
E) {
1313autoR = ScalarTraits<value_type>::input(Str, Ctx, V);
1314E =
static_cast<endian_type
>(
V);
1318static QuotingType mustQuote(StringRef Str) {
1319return ScalarTraits<value_type>::mustQuote(Str);
1323template <
typename value_type, llvm::endianness endian,
size_t alignment>
1324struct ScalarEnumerationTraits<
1325 support::detail::packed_endian_specific_integral<value_type, endian,
1327 std::enable_if_t<has_ScalarEnumerationTraits<value_type>::value>> {
1329 support::detail::packed_endian_specific_integral<value_type,
endian,
1332staticvoid enumeration(IO &io, endian_type &
E) {
1334 ScalarEnumerationTraits<value_type>::enumeration(io, V);
1339template <
typename value_type, llvm::endianness endian,
size_t alignment>
1340struct ScalarBitSetTraits<
1341 support::detail::packed_endian_specific_integral<value_type, endian,
1343 std::enable_if_t<has_ScalarBitSetTraits<value_type>::value>> {
1345 support::detail::packed_endian_specific_integral<value_type,
endian,
1347staticvoid bitset(IO &io, endian_type &
E) {
1349 ScalarBitSetTraits<value_type>::bitset(io, V);
1356template <
typename TNorm,
typename TFinal>
1357struct MappingNormalization {
1358 MappingNormalization(IO &i_o, TFinal &Obj)
1359 : io(i_o), BufPtr(nullptr),
Result(Obj) {
1360if ( io.outputting() ) {
1361 BufPtr =
new (&Buffer) TNorm(io, Obj);
1364 BufPtr =
new (&Buffer) TNorm(io);
1368 ~MappingNormalization() {
1369if ( ! io.outputting() ) {
1370Result = BufPtr->denormalize(io);
1375 TNorm* operator->() {
return BufPtr; }
1378using Storage = AlignedCharArrayUnion<TNorm>;
1388template <
typename TNorm,
typename TFinal>
1389struct MappingNormalizationHeap {
1390 MappingNormalizationHeap(IO &i_o, TFinal &Obj, BumpPtrAllocator *
allocator)
1392if ( io.outputting() ) {
1393 BufPtr =
new (&Buffer) TNorm(io, Obj);
1397new (BufPtr) TNorm(io);
1399 BufPtr =
new TNorm(io);
1403 ~MappingNormalizationHeap() {
1404if ( io.outputting() ) {
1408Result = BufPtr->denormalize(io);
1412 TNorm* operator->() {
return BufPtr; }
1415using Storage = AlignedCharArrayUnion<TNorm>;
1419 TNorm *BufPtr =
nullptr;
1435class Input :
public IO {
1440 Input(StringRef InputContent,
1441void *Ctxt =
nullptr,
1443void *DiagHandlerCtxt =
nullptr);
1444 Input(MemoryBufferRef Input,
1445void *Ctxt =
nullptr,
1447void *DiagHandlerCtxt =
nullptr);
1451 std::error_code
error();
1454bool outputting()
const override;
1455bool mapTag(StringRef,
bool)
override;
1456void beginMapping()
override;
1457void endMapping()
override;
1458bool preflightKey(
constchar *,
bool,
bool,
bool &,
void *&)
override;
1459void postflightKey(
void *)
override;
1460 std::vector<StringRef> keys()
override;
1461void beginFlowMapping()
override;
1462void endFlowMapping()
override;
1463unsigned beginSequence()
override;
1464void endSequence()
override;
1465bool preflightElement(
unsigned index,
void *&)
override;
1466void postflightElement(
void *)
override;
1467unsigned beginFlowSequence()
override;
1468bool preflightFlowElement(
unsigned ,
void *&)
override;
1469void postflightFlowElement(
void *)
override;
1470void endFlowSequence()
override;
1471void beginEnumScalar()
override;
1472bool matchEnumScalar(
constchar*,
bool)
override;
1473bool matchEnumFallback()
override;
1474void endEnumScalar()
override;
1475bool beginBitSetScalar(
bool &)
override;
1476bool bitSetMatch(
constchar *,
bool )
override;
1477void endBitSetScalar()
override;
1478void scalarString(StringRef &, QuotingType)
override;
1479void blockScalarString(StringRef &)
override;
1480void scalarTag(std::string &)
override;
1482void setError(
const Twine &message)
override;
1483bool canElideEmptySequence()
override;
1487 HNode(
Node *n) : _node(n) {}
1489staticbool classof(
const HNode *) {
returntrue; }
1494class EmptyHNode :
public HNode {
1496 EmptyHNode(
Node *n) : HNode(n) { }
1498staticbool classof(
const HNode *n) {
return NullNode::classof(n->_node); }
1500staticbool classof(
const EmptyHNode *) {
returntrue; }
1503class ScalarHNode :
public HNode {
1505 ScalarHNode(
Node *n, StringRef s) : HNode(n), _value(s) { }
1507 StringRef
value()
const {
return _value; }
1509staticbool classof(
const HNode *n) {
1510return ScalarNode::classof(n->_node) ||
1511 BlockScalarNode::classof(n->_node);
1514staticbool classof(
const ScalarHNode *) {
returntrue; }
1520class MapHNode :
public HNode {
1522 MapHNode(
Node *n) : HNode(n) { }
1524staticbool classof(
const HNode *n) {
1525return MappingNode::classof(n->_node);
1528staticbool classof(
const MapHNode *) {
returntrue; }
1530using NameToNodeAndLoc = StringMap<std::pair<HNode *, SMRange>>;
1532 NameToNodeAndLoc Mapping;
1533 SmallVector<std::string, 6> ValidKeys;
1536class SequenceHNode :
public HNode {
1538 SequenceHNode(
Node *n) : HNode(n) { }
1540staticbool classof(
const HNode *n) {
1541return SequenceNode::classof(n->_node);
1544staticbool classof(
const SequenceHNode *) {
returntrue; }
1546 std::vector<HNode *> Entries;
1549 Input::HNode *createHNodes(
Node *node);
1550void setError(HNode *hnode,
const Twine &message);
1551void setError(
Node *node,
const Twine &message);
1552void setError(
const SMRange &
Range,
const Twine &message);
1554void reportWarning(HNode *hnode,
const Twine &message);
1555void reportWarning(
Node *hnode,
const Twine &message);
1556void reportWarning(
const SMRange &
Range,
const Twine &message);
1559void releaseHNodeBuffers();
1564bool setCurrentDocument();
1568constNode *getCurrentNode()
const;
1570void setAllowUnknownKeys(
bool Allow)
override;
1574 std::unique_ptr<llvm::yaml::Stream> Strm;
1575 HNode *TopNode =
nullptr;
1578 SpecificBumpPtrAllocator<EmptyHNode> EmptyHNodeAllocator;
1579 SpecificBumpPtrAllocator<ScalarHNode> ScalarHNodeAllocator;
1580 SpecificBumpPtrAllocator<MapHNode> MapHNodeAllocator;
1581 SpecificBumpPtrAllocator<SequenceHNode> SequenceHNodeAllocator;
1582 document_iterator DocIterator;
1584 HNode *CurrentNode =
nullptr;
1585bool ScalarMatchFound =
false;
1586bool AllowUnknownKeys =
false;
1593class Output :
public IO {
1595 Output(raw_ostream &,
void *Ctxt =
nullptr,
int WrapColumn = 70);
1603void setWriteDefaultValues(
bool Write) { WriteDefaultValues =
Write; }
1605bool outputting()
const override;
1606bool mapTag(StringRef,
bool)
override;
1607void beginMapping()
override;
1608void endMapping()
override;
1609bool preflightKey(
constchar *key,
bool,
bool,
bool &,
void *&)
override;
1610void postflightKey(
void *)
override;
1611 std::vector<StringRef> keys()
override;
1612void beginFlowMapping()
override;
1613void endFlowMapping()
override;
1614unsigned beginSequence()
override;
1615void endSequence()
override;
1616bool preflightElement(
unsigned,
void *&)
override;
1617void postflightElement(
void *)
override;
1618unsigned beginFlowSequence()
override;
1619bool preflightFlowElement(
unsigned,
void *&)
override;
1620void postflightFlowElement(
void *)
override;
1621void endFlowSequence()
override;
1622void beginEnumScalar()
override;
1623bool matchEnumScalar(
constchar*,
bool)
override;
1624bool matchEnumFallback()
override;
1625void endEnumScalar()
override;
1626bool beginBitSetScalar(
bool &)
override;
1627bool bitSetMatch(
constchar *,
bool )
override;
1628void endBitSetScalar()
override;
1629void scalarString(StringRef &, QuotingType)
override;
1630void blockScalarString(StringRef &)
override;
1631void scalarTag(std::string &)
override;
1633void setError(
const Twine &message)
override;
1634bool canElideEmptySequence()
override;
1638void beginDocuments();
1639bool preflightDocument(
unsigned);
1640void postflightDocument();
1644void output(StringRef s);
1645void output(StringRef, QuotingType);
1646void outputUpToEndOfLine(StringRef s);
1647void newLineCheck(
bool EmptySequence =
false);
1648void outputNewLine();
1649void paddedKey(StringRef key);
1650void flowKey(StringRef Key);
1655 inFlowSeqFirstElement,
1656 inFlowSeqOtherElement,
1663staticbool inSeqAnyElement(InState State);
1664staticbool inFlowSeqAnyElement(InState State);
1665staticbool inMapAnyKey(InState State);
1666staticbool inFlowMapAnyKey(InState State);
1670 SmallVector<InState, 8> StateStack;
1672int ColumnAtFlowStart = 0;
1673int ColumnAtMapFlowStart = 0;
1674bool NeedBitValueComma =
false;
1675bool NeedFlowSequenceComma =
false;
1676bool EnumerationMatchFound =
false;
1677bool WriteDefaultValues =
false;
1679 StringRef PaddingBeforeContainer;
1682template <
typename T,
typename Context>
1683void IO::processKeyWithDefault(
constchar *Key, std::optional<T> &Val,
1684const std::optional<T> &DefaultValue,
1685bool Required, Context &Ctx) {
1686assert(!DefaultValue &&
"std::optional<T> shouldn't have a value!");
1688bool UseDefault =
true;
1689constbool sameAsDefault = outputting() && !Val;
1690if (!outputting() && !Val)
1693 this->preflightKey(Key, Required, sameAsDefault, UseDefault, SaveInfo)) {
1701if (
constauto *
Node =
1702 dyn_cast<ScalarNode>(((Input *)
this)->getCurrentNode()))
1705 IsNone =
Node->getRawValue().rtrim(
' ') ==
"<none>";
1710 yamlize(*
this, *Val, Required, Ctx);
1711 this->postflightKey(SaveInfo);
1726#define LLVM_YAML_STRONG_TYPEDEF(_base, _type) \ 1728 _type() = default; \ 1729 _type(const _base v) : value(v) {} \ 1730 _type(const _type &v) = default; \ 1731 _type &operator=(const _type &rhs) = default; \ 1732 _type &operator=(const _base &rhs) { value = rhs; return *this; } \ 1733 operator const _base & () const { return value; } \ 1734 bool operator==(const _type &rhs) const { return value == rhs.value; } \ 1735 bool operator==(const _base &rhs) const { return value == rhs; } \ 1736 bool operator<(const _type &rhs) const { return value < rhs.value; } \ 1738 using BaseType = _base; \ 1751struct ScalarTraits<Hex8> {
1752staticvoid output(
const Hex8 &,
void *, raw_ostream &);
1753static StringRef input(StringRef,
void *, Hex8 &);
1754static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1758struct ScalarTraits<Hex16> {
1759staticvoid output(
const Hex16 &,
void *, raw_ostream &);
1760static StringRef input(StringRef,
void *, Hex16 &);
1761static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1765struct ScalarTraits<Hex32> {
1766staticvoid output(
const Hex32 &,
void *, raw_ostream &);
1767static StringRef input(StringRef,
void *, Hex32 &);
1768static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1772struct ScalarTraits<Hex64> {
1773staticvoid output(
const Hex64 &,
void *, raw_ostream &);
1774static StringRef input(StringRef,
void *, Hex64 &);
1775static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1778template <>
struct ScalarTraits<VersionTuple> {
1780static StringRef input(StringRef,
void *, VersionTuple &);
1781static QuotingType mustQuote(StringRef) {
return QuotingType::None; }
1785template <
typename T>
1786inline std::enable_if_t<has_DocumentListTraits<T>::value, Input &>
1790while ( yin.setCurrentDocument() ) {
1791 yamlize(yin, DocumentListTraits<T>::element(yin, docList, i),
true, Ctx);
1801template <
typename T>
1802inline std::enable_if_t<has_MappingTraits<T, EmptyContext>::value, Input &>
1805 yin.setCurrentDocument();
1806 yamlize(yin, docMap,
true, Ctx);
1812template <
typename T>
1813inline std::enable_if_t<has_SequenceTraits<T>::value, Input &>
1816if (yin.setCurrentDocument())
1817 yamlize(yin, docSeq,
true, Ctx);
1822template <
typename T>
1823inline std::enable_if_t<has_BlockScalarTraits<T>::value, Input &>
1826if (
In.setCurrentDocument())
1827 yamlize(In, Val,
true, Ctx);
1832template <
typename T>
1833inline std::enable_if_t<has_CustomMappingTraits<T>::value, Input &>
1836if (
In.setCurrentDocument())
1837 yamlize(In, Val,
true, Ctx);
1842template <
typename T>
1843inline std::enable_if_t<has_PolymorphicTraits<T>::value, Input &>
1846if (
In.setCurrentDocument())
1847 yamlize(In, Val,
true, Ctx);
1852template <
typename T>
1853inline std::enable_if_t<missingTraits<T, EmptyContext>::value, Input &>
1855char missing_yaml_trait_for_type[
sizeof(MissingTrait<T>)];
1860template <
typename T>
1861inline std::enable_if_t<has_DocumentListTraits<T>::value, Output &>
1864 yout.beginDocuments();
1865constsize_tcount = DocumentListTraits<T>::size(yout, docList);
1866for(
size_t i=0; i <
count; ++i) {
1867if ( yout.preflightDocument(i) ) {
1868 yamlize(yout, DocumentListTraits<T>::element(yout, docList, i),
true,
1870 yout.postflightDocument();
1873 yout.endDocuments();
1878template <
typename T>
1879inline std::enable_if_t<has_MappingTraits<T, EmptyContext>::value, Output &>
1882 yout.beginDocuments();
1883if ( yout.preflightDocument(0) ) {
1884 yamlize(yout, map,
true, Ctx);
1885 yout.postflightDocument();
1887 yout.endDocuments();
1892template <
typename T>
1893inline std::enable_if_t<has_SequenceTraits<T>::value, Output &>
1896 yout.beginDocuments();
1897if ( yout.preflightDocument(0) ) {
1898 yamlize(yout,
seq,
true, Ctx);
1899 yout.postflightDocument();
1901 yout.endDocuments();
1906template <
typename T>
1907inline std::enable_if_t<has_BlockScalarTraits<T>::value, Output &>
1910 Out.beginDocuments();
1911if (Out.preflightDocument(0)) {
1912 yamlize(Out, Val,
true, Ctx);
1913 Out.postflightDocument();
1920template <
typename T>
1921inline std::enable_if_t<has_CustomMappingTraits<T>::value, Output &>
1924 Out.beginDocuments();
1925if (Out.preflightDocument(0)) {
1926 yamlize(Out, Val,
true, Ctx);
1927 Out.postflightDocument();
1935template <
typename T>
1936inline std::enable_if_t<has_PolymorphicTraits<T>::value, Output &>
1939 Out.beginDocuments();
1940if (Out.preflightDocument(0)) {
1943assert(PolymorphicTraits<T>::getKind(Val) != NodeKind::Scalar &&
"plain scalar documents are not supported");
1944 yamlize(Out, Val,
true, Ctx);
1945 Out.postflightDocument();
1952template <
typename T>
1953inline std::enable_if_t<missingTraits<T, EmptyContext>::value, Output &>
1955char missing_yaml_trait_for_type[
sizeof(MissingTrait<T>)];
1959template <
bool B>
struct IsFlowSequenceBase {};
1960template <>
struct IsFlowSequenceBase<
true> {
staticconstbool flow =
true; };
1962template <
typename T,
typename U =
void>
1963struct IsResizable : std::false_type {};
1965template <
typename T>
1966struct IsResizable<
T,
std::void_t<decltype(std::declval<T>().resize(0))>>
1967 :
public std::true_type {};
1969template <
typename T,
bool B>
struct IsResizableBase {
1970using type =
typename T::value_type;
1972static type &element(IO &io,
T &seq,
size_t index) {
1973if (index >=
seq.size())
1974seq.resize(index + 1);
1979template <
typename T>
struct IsResizableBase<
T,
false> {
1980using type =
typename T::value_type;
1982static type &element(IO &io,
T &seq,
size_t index) {
1983if (index >=
seq.size()) {
1984 io.setError(Twine(
"value sequence extends beyond static size (") +
1985 Twine(
seq.size()) +
")");
1992template <
typename T,
bool Flow>
1993struct SequenceTraitsImpl
1994 : IsFlowSequenceBase<Flow>, IsResizableBase<T, IsResizable<T>::value> {
1995staticsize_tsize(IO &io,
T &seq) {
returnseq.size(); }
2000template <
bool>
struct CheckIsBool {
staticconstboolvalue =
true; };
2004template <
typename T>
2005struct SequenceTraits<
2007 std::enable_if_t<CheckIsBool<SequenceElementTraits<T>::flow>::value>>
2008 : SequenceTraitsImpl<std::vector<T>, SequenceElementTraits<T>::flow> {};
2009template <
typename T,
size_t N>
2010struct SequenceTraits<
2012 std::enable_if_t<CheckIsBool<SequenceElementTraits<T>::flow>::value>>
2013 : SequenceTraitsImpl<std::array<T, N>, SequenceElementTraits<T>::flow> {};
2014template <
typename T,
unsigned N>
2015struct SequenceTraits<
2017std::enable_if_t<CheckIsBool<SequenceElementTraits<T>::flow>::value>>
2018 : SequenceTraitsImpl<SmallVector<T, N>, SequenceElementTraits<T>::flow> {};
2019template <
typename T>
2020struct SequenceTraits<
2022std::enable_if_t<CheckIsBool<SequenceElementTraits<T>::flow>::value>>
2023 : SequenceTraitsImpl<SmallVectorImpl<T>, SequenceElementTraits<T>::flow> {};
2024template <
typename T>
2025struct SequenceTraits<
2027std::enable_if_t<CheckIsBool<SequenceElementTraits<T>::flow>::value>>
2028 : SequenceTraitsImpl<MutableArrayRef<T>, SequenceElementTraits<T>::flow> {};
2031template <
typename T>
2032struct SequenceElementTraits<
T,
std::enable_if_t<std::is_fundamental_v<T>>> {
2033staticconstbool flow =
true;
2037template<>
struct SequenceElementTraits<
std::
string> {
2038staticconstbool flow =
false;
2040template<>
struct SequenceElementTraits<StringRef> {
2041staticconstbool flow =
false;
2043template<>
struct SequenceElementTraits<
std::pair<std::string, std::string>> {
2044staticconstbool flow =
false;
2048template <
typename T>
struct StdMapStringCustomMappingTraitsImpl {
2049using map_type = std::map<std::string, T>;
2051staticvoid inputOne(IO &io, StringRef key, map_type &v) {
2052 io.mapRequired(key.str().c_str(), v[std::string(key)]);
2055staticvoid output(IO &io, map_type &v) {
2057 io.mapRequired(
p.first.c_str(),
p.second);
2064#define LLVM_YAML_IS_SEQUENCE_VECTOR_IMPL(TYPE, FLOW) \ 2068 !std::is_fundamental_v<TYPE> && !std::is_same_v<TYPE, std::string> && \ 2069 !std::is_same_v<TYPE, llvm::StringRef>, \ 2070 "only use LLVM_YAML_IS_SEQUENCE_VECTOR for types you control"); \
2071 template <> struct SequenceElementTraits<TYPE> { \
2072 static const bool flow = FLOW; \
2079#define LLVM_YAML_IS_SEQUENCE_VECTOR(type) \ 2080 LLVM_YAML_IS_SEQUENCE_VECTOR_IMPL(type, false) 2084#define LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(type) \ 2085 LLVM_YAML_IS_SEQUENCE_VECTOR_IMPL(type, true) 2087#define LLVM_YAML_DECLARE_MAPPING_TRAITS(Type) \ 2090 template <> struct LLVM_ABI MappingTraits<Type> { \ 2091 static void mapping(IO &IO, Type &Obj); \ 2096#define LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(Type) \ 2099 template <> struct MappingTraits<Type> { \ 2100 static void mapping(IO &IO, Type &Obj); \ 2105#define LLVM_YAML_DECLARE_ENUM_TRAITS(Type) \ 2108 template <> struct LLVM_ABI ScalarEnumerationTraits<Type> { \ 2109 static void enumeration(IO &io, Type &Value); \ 2114#define LLVM_YAML_DECLARE_BITSET_TRAITS(Type) \ 2117 template <> struct LLVM_ABI ScalarBitSetTraits<Type> { \ 2118 static void bitset(IO &IO, Type &Options); \ 2123#define LLVM_YAML_DECLARE_SCALAR_TRAITS(Type, MustQuote) \ 2126 template <> struct LLVM_ABI ScalarTraits<Type> { \ 2127 static void output(const Type &Value, void *ctx, raw_ostream &Out); \ 2128 static StringRef input(StringRef Scalar, void *ctxt, Type &Value); \ 2129 static QuotingType mustQuote(StringRef) { return MustQuote; } \ 2136#define LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(_type) \ 2139 template <unsigned N> \ 2140 struct DocumentListTraits<SmallVector<_type, N>> \ 2141 : public SequenceTraitsImpl<SmallVector<_type, N>, false> {}; \ 2143 struct DocumentListTraits<std::vector<_type>> \ 2144 : public SequenceTraitsImpl<std::vector<_type>, false> {}; \ 2150#define LLVM_YAML_IS_STRING_MAP(_type) \ 2154 struct CustomMappingTraits<std::map<std::string, _type>> \ 2155 : public StdMapStringCustomMappingTraitsImpl<_type> {}; \ This file defines the StringMap class.
This file defines the BumpPtrAllocator interface.
This file implements the BitVector class.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Given that RA is a live value
static void mapOptional(yaml::IO &IO, const char *Key, EndianType &Val, typename EndianType::value_type Default)
Perform an optional yaml-mapping of an endian-aware type EndianType.
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
static void DiagHandler(const SMDiagnostic &Diag, void *Context)
#define LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(type)
#define LLVM_YAML_STRONG_TYPEDEF(_base, _type)
static constexpr size_t npos
This class implements an extremely fast bulk output stream that can only output to a stream.
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
@ C
The default llvm calling convention, compatible with C.
Sequence
A sequence of states that a pointer may go through in which an objc_retain and objc_release are actua...
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
MutableArrayRef(T &OneElt) -> MutableArrayRef< T >
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
ScaledNumber< DigitsT > operator>>(const ScaledNumber< DigitsT > &L, int16_t Shift)
auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
@ Default
The result values are uniform if and only if all operands are uniform.
Implement std::hash so that hash_code can be used in STL containers.
Determine the kind of a node from its type.