aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/DebugInfo/CodeView/Formatters.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView/Formatters.cpp')
-rw-r--r--llvm/lib/DebugInfo/CodeView/Formatters.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/Formatters.cpp b/llvm/lib/DebugInfo/CodeView/Formatters.cpp
index a7a8c7f..3a67f31 100644
--- a/llvm/lib/DebugInfo/CodeView/Formatters.cpp
+++ b/llvm/lib/DebugInfo/CodeView/Formatters.cpp
@@ -24,20 +24,21 @@ GuidAdapter::GuidAdapter(ArrayRef<uint8_t> Guid)
: FormatAdapter(std::move(Guid)) {}
void GuidAdapter::format(raw_ostream &Stream, StringRef Style) {
- static const char *Lookup = "0123456789ABCDEF";
-
assert(Item.size() == 16 && "Expected 16-byte GUID");
- Stream << "{";
- for (int i = 0; i < 16;) {
- uint8_t Byte = Item[i];
- uint8_t HighNibble = (Byte >> 4) & 0xF;
- uint8_t LowNibble = Byte & 0xF;
- Stream << Lookup[HighNibble] << Lookup[LowNibble];
- ++i;
- if (i >= 4 && i <= 10 && i % 2 == 0)
- Stream << "-";
- }
- Stream << "}";
+ struct MSGuid {
+ support::ulittle32_t Data1;
+ support::ulittle16_t Data2;
+ support::ulittle16_t Data3;
+ support::ubig64_t Data4;
+ };
+ const MSGuid *G = reinterpret_cast<const MSGuid *>(Item.data());
+ Stream
+ << '{' << format_hex_no_prefix(G->Data1, sizeof(G->Data1), /*Upper=*/true)
+ << '-' << format_hex_no_prefix(G->Data2, sizeof(G->Data2), /*Upper=*/true)
+ << '-' << format_hex_no_prefix(G->Data3, sizeof(G->Data3), /*Upper=*/true)
+ << '-' << format_hex_no_prefix(G->Data4 >> 48, 2, /*Upper=*/true) << '-'
+ << format_hex_no_prefix(G->Data4 & ((1ULL << 48) - 1), 6, /*Upper=*/true)
+ << '}';
}
raw_ostream &llvm::codeview::operator<<(raw_ostream &OS, const GUID &Guid) {