/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/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 | | // The LLVM Linker |
4 | | // |
5 | | // This file is distributed under the University of Illinois Open Source |
6 | | // License. See LICENSE.TXT for details. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | /// |
10 | | /// \file |
11 | | /// |
12 | | /// Provides ErrorOr<T> smart pointer. |
13 | | /// |
14 | | //===----------------------------------------------------------------------===// |
15 | | |
16 | | #ifndef LLVM_SUPPORT_ERROROR_H |
17 | | #define LLVM_SUPPORT_ERROROR_H |
18 | | |
19 | | #include "llvm/Support/AlignOf.h" |
20 | | #include <cassert> |
21 | | #include <system_error> |
22 | | #include <type_traits> |
23 | | #include <utility> |
24 | | |
25 | | namespace llvm { |
26 | | |
27 | | /// \brief Stores a reference that can be changed. |
28 | | template <typename T> |
29 | | class ReferenceStorage { |
30 | | T *Storage; |
31 | | |
32 | | public: |
33 | | ReferenceStorage(T &Ref) : Storage(&Ref) {} |
34 | | |
35 | | operator T &() const { return *Storage; } |
36 | | T &get() const { return *Storage; } |
37 | | }; |
38 | | |
39 | | /// \brief Represents either an error or a value T. |
40 | | /// |
41 | | /// ErrorOr<T> is a pointer-like class that represents the result of an |
42 | | /// operation. The result is either an error, or a value of type T. This is |
43 | | /// designed to emulate the usage of returning a pointer where nullptr indicates |
44 | | /// failure. However instead of just knowing that the operation failed, we also |
45 | | /// have an error_code and optional user data that describes why it failed. |
46 | | /// |
47 | | /// It is used like the following. |
48 | | /// \code |
49 | | /// ErrorOr<Buffer> getBuffer(); |
50 | | /// |
51 | | /// auto buffer = getBuffer(); |
52 | | /// if (error_code ec = buffer.getError()) |
53 | | /// return ec; |
54 | | /// buffer->write("adena"); |
55 | | /// \endcode |
56 | | /// |
57 | | /// |
58 | | /// Implicit conversion to bool returns true if there is a usable value. The |
59 | | /// unary * and -> operators provide pointer like access to the value. Accessing |
60 | | /// the value when there is an error has undefined behavior. |
61 | | /// |
62 | | /// When T is a reference type the behavior is slightly different. The reference |
63 | | /// is held in a std::reference_wrapper<std::remove_reference<T>::type>, and |
64 | | /// there is special handling to make operator -> work as if T was not a |
65 | | /// reference. |
66 | | /// |
67 | | /// T cannot be a rvalue reference. |
68 | | template<class T> |
69 | | class ErrorOr { |
70 | | template <class OtherT> friend class ErrorOr; |
71 | | |
72 | | static const bool isRef = std::is_reference<T>::value; |
73 | | |
74 | | using wrap = ReferenceStorage<typename std::remove_reference<T>::type>; |
75 | | |
76 | | public: |
77 | | using storage_type = typename std::conditional<isRef, wrap, T>::type; |
78 | | |
79 | | private: |
80 | | using reference = typename std::remove_reference<T>::type &; |
81 | | using const_reference = const typename std::remove_reference<T>::type &; |
82 | | using pointer = typename std::remove_reference<T>::type *; |
83 | | using const_pointer = const typename std::remove_reference<T>::type *; |
84 | | |
85 | | public: |
86 | | template <class E> |
87 | | ErrorOr(E ErrorCode, |
88 | | typename std::enable_if<std::is_error_code_enum<E>::value || |
89 | | std::is_error_condition_enum<E>::value, |
90 | | void *>::type = nullptr) |
91 | 3.77k | : HasError(true) { |
92 | 3.77k | new (getErrorStorage()) std::error_code(make_error_code(ErrorCode)); |
93 | 3.77k | } llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::ErrorOr<llvm::errc>(llvm::errc, std::__1::enable_if<(std::is_error_code_enum<llvm::errc>::value) || (std::is_error_condition_enum<llvm::errc>::value), void*>::type) Line | Count | Source | 91 | 3.76k | : HasError(true) { | 92 | 3.76k | new (getErrorStorage()) std::error_code(make_error_code(ErrorCode)); | 93 | 3.76k | } |
Unexecuted instantiation: llvm::ErrorOr<llvm::StringRef>::ErrorOr<llvm::sampleprof_error>(llvm::sampleprof_error, std::__1::enable_if<(std::is_error_code_enum<llvm::sampleprof_error>::value) || (std::is_error_condition_enum<llvm::sampleprof_error>::value), void*>::type) llvm::ErrorOr<std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> > >::ErrorOr<llvm::sampleprof_error>(llvm::sampleprof_error, std::__1::enable_if<(std::is_error_code_enum<llvm::sampleprof_error>::value) || (std::is_error_condition_enum<llvm::sampleprof_error>::value), void*>::type) Line | Count | Source | 91 | 3 | : HasError(true) { | 92 | 3 | new (getErrorStorage()) std::error_code(make_error_code(ErrorCode)); | 93 | 3 | } |
Unexecuted instantiation: llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::ErrorOr<llvm::sampleprof_error>(llvm::sampleprof_error, std::__1::enable_if<(std::is_error_code_enum<llvm::sampleprof_error>::value) || (std::is_error_condition_enum<llvm::sampleprof_error>::value), void*>::type) |
94 | | |
95 | 62.0k | ErrorOr(std::error_code EC) : HasError(true) { |
96 | 62.0k | new (getErrorStorage()) std::error_code(EC); |
97 | 62.0k | } Unexecuted instantiation: llvm::ErrorOr<llvm::MD5::MD5Result>::ErrorOr(std::__1::error_code) Unexecuted instantiation: llvm::ErrorOr<llvm::sys::fs::perms>::ErrorOr(std::__1::error_code) Unexecuted instantiation: llvm::ErrorOr<llvm::sys::fs::space_info>::ErrorOr(std::__1::error_code) llvm::ErrorOr<unsigned long long>::ErrorOr(std::__1::error_code) Line | Count | Source | 95 | 777 | ErrorOr(std::error_code EC) : HasError(true) { | 96 | 777 | new (getErrorStorage()) std::error_code(EC); | 97 | 777 | } |
llvm::ErrorOr<llvm::StringMap<unsigned long long, llvm::MallocAllocator> >::ErrorOr(std::__1::error_code) Line | Count | Source | 95 | 5 | ErrorOr(std::error_code EC) : HasError(true) { | 96 | 5 | new (getErrorStorage()) std::error_code(EC); | 97 | 5 | } |
Unexecuted instantiation: llvm::ErrorOr<llvm::StringRef>::ErrorOr(std::__1::error_code) Unexecuted instantiation: llvm::ErrorOr<unsigned int>::ErrorOr(std::__1::error_code) llvm::ErrorOr<std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> > >::ErrorOr(std::__1::error_code) Line | Count | Source | 95 | 2 | ErrorOr(std::error_code EC) : HasError(true) { | 96 | 2 | new (getErrorStorage()) std::error_code(EC); | 97 | 2 | } |
llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::ErrorOr(std::__1::error_code) Line | Count | Source | 95 | 49 | ErrorOr(std::error_code EC) : HasError(true) { | 96 | 49 | new (getErrorStorage()) std::error_code(EC); | 97 | 49 | } |
llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::ErrorOr(std::__1::error_code) Line | Count | Source | 95 | 61.2k | ErrorOr(std::error_code EC) : HasError(true) { | 96 | 61.2k | new (getErrorStorage()) std::error_code(EC); | 97 | 61.2k | } |
|
98 | | |
99 | | template <class OtherT> |
100 | | ErrorOr(OtherT &&Val, |
101 | | typename std::enable_if<std::is_convertible<OtherT, T>::value>::type |
102 | | * = nullptr) |
103 | 1.14M | : HasError(false) { |
104 | 1.14M | new (getStorage()) storage_type(std::forward<OtherT>(Val)); |
105 | 1.14M | } llvm::ErrorOr<llvm::StringRef>::ErrorOr<llvm::StringRef>(llvm::StringRef&&, std::__1::enable_if<std::is_convertible<llvm::StringRef, llvm::StringRef>::value, void>::type*) Line | Count | Source | 103 | 517 | : HasError(false) { | 104 | 517 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 105 | 517 | } |
llvm::ErrorOr<unsigned int>::ErrorOr<unsigned int>(unsigned int&&, std::__1::enable_if<std::is_convertible<unsigned int, unsigned int>::value, void>::type*) Line | Count | Source | 103 | 287 | : HasError(false) { | 104 | 287 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 105 | 287 | } |
llvm::ErrorOr<unsigned long long>::ErrorOr<unsigned long long&>(unsigned long long&&&, std::__1::enable_if<std::is_convertible<unsigned long long&, unsigned long long>::value, void>::type*) Line | Count | Source | 103 | 195 | : HasError(false) { | 104 | 195 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 105 | 195 | } |
llvm::ErrorOr<unsigned long long>::ErrorOr<unsigned long long>(unsigned long long&&, std::__1::enable_if<std::is_convertible<unsigned long long, unsigned long long>::value, void>::type*) Line | Count | Source | 103 | 1.80k | : HasError(false) { | 104 | 1.80k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 105 | 1.80k | } |
llvm::ErrorOr<unsigned long long>::ErrorOr<int>(int&&, std::__1::enable_if<std::is_convertible<int, unsigned long long>::value, void>::type*) Line | Count | Source | 103 | 17 | : HasError(false) { | 104 | 17 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 105 | 17 | } |
llvm::ErrorOr<llvm::sys::fs::space_info>::ErrorOr<llvm::sys::fs::space_info>(llvm::sys::fs::space_info&&, std::__1::enable_if<std::is_convertible<llvm::sys::fs::space_info, llvm::sys::fs::space_info>::value, void>::type*) Line | Count | Source | 103 | 10 | : HasError(false) { | 104 | 10 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 105 | 10 | } |
llvm::ErrorOr<llvm::sys::fs::perms>::ErrorOr<llvm::sys::fs::perms>(llvm::sys::fs::perms&&, std::__1::enable_if<std::is_convertible<llvm::sys::fs::perms, llvm::sys::fs::perms>::value, void>::type*) Line | Count | Source | 103 | 25 | : HasError(false) { | 104 | 25 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 105 | 25 | } |
llvm::ErrorOr<llvm::MD5::MD5Result>::ErrorOr<llvm::MD5::MD5Result>(llvm::MD5::MD5Result&&, std::__1::enable_if<std::is_convertible<llvm::MD5::MD5Result, llvm::MD5::MD5Result>::value, void>::type*) Line | Count | Source | 103 | 1 | : HasError(false) { | 104 | 1 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 105 | 1 | } |
llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::ErrorOr<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 | 103 | 610k | : HasError(false) { | 104 | 610k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 105 | 610k | } |
llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::ErrorOr<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 | 103 | 528k | : HasError(false) { | 104 | 528k | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 105 | 528k | } |
llvm::ErrorOr<llvm::StringRef>::ErrorOr<llvm::StringRef&>(llvm::StringRef&&&, std::__1::enable_if<std::is_convertible<llvm::StringRef&, llvm::StringRef>::value, void>::type*) Line | Count | Source | 103 | 70 | : HasError(false) { | 104 | 70 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 105 | 70 | } |
llvm::ErrorOr<std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> > >::ErrorOr<std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> > >(std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> >&&, std::__1::enable_if<std::is_convertible<std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> >, std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> > >::value, void>::type*) Line | Count | Source | 103 | 105 | : HasError(false) { | 104 | 105 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 105 | 105 | } |
llvm::ErrorOr<llvm::StringMap<unsigned long long, llvm::MallocAllocator> >::ErrorOr<llvm::StringMap<unsigned long long, llvm::MallocAllocator> const&>(llvm::StringMap<unsigned long long, llvm::MallocAllocator> const&&&, std::__1::enable_if<std::is_convertible<llvm::StringMap<unsigned long long, llvm::MallocAllocator> const&, llvm::StringMap<unsigned long long, llvm::MallocAllocator> >::value, void>::type*) Line | Count | Source | 103 | 16 | : HasError(false) { | 104 | 16 | new (getStorage()) storage_type(std::forward<OtherT>(Val)); | 105 | 16 | } |
|
106 | | |
107 | | ErrorOr(const ErrorOr &Other) { |
108 | | copyConstruct(Other); |
109 | | } |
110 | | |
111 | | template <class OtherT> |
112 | | ErrorOr( |
113 | | const ErrorOr<OtherT> &Other, |
114 | | typename std::enable_if<std::is_convertible<OtherT, T>::value>::type * = |
115 | | nullptr) { |
116 | | copyConstruct(Other); |
117 | | } |
118 | | |
119 | | template <class OtherT> |
120 | | explicit ErrorOr( |
121 | | const ErrorOr<OtherT> &Other, |
122 | | typename std::enable_if< |
123 | | !std::is_convertible<OtherT, const T &>::value>::type * = nullptr) { |
124 | | copyConstruct(Other); |
125 | | } |
126 | | |
127 | 51.2k | ErrorOr(ErrorOr &&Other) { |
128 | 51.2k | moveConstruct(std::move(Other)); |
129 | 51.2k | } Unexecuted instantiation: llvm::ErrorOr<llvm::MD5::MD5Result>::ErrorOr(llvm::ErrorOr<llvm::MD5::MD5Result>&&) Unexecuted instantiation: llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::ErrorOr(llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&&) llvm::ErrorOr<unsigned long long>::ErrorOr(llvm::ErrorOr<unsigned long long>&&) Line | Count | Source | 127 | 711 | ErrorOr(ErrorOr &&Other) { | 128 | 711 | moveConstruct(std::move(Other)); | 129 | 711 | } |
llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::ErrorOr(llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >&&) Line | Count | Source | 127 | 50.5k | ErrorOr(ErrorOr &&Other) { | 128 | 50.5k | moveConstruct(std::move(Other)); | 129 | 50.5k | } |
|
130 | | |
131 | | template <class OtherT> |
132 | | ErrorOr( |
133 | | ErrorOr<OtherT> &&Other, |
134 | | typename std::enable_if<std::is_convertible<OtherT, T>::value>::type * = |
135 | | nullptr) { |
136 | | moveConstruct(std::move(Other)); |
137 | | } |
138 | | |
139 | | // This might eventually need SFINAE but it's more complex than is_convertible |
140 | | // & I'm too lazy to write it right now. |
141 | | template <class OtherT> |
142 | | explicit ErrorOr( |
143 | | ErrorOr<OtherT> &&Other, |
144 | | typename std::enable_if<!std::is_convertible<OtherT, T>::value>::type * = |
145 | | nullptr) { |
146 | | moveConstruct(std::move(Other)); |
147 | | } |
148 | | |
149 | | ErrorOr &operator=(const ErrorOr &Other) { |
150 | | copyAssign(Other); |
151 | | return *this; |
152 | | } |
153 | | |
154 | 22.4k | ErrorOr &operator=(ErrorOr &&Other) { |
155 | 22.4k | moveAssign(std::move(Other)); |
156 | 22.4k | return *this; |
157 | 22.4k | } Unexecuted instantiation: llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::operator=(llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&&) llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::operator=(llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >&&) Line | Count | Source | 154 | 22.4k | ErrorOr &operator=(ErrorOr &&Other) { | 155 | 22.4k | moveAssign(std::move(Other)); | 156 | 22.4k | return *this; | 157 | 22.4k | } |
|
158 | | |
159 | 1.37M | ~ErrorOr() { |
160 | 1.37M | if (!HasError) |
161 | 1.29M | getStorage()->~storage_type(); |
162 | 1.37M | } llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::~ErrorOr() Line | Count | Source | 159 | 721k | ~ErrorOr() { | 160 | 721k | if (!HasError) | 161 | 647k | getStorage()->~storage_type(); | 162 | 721k | } |
llvm::ErrorOr<unsigned int>::~ErrorOr() Line | Count | Source | 159 | 287 | ~ErrorOr() { | 160 | 287 | if (!HasError) | 161 | 287 | getStorage()->~storage_type(); | 162 | 287 | } |
llvm::ErrorOr<llvm::StringRef>::~ErrorOr() Line | Count | Source | 159 | 595 | ~ErrorOr() { | 160 | 595 | if (!HasError) | 161 | 587 | getStorage()->~storage_type(); | 162 | 595 | } |
llvm::ErrorOr<llvm::StringMap<unsigned long long, llvm::MallocAllocator> >::~ErrorOr() Line | Count | Source | 159 | 21 | ~ErrorOr() { | 160 | 21 | if (!HasError) | 161 | 16 | getStorage()->~storage_type(); | 162 | 21 | } |
llvm::ErrorOr<unsigned long long>::~ErrorOr() Line | Count | Source | 159 | 3.50k | ~ErrorOr() { | 160 | 3.50k | if (!HasError) | 161 | 2.59k | getStorage()->~storage_type(); | 162 | 3.50k | } |
llvm::ErrorOr<std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> > >::~ErrorOr() Line | Count | Source | 159 | 97 | ~ErrorOr() { | 160 | 97 | if (!HasError) | 161 | 97 | getStorage()->~storage_type(); | 162 | 97 | } |
llvm::ErrorOr<llvm::MD5::MD5Result>::~ErrorOr() Line | Count | Source | 159 | 1 | ~ErrorOr() { | 160 | 1 | if (!HasError) | 161 | 1 | getStorage()->~storage_type(); | 162 | 1 | } |
llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::~ErrorOr() Line | Count | Source | 159 | 649k | ~ErrorOr() { | 160 | 649k | if (!HasError) | 161 | 645k | getStorage()->~storage_type(); | 162 | 649k | } |
|
163 | | |
164 | | /// \brief Return false if there is an error. |
165 | 1.27M | explicit operator bool() const { |
166 | 1.27M | return !HasError; |
167 | 1.27M | } llvm::ErrorOr<unsigned long long>::operator bool() const Line | Count | Source | 165 | 2.27k | explicit operator bool() const { | 166 | 2.27k | return !HasError; | 167 | 2.27k | } |
llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::operator bool() const Line | Count | Source | 165 | 628k | explicit operator bool() const { | 166 | 628k | return !HasError; | 167 | 628k | } |
llvm::ErrorOr<llvm::StringMap<unsigned long long, llvm::MallocAllocator> >::operator bool() const Line | Count | Source | 165 | 21 | explicit operator bool() const { | 166 | 21 | return !HasError; | 167 | 21 | } |
llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::operator bool() const Line | Count | Source | 165 | 646k | explicit operator bool() const { | 166 | 646k | return !HasError; | 167 | 646k | } |
|
168 | | |
169 | 163k | reference get() { return *getStorage(); } llvm::ErrorOr<std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> > >::get() Line | Count | Source | 169 | 105 | reference get() { return *getStorage(); } |
llvm::ErrorOr<unsigned long long>::get() Line | Count | Source | 169 | 1.36k | reference get() { return *getStorage(); } |
llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::get() Line | Count | Source | 169 | 36.8k | reference get() { return *getStorage(); } |
llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::get() Line | Count | Source | 169 | 124k | reference get() { return *getStorage(); } |
llvm::ErrorOr<llvm::StringMap<unsigned long long, llvm::MallocAllocator> >::get() Line | Count | Source | 169 | 28 | reference get() { return *getStorage(); } |
|
170 | 592 | const_reference get() const { return const_cast<ErrorOr<T> *>(this)->get(); } |
171 | | |
172 | 60.8k | std::error_code getError() const { |
173 | 60.8k | return HasError ? *getErrorStorage()13.8k : std::error_code()47.0k ; |
174 | 60.8k | } llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::getError() const Line | Count | Source | 172 | 1 | std::error_code getError() const { | 173 | 1 | return HasError ? *getErrorStorage()0 : std::error_code()1 ; | 174 | 1 | } |
llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::getError() const Line | Count | Source | 172 | 58.9k | std::error_code getError() const { | 173 | 58.9k | return HasError ? *getErrorStorage()13.6k : std::error_code()45.3k ; | 174 | 58.9k | } |
llvm::ErrorOr<llvm::MD5::MD5Result>::getError() const Line | Count | Source | 172 | 1 | std::error_code getError() const { | 173 | 1 | return HasError ? *getErrorStorage()0 : std::error_code()1 ; | 174 | 1 | } |
Unexecuted instantiation: llvm::ErrorOr<llvm::sys::fs::perms>::getError() const Unexecuted instantiation: llvm::ErrorOr<llvm::sys::fs::space_info>::getError() const llvm::ErrorOr<std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> > >::getError() const Line | Count | Source | 172 | 110 | std::error_code getError() const { | 173 | 110 | return HasError ? *getErrorStorage()5 : std::error_code()105 ; | 174 | 110 | } |
llvm::ErrorOr<unsigned long long>::getError() const Line | Count | Source | 172 | 1.36k | std::error_code getError() const { | 173 | 1.36k | return HasError ? *getErrorStorage()136 : std::error_code()1.22k ; | 174 | 1.36k | } |
Unexecuted instantiation: llvm::ErrorOr<llvm::StringMap<unsigned long long, llvm::MallocAllocator> >::getError() const llvm::ErrorOr<unsigned int>::getError() const Line | Count | Source | 172 | 287 | std::error_code getError() const { | 173 | 287 | return HasError ? *getErrorStorage()0 : std::error_code()287 ; | 174 | 287 | } |
llvm::ErrorOr<llvm::StringRef>::getError() const Line | Count | Source | 172 | 117 | std::error_code getError() const { | 173 | 117 | return HasError ? *getErrorStorage()0 : std::error_code()117 ; | 174 | 117 | } |
|
175 | | |
176 | | pointer operator ->() { |
177 | | return toPointer(getStorage()); |
178 | | } |
179 | | |
180 | | const_pointer operator->() const { return toPointer(getStorage()); } |
181 | | |
182 | 546k | reference operator *() { |
183 | 546k | return *getStorage(); |
184 | 546k | } llvm::ErrorOr<unsigned int>::operator*() Line | Count | Source | 182 | 551 | reference operator *() { | 183 | 551 | return *getStorage(); | 184 | 551 | } |
llvm::ErrorOr<llvm::StringRef>::operator*() Line | Count | Source | 182 | 662 | reference operator *() { | 183 | 662 | return *getStorage(); | 184 | 662 | } |
llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::operator*() Line | Count | Source | 182 | 23.4k | reference operator *() { | 183 | 23.4k | return *getStorage(); | 184 | 23.4k | } |
llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::operator*() Line | Count | Source | 182 | 520k | reference operator *() { | 183 | 520k | return *getStorage(); | 184 | 520k | } |
llvm::ErrorOr<unsigned long long>::operator*() Line | Count | Source | 182 | 1.77k | reference operator *() { | 183 | 1.77k | return *getStorage(); | 184 | 1.77k | } |
|
185 | | |
186 | | const_reference operator*() const { return *getStorage(); } |
187 | | |
188 | | private: |
189 | | template <class OtherT> |
190 | | void copyConstruct(const ErrorOr<OtherT> &Other) { |
191 | | if (!Other.HasError) { |
192 | | // Get the other value. |
193 | | HasError = false; |
194 | | new (getStorage()) storage_type(*Other.getStorage()); |
195 | | } else { |
196 | | // Get other's error. |
197 | | HasError = true; |
198 | | new (getErrorStorage()) std::error_code(Other.getError()); |
199 | | } |
200 | | } |
201 | | |
202 | | template <class T1> |
203 | 22.4k | static bool compareThisIfSameType(const T1 &a, const T1 &b) { |
204 | 22.4k | return &a == &b; |
205 | 22.4k | } bool llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::compareThisIfSameType<llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > > >(llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > > const&, llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > > const&) Line | Count | Source | 203 | 22.4k | static bool compareThisIfSameType(const T1 &a, const T1 &b) { | 204 | 22.4k | return &a == &b; | 205 | 22.4k | } |
Unexecuted instantiation: bool llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::compareThisIfSameType<llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >(llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > const&, llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > const&) |
206 | | |
207 | | template <class T1, class T2> |
208 | | static bool compareThisIfSameType(const T1 &a, const T2 &b) { |
209 | | return false; |
210 | | } |
211 | | |
212 | | template <class OtherT> |
213 | | void copyAssign(const ErrorOr<OtherT> &Other) { |
214 | | if (compareThisIfSameType(*this, Other)) |
215 | | return; |
216 | | |
217 | | this->~ErrorOr(); |
218 | | new (this) ErrorOr(Other); |
219 | | } |
220 | | |
221 | | template <class OtherT> |
222 | 51.2k | void moveConstruct(ErrorOr<OtherT> &&Other) { |
223 | 51.2k | if (!Other.HasError51.2k ) { |
224 | 37.9k | // Get the other value. |
225 | 37.9k | HasError = false; |
226 | 37.9k | new (getStorage()) storage_type(std::move(*Other.getStorage())); |
227 | 51.2k | } else { |
228 | 13.2k | // Get other's error. |
229 | 13.2k | HasError = true; |
230 | 13.2k | new (getErrorStorage()) std::error_code(Other.getError()); |
231 | 13.2k | } |
232 | 51.2k | } Unexecuted instantiation: void llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::moveConstruct<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&&) void llvm::ErrorOr<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::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >&&) Line | Count | Source | 222 | 50.5k | void moveConstruct(ErrorOr<OtherT> &&Other) { | 223 | 50.5k | if (!Other.HasError50.5k ) { | 224 | 37.4k | // Get the other value. | 225 | 37.4k | HasError = false; | 226 | 37.4k | new (getStorage()) storage_type(std::move(*Other.getStorage())); | 227 | 50.5k | } else { | 228 | 13.0k | // Get other's error. | 229 | 13.0k | HasError = true; | 230 | 13.0k | new (getErrorStorage()) std::error_code(Other.getError()); | 231 | 13.0k | } | 232 | 50.5k | } |
Unexecuted instantiation: void llvm::ErrorOr<llvm::MD5::MD5Result>::moveConstruct<llvm::MD5::MD5Result>(llvm::ErrorOr<llvm::MD5::MD5Result>&&) Unexecuted instantiation: void llvm::ErrorOr<llvm::StringMap<unsigned long long, llvm::MallocAllocator> >::moveConstruct<llvm::StringMap<unsigned long long, llvm::MallocAllocator> >(llvm::ErrorOr<llvm::StringMap<unsigned long long, llvm::MallocAllocator> >&&) Unexecuted instantiation: void llvm::ErrorOr<llvm::StringRef>::moveConstruct<llvm::StringRef>(llvm::ErrorOr<llvm::StringRef>&&) Unexecuted instantiation: void llvm::ErrorOr<llvm::sys::fs::space_info>::moveConstruct<llvm::sys::fs::space_info>(llvm::ErrorOr<llvm::sys::fs::space_info>&&) Unexecuted instantiation: void llvm::ErrorOr<llvm::sys::fs::perms>::moveConstruct<llvm::sys::fs::perms>(llvm::ErrorOr<llvm::sys::fs::perms>&&) void llvm::ErrorOr<unsigned long long>::moveConstruct<unsigned long long>(llvm::ErrorOr<unsigned long long>&&) Line | Count | Source | 222 | 711 | void moveConstruct(ErrorOr<OtherT> &&Other) { | 223 | 711 | if (!Other.HasError711 ) { | 224 | 575 | // Get the other value. | 225 | 575 | HasError = false; | 226 | 575 | new (getStorage()) storage_type(std::move(*Other.getStorage())); | 227 | 711 | } else { | 228 | 136 | // Get other's error. | 229 | 136 | HasError = true; | 230 | 136 | new (getErrorStorage()) std::error_code(Other.getError()); | 231 | 136 | } | 232 | 711 | } |
Unexecuted instantiation: void llvm::ErrorOr<std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> > >::moveConstruct<std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> > >(llvm::ErrorOr<std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> > >&&) Unexecuted instantiation: void llvm::ErrorOr<unsigned int>::moveConstruct<unsigned int>(llvm::ErrorOr<unsigned int>&&) |
233 | | |
234 | | template <class OtherT> |
235 | 22.4k | void moveAssign(ErrorOr<OtherT> &&Other) { |
236 | 22.4k | if (compareThisIfSameType(*this, Other)) |
237 | 0 | return; |
238 | 22.4k | |
239 | 22.4k | this->~ErrorOr(); |
240 | 22.4k | new (this) ErrorOr(std::move(Other)); |
241 | 22.4k | } Unexecuted instantiation: void llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::moveAssign<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&&) void llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::moveAssign<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >(llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >&&) Line | Count | Source | 235 | 22.4k | void moveAssign(ErrorOr<OtherT> &&Other) { | 236 | 22.4k | if (compareThisIfSameType(*this, Other)) | 237 | 0 | return; | 238 | 22.4k | | 239 | 22.4k | this->~ErrorOr(); | 240 | 22.4k | new (this) ErrorOr(std::move(Other)); | 241 | 22.4k | } |
|
242 | | |
243 | | pointer toPointer(pointer Val) { |
244 | | return Val; |
245 | | } |
246 | | |
247 | | const_pointer toPointer(const_pointer Val) const { return Val; } |
248 | | |
249 | | pointer toPointer(wrap *Val) { |
250 | | return &Val->get(); |
251 | | } |
252 | | |
253 | | const_pointer toPointer(const wrap *Val) const { return &Val->get(); } |
254 | | |
255 | 3.89M | storage_type *getStorage() { |
256 | 3.89M | assert(!HasError && "Cannot get value when an error exists!"); |
257 | 3.89M | return reinterpret_cast<storage_type*>(TStorage.buffer); |
258 | 3.89M | } llvm::ErrorOr<llvm::sys::fs::perms>::getStorage() Line | Count | Source | 255 | 75 | storage_type *getStorage() { | 256 | 75 | assert(!HasError && "Cannot get value when an error exists!"); | 257 | 75 | return reinterpret_cast<storage_type*>(TStorage.buffer); | 258 | 75 | } |
llvm::ErrorOr<llvm::sys::fs::space_info>::getStorage() Line | Count | Source | 255 | 30 | storage_type *getStorage() { | 256 | 30 | assert(!HasError && "Cannot get value when an error exists!"); | 257 | 30 | return reinterpret_cast<storage_type*>(TStorage.buffer); | 258 | 30 | } |
llvm::ErrorOr<std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> > >::getStorage() Line | Count | Source | 255 | 307 | storage_type *getStorage() { | 256 | 307 | assert(!HasError && "Cannot get value when an error exists!"); | 257 | 307 | return reinterpret_cast<storage_type*>(TStorage.buffer); | 258 | 307 | } |
llvm::ErrorOr<unsigned long long>::getStorage() Line | Count | Source | 255 | 8.89k | storage_type *getStorage() { | 256 | 8.89k | assert(!HasError && "Cannot get value when an error exists!"); | 257 | 8.89k | return reinterpret_cast<storage_type*>(TStorage.buffer); | 258 | 8.89k | } |
llvm::ErrorOr<llvm::StringMap<unsigned long long, llvm::MallocAllocator> >::getStorage() Line | Count | Source | 255 | 60 | storage_type *getStorage() { | 256 | 60 | assert(!HasError && "Cannot get value when an error exists!"); | 257 | 60 | return reinterpret_cast<storage_type*>(TStorage.buffer); | 258 | 60 | } |
llvm::ErrorOr<llvm::StringRef>::getStorage() Line | Count | Source | 255 | 1.83k | storage_type *getStorage() { | 256 | 1.83k | assert(!HasError && "Cannot get value when an error exists!"); | 257 | 1.83k | return reinterpret_cast<storage_type*>(TStorage.buffer); | 258 | 1.83k | } |
llvm::ErrorOr<unsigned int>::getStorage() Line | Count | Source | 255 | 1.12k | storage_type *getStorage() { | 256 | 1.12k | assert(!HasError && "Cannot get value when an error exists!"); | 257 | 1.12k | return reinterpret_cast<storage_type*>(TStorage.buffer); | 258 | 1.12k | } |
llvm::ErrorOr<llvm::MD5::MD5Result>::getStorage() Line | Count | Source | 255 | 3 | storage_type *getStorage() { | 256 | 3 | assert(!HasError && "Cannot get value when an error exists!"); | 257 | 3 | return reinterpret_cast<storage_type*>(TStorage.buffer); | 258 | 3 | } |
llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::getStorage() Line | Count | Source | 255 | 1.93M | storage_type *getStorage() { | 256 | 1.93M | assert(!HasError && "Cannot get value when an error exists!"); | 257 | 1.93M | return reinterpret_cast<storage_type*>(TStorage.buffer); | 258 | 1.93M | } |
llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::getStorage() Line | Count | Source | 255 | 1.94M | storage_type *getStorage() { | 256 | 1.94M | assert(!HasError && "Cannot get value when an error exists!"); | 257 | 1.94M | return reinterpret_cast<storage_type*>(TStorage.buffer); | 258 | 1.94M | } |
|
259 | | |
260 | | const storage_type *getStorage() const { |
261 | | assert(!HasError && "Cannot get value when an error exists!"); |
262 | | return reinterpret_cast<const storage_type*>(TStorage.buffer); |
263 | | } |
264 | | |
265 | 92.8k | std::error_code *getErrorStorage() { |
266 | 92.8k | assert(HasError && "Cannot get error when a value exists!"); |
267 | 92.8k | return reinterpret_cast<std::error_code *>(ErrorStorage.buffer); |
268 | 92.8k | } llvm::ErrorOr<std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> > >::getErrorStorage() Line | Count | Source | 265 | 10 | std::error_code *getErrorStorage() { | 266 | 10 | assert(HasError && "Cannot get error when a value exists!"); | 267 | 10 | return reinterpret_cast<std::error_code *>(ErrorStorage.buffer); | 268 | 10 | } |
llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::getErrorStorage() Line | Count | Source | 265 | 3.81k | std::error_code *getErrorStorage() { | 266 | 3.81k | assert(HasError && "Cannot get error when a value exists!"); | 267 | 3.81k | return reinterpret_cast<std::error_code *>(ErrorStorage.buffer); | 268 | 3.81k | } |
llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::getErrorStorage() Line | Count | Source | 265 | 87.9k | std::error_code *getErrorStorage() { | 266 | 87.9k | assert(HasError && "Cannot get error when a value exists!"); | 267 | 87.9k | return reinterpret_cast<std::error_code *>(ErrorStorage.buffer); | 268 | 87.9k | } |
Unexecuted instantiation: llvm::ErrorOr<llvm::MD5::MD5Result>::getErrorStorage() Unexecuted instantiation: llvm::ErrorOr<llvm::sys::fs::perms>::getErrorStorage() Unexecuted instantiation: llvm::ErrorOr<llvm::sys::fs::space_info>::getErrorStorage() Unexecuted instantiation: llvm::ErrorOr<unsigned int>::getErrorStorage() llvm::ErrorOr<llvm::StringRef>::getErrorStorage() Line | Count | Source | 265 | 8 | std::error_code *getErrorStorage() { | 266 | 8 | assert(HasError && "Cannot get error when a value exists!"); | 267 | 8 | return reinterpret_cast<std::error_code *>(ErrorStorage.buffer); | 268 | 8 | } |
llvm::ErrorOr<llvm::StringMap<unsigned long long, llvm::MallocAllocator> >::getErrorStorage() Line | Count | Source | 265 | 5 | std::error_code *getErrorStorage() { | 266 | 5 | assert(HasError && "Cannot get error when a value exists!"); | 267 | 5 | return reinterpret_cast<std::error_code *>(ErrorStorage.buffer); | 268 | 5 | } |
llvm::ErrorOr<unsigned long long>::getErrorStorage() Line | Count | Source | 265 | 1.04k | std::error_code *getErrorStorage() { | 266 | 1.04k | assert(HasError && "Cannot get error when a value exists!"); | 267 | 1.04k | return reinterpret_cast<std::error_code *>(ErrorStorage.buffer); | 268 | 1.04k | } |
|
269 | | |
270 | 13.8k | const std::error_code *getErrorStorage() const { |
271 | 13.8k | return const_cast<ErrorOr<T> *>(this)->getErrorStorage(); |
272 | 13.8k | } Unexecuted instantiation: llvm::ErrorOr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::getErrorStorage() const llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > >::getErrorStorage() const Line | Count | Source | 270 | 13.6k | const std::error_code *getErrorStorage() const { | 271 | 13.6k | return const_cast<ErrorOr<T> *>(this)->getErrorStorage(); | 272 | 13.6k | } |
Unexecuted instantiation: llvm::ErrorOr<llvm::MD5::MD5Result>::getErrorStorage() const Unexecuted instantiation: llvm::ErrorOr<llvm::sys::fs::perms>::getErrorStorage() const Unexecuted instantiation: llvm::ErrorOr<llvm::sys::fs::space_info>::getErrorStorage() const llvm::ErrorOr<std::__1::unique_ptr<llvm::sampleprof::SampleProfileReader, std::__1::default_delete<llvm::sampleprof::SampleProfileReader> > >::getErrorStorage() const Line | Count | Source | 270 | 5 | const std::error_code *getErrorStorage() const { | 271 | 5 | return const_cast<ErrorOr<T> *>(this)->getErrorStorage(); | 272 | 5 | } |
llvm::ErrorOr<unsigned long long>::getErrorStorage() const Line | Count | Source | 270 | 136 | const std::error_code *getErrorStorage() const { | 271 | 136 | return const_cast<ErrorOr<T> *>(this)->getErrorStorage(); | 272 | 136 | } |
Unexecuted instantiation: llvm::ErrorOr<llvm::StringMap<unsigned long long, llvm::MallocAllocator> >::getErrorStorage() const Unexecuted instantiation: llvm::ErrorOr<unsigned int>::getErrorStorage() const Unexecuted instantiation: llvm::ErrorOr<llvm::StringRef>::getErrorStorage() const |
273 | | |
274 | | union { |
275 | | AlignedCharArrayUnion<storage_type> TStorage; |
276 | | AlignedCharArrayUnion<std::error_code> ErrorStorage; |
277 | | }; |
278 | | bool HasError : 1; |
279 | | }; |
280 | | |
281 | | template <class T, class E> |
282 | | typename std::enable_if<std::is_error_code_enum<E>::value || |
283 | | std::is_error_condition_enum<E>::value, |
284 | | bool>::type |
285 | | operator==(const ErrorOr<T> &Err, E Code) { |
286 | | return Err.getError() == Code; |
287 | | } |
288 | | |
289 | | } // end namespace llvm |
290 | | |
291 | | #endif // LLVM_SUPPORT_ERROROR_H |