/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/DebugInfo/CodeView/Formatters.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===- Formatters.cpp -----------------------------------------------------===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | |
9 | | #include "llvm/DebugInfo/CodeView/Formatters.h" |
10 | | #include "llvm/ADT/ArrayRef.h" |
11 | | #include "llvm/DebugInfo/CodeView/GUID.h" |
12 | | #include "llvm/Support/raw_ostream.h" |
13 | | #include <algorithm> |
14 | | #include <cassert> |
15 | | |
16 | | using namespace llvm; |
17 | | using namespace llvm::codeview; |
18 | | using namespace llvm::codeview::detail; |
19 | | |
20 | | GuidAdapter::GuidAdapter(StringRef Guid) |
21 | 0 | : FormatAdapter(makeArrayRef(Guid.bytes_begin(), Guid.bytes_end())) {} |
22 | | |
23 | | GuidAdapter::GuidAdapter(ArrayRef<uint8_t> Guid) |
24 | 31 | : FormatAdapter(std::move(Guid)) {} |
25 | | |
26 | 31 | void GuidAdapter::format(raw_ostream &Stream, StringRef Style) { |
27 | 31 | static const char *Lookup = "0123456789ABCDEF"; |
28 | 31 | |
29 | 31 | assert(Item.size() == 16 && "Expected 16-byte GUID"); |
30 | 31 | Stream << "{"; |
31 | 527 | for (int i = 0; i < 16;) { |
32 | 496 | uint8_t Byte = Item[i]; |
33 | 496 | uint8_t HighNibble = (Byte >> 4) & 0xF; |
34 | 496 | uint8_t LowNibble = Byte & 0xF; |
35 | 496 | Stream << Lookup[HighNibble] << Lookup[LowNibble]; |
36 | 496 | ++i; |
37 | 496 | if (i >= 4 && i <= 10403 && i % 2 == 0217 ) |
38 | 124 | Stream << "-"; |
39 | 496 | } |
40 | 31 | Stream << "}"; |
41 | 31 | } |
42 | | |
43 | 24 | raw_ostream &llvm::codeview::operator<<(raw_ostream &OS, const GUID &Guid) { |
44 | 24 | codeview::detail::GuidAdapter A(Guid.Guid); |
45 | 24 | A.format(OS, ""); |
46 | 24 | return OS; |
47 | 24 | } |