LLVM 22.0.0git
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"
20#include <cstdint>
21
22namespace llvm {
23
24namespace codeview {
25
26struct GUID;
27
28namespace detail {
29
30class LLVM_ABI GuidAdapter final : public FormatAdapter<ArrayRef<uint8_t>> {
32
33public:
34 explicit GuidAdapter(ArrayRef<uint8_t> Guid);
35 explicit GuidAdapter(StringRef Guid);
36
37 void format(raw_ostream &Stream, StringRef Style) override;
38};
39
40} // end namespace detail
41
43 return detail::GuidAdapter(Item);
44}
45
49
50} // end namespace codeview
51
52template <> struct format_provider<codeview::TypeIndex> {
53public:
54 static void format(const codeview::TypeIndex &V, raw_ostream &Stream,
55 StringRef Style) {
56 if (V.isNoneType())
57 Stream << "<no type>";
58 else {
59 Stream << formatv("{0:X+4}", V.getIndex());
60 if (V.isSimple())
61 Stream << " (" << codeview::TypeIndex::simpleTypeName(V) << ")";
62 }
63 }
64};
65
66template <> struct format_provider<codeview::GUID> {
67 static void format(const codeview::GUID &V, llvm::raw_ostream &Stream,
68 StringRef Style) {
69 Stream << V;
70 }
71};
72
73} // end namespace llvm
74
75#endif // LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
#define LLVM_ABI
Definition Compiler.h:213
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
FormatAdapter(ArrayRef< uint8_t > &&Item)
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
A 32-bit type reference.
Definition TypeIndex.h:97
static LLVM_ABI StringRef simpleTypeName(TypeIndex TI)
Definition TypeIndex.cpp:71
GuidAdapter(ArrayRef< uint8_t > Guid)
void format(raw_ostream &Stream, StringRef Style) override
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
detail::GuidAdapter fmt_guid(StringRef Item)
Definition Formatters.h:42
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
This represents the 'GUID' type from windows.h.
Definition GUID.h:22
static void format(const codeview::GUID &V, llvm::raw_ostream &Stream, StringRef Style)
Definition Formatters.h:67
static void format(const codeview::TypeIndex &V, raw_ostream &Stream, StringRef Style)
Definition Formatters.h:54