1 //===- Formatters.cpp -------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/DebugInfo/CodeView/Formatters.h"
13 using namespace llvm::codeview;
14 using namespace llvm::codeview::detail;
16 GuidAdapter::GuidAdapter(StringRef Guid)
17 : FormatAdapter(makeArrayRef(Guid.bytes_begin(), Guid.bytes_end())) {}
19 GuidAdapter::GuidAdapter(ArrayRef<uint8_t> Guid)
20 : FormatAdapter(std::move(Guid)) {}
22 void GuidAdapter::format(llvm::raw_ostream &Stream, StringRef Style) {
23 static const char *Lookup = "0123456789ABCDEF";
25 assert(Item.size() == 16 && "Expected 16-byte GUID");
27 for (int i = 0; i < 16;) {
28 uint8_t Byte = Item[i];
29 uint8_t HighNibble = (Byte >> 4) & 0xF;
30 uint8_t LowNibble = Byte & 0xF;
31 Stream << Lookup[HighNibble] << Lookup[LowNibble];
33 if (i >= 4 && i <= 10 && i % 2 == 0)