/home/arjun/llvm-project/llvm/include/llvm/Support/ErrorOr.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===- llvm/Support/ErrorOr.h - Error Smart Pointer -------------*- C++ -*-===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | /// |
9 | | /// \file |
10 | | /// |
11 | | /// Provides ErrorOr<T> smart pointer. |
12 | | /// |
13 | | //===----------------------------------------------------------------------===// |
14 | | |
15 | | #ifndef LLVM_SUPPORT_ERROROR_H |
16 | | #define LLVM_SUPPORT_ERROROR_H |
17 | | |
18 | | #include "llvm/Support/AlignOf.h" |
19 | | #include <cassert> |
20 | | #include <system_error> |
21 | | #include <type_traits> |
22 | | #include <utility> |
23 | | |
24 | | namespace llvm { |
25 | | |
26 | | /// Represents either an error or a value T. |
27 | | /// |
28 | | /// ErrorOr<T> is a pointer-like class that represents the result of an |
29 | | /// operation. The result is either an error, or a value of type T. This is |
30 | | /// designed to emulate the usage of returning a pointer where nullptr indicates |
31 | | /// failure. However instead of just knowing that the operation failed, we also |
32 | | /// have an error_code and optional user data that describes why it failed. |
33 | | /// |
34 | | /// It is used like the following. |
35 | | /// \code |
36 | | /// ErrorOr<Buffer> getBuffer(); |
37 | | /// |
38 | | /// auto buffer = getBuffer(); |
39 | | /// if (error_code ec = buffer.getError()) |
40 | | /// return ec; |
41 | | /// buffer->write("adena"); |
42 | | /// \endcode |
43 | | /// |
44 | | /// |
45 | | /// Implicit conversion to bool returns true if there is a usable value. The |
46 | | /// unary * and -> operators provide pointer like access to the value. Accessing |
47 | | /// the value when there is an error has undefined behavior. |
48 | | /// |
49 | | /// When T is a reference type the behavior is slightly different. The reference |
50 | | /// is held in a std::reference_wrapper<std::remove_reference<T>::type>, and |
51 | | /// there is special handling to make operator -> work as if T was not a |
52 | | /// reference. |
53 | | /// |
54 | | /// T cannot be a rvalue reference. |
55 | | template<class T> |
56 | | class ErrorOr { |
57 | | template <class OtherT> friend class ErrorOr; |
58 | | |
59 | | static constexpr bool isRef = std::is_reference<T>::value; |
60 | | |
61 | | using wrap = std::reference_wrapper<std::remove_reference_t<T>>; |
62 | | |
63 | | public: |
64 | | using storage_type = std::conditional_t<isRef, wrap, T>; |
65 | | |
66 | | private: |
67 | | using reference = std::remove_reference_t<T> &; |
68 | | using const_reference = const std::remove_reference_t<T> &; |
69 | | using pointer = std::remove_reference_t<T> *; |
70 | | using const_pointer = const std::remove_reference_t<T> *; |
71 | | |
72 | | public: |
73 | | template <class E> |
74 | | ErrorOr(E ErrorCode, |
75 | | std::enable_if_t<std::is_error_code_enum<E>::value || |
76 | | std::is_error_condition_enum<E>::value, |
77 | | void *> = nullptr) |
78 | 0 | : HasError(true) { |
79 | 0 | new (getErrorStorage()) std::error_code(make_error_code(ErrorCode)); |
80 | 0 | } Unexecuted instantiation: _ZN4llvm7ErrorOrIPKNS_3vfs6detail12InMemoryNodeEEC2INS_4errcEEET_NSt9enable_ifIXoosr3std18is_error_code_enumIS9_EE5valuesr3std23is_error_condition_enumIS9_EE5valueEPvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEC2INS_4errcEEET_NSt9enable_ifIXoosr3std18is_error_code_enumISA_EE5valuesr3std23is_error_condition_enumISA_EE5valueEPvE4typeE |
81 | | |
82 | 0 | ErrorOr(std::error_code EC) : HasError(true) { |
83 | 0 | new (getErrorStorage()) std::error_code(EC); |
84 | 0 | } Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEC2ESt10error_code Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEEC2ESt10error_code Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3vfs6StatusEEC2ESt10error_code Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_3vfs4FileESt14default_deleteIS3_EEEC2ESt10error_code Unexecuted instantiation: _ZN4llvm7ErrorOrIPNS_3vfs21RedirectingFileSystem5EntryEEC2ESt10error_code Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_20WritableMemoryBufferESt14default_deleteIS2_EEEC2ESt10error_code Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_24WriteThroughMemoryBufferESt14default_deleteIS2_EEEC2ESt10error_code Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3MD59MD5ResultEEC2ESt10error_code Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs5permsEEC2ESt10error_code Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs10space_infoEEC2ESt10error_code Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs17basic_file_statusEEC2ESt10error_code |
85 | | |
86 | | template <class OtherT> |
87 | | ErrorOr(OtherT &&Val, |
88 | | std::enable_if_t<std::is_convertible<OtherT, T>::value> * = nullptr) |
89 | 0 | : HasError(false) { |
90 | 0 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); |
91 | 0 | } Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3vfs6StatusEEC2IRS2_EEOT_PNSt9enable_ifIXsr3std14is_convertibleIS6_S2_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEC2IS6_EEOT_PNSt9enable_ifIXsr3std14is_convertibleIS9_S6_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrIPKNS_3vfs6detail12InMemoryNodeEEC2IPNS2_17InMemoryDirectoryEEEOT_PNSt9enable_ifIXsr3std14is_convertibleISA_S5_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrIPKNS_3vfs6detail12InMemoryNodeEEC2IPNS2_12InMemoryFileEEEOT_PNSt9enable_ifIXsr3std14is_convertibleISA_S5_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrIPKNS_3vfs6detail12InMemoryNodeEEC2IPKNS2_12InMemoryFileEEEOT_PNSt9enable_ifIXsr3std14is_convertibleISB_S5_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEEC2IS5_EEOT_PNSt9enable_ifIXsr3std14is_convertibleIS8_S5_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEC2IRKS6_EEOT_PNSt9enable_ifIXsr3std14is_convertibleISB_S6_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3vfs6StatusEEC2IS2_EEOT_PNSt9enable_ifIXsr3std14is_convertibleIS5_S2_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_3vfs4FileESt14default_deleteIS3_EEEC2IS6_EEOT_PNSt9enable_ifIXsr3std14is_convertibleIS9_S6_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrIPNS_3vfs21RedirectingFileSystem5EntryEEC2IS4_EEOT_PNSt9enable_ifIXsr3std14is_convertibleIS7_S4_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_20WritableMemoryBufferESt14default_deleteIS2_EEEC2IS5_EEOT_PNSt9enable_ifIXsr3std14is_convertibleIS8_S5_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_24WriteThroughMemoryBufferESt14default_deleteIS2_EEEC2IS5_EEOT_PNSt9enable_ifIXsr3std14is_convertibleIS8_S5_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEEC2IS1_INS_20WritableMemoryBufferES3_IS8_EEEEOT_PNSt9enable_ifIXsr3std14is_convertibleISB_S5_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3MD59MD5ResultEEC2IS2_EEOT_PNSt9enable_ifIXsr3std14is_convertibleIS5_S2_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs5permsEEC2IS3_EEOT_PNSt9enable_ifIXsr3std14is_convertibleIS6_S3_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs10space_infoEEC2IS3_EEOT_PNSt9enable_ifIXsr3std14is_convertibleIS6_S3_EE5valueEvE4typeE Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs17basic_file_statusEEC2INS2_11file_statusEEEOT_PNSt9enable_ifIXsr3std14is_convertibleIS7_S3_EE5valueEvE4typeE |
92 | | |
93 | | ErrorOr(const ErrorOr &Other) { |
94 | | copyConstruct(Other); |
95 | | } |
96 | | |
97 | | template <class OtherT> |
98 | | ErrorOr(const ErrorOr<OtherT> &Other, |
99 | | std::enable_if_t<std::is_convertible<OtherT, T>::value> * = nullptr) { |
100 | | copyConstruct(Other); |
101 | | } |
102 | | |
103 | | template <class OtherT> |
104 | | explicit ErrorOr( |
105 | | const ErrorOr<OtherT> &Other, |
106 | | std::enable_if_t<!std::is_convertible<OtherT, const T &>::value> * = |
107 | | nullptr) { |
108 | | copyConstruct(Other); |
109 | | } |
110 | | |
111 | 0 | ErrorOr(ErrorOr &&Other) { |
112 | 0 | moveConstruct(std::move(Other)); |
113 | 0 | } Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3vfs6StatusEEC2EOS3_ Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_3vfs4FileESt14default_deleteIS3_EEEC2EOS7_ Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEEC2EOS6_ Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_20WritableMemoryBufferESt14default_deleteIS2_EEEC2EOS6_ Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3MD59MD5ResultEEC2EOS3_ Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEC2EOS7_ |
114 | | |
115 | | template <class OtherT> |
116 | | ErrorOr(ErrorOr<OtherT> &&Other, |
117 | 0 | std::enable_if_t<std::is_convertible<OtherT, T>::value> * = nullptr) { |
118 | 0 | moveConstruct(std::move(Other)); |
119 | 0 | } |
120 | | |
121 | | // This might eventually need SFINAE but it's more complex than is_convertible |
122 | | // & I'm too lazy to write it right now. |
123 | | template <class OtherT> |
124 | | explicit ErrorOr( |
125 | | ErrorOr<OtherT> &&Other, |
126 | | std::enable_if_t<!std::is_convertible<OtherT, T>::value> * = nullptr) { |
127 | | moveConstruct(std::move(Other)); |
128 | | } |
129 | | |
130 | | ErrorOr &operator=(const ErrorOr &Other) { |
131 | | copyAssign(Other); |
132 | | return *this; |
133 | | } |
134 | | |
135 | 0 | ErrorOr &operator=(ErrorOr &&Other) { |
136 | 0 | moveAssign(std::move(Other)); |
137 | 0 | return *this; |
138 | 0 | } Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEEaSEOS6_ Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEaSEOS7_ |
139 | | |
140 | 0 | ~ErrorOr() { |
141 | 0 | if (!HasError) |
142 | 0 | getStorage()->~storage_type(); |
143 | 0 | } Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEED2Ev Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3vfs6StatusEED2Ev Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs17basic_file_statusEED2Ev Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEED2Ev Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_3vfs4FileESt14default_deleteIS3_EEED2Ev Unexecuted instantiation: _ZN4llvm7ErrorOrIPKNS_3vfs6detail12InMemoryNodeEED2Ev Unexecuted instantiation: _ZN4llvm7ErrorOrIPNS_3vfs21RedirectingFileSystem5EntryEED2Ev Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_20WritableMemoryBufferESt14default_deleteIS2_EEED2Ev Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3MD59MD5ResultEED2Ev |
144 | | |
145 | | /// Return false if there is an error. |
146 | 0 | explicit operator bool() const { |
147 | 0 | return !HasError; |
148 | 0 | } Unexecuted instantiation: _ZNK4llvm7ErrorOrINS_3sys2fs17basic_file_statusEEcvbEv Unexecuted instantiation: _ZNK4llvm7ErrorOrINS_3vfs6StatusEEcvbEv Unexecuted instantiation: _ZNK4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEEcvbEv Unexecuted instantiation: _ZNK4llvm7ErrorOrISt10unique_ptrINS_3vfs4FileESt14default_deleteIS3_EEEcvbEv Unexecuted instantiation: _ZNK4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEcvbEv Unexecuted instantiation: _ZNK4llvm7ErrorOrIPKNS_3vfs6detail12InMemoryNodeEEcvbEv Unexecuted instantiation: _ZNK4llvm7ErrorOrIPNS_3vfs21RedirectingFileSystem5EntryEEcvbEv Unexecuted instantiation: _ZNK4llvm7ErrorOrISt10unique_ptrINS_20WritableMemoryBufferESt14default_deleteIS2_EEEcvbEv |
149 | | |
150 | 0 | reference get() { return *getStorage(); } Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEE3getEv Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE3getEv |
151 | | const_reference get() const { return const_cast<ErrorOr<T> *>(this)->get(); } |
152 | | |
153 | 0 | std::error_code getError() const { |
154 | 0 | return HasError ? *getErrorStorage() : std::error_code(); |
155 | 0 | } Unexecuted instantiation: _ZNK4llvm7ErrorOrINS_3sys2fs17basic_file_statusEE8getErrorEv Unexecuted instantiation: _ZNK4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE8getErrorEv Unexecuted instantiation: _ZNK4llvm7ErrorOrINS_3vfs6StatusEE8getErrorEv Unexecuted instantiation: _ZNK4llvm7ErrorOrISt10unique_ptrINS_3vfs4FileESt14default_deleteIS3_EEE8getErrorEv Unexecuted instantiation: _ZNK4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEE8getErrorEv Unexecuted instantiation: _ZNK4llvm7ErrorOrIPKNS_3vfs6detail12InMemoryNodeEE8getErrorEv Unexecuted instantiation: _ZNK4llvm7ErrorOrIPNS_3vfs21RedirectingFileSystem5EntryEE8getErrorEv Unexecuted instantiation: _ZNK4llvm7ErrorOrISt10unique_ptrINS_20WritableMemoryBufferESt14default_deleteIS2_EEE8getErrorEv Unexecuted instantiation: _ZNK4llvm7ErrorOrISt10unique_ptrINS_24WriteThroughMemoryBufferESt14default_deleteIS2_EEE8getErrorEv Unexecuted instantiation: _ZNK4llvm7ErrorOrINS_3MD59MD5ResultEE8getErrorEv Unexecuted instantiation: _ZNK4llvm7ErrorOrINS_3sys2fs5permsEE8getErrorEv Unexecuted instantiation: _ZNK4llvm7ErrorOrINS_3sys2fs10space_infoEE8getErrorEv |
156 | | |
157 | 0 | pointer operator ->() { |
158 | 0 | return toPointer(getStorage()); |
159 | 0 | } Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs17basic_file_statusEEptEv Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3vfs6StatusEEptEv Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEptEv |
160 | | |
161 | | const_pointer operator->() const { return toPointer(getStorage()); } |
162 | | |
163 | 0 | reference operator *() { |
164 | 0 | return *getStorage(); |
165 | 0 | } Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3vfs6StatusEEdeEv Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_3vfs4FileESt14default_deleteIS3_EEEdeEv Unexecuted instantiation: _ZN4llvm7ErrorOrIPKNS_3vfs6detail12InMemoryNodeEEdeEv Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEdeEv Unexecuted instantiation: _ZN4llvm7ErrorOrIPNS_3vfs21RedirectingFileSystem5EntryEEdeEv Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_20WritableMemoryBufferESt14default_deleteIS2_EEEdeEv Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEEdeEv Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs17basic_file_statusEEdeEv |
166 | | |
167 | | const_reference operator*() const { return *getStorage(); } |
168 | | |
169 | | private: |
170 | | template <class OtherT> |
171 | | void copyConstruct(const ErrorOr<OtherT> &Other) { |
172 | | if (!Other.HasError) { |
173 | | // Get the other value. |
174 | | HasError = false; |
175 | | new (getStorage()) storage_type(*Other.getStorage()); |
176 | | } else { |
177 | | // Get other's error. |
178 | | HasError = true; |
179 | | new (getErrorStorage()) std::error_code(Other.getError()); |
180 | | } |
181 | | } |
182 | | |
183 | | template <class T1> |
184 | 0 | static bool compareThisIfSameType(const T1 &a, const T1 &b) { |
185 | 0 | return &a == &b; |
186 | 0 | } Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEE21compareThisIfSameTypeIS6_EEbRKT_SA_ Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE21compareThisIfSameTypeIS7_EEbRKT_SB_ |
187 | | |
188 | | template <class T1, class T2> |
189 | | static bool compareThisIfSameType(const T1 &a, const T2 &b) { |
190 | | return false; |
191 | | } |
192 | | |
193 | | template <class OtherT> |
194 | | void copyAssign(const ErrorOr<OtherT> &Other) { |
195 | | if (compareThisIfSameType(*this, Other)) |
196 | | return; |
197 | | |
198 | | this->~ErrorOr(); |
199 | | new (this) ErrorOr(Other); |
200 | | } |
201 | | |
202 | | template <class OtherT> |
203 | 0 | void moveConstruct(ErrorOr<OtherT> &&Other) { |
204 | 0 | if (!Other.HasError) { |
205 | 0 | // Get the other value. |
206 | 0 | HasError = false; |
207 | 0 | new (getStorage()) storage_type(std::move(*Other.getStorage())); |
208 | 0 | } else { |
209 | 0 | // Get other's error. |
210 | 0 | HasError = true; |
211 | 0 | new (getErrorStorage()) std::error_code(Other.getError()); |
212 | 0 | } |
213 | 0 | } Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs17basic_file_statusEE13moveConstructIS3_EEvONS0_IT_EE Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3vfs6StatusEE13moveConstructIS2_EEvONS0_IT_EE Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE13moveConstructIS6_EEvONS0_IT_EE Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_3vfs4FileESt14default_deleteIS3_EEE13moveConstructIS6_EEvONS0_IT_EE Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEE13moveConstructIS5_EEvONS0_IT_EE Unexecuted instantiation: _ZN4llvm7ErrorOrIPKNS_3vfs6detail12InMemoryNodeEE13moveConstructIS5_EEvONS0_IT_EE Unexecuted instantiation: _ZN4llvm7ErrorOrIPNS_3vfs21RedirectingFileSystem5EntryEE13moveConstructIS4_EEvONS0_IT_EE Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_20WritableMemoryBufferESt14default_deleteIS2_EEE13moveConstructIS5_EEvONS0_IT_EE Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEE13moveConstructIS1_INS_20WritableMemoryBufferES3_IS8_EEEEvONS0_IT_EE Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_24WriteThroughMemoryBufferESt14default_deleteIS2_EEE13moveConstructIS5_EEvONS0_IT_EE Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3MD59MD5ResultEE13moveConstructIS2_EEvONS0_IT_EE Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs5permsEE13moveConstructIS3_EEvONS0_IT_EE Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs10space_infoEE13moveConstructIS3_EEvONS0_IT_EE |
214 | | |
215 | | template <class OtherT> |
216 | 0 | void moveAssign(ErrorOr<OtherT> &&Other) { |
217 | 0 | if (compareThisIfSameType(*this, Other)) |
218 | 0 | return; |
219 | 0 | |
220 | 0 | this->~ErrorOr(); |
221 | 0 | new (this) ErrorOr(std::move(Other)); |
222 | 0 | } Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEE10moveAssignIS5_EEvONS0_IT_EE Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE10moveAssignIS6_EEvONS0_IT_EE |
223 | | |
224 | 0 | pointer toPointer(pointer Val) { |
225 | 0 | return Val; |
226 | 0 | } Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs17basic_file_statusEE9toPointerEPS3_ Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3vfs6StatusEE9toPointerEPS2_ Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE9toPointerEPS6_ |
227 | | |
228 | | const_pointer toPointer(const_pointer Val) const { return Val; } |
229 | | |
230 | | pointer toPointer(wrap *Val) { |
231 | | return &Val->get(); |
232 | | } |
233 | | |
234 | | const_pointer toPointer(const wrap *Val) const { return &Val->get(); } |
235 | | |
236 | 0 | storage_type *getStorage() { |
237 | 0 | assert(!HasError && "Cannot get value when an error exists!"); |
238 | 0 | return reinterpret_cast<storage_type*>(TStorage.buffer); |
239 | 0 | } Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs17basic_file_statusEE10getStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3vfs6StatusEE10getStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE10getStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_3vfs4FileESt14default_deleteIS3_EEE10getStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEE10getStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrIPKNS_3vfs6detail12InMemoryNodeEE10getStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrIPNS_3vfs21RedirectingFileSystem5EntryEE10getStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_20WritableMemoryBufferESt14default_deleteIS2_EEE10getStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_24WriteThroughMemoryBufferESt14default_deleteIS2_EEE10getStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3MD59MD5ResultEE10getStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs5permsEE10getStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs10space_infoEE10getStorageEv |
240 | | |
241 | | const storage_type *getStorage() const { |
242 | | assert(!HasError && "Cannot get value when an error exists!"); |
243 | | return reinterpret_cast<const storage_type*>(TStorage.buffer); |
244 | | } |
245 | | |
246 | 0 | std::error_code *getErrorStorage() { |
247 | 0 | assert(HasError && "Cannot get error when a value exists!"); |
248 | 0 | return reinterpret_cast<std::error_code *>(ErrorStorage.buffer); |
249 | 0 | } Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs17basic_file_statusEE15getErrorStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3vfs6StatusEE15getErrorStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE15getErrorStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_3vfs4FileESt14default_deleteIS3_EEE15getErrorStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEE15getErrorStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrIPKNS_3vfs6detail12InMemoryNodeEE15getErrorStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrIPNS_3vfs21RedirectingFileSystem5EntryEE15getErrorStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_20WritableMemoryBufferESt14default_deleteIS2_EEE15getErrorStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrISt10unique_ptrINS_24WriteThroughMemoryBufferESt14default_deleteIS2_EEE15getErrorStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3MD59MD5ResultEE15getErrorStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs5permsEE15getErrorStorageEv Unexecuted instantiation: _ZN4llvm7ErrorOrINS_3sys2fs10space_infoEE15getErrorStorageEv |
250 | | |
251 | 0 | const std::error_code *getErrorStorage() const { |
252 | 0 | return const_cast<ErrorOr<T> *>(this)->getErrorStorage(); |
253 | 0 | } Unexecuted instantiation: _ZNK4llvm7ErrorOrINS_3sys2fs17basic_file_statusEE15getErrorStorageEv Unexecuted instantiation: _ZNK4llvm7ErrorOrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE15getErrorStorageEv Unexecuted instantiation: _ZNK4llvm7ErrorOrINS_3vfs6StatusEE15getErrorStorageEv Unexecuted instantiation: _ZNK4llvm7ErrorOrISt10unique_ptrINS_3vfs4FileESt14default_deleteIS3_EEE15getErrorStorageEv Unexecuted instantiation: _ZNK4llvm7ErrorOrISt10unique_ptrINS_12MemoryBufferESt14default_deleteIS2_EEE15getErrorStorageEv Unexecuted instantiation: _ZNK4llvm7ErrorOrIPKNS_3vfs6detail12InMemoryNodeEE15getErrorStorageEv Unexecuted instantiation: _ZNK4llvm7ErrorOrIPNS_3vfs21RedirectingFileSystem5EntryEE15getErrorStorageEv Unexecuted instantiation: _ZNK4llvm7ErrorOrISt10unique_ptrINS_20WritableMemoryBufferESt14default_deleteIS2_EEE15getErrorStorageEv Unexecuted instantiation: _ZNK4llvm7ErrorOrISt10unique_ptrINS_24WriteThroughMemoryBufferESt14default_deleteIS2_EEE15getErrorStorageEv Unexecuted instantiation: _ZNK4llvm7ErrorOrINS_3MD59MD5ResultEE15getErrorStorageEv Unexecuted instantiation: _ZNK4llvm7ErrorOrINS_3sys2fs5permsEE15getErrorStorageEv Unexecuted instantiation: _ZNK4llvm7ErrorOrINS_3sys2fs10space_infoEE15getErrorStorageEv |
254 | | |
255 | | union { |
256 | | AlignedCharArrayUnion<storage_type> TStorage; |
257 | | AlignedCharArrayUnion<std::error_code> ErrorStorage; |
258 | | }; |
259 | | bool HasError : 1; |
260 | | }; |
261 | | |
262 | | template <class T, class E> |
263 | | std::enable_if_t<std::is_error_code_enum<E>::value || |
264 | | std::is_error_condition_enum<E>::value, |
265 | | bool> |
266 | | operator==(const ErrorOr<T> &Err, E Code) { |
267 | | return Err.getError() == Code; |
268 | | } |
269 | | |
270 | | } // end namespace llvm |
271 | | |
272 | | #endif // LLVM_SUPPORT_ERROROR_H |