[Mlir-commits] [mlir] 4b6b248 - [ADT] Remove Optional::{has_value, value}, etc (NFC)
Kazu Hirata
llvmlistbot at llvm.org
Wed Nov 23 15:08:48 PST 2022
Author: Kazu Hirata
Date: 2022-11-23T15:08:40-08:00
New Revision: 4b6b248731b81deb471838ff79392993aeb6c621
URL: https://github.com/llvm/llvm-project/commit/4b6b248731b81deb471838ff79392993aeb6c621
DIFF: https://github.com/llvm/llvm-project/commit/4b6b248731b81deb471838ff79392993aeb6c621.diff
LOG: [ADT] Remove Optional::{has_value,value}, etc (NFC)
This patch removes methods that I deprecated on August, 2022 in
commits b5f8d42efe3e246d582d4a1a328fac915e4ce8dc and
eeac9e923283d8535e4175fef35e132e796fa78e.
This is part of an effort to migrate from llvm::Optional to
std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Added:
Modified:
llvm/include/llvm/ADT/Optional.h
mlir/include/mlir/Support/LogicalResult.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/Optional.h b/llvm/include/llvm/ADT/Optional.h
index 6bc17c419ca14..944a996c8eba7 100644
--- a/llvm/include/llvm/ADT/Optional.h
+++ b/llvm/include/llvm/ADT/Optional.h
@@ -277,21 +277,10 @@ template <typename T> class Optional {
constexpr const T *getPointer() const { return &Storage.value(); }
T *getPointer() { return &Storage.value(); }
constexpr const T &value() const & { return Storage.value(); }
- LLVM_DEPRECATED("Use value instead.", "value")
- constexpr const T &getValue() const & {
- return Storage.value();
- }
T &value() & { return Storage.value(); }
- LLVM_DEPRECATED("Use value instead.", "value") T &getValue() & {
- return Storage.value();
- }
constexpr explicit operator bool() const { return has_value(); }
constexpr bool has_value() const { return Storage.has_value(); }
- LLVM_DEPRECATED("Use has_value instead.", "has_value")
- constexpr bool hasValue() const {
- return Storage.has_value();
- }
constexpr const T *operator->() const { return getPointer(); }
T *operator->() { return getPointer(); }
constexpr const T &operator*() const & { return value(); }
@@ -300,11 +289,6 @@ template <typename T> class Optional {
template <typename U> constexpr T value_or(U &&alt) const & {
return has_value() ? value() : std::forward<U>(alt);
}
- template <typename U>
- LLVM_DEPRECATED("Use value_or instead.", "value_or")
- constexpr T getValueOr(U &&alt) const & {
- return has_value() ? value() : std::forward<U>(alt);
- }
/// Apply a function to the value if present; otherwise return None.
template <class Function>
@@ -313,28 +297,13 @@ template <typename T> class Optional {
return F(value());
return None;
}
- template <class Function>
- LLVM_DEPRECATED("Use transform instead.", "transform")
- auto map(const Function &F) const & -> Optional<decltype(F(value()))> {
- if (*this)
- return F(value());
- return None;
- }
T &&value() && { return std::move(Storage.value()); }
- LLVM_DEPRECATED("Use value instead.", "value") T &&getValue() && {
- return std::move(Storage.value());
- }
T &&operator*() && { return std::move(Storage.value()); }
template <typename U> T value_or(U &&alt) && {
return has_value() ? std::move(value()) : std::forward<U>(alt);
}
- template <typename U>
- LLVM_DEPRECATED("Use value_or instead.", "value_or")
- T getValueOr(U &&alt) && {
- return has_value() ? std::move(value()) : std::forward<U>(alt);
- }
/// Apply a function to the value if present; otherwise return None.
template <class Function>
@@ -344,14 +313,6 @@ template <typename T> class Optional {
return F(std::move(*this).value());
return None;
}
- template <class Function>
- LLVM_DEPRECATED("Use transform instead.", "transform")
- auto map(const Function &F)
- && -> Optional<decltype(F(std::move(*this).value()))> {
- if (*this)
- return F(std::move(*this).value());
- return None;
- }
};
template<typename T>
diff --git a/mlir/include/mlir/Support/LogicalResult.h b/mlir/include/mlir/Support/LogicalResult.h
index ddd338946c867..e3163fe431e52 100644
--- a/mlir/include/mlir/Support/LogicalResult.h
+++ b/mlir/include/mlir/Support/LogicalResult.h
@@ -96,7 +96,6 @@ class [[nodiscard]] FailureOr : public Optional<T> {
private:
/// Hide the bool conversion as it easily creates confusion.
using Optional<T>::operator bool;
- using Optional<T>::hasValue;
using Optional<T>::has_value;
};
More information about the Mlir-commits
mailing list