12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #include "llvm/DebugInfo/CodeView/Formatters.h"
- #include "llvm/ADT/ArrayRef.h"
- #include "llvm/DebugInfo/CodeView/GUID.h"
- #include "llvm/Support/Endian.h"
- #include "llvm/Support/ErrorHandling.h"
- #include "llvm/Support/Format.h"
- #include "llvm/Support/raw_ostream.h"
- #include <cassert>
- using namespace llvm;
- using namespace llvm::codeview;
- using namespace llvm::codeview::detail;
- GuidAdapter::GuidAdapter(StringRef Guid)
- : FormatAdapter(ArrayRef(Guid.bytes_begin(), Guid.bytes_end())) {}
- GuidAdapter::GuidAdapter(ArrayRef<uint8_t> Guid)
- : FormatAdapter(std::move(Guid)) {}
- void GuidAdapter::format(raw_ostream &Stream, StringRef Style) {
- assert(Item.size() == 16 && "Expected 16-byte GUID");
- 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, 8, true)
- << '-' << format_hex_no_prefix(G->Data2, 4, true)
- << '-' << format_hex_no_prefix(G->Data3, 4, true)
- << '-' << format_hex_no_prefix(G->Data4 >> 48, 4, true) << '-'
- << format_hex_no_prefix(G->Data4 & ((1ULL << 48) - 1), 12, true)
- << '}';
- }
- raw_ostream &llvm::codeview::operator<<(raw_ostream &OS, const GUID &Guid) {
- codeview::detail::GuidAdapter A(Guid.Guid);
- A.format(OS, "");
- return OS;
- }
|