LLVM  13.0.0git
ScopedPrinter.cpp
Go to the documentation of this file.
2 
3 #include "llvm/Support/Format.h"
4 #include <cctype>
5 
6 using namespace llvm::support;
7 
8 namespace llvm {
9 
11  OS << "0x" << to_hexString(Value.Value);
12  return OS;
13 }
14 
15 std::string to_hexString(uint64_t Value, bool UpperCase) {
16  std::string number;
17  llvm::raw_string_ostream stream(number);
18  stream << format_hex_no_prefix(Value, 1, UpperCase);
19  return stream.str();
20 }
21 
22 void ScopedPrinter::printBinaryImpl(StringRef Label, StringRef Str,
23  ArrayRef<uint8_t> Data, bool Block,
24  uint32_t StartOffset) {
25  if (Data.size() > 16)
26  Block = true;
27 
28  if (Block) {
29  startLine() << Label;
30  if (!Str.empty())
31  OS << ": " << Str;
32  OS << " (\n";
33  if (!Data.empty())
34  OS << format_bytes_with_ascii(Data, StartOffset, 16, 4,
35  (IndentLevel + 1) * 2, true)
36  << "\n";
37  startLine() << ")\n";
38  } else {
39  startLine() << Label << ":";
40  if (!Str.empty())
41  OS << " " << Str;
42  OS << " (" << format_bytes(Data, None, Data.size(), 1, 0, true) << ")\n";
43  }
44 }
45 
46 } // namespace llvm
llvm
Definition: AllocatorList.h:23
llvm::format_bytes
FormattedBytes format_bytes(ArrayRef< uint8_t > Bytes, Optional< uint64_t > FirstByteOffset=None, uint32_t NumPerLine=16, uint8_t ByteGroupSize=4, uint32_t IndentLevel=0, bool Upper=false)
Definition: Format.h:239
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:614
llvm::to_hexString
std::string to_hexString(uint64_t Value, bool UpperCase=true)
Definition: ScopedPrinter.cpp:15
Format.h
llvm::format_hex_no_prefix
FormattedNumber format_hex_no_prefix(uint64_t N, unsigned Width, bool Upper=false)
format_hex_no_prefix - Output N as a fixed width hexadecimal.
Definition: Format.h:199
llvm::Data
@ Data
Definition: SIMachineScheduler.h:56
llvm::rust_demangle::BasicType::Str
@ Str
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:50
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:230
llvm::Value::Value
Value(Type *Ty, unsigned scid)
Definition: Value.cpp:53
llvm::HexNumber
Definition: ScopedPrinter.h:39
uint32_t
llvm::pdb::PDB_SymType::Label
@ Label
llvm::support
Definition: Endian.h:25
llvm::format_bytes_with_ascii
FormattedBytes format_bytes_with_ascii(ArrayRef< uint8_t > Bytes, Optional< uint64_t > FirstByteOffset=None, uint32_t NumPerLine=16, uint8_t ByteGroupSize=4, uint32_t IndentLevel=0, bool Upper=false)
Definition: Format.h:247
llvm::raw_string_ostream::str
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
Definition: raw_ostream.h:632
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
ScopedPrinter.h