LLVM: lib/Support/YAMLTraits.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
24#include
25#include
26#include
27#include
28#include
29
30using namespace llvm;
31using namespace yaml;
32
33
34
35
36
37IO::IO(void *Context) : Ctxt(Context) {}
38
40
44
48
52
53
54
55
56
59 : IO(Ctxt), Strm(new Stream(InputContent, SrcMgr, false, &EC)) {
61 SrcMgr.setDiagHandler(DiagHandler, DiagHandlerCtxt);
62 DocIterator = Strm->begin();
63}
64
69 SrcMgr.setDiagHandler(DiagHandler, DiagHandlerCtxt);
70 DocIterator = Strm->begin();
71}
72
74
76
78 return false;
79}
80
82 if (DocIterator != Strm->end()) {
83 Node *N = DocIterator->getRoot();
84 if () {
86 return false;
87 }
88
90
91 ++DocIterator;
93 }
94 releaseHNodeBuffers();
95 TopNode = createHNodes(N);
96 CurrentNode = TopNode;
97 return true;
98 }
99 return false;
100}
101
103 return ++DocIterator != Strm->end();
104}
105
107 return CurrentNode ? CurrentNode->_node : nullptr;
108}
109
111
112
113 if (!CurrentNode)
114 return false;
115
116 std::string foundTag = CurrentNode->_node->getVerbatimTag();
117 if (foundTag.empty()) {
118
120 }
121
122 return Tag == foundTag;
123}
124
126 if (EC)
127 return;
128
130 if (MN) {
131 MN->ValidKeys.clear();
132 }
133}
134
137 std::vector Ret;
138 if (!MN) {
139 setError(CurrentNode, "not a mapping");
140 return Ret;
141 }
142 for (auto &P : MN->Mapping)
143 Ret.push_back(P.first());
144 return Ret;
145}
146
147bool Input::preflightKey(StringRef Key, bool Required, bool, bool &UseDefault,
148 void *&SaveInfo) {
149 UseDefault = false;
150 if (EC)
151 return false;
152
153
154
155 if (!CurrentNode) {
158 else
159 UseDefault = true;
160 return false;
161 }
162
164 if (!MN) {
166 setError(CurrentNode, "not a mapping");
167 else
168 UseDefault = true;
169 return false;
170 }
171 MN->ValidKeys.push_back(Key.str());
172 HNode *Value = MN->Mapping[Key].first;
175 setError(CurrentNode, Twine("missing required key '") + Key + "'");
176 else
177 UseDefault = true;
178 return false;
179 }
180 SaveInfo = CurrentNode;
181 CurrentNode = Value;
182 return true;
183}
184
185void Input::postflightKey(void *saveInfo) {
186 CurrentNode = reinterpret_cast<HNode *>(saveInfo);
187}
188
190 if (EC)
191 return;
192
194 if (!MN)
195 return;
196 for (const auto &NN : MN->Mapping) {
197 if ((MN->ValidKeys, NN.first())) {
198 const SMRange &ReportLoc = NN.second.second;
199 if (!AllowUnknownKeys) {
200 setError(ReportLoc, Twine("unknown key '") + NN.first() + "'");
201 break;
202 } else
203 reportWarning(ReportLoc, Twine("unknown key '") + NN.first() + "'");
204 }
205 }
206}
207
209
211
214 return SQ->Entries.size();
216 return 0;
217
219 if (isNull(SN->value()))
220 return 0;
221 }
222
223 setError(CurrentNode, "not a sequence");
224 return 0;
225}
226
228}
229
230bool Input::preflightElement(unsigned Index, void *&SaveInfo) {
231 if (EC)
232 return false;
234 SaveInfo = CurrentNode;
235 CurrentNode = SQ->Entries[Index];
236 return true;
237 }
238 return false;
239}
240
241void Input::postflightElement(void *SaveInfo) {
242 CurrentNode = reinterpret_cast<HNode *>(SaveInfo);
243}
244
246
247bool Input::preflightFlowElement(unsigned index, void *&SaveInfo) {
248 if (EC)
249 return false;
251 SaveInfo = CurrentNode;
252 CurrentNode = SQ->Entries[index];
253 return true;
254 }
255 return false;
256}
257
258void Input::postflightFlowElement(void *SaveInfo) {
259 CurrentNode = reinterpret_cast<HNode *>(SaveInfo);
260}
261
263}
264
266 ScalarMatchFound = false;
267}
268
269bool Input::matchEnumScalar(StringRef Str, bool) {
270 if (ScalarMatchFound)
271 return false;
273 if (SN->value() == Str) {
274 ScalarMatchFound = true;
275 return true;
276 }
277 }
278 return false;
279}
280
282 if (ScalarMatchFound)
283 return false;
284 ScalarMatchFound = true;
285 return true;
286}
287
289 if (!ScalarMatchFound) {
290 setError(CurrentNode, "unknown enumerated scalar");
291 }
292}
293
294bool Input::beginBitSetScalar(bool &DoClear) {
295 BitValuesUsed.clear();
297 BitValuesUsed.resize(SQ->Entries.size());
298 } else {
299 setError(CurrentNode, "expected sequence of bit values");
300 }
301 DoClear = true;
302 return true;
303}
304
305bool Input::bitSetMatch(StringRef Str, bool) {
306 if (EC)
307 return false;
309 unsigned Index = 0;
310 for (auto &N : SQ->Entries) {
312 if (SN->value() == Str) {
313 BitValuesUsed[Index] = true;
314 return true;
315 }
316 } else {
317 setError(CurrentNode, "unexpected scalar in sequence of bit values");
318 }
320 }
321 } else {
322 setError(CurrentNode, "expected sequence of bit values");
323 }
324 return false;
325}
326
328 if (EC)
329 return;
331 assert(BitValuesUsed.size() == SQ->Entries.size());
332 for (unsigned i = 0; i < SQ->Entries.size(); ++i) {
333 if (!BitValuesUsed[i]) {
334 setError(SQ->Entries[i], "unknown bit value");
335 return;
336 }
337 }
338 }
339}
340
341void Input::scalarString(StringRef &S, QuotingType) {
343 S = SN->value();
344 } else {
345 setError(CurrentNode, "unexpected scalar");
346 }
347}
348
349void Input::blockScalarString(StringRef &S) { scalarString(S, QuotingType::None); }
350
351void Input::scalarTag(std::string &Tag) {
352 Tag = CurrentNode->_node->getVerbatimTag();
353}
354
355void Input::setError(HNode *hnode, const Twine &message) {
356 assert(hnode && "HNode must not be NULL");
357 setError(hnode->_node, message);
358}
359
368}
369
370void Input::setError(Node *node, const Twine &message) {
371 Strm->printError(node, message);
373}
374
375void Input::setError(const SMRange &range, const Twine &message) {
376 Strm->printError(range, message);
378}
379
380void Input::reportWarning(HNode *hnode, const Twine &message) {
381 assert(hnode && "HNode must not be NULL");
383}
384
385void Input::reportWarning(Node *node, const Twine &message) {
387}
388
389void Input::reportWarning(const SMRange &range, const Twine &message) {
391}
392
393void Input::releaseHNodeBuffers() {
394 EmptyHNodeAllocator.DestroyAll();
395 ScalarHNodeAllocator.DestroyAll();
396 SequenceHNodeAllocator.DestroyAll();
397 MapHNodeAllocator.DestroyAll();
398}
399
400Input::HNode *Input::createHNodes(Node *N) {
401 SmallString<128> StringStorage;
402 switch (N->getType()) {
405 StringRef KeyStr = SN->getValue(StringStorage);
406 if (!StringStorage.empty()) {
407
408 KeyStr = StringStorage.str().copy(StringAllocator);
409 }
410 return new (ScalarHNodeAllocator.Allocate()) ScalarHNode(N, KeyStr);
411 }
414 StringRef ValueCopy = BSN->getValue().copy(StringAllocator);
415 return new (ScalarHNodeAllocator.Allocate()) ScalarHNode(N, ValueCopy);
416 }
419 auto SQHNode = new (SequenceHNodeAllocator.Allocate()) SequenceHNode(N);
420 for (Node &SN : *SQ) {
421 auto Entry = createHNodes(&SN);
422 if (EC)
423 break;
424 SQHNode->Entries.push_back(Entry);
425 }
426 return SQHNode;
427 }
430 auto mapHNode = new (MapHNodeAllocator.Allocate()) MapHNode(N);
431 for (KeyValueNode &KVN : *Map) {
432 Node *KeyNode = KVN.getKey();
436 if ()
437 setError(KeyNode, "Map key must be a scalar");
439 setError(KeyNode, "Map value must not be empty");
440 break;
441 }
442 StringStorage.clear();
443 StringRef KeyStr = Key->getValue(StringStorage);
444 if (!StringStorage.empty()) {
445
446 KeyStr = StringStorage.str().copy(StringAllocator);
447 }
448 if (mapHNode->Mapping.count(KeyStr))
449
450
451
452 setError(KeyNode, Twine("duplicated mapping key '") + KeyStr + "'");
453 auto ValueHNode = createHNodes(Value);
454 if (EC)
455 break;
456 mapHNode->Mapping[KeyStr] =
457 std::make_pair(std::move(ValueHNode), KeyNode->getSourceRange());
458 }
459 return std::move(mapHNode);
460 }
462 return new (EmptyHNodeAllocator.Allocate()) EmptyHNode(N);
463 default:
464 setError(N, "unknown node kind");
465 return nullptr;
466 }
467}
468
469void Input::setError(const Twine &Message) {
470 setError(CurrentNode, Message);
471}
472
474
476 return false;
477}
478
479
480
481
482
484 : IO(context), Out(yout), WrapColumn(WrapColumn) {}
485
487
491
493 StateStack.push_back(inMapFirstKey);
494 PaddingBeforeContainer = Padding;
495 Padding = "\n";
496}
497
499 if (Use) {
500
501
502
503 bool SequenceElement = false;
504 if (StateStack.size() > 1) {
505 auto &E = StateStack[StateStack.size() - 2];
506 SequenceElement = inSeqAnyElement(E) || inFlowSeqAnyElement(E);
507 }
508 if (SequenceElement && StateStack.back() == inMapFirstKey) {
509 newLineCheck();
510 } else {
511 output(" ");
512 }
513 output(Tag);
514 if (SequenceElement) {
515
516
517 if (StateStack.back() == inMapFirstKey) {
518 StateStack.pop_back();
519 StateStack.push_back(inMapOtherKey);
520 }
521
522
523 Padding = "\n";
524 }
525 }
526 return Use;
527}
528
530
531 if (StateStack.back() == inMapFirstKey) {
532 Padding = PaddingBeforeContainer;
533 newLineCheck();
534 output("{}");
535 Padding = "\n";
536 }
537 StateStack.pop_back();
538}
539
543
545 bool &UseDefault, void *&SaveInfo) {
546 UseDefault = false;
547 SaveInfo = nullptr;
548 if (Required || !SameAsDefault || WriteDefaultValues) {
549 auto State = StateStack.back();
550 if (State == inFlowMapFirstKey || State == inFlowMapOtherKey) {
551 flowKey(Key);
552 } else {
553 newLineCheck();
554 paddedKey(Key);
555 }
556 return true;
557 }
558 return false;
559}
560
562 if (StateStack.back() == inMapFirstKey) {
563 StateStack.pop_back();
564 StateStack.push_back(inMapOtherKey);
565 } else if (StateStack.back() == inFlowMapFirstKey) {
566 StateStack.pop_back();
567 StateStack.push_back(inFlowMapOtherKey);
568 }
569}
570
572 StateStack.push_back(inFlowMapFirstKey);
573 newLineCheck();
574 ColumnAtMapFlowStart = Column;
575 output("{ ");
576}
577
579 StateStack.pop_back();
580 outputUpToEndOfLine(" }");
581}
582
584 outputUpToEndOfLine("---");
585}
586
588 if (index > 0)
589 outputUpToEndOfLine("\n---");
590 return true;
591}
592
595
597 output("\n...\n");
598}
599
601 StateStack.push_back(inSeqFirstElement);
602 PaddingBeforeContainer = Padding;
603 Padding = "\n";
604 return 0;
605}
606
608
609 if (StateStack.back() == inSeqFirstElement) {
610 Padding = PaddingBeforeContainer;
611 newLineCheck(true);
612 output("[]");
613 Padding = "\n";
614 }
615 StateStack.pop_back();
616}
617
619 SaveInfo = nullptr;
620 return true;
621}
622
624 if (StateStack.back() == inSeqFirstElement) {
625 StateStack.pop_back();
626 StateStack.push_back(inSeqOtherElement);
627 } else if (StateStack.back() == inFlowSeqFirstElement) {
628 StateStack.pop_back();
629 StateStack.push_back(inFlowSeqOtherElement);
630 }
631}
632
634 StateStack.push_back(inFlowSeqFirstElement);
635 newLineCheck();
636 ColumnAtFlowStart = Column;
637 output("[ ");
638 NeedFlowSequenceComma = false;
639 return 0;
640}
641
643 StateStack.pop_back();
644 outputUpToEndOfLine(" ]");
645}
646
648 if (NeedFlowSequenceComma)
649 output(", ");
650 if (WrapColumn && Column > WrapColumn) {
651 output("\n");
652 for (int i = 0; i < ColumnAtFlowStart; ++i)
653 output(" ");
654 Column = ColumnAtFlowStart;
655 output(" ");
656 }
657 SaveInfo = nullptr;
658 return true;
659}
660
662 NeedFlowSequenceComma = true;
663}
664
666 EnumerationMatchFound = false;
667}
668
670 if (Match && !EnumerationMatchFound) {
671 newLineCheck();
672 outputUpToEndOfLine(Str);
673 EnumerationMatchFound = true;
674 }
675 return false;
676}
677
679 if (EnumerationMatchFound)
680 return false;
681 EnumerationMatchFound = true;
682 return true;
683}
684
686 if (!EnumerationMatchFound)
688}
689
691 newLineCheck();
692 output("[ ");
693 NeedBitValueComma = false;
694 DoClear = false;
695 return true;
696}
697
699 if (Matches) {
700 if (NeedBitValueComma)
701 output(", ");
702 output(Str);
703 NeedBitValueComma = true;
704 }
705 return false;
706}
707
709 outputUpToEndOfLine(" ]");
710}
711
713 newLineCheck();
715
716
717 outputUpToEndOfLine("''");
718 return;
719 }
720 output(S, MustQuote);
721 outputUpToEndOfLine("");
722}
723
725 if (!StateStack.empty())
726 newLineCheck();
727 output(" |");
728
729 unsigned Indent = StateStack.empty() ? 1 : StateStack.size();
730
732 for (line_iterator Lines(*Buffer, false); !Lines.is_at_end(); ++Lines) {
733 outputNewLine();
734 for (unsigned I = 0; I < Indent; ++I) {
735 output(" ");
736 }
737 output(*Lines);
738 }
739 outputUpToEndOfLine("");
740}
741
743 if (Tag.empty())
744 return;
745 newLineCheck();
746 output(Tag);
747 output(" ");
748}
749
752
754
756
757
758
759
760
761 if (StateStack.size() < 2)
762 return true;
763 if (StateStack.back() != inMapFirstKey)
764 return true;
765 return !inSeqAnyElement(StateStack[StateStack.size() - 2]);
766}
767
768void Output::output(StringRef s) {
769 Column += s.size();
770 Out << s;
771}
772
775
776 output(S);
777 return;
778 }
779
782 output(Quote);
783
784
785
786
787
789 output(yaml::escape(S, false));
790 output(Quote);
791 return;
792 }
793
794 unsigned i = 0;
795 unsigned j = 0;
796 unsigned End = S.size();
798
799
800
801 while (j < End) {
802 if (S[j] == '\'') {
803 output(StringRef(&Base[i], j - i));
804 output(StringLiteral("''"));
805 i = j + 1;
806 }
807 ++j;
808 }
809 output(StringRef(&Base[i], j - i));
810 output(Quote);
811}
812
813void Output::outputUpToEndOfLine(StringRef s) {
814 output(s);
815 if (StateStack.empty() || (!inFlowSeqAnyElement(StateStack.back()) &&
816 !inFlowMapAnyKey(StateStack.back())))
817 Padding = "\n";
818}
819
820void Output::outputNewLine() {
821 Out << "\n";
822 Column = 0;
823}
824
825
826
827
828
829void Output::newLineCheck(bool EmptySequence) {
830 if (Padding != "\n") {
831 output(Padding);
832 Padding = {};
833 return;
834 }
835 outputNewLine();
836 Padding = {};
837
838 if (StateStack.size() == 0 || EmptySequence)
839 return;
840
841 unsigned Indent = StateStack.size() - 1;
842 bool PossiblyNestedSeq = false;
843 auto I = StateStack.rbegin(), E = StateStack.rend();
844
845 if (inSeqAnyElement(*I)) {
846 PossiblyNestedSeq = true;
847 ++Indent;
848 } else if (*I == inMapFirstKey || *I == inFlowMapFirstKey ||
849 inFlowSeqAnyElement(*I)) {
850 PossiblyNestedSeq = true;
851 ++I;
852 }
853
854 unsigned OutputDashCount = 0;
855 if (PossiblyNestedSeq) {
856
857
859
860 if (!inSeqAnyElement(*I))
861 break;
862
863 ++OutputDashCount;
864
865
866 if (*I++ != inSeqFirstElement)
867 break;
868 }
869 }
870
871 for (unsigned I = OutputDashCount; I < Indent; ++I)
872 output(" ");
873
874 for (unsigned I = 0; I < OutputDashCount; ++I)
875 output("- ");
876}
877
878void Output::paddedKey(StringRef key) {
880 output(":");
881 const char *spaces = " ";
884 else
885 Padding = " ";
886}
887
888void Output::flowKey(StringRef Key) {
889 if (StateStack.back() == inFlowMapOtherKey)
890 output(", ");
891 if (WrapColumn && Column > WrapColumn) {
892 output("\n");
893 for (int I = 0; I < ColumnAtMapFlowStart; ++I)
894 output(" ");
895 Column = ColumnAtMapFlowStart;
896 output(" ");
897 }
899 output(": ");
900}
901
903
904bool Output::inSeqAnyElement(InState State) {
905 return State == inSeqFirstElement || State == inSeqOtherElement;
906}
907
908bool Output::inFlowSeqAnyElement(InState State) {
909 return State == inFlowSeqFirstElement || State == inFlowSeqOtherElement;
910}
911
912bool Output::inMapAnyKey(InState State) {
913 return State == inMapFirstKey || State == inMapOtherKey;
914}
915
916bool Output::inFlowMapAnyKey(InState State) {
917 return State == inFlowMapFirstKey || State == inFlowMapOtherKey;
918}
919
920
921
922
923
925 Out << (Val ? "true" : "false");
926}
927
930 Val = *Parsed;
931 return StringRef();
932 }
933 return "invalid boolean";
934}
935
937 raw_ostream &Out) {
938 Out << Val;
939}
940
942 StringRef &Val) {
944 return StringRef();
945}
946
948 raw_ostream &Out) {
949 Out << Val;
950}
951
953 std::string &Val) {
955 return StringRef();
956}
957
959 raw_ostream &Out) {
960
961 uint32_t Num = Val;
962 Out << Num;
963}
964
966 unsigned long long n;
968 return "invalid number";
969 if (n > 0xFF)
970 return "out of range number";
971 Val = n;
972 return StringRef();
973}
974
976 raw_ostream &Out) {
977 Out << Val;
978}
979
981 uint16_t &Val) {
982 unsigned long long n;
984 return "invalid number";
985 if (n > 0xFFFF)
986 return "out of range number";
987 Val = n;
988 return StringRef();
989}
990
992 raw_ostream &Out) {
993 Out << Val;
994}
995
997 uint32_t &Val) {
998 unsigned long long n;
1000 return "invalid number";
1001 if (n > 0xFFFFFFFFUL)
1002 return "out of range number";
1003 Val = n;
1004 return StringRef();
1005}
1006
1008 raw_ostream &Out) {
1009 Out << Val;
1010}
1011
1013 uint64_t &Val) {
1014 unsigned long long N;
1016 return "invalid number";
1017 Val = N;
1018 return StringRef();
1019}
1020
1022
1023 int32_t Num = Val;
1024 Out << Num;
1025}
1026
1028 long long N;
1030 return "invalid number";
1031 if ((N > 127) || (N < -128))
1032 return "out of range number";
1033 Val = N;
1034 return StringRef();
1035}
1036
1038 raw_ostream &Out) {
1039 Out << Val;
1040}
1041
1043 long long N;
1045 return "invalid number";
1046 if ((N > INT16_MAX) || (N < INT16_MIN))
1047 return "out of range number";
1048 Val = N;
1049 return StringRef();
1050}
1051
1053 raw_ostream &Out) {
1054 Out << Val;
1055}
1056
1058 long long N;
1060 return "invalid number";
1061 if ((N > INT32_MAX) || (N < INT32_MIN))
1062 return "out of range number";
1063 Val = N;
1064 return StringRef();
1065}
1066
1068 raw_ostream &Out) {
1069 Out << Val;
1070}
1071
1073 long long N;
1075 return "invalid number";
1076 Val = N;
1077 return StringRef();
1078}
1079
1081 Out << format("%g", Val);
1082}
1083
1086 return StringRef();
1087 return "invalid floating point number";
1088}
1089
1091 Out << format("%g", Val);
1092}
1093
1096 return StringRef();
1097 return "invalid floating point number";
1098}
1099
1101 Out << format("0x%" PRIX8, (uint8_t)Val);
1102}
1103
1105 unsigned long long n;
1107 return "invalid hex8 number";
1108 if (n > 0xFF)
1109 return "out of range hex8 number";
1110 Val = n;
1111 return StringRef();
1112}
1113
1115 Out << format("0x%" PRIX16, (uint16_t)Val);
1116}
1117
1119 unsigned long long n;
1121 return "invalid hex16 number";
1122 if (n > 0xFFFF)
1123 return "out of range hex16 number";
1124 Val = n;
1125 return StringRef();
1126}
1127
1129 Out << format("0x%" PRIX32, (uint32_t)Val);
1130}
1131
1133 unsigned long long n;
1135 return "invalid hex32 number";
1136 if (n > 0xFFFFFFFFUL)
1137 return "out of range hex32 number";
1138 Val = n;
1139 return StringRef();
1140}
1141
1143 Out << format("0x%" PRIX64, (uint64_t)Val);
1144}
1145
1147 unsigned long long Num;
1149 return "invalid hex64 number";
1150 Val = Num;
1151 return StringRef();
1152}
1153
1155 llvm::raw_ostream &Out) {
1157}
1158
1160 VersionTuple &Val) {
1162 return "invalid version format";
1163 return StringRef();
1164}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the SmallString class.
static void DiagHandler(const SMDiagnostic &Diag, void *Context)
Defines the llvm::VersionTuple class, which represents a version in the form major[....
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
StringRef str() const
Explicit conversion to StringRef.
void(*)(const SMDiagnostic &, void *Context) DiagHandlerTy
Clients that want to handle their own diagnostics in a custom way can register a function pointer+con...
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
constexpr size_t size() const
size - Get the string size.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
StringRef copy(Allocator &A) const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
A Use represents the edge between a Value definition and its users.
LLVM_ABI bool tryParse(StringRef string)
Try to parse the given string as a version number.
LLVM_ABI std::string getAsString() const
Retrieve a string representation of the version number.
A forward iterator which reads text lines from a buffer.
This class implements an extremely fast bulk output stream that can only output to a stream.
StringRef getValue() const
Gets the value of this node as a StringRef.
virtual bool canElideEmptySequence()=0
virtual NodeKind getNodeKind()=0
void setContext(void *)
Definition YAMLTraits.cpp:45
virtual void endSequence()=0
virtual void endEnumScalar()=0
virtual bool outputting() const =0
virtual unsigned beginFlowSequence()=0
virtual void endFlowSequence()=0
virtual void beginMapping()=0
virtual void setAllowUnknownKeys(bool Allow)
Definition YAMLTraits.cpp:49
virtual void endMapping()=0
virtual unsigned beginSequence()=0
virtual void beginEnumScalar()=0
void * getContext() const
Definition YAMLTraits.cpp:41
virtual void endFlowMapping()=0
virtual void beginFlowMapping()=0
virtual bool matchEnumFallback()=0
virtual void endBitSetScalar()=0
virtual std::vector< StringRef > keys()=0
IO(void *Ctxt=nullptr)
Definition YAMLTraits.cpp:37
bool nextDocument()
Definition YAMLTraits.cpp:102
void setAllowUnknownKeys(bool Allow) override
Definition YAMLTraits.cpp:473
Input(StringRef InputContent, void *Ctxt=nullptr, SourceMgr::DiagHandlerTy DiagHandler=nullptr, void *DiagHandlerCtxt=nullptr)
Definition YAMLTraits.cpp:57
std::error_code error() override
Definition YAMLTraits.cpp:75
bool setCurrentDocument()
Definition YAMLTraits.cpp:81
const Node * getCurrentNode() const
Returns the current node that's being parsed by the YAML Parser.
Definition YAMLTraits.cpp:106
Abstract base class for all Nodes.
std::string getVerbatimTag() const
Get the verbatium tag for a given Node.
unsigned beginFlowSequence() override
Definition YAMLTraits.cpp:633
std::vector< StringRef > keys() override
Definition YAMLTraits.cpp:540
Output(raw_ostream &, void *Ctxt=nullptr, int WrapColumn=70)
Definition YAMLTraits.cpp:483
void setError(const Twine &message) override
Definition YAMLTraits.cpp:750
void scalarString(StringRef &, QuotingType) override
Definition YAMLTraits.cpp:712
void endBitSetScalar() override
Definition YAMLTraits.cpp:708
void endDocuments()
Definition YAMLTraits.cpp:596
void beginFlowMapping() override
Definition YAMLTraits.cpp:571
void endFlowMapping() override
Definition YAMLTraits.cpp:578
void endFlowSequence() override
Definition YAMLTraits.cpp:642
void postflightElement(void *) override
Definition YAMLTraits.cpp:623
void endEnumScalar() override
Definition YAMLTraits.cpp:685
void blockScalarString(StringRef &) override
Definition YAMLTraits.cpp:724
void beginDocuments()
Definition YAMLTraits.cpp:583
bool preflightDocument(unsigned)
Definition YAMLTraits.cpp:587
bool bitSetMatch(StringRef, bool) override
Definition YAMLTraits.cpp:698
bool canElideEmptySequence() override
Definition YAMLTraits.cpp:755
void beginMapping() override
Definition YAMLTraits.cpp:492
void postflightFlowElement(void *) override
Definition YAMLTraits.cpp:661
void scalarTag(std::string &) override
Definition YAMLTraits.cpp:742
bool beginBitSetScalar(bool &) override
Definition YAMLTraits.cpp:690
bool mapTag(StringRef, bool) override
Definition YAMLTraits.cpp:498
bool preflightElement(unsigned, void *&) override
Definition YAMLTraits.cpp:618
bool matchEnumFallback() override
Definition YAMLTraits.cpp:678
void beginEnumScalar() override
Definition YAMLTraits.cpp:665
bool preflightKey(StringRef Key, bool, bool, bool &, void *&) override
Definition YAMLTraits.cpp:544
void endSequence() override
Definition YAMLTraits.cpp:607
bool matchEnumScalar(StringRef, bool) override
Definition YAMLTraits.cpp:669
bool outputting() const override
Definition YAMLTraits.cpp:488
unsigned beginSequence() override
Definition YAMLTraits.cpp:600
NodeKind getNodeKind() override
Definition YAMLTraits.cpp:902
void endMapping() override
Definition YAMLTraits.cpp:529
std::error_code error() override
Definition YAMLTraits.cpp:753
void postflightKey(void *) override
Definition YAMLTraits.cpp:561
void postflightDocument()
Definition YAMLTraits.cpp:593
bool preflightFlowElement(unsigned, void *&) override
Definition YAMLTraits.cpp:647
StringRef getValue(SmallVectorImpl< char > &Storage) const
Gets the value of this node as a StringRef.
This class represents a YAML stream potentially containing multiple documents.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
NodeAddr< NodeBase * > Node
QuotingType
Describe which type of quotes should be used when quoting is necessary.
LLVM_ABI std::optional< bool > parseBool(StringRef S)
Parse S as a bool according to https://yaml.org/type/bool.html.
QuotingType needsQuotes(StringRef S, bool ForcePreserveAsString=true)
LLVM_ABI std::string escape(StringRef Input, bool EscapePrintable=true)
Escape Input for a double quoted scalar; if EscapePrintable is true, all UTF8 sequences will be escap...
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
LLVM_ABI bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result)
std::error_code make_error_code(BitcodeError E)
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
bool to_float(const Twine &T, float &Num)
auto dyn_cast_or_null(const Y &Val)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
LLVM_ABI bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result)
Helper functions for StringRef::getAsInteger.
@ Default
The result values are uniform if and only if all operands are uniform.
This class should be specialized by type that requires custom conversion to/from a yaml scalar.