LLVM 22.0.0git
VirtualOutputConfig.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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/// \file
10/// This file contains the declarations of the OutputConfig class.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_SUPPORT_VIRTUALOUTPUTCONFIG_H
15#define LLVM_SUPPORT_VIRTUALOUTPUTCONFIG_H
16
17namespace llvm {
18
19class raw_ostream;
20
21namespace sys::fs {
22enum OpenFlags : unsigned;
23} // end namespace sys::fs
24
25namespace vfs {
26
27namespace detail {
28/// Unused and empty base class to allow OutputConfig constructor to be
29/// constexpr, with commas before every field's initializer.
31} // namespace detail
32
33/// Full configuration for an output for use by the \a OutputBackend. Each
34/// configuration flag is either \c true or \c false.
36public:
37 void print(raw_ostream &OS) const;
38 void dump() const;
39
40#define HANDLE_OUTPUT_CONFIG_FLAG(NAME, DEFAULT) \
41 constexpr bool get##NAME() const { return NAME; } \
42 constexpr bool getNo##NAME() const { return !NAME; } \
43 constexpr OutputConfig &set##NAME(bool Value) { \
44 NAME = Value; \
45 return *this; \
46 } \
47 constexpr OutputConfig &set##NAME() { return set##NAME(true); } \
48 constexpr OutputConfig &setNo##NAME() { return set##NAME(false); }
49#include "llvm/Support/VirtualOutputConfig.def"
50
51 constexpr OutputConfig &setBinary() { return setNoText().setNoCRLF(); }
52 constexpr OutputConfig &setTextWithCRLF() { return setText().setCRLF(); }
54 return Value ? setText().setCRLF() : setBinary();
55 }
56 constexpr bool getTextWithCRLF() const { return getText() && getCRLF(); }
57 constexpr bool getBinary() const { return !getText(); }
58
59 /// Updates Text and CRLF flags based on \a sys::fs::OF_Text and \a
60 /// sys::fs::OF_CRLF in \p Flags. Rejects CRLF without Text (calling
61 /// \a setBinary()).
63
64 constexpr OutputConfig()
65 : EmptyBaseClass()
66#define HANDLE_OUTPUT_CONFIG_FLAG(NAME, DEFAULT) , NAME(DEFAULT)
67#include "llvm/Support/VirtualOutputConfig.def"
68 {
69 }
70
72#define HANDLE_OUTPUT_CONFIG_FLAG(NAME, DEFAULT) \
73 if (NAME != RHS.NAME) \
74 return false;
75#include "llvm/Support/VirtualOutputConfig.def"
76 return true;
77 }
78 bool operator!=(OutputConfig RHS) const { return !operator==(RHS); }
79
80private:
81#define HANDLE_OUTPUT_CONFIG_FLAG(NAME, DEFAULT) bool NAME : 1;
82#include "llvm/Support/VirtualOutputConfig.def"
83};
84
85} // namespace vfs
86
87raw_ostream &operator<<(raw_ostream &OS, vfs::OutputConfig Config);
88
89} // namespace llvm
90
91#endif // LLVM_SUPPORT_VIRTUALOUTPUTCONFIG_H
@ DEFAULT
Default weight is used in cases when there is no dedicated execution weight set.
#define HANDLE_OUTPUT_CONFIG_FLAG(NAME, DEFAULT)
Value * RHS
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
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Full configuration for an output for use by the OutputBackend.
bool operator==(OutputConfig RHS) const
constexpr bool getTextWithCRLF() const
constexpr OutputConfig & setBinary()
void print(raw_ostream &OS) const
constexpr OutputConfig & setTextWithCRLF(bool Value)
OutputConfig & setOpenFlags(const sys::fs::OpenFlags &Flags)
Updates Text and CRLF flags based on sys::fs::OF_Text and sys::fs::OF_CRLF in Flags.
constexpr bool getBinary() const
constexpr OutputConfig & setTextWithCRLF()
bool operator!=(OutputConfig RHS) const
Unused and empty base class to allow OutputConfig constructor to be constexpr, with commas before eve...