[llvm] 80145dc - [ADT] Deprecate Optional::getPointer
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 23 16:50:40 PST 2022
Author: Kazu Hirata
Date: 2022-11-23T16:50:34-08:00
New Revision: 80145dcb011b03a7c54fdfaa3a7beeaf5c18863a
URL: https://github.com/llvm/llvm-project/commit/80145dcb011b03a7c54fdfaa3a7beeaf5c18863a
DIFF: https://github.com/llvm/llvm-project/commit/80145dcb011b03a7c54fdfaa3a7beeaf5c18863a.diff
LOG: [ADT] Deprecate Optional::getPointer
This patch deprecates Optional::getPointer. Note that I've converted
all known occurrences of X.getPointer() to &*X on Nov 21, 2022 in
commit 1f914944b6c9a5e4229ceb9f06140fdf178c5ea0.
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
Differential Revision: https://reviews.llvm.org/D138621
Added:
Modified:
llvm/include/llvm/ADT/Optional.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/Optional.h b/llvm/include/llvm/ADT/Optional.h
index 944a996c8eba..4d0cd4542342 100644
--- a/llvm/include/llvm/ADT/Optional.h
+++ b/llvm/include/llvm/ADT/Optional.h
@@ -274,15 +274,17 @@ template <typename T> class Optional {
void reset() { Storage.reset(); }
+ LLVM_DEPRECATED("Use &*X instead.", "&*X")
constexpr const T *getPointer() const { return &Storage.value(); }
+ LLVM_DEPRECATED("Use &*X instead.", "&*X")
T *getPointer() { return &Storage.value(); }
constexpr const T &value() const & { return Storage.value(); }
T &value() & { return Storage.value(); }
constexpr explicit operator bool() const { return has_value(); }
constexpr bool has_value() const { return Storage.has_value(); }
- constexpr const T *operator->() const { return getPointer(); }
- T *operator->() { return getPointer(); }
+ constexpr const T *operator->() const { return &Storage.value(); }
+ T *operator->() { return &Storage.value(); }
constexpr const T &operator*() const & { return value(); }
T &operator*() & { return value(); }
More information about the llvm-commits
mailing list