Skip to content

Commit

Permalink
[ADT] Define None as std::nullopt (NFC)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kazutakahirata committed Nov 22, 2022
1 parent 8fa57a7 commit abfe65a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions llvm/include/llvm/ADT/None.h
Expand Up @@ -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

0 comments on commit abfe65a

Please sign in to comment.