LLVM  10.0.0svn
Formatters.h
Go to the documentation of this file.
1 //===- Formatters.h ---------------------------------------------*- C++ -*-===//
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 
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
10 #define LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
11 
12 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/StringRef.h"
19 #include <cstdint>
20 
21 namespace llvm {
22 
23 namespace codeview {
24 
25 namespace detail {
26 
27 class GuidAdapter final : public FormatAdapter<ArrayRef<uint8_t>> {
28  ArrayRef<uint8_t> Guid;
29 
30 public:
31  explicit GuidAdapter(ArrayRef<uint8_t> Guid);
32  explicit GuidAdapter(StringRef Guid);
33 
34  void format(raw_ostream &Stream, StringRef Style) override;
35 };
36 
37 } // end namespace detail
38 
40  return detail::GuidAdapter(Item);
41 }
42 
44  return detail::GuidAdapter(Item);
45 }
46 
47 } // end namespace codeview
48 
49 template <> struct format_provider<codeview::TypeIndex> {
50 public:
51  static void format(const codeview::TypeIndex &V, raw_ostream &Stream,
52  StringRef Style) {
53  if (V.isNoneType())
54  Stream << "<no type>";
55  else {
56  Stream << formatv("{0:X+4}", V.getIndex());
57  if (V.isSimple())
58  Stream << " (" << codeview::TypeIndex::simpleTypeName(V) << ")";
59  }
60  }
61 };
62 
63 template <> struct format_provider<codeview::GUID> {
64  static void format(const codeview::GUID &V, llvm::raw_ostream &Stream,
65  StringRef Style) {
66  Stream << V;
67  }
68 };
69 
70 } // end namespace llvm
71 
72 #endif // LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
bool isNoneType() const
Definition: TypeIndex.h:115
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
static void format(const codeview::TypeIndex &V, raw_ostream &Stream, StringRef Style)
Definition: Formatters.h:51
A 32-bit type reference.
Definition: TypeIndex.h:95
detail::GuidAdapter fmt_guid(StringRef Item)
Definition: Formatters.h:39
static void format(const codeview::GUID &V, llvm::raw_ostream &Stream, StringRef Style)
Definition: Formatters.h:64
static StringRef simpleTypeName(TypeIndex TI)
Definition: TypeIndex.cpp:70
uint32_t getIndex() const
Definition: TypeIndex.h:110
GuidAdapter(ArrayRef< uint8_t > Guid)
Definition: Formatters.cpp:23
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