1 //===- Formatters.cpp -----------------------------------------------------===//
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"
11 #include "llvm/ADT/ArrayRef.h"
12 #include "llvm/DebugInfo/CodeView/GUID.h"
13 #include "llvm/Support/raw_ostream.h"
18 using namespace llvm::codeview
;
19 using namespace llvm::codeview::detail
;
21 GuidAdapter::GuidAdapter(StringRef Guid
)
22 : FormatAdapter(makeArrayRef(Guid
.bytes_begin(), Guid
.bytes_end())) {}
24 GuidAdapter::GuidAdapter(ArrayRef
<uint8_t> Guid
)
25 : FormatAdapter(std::move(Guid
)) {}
27 void GuidAdapter::format(raw_ostream
&Stream
, StringRef Style
) {
28 static const char *Lookup
= "0123456789ABCDEF";
30 assert(Item
.size() == 16 && "Expected 16-byte GUID");
32 for (int i
= 0; i
< 16;) {
33 uint8_t Byte
= Item
[i
];
34 uint8_t HighNibble
= (Byte
>> 4) & 0xF;
35 uint8_t LowNibble
= Byte
& 0xF;
36 Stream
<< Lookup
[HighNibble
] << Lookup
[LowNibble
];
38 if (i
>= 4 && i
<= 10 && i
% 2 == 0)
44 raw_ostream
&llvm::codeview::operator<<(raw_ostream
&OS
, const GUID
&Guid
) {
45 codeview::detail::GuidAdapter
A(Guid
.Guid
);