Skip to content

Commit 4b6b248

Browse files
[ADT] Remove Optional::{has_value,value}, etc (NFC)
This patch removes methods that I deprecated on August, 2022 in commits b5f8d42 and eeac9e9. 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
1 parent 34bcadc commit 4b6b248

File tree

2 files changed

+0
-40
lines changed

2 files changed

+0
-40
lines changed

llvm/include/llvm/ADT/Optional.h

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -277,21 +277,10 @@ template <typename T> class Optional {
277277
constexpr const T *getPointer() const { return &Storage.value(); }
278278
T *getPointer() { return &Storage.value(); }
279279
constexpr const T &value() const & { return Storage.value(); }
280-
LLVM_DEPRECATED("Use value instead.", "value")
281-
constexpr const T &getValue() const & {
282-
return Storage.value();
283-
}
284280
T &value() & { return Storage.value(); }
285-
LLVM_DEPRECATED("Use value instead.", "value") T &getValue() & {
286-
return Storage.value();
287-
}
288281

289282
constexpr explicit operator bool() const { return has_value(); }
290283
constexpr bool has_value() const { return Storage.has_value(); }
291-
LLVM_DEPRECATED("Use has_value instead.", "has_value")
292-
constexpr bool hasValue() const {
293-
return Storage.has_value();
294-
}
295284
constexpr const T *operator->() const { return getPointer(); }
296285
T *operator->() { return getPointer(); }
297286
constexpr const T &operator*() const & { return value(); }
@@ -300,11 +289,6 @@ template <typename T> class Optional {
300289
template <typename U> constexpr T value_or(U &&alt) const & {
301290
return has_value() ? value() : std::forward<U>(alt);
302291
}
303-
template <typename U>
304-
LLVM_DEPRECATED("Use value_or instead.", "value_or")
305-
constexpr T getValueOr(U &&alt) const & {
306-
return has_value() ? value() : std::forward<U>(alt);
307-
}
308292

309293
/// Apply a function to the value if present; otherwise return None.
310294
template <class Function>
@@ -313,28 +297,13 @@ template <typename T> class Optional {
313297
return F(value());
314298
return None;
315299
}
316-
template <class Function>
317-
LLVM_DEPRECATED("Use transform instead.", "transform")
318-
auto map(const Function &F) const & -> Optional<decltype(F(value()))> {
319-
if (*this)
320-
return F(value());
321-
return None;
322-
}
323300

324301
T &&value() && { return std::move(Storage.value()); }
325-
LLVM_DEPRECATED("Use value instead.", "value") T &&getValue() && {
326-
return std::move(Storage.value());
327-
}
328302
T &&operator*() && { return std::move(Storage.value()); }
329303

330304
template <typename U> T value_or(U &&alt) && {
331305
return has_value() ? std::move(value()) : std::forward<U>(alt);
332306
}
333-
template <typename U>
334-
LLVM_DEPRECATED("Use value_or instead.", "value_or")
335-
T getValueOr(U &&alt) && {
336-
return has_value() ? std::move(value()) : std::forward<U>(alt);
337-
}
338307

339308
/// Apply a function to the value if present; otherwise return None.
340309
template <class Function>
@@ -344,14 +313,6 @@ template <typename T> class Optional {
344313
return F(std::move(*this).value());
345314
return None;
346315
}
347-
template <class Function>
348-
LLVM_DEPRECATED("Use transform instead.", "transform")
349-
auto map(const Function &F)
350-
&& -> Optional<decltype(F(std::move(*this).value()))> {
351-
if (*this)
352-
return F(std::move(*this).value());
353-
return None;
354-
}
355316
};
356317

357318
template<typename T>

mlir/include/mlir/Support/LogicalResult.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ class [[nodiscard]] FailureOr : public Optional<T> {
9696
private:
9797
/// Hide the bool conversion as it easily creates confusion.
9898
using Optional<T>::operator bool;
99-
using Optional<T>::hasValue;
10099
using Optional<T>::has_value;
101100
};
102101

0 commit comments

Comments
 (0)