[llvm] abfe65a - [ADT] Define None as std::nullopt (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 22 09:57:28 PST 2022


Author: Kazu Hirata
Date: 2022-11-22T09:57:22-08:00
New Revision: abfe65a12b77f9f0292d3ec70bd9fc3b9c13d905

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

LOG: [ADT] Define None as std::nullopt (NFC)

This patch defines NoneType and None as std::nullopt_t and
std::nullopt, respectively.

This patch effectively makes None and std::nullopt interchangeable, so
we can gradually replace None with std::nullopt all while we continue
to use llvm::Optional.

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/D138468

Added: 
    

Modified: 
    llvm/include/llvm/ADT/None.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/None.h b/llvm/include/llvm/ADT/None.h
index b3dc18089683f..7202983642c62 100644
--- a/llvm/include/llvm/ADT/None.h
+++ b/llvm/include/llvm/ADT/None.h
@@ -16,11 +16,13 @@
 #ifndef LLVM_ADT_NONE_H
 #define LLVM_ADT_NONE_H
 
+#include <optional>
+
 namespace llvm {
 /// A simple null object to allow implicit construction of Optional<T>
 /// and similar types without having to spell out the specialization's name.
-enum class NoneType { None };
-const NoneType None = NoneType::None;
+using NoneType = std::nullopt_t;
+inline constexpr std::nullopt_t None = std::nullopt;
 }
 
 #endif


        


More information about the llvm-commits mailing list