LLVM  13.0.0git
Formatters.cpp
Go to the documentation of this file.
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 
10 #include "llvm/ADT/ArrayRef.h"
13 #include <algorithm>
14 #include <cassert>
15 
16 using namespace llvm;
17 using namespace llvm::codeview;
18 using namespace llvm::codeview::detail;
19 
21  : FormatAdapter(makeArrayRef(Guid.bytes_begin(), Guid.bytes_end())) {}
22 
24  : FormatAdapter(std::move(Guid)) {}
25 
27  assert(Item.size() == 16 && "Expected 16-byte GUID");
28  struct MSGuid {
32  support::ubig64_t Data4;
33  };
34  const MSGuid *G = reinterpret_cast<const MSGuid *>(Item.data());
35  Stream
36  << '{' << format_hex_no_prefix(G->Data1, sizeof(G->Data1), /*Upper=*/true)
37  << '-' << format_hex_no_prefix(G->Data2, sizeof(G->Data2), /*Upper=*/true)
38  << '-' << format_hex_no_prefix(G->Data3, sizeof(G->Data3), /*Upper=*/true)
39  << '-' << format_hex_no_prefix(G->Data4 >> 48, 2, /*Upper=*/true) << '-'
40  << format_hex_no_prefix(G->Data4 & ((1ULL << 48) - 1), 6, /*Upper=*/true)
41  << '}';
42 }
43 
46  A.format(OS, "");
47  return OS;
48 }
llvm::codeview::detail::GuidAdapter::GuidAdapter
GuidAdapter(ArrayRef< uint8_t > Guid)
Definition: Formatters.cpp:23
llvm
Definition: AllocatorList.h:23
GUID.h
llvm::FormatAdapter< ArrayRef< uint8_t > >::Item
ArrayRef< uint8_t > Item
Definition: FormatAdapters.h:23
llvm::support::detail::packed_endian_specific_integral
Definition: Endian.h:206
llvm::codeview::GUID
This represents the 'GUID' type from windows.h.
Definition: GUID.h:21
llvm::format_hex_no_prefix
FormattedNumber format_hex_no_prefix(uint64_t N, unsigned Width, bool Upper=false)
format_hex_no_prefix - Output N as a fixed width hexadecimal.
Definition: Format.h:199
llvm::ArrayRef::data
const T * data() const
Definition: ArrayRef.h:162
Formatters.h
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:50
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
llvm::codeview::detail::GuidAdapter::format
void format(raw_ostream &Stream, StringRef Style) override
Definition: Formatters.cpp:26
ArrayRef.h
llvm::HexStyle::Style
Style
Definition: MCInstPrinter.h:32
llvm::codeview::detail
Definition: DebugSubsectionVisitor.h:68
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1540
llvm::codeview::operator<<
raw_ostream & operator<<(raw_ostream &OS, const GUID &Guid)
Definition: Formatters.cpp:44
llvm::ArrayRef< uint8_t >
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::codeview::detail::GuidAdapter
Definition: Formatters.h:27
llvm::FormatAdapter
Definition: FormatAdapters.h:19
std
Definition: BitVector.h:838
llvm::codeview::GUID::Guid
uint8_t Guid[16]
Definition: GUID.h:22
llvm::codeview
Definition: AppendingTypeTableBuilder.h:22
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:476
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:165
raw_ostream.h