[llvm] 8a55264 - [Bitcode] Use std::nullopt_t instead of NoneType (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 14 00:39:51 PST 2022


Author: Kazu Hirata
Date: 2022-12-14T00:39:45-08:00
New Revision: 8a55264be311bf54ddef0430c712ad51a80a5f7f

URL: https://github.com/llvm/llvm-project/commit/8a55264be311bf54ddef0430c712ad51a80a5f7f
DIFF: https://github.com/llvm/llvm-project/commit/8a55264be311bf54ddef0430c712ad51a80a5f7f.diff

LOG: [Bitcode] Use std::nullopt_t instead of NoneType (NFC)

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

Added: 
    

Modified: 
    llvm/include/llvm/Bitcode/BitcodeConvenience.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Bitcode/BitcodeConvenience.h b/llvm/include/llvm/Bitcode/BitcodeConvenience.h
index 2de91247187fc..8ef40fa0bb159 100644
--- a/llvm/include/llvm/Bitcode/BitcodeConvenience.h
+++ b/llvm/include/llvm/Bitcode/BitcodeConvenience.h
@@ -33,10 +33,9 @@
 #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 @@ template <typename ElementTy, typename... Fields> class BCRecordCoding {
   }
 
   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 @@ template <typename ElementTy> class BCRecordCoding<ElementTy> {
     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 @@ template <typename ElementTy> class BCRecordCoding<BCArray<ElementTy>> {
 
   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 @@ template <typename ElementTy> class BCRecordCoding<BCArray<ElementTy>> {
                  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;
   }
 


        


More information about the llvm-commits mailing list