LLVM  10.0.0svn
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  static const char *Lookup = "0123456789ABCDEF";
28 
29  assert(Item.size() == 16 && "Expected 16-byte GUID");
30  Stream << "{";
31  for (int i = 0; i < 16;) {
32  uint8_t Byte = Item[i];
33  uint8_t HighNibble = (Byte >> 4) & 0xF;
34  uint8_t LowNibble = Byte & 0xF;
35  Stream << Lookup[HighNibble] << Lookup[LowNibble];
36  ++i;
37  if (i >= 4 && i <= 10 && i % 2 == 0)
38  Stream << "-";
39  }
40  Stream << "}";
41 }
42 
45  A.format(OS, "");
46  return OS;
47 }
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Definition: BitVector.h:937
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:450
static int Lookup(ArrayRef< TableEntry > Table, unsigned Opcode)
void format(raw_ostream &Stream, StringRef Style) override
Definition: Formatters.cpp:26
This represents the &#39;GUID&#39; type from windows.h.
Definition: GUID.h:21
uint8_t Guid[16]
Definition: GUID.h:22
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:148
raw_ostream & operator<<(raw_ostream &OS, const GUID &Guid)
Definition: Formatters.cpp:43
GuidAdapter(ArrayRef< uint8_t > Guid)
Definition: Formatters.cpp:23
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48