/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/include/llvm/Support/Error.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===- llvm/Support/Error.h - Recoverable error handling --------*- C++ -*-===// |
2 | | // |
3 | | // The LLVM Compiler Infrastructure |
4 | | // |
5 | | // This file is distributed under the University of Illinois Open Source |
6 | | // License. See LICENSE.TXT for details. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | // |
10 | | // This file defines an API used to report recoverable errors. |
11 | | // |
12 | | //===----------------------------------------------------------------------===// |
13 | | |
14 | | #ifndef LLVM_SUPPORT_ERROR_H |
15 | | #define LLVM_SUPPORT_ERROR_H |
16 | | |
17 | | #include "llvm/ADT/SmallVector.h" |
18 | | #include "llvm/ADT/STLExtras.h" |
19 | | #include "llvm/ADT/StringExtras.h" |
20 | | #include "llvm/ADT/Twine.h" |
21 | | #include "llvm/Config/abi-breaking.h" |
22 | | #include "llvm/Support/AlignOf.h" |
23 | | #include "llvm/Support/Compiler.h" |
24 | | #include "llvm/Support/Debug.h" |
25 | | #include "llvm/Support/ErrorHandling.h" |
26 | | #include "llvm/Support/ErrorOr.h" |
27 | | #include "llvm/Support/raw_ostream.h" |
28 | | #include <algorithm> |
29 | | #include <cassert> |
30 | | #include <cstdint> |
31 | | #include <cstdlib> |
32 | | #include <functional> |
33 | | #include <memory> |
34 | | #include <new> |
35 | | #include <string> |
36 | | #include <system_error> |
37 | | #include <type_traits> |
38 | | #include <utility> |
39 | | #include <vector> |
40 | | |
41 | | namespace llvm { |
42 | | |
43 | | class ErrorSuccess; |
44 | | |
45 | | /// Base class for error info classes. Do not extend this directly: Extend |
46 | | /// the ErrorInfo template subclass instead. |
47 | | class ErrorInfoBase { |
48 | | public: |
49 | 27.8k | virtual ~ErrorInfoBase() = default; |
50 | | |
51 | | /// Print an error message to an output stream. |
52 | | virtual void log(raw_ostream &OS) const = 0; |
53 | | |
54 | | /// Return the error message as a string. |
55 | 2.58k | virtual std::string message() const { |
56 | 2.58k | std::string Msg; |
57 | 2.58k | raw_string_ostream OS(Msg); |
58 | 2.58k | log(OS); |
59 | 2.58k | return OS.str(); |
60 | 2.58k | } |
61 | | |
62 | | /// Convert this error to a std::error_code. |
63 | | /// |
64 | | /// This is a temporary crutch to enable interaction with code still |
65 | | /// using std::error_code. It will be removed in the future. |
66 | | virtual std::error_code convertToErrorCode() const = 0; |
67 | | |
68 | | // Returns the class ID for this type. |
69 | 81.4k | static const void *classID() { return &ID; } |
70 | | |
71 | | // Returns the class ID for the dynamic type of this ErrorInfoBase instance. |
72 | | virtual const void *dynamicClassID() const = 0; |
73 | | |
74 | | // Check whether this instance is a subclass of the class identified by |
75 | | // ClassID. |
76 | 54.5k | virtual bool isA(const void *const ClassID) const { |
77 | 54.5k | return ClassID == classID(); |
78 | 54.5k | } |
79 | | |
80 | | // Check whether this instance is a subclass of ErrorInfoT. |
81 | 54.9k | template <typename ErrorInfoT> bool isA() const { |
82 | 54.9k | return isA(ErrorInfoT::classID()); |
83 | 54.9k | } bool llvm::ErrorInfoBase::isA<llvm::ErrorList>() const Line | Count | Source | 81 | 27.6k | template <typename ErrorInfoT> bool isA() const { | 82 | 27.6k | return isA(ErrorInfoT::classID()); | 83 | 27.6k | } |
bool llvm::ErrorInfoBase::isA<llvm::InstrProfError>() const Line | Count | Source | 81 | 368 | template <typename ErrorInfoT> bool isA() const { | 82 | 368 | return isA(ErrorInfoT::classID()); | 83 | 368 | } |
bool llvm::ErrorInfoBase::isA<llvm::ErrorInfoBase>() const Line | Count | Source | 81 | 26.8k | template <typename ErrorInfoT> bool isA() const { | 82 | 26.8k | return isA(ErrorInfoT::classID()); | 83 | 26.8k | } |
|
84 | | |
85 | | private: |
86 | | virtual void anchor(); |
87 | | |
88 | | static char ID; |
89 | | }; |
90 | | |
91 | | /// Lightweight error class with error context and mandatory checking. |
92 | | /// |
93 | | /// Instances of this class wrap a ErrorInfoBase pointer. Failure states |
94 | | /// are represented by setting the pointer to a ErrorInfoBase subclass |
95 | | /// instance containing information describing the failure. Success is |
96 | | /// represented by a null pointer value. |
97 | | /// |
98 | | /// Instances of Error also contains a 'Checked' flag, which must be set |
99 | | /// before the destructor is called, otherwise the destructor will trigger a |
100 | | /// runtime error. This enforces at runtime the requirement that all Error |
101 | | /// instances be checked or returned to the caller. |
102 | | /// |
103 | | /// There are two ways to set the checked flag, depending on what state the |
104 | | /// Error instance is in. For Error instances indicating success, it |
105 | | /// is sufficient to invoke the boolean conversion operator. E.g.: |
106 | | /// |
107 | | /// @code{.cpp} |
108 | | /// Error foo(<...>); |
109 | | /// |
110 | | /// if (auto E = foo(<...>)) |
111 | | /// return E; // <- Return E if it is in the error state. |
112 | | /// // We have verified that E was in the success state. It can now be safely |
113 | | /// // destroyed. |
114 | | /// @endcode |
115 | | /// |
116 | | /// A success value *can not* be dropped. For example, just calling 'foo(<...>)' |
117 | | /// without testing the return value will raise a runtime error, even if foo |
118 | | /// returns success. |
119 | | /// |
120 | | /// For Error instances representing failure, you must use either the |
121 | | /// handleErrors or handleAllErrors function with a typed handler. E.g.: |
122 | | /// |
123 | | /// @code{.cpp} |
124 | | /// class MyErrorInfo : public ErrorInfo<MyErrorInfo> { |
125 | | /// // Custom error info. |
126 | | /// }; |
127 | | /// |
128 | | /// Error foo(<...>) { return make_error<MyErrorInfo>(...); } |
129 | | /// |
130 | | /// auto E = foo(<...>); // <- foo returns failure with MyErrorInfo. |
131 | | /// auto NewE = |
132 | | /// handleErrors(E, |
133 | | /// [](const MyErrorInfo &M) { |
134 | | /// // Deal with the error. |
135 | | /// }, |
136 | | /// [](std::unique_ptr<OtherError> M) -> Error { |
137 | | /// if (canHandle(*M)) { |
138 | | /// // handle error. |
139 | | /// return Error::success(); |
140 | | /// } |
141 | | /// // Couldn't handle this error instance. Pass it up the stack. |
142 | | /// return Error(std::move(M)); |
143 | | /// ); |
144 | | /// // Note - we must check or return NewE in case any of the handlers |
145 | | /// // returned a new error. |
146 | | /// @endcode |
147 | | /// |
148 | | /// The handleAllErrors function is identical to handleErrors, except |
149 | | /// that it has a void return type, and requires all errors to be handled and |
150 | | /// no new errors be returned. It prevents errors (assuming they can all be |
151 | | /// handled) from having to be bubbled all the way to the top-level. |
152 | | /// |
153 | | /// *All* Error instances must be checked before destruction, even if |
154 | | /// they're moved-assigned or constructed from Success values that have already |
155 | | /// been checked. This enforces checking through all levels of the call stack. |
156 | | class LLVM_NODISCARD Error { |
157 | | // ErrorList needs to be able to yank ErrorInfoBase pointers out of this |
158 | | // class to add to the error list. |
159 | | friend class ErrorList; |
160 | | |
161 | | // handleErrors needs to be able to set the Checked flag. |
162 | | template <typename... HandlerTs> |
163 | | friend Error handleErrors(Error E, HandlerTs &&... Handlers); |
164 | | |
165 | | // Expected<T> needs to be able to steal the payload when constructed from an |
166 | | // error. |
167 | | template <typename T> friend class Expected; |
168 | | |
169 | | protected: |
170 | | /// Create a success value. Prefer using 'Error::success()' for readability |
171 | 39.0M | Error() { |
172 | 39.0M | setPtr(nullptr); |
173 | 39.0M | setChecked(false); |
174 | 39.0M | } |
175 | | |
176 | | public: |
177 | | /// Create a success value. |
178 | | static ErrorSuccess success(); |
179 | | |
180 | | // Errors are not copy-constructable. |
181 | | Error(const Error &Other) = delete; |
182 | | |
183 | | /// Move-construct an error value. The newly constructed error is considered |
184 | | /// unchecked, even if the source error had been checked. The original error |
185 | | /// becomes a checked Success value, regardless of its original state. |
186 | 40.0M | Error(Error &&Other) { |
187 | 40.0M | setChecked(true); |
188 | 40.0M | *this = std::move(Other); |
189 | 40.0M | } |
190 | | |
191 | | /// Create an error value. Prefer using the 'make_error' function, but |
192 | | /// this constructor can be useful when "re-throwing" errors from handlers. |
193 | 73.0k | Error(std::unique_ptr<ErrorInfoBase> Payload) { |
194 | 73.0k | setPtr(Payload.release()); |
195 | 73.0k | setChecked(false); |
196 | 73.0k | } |
197 | | |
198 | | // Errors are not copy-assignable. |
199 | | Error &operator=(const Error &Other) = delete; |
200 | | |
201 | | /// Move-assign an error value. The current error must represent success, you |
202 | | /// you cannot overwrite an unhandled error. The current error is then |
203 | | /// considered unchecked. The source error becomes a checked success value, |
204 | | /// regardless of its original state. |
205 | 40.0M | Error &operator=(Error &&Other) { |
206 | 40.0M | // Don't allow overwriting of unchecked values. |
207 | 40.0M | assertIsChecked(); |
208 | 40.0M | setPtr(Other.getPtr()); |
209 | 40.0M | |
210 | 40.0M | // This Error is unchecked, even if the source error was checked. |
211 | 40.0M | setChecked(false); |
212 | 40.0M | |
213 | 40.0M | // Null out Other's payload and set its checked bit. |
214 | 40.0M | Other.setPtr(nullptr); |
215 | 40.0M | Other.setChecked(true); |
216 | 40.0M | |
217 | 40.0M | return *this; |
218 | 40.0M | } |
219 | | |
220 | | /// Destroy a Error. Fails with a call to abort() if the error is |
221 | | /// unchecked. |
222 | 79.1M | ~Error() { |
223 | 79.1M | assertIsChecked(); |
224 | 79.1M | delete getPtr(); |
225 | 79.1M | } |
226 | | |
227 | | /// Bool conversion. Returns true if this Error is in a failure state, |
228 | | /// and false if it is in an accept state. If the error is in a Success state |
229 | | /// it will be considered checked. |
230 | 39.1M | explicit operator bool() { |
231 | 39.1M | setChecked(getPtr() == nullptr); |
232 | 39.1M | return getPtr() != nullptr; |
233 | 39.1M | } |
234 | | |
235 | | /// Check whether one error is a subclass of another. |
236 | 30 | template <typename ErrT> bool isA() const { |
237 | 30 | return getPtr() && getPtr()->isA(ErrT::classID()); |
238 | 30 | } |
239 | | |
240 | | /// Returns the dynamic class id of this error, or null if this is a success |
241 | | /// value. |
242 | 0 | const void* dynamicClassID() const { |
243 | 0 | if (!getPtr()) |
244 | 0 | return nullptr; |
245 | 0 | return getPtr()->dynamicClassID(); |
246 | 0 | } |
247 | | |
248 | | private: |
249 | 119M | void assertIsChecked() { |
250 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS |
251 | | if (!getChecked() || getPtr()) { |
252 | | dbgs() << "Program aborted due to an unhandled Error:\n"; |
253 | | if (getPtr()) |
254 | | getPtr()->log(dbgs()); |
255 | | else |
256 | | dbgs() |
257 | | << "Error value was Success. (Note: Success values must still be " |
258 | | "checked prior to being destroyed).\n"; |
259 | | abort(); |
260 | | } |
261 | | #endif |
262 | | } |
263 | | |
264 | 197M | ErrorInfoBase *getPtr() const { |
265 | 197M | return reinterpret_cast<ErrorInfoBase*>( |
266 | 197M | reinterpret_cast<uintptr_t>(Payload) & |
267 | 197M | ~static_cast<uintptr_t>(0x1)); |
268 | 197M | } |
269 | | |
270 | 119M | void setPtr(ErrorInfoBase *EI) { |
271 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS |
272 | | Payload = reinterpret_cast<ErrorInfoBase*>( |
273 | | (reinterpret_cast<uintptr_t>(EI) & |
274 | | ~static_cast<uintptr_t>(0x1)) | |
275 | | (reinterpret_cast<uintptr_t>(Payload) & 0x1)); |
276 | | #else |
277 | | Payload = EI; |
278 | 119M | #endif |
279 | 119M | } |
280 | | |
281 | 0 | bool getChecked() const { |
282 | 0 | #if LLVM_ENABLE_ABI_BREAKING_CHECKS |
283 | 0 | return (reinterpret_cast<uintptr_t>(Payload) & 0x1) == 0; |
284 | 0 | #else |
285 | 0 | return true; |
286 | 0 | #endif |
287 | 0 | } |
288 | | |
289 | 198M | void setChecked(bool V) { |
290 | 198M | Payload = reinterpret_cast<ErrorInfoBase*>( |
291 | 198M | (reinterpret_cast<uintptr_t>(Payload) & |
292 | 198M | ~static_cast<uintptr_t>(0x1)) | |
293 | 198M | (V ? 0119M : 179.2M )); |
294 | 198M | } |
295 | | |
296 | 73.0k | std::unique_ptr<ErrorInfoBase> takePayload() { |
297 | 73.0k | std::unique_ptr<ErrorInfoBase> Tmp(getPtr()); |
298 | 73.0k | setPtr(nullptr); |
299 | 73.0k | setChecked(true); |
300 | 73.0k | return Tmp; |
301 | 73.0k | } |
302 | | |
303 | | ErrorInfoBase *Payload = nullptr; |
304 | | }; |
305 | | |
306 | | /// Subclass of Error for the sole purpose of identifying the success path in |
307 | | /// the type system. This allows to catch invalid conversion to Expected<T> at |
308 | | /// compile time. |
309 | | class ErrorSuccess : public Error {}; |
310 | | |
311 | 39.0M | inline ErrorSuccess Error::success() { return ErrorSuccess(); } |
312 | | |
313 | | /// Make a Error instance representing failure using the given error info |
314 | | /// type. |
315 | 24.0k | template <typename ErrT, typename... ArgTs> Error make_error(ArgTs &&... Args) { |
316 | 24.0k | return Error(llvm::make_unique<ErrT>(std::forward<ArgTs>(Args)...)); |
317 | 24.0k | } llvm::Error llvm::make_error<llvm::InstrProfError, llvm::instrprof_error&>(llvm::instrprof_error&&&) Line | Count | Source | 315 | 249 | template <typename ErrT, typename... ArgTs> Error make_error(ArgTs &&... Args) { | 316 | 249 | return Error(llvm::make_unique<ErrT>(std::forward<ArgTs>(Args)...)); | 317 | 249 | } |
Unexecuted instantiation: llvm::Error llvm::make_error<llvm::StringError, llvm::StringRef&, llvm::object::object_error>(llvm::StringRef&&&, llvm::object::object_error&&) llvm::Error llvm::make_error<llvm::InstrProfError, llvm::instrprof_error>(llvm::instrprof_error&&) Line | Count | Source | 315 | 118 | template <typename ErrT, typename... ArgTs> Error make_error(ArgTs &&... Args) { | 316 | 118 | return Error(llvm::make_unique<ErrT>(std::forward<ArgTs>(Args)...)); | 317 | 118 | } |
llvm::Error llvm::make_error<llvm::StringError, llvm::Twine const&, std::__1::error_code>(llvm::Twine const&&&, std::__1::error_code&&) Line | Count | Source | 315 | 23.4k | template <typename ErrT, typename... ArgTs> Error make_error(ArgTs &&... Args) { | 316 | 23.4k | return Error(llvm::make_unique<ErrT>(std::forward<ArgTs>(Args)...)); | 317 | 23.4k | } |
Unexecuted instantiation: llvm::Error llvm::make_error<llvm::codeview::CodeViewError, llvm::codeview::cv_error_code, char const (&) [40]>(llvm::codeview::cv_error_code&&, char const (&&&) [40]) Unexecuted instantiation: llvm::Error llvm::make_error<llvm::codeview::CodeViewError, llvm::codeview::cv_error_code, char const (&) [29]>(llvm::codeview::cv_error_code&&, char const (&&&) [29]) Unexecuted instantiation: llvm::Error llvm::make_error<llvm::codeview::CodeViewError, llvm::codeview::cv_error_code, char const (&) [36]>(llvm::codeview::cv_error_code&&, char const (&&&) [36]) Unexecuted instantiation: llvm::Error llvm::make_error<llvm::codeview::CodeViewError, llvm::codeview::cv_error_code>(llvm::codeview::cv_error_code&&) llvm::Error llvm::make_error<llvm::StringError, llvm::StringRef&, std::__1::error_code>(llvm::StringRef&&&, std::__1::error_code&&) Line | Count | Source | 315 | 10 | template <typename ErrT, typename... ArgTs> Error make_error(ArgTs &&... Args) { | 316 | 10 | return Error(llvm::make_unique<ErrT>(std::forward<ArgTs>(Args)...)); | 317 | 10 | } |
llvm::Error llvm::make_error<llvm::BinaryStreamError, llvm::stream_error_code>(llvm::stream_error_code&&) Line | Count | Source | 315 | 219 | template <typename ErrT, typename... ArgTs> Error make_error(ArgTs &&... Args) { | 316 | 219 | return Error(llvm::make_unique<ErrT>(std::forward<ArgTs>(Args)...)); | 317 | 219 | } |
Unexecuted instantiation: llvm::Error llvm::make_error<llvm::codeview::CodeViewError, llvm::codeview::cv_error_code, char const (&) [33]>(llvm::codeview::cv_error_code&&, char const (&&&) [33]) |
318 | | |
319 | | /// Base class for user error types. Users should declare their error types |
320 | | /// like: |
321 | | /// |
322 | | /// class MyError : public ErrorInfo<MyError> { |
323 | | /// .... |
324 | | /// }; |
325 | | /// |
326 | | /// This class provides an implementation of the ErrorInfoBase::kind |
327 | | /// method, which is used by the Error RTTI system. |
328 | | template <typename ThisErrT, typename ParentErrT = ErrorInfoBase> |
329 | | class ErrorInfo : public ParentErrT { |
330 | | public: |
331 | 83.0k | static const void *classID() { return &ThisErrT::ID; } llvm::ErrorInfo<llvm::ErrorList, llvm::ErrorInfoBase>::classID() Line | Count | Source | 331 | 27.7k | static const void *classID() { return &ThisErrT::ID; } |
llvm::ErrorInfo<llvm::codeview::CodeViewError, llvm::ErrorInfoBase>::classID() Line | Count | Source | 331 | 194 | static const void *classID() { return &ThisErrT::ID; } |
llvm::ErrorInfo<llvm::StringError, llvm::ErrorInfoBase>::classID() Line | Count | Source | 331 | 51.0k | static const void *classID() { return &ThisErrT::ID; } |
Unexecuted instantiation: llvm::ErrorInfo<llvm::object::BinaryError, llvm::ECError>::classID() llvm::ErrorInfo<llvm::ECError, llvm::ErrorInfoBase>::classID() Line | Count | Source | 331 | 2.45k | static const void *classID() { return &ThisErrT::ID; } |
llvm::ErrorInfo<llvm::InstrProfError, llvm::ErrorInfoBase>::classID() Line | Count | Source | 331 | 1.12k | static const void *classID() { return &ThisErrT::ID; } |
llvm::ErrorInfo<llvm::BinaryStreamError, llvm::ErrorInfoBase>::classID() Line | Count | Source | 331 | 438 | static const void *classID() { return &ThisErrT::ID; } |
|
332 | | |
333 | 5 | const void *dynamicClassID() const override { return &ThisErrT::ID; } Unexecuted instantiation: llvm::ErrorInfo<llvm::ErrorList, llvm::ErrorInfoBase>::dynamicClassID() const Unexecuted instantiation: llvm::ErrorInfo<llvm::InstrProfError, llvm::ErrorInfoBase>::dynamicClassID() const Unexecuted instantiation: llvm::ErrorInfo<llvm::object::BinaryError, llvm::ECError>::dynamicClassID() const Unexecuted instantiation: llvm::ErrorInfo<llvm::ECError, llvm::ErrorInfoBase>::dynamicClassID() const Unexecuted instantiation: llvm::ErrorInfo<llvm::codeview::CodeViewError, llvm::ErrorInfoBase>::dynamicClassID() const llvm::ErrorInfo<llvm::StringError, llvm::ErrorInfoBase>::dynamicClassID() const Line | Count | Source | 333 | 5 | const void *dynamicClassID() const override { return &ThisErrT::ID; } |
Unexecuted instantiation: llvm::ErrorInfo<llvm::BinaryStreamError, llvm::ErrorInfoBase>::dynamicClassID() const |
334 | | |
335 | 54.7k | bool isA(const void *const ClassID) const override { |
336 | 54.1k | return ClassID == classID() || ParentErrT::isA(ClassID); |
337 | 54.7k | } llvm::ErrorInfo<llvm::ErrorList, llvm::ErrorInfoBase>::isA(void const*) const Line | Count | Source | 335 | 15 | bool isA(const void *const ClassID) const override { | 336 | 0 | return ClassID == classID() || ParentErrT::isA(ClassID); | 337 | 15 | } |
llvm::ErrorInfo<llvm::codeview::CodeViewError, llvm::ErrorInfoBase>::isA(void const*) const Line | Count | Source | 335 | 194 | bool isA(const void *const ClassID) const override { | 336 | 194 | return ClassID == classID() || ParentErrT::isA(ClassID); | 337 | 194 | } |
llvm::ErrorInfo<llvm::StringError, llvm::ErrorInfoBase>::isA(void const*) const Line | Count | Source | 335 | 51.0k | bool isA(const void *const ClassID) const override { | 336 | 51.0k | return ClassID == classID() || ParentErrT::isA(ClassID); | 337 | 51.0k | } |
llvm::ErrorInfo<llvm::ECError, llvm::ErrorInfoBase>::isA(void const*) const Line | Count | Source | 335 | 2.25k | bool isA(const void *const ClassID) const override { | 336 | 2.05k | return ClassID == classID() || ParentErrT::isA(ClassID); | 337 | 2.25k | } |
llvm::ErrorInfo<llvm::InstrProfError, llvm::ErrorInfoBase>::isA(void const*) const Line | Count | Source | 335 | 749 | bool isA(const void *const ClassID) const override { | 336 | 373 | return ClassID == classID() || ParentErrT::isA(ClassID); | 337 | 749 | } |
llvm::ErrorInfo<llvm::BinaryStreamError, llvm::ErrorInfoBase>::isA(void const*) const Line | Count | Source | 335 | 438 | bool isA(const void *const ClassID) const override { | 336 | 438 | return ClassID == classID() || ParentErrT::isA(ClassID); | 337 | 438 | } |
|
338 | | }; |
339 | | |
340 | | /// Special ErrorInfo subclass representing a list of ErrorInfos. |
341 | | /// Instances of this class are constructed by joinError. |
342 | | class ErrorList final : public ErrorInfo<ErrorList> { |
343 | | // handleErrors needs to be able to iterate the payload list of an |
344 | | // ErrorList. |
345 | | template <typename... HandlerTs> |
346 | | friend Error handleErrors(Error E, HandlerTs &&... Handlers); |
347 | | |
348 | | // joinErrors is implemented in terms of join. |
349 | | friend Error joinErrors(Error, Error); |
350 | | |
351 | | public: |
352 | 0 | void log(raw_ostream &OS) const override { |
353 | 0 | OS << "Multiple errors:\n"; |
354 | 0 | for (auto &ErrPayload : Payloads) { |
355 | 0 | ErrPayload->log(OS); |
356 | 0 | OS << "\n"; |
357 | 0 | } |
358 | 0 | } |
359 | | |
360 | | std::error_code convertToErrorCode() const override; |
361 | | |
362 | | // Used by ErrorInfo::classID. |
363 | | static char ID; |
364 | | |
365 | | private: |
366 | | ErrorList(std::unique_ptr<ErrorInfoBase> Payload1, |
367 | 12 | std::unique_ptr<ErrorInfoBase> Payload2) { |
368 | 12 | assert(!Payload1->isA<ErrorList>() && !Payload2->isA<ErrorList>() && |
369 | 12 | "ErrorList constructor payloads should be singleton errors"); |
370 | 12 | Payloads.push_back(std::move(Payload1)); |
371 | 12 | Payloads.push_back(std::move(Payload2)); |
372 | 12 | } |
373 | | |
374 | 41 | static Error join(Error E1, Error E2) { |
375 | 41 | if (!E1) |
376 | 26 | return E2; |
377 | 15 | if (15 !E215 ) |
378 | 0 | return E1; |
379 | 15 | if (15 E1.isA<ErrorList>()15 ) { |
380 | 2 | auto &E1List = static_cast<ErrorList &>(*E1.getPtr()); |
381 | 2 | if (E2.isA<ErrorList>()2 ) { |
382 | 1 | auto E2Payload = E2.takePayload(); |
383 | 1 | auto &E2List = static_cast<ErrorList &>(*E2Payload); |
384 | 1 | for (auto &Payload : E2List.Payloads) |
385 | 2 | E1List.Payloads.push_back(std::move(Payload)); |
386 | 1 | } else |
387 | 1 | E1List.Payloads.push_back(E2.takePayload()); |
388 | 2 | |
389 | 2 | return E1; |
390 | 2 | } |
391 | 13 | if (13 E2.isA<ErrorList>()13 ) { |
392 | 1 | auto &E2List = static_cast<ErrorList &>(*E2.getPtr()); |
393 | 1 | E2List.Payloads.insert(E2List.Payloads.begin(), E1.takePayload()); |
394 | 1 | return E2; |
395 | 1 | } |
396 | 12 | return Error(std::unique_ptr<ErrorList>( |
397 | 12 | new ErrorList(E1.takePayload(), E2.takePayload()))); |
398 | 41 | } |
399 | | |
400 | | std::vector<std::unique_ptr<ErrorInfoBase>> Payloads; |
401 | | }; |
402 | | |
403 | | /// Concatenate errors. The resulting Error is unchecked, and contains the |
404 | | /// ErrorInfo(s), if any, contained in E1, followed by the |
405 | | /// ErrorInfo(s), if any, contained in E2. |
406 | 0 | inline Error joinErrors(Error E1, Error E2) { |
407 | 0 | return ErrorList::join(std::move(E1), std::move(E2)); |
408 | 0 | } |
409 | | |
410 | | /// Tagged union holding either a T or a Error. |
411 | | /// |
412 | | /// This class parallels ErrorOr, but replaces error_code with Error. Since |
413 | | /// Error cannot be copied, this class replaces getError() with |
414 | | /// takeError(). It also adds an bool errorIsA<ErrT>() method for testing the |
415 | | /// error class type. |
416 | | template <class T> class LLVM_NODISCARD Expected { |
417 | | template <class T1> friend class ExpectedAsOutParameter; |
418 | | template <class OtherT> friend class Expected; |
419 | | |
420 | | static const bool isRef = std::is_reference<T>::value; |
421 | | |
422 | | using wrap = ReferenceStorage<typename std::remove_reference<T>::type>; |
423 | | |
424 | | using error_type = std::unique_ptr<ErrorInfoBase>; |
425 | | |
426 | | public: |
427 | | using storage_type = typename std::conditional<isRef, wrap, T>::type; |
428 | | using value_type = T; |
429 | | |
430 | | private: |
431 | | using reference = typename std::remove_reference<T>::type &; |
432 | | using const_reference = const typename std::remove_reference<T>::type &; |
433 | | using pointer = typename std::remove_reference<T>::type *; |
434 | | using const_pointer = const typename std::remove_reference<T>::type *; |
435 | | |
436 | | public: |
437 | | /// Create an Expected<T> error value from the given Error. |
438 | | Expected(Error Err) |
439 | | : HasError(true) |
440 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS |
441 | | // Expected is unchecked upon construction in Debug builds. |
442 | | , Unchecked(true) |
443 | | #endif |
444 | 229 | { |
445 | 229 | assert(Err && "Cannot create Expected<T> from Error success value."); |
446 | 229 | new (getErrorStorage()) error_type(Err.takePayload()); |
447 | 229 | } llvm::Expected<std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > >::Expected(llvm::Error) Line | Count | Source | 444 | 34 | { | 445 | 34 | assert(Err && "Cannot create Expected<T> from Error success value."); | 446 | 34 | new (getErrorStorage()) error_type(Err.takePayload()); | 447 | 34 | } |
llvm::Expected<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::Expected(llvm::Error) Line | Count | Source | 444 | 8 | { | 445 | 8 | assert(Err && "Cannot create Expected<T> from Error success value."); | 446 | 8 | new (getErrorStorage()) error_type(Err.takePayload()); | 447 | 8 | } |
Unexecuted instantiation: llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >::Expected(llvm::Error) llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::SymbolKind> >::Expected(llvm::Error) Line | Count | Source | 444 | 1 | { | 445 | 1 | assert(Err && "Cannot create Expected<T> from Error success value."); | 446 | 1 | new (getErrorStorage()) error_type(Err.takePayload()); | 447 | 1 | } |
Unexecuted instantiation: llvm::Expected<llvm::MutableArrayRef<unsigned char> >::Expected(llvm::Error) Unexecuted instantiation: llvm::Expected<llvm::codeview::TypeIndex>::Expected(llvm::Error) llvm::Expected<llvm::BitstreamCursor>::Expected(llvm::Error) Line | Count | Source | 444 | 2 | { | 445 | 2 | assert(Err && "Cannot create Expected<T> from Error success value."); | 446 | 2 | new (getErrorStorage()) error_type(Err.takePayload()); | 447 | 2 | } |
llvm::Expected<llvm::StringRef>::Expected(llvm::Error) Line | Count | Source | 444 | 43 | { | 445 | 43 | assert(Err && "Cannot create Expected<T> from Error success value."); | 446 | 43 | new (getErrorStorage()) error_type(Err.takePayload()); | 447 | 43 | } |
Unexecuted instantiation: llvm::Expected<llvm::Value*>::Expected(llvm::Error) llvm::Expected<unsigned int>::Expected(llvm::Error) Line | Count | Source | 444 | 16 | { | 445 | 16 | assert(Err && "Cannot create Expected<T> from Error success value."); | 446 | 16 | new (getErrorStorage()) error_type(Err.takePayload()); | 447 | 16 | } |
llvm::Expected<llvm::BitcodeModule>::Expected(llvm::Error) Line | Count | Source | 444 | 20 | { | 445 | 20 | assert(Err && "Cannot create Expected<T> from Error success value."); | 446 | 20 | new (getErrorStorage()) error_type(Err.takePayload()); | 447 | 20 | } |
llvm::Expected<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::Expected(llvm::Error) Line | Count | Source | 444 | 3 | { | 445 | 3 | assert(Err && "Cannot create Expected<T> from Error success value."); | 446 | 3 | new (getErrorStorage()) error_type(Err.takePayload()); | 447 | 3 | } |
llvm::Expected<bool>::Expected(llvm::Error) Line | Count | Source | 444 | 5 | { | 445 | 5 | assert(Err && "Cannot create Expected<T> from Error success value."); | 446 | 5 | new (getErrorStorage()) error_type(Err.takePayload()); | 447 | 5 | } |
llvm::Expected<llvm::InstrProfRecord>::Expected(llvm::Error) Line | Count | Source | 444 | 58 | { | 445 | 58 | assert(Err && "Cannot create Expected<T> from Error success value."); | 446 | 58 | new (getErrorStorage()) error_type(Err.takePayload()); | 447 | 58 | } |
llvm::Expected<std::__1::unique_ptr<llvm::IndexedInstrProfReader, std::__1::default_delete<llvm::IndexedInstrProfReader> > >::Expected(llvm::Error) Line | Count | Source | 444 | 4 | { | 445 | 4 | assert(Err && "Cannot create Expected<T> from Error success value."); | 446 | 4 | new (getErrorStorage()) error_type(Err.takePayload()); | 447 | 4 | } |
llvm::Expected<std::__1::unique_ptr<llvm::InstrProfReader, std::__1::default_delete<llvm::InstrProfReader> > >::Expected(llvm::Error) Line | Count | Source | 444 | 6 | { | 445 | 6 | assert(Err && "Cannot create Expected<T> from Error success value."); | 446 | 6 | new (getErrorStorage()) error_type(Err.takePayload()); | 447 | 6 | } |
Unexecuted instantiation: llvm::Expected<std::__1::unique_ptr<llvm::ValueProfData, std::__1::default_delete<llvm::ValueProfData> > >::Expected(llvm::Error) Unexecuted instantiation: llvm::Expected<llvm::BitcodeLTOInfo>::Expected(llvm::Error) llvm::Expected<std::__1::unique_ptr<llvm::ModuleSummaryIndex, std::__1::default_delete<llvm::ModuleSummaryIndex> > >::Expected(llvm::Error) Line | Count | Source | 444 | 1 | { | 445 | 1 | assert(Err && "Cannot create Expected<T> from Error success value."); | 446 | 1 | new (getErrorStorage()) error_type(Err.takePayload()); | 447 | 1 | } |
llvm::Expected<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >::Expected(llvm::Error) Line | Count | Source | 444 | 14 | { | 445 | 14 | assert(Err && "Cannot create Expected<T> from Error success value."); | 446 | 14 | new (getErrorStorage()) error_type(Err.takePayload()); | 447 | 14 | } |
llvm::Expected<llvm::BitcodeFileContents>::Expected(llvm::Error) Line | Count | Source | 444 | 14 | { | 445 | 14 | assert(Err && "Cannot create Expected<T> from Error success value."); | 446 | 14 | new (getErrorStorage()) error_type(Err.takePayload()); | 447 | 14 | } |
|
448 | | |
449 | | /// Forbid to convert from Error::success() implicitly, this avoids having |
450 | | /// Expected<T> foo() { return Error::success(); } which compiles otherwise |
451 | | /// but triggers the assertion above. |
452 | | Expected(ErrorSuccess) = delete; |
453 | | |
454 | | /// Create an Expected<T> success value from the given OtherT value, which |
455 | | /// must be convertible to T. |
456 | | template <typename OtherT> |
457 | | Expected(OtherT &&Val, |
458 | | typename std::enable_if<std::is_convertible<OtherT, T>::value>::type |
459 | | * = nullptr) |
460 | | : HasError(false) |
461 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS |
462 | | // Expected is unchecked upon construction in Debug builds. |
463 | | , Unchecked(true) |
464 | | #endif |
465 | 15.4M | { |
466 | 15.4M | new (getStorage()) storage_type(std::forward<OtherT>(Val)); |
467 | 15.4M | } llvm::Expected<bool>::Expected<bool>(bool&&, std::__1::enable_if<std::is_convertible<bool, bool>::value, void>::type*) Line | Count | Source | 465 | 3.70k | { | 466 | 3.70k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 3.70k | } |
llvm::Expected<llvm::codeview::TypeIndex>::Expected<llvm::codeview::TypeIndex>(llvm::codeview::TypeIndex&&, std::__1::enable_if<std::is_convertible<llvm::codeview::TypeIndex, llvm::codeview::TypeIndex>::value, void>::type*) Line | Count | Source | 465 | 1.77k | { | 466 | 1.77k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 1.77k | } |
llvm::Expected<llvm::BitstreamCursor>::Expected<llvm::BitstreamCursor>(llvm::BitstreamCursor&&, std::__1::enable_if<std::is_convertible<llvm::BitstreamCursor, llvm::BitstreamCursor>::value, void>::type*) Line | Count | Source | 465 | 11.4k | { | 466 | 11.4k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 11.4k | } |
llvm::Expected<llvm::StringRef>::Expected<llvm::StringRef>(llvm::StringRef&&, std::__1::enable_if<std::is_convertible<llvm::StringRef, llvm::StringRef>::value, void>::type*) Line | Count | Source | 465 | 735k | { | 466 | 735k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 735k | } |
llvm::Expected<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::Expected<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::enable_if<std::is_convertible<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::value, void>::type*) Line | Count | Source | 465 | 35.1k | { | 466 | 35.1k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 35.1k | } |
llvm::Expected<llvm::Value*>::Expected<llvm::Value*>(llvm::Value*&&, std::__1::enable_if<std::is_convertible<llvm::Value*, llvm::Value*>::value, void>::type*) Line | Count | Source | 465 | 14.6M | { | 466 | 14.6M | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 14.6M | } |
llvm::Expected<unsigned int>::Expected<unsigned int>(unsigned int&&, std::__1::enable_if<std::is_convertible<unsigned int, unsigned int>::value, void>::type*) Line | Count | Source | 465 | 32.2k | { | 466 | 32.2k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 32.2k | } |
llvm::Expected<llvm::BitcodeModule>::Expected<llvm::BitcodeModule&>(llvm::BitcodeModule&&&, std::__1::enable_if<std::is_convertible<llvm::BitcodeModule&, llvm::BitcodeModule>::value, void>::type*) Line | Count | Source | 465 | 10.8k | { | 466 | 10.8k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 10.8k | } |
Unexecuted instantiation: llvm::Expected<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::Expected<char const (&) [1]>(char const (&&&) [1], std::__1::enable_if<std::is_convertible<char const (&) [1], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::value, void>::type*) llvm::Expected<std::__1::unique_ptr<llvm::IndexedInstrProfReader, std::__1::default_delete<llvm::IndexedInstrProfReader> > >::Expected<std::__1::unique_ptr<llvm::IndexedInstrProfReader, std::__1::default_delete<llvm::IndexedInstrProfReader> > >(std::__1::unique_ptr<llvm::IndexedInstrProfReader, std::__1::default_delete<llvm::IndexedInstrProfReader> >&&, std::__1::enable_if<std::is_convertible<std::__1::unique_ptr<llvm::IndexedInstrProfReader, std::__1::default_delete<llvm::IndexedInstrProfReader> >, std::__1::unique_ptr<llvm::IndexedInstrProfReader, std::__1::default_delete<llvm::IndexedInstrProfReader> > >::value, void>::type*) Line | Count | Source | 465 | 307 | { | 466 | 307 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 307 | } |
llvm::Expected<std::__1::unique_ptr<llvm::InstrProfReader, std::__1::default_delete<llvm::InstrProfReader> > >::Expected<std::__1::unique_ptr<llvm::InstrProfReader, std::__1::default_delete<llvm::InstrProfReader> > >(std::__1::unique_ptr<llvm::InstrProfReader, std::__1::default_delete<llvm::InstrProfReader> >&&, std::__1::enable_if<std::is_convertible<std::__1::unique_ptr<llvm::InstrProfReader, std::__1::default_delete<llvm::InstrProfReader> >, std::__1::unique_ptr<llvm::InstrProfReader, std::__1::default_delete<llvm::InstrProfReader> > >::value, void>::type*) Line | Count | Source | 465 | 186 | { | 466 | 186 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 186 | } |
llvm::Expected<std::__1::unique_ptr<llvm::ValueProfData, std::__1::default_delete<llvm::ValueProfData> > >::Expected<std::__1::unique_ptr<llvm::ValueProfData, std::__1::default_delete<llvm::ValueProfData> > >(std::__1::unique_ptr<llvm::ValueProfData, std::__1::default_delete<llvm::ValueProfData> >&&, std::__1::enable_if<std::is_convertible<std::__1::unique_ptr<llvm::ValueProfData, std::__1::default_delete<llvm::ValueProfData> >, std::__1::unique_ptr<llvm::ValueProfData, std::__1::default_delete<llvm::ValueProfData> > >::value, void>::type*) Line | Count | Source | 465 | 516 | { | 466 | 516 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 516 | } |
llvm::Expected<std::__1::unique_ptr<llvm::ModuleSummaryIndex, std::__1::default_delete<llvm::ModuleSummaryIndex> > >::Expected<std::nullptr_t>(std::nullptr_t&&, std::__1::enable_if<std::is_convertible<std::nullptr_t, std::__1::unique_ptr<llvm::ModuleSummaryIndex, std::__1::default_delete<llvm::ModuleSummaryIndex> > >::value, void>::type*) Line | Count | Source | 465 | 1 | { | 466 | 1 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 1 | } |
llvm::Expected<llvm::MutableArrayRef<unsigned char> >::Expected<llvm::MutableArrayRef<unsigned char> >(llvm::MutableArrayRef<unsigned char>&&, std::__1::enable_if<std::is_convertible<llvm::MutableArrayRef<unsigned char>, llvm::MutableArrayRef<unsigned char> >::value, void>::type*) Line | Count | Source | 465 | 7.96k | { | 466 | 7.96k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 7.96k | } |
llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::SymbolKind> >::Expected<llvm::codeview::CVRecord<llvm::codeview::SymbolKind> >(llvm::codeview::CVRecord<llvm::codeview::SymbolKind>&&, std::__1::enable_if<std::is_convertible<llvm::codeview::CVRecord<llvm::codeview::SymbolKind>, llvm::codeview::CVRecord<llvm::codeview::SymbolKind> >::value, void>::type*) Line | Count | Source | 465 | 1.81k | { | 466 | 1.81k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 1.81k | } |
llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >::Expected<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&&, std::__1::enable_if<std::is_convertible<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>, llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >::value, void>::type*) Line | Count | Source | 465 | 5.18k | { | 466 | 5.18k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 5.18k | } |
llvm::Expected<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::Expected<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >&&, std::__1::enable_if<std::is_convertible<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::value, void>::type*) Line | Count | Source | 465 | 1.27k | { | 466 | 1.27k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 1.27k | } |
llvm::Expected<llvm::BitcodeLTOInfo>::Expected<llvm::BitcodeLTOInfo>(llvm::BitcodeLTOInfo&&, std::__1::enable_if<std::is_convertible<llvm::BitcodeLTOInfo, llvm::BitcodeLTOInfo>::value, void>::type*) Line | Count | Source | 465 | 393 | { | 466 | 393 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 393 | } |
llvm::Expected<std::__1::unique_ptr<llvm::ModuleSummaryIndex, std::__1::default_delete<llvm::ModuleSummaryIndex> > >::Expected<std::__1::unique_ptr<llvm::ModuleSummaryIndex, std::__1::default_delete<llvm::ModuleSummaryIndex> > >(std::__1::unique_ptr<llvm::ModuleSummaryIndex, std::__1::default_delete<llvm::ModuleSummaryIndex> >&&, std::__1::enable_if<std::is_convertible<std::__1::unique_ptr<llvm::ModuleSummaryIndex, std::__1::default_delete<llvm::ModuleSummaryIndex> >, std::__1::unique_ptr<llvm::ModuleSummaryIndex, std::__1::default_delete<llvm::ModuleSummaryIndex> > >::value, void>::type*) Line | Count | Source | 465 | 112 | { | 466 | 112 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 112 | } |
llvm::Expected<std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > >::Expected<std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > >(std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> >&&, std::__1::enable_if<std::is_convertible<std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> >, std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > >::value, void>::type*) Line | Count | Source | 465 | 11.0k | { | 466 | 11.0k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 11.0k | } |
llvm::Expected<llvm::BitcodeFileContents>::Expected<llvm::BitcodeFileContents>(llvm::BitcodeFileContents&&, std::__1::enable_if<std::is_convertible<llvm::BitcodeFileContents, llvm::BitcodeFileContents>::value, void>::type*) Line | Count | Source | 465 | 11.3k | { | 466 | 11.3k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 11.3k | } |
llvm::Expected<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >::Expected<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >(std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> >&&, std::__1::enable_if<std::is_convertible<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> >, std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >::value, void>::type*) Line | Count | Source | 465 | 10.9k | { | 466 | 10.9k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 10.9k | } |
llvm::Expected<llvm::InstrProfRecord>::Expected<llvm::NamedInstrProfRecord const>(llvm::NamedInstrProfRecord const&&, std::__1::enable_if<std::is_convertible<llvm::NamedInstrProfRecord const, llvm::InstrProfRecord>::value, void>::type*) Line | Count | Source | 465 | 449 | { | 466 | 449 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 467 | 449 | } |
|
468 | | |
469 | | /// Move construct an Expected<T> value. |
470 | | Expected(Expected &&Other) { moveConstruct(std::move(Other)); } |
471 | | |
472 | | /// Move construct an Expected<T> value from an Expected<OtherT>, where OtherT |
473 | | /// must be convertible to T. |
474 | | template <class OtherT> |
475 | | Expected(Expected<OtherT> &&Other, |
476 | | typename std::enable_if<std::is_convertible<OtherT, T>::value>::type |
477 | | * = nullptr) { |
478 | | moveConstruct(std::move(Other)); |
479 | | } |
480 | | |
481 | | /// Move construct an Expected<T> value from an Expected<OtherT>, where OtherT |
482 | | /// isn't convertible to T. |
483 | | template <class OtherT> |
484 | | explicit Expected( |
485 | | Expected<OtherT> &&Other, |
486 | | typename std::enable_if<!std::is_convertible<OtherT, T>::value>::type * = |
487 | | nullptr) { |
488 | | moveConstruct(std::move(Other)); |
489 | | } |
490 | | |
491 | | /// Move-assign from another Expected<T>. |
492 | | Expected &operator=(Expected &&Other) { |
493 | | moveAssign(std::move(Other)); |
494 | | return *this; |
495 | | } |
496 | | |
497 | | /// Destroy an Expected<T>. |
498 | 15.5M | ~Expected() { |
499 | 15.5M | assertIsChecked(); |
500 | 15.5M | if (!HasError) |
501 | 15.5M | getStorage()->~storage_type(); |
502 | 15.5M | else |
503 | 174 | getErrorStorage()->~error_type(); |
504 | 15.5M | } llvm::Expected<llvm::BitstreamCursor>::~Expected() Line | Count | Source | 498 | 11.4k | ~Expected() { | 499 | 11.4k | assertIsChecked(); | 500 | 11.4k | if (!HasError) | 501 | 11.4k | getStorage()->~storage_type(); | 502 | 11.4k | else | 503 | 2 | getErrorStorage()->~error_type(); | 504 | 11.4k | } |
llvm::Expected<std::__1::unique_ptr<llvm::ValueProfData, std::__1::default_delete<llvm::ValueProfData> > >::~Expected() Line | Count | Source | 498 | 516 | ~Expected() { | 499 | 516 | assertIsChecked(); | 500 | 516 | if (!HasError) | 501 | 516 | getStorage()->~storage_type(); | 502 | 516 | else | 503 | 0 | getErrorStorage()->~error_type(); | 504 | 516 | } |
llvm::Expected<bool>::~Expected() Line | Count | Source | 498 | 4.05k | ~Expected() { | 499 | 4.05k | assertIsChecked(); | 500 | 4.05k | if (!HasError) | 501 | 4.05k | getStorage()->~storage_type(); | 502 | 4.05k | else | 503 | 5 | getErrorStorage()->~error_type(); | 504 | 4.05k | } |
llvm::Expected<llvm::BitcodeModule>::~Expected() Line | Count | Source | 498 | 10.8k | ~Expected() { | 499 | 10.8k | assertIsChecked(); | 500 | 10.8k | if (!HasError) | 501 | 10.8k | getStorage()->~storage_type(); | 502 | 10.8k | else | 503 | 20 | getErrorStorage()->~error_type(); | 504 | 10.8k | } |
llvm::Expected<llvm::BitcodeFileContents>::~Expected() Line | Count | Source | 498 | 11.3k | ~Expected() { | 499 | 11.3k | assertIsChecked(); | 500 | 11.3k | if (!HasError) | 501 | 11.3k | getStorage()->~storage_type(); | 502 | 11.3k | else | 503 | 14 | getErrorStorage()->~error_type(); | 504 | 11.3k | } |
llvm::Expected<llvm::StringRef>::~Expected() Line | Count | Source | 498 | 735k | ~Expected() { | 499 | 735k | assertIsChecked(); | 500 | 735k | if (!HasError) | 501 | 735k | getStorage()->~storage_type(); | 502 | 735k | else | 503 | 30 | getErrorStorage()->~error_type(); | 504 | 735k | } |
llvm::Expected<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::~Expected() Line | Count | Source | 498 | 35.3k | ~Expected() { | 499 | 35.3k | assertIsChecked(); | 500 | 35.3k | if (!HasError) | 501 | 35.3k | getStorage()->~storage_type(); | 502 | 35.3k | else | 503 | 1 | getErrorStorage()->~error_type(); | 504 | 35.3k | } |
llvm::Expected<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >::~Expected() Line | Count | Source | 498 | 10.9k | ~Expected() { | 499 | 10.9k | assertIsChecked(); | 500 | 10.9k | if (!HasError) | 501 | 10.9k | getStorage()->~storage_type(); | 502 | 10.9k | else | 503 | 14 | getErrorStorage()->~error_type(); | 504 | 10.9k | } |
llvm::Expected<unsigned int>::~Expected() Line | Count | Source | 498 | 40.4k | ~Expected() { | 499 | 40.4k | assertIsChecked(); | 500 | 40.4k | if (!HasError) | 501 | 40.3k | getStorage()->~storage_type(); | 502 | 40.4k | else | 503 | 17 | getErrorStorage()->~error_type(); | 504 | 40.4k | } |
llvm::Expected<llvm::Value*>::~Expected() Line | Count | Source | 498 | 14.6M | ~Expected() { | 499 | 14.6M | assertIsChecked(); | 500 | 14.6M | if (!HasError) | 501 | 14.6M | getStorage()->~storage_type(); | 502 | 14.6M | else | 503 | 0 | getErrorStorage()->~error_type(); | 504 | 14.6M | } |
llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >::~Expected() Line | Count | Source | 498 | 5.18k | ~Expected() { | 499 | 5.18k | assertIsChecked(); | 500 | 5.18k | if (!HasError) | 501 | 5.18k | getStorage()->~storage_type(); | 502 | 5.18k | else | 503 | 0 | getErrorStorage()->~error_type(); | 504 | 5.18k | } |
llvm::Expected<std::__1::unique_ptr<llvm::IndexedInstrProfReader, std::__1::default_delete<llvm::IndexedInstrProfReader> > >::~Expected() Line | Count | Source | 498 | 307 | ~Expected() { | 499 | 307 | assertIsChecked(); | 500 | 307 | if (!HasError) | 501 | 305 | getStorage()->~storage_type(); | 502 | 307 | else | 503 | 2 | getErrorStorage()->~error_type(); | 504 | 307 | } |
llvm::Expected<llvm::InstrProfRecord>::~Expected() Line | Count | Source | 498 | 514 | ~Expected() { | 499 | 514 | assertIsChecked(); | 500 | 514 | if (!HasError) | 501 | 452 | getStorage()->~storage_type(); | 502 | 514 | else | 503 | 62 | getErrorStorage()->~error_type(); | 504 | 514 | } |
llvm::Expected<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::~Expected() Line | Count | Source | 498 | 1.27k | ~Expected() { | 499 | 1.27k | assertIsChecked(); | 500 | 1.27k | if (!HasError) | 501 | 1.27k | getStorage()->~storage_type(); | 502 | 1.27k | else | 503 | 4 | getErrorStorage()->~error_type(); | 504 | 1.27k | } |
llvm::Expected<std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > >::~Expected() Line | Count | Source | 498 | 11.0k | ~Expected() { | 499 | 11.0k | assertIsChecked(); | 500 | 11.0k | if (!HasError) | 501 | 11.0k | getStorage()->~storage_type(); | 502 | 11.0k | else | 503 | 3 | getErrorStorage()->~error_type(); | 504 | 11.0k | } |
llvm::Expected<llvm::MutableArrayRef<unsigned char> >::~Expected() Line | Count | Source | 498 | 7.96k | ~Expected() { | 499 | 7.96k | assertIsChecked(); | 500 | 7.96k | if (!HasError) | 501 | 7.96k | getStorage()->~storage_type(); | 502 | 7.96k | else | 503 | 0 | getErrorStorage()->~error_type(); | 504 | 7.96k | } |
llvm::Expected<llvm::codeview::TypeIndex>::~Expected() Line | Count | Source | 498 | 1.77k | ~Expected() { | 499 | 1.77k | assertIsChecked(); | 500 | 1.77k | if (!HasError) | 501 | 1.77k | getStorage()->~storage_type(); | 502 | 1.77k | else | 503 | 0 | getErrorStorage()->~error_type(); | 504 | 1.77k | } |
|
505 | | |
506 | | /// \brief Return false if there is an error. |
507 | 860k | explicit operator bool() { |
508 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS |
509 | | Unchecked = HasError; |
510 | | #endif |
511 | | return !HasError; |
512 | 860k | } llvm::Expected<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >::operator bool() Line | Count | Source | 507 | 10.8k | explicit operator bool() { | 508 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 509 | | Unchecked = HasError; | 510 | | #endif | 511 | | return !HasError; | 512 | 10.8k | } |
llvm::Expected<llvm::BitstreamCursor>::operator bool() Line | Count | Source | 507 | 11.4k | explicit operator bool() { | 508 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 509 | | Unchecked = HasError; | 510 | | #endif | 511 | | return !HasError; | 512 | 11.4k | } |
llvm::Expected<llvm::StringRef>::operator bool() Line | Count | Source | 507 | 725k | explicit operator bool() { | 508 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 509 | | Unchecked = HasError; | 510 | | #endif | 511 | | return !HasError; | 512 | 725k | } |
llvm::Expected<llvm::BitcodeFileContents>::operator bool() Line | Count | Source | 507 | 11.3k | explicit operator bool() { | 508 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 509 | | Unchecked = HasError; | 510 | | #endif | 511 | | return !HasError; | 512 | 11.3k | } |
llvm::Expected<std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > >::operator bool() Line | Count | Source | 507 | 2.46k | explicit operator bool() { | 508 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 509 | | Unchecked = HasError; | 510 | | #endif | 511 | | return !HasError; | 512 | 2.46k | } |
llvm::Expected<llvm::BitcodeModule>::operator bool() Line | Count | Source | 507 | 10.8k | explicit operator bool() { | 508 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 509 | | Unchecked = HasError; | 510 | | #endif | 511 | | return !HasError; | 512 | 10.8k | } |
llvm::Expected<unsigned int>::operator bool() Line | Count | Source | 507 | 35.1k | explicit operator bool() { | 508 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 509 | | Unchecked = HasError; | 510 | | #endif | 511 | | return !HasError; | 512 | 35.1k | } |
llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >::operator bool() Line | Count | Source | 507 | 5.18k | explicit operator bool() { | 508 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 509 | | Unchecked = HasError; | 510 | | #endif | 511 | | return !HasError; | 512 | 5.18k | } |
llvm::Expected<llvm::codeview::TypeIndex>::operator bool() Line | Count | Source | 507 | 1.77k | explicit operator bool() { | 508 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 509 | | Unchecked = HasError; | 510 | | #endif | 511 | | return !HasError; | 512 | 1.77k | } |
llvm::Expected<bool>::operator bool() Line | Count | Source | 507 | 2.78k | explicit operator bool() { | 508 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 509 | | Unchecked = HasError; | 510 | | #endif | 511 | | return !HasError; | 512 | 2.78k | } |
llvm::Expected<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::operator bool() Line | Count | Source | 507 | 35.5k | explicit operator bool() { | 508 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 509 | | Unchecked = HasError; | 510 | | #endif | 511 | | return !HasError; | 512 | 35.5k | } |
llvm::Expected<llvm::MutableArrayRef<unsigned char> >::operator bool() Line | Count | Source | 507 | 7.96k | explicit operator bool() { | 508 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 509 | | Unchecked = HasError; | 510 | | #endif | 511 | | return !HasError; | 512 | 7.96k | } |
|
513 | | |
514 | | /// \brief Returns a reference to the stored T value. |
515 | 14.6M | reference get() { |
516 | 14.6M | assertIsChecked(); |
517 | 14.6M | return *getStorage(); |
518 | 14.6M | } llvm::Expected<std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > >::get() Line | Count | Source | 515 | 9.66k | reference get() { | 516 | 9.66k | assertIsChecked(); | 517 | 9.66k | return *getStorage(); | 518 | 9.66k | } |
llvm::Expected<llvm::InstrProfRecord>::get() Line | Count | Source | 515 | 431 | reference get() { | 516 | 431 | assertIsChecked(); | 517 | 431 | return *getStorage(); | 518 | 431 | } |
llvm::Expected<llvm::Value*>::get() Line | Count | Source | 515 | 14.6M | reference get() { | 516 | 14.6M | assertIsChecked(); | 517 | 14.6M | return *getStorage(); | 518 | 14.6M | } |
llvm::Expected<bool>::get() Line | Count | Source | 515 | 3.37k | reference get() { | 516 | 3.37k | assertIsChecked(); | 517 | 3.37k | return *getStorage(); | 518 | 3.37k | } |
llvm::Expected<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::get() Line | Count | Source | 515 | 387 | reference get() { | 516 | 387 | assertIsChecked(); | 517 | 387 | return *getStorage(); | 518 | 387 | } |
llvm::Expected<std::__1::unique_ptr<llvm::ValueProfData, std::__1::default_delete<llvm::ValueProfData> > >::get() Line | Count | Source | 515 | 1.03k | reference get() { | 516 | 1.03k | assertIsChecked(); | 517 | 1.03k | return *getStorage(); | 518 | 1.03k | } |
llvm::Expected<std::__1::unique_ptr<llvm::IndexedInstrProfReader, std::__1::default_delete<llvm::IndexedInstrProfReader> > >::get() Line | Count | Source | 515 | 307 | reference get() { | 516 | 307 | assertIsChecked(); | 517 | 307 | return *getStorage(); | 518 | 307 | } |
|
519 | | |
520 | | /// \brief Returns a const reference to the stored T value. |
521 | | const_reference get() const { |
522 | | assertIsChecked(); |
523 | | return const_cast<Expected<T> *>(this)->get(); |
524 | | } |
525 | | |
526 | | /// \brief Check that this Expected<T> is an error of type ErrT. |
527 | | template <typename ErrT> bool errorIsA() const { |
528 | | return HasError && (*getErrorStorage())->template isA<ErrT>(); |
529 | | } |
530 | | |
531 | | /// \brief Take ownership of the stored error. |
532 | | /// After calling this the Expected<T> is in an indeterminate state that can |
533 | | /// only be safely destructed. No further calls (beside the destructor) should |
534 | | /// be made on the Expected<T> vaule. |
535 | 14.6M | Error takeError() { |
536 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS |
537 | | Unchecked = false; |
538 | | #endif |
539 | 14.6M | return HasError ? Error(std::move(*getErrorStorage()))219 : Error::success()14.6M ; |
540 | 14.6M | } llvm::Expected<llvm::BitcodeFileContents>::takeError() Line | Count | Source | 535 | 14 | Error takeError() { | 536 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 537 | | Unchecked = false; | 538 | | #endif | 539 | 14 | return HasError ? Error(std::move(*getErrorStorage()))14 : Error::success()0 ; | 540 | 14 | } |
llvm::Expected<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >::takeError() Line | Count | Source | 535 | 65 | Error takeError() { | 536 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 537 | | Unchecked = false; | 538 | | #endif | 539 | 65 | return HasError ? Error(std::move(*getErrorStorage()))14 : Error::success()51 ; | 540 | 65 | } |
llvm::Expected<unsigned int>::takeError() Line | Count | Source | 535 | 1.71k | Error takeError() { | 536 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 537 | | Unchecked = false; | 538 | | #endif | 539 | 1.71k | return HasError ? Error(std::move(*getErrorStorage()))14 : Error::success()1.70k ; | 540 | 1.71k | } |
llvm::Expected<llvm::Value*>::takeError() Line | Count | Source | 535 | 14.6M | Error takeError() { | 536 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 537 | | Unchecked = false; | 538 | | #endif | 539 | 14.6M | return HasError ? Error(std::move(*getErrorStorage()))0 : Error::success()14.6M ; | 540 | 14.6M | } |
Unexecuted instantiation: llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >::takeError() llvm::Expected<llvm::InstrProfRecord>::takeError() Line | Count | Source | 535 | 505 | Error takeError() { | 536 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 537 | | Unchecked = false; | 538 | | #endif | 539 | 505 | return HasError ? Error(std::move(*getErrorStorage()))58 : Error::success()447 ; | 540 | 505 | } |
llvm::Expected<std::__1::unique_ptr<llvm::IndexedInstrProfReader, std::__1::default_delete<llvm::IndexedInstrProfReader> > >::takeError() Line | Count | Source | 535 | 311 | Error takeError() { | 536 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 537 | | Unchecked = false; | 538 | | #endif | 539 | 311 | return HasError ? Error(std::move(*getErrorStorage()))4 : Error::success()307 ; | 540 | 311 | } |
llvm::Expected<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::takeError() Line | Count | Source | 535 | 1.27k | Error takeError() { | 536 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 537 | | Unchecked = false; | 538 | | #endif | 539 | 1.27k | return HasError ? Error(std::move(*getErrorStorage()))8 : Error::success()1.26k ; | 540 | 1.27k | } |
llvm::Expected<std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > >::takeError() Line | Count | Source | 535 | 9.55k | Error takeError() { | 536 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 537 | | Unchecked = false; | 538 | | #endif | 539 | 9.55k | return HasError ? Error(std::move(*getErrorStorage()))34 : Error::success()9.52k ; | 540 | 9.55k | } |
Unexecuted instantiation: llvm::Expected<llvm::codeview::TypeIndex>::takeError() Unexecuted instantiation: llvm::Expected<llvm::MutableArrayRef<unsigned char> >::takeError() llvm::Expected<llvm::BitstreamCursor>::takeError() Line | Count | Source | 535 | 2 | Error takeError() { | 536 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 537 | | Unchecked = false; | 538 | | #endif | 539 | 2 | return HasError ? Error(std::move(*getErrorStorage()))2 : Error::success()0 ; | 540 | 2 | } |
llvm::Expected<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::takeError() Line | Count | Source | 535 | 3 | Error takeError() { | 536 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 537 | | Unchecked = false; | 538 | | #endif | 539 | 3 | return HasError ? Error(std::move(*getErrorStorage()))3 : Error::success()0 ; | 540 | 3 | } |
llvm::Expected<llvm::BitcodeModule>::takeError() Line | Count | Source | 535 | 20 | Error takeError() { | 536 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 537 | | Unchecked = false; | 538 | | #endif | 539 | 20 | return HasError ? Error(std::move(*getErrorStorage()))20 : Error::success()0 ; | 540 | 20 | } |
llvm::Expected<bool>::takeError() Line | Count | Source | 535 | 1.15k | Error takeError() { | 536 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 537 | | Unchecked = false; | 538 | | #endif | 539 | 1.15k | return HasError ? Error(std::move(*getErrorStorage()))5 : Error::success()1.14k ; | 540 | 1.15k | } |
llvm::Expected<std::__1::unique_ptr<llvm::ValueProfData, std::__1::default_delete<llvm::ValueProfData> > >::takeError() Line | Count | Source | 535 | 516 | Error takeError() { | 536 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 537 | | Unchecked = false; | 538 | | #endif | 539 | 516 | return HasError ? Error(std::move(*getErrorStorage()))0 : Error::success()516 ; | 540 | 516 | } |
llvm::Expected<llvm::StringRef>::takeError() Line | Count | Source | 535 | 9.89k | Error takeError() { | 536 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 537 | | Unchecked = false; | 538 | | #endif | 539 | 9.89k | return HasError ? Error(std::move(*getErrorStorage()))43 : Error::success()9.85k ; | 540 | 9.89k | } |
|
541 | | |
542 | | /// \brief Returns a pointer to the stored T value. |
543 | 38.2k | pointer operator->() { |
544 | 38.2k | assertIsChecked(); |
545 | 38.2k | return toPointer(getStorage()); |
546 | 38.2k | } llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >::operator->() Line | Count | Source | 543 | 5.18k | pointer operator->() { | 544 | 5.18k | assertIsChecked(); | 545 | 5.18k | return toPointer(getStorage()); | 546 | 5.18k | } |
llvm::Expected<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >::operator->() Line | Count | Source | 543 | 10.8k | pointer operator->() { | 544 | 10.8k | assertIsChecked(); | 545 | 10.8k | return toPointer(getStorage()); | 546 | 10.8k | } |
llvm::Expected<llvm::BitcodeFileContents>::operator->() Line | Count | Source | 543 | 11.2k | pointer operator->() { | 544 | 11.2k | assertIsChecked(); | 545 | 11.2k | return toPointer(getStorage()); | 546 | 11.2k | } |
llvm::Expected<llvm::BitcodeModule>::operator->() Line | Count | Source | 543 | 10.9k | pointer operator->() { | 544 | 10.9k | assertIsChecked(); | 545 | 10.9k | return toPointer(getStorage()); | 546 | 10.9k | } |
|
547 | | |
548 | | /// \brief Returns a const pointer to the stored T value. |
549 | | const_pointer operator->() const { |
550 | | assertIsChecked(); |
551 | | return toPointer(getStorage()); |
552 | | } |
553 | | |
554 | | /// \brief Returns a reference to the stored T value. |
555 | 820k | reference operator*() { |
556 | 820k | assertIsChecked(); |
557 | 820k | return *getStorage(); |
558 | 820k | } llvm::Expected<llvm::codeview::TypeIndex>::operator*() Line | Count | Source | 555 | 1.64k | reference operator*() { | 556 | 1.64k | assertIsChecked(); | 557 | 1.64k | return *getStorage(); | 558 | 1.64k | } |
llvm::Expected<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::operator*() Line | Count | Source | 555 | 887 | reference operator*() { | 556 | 887 | assertIsChecked(); | 557 | 887 | return *getStorage(); | 558 | 887 | } |
llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >::operator*() Line | Count | Source | 555 | 5.18k | reference operator*() { | 556 | 5.18k | assertIsChecked(); | 557 | 5.18k | return *getStorage(); | 558 | 5.18k | } |
llvm::Expected<unsigned int>::operator*() Line | Count | Source | 555 | 35.2k | reference operator*() { | 556 | 35.2k | assertIsChecked(); | 557 | 35.2k | return *getStorage(); | 558 | 35.2k | } |
llvm::Expected<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >::operator*() Line | Count | Source | 555 | 10.9k | reference operator*() { | 556 | 10.9k | assertIsChecked(); | 557 | 10.9k | return *getStorage(); | 558 | 10.9k | } |
llvm::Expected<llvm::BitstreamCursor>::operator*() Line | Count | Source | 555 | 11.4k | reference operator*() { | 556 | 11.4k | assertIsChecked(); | 557 | 11.4k | return *getStorage(); | 558 | 11.4k | } |
llvm::Expected<llvm::StringRef>::operator*() Line | Count | Source | 555 | 717k | reference operator*() { | 556 | 717k | assertIsChecked(); | 557 | 717k | return *getStorage(); | 558 | 717k | } |
llvm::Expected<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::operator*() Line | Count | Source | 555 | 27.9k | reference operator*() { | 556 | 27.9k | assertIsChecked(); | 557 | 27.9k | return *getStorage(); | 558 | 27.9k | } |
llvm::Expected<std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > >::operator*() Line | Count | Source | 555 | 2.57k | reference operator*() { | 556 | 2.57k | assertIsChecked(); | 557 | 2.57k | return *getStorage(); | 558 | 2.57k | } |
llvm::Expected<llvm::MutableArrayRef<unsigned char> >::operator*() Line | Count | Source | 555 | 7.96k | reference operator*() { | 556 | 7.96k | assertIsChecked(); | 557 | 7.96k | return *getStorage(); | 558 | 7.96k | } |
|
559 | | |
560 | | /// \brief Returns a const reference to the stored T value. |
561 | | const_reference operator*() const { |
562 | | assertIsChecked(); |
563 | | return *getStorage(); |
564 | | } |
565 | | |
566 | | private: |
567 | | template <class T1> |
568 | | static bool compareThisIfSameType(const T1 &a, const T1 &b) { |
569 | | return &a == &b; |
570 | | } |
571 | | |
572 | | template <class T1, class T2> |
573 | | static bool compareThisIfSameType(const T1 &a, const T2 &b) { |
574 | | return false; |
575 | | } |
576 | | |
577 | 0 | template <class OtherT> void moveConstruct(Expected<OtherT> &&Other) { |
578 | 0 | HasError = Other.HasError; |
579 | 0 | #if LLVM_ENABLE_ABI_BREAKING_CHECKS |
580 | 0 | Unchecked = true; |
581 | 0 | Other.Unchecked = false; |
582 | 0 | #endif |
583 | 0 |
|
584 | 0 | if (!HasError) |
585 | 0 | new (getStorage()) storage_type(std::move(*Other.getStorage())); |
586 | 0 | else |
587 | 0 | new (getErrorStorage()) error_type(std::move(*Other.getErrorStorage())); |
588 | 0 | } Unexecuted instantiation: void llvm::Expected<llvm::MutableArrayRef<unsigned char> >::moveConstruct<llvm::MutableArrayRef<unsigned char> >(llvm::Expected<llvm::MutableArrayRef<unsigned char> >&&) Unexecuted instantiation: void llvm::Expected<llvm::codeview::TypeIndex>::moveConstruct<llvm::codeview::TypeIndex>(llvm::Expected<llvm::codeview::TypeIndex>&&) Unexecuted instantiation: void llvm::Expected<llvm::BitcodeLTOInfo>::moveConstruct<llvm::BitcodeLTOInfo>(llvm::Expected<llvm::BitcodeLTOInfo>&&) Unexecuted instantiation: void llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::SymbolKind> >::moveConstruct<llvm::codeview::CVRecord<llvm::codeview::SymbolKind> >(llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::SymbolKind> >&&) Unexecuted instantiation: void llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >::moveConstruct<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >(llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >&&) Unexecuted instantiation: void llvm::Expected<llvm::Value*>::moveConstruct<llvm::Value*>(llvm::Expected<llvm::Value*>&&) Unexecuted instantiation: void llvm::Expected<llvm::BitcodeFileContents>::moveConstruct<llvm::BitcodeFileContents>(llvm::Expected<llvm::BitcodeFileContents>&&) Unexecuted instantiation: void llvm::Expected<std::__1::unique_ptr<llvm::ValueProfData, std::__1::default_delete<llvm::ValueProfData> > >::moveConstruct<std::__1::unique_ptr<llvm::ValueProfData, std::__1::default_delete<llvm::ValueProfData> > >(llvm::Expected<std::__1::unique_ptr<llvm::ValueProfData, std::__1::default_delete<llvm::ValueProfData> > >&&) Unexecuted instantiation: void llvm::Expected<std::__1::unique_ptr<llvm::InstrProfReader, std::__1::default_delete<llvm::InstrProfReader> > >::moveConstruct<std::__1::unique_ptr<llvm::InstrProfReader, std::__1::default_delete<llvm::InstrProfReader> > >(llvm::Expected<std::__1::unique_ptr<llvm::InstrProfReader, std::__1::default_delete<llvm::InstrProfReader> > >&&) Unexecuted instantiation: void llvm::Expected<std::__1::unique_ptr<llvm::IndexedInstrProfReader, std::__1::default_delete<llvm::IndexedInstrProfReader> > >::moveConstruct<std::__1::unique_ptr<llvm::IndexedInstrProfReader, std::__1::default_delete<llvm::IndexedInstrProfReader> > >(llvm::Expected<std::__1::unique_ptr<llvm::IndexedInstrProfReader, std::__1::default_delete<llvm::IndexedInstrProfReader> > >&&) Unexecuted instantiation: void llvm::Expected<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >::moveConstruct<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >(llvm::Expected<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >&&) Unexecuted instantiation: void llvm::Expected<llvm::BitcodeModule>::moveConstruct<llvm::BitcodeModule>(llvm::Expected<llvm::BitcodeModule>&&) Unexecuted instantiation: void llvm::Expected<llvm::BitstreamCursor>::moveConstruct<llvm::BitstreamCursor>(llvm::Expected<llvm::BitstreamCursor>&&) Unexecuted instantiation: void llvm::Expected<std::__1::unique_ptr<llvm::ModuleSummaryIndex, std::__1::default_delete<llvm::ModuleSummaryIndex> > >::moveConstruct<std::__1::unique_ptr<llvm::ModuleSummaryIndex, std::__1::default_delete<llvm::ModuleSummaryIndex> > >(llvm::Expected<std::__1::unique_ptr<llvm::ModuleSummaryIndex, std::__1::default_delete<llvm::ModuleSummaryIndex> > >&&) Unexecuted instantiation: void llvm::Expected<std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > >::moveConstruct<std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > >(llvm::Expected<std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > >&&) Unexecuted instantiation: void llvm::Expected<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::moveConstruct<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >(llvm::Expected<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >&&) |
589 | | |
590 | | template <class OtherT> void moveAssign(Expected<OtherT> &&Other) { |
591 | | assertIsChecked(); |
592 | | |
593 | | if (compareThisIfSameType(*this, Other)) |
594 | | return; |
595 | | |
596 | | this->~Expected(); |
597 | | new (this) Expected(std::move(Other)); |
598 | | } |
599 | | |
600 | 38.2k | pointer toPointer(pointer Val) { return Val; } llvm::Expected<llvm::BitcodeModule>::toPointer(llvm::BitcodeModule*) Line | Count | Source | 600 | 10.9k | pointer toPointer(pointer Val) { return Val; } |
llvm::Expected<llvm::BitcodeFileContents>::toPointer(llvm::BitcodeFileContents*) Line | Count | Source | 600 | 11.2k | pointer toPointer(pointer Val) { return Val; } |
llvm::Expected<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >::toPointer(std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> >*) Line | Count | Source | 600 | 10.8k | pointer toPointer(pointer Val) { return Val; } |
llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >::toPointer(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>*) Line | Count | Source | 600 | 5.18k | pointer toPointer(pointer Val) { return Val; } |
|
601 | | |
602 | | const_pointer toPointer(const_pointer Val) const { return Val; } |
603 | | |
604 | | pointer toPointer(wrap *Val) { return &Val->get(); } |
605 | | |
606 | | const_pointer toPointer(const wrap *Val) const { return &Val->get(); } |
607 | | |
608 | 46.5M | storage_type *getStorage() { |
609 | 46.5M | assert(!HasError && "Cannot get value when an error exists!"); |
610 | 46.5M | return reinterpret_cast<storage_type *>(TStorage.buffer); |
611 | 46.5M | } llvm::Expected<std::__1::unique_ptr<llvm::ValueProfData, std::__1::default_delete<llvm::ValueProfData> > >::getStorage() Line | Count | Source | 608 | 2.06k | storage_type *getStorage() { | 609 | 2.06k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 2.06k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 2.06k | } |
llvm::Expected<bool>::getStorage() Line | Count | Source | 608 | 11.6k | storage_type *getStorage() { | 609 | 11.6k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 11.6k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 11.6k | } |
llvm::Expected<llvm::BitcodeLTOInfo>::getStorage() Line | Count | Source | 608 | 2.16k | storage_type *getStorage() { | 609 | 2.16k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 2.16k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 2.16k | } |
llvm::Expected<std::__1::unique_ptr<llvm::ModuleSummaryIndex, std::__1::default_delete<llvm::ModuleSummaryIndex> > >::getStorage() Line | Count | Source | 608 | 338 | storage_type *getStorage() { | 609 | 338 | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 338 | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 338 | } |
llvm::Expected<llvm::BitcodeFileContents>::getStorage() Line | Count | Source | 608 | 34.3k | storage_type *getStorage() { | 609 | 34.3k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 34.3k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 34.3k | } |
llvm::Expected<llvm::MutableArrayRef<unsigned char> >::getStorage() Line | Count | Source | 608 | 23.8k | storage_type *getStorage() { | 609 | 23.8k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 23.8k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 23.8k | } |
llvm::Expected<llvm::codeview::TypeIndex>::getStorage() Line | Count | Source | 608 | 5.19k | storage_type *getStorage() { | 609 | 5.19k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 5.19k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 5.19k | } |
llvm::Expected<std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > >::getStorage() Line | Count | Source | 608 | 34.3k | storage_type *getStorage() { | 609 | 34.3k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 34.3k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 34.3k | } |
llvm::Expected<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::getStorage() Line | Count | Source | 608 | 3.82k | storage_type *getStorage() { | 609 | 3.82k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 3.82k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 3.82k | } |
llvm::Expected<std::__1::unique_ptr<llvm::IndexedInstrProfReader, std::__1::default_delete<llvm::IndexedInstrProfReader> > >::getStorage() Line | Count | Source | 608 | 919 | storage_type *getStorage() { | 609 | 919 | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 919 | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 919 | } |
llvm::Expected<llvm::InstrProfRecord>::getStorage() Line | Count | Source | 608 | 1.42k | storage_type *getStorage() { | 609 | 1.42k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 1.42k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 1.42k | } |
llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >::getStorage() Line | Count | Source | 608 | 20.7k | storage_type *getStorage() { | 609 | 20.7k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 20.7k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 20.7k | } |
llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::SymbolKind> >::getStorage() Line | Count | Source | 608 | 7.20k | storage_type *getStorage() { | 609 | 7.20k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 7.20k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 7.20k | } |
llvm::Expected<llvm::BitstreamCursor>::getStorage() Line | Count | Source | 608 | 34.3k | storage_type *getStorage() { | 609 | 34.3k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 34.3k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 34.3k | } |
llvm::Expected<llvm::StringRef>::getStorage() Line | Count | Source | 608 | 2.21M | storage_type *getStorage() { | 609 | 2.21M | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 2.21M | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 2.21M | } |
llvm::Expected<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::getStorage() Line | Count | Source | 608 | 98.7k | storage_type *getStorage() { | 609 | 98.7k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 98.7k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 98.7k | } |
llvm::Expected<llvm::Value*>::getStorage() Line | Count | Source | 608 | 43.8M | storage_type *getStorage() { | 609 | 43.8M | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 43.8M | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 43.8M | } |
llvm::Expected<unsigned int>::getStorage() Line | Count | Source | 608 | 121k | storage_type *getStorage() { | 609 | 121k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 121k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 121k | } |
llvm::Expected<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >::getStorage() Line | Count | Source | 608 | 43.5k | storage_type *getStorage() { | 609 | 43.5k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 43.5k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 43.5k | } |
llvm::Expected<llvm::BitcodeModule>::getStorage() Line | Count | Source | 608 | 32.5k | storage_type *getStorage() { | 609 | 32.5k | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 32.5k | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 32.5k | } |
llvm::Expected<std::__1::unique_ptr<llvm::InstrProfReader, std::__1::default_delete<llvm::InstrProfReader> > >::getStorage() Line | Count | Source | 608 | 552 | storage_type *getStorage() { | 609 | 552 | assert(!HasError && "Cannot get value when an error exists!"); | 610 | 552 | return reinterpret_cast<storage_type *>(TStorage.buffer); | 611 | 552 | } |
|
612 | | |
613 | | const storage_type *getStorage() const { |
614 | | assert(!HasError && "Cannot get value when an error exists!"); |
615 | | return reinterpret_cast<const storage_type *>(TStorage.buffer); |
616 | | } |
617 | | |
618 | 652 | error_type *getErrorStorage() { |
619 | 652 | assert(HasError && "Cannot get error when a value exists!"); |
620 | 652 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); |
621 | 652 | } Unexecuted instantiation: llvm::Expected<std::__1::unique_ptr<llvm::ValueProfData, std::__1::default_delete<llvm::ValueProfData> > >::getErrorStorage() Unexecuted instantiation: llvm::Expected<llvm::BitcodeLTOInfo>::getErrorStorage() llvm::Expected<std::__1::unique_ptr<llvm::ModuleSummaryIndex, std::__1::default_delete<llvm::ModuleSummaryIndex> > >::getErrorStorage() Line | Count | Source | 618 | 3 | error_type *getErrorStorage() { | 619 | 3 | assert(HasError && "Cannot get error when a value exists!"); | 620 | 3 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); | 621 | 3 | } |
llvm::Expected<llvm::BitcodeFileContents>::getErrorStorage() Line | Count | Source | 618 | 42 | error_type *getErrorStorage() { | 619 | 42 | assert(HasError && "Cannot get error when a value exists!"); | 620 | 42 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); | 621 | 42 | } |
llvm::Expected<bool>::getErrorStorage() Line | Count | Source | 618 | 15 | error_type *getErrorStorage() { | 619 | 15 | assert(HasError && "Cannot get error when a value exists!"); | 620 | 15 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); | 621 | 15 | } |
llvm::Expected<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::getErrorStorage() Line | Count | Source | 618 | 9 | error_type *getErrorStorage() { | 619 | 9 | assert(HasError && "Cannot get error when a value exists!"); | 620 | 9 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); | 621 | 9 | } |
llvm::Expected<llvm::BitcodeModule>::getErrorStorage() Line | Count | Source | 618 | 60 | error_type *getErrorStorage() { | 619 | 60 | assert(HasError && "Cannot get error when a value exists!"); | 620 | 60 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); | 621 | 60 | } |
llvm::Expected<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >::getErrorStorage() Line | Count | Source | 618 | 42 | error_type *getErrorStorage() { | 619 | 42 | assert(HasError && "Cannot get error when a value exists!"); | 620 | 42 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); | 621 | 42 | } |
llvm::Expected<unsigned int>::getErrorStorage() Line | Count | Source | 618 | 54 | error_type *getErrorStorage() { | 619 | 54 | assert(HasError && "Cannot get error when a value exists!"); | 620 | 54 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); | 621 | 54 | } |
Unexecuted instantiation: llvm::Expected<llvm::Value*>::getErrorStorage() llvm::Expected<llvm::StringRef>::getErrorStorage() Line | Count | Source | 618 | 116 | error_type *getErrorStorage() { | 619 | 116 | assert(HasError && "Cannot get error when a value exists!"); | 620 | 116 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); | 621 | 116 | } |
llvm::Expected<llvm::BitstreamCursor>::getErrorStorage() Line | Count | Source | 618 | 6 | error_type *getErrorStorage() { | 619 | 6 | assert(HasError && "Cannot get error when a value exists!"); | 620 | 6 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); | 621 | 6 | } |
llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::SymbolKind> >::getErrorStorage() Line | Count | Source | 618 | 3 | error_type *getErrorStorage() { | 619 | 3 | assert(HasError && "Cannot get error when a value exists!"); | 620 | 3 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); | 621 | 3 | } |
llvm::Expected<std::__1::unique_ptr<llvm::InstrProfReader, std::__1::default_delete<llvm::InstrProfReader> > >::getErrorStorage() Line | Count | Source | 618 | 15 | error_type *getErrorStorage() { | 619 | 15 | assert(HasError && "Cannot get error when a value exists!"); | 620 | 15 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); | 621 | 15 | } |
Unexecuted instantiation: llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >::getErrorStorage() llvm::Expected<llvm::InstrProfRecord>::getErrorStorage() Line | Count | Source | 618 | 186 | error_type *getErrorStorage() { | 619 | 186 | assert(HasError && "Cannot get error when a value exists!"); | 620 | 186 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); | 621 | 186 | } |
llvm::Expected<std::__1::unique_ptr<llvm::IndexedInstrProfReader, std::__1::default_delete<llvm::IndexedInstrProfReader> > >::getErrorStorage() Line | Count | Source | 618 | 10 | error_type *getErrorStorage() { | 619 | 10 | assert(HasError && "Cannot get error when a value exists!"); | 620 | 10 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); | 621 | 10 | } |
llvm::Expected<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::getErrorStorage() Line | Count | Source | 618 | 20 | error_type *getErrorStorage() { | 619 | 20 | assert(HasError && "Cannot get error when a value exists!"); | 620 | 20 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); | 621 | 20 | } |
llvm::Expected<std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > >::getErrorStorage() Line | Count | Source | 618 | 71 | error_type *getErrorStorage() { | 619 | 71 | assert(HasError && "Cannot get error when a value exists!"); | 620 | 71 | return reinterpret_cast<error_type *>(ErrorStorage.buffer); | 621 | 71 | } |
Unexecuted instantiation: llvm::Expected<llvm::codeview::TypeIndex>::getErrorStorage() Unexecuted instantiation: llvm::Expected<llvm::MutableArrayRef<unsigned char> >::getErrorStorage() |
622 | | |
623 | | const error_type *getErrorStorage() const { |
624 | | assert(HasError && "Cannot get error when a value exists!"); |
625 | | return reinterpret_cast<const error_type *>(ErrorStorage.buffer); |
626 | | } |
627 | | |
628 | | // Used by ExpectedAsOutParameter to reset the checked flag. |
629 | | void setUnchecked() { |
630 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS |
631 | | Unchecked = true; |
632 | | #endif |
633 | | } |
634 | | |
635 | 31.0M | void assertIsChecked() { |
636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS |
637 | | if (Unchecked) { |
638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; |
639 | | if (HasError) { |
640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; |
641 | | (*getErrorStorage())->log(dbgs()); |
642 | | } else |
643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " |
644 | | "values in success mode must still be checked prior to being " |
645 | | "destroyed).\n"; |
646 | | abort(); |
647 | | } |
648 | | #endif |
649 | | } Unexecuted instantiation: llvm::Expected<llvm::BitcodeLTOInfo>::assertIsChecked() llvm::Expected<std::__1::unique_ptr<llvm::ValueProfData, std::__1::default_delete<llvm::ValueProfData> > >::assertIsChecked() Line | Count | Source | 635 | 1.54k | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
Unexecuted instantiation: llvm::Expected<std::__1::unique_ptr<llvm::InstrProfReader, std::__1::default_delete<llvm::InstrProfReader> > >::assertIsChecked() llvm::Expected<bool>::assertIsChecked() Line | Count | Source | 635 | 7.60k | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
Unexecuted instantiation: llvm::Expected<std::__1::unique_ptr<llvm::ModuleSummaryIndex, std::__1::default_delete<llvm::ModuleSummaryIndex> > >::assertIsChecked() llvm::Expected<llvm::BitcodeModule>::assertIsChecked() Line | Count | Source | 635 | 21.7k | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
llvm::Expected<llvm::BitcodeFileContents>::assertIsChecked() Line | Count | Source | 635 | 23.0k | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
llvm::Expected<llvm::StringRef>::assertIsChecked() Line | Count | Source | 635 | 1.47M | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
llvm::Expected<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::assertIsChecked() Line | Count | Source | 635 | 63.3k | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
llvm::Expected<llvm::BitstreamCursor>::assertIsChecked() Line | Count | Source | 635 | 22.8k | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
llvm::Expected<std::__1::vector<llvm::BitcodeModule, std::__1::allocator<llvm::BitcodeModule> > >::assertIsChecked() Line | Count | Source | 635 | 32.6k | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
llvm::Expected<unsigned int>::assertIsChecked() Line | Count | Source | 635 | 77.3k | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
llvm::Expected<llvm::Value*>::assertIsChecked() Line | Count | Source | 635 | 29.2M | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
Unexecuted instantiation: llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::SymbolKind> >::assertIsChecked() llvm::Expected<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::assertIsChecked() Line | Count | Source | 635 | 2.55k | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
llvm::Expected<std::__1::unique_ptr<llvm::IndexedInstrProfReader, std::__1::default_delete<llvm::IndexedInstrProfReader> > >::assertIsChecked() Line | Count | Source | 635 | 614 | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
llvm::Expected<llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind> >::assertIsChecked() Line | Count | Source | 635 | 15.5k | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
llvm::Expected<llvm::MutableArrayRef<unsigned char> >::assertIsChecked() Line | Count | Source | 635 | 15.9k | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
llvm::Expected<llvm::codeview::TypeIndex>::assertIsChecked() Line | Count | Source | 635 | 3.42k | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
llvm::Expected<std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > >::assertIsChecked() Line | Count | Source | 635 | 23.2k | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
llvm::Expected<llvm::InstrProfRecord>::assertIsChecked() Line | Count | Source | 635 | 1.03k | void assertIsChecked() { | 636 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS | 637 | | if (Unchecked) { | 638 | | dbgs() << "Expected<T> must be checked before access or destruction.\n"; | 639 | | if (HasError) { | 640 | | dbgs() << "Unchecked Expected<T> contained error:\n"; | 641 | | (*getErrorStorage())->log(dbgs()); | 642 | | } else | 643 | | dbgs() << "Expected<T> value was in success state. (Note: Expected<T> " | 644 | | "values in success mode must still be checked prior to being " | 645 | | "destroyed).\n"; | 646 | | abort(); | 647 | | } | 648 | | #endif | 649 | | } |
|
650 | | |
651 | | union { |
652 | | AlignedCharArrayUnion<storage_type> TStorage; |
653 | | AlignedCharArrayUnion<error_type> ErrorStorage; |
654 | | }; |
655 | | bool HasError : 1; |
656 | | #if LLVM_ENABLE_ABI_BREAKING_CHECKS |
657 | | bool Unchecked : 1; |
658 | | #endif |
659 | | }; |
660 | | |
661 | | /// Report a serious error, calling any installed error handler. See |
662 | | /// ErrorHandling.h. |
663 | | LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, |
664 | | bool gen_crash_diag = true); |
665 | | |
666 | | /// Report a fatal error if Err is a failure value. |
667 | | /// |
668 | | /// This function can be used to wrap calls to fallible functions ONLY when it |
669 | | /// is known that the Error will always be a success value. E.g. |
670 | | /// |
671 | | /// @code{.cpp} |
672 | | /// // foo only attempts the fallible operation if DoFallibleOperation is |
673 | | /// // true. If DoFallibleOperation is false then foo always returns |
674 | | /// // Error::success(). |
675 | | /// Error foo(bool DoFallibleOperation); |
676 | | /// |
677 | | /// cantFail(foo(false)); |
678 | | /// @endcode |
679 | 878k | inline void cantFail(Error Err, const char *Msg = nullptr) { |
680 | 878k | if (Err878k ) { |
681 | 0 | if (!Msg) |
682 | 0 | Msg = "Failure value returned from cantFail wrapped call"; |
683 | 0 | llvm_unreachable(Msg); |
684 | 0 | } |
685 | 878k | } |
686 | | |
687 | | /// Report a fatal error if ValOrErr is a failure value, otherwise unwraps and |
688 | | /// returns the contained value. |
689 | | /// |
690 | | /// This function can be used to wrap calls to fallible functions ONLY when it |
691 | | /// is known that the Error will always be a success value. E.g. |
692 | | /// |
693 | | /// @code{.cpp} |
694 | | /// // foo only attempts the fallible operation if DoFallibleOperation is |
695 | | /// // true. If DoFallibleOperation is false then foo always returns an int. |
696 | | /// Expected<int> foo(bool DoFallibleOperation); |
697 | | /// |
698 | | /// int X = cantFail(foo(false)); |
699 | | /// @endcode |
700 | | template <typename T> |
701 | | T cantFail(Expected<T> ValOrErr, const char *Msg = nullptr) { |
702 | | if (ValOrErr) |
703 | | return std::move(*ValOrErr); |
704 | | else { |
705 | | if (!Msg) |
706 | | Msg = "Failure value returned from cantFail wrapped call"; |
707 | | llvm_unreachable(Msg); |
708 | | } |
709 | | } |
710 | | |
711 | | /// Report a fatal error if ValOrErr is a failure value, otherwise unwraps and |
712 | | /// returns the contained reference. |
713 | | /// |
714 | | /// This function can be used to wrap calls to fallible functions ONLY when it |
715 | | /// is known that the Error will always be a success value. E.g. |
716 | | /// |
717 | | /// @code{.cpp} |
718 | | /// // foo only attempts the fallible operation if DoFallibleOperation is |
719 | | /// // true. If DoFallibleOperation is false then foo always returns a Bar&. |
720 | | /// Expected<Bar&> foo(bool DoFallibleOperation); |
721 | | /// |
722 | | /// Bar &X = cantFail(foo(false)); |
723 | | /// @endcode |
724 | | template <typename T> |
725 | | T& cantFail(Expected<T&> ValOrErr, const char *Msg = nullptr) { |
726 | | if (ValOrErr) |
727 | | return *ValOrErr; |
728 | | else { |
729 | | if (!Msg) |
730 | | Msg = "Failure value returned from cantFail wrapped call"; |
731 | | llvm_unreachable(Msg); |
732 | | } |
733 | | } |
734 | | |
735 | | /// Helper for testing applicability of, and applying, handlers for |
736 | | /// ErrorInfo types. |
737 | | template <typename HandlerT> |
738 | | class ErrorHandlerTraits |
739 | | : public ErrorHandlerTraits<decltype( |
740 | | &std::remove_reference<HandlerT>::type::operator())> {}; |
741 | | |
742 | | // Specialization functions of the form 'Error (const ErrT&)'. |
743 | | template <typename ErrT> class ErrorHandlerTraits<Error (&)(ErrT &)> { |
744 | | public: |
745 | | static bool appliesTo(const ErrorInfoBase &E) { |
746 | | return E.template isA<ErrT>(); |
747 | | } |
748 | | |
749 | | template <typename HandlerT> |
750 | | static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) { |
751 | | assert(appliesTo(*E) && "Applying incorrect handler"); |
752 | | return H(static_cast<ErrT &>(*E)); |
753 | | } |
754 | | }; |
755 | | |
756 | | // Specialization functions of the form 'void (const ErrT&)'. |
757 | | template <typename ErrT> class ErrorHandlerTraits<void (&)(ErrT &)> { |
758 | | public: |
759 | 27.2k | static bool appliesTo(const ErrorInfoBase &E) { |
760 | 27.2k | return E.template isA<ErrT>(); |
761 | 27.2k | } llvm::ErrorHandlerTraits<void (&)(llvm::InstrProfError&)>::appliesTo(llvm::ErrorInfoBase const&) Line | Count | Source | 759 | 362 | static bool appliesTo(const ErrorInfoBase &E) { | 760 | 362 | return E.template isA<ErrT>(); | 761 | 362 | } |
llvm::ErrorHandlerTraits<void (&)(llvm::ErrorInfoBase&)>::appliesTo(llvm::ErrorInfoBase const&) Line | Count | Source | 759 | 26.8k | static bool appliesTo(const ErrorInfoBase &E) { | 760 | 26.8k | return E.template isA<ErrT>(); | 761 | 26.8k | } |
|
762 | | |
763 | | template <typename HandlerT> |
764 | 27.0k | static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) { |
765 | 27.0k | assert(appliesTo(*E) && "Applying incorrect handler"); |
766 | 27.0k | H(static_cast<ErrT &>(*E)); |
767 | 27.0k | return Error::success(); |
768 | 27.0k | } BitcodeReader.cpp:llvm::Error llvm::ErrorHandlerTraits<void (&)(llvm::ErrorInfoBase&)>::apply<llvm::errorToErrorCodeAndEmitErrors(llvm::LLVMContext&, llvm::Error)::$_0>(llvm::errorToErrorCodeAndEmitErrors(llvm::LLVMContext&, llvm::Error)::$_0&&, std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >) Line | Count | Source | 764 | 4 | static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) { | 765 | 4 | assert(appliesTo(*E) && "Applying incorrect handler"); | 766 | 4 | H(static_cast<ErrT &>(*E)); | 767 | 4 | return Error::success(); | 768 | 4 | } |
llvm::Error llvm::ErrorHandlerTraits<void (&)(llvm::ErrorInfoBase&)>::apply<llvm::consumeError(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)>(llvm::consumeError(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)&&, std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >) Line | Count | Source | 764 | 23.7k | static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) { | 765 | 23.7k | assert(appliesTo(*E) && "Applying incorrect handler"); | 766 | 23.7k | H(static_cast<ErrT &>(*E)); | 767 | 23.7k | return Error::success(); | 768 | 23.7k | } |
PGOInstrumentation.cpp:llvm::Error llvm::ErrorHandlerTraits<void (&)(llvm::InstrProfError&)>::apply<(anonymous namespace)::PGOUseFunc::readCounters(llvm::IndexedInstrProfReader*)::$_6>((anonymous namespace)::PGOUseFunc::readCounters(llvm::IndexedInstrProfReader*)::$_6&&, std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >) Line | Count | Source | 764 | 8 | static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) { | 765 | 8 | assert(appliesTo(*E) && "Applying incorrect handler"); | 766 | 8 | H(static_cast<ErrT &>(*E)); | 767 | 8 | return Error::success(); | 768 | 8 | } |
PGOInstrumentation.cpp:llvm::Error llvm::ErrorHandlerTraits<void (&)(llvm::ErrorInfoBase&)>::apply<annotateAllFunctions(llvm::Module&, llvm::StringRef, llvm::function_ref<llvm::BranchProbabilityInfo* (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo* (llvm::Function&)>)::$_9>(annotateAllFunctions(llvm::Module&, llvm::StringRef, llvm::function_ref<llvm::BranchProbabilityInfo* (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo* (llvm::Function&)>)::$_9&&, std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >) Line | Count | Source | 764 | 2 | static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) { | 765 | 2 | assert(appliesTo(*E) && "Applying incorrect handler"); | 766 | 2 | H(static_cast<ErrT &>(*E)); | 767 | 2 | return Error::success(); | 768 | 2 | } |
Error.cpp:llvm::Error llvm::ErrorHandlerTraits<void (&)(llvm::ErrorInfoBase&)>::apply<llvm::errorToErrorCode(llvm::Error)::$_1>(llvm::errorToErrorCode(llvm::Error)::$_1&&, std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >) Line | Count | Source | 764 | 21 | static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) { | 765 | 21 | assert(appliesTo(*E) && "Applying incorrect handler"); | 766 | 21 | H(static_cast<ErrT &>(*E)); | 767 | 21 | return Error::success(); | 768 | 21 | } |
Error.cpp:llvm::Error llvm::ErrorHandlerTraits<void (&)(llvm::ErrorInfoBase&)>::apply<llvm::logAllUnhandledErrors(llvm::Error, llvm::raw_ostream&, llvm::Twine)::$_0>(llvm::logAllUnhandledErrors(llvm::Error, llvm::raw_ostream&, llvm::Twine)::$_0&&, std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >) Line | Count | Source | 764 | 399 | static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) { | 765 | 399 | assert(appliesTo(*E) && "Applying incorrect handler"); | 766 | 399 | H(static_cast<ErrT &>(*E)); | 767 | 399 | return Error::success(); | 768 | 399 | } |
Unexecuted instantiation: IRReader.cpp:llvm::Error llvm::ErrorHandlerTraits<void (&)(llvm::ErrorInfoBase&)>::apply<llvm::parseIR(llvm::MemoryBufferRef, llvm::SMDiagnostic&, llvm::LLVMContext&)::$_0>(llvm::parseIR(llvm::MemoryBufferRef, llvm::SMDiagnostic&, llvm::LLVMContext&)::$_0&&, std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >) Unexecuted instantiation: IRReader.cpp:llvm::Error llvm::ErrorHandlerTraits<void (&)(llvm::ErrorInfoBase&)>::apply<getLazyIRModule(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, llvm::SMDiagnostic&, llvm::LLVMContext&, bool)::$_1>(getLazyIRModule(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, llvm::SMDiagnostic&, llvm::LLVMContext&, bool)::$_1&&, std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >) Unexecuted instantiation: LegacyPassManager.cpp:llvm::Error llvm::ErrorHandlerTraits<void (&)(llvm::ErrorInfoBase&)>::apply<llvm::legacy::FunctionPassManager::run(llvm::Function&)::$_0>(llvm::legacy::FunctionPassManager::run(llvm::Function&)::$_0&&, std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >) llvm::Error llvm::ErrorHandlerTraits<void (&)(llvm::InstrProfError&)>::apply<llvm::InstrProfError::take(llvm::Error)::'lambda'(llvm::InstrProfError const&)>(llvm::InstrProfError::take(llvm::Error)::'lambda'(llvm::InstrProfError const&)&&, std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >) Line | Count | Source | 764 | 334 | static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) { | 765 | 334 | assert(appliesTo(*E) && "Applying incorrect handler"); | 766 | 334 | H(static_cast<ErrT &>(*E)); | 767 | 334 | return Error::success(); | 768 | 334 | } |
llvm::Error llvm::ErrorHandlerTraits<void (&)(llvm::ErrorInfoBase&)>::apply<llvm::toString(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)>(llvm::toString(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)&&, std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >) Line | Count | Source | 764 | 2.56k | static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) { | 765 | 2.56k | assert(appliesTo(*E) && "Applying incorrect handler"); | 766 | 2.56k | H(static_cast<ErrT &>(*E)); | 767 | 2.56k | return Error::success(); | 768 | 2.56k | } |
|
769 | | }; |
770 | | |
771 | | /// Specialization for functions of the form 'Error (std::unique_ptr<ErrT>)'. |
772 | | template <typename ErrT> |
773 | | class ErrorHandlerTraits<Error (&)(std::unique_ptr<ErrT>)> { |
774 | | public: |
775 | | static bool appliesTo(const ErrorInfoBase &E) { |
776 | | return E.template isA<ErrT>(); |
777 | | } |
778 | | |
779 | | template <typename HandlerT> |
780 | | static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) { |
781 | | assert(appliesTo(*E) && "Applying incorrect handler"); |
782 | | std::unique_ptr<ErrT> SubE(static_cast<ErrT *>(E.release())); |
783 | | return H(std::move(SubE)); |
784 | | } |
785 | | }; |
786 | | |
787 | | /// Specialization for functions of the form 'void (std::unique_ptr<ErrT>)'. |
788 | | template <typename ErrT> |
789 | | class ErrorHandlerTraits<void (&)(std::unique_ptr<ErrT>)> { |
790 | | public: |
791 | | static bool appliesTo(const ErrorInfoBase &E) { |
792 | | return E.template isA<ErrT>(); |
793 | | } |
794 | | |
795 | | template <typename HandlerT> |
796 | | static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) { |
797 | | assert(appliesTo(*E) && "Applying incorrect handler"); |
798 | | std::unique_ptr<ErrT> SubE(static_cast<ErrT *>(E.release())); |
799 | | H(std::move(SubE)); |
800 | | return Error::success(); |
801 | | } |
802 | | }; |
803 | | |
804 | | // Specialization for member functions of the form 'RetT (const ErrT&)'. |
805 | | template <typename C, typename RetT, typename ErrT> |
806 | | class ErrorHandlerTraits<RetT (C::*)(ErrT &)> |
807 | | : public ErrorHandlerTraits<RetT (&)(ErrT &)> {}; |
808 | | |
809 | | // Specialization for member functions of the form 'RetT (const ErrT&) const'. |
810 | | template <typename C, typename RetT, typename ErrT> |
811 | | class ErrorHandlerTraits<RetT (C::*)(ErrT &) const> |
812 | | : public ErrorHandlerTraits<RetT (&)(ErrT &)> {}; |
813 | | |
814 | | // Specialization for member functions of the form 'RetT (const ErrT&)'. |
815 | | template <typename C, typename RetT, typename ErrT> |
816 | | class ErrorHandlerTraits<RetT (C::*)(const ErrT &)> |
817 | | : public ErrorHandlerTraits<RetT (&)(ErrT &)> {}; |
818 | | |
819 | | // Specialization for member functions of the form 'RetT (const ErrT&) const'. |
820 | | template <typename C, typename RetT, typename ErrT> |
821 | | class ErrorHandlerTraits<RetT (C::*)(const ErrT &) const> |
822 | | : public ErrorHandlerTraits<RetT (&)(ErrT &)> {}; |
823 | | |
824 | | /// Specialization for member functions of the form |
825 | | /// 'RetT (std::unique_ptr<ErrT>)'. |
826 | | template <typename C, typename RetT, typename ErrT> |
827 | | class ErrorHandlerTraits<RetT (C::*)(std::unique_ptr<ErrT>)> |
828 | | : public ErrorHandlerTraits<RetT (&)(std::unique_ptr<ErrT>)> {}; |
829 | | |
830 | | /// Specialization for member functions of the form |
831 | | /// 'RetT (std::unique_ptr<ErrT>) const'. |
832 | | template <typename C, typename RetT, typename ErrT> |
833 | | class ErrorHandlerTraits<RetT (C::*)(std::unique_ptr<ErrT>) const> |
834 | | : public ErrorHandlerTraits<RetT (&)(std::unique_ptr<ErrT>)> {}; |
835 | | |
836 | 4 | inline Error handleErrorImpl(std::unique_ptr<ErrorInfoBase> Payload) { |
837 | 4 | return Error(std::move(Payload)); |
838 | 4 | } |
839 | | |
840 | | template <typename HandlerT, typename... HandlerTs> |
841 | | Error handleErrorImpl(std::unique_ptr<ErrorInfoBase> Payload, |
842 | 27.0k | HandlerT &&Handler, HandlerTs &&... Handlers) { |
843 | 27.0k | if (ErrorHandlerTraits<HandlerT>::appliesTo(*Payload)) |
844 | 27.0k | return ErrorHandlerTraits<HandlerT>::apply(std::forward<HandlerT>(Handler), |
845 | 27.0k | std::move(Payload)); |
846 | 0 | return handleErrorImpl(std::move(Payload), |
847 | 0 | std::forward<HandlerTs>(Handlers)...); |
848 | 27.0k | } llvm::Error llvm::handleErrorImpl<llvm::consumeError(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)>(std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >, llvm::consumeError(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)&&) Line | Count | Source | 842 | 23.7k | HandlerT &&Handler, HandlerTs &&... Handlers) { | 843 | 23.7k | if (ErrorHandlerTraits<HandlerT>::appliesTo(*Payload)) | 844 | 23.7k | return ErrorHandlerTraits<HandlerT>::apply(std::forward<HandlerT>(Handler), | 845 | 23.7k | std::move(Payload)); | 846 | 0 | return handleErrorImpl(std::move(Payload), | 847 | 0 | std::forward<HandlerTs>(Handlers)...); | 848 | 23.7k | } |
BitcodeReader.cpp:llvm::Error llvm::handleErrorImpl<llvm::errorToErrorCodeAndEmitErrors(llvm::LLVMContext&, llvm::Error)::$_0>(std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >, llvm::errorToErrorCodeAndEmitErrors(llvm::LLVMContext&, llvm::Error)::$_0&&) Line | Count | Source | 842 | 4 | HandlerT &&Handler, HandlerTs &&... Handlers) { | 843 | 4 | if (ErrorHandlerTraits<HandlerT>::appliesTo(*Payload)) | 844 | 4 | return ErrorHandlerTraits<HandlerT>::apply(std::forward<HandlerT>(Handler), | 845 | 4 | std::move(Payload)); | 846 | 0 | return handleErrorImpl(std::move(Payload), | 847 | 0 | std::forward<HandlerTs>(Handlers)...); | 848 | 4 | } |
PGOInstrumentation.cpp:llvm::Error llvm::handleErrorImpl<(anonymous namespace)::PGOUseFunc::readCounters(llvm::IndexedInstrProfReader*)::$_6>(std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >, (anonymous namespace)::PGOUseFunc::readCounters(llvm::IndexedInstrProfReader*)::$_6&&) Line | Count | Source | 842 | 8 | HandlerT &&Handler, HandlerTs &&... Handlers) { | 843 | 8 | if (ErrorHandlerTraits<HandlerT>::appliesTo(*Payload)) | 844 | 8 | return ErrorHandlerTraits<HandlerT>::apply(std::forward<HandlerT>(Handler), | 845 | 8 | std::move(Payload)); | 846 | 0 | return handleErrorImpl(std::move(Payload), | 847 | 0 | std::forward<HandlerTs>(Handlers)...); | 848 | 8 | } |
PGOInstrumentation.cpp:llvm::Error llvm::handleErrorImpl<annotateAllFunctions(llvm::Module&, llvm::StringRef, llvm::function_ref<llvm::BranchProbabilityInfo* (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo* (llvm::Function&)>)::$_9>(std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >, annotateAllFunctions(llvm::Module&, llvm::StringRef, llvm::function_ref<llvm::BranchProbabilityInfo* (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo* (llvm::Function&)>)::$_9&&) Line | Count | Source | 842 | 2 | HandlerT &&Handler, HandlerTs &&... Handlers) { | 843 | 2 | if (ErrorHandlerTraits<HandlerT>::appliesTo(*Payload)) | 844 | 2 | return ErrorHandlerTraits<HandlerT>::apply(std::forward<HandlerT>(Handler), | 845 | 2 | std::move(Payload)); | 846 | 0 | return handleErrorImpl(std::move(Payload), | 847 | 0 | std::forward<HandlerTs>(Handlers)...); | 848 | 2 | } |
Error.cpp:llvm::Error llvm::handleErrorImpl<llvm::errorToErrorCode(llvm::Error)::$_1>(std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >, llvm::errorToErrorCode(llvm::Error)::$_1&&) Line | Count | Source | 842 | 21 | HandlerT &&Handler, HandlerTs &&... Handlers) { | 843 | 21 | if (ErrorHandlerTraits<HandlerT>::appliesTo(*Payload)) | 844 | 21 | return ErrorHandlerTraits<HandlerT>::apply(std::forward<HandlerT>(Handler), | 845 | 21 | std::move(Payload)); | 846 | 0 | return handleErrorImpl(std::move(Payload), | 847 | 0 | std::forward<HandlerTs>(Handlers)...); | 848 | 21 | } |
Error.cpp:llvm::Error llvm::handleErrorImpl<llvm::logAllUnhandledErrors(llvm::Error, llvm::raw_ostream&, llvm::Twine)::$_0>(std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >, llvm::logAllUnhandledErrors(llvm::Error, llvm::raw_ostream&, llvm::Twine)::$_0&&) Line | Count | Source | 842 | 399 | HandlerT &&Handler, HandlerTs &&... Handlers) { | 843 | 399 | if (ErrorHandlerTraits<HandlerT>::appliesTo(*Payload)) | 844 | 399 | return ErrorHandlerTraits<HandlerT>::apply(std::forward<HandlerT>(Handler), | 845 | 399 | std::move(Payload)); | 846 | 0 | return handleErrorImpl(std::move(Payload), | 847 | 0 | std::forward<HandlerTs>(Handlers)...); | 848 | 399 | } |
Unexecuted instantiation: IRReader.cpp:llvm::Error llvm::handleErrorImpl<llvm::parseIR(llvm::MemoryBufferRef, llvm::SMDiagnostic&, llvm::LLVMContext&)::$_0>(std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >, llvm::parseIR(llvm::MemoryBufferRef, llvm::SMDiagnostic&, llvm::LLVMContext&)::$_0&&) Unexecuted instantiation: IRReader.cpp:llvm::Error llvm::handleErrorImpl<getLazyIRModule(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, llvm::SMDiagnostic&, llvm::LLVMContext&, bool)::$_1>(std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >, getLazyIRModule(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, llvm::SMDiagnostic&, llvm::LLVMContext&, bool)::$_1&&) Unexecuted instantiation: LegacyPassManager.cpp:llvm::Error llvm::handleErrorImpl<llvm::legacy::FunctionPassManager::run(llvm::Function&)::$_0>(std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >, llvm::legacy::FunctionPassManager::run(llvm::Function&)::$_0&&) llvm::Error llvm::handleErrorImpl<llvm::InstrProfError::take(llvm::Error)::'lambda'(llvm::InstrProfError const&)>(std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >, llvm::InstrProfError::take(llvm::Error)::'lambda'(llvm::InstrProfError const&)&&) Line | Count | Source | 842 | 334 | HandlerT &&Handler, HandlerTs &&... Handlers) { | 843 | 334 | if (ErrorHandlerTraits<HandlerT>::appliesTo(*Payload)) | 844 | 334 | return ErrorHandlerTraits<HandlerT>::apply(std::forward<HandlerT>(Handler), | 845 | 334 | std::move(Payload)); | 846 | 0 | return handleErrorImpl(std::move(Payload), | 847 | 0 | std::forward<HandlerTs>(Handlers)...); | 848 | 334 | } |
llvm::Error llvm::handleErrorImpl<llvm::toString(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)>(std::__1::unique_ptr<llvm::ErrorInfoBase, std::__1::default_delete<llvm::ErrorInfoBase> >, llvm::toString(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)&&) Line | Count | Source | 842 | 2.56k | HandlerT &&Handler, HandlerTs &&... Handlers) { | 843 | 2.56k | if (ErrorHandlerTraits<HandlerT>::appliesTo(*Payload)) | 844 | 2.56k | return ErrorHandlerTraits<HandlerT>::apply(std::forward<HandlerT>(Handler), | 845 | 2.56k | std::move(Payload)); | 846 | 0 | return handleErrorImpl(std::move(Payload), | 847 | 0 | std::forward<HandlerTs>(Handlers)...); | 848 | 2.56k | } |
|
849 | | |
850 | | /// Pass the ErrorInfo(s) contained in E to their respective handlers. Any |
851 | | /// unhandled errors (or Errors returned by handlers) are re-concatenated and |
852 | | /// returned. |
853 | | /// Because this function returns an error, its result must also be checked |
854 | | /// or returned. If you intend to handle all errors use handleAllErrors |
855 | | /// (which returns void, and will abort() on unhandled errors) instead. |
856 | | template <typename... HandlerTs> |
857 | 875k | Error handleErrors(Error E, HandlerTs &&... Hs) { |
858 | 875k | if (!E) |
859 | 848k | return Error::success(); |
860 | 875k | |
861 | 27.0k | std::unique_ptr<ErrorInfoBase> Payload = E.takePayload(); |
862 | 27.0k | |
863 | 27.0k | if (Payload->isA<ErrorList>()27.0k ) { |
864 | 7 | ErrorList &List = static_cast<ErrorList &>(*Payload); |
865 | 7 | Error R; |
866 | 7 | for (auto &P : List.Payloads) |
867 | 14 | R = ErrorList::join( |
868 | 14 | std::move(R), |
869 | 14 | handleErrorImpl(std::move(P), std::forward<HandlerTs>(Hs)...)); |
870 | 7 | return R; |
871 | 7 | } |
872 | 27.0k | |
873 | 27.0k | return handleErrorImpl(std::move(Payload), std::forward<HandlerTs>(Hs)...); |
874 | 875k | } llvm::Error llvm::handleErrors<llvm::toString(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)>(llvm::Error, llvm::toString(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)&&) Line | Count | Source | 857 | 2.56k | Error handleErrors(Error E, HandlerTs &&... Hs) { | 858 | 2.56k | if (!E) | 859 | 6 | return Error::success(); | 860 | 2.56k | | 861 | 2.56k | std::unique_ptr<ErrorInfoBase> Payload = E.takePayload(); | 862 | 2.56k | | 863 | 2.56k | if (Payload->isA<ErrorList>()2.56k ) { | 864 | 2 | ErrorList &List = static_cast<ErrorList &>(*Payload); | 865 | 2 | Error R; | 866 | 2 | for (auto &P : List.Payloads) | 867 | 4 | R = ErrorList::join( | 868 | 4 | std::move(R), | 869 | 4 | handleErrorImpl(std::move(P), std::forward<HandlerTs>(Hs)...)); | 870 | 2 | return R; | 871 | 2 | } | 872 | 2.56k | | 873 | 2.55k | return handleErrorImpl(std::move(Payload), std::forward<HandlerTs>(Hs)...); | 874 | 2.56k | } |
LegacyPassManager.cpp:llvm::Error llvm::handleErrors<llvm::legacy::FunctionPassManager::run(llvm::Function&)::$_0>(llvm::Error, llvm::legacy::FunctionPassManager::run(llvm::Function&)::$_0&&) Line | Count | Source | 857 | 835k | Error handleErrors(Error E, HandlerTs &&... Hs) { | 858 | 835k | if (!E) | 859 | 835k | return Error::success(); | 860 | 835k | | 861 | 0 | std::unique_ptr<ErrorInfoBase> Payload = E.takePayload(); | 862 | 0 |
| 863 | 0 | if (Payload->isA<ErrorList>()0 ) { | 864 | 0 | ErrorList &List = static_cast<ErrorList &>(*Payload); | 865 | 0 | Error R; | 866 | 0 | for (auto &P : List.Payloads) | 867 | 0 | R = ErrorList::join( | 868 | 0 | std::move(R), | 869 | 0 | handleErrorImpl(std::move(P), std::forward<HandlerTs>(Hs)...)); | 870 | 0 | return R; | 871 | 0 | } | 872 | 0 |
| 873 | 0 | return handleErrorImpl(std::move(Payload), std::forward<HandlerTs>(Hs)...); | 874 | 835k | } |
llvm::Error llvm::handleErrors<llvm::InstrProfError::take(llvm::Error)::'lambda'(llvm::InstrProfError const&)>(llvm::Error, llvm::InstrProfError::take(llvm::Error)::'lambda'(llvm::InstrProfError const&)&&) Line | Count | Source | 857 | 334 | Error handleErrors(Error E, HandlerTs &&... Hs) { | 858 | 334 | if (!E) | 859 | 0 | return Error::success(); | 860 | 334 | | 861 | 334 | std::unique_ptr<ErrorInfoBase> Payload = E.takePayload(); | 862 | 334 | | 863 | 334 | if (Payload->isA<ErrorList>()334 ) { | 864 | 0 | ErrorList &List = static_cast<ErrorList &>(*Payload); | 865 | 0 | Error R; | 866 | 0 | for (auto &P : List.Payloads) | 867 | 0 | R = ErrorList::join( | 868 | 0 | std::move(R), | 869 | 0 | handleErrorImpl(std::move(P), std::forward<HandlerTs>(Hs)...)); | 870 | 0 | return R; | 871 | 0 | } | 872 | 334 | | 873 | 334 | return handleErrorImpl(std::move(Payload), std::forward<HandlerTs>(Hs)...); | 874 | 334 | } |
llvm::Error llvm::handleErrors<llvm::consumeError(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)>(llvm::Error, llvm::consumeError(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)&&) Line | Count | Source | 857 | 34.7k | Error handleErrors(Error E, HandlerTs &&... Hs) { | 858 | 34.7k | if (!E) | 859 | 11.0k | return Error::success(); | 860 | 34.7k | | 861 | 23.7k | std::unique_ptr<ErrorInfoBase> Payload = E.takePayload(); | 862 | 23.7k | | 863 | 23.7k | if (Payload->isA<ErrorList>()23.7k ) { | 864 | 0 | ErrorList &List = static_cast<ErrorList &>(*Payload); | 865 | 0 | Error R; | 866 | 0 | for (auto &P : List.Payloads) | 867 | 0 | R = ErrorList::join( | 868 | 0 | std::move(R), | 869 | 0 | handleErrorImpl(std::move(P), std::forward<HandlerTs>(Hs)...)); | 870 | 0 | return R; | 871 | 0 | } | 872 | 23.7k | | 873 | 23.7k | return handleErrorImpl(std::move(Payload), std::forward<HandlerTs>(Hs)...); | 874 | 34.7k | } |
Unexecuted instantiation: IRReader.cpp:llvm::Error llvm::handleErrors<getLazyIRModule(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, llvm::SMDiagnostic&, llvm::LLVMContext&, bool)::$_1>(llvm::Error, getLazyIRModule(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, llvm::SMDiagnostic&, llvm::LLVMContext&, bool)::$_1&&) Unexecuted instantiation: IRReader.cpp:llvm::Error llvm::handleErrors<llvm::parseIR(llvm::MemoryBufferRef, llvm::SMDiagnostic&, llvm::LLVMContext&)::$_0>(llvm::Error, llvm::parseIR(llvm::MemoryBufferRef, llvm::SMDiagnostic&, llvm::LLVMContext&)::$_0&&) Error.cpp:llvm::Error llvm::handleErrors<llvm::logAllUnhandledErrors(llvm::Error, llvm::raw_ostream&, llvm::Twine)::$_0>(llvm::Error, llvm::logAllUnhandledErrors(llvm::Error, llvm::raw_ostream&, llvm::Twine)::$_0&&) Line | Count | Source | 857 | 394 | Error handleErrors(Error E, HandlerTs &&... Hs) { | 858 | 394 | if (!E) | 859 | 0 | return Error::success(); | 860 | 394 | | 861 | 394 | std::unique_ptr<ErrorInfoBase> Payload = E.takePayload(); | 862 | 394 | | 863 | 394 | if (Payload->isA<ErrorList>()394 ) { | 864 | 5 | ErrorList &List = static_cast<ErrorList &>(*Payload); | 865 | 5 | Error R; | 866 | 5 | for (auto &P : List.Payloads) | 867 | 10 | R = ErrorList::join( | 868 | 10 | std::move(R), | 869 | 10 | handleErrorImpl(std::move(P), std::forward<HandlerTs>(Hs)...)); | 870 | 5 | return R; | 871 | 5 | } | 872 | 394 | | 873 | 389 | return handleErrorImpl(std::move(Payload), std::forward<HandlerTs>(Hs)...); | 874 | 394 | } |
Error.cpp:llvm::Error llvm::handleErrors<llvm::errorToErrorCode(llvm::Error)::$_1>(llvm::Error, llvm::errorToErrorCode(llvm::Error)::$_1&&) Line | Count | Source | 857 | 2.21k | Error handleErrors(Error E, HandlerTs &&... Hs) { | 858 | 2.21k | if (!E) | 859 | 2.18k | return Error::success(); | 860 | 2.21k | | 861 | 21 | std::unique_ptr<ErrorInfoBase> Payload = E.takePayload(); | 862 | 21 | | 863 | 21 | if (Payload->isA<ErrorList>()21 ) { | 864 | 0 | ErrorList &List = static_cast<ErrorList &>(*Payload); | 865 | 0 | Error R; | 866 | 0 | for (auto &P : List.Payloads) | 867 | 0 | R = ErrorList::join( | 868 | 0 | std::move(R), | 869 | 0 | handleErrorImpl(std::move(P), std::forward<HandlerTs>(Hs)...)); | 870 | 0 | return R; | 871 | 0 | } | 872 | 21 | | 873 | 21 | return handleErrorImpl(std::move(Payload), std::forward<HandlerTs>(Hs)...); | 874 | 2.21k | } |
PGOInstrumentation.cpp:llvm::Error llvm::handleErrors<annotateAllFunctions(llvm::Module&, llvm::StringRef, llvm::function_ref<llvm::BranchProbabilityInfo* (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo* (llvm::Function&)>)::$_9>(llvm::Error, annotateAllFunctions(llvm::Module&, llvm::StringRef, llvm::function_ref<llvm::BranchProbabilityInfo* (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo* (llvm::Function&)>)::$_9&&) Line | Count | Source | 857 | 2 | Error handleErrors(Error E, HandlerTs &&... Hs) { | 858 | 2 | if (!E) | 859 | 0 | return Error::success(); | 860 | 2 | | 861 | 2 | std::unique_ptr<ErrorInfoBase> Payload = E.takePayload(); | 862 | 2 | | 863 | 2 | if (Payload->isA<ErrorList>()2 ) { | 864 | 0 | ErrorList &List = static_cast<ErrorList &>(*Payload); | 865 | 0 | Error R; | 866 | 0 | for (auto &P : List.Payloads) | 867 | 0 | R = ErrorList::join( | 868 | 0 | std::move(R), | 869 | 0 | handleErrorImpl(std::move(P), std::forward<HandlerTs>(Hs)...)); | 870 | 0 | return R; | 871 | 0 | } | 872 | 2 | | 873 | 2 | return handleErrorImpl(std::move(Payload), std::forward<HandlerTs>(Hs)...); | 874 | 2 | } |
PGOInstrumentation.cpp:llvm::Error llvm::handleErrors<(anonymous namespace)::PGOUseFunc::readCounters(llvm::IndexedInstrProfReader*)::$_6>(llvm::Error, (anonymous namespace)::PGOUseFunc::readCounters(llvm::IndexedInstrProfReader*)::$_6&&) Line | Count | Source | 857 | 8 | Error handleErrors(Error E, HandlerTs &&... Hs) { | 858 | 8 | if (!E) | 859 | 0 | return Error::success(); | 860 | 8 | | 861 | 8 | std::unique_ptr<ErrorInfoBase> Payload = E.takePayload(); | 862 | 8 | | 863 | 8 | if (Payload->isA<ErrorList>()8 ) { | 864 | 0 | ErrorList &List = static_cast<ErrorList &>(*Payload); | 865 | 0 | Error R; | 866 | 0 | for (auto &P : List.Payloads) | 867 | 0 | R = ErrorList::join( | 868 | 0 | std::move(R), | 869 | 0 | handleErrorImpl(std::move(P), std::forward<HandlerTs>(Hs)...)); | 870 | 0 | return R; | 871 | 0 | } | 872 | 8 | | 873 | 8 | return handleErrorImpl(std::move(Payload), std::forward<HandlerTs>(Hs)...); | 874 | 8 | } |
BitcodeReader.cpp:llvm::Error llvm::handleErrors<llvm::errorToErrorCodeAndEmitErrors(llvm::LLVMContext&, llvm::Error)::$_0>(llvm::Error, llvm::errorToErrorCodeAndEmitErrors(llvm::LLVMContext&, llvm::Error)::$_0&&) Line | Count | Source | 857 | 4 | Error handleErrors(Error E, HandlerTs &&... Hs) { | 858 | 4 | if (!E) | 859 | 0 | return Error::success(); | 860 | 4 | | 861 | 4 | std::unique_ptr<ErrorInfoBase> Payload = E.takePayload(); | 862 | 4 | | 863 | 4 | if (Payload->isA<ErrorList>()4 ) { | 864 | 0 | ErrorList &List = static_cast<ErrorList &>(*Payload); | 865 | 0 | Error R; | 866 | 0 | for (auto &P : List.Payloads) | 867 | 0 | R = ErrorList::join( | 868 | 0 | std::move(R), | 869 | 0 | handleErrorImpl(std::move(P), std::forward<HandlerTs>(Hs)...)); | 870 | 0 | return R; | 871 | 0 | } | 872 | 4 | | 873 | 4 | return handleErrorImpl(std::move(Payload), std::forward<HandlerTs>(Hs)...); | 874 | 4 | } |
|
875 | | |
876 | | /// Behaves the same as handleErrors, except that it requires that all |
877 | | /// errors be handled by the given handlers. If any unhandled error remains |
878 | | /// after the handlers have run, report_fatal_error() will be called. |
879 | | template <typename... HandlerTs> |
880 | 875k | void handleAllErrors(Error E, HandlerTs &&... Handlers) { |
881 | 875k | cantFail(handleErrors(std::move(E), std::forward<HandlerTs>(Handlers)...)); |
882 | 875k | } BitcodeReader.cpp:void llvm::handleAllErrors<llvm::errorToErrorCodeAndEmitErrors(llvm::LLVMContext&, llvm::Error)::$_0>(llvm::Error, llvm::errorToErrorCodeAndEmitErrors(llvm::LLVMContext&, llvm::Error)::$_0&&) Line | Count | Source | 880 | 4 | void handleAllErrors(Error E, HandlerTs &&... Handlers) { | 881 | 4 | cantFail(handleErrors(std::move(E), std::forward<HandlerTs>(Handlers)...)); | 882 | 4 | } |
void llvm::handleAllErrors<llvm::consumeError(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)>(llvm::Error, llvm::consumeError(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)&&) Line | Count | Source | 880 | 34.7k | void handleAllErrors(Error E, HandlerTs &&... Handlers) { | 881 | 34.7k | cantFail(handleErrors(std::move(E), std::forward<HandlerTs>(Handlers)...)); | 882 | 34.7k | } |
void llvm::handleAllErrors<llvm::InstrProfError::take(llvm::Error)::'lambda'(llvm::InstrProfError const&)>(llvm::Error, llvm::InstrProfError::take(llvm::Error)::'lambda'(llvm::InstrProfError const&)&&) Line | Count | Source | 880 | 334 | void handleAllErrors(Error E, HandlerTs &&... Handlers) { | 881 | 334 | cantFail(handleErrors(std::move(E), std::forward<HandlerTs>(Handlers)...)); | 882 | 334 | } |
LegacyPassManager.cpp:void llvm::handleAllErrors<llvm::legacy::FunctionPassManager::run(llvm::Function&)::$_0>(llvm::Error, llvm::legacy::FunctionPassManager::run(llvm::Function&)::$_0&&) Line | Count | Source | 880 | 835k | void handleAllErrors(Error E, HandlerTs &&... Handlers) { | 881 | 835k | cantFail(handleErrors(std::move(E), std::forward<HandlerTs>(Handlers)...)); | 882 | 835k | } |
Unexecuted instantiation: IRReader.cpp:void llvm::handleAllErrors<getLazyIRModule(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, llvm::SMDiagnostic&, llvm::LLVMContext&, bool)::$_1>(llvm::Error, getLazyIRModule(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, llvm::SMDiagnostic&, llvm::LLVMContext&, bool)::$_1&&) Unexecuted instantiation: IRReader.cpp:void llvm::handleAllErrors<llvm::parseIR(llvm::MemoryBufferRef, llvm::SMDiagnostic&, llvm::LLVMContext&)::$_0>(llvm::Error, llvm::parseIR(llvm::MemoryBufferRef, llvm::SMDiagnostic&, llvm::LLVMContext&)::$_0&&) Error.cpp:void llvm::handleAllErrors<llvm::logAllUnhandledErrors(llvm::Error, llvm::raw_ostream&, llvm::Twine)::$_0>(llvm::Error, llvm::logAllUnhandledErrors(llvm::Error, llvm::raw_ostream&, llvm::Twine)::$_0&&) Line | Count | Source | 880 | 394 | void handleAllErrors(Error E, HandlerTs &&... Handlers) { | 881 | 394 | cantFail(handleErrors(std::move(E), std::forward<HandlerTs>(Handlers)...)); | 882 | 394 | } |
Error.cpp:void llvm::handleAllErrors<llvm::errorToErrorCode(llvm::Error)::$_1>(llvm::Error, llvm::errorToErrorCode(llvm::Error)::$_1&&) Line | Count | Source | 880 | 2.21k | void handleAllErrors(Error E, HandlerTs &&... Handlers) { | 881 | 2.21k | cantFail(handleErrors(std::move(E), std::forward<HandlerTs>(Handlers)...)); | 882 | 2.21k | } |
PGOInstrumentation.cpp:void llvm::handleAllErrors<annotateAllFunctions(llvm::Module&, llvm::StringRef, llvm::function_ref<llvm::BranchProbabilityInfo* (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo* (llvm::Function&)>)::$_9>(llvm::Error, annotateAllFunctions(llvm::Module&, llvm::StringRef, llvm::function_ref<llvm::BranchProbabilityInfo* (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo* (llvm::Function&)>)::$_9&&) Line | Count | Source | 880 | 2 | void handleAllErrors(Error E, HandlerTs &&... Handlers) { | 881 | 2 | cantFail(handleErrors(std::move(E), std::forward<HandlerTs>(Handlers)...)); | 882 | 2 | } |
PGOInstrumentation.cpp:void llvm::handleAllErrors<(anonymous namespace)::PGOUseFunc::readCounters(llvm::IndexedInstrProfReader*)::$_6>(llvm::Error, (anonymous namespace)::PGOUseFunc::readCounters(llvm::IndexedInstrProfReader*)::$_6&&) Line | Count | Source | 880 | 8 | void handleAllErrors(Error E, HandlerTs &&... Handlers) { | 881 | 8 | cantFail(handleErrors(std::move(E), std::forward<HandlerTs>(Handlers)...)); | 882 | 8 | } |
void llvm::handleAllErrors<llvm::toString(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)>(llvm::Error, llvm::toString(llvm::Error)::'lambda'(llvm::ErrorInfoBase const&)&&) Line | Count | Source | 880 | 2.56k | void handleAllErrors(Error E, HandlerTs &&... Handlers) { | 881 | 2.56k | cantFail(handleErrors(std::move(E), std::forward<HandlerTs>(Handlers)...)); | 882 | 2.56k | } |
|
883 | | |
884 | | /// Check that E is a non-error, then drop it. |
885 | | /// If E is an error report_fatal_error will be called. |
886 | 0 | inline void handleAllErrors(Error E) { |
887 | 0 | cantFail(std::move(E)); |
888 | 0 | } |
889 | | |
890 | | /// Handle any errors (if present) in an Expected<T>, then try a recovery path. |
891 | | /// |
892 | | /// If the incoming value is a success value it is returned unmodified. If it |
893 | | /// is a failure value then it the contained error is passed to handleErrors. |
894 | | /// If handleErrors is able to handle the error then the RecoveryPath functor |
895 | | /// is called to supply the final result. If handleErrors is not able to |
896 | | /// handle all errors then the unhandled errors are returned. |
897 | | /// |
898 | | /// This utility enables the follow pattern: |
899 | | /// |
900 | | /// @code{.cpp} |
901 | | /// enum FooStrategy { Aggressive, Conservative }; |
902 | | /// Expected<Foo> foo(FooStrategy S); |
903 | | /// |
904 | | /// auto ResultOrErr = |
905 | | /// handleExpected( |
906 | | /// foo(Aggressive), |
907 | | /// []() { return foo(Conservative); }, |
908 | | /// [](AggressiveStrategyError&) { |
909 | | /// // Implicitly conusme this - we'll recover by using a conservative |
910 | | /// // strategy. |
911 | | /// }); |
912 | | /// |
913 | | /// @endcode |
914 | | template <typename T, typename RecoveryFtor, typename... HandlerTs> |
915 | | Expected<T> handleExpected(Expected<T> ValOrErr, RecoveryFtor &&RecoveryPath, |
916 | | HandlerTs &&... Handlers) { |
917 | | if (ValOrErr) |
918 | | return ValOrErr; |
919 | | |
920 | | if (auto Err = handleErrors(ValOrErr.takeError(), |
921 | | std::forward<HandlerTs>(Handlers)...)) |
922 | | return std::move(Err); |
923 | | |
924 | | return RecoveryPath(); |
925 | | } |
926 | | |
927 | | /// Log all errors (if any) in E to OS. If there are any errors, ErrorBanner |
928 | | /// will be printed before the first one is logged. A newline will be printed |
929 | | /// after each error. |
930 | | /// |
931 | | /// This is useful in the base level of your program to allow clean termination |
932 | | /// (allowing clean deallocation of resources, etc.), while reporting error |
933 | | /// information to the user. |
934 | | void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner); |
935 | | |
936 | | /// Write all error messages (if any) in E to a string. The newline character |
937 | | /// is used to separate error messages. |
938 | 2.56k | inline std::string toString(Error E) { |
939 | 2.56k | SmallVector<std::string, 2> Errors; |
940 | 2.56k | handleAllErrors(std::move(E), [&Errors](const ErrorInfoBase &EI) { |
941 | 2.56k | Errors.push_back(EI.message()); |
942 | 2.56k | }); |
943 | 2.56k | return join(Errors.begin(), Errors.end(), "\n"); |
944 | 2.56k | } |
945 | | |
946 | | /// Consume a Error without doing anything. This method should be used |
947 | | /// only where an error can be considered a reasonable and expected return |
948 | | /// value. |
949 | | /// |
950 | | /// Uses of this method are potentially indicative of design problems: If it's |
951 | | /// legitimate to do nothing while processing an "error", the error-producer |
952 | | /// might be more clearly refactored to return an Optional<T>. |
953 | 34.7k | inline void consumeError(Error Err) { |
954 | 23.7k | handleAllErrors(std::move(Err), [](const ErrorInfoBase &) {}); |
955 | 34.7k | } |
956 | | |
957 | | /// Helper for Errors used as out-parameters. |
958 | | /// |
959 | | /// This helper is for use with the Error-as-out-parameter idiom, where an error |
960 | | /// is passed to a function or method by reference, rather than being returned. |
961 | | /// In such cases it is helpful to set the checked bit on entry to the function |
962 | | /// so that the error can be written to (unchecked Errors abort on assignment) |
963 | | /// and clear the checked bit on exit so that clients cannot accidentally forget |
964 | | /// to check the result. This helper performs these actions automatically using |
965 | | /// RAII: |
966 | | /// |
967 | | /// @code{.cpp} |
968 | | /// Result foo(Error &Err) { |
969 | | /// ErrorAsOutParameter ErrAsOutParam(&Err); // 'Checked' flag set |
970 | | /// // <body of foo> |
971 | | /// // <- 'Checked' flag auto-cleared when ErrAsOutParam is destructed. |
972 | | /// } |
973 | | /// @endcode |
974 | | /// |
975 | | /// ErrorAsOutParameter takes an Error* rather than Error& so that it can be |
976 | | /// used with optional Errors (Error pointers that are allowed to be null). If |
977 | | /// ErrorAsOutParameter took an Error reference, an instance would have to be |
978 | | /// created inside every condition that verified that Error was non-null. By |
979 | | /// taking an Error pointer we can just create one instance at the top of the |
980 | | /// function. |
981 | | class ErrorAsOutParameter { |
982 | | public: |
983 | | ErrorAsOutParameter(Error *Err) : Err(Err) { |
984 | | // Raise the checked bit if Err is success. |
985 | | if (Err) |
986 | | (void)!!*Err; |
987 | | } |
988 | | |
989 | | ~ErrorAsOutParameter() { |
990 | | // Clear the checked bit. |
991 | | if (Err && !*Err) |
992 | | *Err = Error::success(); |
993 | | } |
994 | | |
995 | | private: |
996 | | Error *Err; |
997 | | }; |
998 | | |
999 | | /// Helper for Expected<T>s used as out-parameters. |
1000 | | /// |
1001 | | /// See ErrorAsOutParameter. |
1002 | | template <typename T> |
1003 | | class ExpectedAsOutParameter { |
1004 | | public: |
1005 | | ExpectedAsOutParameter(Expected<T> *ValOrErr) |
1006 | | : ValOrErr(ValOrErr) { |
1007 | | if (ValOrErr) |
1008 | | (void)!!*ValOrErr; |
1009 | | } |
1010 | | |
1011 | | ~ExpectedAsOutParameter() { |
1012 | | if (ValOrErr) |
1013 | | ValOrErr->setUnchecked(); |
1014 | | } |
1015 | | |
1016 | | private: |
1017 | | Expected<T> *ValOrErr; |
1018 | | }; |
1019 | | |
1020 | | /// This class wraps a std::error_code in a Error. |
1021 | | /// |
1022 | | /// This is useful if you're writing an interface that returns a Error |
1023 | | /// (or Expected) and you want to call code that still returns |
1024 | | /// std::error_codes. |
1025 | | class ECError : public ErrorInfo<ECError> { |
1026 | | friend Error errorCodeToError(std::error_code); |
1027 | | |
1028 | | public: |
1029 | 0 | void setErrorCode(std::error_code EC) { this->EC = EC; } |
1030 | 264 | std::error_code convertToErrorCode() const override { return EC; } |
1031 | 44 | void log(raw_ostream &OS) const override { OS << EC.message(); } |
1032 | | |
1033 | | // Used by ErrorInfo::classID. |
1034 | | static char ID; |
1035 | | |
1036 | | protected: |
1037 | | ECError() = default; |
1038 | 380 | ECError(std::error_code EC) : EC(EC) {} |
1039 | | |
1040 | | std::error_code EC; |
1041 | | }; |
1042 | | |
1043 | | /// The value returned by this function can be returned from convertToErrorCode |
1044 | | /// for Error values where no sensible translation to std::error_code exists. |
1045 | | /// It should only be used in this situation, and should never be used where a |
1046 | | /// sensible conversion to std::error_code is available, as attempts to convert |
1047 | | /// to/from this error will result in a fatal error. (i.e. it is a programmatic |
1048 | | ///error to try to convert such a value). |
1049 | | std::error_code inconvertibleErrorCode(); |
1050 | | |
1051 | | /// Helper for converting an std::error_code to a Error. |
1052 | | Error errorCodeToError(std::error_code EC); |
1053 | | |
1054 | | /// Helper for converting an ECError to a std::error_code. |
1055 | | /// |
1056 | | /// This method requires that Err be Error() or an ECError, otherwise it |
1057 | | /// will trigger a call to abort(). |
1058 | | std::error_code errorToErrorCode(Error Err); |
1059 | | |
1060 | | /// Convert an ErrorOr<T> to an Expected<T>. |
1061 | 891 | template <typename T> Expected<T> errorOrToExpected(ErrorOr<T> &&EO) { |
1062 | 891 | if (auto EC = EO.getError()) |
1063 | 4 | return errorCodeToError(EC); |
1064 | 887 | return std::move(*EO); |
1065 | 891 | } |
1066 | | |
1067 | | /// Convert an Expected<T> to an ErrorOr<T>. |
1068 | | template <typename T> ErrorOr<T> expectedToErrorOr(Expected<T> &&E) { |
1069 | | if (auto Err = E.takeError()) |
1070 | | return errorToErrorCode(std::move(Err)); |
1071 | | return std::move(*E); |
1072 | | } |
1073 | | |
1074 | | /// This class wraps a string in an Error. |
1075 | | /// |
1076 | | /// StringError is useful in cases where the client is not expected to be able |
1077 | | /// to consume the specific error message programmatically (for example, if the |
1078 | | /// error message is to be presented to the user). |
1079 | | class StringError : public ErrorInfo<StringError> { |
1080 | | public: |
1081 | | static char ID; |
1082 | | |
1083 | | StringError(const Twine &S, std::error_code EC); |
1084 | | |
1085 | | void log(raw_ostream &OS) const override; |
1086 | | std::error_code convertToErrorCode() const override; |
1087 | | |
1088 | 0 | const std::string &getMessage() const { return Msg; } |
1089 | | |
1090 | | private: |
1091 | | std::string Msg; |
1092 | | std::error_code EC; |
1093 | | }; |
1094 | | |
1095 | | /// Helper for check-and-exit error handling. |
1096 | | /// |
1097 | | /// For tool use only. NOT FOR USE IN LIBRARY CODE. |
1098 | | /// |
1099 | | class ExitOnError { |
1100 | | public: |
1101 | | /// Create an error on exit helper. |
1102 | | ExitOnError(std::string Banner = "", int DefaultErrorExitCode = 1) |
1103 | | : Banner(std::move(Banner)), |
1104 | 4.43k | GetExitCode([=](const Error &) { return DefaultErrorExitCode; }100 ) {}4.43k |
1105 | | |
1106 | | /// Set the banner string for any errors caught by operator(). |
1107 | 0 | void setBanner(std::string Banner) { this->Banner = std::move(Banner); } |
1108 | | |
1109 | | /// Set the exit-code mapper function. |
1110 | 0 | void setExitCodeMapper(std::function<int(const Error &)> GetExitCode) { |
1111 | 0 | this->GetExitCode = std::move(GetExitCode); |
1112 | 0 | } |
1113 | | |
1114 | | /// Check Err. If it's in a failure state log the error(s) and exit. |
1115 | 3.24k | void operator()(Error Err) const { checkError(std::move(Err)); } |
1116 | | |
1117 | | /// Check E. If it's in a success state then return the contained value. If |
1118 | | /// it's in a failure state log the error(s) and exit. |
1119 | 891 | template <typename T> T operator()(Expected<T> &&E) const { |
1120 | 891 | checkError(E.takeError()); |
1121 | 891 | return std::move(*E); |
1122 | 891 | } |
1123 | | |
1124 | | /// Check E. If it's in a success state then return the contained reference. If |
1125 | | /// it's in a failure state log the error(s) and exit. |
1126 | | template <typename T> T& operator()(Expected<T&> &&E) const { |
1127 | | checkError(E.takeError()); |
1128 | | return *E; |
1129 | | } |
1130 | | |
1131 | | private: |
1132 | 6.36k | void checkError(Error Err) const { |
1133 | 6.36k | if (Err6.36k ) { |
1134 | 102 | int ExitCode = GetExitCode(Err); |
1135 | 102 | logAllUnhandledErrors(std::move(Err), errs(), Banner); |
1136 | 102 | exit(ExitCode); |
1137 | 102 | } |
1138 | 6.36k | } |
1139 | | |
1140 | | std::string Banner; |
1141 | | std::function<int(const Error &)> GetExitCode; |
1142 | | }; |
1143 | | |
1144 | | } // end namespace llvm |
1145 | | |
1146 | | #endif // LLVM_SUPPORT_ERROR_H |