[Bitcode] Use std::nullopt_t instead of NoneType (NFC)
authorKazu Hirata <kazu@google.com>
Wed, 14 Dec 2022 08:39:45 +0000 (00:39 -0800)
committerKazu Hirata <kazu@google.com>
Wed, 14 Dec 2022 08:39:45 +0000 (00:39 -0800)
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

llvm/include/llvm/Bitcode/BitcodeConvenience.h

index 2de9124..8ef40fa 100644 (file)
 #include "llvm/Bitstream/BitCodes.h"
 #include "llvm/Bitstream/BitstreamWriter.h"
 #include <cstdint>
+#include <optional>
 
 namespace llvm {
-typedef std::nullopt_t NoneType;
-
 namespace detail {
 /// Convenience base for all kinds of bitcode abbreviation fields.
 ///
@@ -207,7 +206,7 @@ public:
   }
 
   template <typename T, typename... DataTy>
-  static void read(ArrayRef<T> buffer, NoneType, DataTy &&...data) {
+  static void read(ArrayRef<T> buffer, std::nullopt_t, DataTy &&...data) {
     assert(!buffer.empty() && "too few elements in buffer");
     BCRecordCoding<Fields...>::read(buffer.slice(1),
                                     std::forward<DataTy>(data)...);
@@ -239,7 +238,7 @@ public:
     data = ElementTy::convert(buffer.front());
   }
 
-  template <typename T> static void read(ArrayRef<T> buffer, NoneType) {
+  template <typename T> static void read(ArrayRef<T> buffer, std::nullopt_t) {
     assert(buffer.size() == 1 && "record data does not match layout");
     (void)buffer;
   }
@@ -280,7 +279,7 @@ public:
 
   template <typename BufferTy>
   static void emit(llvm::BitstreamWriter &Stream, BufferTy &Buffer,
-                   unsigned code, NoneType) {
+                   unsigned code, std::nullopt_t) {
     Stream.EmitRecordWithAbbrev(code, Buffer);
   }
 
@@ -295,7 +294,7 @@ public:
                  llvm::map_iterator(buffer.end(), T::convert));
   }
 
-  template <typename T> static void read(ArrayRef<T> buffer, NoneType) {
+  template <typename T> static void read(ArrayRef<T> buffer, std::nullopt_t) {
     (void)buffer;
   }