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