LLVM  6.0.0svn
Formatters.h
Go to the documentation of this file.
1 //===- Formatters.h ---------------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
11 #define LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
12 
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/StringRef.h"
20 #include <cstdint>
21 
22 namespace llvm {
23 
24 namespace codeview {
25 
26 namespace detail {
27 
28 class GuidAdapter final : public FormatAdapter<ArrayRef<uint8_t>> {
29  ArrayRef<uint8_t> Guid;
30 
31 public:
32  explicit GuidAdapter(ArrayRef<uint8_t> Guid);
33  explicit GuidAdapter(StringRef Guid);
34 
35  void format(raw_ostream &Stream, StringRef Style) override;
36 };
37 
38 } // end namespace detail
39 
41  return detail::GuidAdapter(Item);
42 }
43 
45  return detail::GuidAdapter(Item);
46 }
47 
48 } // end namespace codeview
49 
50 template <> struct format_provider<codeview::TypeIndex> {
51 public:
52  static void format(const codeview::TypeIndex &V, raw_ostream &Stream,
53  StringRef Style) {
54  if (V.isNoneType())
55  Stream << "<no type>";
56  else {
57  Stream << formatv("{0:X+4}", V.getIndex());
58  if (V.isSimple())
59  Stream << " (" << codeview::TypeIndex::simpleTypeName(V) << ")";
60  }
61  }
62 };
63 
64 template <> struct format_provider<codeview::GUID> {
65  static void format(const codeview::GUID &V, llvm::raw_ostream &Stream,
66  StringRef Style) {
67  Stream << V;
68  }
69 };
70 
71 } // end namespace llvm
72 
73 #endif // LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
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:114
void format(raw_ostream &Stream, StringRef Style) override
Definition: Formatters.cpp:27
This represents the &#39;GUID&#39; type from windows.h.
Definition: GUID.h:22
static void format(const codeview::TypeIndex &V, raw_ostream &Stream, StringRef Style)
Definition: Formatters.h:52
A 32-bit type reference.
Definition: TypeIndex.h:96
detail::GuidAdapter fmt_guid(StringRef Item)
Definition: Formatters.h:40
static void format(const codeview::GUID &V, llvm::raw_ostream &Stream, StringRef Style)
Definition: Formatters.h:65
static StringRef simpleTypeName(TypeIndex TI)
Definition: TypeIndex.cpp:71
uint32_t getIndex() const
Definition: TypeIndex.h:110
GuidAdapter(ArrayRef< uint8_t > Guid)
Definition: Formatters.cpp:24
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49