[llvm] fef3a16 - [ADT, Support] Use std::nullopt instead of None (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 2 19:05:03 PST 2022
Author: Kazu Hirata
Date: 2022-12-02T19:04:57-08:00
New Revision: fef3a16aeab660d0789c592985993bd68b51f517
URL: https://github.com/llvm/llvm-project/commit/fef3a16aeab660d0789c592985993bd68b51f517
DIFF: https://github.com/llvm/llvm-project/commit/fef3a16aeab660d0789c592985993bd68b51f517.diff
LOG: [ADT, Support] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated. The intent is to reduce
the amount of manual work required in migrating from Optional to
std::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/D139241
Added:
Modified:
llvm/include/llvm/ADT/AddressRanges.h
llvm/include/llvm/ADT/BreadthFirstIterator.h
llvm/include/llvm/ADT/DepthFirstIterator.h
llvm/include/llvm/ADT/Optional.h
llvm/include/llvm/ADT/STLExtras.h
llvm/include/llvm/ADT/StringMapEntry.h
llvm/include/llvm/ADT/TinyPtrVector.h
llvm/include/llvm/Support/Allocator.h
llvm/include/llvm/Support/CheckedArithmetic.h
llvm/include/llvm/Support/Error.h
llvm/include/llvm/Support/FileUtilities.h
llvm/include/llvm/Support/Format.h
llvm/include/llvm/Support/FormatProviders.h
llvm/include/llvm/Support/InstructionCost.h
llvm/include/llvm/Support/JSON.h
llvm/include/llvm/Support/MemoryBuffer.h
llvm/include/llvm/Support/NativeFormatting.h
llvm/include/llvm/Support/VersionTuple.h
llvm/include/llvm/Support/VirtualFileSystem.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/AddressRanges.h b/llvm/include/llvm/ADT/AddressRanges.h
index c02844a095d1c..1fd71034767d7 100644
--- a/llvm/include/llvm/ADT/AddressRanges.h
+++ b/llvm/include/llvm/ADT/AddressRanges.h
@@ -66,7 +66,7 @@ class AddressRanges {
Optional<AddressRange> getRangeThatContains(uint64_t Addr) const {
Collection::const_iterator It = find(Addr);
if (It == Ranges.end())
- return None;
+ return std::nullopt;
return *It;
}
@@ -129,7 +129,7 @@ template <typename T> class AddressRangesMap : protected AddressRanges {
getRangeValueThatContains(uint64_t Addr) const {
Collection::const_iterator It = find(Addr);
if (It == Ranges.end())
- return None;
+ return std::nullopt;
return std::make_pair(*It, Values[It - Ranges.begin()]);
}
diff --git a/llvm/include/llvm/ADT/BreadthFirstIterator.h b/llvm/include/llvm/ADT/BreadthFirstIterator.h
index 807b0a92c48ca..56a1bb1cb603d 100644
--- a/llvm/include/llvm/ADT/BreadthFirstIterator.h
+++ b/llvm/include/llvm/ADT/BreadthFirstIterator.h
@@ -72,8 +72,8 @@ class bf_iterator : public bf_iterator_storage<SetType> {
Level = 0;
// Also, insert a dummy node as marker.
- VisitQueue.push(QueueElement(Node, None));
- VisitQueue.push(None);
+ VisitQueue.push(QueueElement(Node, std::nullopt));
+ VisitQueue.push(std::nullopt);
}
inline bf_iterator() = default;
@@ -91,14 +91,14 @@ class bf_iterator : public bf_iterator_storage<SetType> {
// Already visited?
if (this->Visited.insert(Next).second)
- VisitQueue.push(QueueElement(Next, None));
+ VisitQueue.push(QueueElement(Next, std::nullopt));
}
VisitQueue.pop();
// Go to the next element skipping markers if needed.
if (!VisitQueue.empty()) {
Head = VisitQueue.front();
- if (Head != None)
+ if (Head != std::nullopt)
return;
Level += 1;
VisitQueue.pop();
@@ -106,7 +106,7 @@ class bf_iterator : public bf_iterator_storage<SetType> {
// Don't push another marker if this is the last
// element.
if (!VisitQueue.empty())
- VisitQueue.push(None);
+ VisitQueue.push(std::nullopt);
}
}
diff --git a/llvm/include/llvm/ADT/DepthFirstIterator.h b/llvm/include/llvm/ADT/DepthFirstIterator.h
index cea6fbcd9d29b..513cc56f68923 100644
--- a/llvm/include/llvm/ADT/DepthFirstIterator.h
+++ b/llvm/include/llvm/ADT/DepthFirstIterator.h
@@ -105,7 +105,7 @@ class df_iterator : public df_iterator_storage<SetType, ExtStorage> {
inline df_iterator(NodeRef Node) {
this->Visited.insert(Node);
- VisitStack.push_back(StackElement(Node, None));
+ VisitStack.push_back(StackElement(Node, std::nullopt));
}
inline df_iterator() = default; // End is when stack is empty
@@ -113,7 +113,7 @@ class df_iterator : public df_iterator_storage<SetType, ExtStorage> {
inline df_iterator(NodeRef Node, SetType &S)
: df_iterator_storage<SetType, ExtStorage>(S) {
if (this->Visited.insert(Node).second)
- VisitStack.push_back(StackElement(Node, None));
+ VisitStack.push_back(StackElement(Node, std::nullopt));
}
inline df_iterator(SetType &S)
@@ -137,7 +137,7 @@ class df_iterator : public df_iterator_storage<SetType, ExtStorage> {
// Has our next sibling been visited?
if (this->Visited.insert(Next).second) {
// No, do it now.
- VisitStack.push_back(StackElement(Next, None));
+ VisitStack.push_back(StackElement(Next, std::nullopt));
return;
}
}
diff --git a/llvm/include/llvm/ADT/Optional.h b/llvm/include/llvm/ADT/Optional.h
index 4d0cd45423428..2df8d35cf1ae4 100644
--- a/llvm/include/llvm/ADT/Optional.h
+++ b/llvm/include/llvm/ADT/Optional.h
@@ -297,7 +297,7 @@ template <typename T> class Optional {
auto transform(const Function &F) const & -> Optional<decltype(F(value()))> {
if (*this)
return F(value());
- return None;
+ return std::nullopt;
}
T &&value() && { return std::move(Storage.value()); }
@@ -313,7 +313,7 @@ template <typename T> class Optional {
const Function &F) && -> Optional<decltype(F(std::move(*this).value()))> {
if (*this)
return F(std::move(*this).value());
- return None;
+ return std::nullopt;
}
};
@@ -365,17 +365,17 @@ constexpr bool operator==(const Optional<T> &X, std::nullopt_t) {
template <typename T>
constexpr bool operator==(std::nullopt_t, const Optional<T> &X) {
- return X == None;
+ return X == std::nullopt;
}
template <typename T>
constexpr bool operator!=(const Optional<T> &X, std::nullopt_t) {
- return !(X == None);
+ return !(X == std::nullopt);
}
template <typename T>
constexpr bool operator!=(std::nullopt_t, const Optional<T> &X) {
- return X != None;
+ return X != std::nullopt;
}
template <typename T>
@@ -390,32 +390,32 @@ constexpr bool operator<(std::nullopt_t, const Optional<T> &X) {
template <typename T>
constexpr bool operator<=(const Optional<T> &X, std::nullopt_t) {
- return !(None < X);
+ return !(std::nullopt < X);
}
template <typename T>
constexpr bool operator<=(std::nullopt_t, const Optional<T> &X) {
- return !(X < None);
+ return !(X < std::nullopt);
}
template <typename T>
constexpr bool operator>(const Optional<T> &X, std::nullopt_t) {
- return None < X;
+ return std::nullopt < X;
}
template <typename T>
constexpr bool operator>(std::nullopt_t, const Optional<T> &X) {
- return X < None;
+ return X < std::nullopt;
}
template <typename T>
constexpr bool operator>=(const Optional<T> &X, std::nullopt_t) {
- return None <= X;
+ return std::nullopt <= X;
}
template <typename T>
constexpr bool operator>=(std::nullopt_t, const Optional<T> &X) {
- return X <= None;
+ return X <= std::nullopt;
}
template <typename T>
@@ -486,7 +486,7 @@ raw_ostream &operator<<(raw_ostream &OS, const Optional<T> &O) {
if (O)
OS << *O;
else
- OS << None;
+ OS << std::nullopt;
return OS;
}
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index 11ef2f99736e7..28c13a8390e62 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -924,7 +924,7 @@ template <typename Iter>
auto deref_or_none(const Iter &I, const Iter &End) -> llvm::Optional<
std::remove_const_t<std::remove_reference_t<decltype(*I)>>> {
if (I == End)
- return None;
+ return std::nullopt;
return *I;
}
diff --git a/llvm/include/llvm/ADT/StringMapEntry.h b/llvm/include/llvm/ADT/StringMapEntry.h
index fb4ec66d04b26..27d82916503e3 100644
--- a/llvm/include/llvm/ADT/StringMapEntry.h
+++ b/llvm/include/llvm/ADT/StringMapEntry.h
@@ -88,11 +88,12 @@ class StringMapEntryStorage : public StringMapEntryBase {
template <>
class StringMapEntryStorage<std::nullopt_t> : public StringMapEntryBase {
public:
- explicit StringMapEntryStorage(size_t keyLength, std::nullopt_t = None)
+ explicit StringMapEntryStorage(size_t keyLength,
+ std::nullopt_t = std::nullopt)
: StringMapEntryBase(keyLength) {}
StringMapEntryStorage(StringMapEntryStorage &entry) = delete;
- std::nullopt_t getValue() const { return None; }
+ std::nullopt_t getValue() const { return std::nullopt; }
};
/// StringMapEntry - This is used to represent one value that is inserted into
diff --git a/llvm/include/llvm/ADT/TinyPtrVector.h b/llvm/include/llvm/ADT/TinyPtrVector.h
index ed20a762f3071..b96b7ea1f006c 100644
--- a/llvm/include/llvm/ADT/TinyPtrVector.h
+++ b/llvm/include/llvm/ADT/TinyPtrVector.h
@@ -136,7 +136,7 @@ class TinyPtrVector {
// implicit conversion operator to ArrayRef.
operator ArrayRef<EltTy>() const {
if (Val.isNull())
- return None;
+ return std::nullopt;
if (Val.template is<EltTy>())
return *Val.getAddrOfPtr1();
return *Val.template get<VecTy*>();
@@ -145,7 +145,7 @@ class TinyPtrVector {
// implicit conversion operator to MutableArrayRef.
operator MutableArrayRef<EltTy>() {
if (Val.isNull())
- return None;
+ return std::nullopt;
if (Val.template is<EltTy>())
return *Val.getAddrOfPtr1();
return *Val.template get<VecTy*>();
diff --git a/llvm/include/llvm/Support/Allocator.h b/llvm/include/llvm/Support/Allocator.h
index 041729fa6594d..8a70709c67841 100644
--- a/llvm/include/llvm/Support/Allocator.h
+++ b/llvm/include/llvm/Support/Allocator.h
@@ -248,7 +248,7 @@ class BumpPtrAllocatorImpl
return InCustomSizedSlabIdx - static_cast<int64_t>(P - S);
InCustomSizedSlabIdx -= static_cast<int64_t>(Size);
}
- return None;
+ return std::nullopt;
}
/// A wrapper around identifyObject that additionally asserts that
diff --git a/llvm/include/llvm/Support/CheckedArithmetic.h b/llvm/include/llvm/Support/CheckedArithmetic.h
index 09e6d7ec95dcc..c9db239672d36 100644
--- a/llvm/include/llvm/Support/CheckedArithmetic.h
+++ b/llvm/include/llvm/Support/CheckedArithmetic.h
@@ -33,7 +33,7 @@ checkedOp(T LHS, T RHS, F Op, bool Signed = true) {
bool Overflow;
llvm::APInt Out = (ALHS.*Op)(ARHS, Overflow);
if (Overflow)
- return llvm::None;
+ return std::nullopt;
return Signed ? Out.getSExtValue() : Out.getZExtValue();
}
}
@@ -75,7 +75,7 @@ std::enable_if_t<std::is_signed<T>::value, llvm::Optional<T>>
checkedMulAdd(T A, T B, T C) {
if (auto Product = checkedMul(A, B))
return checkedAdd(*Product, C);
- return llvm::None;
+ return std::nullopt;
}
/// Add two unsigned integers \p LHS and \p RHS.
@@ -104,7 +104,7 @@ std::enable_if_t<std::is_unsigned<T>::value, llvm::Optional<T>>
checkedMulAddUnsigned(T A, T B, T C) {
if (auto Product = checkedMulUnsigned(A, B))
return checkedAddUnsigned(*Product, C);
- return llvm::None;
+ return std::nullopt;
}
} // End llvm namespace
diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h
index 04c12cb8f2dc4..6c794eaf2827a 100644
--- a/llvm/include/llvm/Support/Error.h
+++ b/llvm/include/llvm/Support/Error.h
@@ -1054,7 +1054,7 @@ template <typename T> Optional<T> expectedToOptional(Expected<T> &&E) {
if (E)
return std::move(*E);
consumeError(E.takeError());
- return None;
+ return std::nullopt;
}
/// Helper for converting an Error to a bool.
diff --git a/llvm/include/llvm/Support/FileUtilities.h b/llvm/include/llvm/Support/FileUtilities.h
index 0033638c6804a..b641781da4ab0 100644
--- a/llvm/include/llvm/Support/FileUtilities.h
+++ b/llvm/include/llvm/Support/FileUtilities.h
@@ -122,7 +122,7 @@ namespace llvm {
/// Copy LastAccess and ModificationTime if \p CopyDates is true.
/// Overwrite stored permissions if \p OverwritePermissions is specified.
Error apply(StringRef OutputFilename, bool CopyDates = false,
- Optional<sys::fs::perms> OverwritePermissions = None);
+ Optional<sys::fs::perms> OverwritePermissions = std::nullopt);
private:
FilePermissionsApplier(StringRef InputFilename, sys::fs::file_status Status)
diff --git a/llvm/include/llvm/Support/Format.h b/llvm/include/llvm/Support/Format.h
index a12f00b87ee43..d6308a88c1894 100644
--- a/llvm/include/llvm/Support/Format.h
+++ b/llvm/include/llvm/Support/Format.h
@@ -236,7 +236,8 @@ class FormattedBytes {
};
inline FormattedBytes
-format_bytes(ArrayRef<uint8_t> Bytes, Optional<uint64_t> FirstByteOffset = None,
+format_bytes(ArrayRef<uint8_t> Bytes,
+ Optional<uint64_t> FirstByteOffset = std::nullopt,
uint32_t NumPerLine = 16, uint8_t ByteGroupSize = 4,
uint32_t IndentLevel = 0, bool Upper = false) {
return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
@@ -245,7 +246,7 @@ format_bytes(ArrayRef<uint8_t> Bytes, Optional<uint64_t> FirstByteOffset = None,
inline FormattedBytes
format_bytes_with_ascii(ArrayRef<uint8_t> Bytes,
- Optional<uint64_t> FirstByteOffset = None,
+ Optional<uint64_t> FirstByteOffset = std::nullopt,
uint32_t NumPerLine = 16, uint8_t ByteGroupSize = 4,
uint32_t IndentLevel = 0, bool Upper = false) {
return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
diff --git a/llvm/include/llvm/Support/FormatProviders.h b/llvm/include/llvm/Support/FormatProviders.h
index c25453e9e881a..ab1245cfd4c04 100644
--- a/llvm/include/llvm/Support/FormatProviders.h
+++ b/llvm/include/llvm/Support/FormatProviders.h
@@ -63,10 +63,10 @@ class HelperFunctions {
size_t Prec;
Optional<size_t> Result;
if (Str.empty())
- Result = None;
+ Result = std::nullopt;
else if (Str.getAsInteger(10, Prec)) {
assert(false && "Invalid precision specifier");
- Result = None;
+ Result = std::nullopt;
} else {
assert(Prec < 100 && "Precision out of range");
Result = std::min<size_t>(99u, Prec);
diff --git a/llvm/include/llvm/Support/InstructionCost.h b/llvm/include/llvm/Support/InstructionCost.h
index 84272355912d8..a4a945d207972 100644
--- a/llvm/include/llvm/Support/InstructionCost.h
+++ b/llvm/include/llvm/Support/InstructionCost.h
@@ -88,7 +88,7 @@ class InstructionCost {
std::optional<CostType> getValue() const {
if (isValid())
return Value;
- return None;
+ return std::nullopt;
}
/// For all of the arithmetic operators provided here any invalid state is
diff --git a/llvm/include/llvm/Support/JSON.h b/llvm/include/llvm/Support/JSON.h
index 3605622841b3b..0d07cad2fa8f0 100644
--- a/llvm/include/llvm/Support/JSON.h
+++ b/llvm/include/llvm/Support/JSON.h
@@ -404,12 +404,12 @@ class Value {
llvm::Optional<std::nullptr_t> getAsNull() const {
if (LLVM_LIKELY(Type == T_Null))
return nullptr;
- return llvm::None;
+ return std::nullopt;
}
llvm::Optional<bool> getAsBoolean() const {
if (LLVM_LIKELY(Type == T_Boolean))
return as<bool>();
- return llvm::None;
+ return std::nullopt;
}
llvm::Optional<double> getAsNumber() const {
if (LLVM_LIKELY(Type == T_Double))
@@ -418,7 +418,7 @@ class Value {
return as<int64_t>();
if (LLVM_LIKELY(Type == T_UINT64))
return as<uint64_t>();
- return llvm::None;
+ return std::nullopt;
}
// Succeeds if the Value is a Number, and exactly representable as int64_t.
llvm::Optional<int64_t> getAsInteger() const {
@@ -431,7 +431,7 @@ class Value {
D <= double(std::numeric_limits<int64_t>::max())))
return D;
}
- return llvm::None;
+ return std::nullopt;
}
llvm::Optional<uint64_t> getAsUINT64() const {
if (Type == T_UINT64)
@@ -441,14 +441,14 @@ class Value {
if (N >= 0)
return as<uint64_t>();
}
- return llvm::None;
+ return std::nullopt;
}
llvm::Optional<llvm::StringRef> getAsString() const {
if (Type == T_String)
return llvm::StringRef(as<std::string>());
if (LLVM_LIKELY(Type == T_StringRef))
return as<llvm::StringRef>();
- return llvm::None;
+ return std::nullopt;
}
const json::Object *getAsObject() const {
return LLVM_LIKELY(Type == T_Object) ? &as<json::Object>() : nullptr;
@@ -764,7 +764,7 @@ inline bool fromJSON(const Value &E, std::nullptr_t &Out, Path P) {
template <typename T>
bool fromJSON(const Value &E, llvm::Optional<T> &Out, Path P) {
if (E.getAsNull()) {
- Out = llvm::None;
+ Out = std::nullopt;
return true;
}
T Result;
@@ -845,7 +845,7 @@ class ObjectMapper {
assert(*this && "Must check this is an object before calling map()");
if (const Value *E = O->get(Prop))
return fromJSON(*E, Out, P.field(Prop));
- Out = llvm::None;
+ Out = std::nullopt;
return true;
}
diff --git a/llvm/include/llvm/Support/MemoryBuffer.h b/llvm/include/llvm/Support/MemoryBuffer.h
index ed975c86c125f..d6ae98e341f0e 100644
--- a/llvm/include/llvm/Support/MemoryBuffer.h
+++ b/llvm/include/llvm/Support/MemoryBuffer.h
@@ -97,7 +97,7 @@ class MemoryBuffer {
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getFile(const Twine &Filename, bool IsText = false,
bool RequiresNullTerminator = true, bool IsVolatile = false,
- Optional<Align> Alignment = None);
+ Optional<Align> Alignment = std::nullopt);
/// Read all of the specified file into a MemoryBuffer as a stream
/// (i.e. until EOF reached). This is useful for special files that
@@ -111,7 +111,7 @@ class MemoryBuffer {
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getOpenFileSlice(sys::fs::file_t FD, const Twine &Filename, uint64_t MapSize,
int64_t Offset, bool IsVolatile = false,
- Optional<Align> Alignment = None);
+ Optional<Align> Alignment = std::nullopt);
/// Given an already-open file descriptor, read the file and return a
/// MemoryBuffer.
@@ -125,7 +125,7 @@ class MemoryBuffer {
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getOpenFile(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize,
bool RequiresNullTerminator = true, bool IsVolatile = false,
- Optional<Align> Alignment = None);
+ Optional<Align> Alignment = std::nullopt);
/// Open the specified memory range as a MemoryBuffer. Note that InputData
/// must be null terminated if RequiresNullTerminator is true.
@@ -149,12 +149,13 @@ class MemoryBuffer {
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getFileOrSTDIN(const Twine &Filename, bool IsText = false,
bool RequiresNullTerminator = true,
- Optional<Align> Alignment = None);
+ Optional<Align> Alignment = std::nullopt);
/// Map a subrange of the specified file as a MemoryBuffer.
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset,
- bool IsVolatile = false, Optional<Align> Alignment = None);
+ bool IsVolatile = false,
+ Optional<Align> Alignment = std::nullopt);
//===--------------------------------------------------------------------===//
// Provided for performance analysis.
@@ -200,12 +201,13 @@ class WritableMemoryBuffer : public MemoryBuffer {
static ErrorOr<std::unique_ptr<WritableMemoryBuffer>>
getFile(const Twine &Filename, bool IsVolatile = false,
- Optional<Align> Alignment = None);
+ Optional<Align> Alignment = std::nullopt);
/// Map a subrange of the specified file as a WritableMemoryBuffer.
static ErrorOr<std::unique_ptr<WritableMemoryBuffer>>
getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset,
- bool IsVolatile = false, Optional<Align> Alignment = None);
+ bool IsVolatile = false,
+ Optional<Align> Alignment = std::nullopt);
/// Allocate a new MemoryBuffer of the specified size that is not initialized.
/// Note that the caller should initialize the memory allocated by this
@@ -215,7 +217,7 @@ class WritableMemoryBuffer : public MemoryBuffer {
/// least the specified alignment.
static std::unique_ptr<WritableMemoryBuffer>
getNewUninitMemBuffer(size_t Size, const Twine &BufferName = "",
- Optional<Align> Alignment = None);
+ Optional<Align> Alignment = std::nullopt);
/// Allocate a new zero-initialized MemoryBuffer of the specified size. Note
/// that the caller need not initialize the memory allocated by this method.
diff --git a/llvm/include/llvm/Support/NativeFormatting.h b/llvm/include/llvm/Support/NativeFormatting.h
index 80cb554ca2f35..f94b0174edd47 100644
--- a/llvm/include/llvm/Support/NativeFormatting.h
+++ b/llvm/include/llvm/Support/NativeFormatting.h
@@ -38,9 +38,9 @@ void write_integer(raw_ostream &S, long long N, size_t MinDigits,
IntegerStyle Style);
void write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style,
- Optional<size_t> Width = None);
+ Optional<size_t> Width = std::nullopt);
void write_double(raw_ostream &S, double D, FloatStyle Style,
- Optional<size_t> Precision = None);
+ Optional<size_t> Precision = std::nullopt);
}
#endif
diff --git a/llvm/include/llvm/Support/VersionTuple.h b/llvm/include/llvm/Support/VersionTuple.h
index 3adec07e2a23c..75c1c09c77ac3 100644
--- a/llvm/include/llvm/Support/VersionTuple.h
+++ b/llvm/include/llvm/Support/VersionTuple.h
@@ -75,21 +75,21 @@ class VersionTuple {
/// Retrieve the minor version number, if provided.
Optional<unsigned> getMinor() const {
if (!HasMinor)
- return None;
+ return std::nullopt;
return Minor;
}
/// Retrieve the subminor version number, if provided.
Optional<unsigned> getSubminor() const {
if (!HasSubminor)
- return None;
+ return std::nullopt;
return Subminor;
}
/// Retrieve the build version number, if provided.
Optional<unsigned> getBuild() const {
if (!HasBuild)
- return None;
+ return std::nullopt;
return Build;
}
diff --git a/llvm/include/llvm/Support/VirtualFileSystem.h b/llvm/include/llvm/Support/VirtualFileSystem.h
index 447437f46ebd1..6aec30c29b725 100644
--- a/llvm/include/llvm/Support/VirtualFileSystem.h
+++ b/llvm/include/llvm/Support/VirtualFileSystem.h
@@ -534,9 +534,10 @@ class InMemoryFileSystem : public FileSystem {
///
diff erent contents.
bool addFile(const Twine &Path, time_t ModificationTime,
std::unique_ptr<llvm::MemoryBuffer> Buffer,
- Optional<uint32_t> User = None, Optional<uint32_t> Group = None,
- Optional<llvm::sys::fs::file_type> Type = None,
- Optional<llvm::sys::fs::perms> Perms = None);
+ Optional<uint32_t> User = std::nullopt,
+ Optional<uint32_t> Group = std::nullopt,
+ Optional<llvm::sys::fs::file_type> Type = std::nullopt,
+ Optional<llvm::sys::fs::perms> Perms = std::nullopt);
/// Add a hard link to a file.
///
@@ -562,9 +563,10 @@ class InMemoryFileSystem : public FileSystem {
/// to refer to a file (or refer to anything, as it happens). Also, an
/// in-memory directory for \p Target isn't automatically created.
bool addSymbolicLink(const Twine &NewLink, const Twine &Target,
- time_t ModificationTime, Optional<uint32_t> User = None,
- Optional<uint32_t> Group = None,
- Optional<llvm::sys::fs::perms> Perms = None);
+ time_t ModificationTime,
+ Optional<uint32_t> User = std::nullopt,
+ Optional<uint32_t> Group = std::nullopt,
+ Optional<llvm::sys::fs::perms> Perms = std::nullopt);
/// Add a buffer to the VFS with a path. The VFS does not own the buffer.
/// If present, User, Group, Type and Perms apply to the newly-created file
@@ -574,10 +576,10 @@ class InMemoryFileSystem : public FileSystem {
///
diff erent contents.
bool addFileNoOwn(const Twine &Path, time_t ModificationTime,
const llvm::MemoryBufferRef &Buffer,
- Optional<uint32_t> User = None,
- Optional<uint32_t> Group = None,
- Optional<llvm::sys::fs::file_type> Type = None,
- Optional<llvm::sys::fs::perms> Perms = None);
+ Optional<uint32_t> User = std::nullopt,
+ Optional<uint32_t> Group = std::nullopt,
+ Optional<llvm::sys::fs::file_type> Type = std::nullopt,
+ Optional<llvm::sys::fs::perms> Perms = std::nullopt);
std::string toString() const;
@@ -871,7 +873,7 @@ class RedirectingFileSystem : public vfs::FileSystem {
return StringRef(*ExternalRedirect);
if (auto *FE = dyn_cast<FileEntry>(E))
return FE->getExternalContentsPath();
- return None;
+ return std::nullopt;
}
};
More information about the llvm-commits
mailing list