LLVM: include/llvm/Support/JSON.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46#ifndef LLVM_SUPPORT_JSON_H
47#define LLVM_SUPPORT_JSON_H
48
57#include
58#include
59
60namespace llvm {
61namespace json {
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78template
80 std::is_integral_v && std::is_unsigned_v &&
82
83
84
86
87
88
90
94template Value toJSON(const std::optional &Opt);
95
96
97
100 Storage M;
101
102public:
108
110
111
112 struct KV;
113 explicit Object(std::initializer_list Properties);
114
119
120 bool empty() const { return M.empty(); }
121 size_t size() const { return M.size(); }
122
124 std::pair<iterator, bool> insert(KV E);
125 template <typename... Ts>
127 return M.try_emplace(K, std::forward(Args)...);
128 }
129 template <typename... Ts>
131 return M.try_emplace(std::move(K), std::forward(Args)...);
132 }
135
138
141
144
145
146
156
158};
162}
163
164
165
167 std::vector V;
168
169public:
171 using iterator = std::vector::iterator;
173
175 LLVM_ABI explicit Array(std::initializer_list Elements);
176 template explicit Array(const Collection &C) {
177 for (const auto &V : C)
179 }
180
189
194
195 bool empty() const;
196 size_t size() const;
198
202 template <typename... Args> void emplace_back(Args &&...A);
209
211};
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
292public:
303
304
307 LLVM_ABI Value(std::initializer_list Elements);
309 createjson::Array(std::move(Elements));
310 }
311 template
314 createjson::Object(std::move(Properties));
315 }
316 template
318
319 Value(std::string V) : Type(T_String) {
321 assert(false && "Invalid UTF-8 in value used as JSON");
323 }
324 createstd::string(std::move(V));
325 }
327 : Value(std::string(V.begin(), V.end())) {}
329
331 createllvm::StringRef(V);
333 assert(false && "Invalid UTF-8 in value used as JSON");
335 }
336 }
338 Value(std::nullptr_t) : Type(T_Null) {}
339
340
341 template <typename T, typename = std::enable_if_t<std::is_same_v<T, bool>>,
342 bool = false>
344 create(B);
345 }
346
347
348 template <typename T, typename = std::enable_if_t<is_uint_64_bit_v>>
350 create<uint64_t>(uint64_t{V});
351 }
352
353
354
355 template <typename T, typename = std::enable_if_t<std::is_integral_v>,
356 typename = std::enable_if_t<!std::is_same_v<T, bool>>,
357 typename = std::enable_if_t<!is_uint_64_bit_v>>
359 create<int64_t>(int64_t{I});
360 }
361
362 template <typename T,
363 typename = std::enable_if_t<std::is_floating_point_v>,
364 double * = nullptr>
366 create(double{D});
367 }
368
369 template <typename T,
370 typename = std::enable_if_t<
371 std::is_same_v<Value, decltype(toJSON(*(const T *)nullptr))>>,
372 Value * = nullptr>
374
376 destroy();
377 copyFrom(M);
378 return *this;
379 }
381 destroy();
382 moveFrom(std::move(M));
383 return *this;
384 }
386
388 switch (Type) {
389 case T_Null:
391 case T_Boolean:
393 case T_Double:
394 case T_Integer:
395 case T_UINT64:
397 case T_String:
398 case T_StringRef:
400 case T_Object:
402 case T_Array:
404 }
406 }
407
408
409
410 std::optionalstd::nullptr\_t getAsNull() const {
412 return nullptr;
413 return std::nullopt;
414 }
417 return as();
418 return std::nullopt;
419 }
422 return as();
424 return as<int64_t>();
426 return as<uint64_t>();
427 return std::nullopt;
428 }
429
432 return as<int64_t>();
436 return U;
437 }
438 }
440 double D = as();
442 D >= double(std::numeric_limits<int64_t>::min()) &&
443 D <= double(std::numeric_limits<int64_t>::max())))
444 return D;
445 }
446 return std::nullopt;
447 }
449 if (Type == T_UINT64)
450 return as<uint64_t>();
451 else if (Type == T_Integer) {
452 int64_t N = as<int64_t>();
453 if (N >= 0)
454 return as<uint64_t>();
455 }
456 return std::nullopt;
457 }
459 if (Type == T_String)
462 return asllvm::StringRef();
463 return std::nullopt;
464 }
466 return LLVM_LIKELY(Type == T_Object) ? &asjson::Object() : nullptr;
467 }
469 return LLVM_LIKELY(Type == T_Object) ? &asjson::Object() : nullptr;
470 }
472 return LLVM_LIKELY(Type == T_Array) ? &asjson::Array() : nullptr;
473 }
475 return LLVM_LIKELY(Type == T_Array) ? &asjson::Array() : nullptr;
476 }
477
479#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
484#endif
485
486private:
489
490
491
495
496 template <typename T, typename... U> void create(U &&... V) {
497#if LLVM_ADDRESS_SANITIZER_BUILD
498
499
500
501
502
503
504
505
506
508#endif
509 new (reinterpret_cast<T *>(&Union)) T(std::forward(V)...);
510 }
511 template T &as() const {
512
513
514 void *Storage = static_cast<void *>(&Union);
515 return *static_cast<T *>(Storage);
516 }
517
519
520 enum ValueType : char16_t {
521 T_Null,
522 T_Boolean,
523 T_Double,
524 T_Integer,
525 T_UINT64,
526 T_StringRef,
527 T_String,
528 T_Object,
529 T_Array,
530 };
531
536 Union;
538};
539
542
543
552
557
559inline size_t Array::size() const { return V.size(); }
561
566 V.emplace_back(std::forward(A)...);
567}
571}
573 return V.insert(P, std::move(E));
574}
575template
578}
579template <typename... Args>
581 return V.emplace(P, std::forward(A)...);
582}
585
586
587
588
589
591public:
595 assert(false && "Invalid UTF-8 in value used as JSON");
596 *Owned = fixUTF8(*Owned);
597 }
598 Data = *Owned;
599 }
602 assert(false && "Invalid UTF-8 in value used as JSON");
604 }
605 }
609
613 if (C.Owned) {
614 Owned.reset(new std::string(*C.Owned));
615 Data = *Owned;
616 } else {
617 Data = C.Data;
618 }
619 return *this;
620 }
622
624 std::string str() const { return Data.str(); }
625
626private:
627
628
629 std::unique_ptrstd::string Owned;
631};
632
637 return !(L == R);
638}
642
647
649 for (const auto &P : Properties) {
651 if (R.second)
652 R.first->getSecond().moveFrom(std::move(P.V));
653 }
654}
661
662LLVM_ABI std::vector<const Object::value_type *>
664
665
666
667
669public:
671
672
673
674
676
677
678 Path(Root &R) : Parent(nullptr), Seg(&R) {}
679
680 Path index(unsigned Index) const { return Path(this, Segment(Index)); }
681
683
684private:
685
686
687 class Segment {
688 uintptr_t Pointer;
690
691 public:
692 Segment() = default;
693 Segment(Root *R) : Pointer(reinterpret_cast<uintptr_t>(R)) {}
695 : Pointer(reinterpret_cast<uintptr_t>(Field.data())),
697 Segment(unsigned Index) : Pointer(0), Offset(Index) {}
698
699 bool isField() const { return Pointer != 0; }
700 StringRef field() const {
701 return StringRef(reinterpret_cast<const char *>(Pointer), Offset);
702 }
703 unsigned index() const { return Offset; }
704 Root *root() const { return reinterpret_cast<Root *>(Pointer); }
705 };
706
707 const Path *Parent;
708 Segment Seg;
709
710 Path(const Path *Parent, Segment S) : Parent(Parent), Seg(S) {}
711};
712
713
714
718 std::vectorPath::Segment ErrorPath;
719
721
722public:
724
729
730
732
733
734
735
736
737
738
740};
741
742
743
745 if (auto S = E.getAsString()) {
746 Out = std::string(*S);
747 return true;
748 }
749 P.report("expected string");
750 return false;
751}
753 if (auto S = E.getAsInteger()) {
754 Out = *S;
755 return true;
756 }
757 P.report("expected integer");
758 return false;
759}
761 if (auto S = E.getAsInteger()) {
762 Out = *S;
763 return true;
764 }
765 P.report("expected integer");
766 return false;
767}
769 if (auto S = E.getAsNumber()) {
770 Out = *S;
771 return true;
772 }
773 P.report("expected number");
774 return false;
775}
777 if (auto S = E.getAsBoolean()) {
778 Out = *S;
779 return true;
780 }
781 P.report("expected boolean");
782 return false;
783}
785 if (auto S = E.getAsInteger()) {
786 Out = *S;
787 return true;
788 }
789 P.report("expected unsigned integer");
790 return false;
791}
793 if (auto S = E.getAsUINT64()) {
794 Out = *S;
795 return true;
796 }
797 P.report("expected uint64_t");
798 return false;
799}
801 if (auto S = E.getAsNull()) {
802 Out = *S;
803 return true;
804 }
805 P.report("expected null");
806 return false;
807}
808template
810 if (E.getAsNull()) {
811 Out = std::nullopt;
812 return true;
813 }
814 T Result = {};
816 return false;
817 Out = std::move(Result);
818 return true;
819}
820template
822 if (auto *A = E.getAsArray()) {
823 Out.clear();
824 Out.resize(A->size());
825 for (size_t I = 0; I < A->size(); ++I)
827 return false;
828 return true;
829 }
830 P.report("expected array");
831 return false;
832}
833template
835 if (auto *O = E.getAsObject()) {
836 Out.clear();
837 for (const auto &KV : *O)
839 P.field(KV.first)))
840 return false;
841 return true;
842 }
843 P.report("expected object");
844 return false;
845}
846
847
848template Value toJSON(const std::optional &Opt) {
849 return Opt ? Value(*Opt) : Value(nullptr);
850}
851
852
853
854
855
856
857
858
859
860
861
862
864public:
865
867 if (!O)
868 P.report("expected object");
869 }
870
871
872
873 operator bool() const { return O; }
874
875
876
878 assert(*this && "Must check this is an object before calling map()");
879 if (const Value *E = O->get(Prop))
880 return fromJSON(*E, Out, P.field(Prop));
881 P.field(Prop).report("missing value");
882 return false;
883 }
884
885
886
887
888 template bool map(StringLiteral Prop, std::optional &Out) {
889 assert(*this && "Must check this is an object before calling map()");
890 if (const Value *E = O->get(Prop))
891 return fromJSON(*E, Out, P.field(Prop));
892 Out = std::nullopt;
893 return true;
894 }
895
896
897
898
900 assert(*this && "Must check this is an object before calling map()");
901 if (const Value *E = O->get(Prop))
902 return fromJSON(*E, Out, P.field(Prop));
903 return true;
904 }
905
906private:
909};
910
911
912
913
915
917 const char *Msg;
918 unsigned Line, Column, Offset;
919
920public:
922 ParseError(const char *Msg, unsigned Line, unsigned Column, unsigned Offset)
923 : Msg(Msg), Line(Line), Column(Column), Offset(Offset) {}
925 OS << llvm::formatv("[{0}:{1}, byte={2}]: {3}", Line, Column, Offset, Msg);
926 }
930};
931
932
933
934template
936 auto V = parse(JSON);
937 if (!V)
938 return V.takeError();
940 T Result;
942 return std::move(Result);
943 return R.getError();
944}
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1001 public:
1003
1005 : OS(OS), IndentSize(IndentSize) {
1006 Stack.emplace_back();
1007 }
1009 assert(Stack.size() == 1 && "Unmatched begin()/end()");
1010 assert(Stack.back().Ctx == Singleton);
1011 assert(Stack.back().HasValue && "Did not write top-level value");
1012 }
1013
1014
1016
1017
1018
1019
1020
1021
1023
1029
1035
1036
1037
1040 Contents(OS);
1042 }
1046
1047
1048
1050
1051
1052
1053
1054
1056 attributeImpl(Key, [&] { value(Contents); });
1057 }
1058
1060 attributeImpl(Key, [&] { array(Contents); });
1061 }
1062
1064 attributeImpl(Key, [&] { object(Contents); });
1065 }
1066
1067
1068
1069
1078
1079private:
1082 Contents();
1084 }
1085
1087 LLVM_ABI void flushComment();
1089
1090 enum Context {
1091 Singleton,
1092 Array,
1093 Object,
1094 RawValue,
1095 };
1096 struct State {
1097 Context Ctx = Singleton;
1098 bool HasValue = false;
1099 };
1100 llvm::SmallVector<State, 16> Stack;
1101 llvm::StringRef PendingComment;
1102 llvm::raw_ostream &OS;
1103 unsigned IndentSize;
1104 unsigned Indent = 0;
1105};
1106
1107
1108
1109
1114}
1115
1116
1117
1118
1123}
1124
1125#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_UNLIKELY(EXPR)
#define __asan_unpoison_memory_region(p, size)
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
#define LLVM_LIKELY(EXPR)
This file defines the DenseMap class.
OptimizedStructLayoutField Field
This file defines the SmallVector class.
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT, true > const_iterator
Base class for user error types.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
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.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
An efficient, type-erasing, non-owning reference to a callable.
An Array is a JSON array, which contains heterogeneous JSON values.
Definition JSON.h:166
Value * data()
Definition JSON.h:550
void emplace_back(Args &&...A)
Definition JSON.h:565
Value & front()
Definition JSON.h:546
friend bool operator==(const Array &L, const Array &R)
Definition JSON.h:584
iterator begin()
Definition JSON.h:553
size_t size() const
Definition JSON.h:559
std::vector< Value >::const_iterator const_iterator
Definition JSON.h:172
Value & operator[](size_t I)
Definition JSON.h:544
iterator emplace(const_iterator P, Args &&...A)
Definition JSON.h:580
std::vector< Value >::iterator iterator
Definition JSON.h:171
void pop_back()
Definition JSON.h:568
iterator insert(const_iterator P, const Value &E)
Definition JSON.h:569
bool empty() const
Definition JSON.h:558
void clear()
Definition JSON.h:562
void push_back(const Value &E)
Definition JSON.h:563
void reserve(size_t S)
Definition JSON.h:560
Array(const Collection &C)
Definition JSON.h:176
Value value_type
Definition JSON.h:170
iterator erase(const_iterator P)
Definition JSON.h:583
Value & back()
Definition JSON.h:548
iterator end()
Definition JSON.h:555
json::OStream allows writing well-formed JSON without materializing all structures as json::Value ahe...
Definition JSON.h:1000
void object(Block Contents)
Emit an object whose elements are emitted in the provided Block.
Definition JSON.h:1030
void rawValue(llvm::function_ref< void(raw_ostream &)> Contents)
Emit an externally-serialized value.
Definition JSON.h:1038
void attributeObject(llvm::StringRef Key, Block Contents)
Emit an attribute whose value is an object with attributes from the Block.
Definition JSON.h:1063
OStream(llvm::raw_ostream &OS, unsigned IndentSize=0)
Definition JSON.h:1004
LLVM_ABI void attributeBegin(llvm::StringRef Key)
void attribute(llvm::StringRef Key, const Value &Contents)
Emit an attribute whose value is self-contained (number, vector etc).
Definition JSON.h:1055
void flush()
Flushes the underlying ostream. OStream does not buffer internally.
Definition JSON.h:1015
LLVM_ABI void arrayBegin()
LLVM_ABI void objectBegin()
LLVM_ABI raw_ostream & rawValueBegin()
void attributeArray(llvm::StringRef Key, Block Contents)
Emit an attribute whose value is an array with elements from the Block.
Definition JSON.h:1059
LLVM_ABI void comment(llvm::StringRef)
Emit a JavaScript comment associated with the next printed value.
void array(Block Contents)
Emit an array whose elements are emitted in the provided Block.
Definition JSON.h:1024
LLVM_ABI void attributeEnd()
void rawValue(llvm::StringRef Contents)
Definition JSON.h:1043
LLVM_ABI void value(const Value &V)
Emit a self-contained value (number, string, vector etc).
LLVM_ABI void rawValueEnd()
llvm::function_ref< void()> Block
Definition JSON.h:1002
~OStream()
Definition JSON.h:1008
LLVM_ABI void objectEnd()
ObjectKey is a used to capture keys in Object.
Definition JSON.h:590
ObjectKey & operator=(ObjectKey &&)=default
ObjectKey(ObjectKey &&C)
Definition JSON.h:611
ObjectKey(const ObjectKey &C)
Definition JSON.h:610
ObjectKey(const llvm::formatv_object_base &V)
Definition JSON.h:608
ObjectKey(const char *S)
Definition JSON.h:592
ObjectKey(llvm::StringRef S)
Definition JSON.h:600
operator llvm::StringRef() const
Definition JSON.h:623
ObjectKey(std::string S)
Definition JSON.h:593
std::string str() const
Definition JSON.h:624
ObjectKey & operator=(const ObjectKey &C)
Definition JSON.h:612
ObjectKey(const llvm::SmallVectorImpl< char > &V)
Definition JSON.h:606
ObjectMapper(const Value &E, Path P)
If O is not an object, this mapper is invalid and an error is reported.
Definition JSON.h:866
bool map(StringLiteral Prop, T &Out)
Maps a property to a field.
Definition JSON.h:877
bool mapOptional(StringLiteral Prop, T &Out)
Maps a property to a field, if it exists.
Definition JSON.h:899
bool map(StringLiteral Prop, std::optional< T > &Out)
Maps a property to a field, if it exists.
Definition JSON.h:888
An Object is a JSON object, which maps strings to heterogenous JSON values.
Definition JSON.h:98
iterator end()
Definition JSON.h:117
LLVM_ABI std::optional< bool > getBoolean(StringRef K) const
const_iterator end() const
Definition JSON.h:118
LLVM_ABI Value & operator[](const ObjectKey &K)
Value mapped_type
Definition JSON.h:104
LLVM_ABI std::optional< double > getNumber(StringRef K) const
LLVM_ABI const json::Object * getObject(StringRef K) const
LLVM_ABI std::optional< llvm::StringRef > getString(StringRef K) const
Storage::value_type value_type
Definition JSON.h:105
LLVM_ABI Value * get(StringRef K)
ObjectKey key_type
Definition JSON.h:103
std::pair< iterator, bool > try_emplace(ObjectKey &&K, Ts &&... Args)
Definition JSON.h:130
LLVM_ABI std::optional< int64_t > getInteger(StringRef K) const
bool erase(StringRef K)
Definition JSON.h:658
friend LLVM_ABI bool operator==(const Object &LHS, const Object &RHS)
LLVM_ABI std::optional< std::nullptr_t > getNull(StringRef K) const
std::pair< iterator, bool > try_emplace(const ObjectKey &K, Ts &&... Args)
Definition JSON.h:126
const_iterator begin() const
Definition JSON.h:116
void erase(iterator I)
Definition JSON.h:134
Storage::iterator iterator
Definition JSON.h:106
bool empty() const
Definition JSON.h:120
const_iterator find(StringRef K) const
Definition JSON.h:137
iterator begin()
Definition JSON.h:115
Storage::const_iterator const_iterator
Definition JSON.h:107
iterator find(StringRef K)
Definition JSON.h:136
std::pair< iterator, bool > insert(KV E)
Definition JSON.h:655
size_t size() const
Definition JSON.h:121
void clear()
Definition JSON.h:123
LLVM_ABI const json::Array * getArray(StringRef K) const
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition JSON.h:927
void log(llvm::raw_ostream &OS) const override
Print an error message to an output stream.
Definition JSON.h:924
ParseError(const char *Msg, unsigned Line, unsigned Column, unsigned Offset)
Definition JSON.h:922
static LLVM_ABI char ID
Definition JSON.h:921
The root is the trivial Path to the root value.
Definition JSON.h:715
LLVM_ABI void printErrorContext(const Value &, llvm::raw_ostream &) const
Print the root value with the error shown inline as a comment.
Root & operator=(const Root &)=delete
LLVM_ABI Error getError() const
Returns the last error reported, or else a generic error.
Root(const Root &)=delete
Root & operator=(Root &&)=delete
Root(llvm::StringRef Name="")
Definition JSON.h:723
A "cursor" marking a position within a Value.
Definition JSON.h:668
Path index(unsigned Index) const
Derives a path for an array element: this[Index].
Definition JSON.h:680
LLVM_ABI void report(llvm::StringLiteral Message)
Records that the value at the current path is invalid.
Path field(StringRef Field) const
Derives a path for an object field: this.Field.
Definition JSON.h:682
Path(Root &R)
The root may be treated as a Path.
Definition JSON.h:678
A Value is an JSON value of unknown type.
Definition JSON.h:291
friend class Object
Definition JSON.h:494
LLVM_ABI void print(llvm::raw_ostream &OS) const
Value(json::Object &&Properties)
Definition JSON.h:313
Value(const std::vector< Elt > &C)
Definition JSON.h:312
std::optional< bool > getAsBoolean() const
Definition JSON.h:415
std::optional< double > getAsNumber() const
Definition JSON.h:420
std::optional< uint64_t > getAsUINT64() const
Definition JSON.h:448
Value(std::nullptr_t)
Definition JSON.h:338
Value & operator=(Value &&M)
Definition JSON.h:380
Value(T B)
Definition JSON.h:343
Value(T D)
Definition JSON.h:365
Value(const char *V)
Definition JSON.h:337
~Value()
Definition JSON.h:385
Value(const Value &M)
Definition JSON.h:305
Value & operator=(const Value &M)
Definition JSON.h:375
LLVM_DUMP_METHOD void dump() const
Definition JSON.h:480
Value(const llvm::formatv_object_base &V)
Definition JSON.h:328
Value(Value &&M)
Definition JSON.h:306
json::Object * getAsObject()
Definition JSON.h:468
std::optional< int64_t > getAsInteger() const
Definition JSON.h:430
Value(const llvm::SmallVectorImpl< char > &V)
Definition JSON.h:326
Kind kind() const
Definition JSON.h:387
Value(std::string V)
Definition JSON.h:319
friend class OStream
Definition JSON.h:518
Value(T V)
Definition JSON.h:349
Value(const std::map< std::string, Elt > &C)
Definition JSON.h:317
LLVM_ABI friend bool operator==(const Value &, const Value &)
json::Array * getAsArray()
Definition JSON.h:474
Value(T I)
Definition JSON.h:358
Value(json::Array &&Elements)
Definition JSON.h:308
Kind
Definition JSON.h:293
@ Boolean
Definition JSON.h:295
@ String
Definition JSON.h:299
@ Number
Number values can store both int64s and doubles at full precision, depending on what they were constr...
Definition JSON.h:298
@ Null
Definition JSON.h:294
friend class Array
Definition JSON.h:493
Value(const T &V)
Definition JSON.h:373
Value(StringRef V)
Definition JSON.h:330
std::optional< llvm::StringRef > getAsString() const
Definition JSON.h:458
std::optional< std::nullptr_t > getAsNull() const
Definition JSON.h:410
const json::Object * getAsObject() const
Definition JSON.h:465
const json::Array * getAsArray() const
Definition JSON.h:471
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
constexpr bool is_uint_64_bit_v
Definition JSON.h:79
Value toJSON(const std::optional< T > &Opt)
Definition JSON.h:848
LLVM_ABI llvm::Expected< Value > parse(llvm::StringRef JSON)
Parses the provided JSON source, or returns a ParseError.
bool operator<(const ObjectKey &L, const ObjectKey &R)
Definition JSON.h:639
LLVM_ABI bool operator==(const Object &LHS, const Object &RHS)
LLVM_ABI bool isUTF8(llvm::StringRef S, size_t *ErrOffset=nullptr)
Returns true if S is valid UTF-8, which is required for use as JSON.
bool fromJSON(const Value &E, std::string &Out, Path P)
Definition JSON.h:744
LLVM_ABI std::vector< const Object::value_type * > sortedElements(const Object &O)
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const Value &V)
Serializes this Value to JSON, writing it to the provided stream.
Definition JSON.h:1110
LLVM_ABI std::string fixUTF8(llvm::StringRef S)
Replaces invalid UTF-8 sequences in S with the replacement character (U+FFFD).
bool operator!=(const Object &LHS, const Object &RHS)
Definition JSON.h:160
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
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.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
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
FunctionAddr VTableAddr uintptr_t uintptr_t Data
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
PointerUnion< const Value *, const PseudoSourceValue * > ValueType
Implement std::hash so that hash_code can be used in STL containers.
A suitably aligned and sized character array member which can hold elements of any type.
Value V
Definition JSON.h:645
ObjectKey K
Definition JSON.h:644