1 //===- Formatters.h ---------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
10 #define LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
12 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/DebugInfo/CodeView/GUID.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"
27 class GuidAdapter final
: public FormatAdapter
<ArrayRef
<uint8_t>> {
28 ArrayRef
<uint8_t> Guid
;
31 explicit GuidAdapter(ArrayRef
<uint8_t> Guid
);
32 explicit GuidAdapter(StringRef Guid
);
34 void format(raw_ostream
&Stream
, StringRef Style
) override
;
37 } // end namespace detail
39 inline detail::GuidAdapter
fmt_guid(StringRef Item
) {
40 return detail::GuidAdapter(Item
);
43 inline detail::GuidAdapter
fmt_guid(ArrayRef
<uint8_t> Item
) {
44 return detail::GuidAdapter(Item
);
47 } // end namespace codeview
49 template <> struct format_provider
<codeview::TypeIndex
> {
51 static void format(const codeview::TypeIndex
&V
, raw_ostream
&Stream
,
54 Stream
<< "<no type>";
56 Stream
<< formatv("{0:X+4}", V
.getIndex());
58 Stream
<< " (" << codeview::TypeIndex::simpleTypeName(V
) << ")";
63 template <> struct format_provider
<codeview::GUID
> {
64 static void format(const codeview::GUID
&V
, llvm::raw_ostream
&Stream
,
70 } // end namespace llvm
72 #endif // LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H