LLVM 23.0.0git
FormatUtil.h
Go to the documentation of this file.
1//===- FormatUtil.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_PDB_NATIVE_FORMATUTIL_H
10#define LLVM_DEBUGINFO_PDB_NATIVE_FORMATUTIL_H
11
12#include "llvm/ADT/ArrayRef.h"
14#include "llvm/ADT/StringRef.h"
17#include "llvm/Support/Endian.h"
20
21#include <string>
22
23namespace llvm {
24namespace pdb {
25
26#define PUSH_MASKED_FLAG(Enum, Mask, TheOpt, Value, Text) \
27 if (Enum::TheOpt == (Value & Mask)) \
28 Opts.push_back(Text);
29
30#define PUSH_FLAG(Enum, TheOpt, Value, Text) \
31 PUSH_MASKED_FLAG(Enum, Enum::TheOpt, TheOpt, Value, Text)
32
33#define RETURN_CASE(Enum, X, Ret) \
34 case Enum::X: \
35 return Ret;
36
37template <typename T> std::string formatUnknownEnum(T Value) {
38 return formatv("unknown ({0})", llvm::to_underlying(Value)).str();
39}
40
42
44 HeaderDefinition, // format as windows header definition
45 Descriptive, // format as human readable words
46};
48 uint32_t IndentLevel, uint32_t C, uint32_t FlagsPerLine,
49 StringRef Separator,
51
53 uint32_t IndentLevel, uint32_t GroupSize,
54 StringRef Sep);
55
56LLVM_ABI std::string typesetStringList(uint32_t IndentLevel,
57 ArrayRef<StringRef> Strings);
58
60 bool Friendly = true);
63
64namespace detail {
65template <typename T>
66struct EndianAdapter final
67 : public FormatAdapter<support::detail::packed_endian_specific_integral<
68 T, llvm::endianness::little, support::unaligned>> {
71
74
75 void format(llvm::raw_ostream &Stream, StringRef Style) override {
76 format_provider<T>::format(static_cast<T>(this->Item), Stream, Style);
77 }
78};
79} // namespace detail
80
81template <typename T>
87} // namespace pdb
88} // namespace llvm
89#endif
#define LLVM_ABI
Definition Compiler.h:213
#define T
This file contains library features backported from future STL versions.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
LLVM Value Representation.
Definition Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
TypeLeafKind
Duplicate copy of the above enum, but using the official CV names.
Definition CodeView.h:34
SymbolKind
Duplicate copy of the above enum, but using the official CV names.
Definition CodeView.h:48
LLVM_ABI std::string formatSegmentOffset(uint16_t Segment, uint32_t Offset)
std::string formatUnknownEnum(T Value)
Definition FormatUtil.h:37
LLVM_ABI std::string typesetStringList(uint32_t IndentLevel, ArrayRef< StringRef > Strings)
CharacteristicStyle
Definition FormatUtil.h:43
LLVM_ABI std::string formatSymbolKind(codeview::SymbolKind K)
LLVM_ABI std::string formatTypeLeafKind(codeview::TypeLeafKind K)
detail::EndianAdapter< T > fmtle(support::detail::packed_endian_specific_integral< T, llvm::endianness::little, support::unaligned > Value)
Definition FormatUtil.h:82
LLVM_ABI std::string formatChunkKind(codeview::DebugSubsectionKind Kind, bool Friendly=true)
LLVM_ABI std::string formatSectionCharacteristics(uint32_t IndentLevel, uint32_t C, uint32_t FlagsPerLine, StringRef Separator, CharacteristicStyle Style=CharacteristicStyle::HeaderDefinition)
LLVM_ABI std::string typesetItemList(ArrayRef< std::string > Opts, uint32_t IndentLevel, uint32_t GroupSize, StringRef Sep)
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
@ Offset
Definition DWP.cpp:532
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
constexpr std::underlying_type_t< Enum > to_underlying(Enum E)
Returns underlying integer value of an enum.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1917
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:870
support::detail::packed_endian_specific_integral< T, llvm::endianness::little, support::unaligned > EndianType
Definition FormatUtil.h:69
EndianAdapter(EndianType &&Item)
Definition FormatUtil.h:72
void format(llvm::raw_ostream &Stream, StringRef Style) override
Definition FormatUtil.h:75