diff options
Diffstat (limited to 'llvm/include/llvm/Support/Error.h')
-rw-r--r-- | llvm/include/llvm/Support/Error.h | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h index 44676338808b..9dd1bb7cb96d 100644 --- a/llvm/include/llvm/Support/Error.h +++ b/llvm/include/llvm/Support/Error.h @@ -269,9 +269,13 @@ private: } ErrorInfoBase *getPtr() const { +#if LLVM_ENABLE_ABI_BREAKING_CHECKS return reinterpret_cast<ErrorInfoBase*>( reinterpret_cast<uintptr_t>(Payload) & ~static_cast<uintptr_t>(0x1)); +#else + return Payload; +#endif } void setPtr(ErrorInfoBase *EI) { @@ -294,10 +298,12 @@ private: } void setChecked(bool V) { +#if LLVM_ENABLE_ABI_BREAKING_CHECKS Payload = reinterpret_cast<ErrorInfoBase*>( (reinterpret_cast<uintptr_t>(Payload) & ~static_cast<uintptr_t>(0x1)) | (V ? 0 : 1)); +#endif } std::unique_ptr<ErrorInfoBase> takePayload() { @@ -434,21 +440,21 @@ template <class T> class LLVM_NODISCARD Expected { template <class T1> friend class ExpectedAsOutParameter; template <class OtherT> friend class Expected; - static const bool isRef = std::is_reference<T>::value; + static constexpr bool isRef = std::is_reference<T>::value; - using wrap = std::reference_wrapper<typename std::remove_reference<T>::type>; + using wrap = std::reference_wrapper<std::remove_reference_t<T>>; using error_type = std::unique_ptr<ErrorInfoBase>; public: - using storage_type = typename std::conditional<isRef, wrap, T>::type; + using storage_type = std::conditional_t<isRef, wrap, T>; using value_type = T; private: - using reference = typename std::remove_reference<T>::type &; - using const_reference = const typename std::remove_reference<T>::type &; - using pointer = typename std::remove_reference<T>::type *; - using const_pointer = const typename std::remove_reference<T>::type *; + using reference = std::remove_reference_t<T> &; + using const_reference = const std::remove_reference_t<T> &; + using pointer = std::remove_reference_t<T> *; + using const_pointer = const std::remove_reference_t<T> *; public: /// Create an Expected<T> error value from the given Error. @@ -472,12 +478,12 @@ public: /// must be convertible to T. template <typename OtherT> Expected(OtherT &&Val, - typename std::enable_if<std::is_convertible<OtherT, T>::value>::type - * = nullptr) + std::enable_if_t<std::is_convertible<OtherT, T>::value> * = nullptr) : HasError(false) #if LLVM_ENABLE_ABI_BREAKING_CHECKS // Expected is unchecked upon construction in Debug builds. - , Unchecked(true) + , + Unchecked(true) #endif { new (getStorage()) storage_type(std::forward<OtherT>(Val)); @@ -489,9 +495,9 @@ public: /// Move construct an Expected<T> value from an Expected<OtherT>, where OtherT /// must be convertible to T. template <class OtherT> - Expected(Expected<OtherT> &&Other, - typename std::enable_if<std::is_convertible<OtherT, T>::value>::type - * = nullptr) { + Expected( + Expected<OtherT> &&Other, + std::enable_if_t<std::is_convertible<OtherT, T>::value> * = nullptr) { moveConstruct(std::move(Other)); } @@ -500,8 +506,7 @@ public: template <class OtherT> explicit Expected( Expected<OtherT> &&Other, - typename std::enable_if<!std::is_convertible<OtherT, T>::value>::type * = - nullptr) { + std::enable_if_t<!std::is_convertible<OtherT, T>::value> * = nullptr) { moveConstruct(std::move(Other)); } |