[PATCH] D130818: [ADT] Deprecate Optional::hasValue (NFC)

Kazu Hirata via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 29 21:29:20 PDT 2022


kazu created this revision.
kazu added a reviewer: dblaikie.
Herald added a project: All.
kazu requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130818

Files:
  llvm/include/llvm/ADT/Optional.h


Index: llvm/include/llvm/ADT/Optional.h
===================================================================
--- llvm/include/llvm/ADT/Optional.h
+++ llvm/include/llvm/ADT/Optional.h
@@ -92,7 +92,10 @@
   }
 
   constexpr bool has_value() const noexcept { return hasVal; }
-  constexpr bool hasValue() const noexcept { return hasVal; }
+  [[deprecated("Use has_value instead.")]] constexpr bool
+  hasValue() const noexcept {
+    return hasVal;
+  }
 
   T &value() &noexcept {
     assert(hasVal);
@@ -203,7 +206,10 @@
   }
 
   constexpr bool has_value() const noexcept { return hasVal; }
-  constexpr bool hasValue() const noexcept { return hasVal; }
+  [[deprecated("Use has_value instead.")]] constexpr bool
+  hasValue() const noexcept {
+    return hasVal;
+  }
 
   T &value() &noexcept {
     assert(hasVal);
@@ -309,7 +315,9 @@
 
   constexpr explicit operator bool() const { return has_value(); }
   constexpr bool has_value() const { return Storage.has_value(); }
-  constexpr bool hasValue() const { return Storage.has_value(); }
+  [[deprecated("Use has_value instead.")]] 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(); }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130818.448772.patch
Type: text/x-patch
Size: 1331 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220730/4a886e1f/attachment.bin>


More information about the llvm-commits mailing list