/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/Support/ScopedPrinter.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | #include "llvm/Support/ScopedPrinter.h" |
2 | | |
3 | | #include "llvm/ADT/StringExtras.h" |
4 | | #include "llvm/Support/Format.h" |
5 | | #include <cctype> |
6 | | |
7 | | using namespace llvm::support; |
8 | | |
9 | | namespace llvm { |
10 | | |
11 | 612k | raw_ostream &operator<<(raw_ostream &OS, const HexNumber &Value) { |
12 | 612k | OS << "0x" << to_hexString(Value.Value); |
13 | 612k | return OS; |
14 | 612k | } |
15 | | |
16 | 612k | const std::string to_hexString(uint64_t Value, bool UpperCase) { |
17 | 612k | std::string number; |
18 | 612k | llvm::raw_string_ostream stream(number); |
19 | 612k | stream << format_hex_no_prefix(Value, 1, UpperCase); |
20 | 612k | return stream.str(); |
21 | 612k | } |
22 | | |
23 | | void ScopedPrinter::printBinaryImpl(StringRef Label, StringRef Str, |
24 | | ArrayRef<uint8_t> Data, bool Block, |
25 | 3.73k | uint32_t StartOffset) { |
26 | 3.73k | if (Data.size() > 16) |
27 | 929 | Block = true; |
28 | 3.73k | |
29 | 3.73k | if (Block3.73k ) { |
30 | 2.03k | startLine() << Label; |
31 | 2.03k | if (!Str.empty()) |
32 | 0 | OS << ": " << Str; |
33 | 2.03k | OS << " (\n"; |
34 | 2.03k | if (!Data.empty()) |
35 | 1.54k | OS << format_bytes_with_ascii(Data, StartOffset, 16, 4, |
36 | 1.54k | (IndentLevel + 1) * 2, true) |
37 | 1.54k | << "\n"; |
38 | 2.03k | startLine() << ")\n"; |
39 | 3.73k | } else { |
40 | 1.70k | startLine() << Label << ":"; |
41 | 1.70k | if (!Str.empty()) |
42 | 1.13k | OS << " " << Str; |
43 | 1.70k | OS << " (" << format_bytes(Data, None, Data.size(), 1, 0, true) << ")\n"; |
44 | 1.70k | } |
45 | 3.73k | } |
46 | | |
47 | | } // namespace llvm |