[PATCH] D139775: [ADT] Deprecate Optional<T>::create (NFC)

Kazu Hirata via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 10 12:52:38 PST 2022


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

std::optional<T> does not have an equivalent method.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139775

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
@@ -258,6 +258,8 @@
     Storage.emplace(std::forward<ArgTypes>(Args)...);
   }
 
+  LLVM_DEPRECATED("Use X ? Optional<T>(*X) : std::nullopt instead.",
+                  "X ? Optional<T>(*X) : std::nullopt")
   static constexpr Optional create(const T *y) {
     return y ? Optional(*y) : Optional();
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139775.481877.patch
Type: text/x-patch
Size: 489 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221210/3aebc313/attachment.bin>


More information about the llvm-commits mailing list