Skip to content

Commit

Permalink
[Bitcode] Use std::nullopt_t instead of NoneType (NFC)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kazutakahirata committed Dec 14, 2022
1 parent b9b877f commit 8a55264
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions llvm/include/llvm/Bitcode/BitcodeConvenience.h
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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)...);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 8a55264

Please sign in to comment.