1 #include "llvm/Support/ScopedPrinter.h"
3 #include "llvm/Support/Format.h"
5 using namespace llvm::support
;
9 raw_ostream
&operator<<(raw_ostream
&OS
, const HexNumber
&Value
) {
10 OS
<< "0x" << utohexstr(Value
.Value
);
14 void ScopedPrinter::printBinaryImpl(StringRef Label
, StringRef Str
,
15 ArrayRef
<uint8_t> Data
, bool Block
,
16 uint32_t StartOffset
) {
26 OS
<< format_bytes_with_ascii(Data
, StartOffset
, 16, 4,
27 (IndentLevel
+ 1) * 2, true)
31 startLine() << Label
<< ":";
34 OS
<< " (" << format_bytes(Data
, std::nullopt
, Data
.size(), 1, 0, true)
39 JSONScopedPrinter::JSONScopedPrinter(
40 raw_ostream
&OS
, bool PrettyPrint
,
41 std::unique_ptr
<DelimitedScope
> &&OuterScope
)
42 : ScopedPrinter(OS
, ScopedPrinter::ScopedPrinterKind::JSON
),
43 JOS(OS
, /*Indent=*/PrettyPrint
? 2 : 0),
44 OuterScope(std::move(OuterScope
)) {
46 this->OuterScope
->setPrinter(*this);