]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/CodeView/Formatters.h
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r306956, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / DebugInfo / CodeView / Formatters.h
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"
15 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
16 #include "llvm/Support/FormatAdapters.h"
17 #include "llvm/Support/FormatVariadic.h"
18 #include "llvm/Support/raw_ostream.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
39 inline detail::GuidAdapter fmt_guid(StringRef Item) {
40   return detail::GuidAdapter(Item);
41 }
42
43 inline detail::GuidAdapter fmt_guid(ArrayRef<uint8_t> Item) {
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 } // end namespace llvm
64
65 #endif // LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H