LLVM: include/llvm/Support/VirtualOutputFile.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef LLVM_SUPPORT_VIRTUALOUTPUTFILE_H
18#define LLVM_SUPPORT_VIRTUALOUTPUTFILE_H
19
26
28
30 LLVM_ABI void anchor() override;
31
32public:
35
39};
40
42 : public RTTIExtends<NullOutputFileImpl, OutputFileImpl> {
43 LLVM_ABI void anchor() override;
44
45public:
50
51private:
53};
54
55
56
57
58
60public:
62
63
65
66 explicit operator bool() const { return isOpen(); }
67
69 assert(isOpen() && "Expected open output stream");
70 return Impl->getOS();
71 }
74 return getOS() << std::forward(V);
75 }
76
77
78
79
80
81
82
84
85
86
87
88
90
91
92
94 DiscardOnDestroyHandler = std::move(Handler);
95 }
96
97
98
99
100
102
104
105
106
107
108
109 std::unique_ptr takeImpl() {
111 assert(!DiscardOnDestroyHandler && "Unexpected discard handler");
112 return std::move(Impl);
113 }
114
115
117
119
120 explicit OutputFile(const Twine &Path, std::unique_ptr Impl)
121 : Path(Path.str()), Impl(std::move(Impl)) {
122 assert(this->Impl && "Expected open output file");
123 }
124
128 destroy();
129 return moveFrom(O);
130 }
131
132private:
133
134
137 Path = std::move(O.Path);
138 Impl = std::move(O.Impl);
139 DiscardOnDestroyHandler = std::move(O.DiscardOnDestroyHandler);
140 OpenProxy = O.OpenProxy;
141 O.OpenProxy = nullptr;
142 return *this;
143 }
144
145 std::string Path;
146 std::unique_ptr Impl;
148
149 class TrackedProxy;
150 TrackedProxy *OpenProxy = nullptr;
151};
152
153
154
158
159
160
166
167}
168
169#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Inheritance utility for extensible RTTI.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
A raw_ostream that discards all output.
This class implements an extremely fast bulk output stream that can only output to a stream.
An abstract base class for streams implementations that also support a pwrite operation.
unique_function is a type-erasing functor similar to std::function.
Definition VirtualOutputFile.h:42
static LLVM_ABI char ID
Definition VirtualOutputFile.h:46
Error discard() final
Definition VirtualOutputFile.h:48
Error keep() final
Definition VirtualOutputFile.h:47
raw_pwrite_stream & getOS() final
Definition VirtualOutputFile.h:49
Definition VirtualOutputFile.h:29
static LLVM_ABI char ID
Definition VirtualOutputFile.h:33
virtual raw_pwrite_stream & getOS()=0
virtual Error discard()=0
~OutputFileImpl() override=default
A virtualized output file that writes to a specific backend.
Definition VirtualOutputFile.h:59
bool isOpen() const
Check if keep() or discard() has already been called.
Definition VirtualOutputFile.h:64
void discardOnDestroy(unique_function< void(Error E)> Handler)
Discard the output when destroying it if it's still open, sending the result to Handler.
Definition VirtualOutputFile.h:93
StringRef getPath() const
Definition VirtualOutputFile.h:61
raw_ostream & operator<<(T &&V)
Definition VirtualOutputFile.h:73
raw_pwrite_stream & getOS()
Definition VirtualOutputFile.h:68
std::unique_ptr< OutputFileImpl > takeImpl()
Take the implementation.
Definition VirtualOutputFile.h:109
~OutputFile()
Definition VirtualOutputFile.h:125
bool isNull() const
Check whether this is a null output file.
Definition VirtualOutputFile.h:116
OutputFile(const Twine &Path, std::unique_ptr< OutputFileImpl > Impl)
Definition VirtualOutputFile.h:120
LLVM_ABI Expected< std::unique_ptr< raw_pwrite_stream > > createProxy()
Create a proxy stream for clients that need to pass an owned stream to a producer.
OutputFile & operator=(OutputFile &&O)
Definition VirtualOutputFile.h:127
bool hasOpenProxy() const
Definition VirtualOutputFile.h:103
LLVM_ABI Error discard()
Discard an output, cleaning up any temporary state.
LLVM_ABI Error keep()
Keep an output.
OutputFile(OutputFile &&O)
Definition VirtualOutputFile.h:126
void consumeDiscardOnDestroy(OutputFile &File)
Update File to silently discard itself if it's still open when it's destroyed.
Definition VirtualOutputFile.h:155
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
void consumeError(Error Err)
Consume a Error without doing anything.
Implement std::hash so that hash_code can be used in STL containers.