aboutsummaryrefslogtreecommitdiff
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Support/Allocator.h4
-rw-r--r--llvm/include/llvm/Support/BinaryStreamRef.h16
-rw-r--r--llvm/include/llvm/Support/Casting.h37
-rw-r--r--llvm/include/llvm/Support/Error.h12
-rw-r--r--llvm/include/llvm/Support/FileUtilities.h5
-rw-r--r--llvm/include/llvm/Support/FormatProviders.h6
-rw-r--r--llvm/include/llvm/Support/FormatVariadic.h4
-rw-r--r--llvm/include/llvm/Support/KnownBits.h22
-rw-r--r--llvm/include/llvm/Support/LockFileManager.h6
-rw-r--r--llvm/include/llvm/Support/MemoryBuffer.h16
-rw-r--r--llvm/include/llvm/Support/NativeFormatting.h4
-rw-r--r--llvm/include/llvm/Support/SMTAPI.h2
-rw-r--r--llvm/include/llvm/Support/Unicode.h6
-rw-r--r--llvm/include/llvm/Support/VersionTuple.h6
-rw-r--r--llvm/include/llvm/Support/VirtualFileSystem.h43
-rw-r--r--llvm/include/llvm/Support/thread.h14
-rw-r--r--llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp2
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp8
-rw-r--r--llvm/lib/Support/BinaryStreamRef.cpp4
-rw-r--r--llvm/lib/Support/CrashRecoveryContext.cpp2
-rw-r--r--llvm/lib/Support/DJB.cpp5
-rw-r--r--llvm/lib/Support/FileUtilities.cpp2
-rw-r--r--llvm/lib/Support/FormatVariadic.cpp2
-rw-r--r--llvm/lib/Support/KnownBits.cpp44
-rw-r--r--llvm/lib/Support/LockFileManager.cpp2
-rw-r--r--llvm/lib/Support/MemoryBuffer.cpp29
-rw-r--r--llvm/lib/Support/NativeFormatting.cpp4
-rw-r--r--llvm/lib/Support/OptimizedStructLayout.cpp10
-rw-r--r--llvm/lib/Support/SymbolRemappingReader.cpp10
-rw-r--r--llvm/lib/Support/Threading.cpp4
-rw-r--r--llvm/lib/Support/UnicodeNameToCodepoint.cpp14
-rw-r--r--llvm/lib/Support/Unix/Threading.inc2
-rw-r--r--llvm/lib/Support/VersionTuple.cpp6
-rw-r--r--llvm/lib/Support/VirtualFileSystem.cpp52
-rw-r--r--llvm/lib/Support/Windows/Threading.inc2
-rw-r--r--llvm/lib/Support/Z3Solver.cpp2
-rw-r--r--llvm/unittests/ADT/StatisticTest.cpp2
-rw-r--r--llvm/unittests/Support/Casting.cpp8
-rw-r--r--llvm/unittests/Support/ErrorTest.cpp4
-rw-r--r--llvm/unittests/Support/KnownBitsTest.cpp20
-rw-r--r--llvm/unittests/Support/NativeFormatTests.cpp4
-rw-r--r--llvm/unittests/Support/Path.cpp10
-rw-r--r--llvm/unittests/Support/TypeTraitsTest.cpp2
43 files changed, 232 insertions, 227 deletions
diff --git a/llvm/include/llvm/Support/Allocator.h b/llvm/include/llvm/Support/Allocator.h
index 8a70709..ab3e122 100644
--- a/llvm/include/llvm/Support/Allocator.h
+++ b/llvm/include/llvm/Support/Allocator.h
@@ -229,7 +229,7 @@ public:
/// The returned value is negative iff the object is inside a custom-size
/// slab.
/// Returns an empty optional if the pointer is not found in the allocator.
- llvm::Optional<int64_t> identifyObject(const void *Ptr) {
+ std::optional<int64_t> identifyObject(const void *Ptr) {
const char *P = static_cast<const char *>(Ptr);
int64_t InSlabIdx = 0;
for (size_t Idx = 0, E = Slabs.size(); Idx < E; Idx++) {
@@ -256,7 +256,7 @@ public:
/// \return An index uniquely and reproducibly identifying
/// an input pointer \p Ptr in the given allocator.
int64_t identifyKnownObject(const void *Ptr) {
- Optional<int64_t> Out = identifyObject(Ptr);
+ std::optional<int64_t> Out = identifyObject(Ptr);
assert(Out && "Wrong allocator used");
return *Out;
}
diff --git a/llvm/include/llvm/Support/BinaryStreamRef.h b/llvm/include/llvm/Support/BinaryStreamRef.h
index 46fc9fb..0cea224 100644
--- a/llvm/include/llvm/Support/BinaryStreamRef.h
+++ b/llvm/include/llvm/Support/BinaryStreamRef.h
@@ -10,12 +10,12 @@
#define LLVM_SUPPORT_BINARYSTREAMREF_H
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/Support/BinaryStream.h"
#include "llvm/Support/BinaryStreamError.h"
#include "llvm/Support/Error.h"
#include <cstdint>
#include <memory>
+#include <optional>
namespace llvm {
@@ -30,11 +30,11 @@ protected:
}
BinaryStreamRefBase(std::shared_ptr<StreamType> SharedImpl, uint64_t Offset,
- Optional<uint64_t> Length)
+ std::optional<uint64_t> Length)
: SharedImpl(SharedImpl), BorrowedImpl(SharedImpl.get()),
ViewOffset(Offset), Length(Length) {}
BinaryStreamRefBase(StreamType &BorrowedImpl, uint64_t Offset,
- Optional<uint64_t> Length)
+ std::optional<uint64_t> Length)
: BorrowedImpl(&BorrowedImpl), ViewOffset(Offset), Length(Length) {}
BinaryStreamRefBase(const BinaryStreamRefBase &Other) = default;
BinaryStreamRefBase &operator=(const BinaryStreamRefBase &Other) = default;
@@ -142,7 +142,7 @@ protected:
std::shared_ptr<StreamType> SharedImpl;
StreamType *BorrowedImpl = nullptr;
uint64_t ViewOffset = 0;
- Optional<uint64_t> Length;
+ std::optional<uint64_t> Length;
};
/// BinaryStreamRef is to BinaryStream what ArrayRef is to an Array. It
@@ -157,14 +157,14 @@ class BinaryStreamRef
friend BinaryStreamRefBase<BinaryStreamRef, BinaryStream>;
friend class WritableBinaryStreamRef;
BinaryStreamRef(std::shared_ptr<BinaryStream> Impl, uint64_t ViewOffset,
- Optional<uint64_t> Length)
+ std::optional<uint64_t> Length)
: BinaryStreamRefBase(Impl, ViewOffset, Length) {}
public:
BinaryStreamRef() = default;
BinaryStreamRef(BinaryStream &Stream);
BinaryStreamRef(BinaryStream &Stream, uint64_t Offset,
- Optional<uint64_t> Length);
+ std::optional<uint64_t> Length);
explicit BinaryStreamRef(ArrayRef<uint8_t> Data,
llvm::support::endianness Endian);
explicit BinaryStreamRef(StringRef Data, llvm::support::endianness Endian);
@@ -222,7 +222,7 @@ class WritableBinaryStreamRef
WritableBinaryStream> {
friend BinaryStreamRefBase<WritableBinaryStreamRef, WritableBinaryStream>;
WritableBinaryStreamRef(std::shared_ptr<WritableBinaryStream> Impl,
- uint64_t ViewOffset, Optional<uint64_t> Length)
+ uint64_t ViewOffset, std::optional<uint64_t> Length)
: BinaryStreamRefBase(Impl, ViewOffset, Length) {}
Error checkOffsetForWrite(uint64_t Offset, uint64_t DataSize) const {
@@ -238,7 +238,7 @@ public:
WritableBinaryStreamRef() = default;
WritableBinaryStreamRef(WritableBinaryStream &Stream);
WritableBinaryStreamRef(WritableBinaryStream &Stream, uint64_t Offset,
- Optional<uint64_t> Length);
+ std::optional<uint64_t> Length);
explicit WritableBinaryStreamRef(MutableArrayRef<uint8_t> Data,
llvm::support::endianness Endian);
WritableBinaryStreamRef(const WritableBinaryStreamRef &Other) = default;
diff --git a/llvm/include/llvm/Support/Casting.h b/llvm/include/llvm/Support/Casting.h
index 8a2fa94..9d1228b 100644
--- a/llvm/include/llvm/Support/Casting.h
+++ b/llvm/include/llvm/Support/Casting.h
@@ -14,11 +14,11 @@
#ifndef LLVM_SUPPORT_CASTING_H
#define LLVM_SUPPORT_CASTING_H
-#include "llvm/ADT/Optional.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/type_traits.h"
#include <cassert>
#include <memory>
+#include <optional>
#include <type_traits>
namespace llvm {
@@ -263,8 +263,8 @@ struct CastIsPossible {
// over. In fact, some of the isa_impl templates should be moved over to
// CastIsPossible.
template <typename To, typename From>
-struct CastIsPossible<To, Optional<From>> {
- static inline bool isPossible(const Optional<From> &f) {
+struct CastIsPossible<To, std::optional<From>> {
+ static inline bool isPossible(const std::optional<From> &f) {
assert(f && "CastIsPossible::isPossible called on a nullopt!");
return isa_impl_wrap<
To, const From,
@@ -359,18 +359,18 @@ struct UniquePtrCast : public CastIsPossible<To, From *> {
}
};
-/// This cast trait provides Optional<T> casting. This means that if you have a
-/// value type, you can cast it to another value type and have dyn_cast return
-/// an Optional<T>.
+/// This cast trait provides std::optional<T> casting. This means that if you
+/// have a value type, you can cast it to another value type and have dyn_cast
+/// return an std::optional<T>.
template <typename To, typename From, typename Derived = void>
struct OptionalValueCast
: public CastIsPossible<To, From>,
public DefaultDoCastIfPossible<
- Optional<To>, From,
+ std::optional<To>, From,
detail::SelfType<Derived, OptionalValueCast<To, From>>> {
- static inline Optional<To> castFailed() { return Optional<To>{}; }
+ static inline std::optional<To> castFailed() { return std::optional<To>{}; }
- static inline Optional<To> doCast(const From &f) { return To(f); }
+ static inline std::optional<To> doCast(const From &f) { return To(f); }
};
/// Provides a cast trait that strips `const` from types to make it easier to
@@ -533,11 +533,12 @@ struct CastInfo<To, From, std::enable_if_t<!is_simple_type<From>::value>> {
template <typename To, typename From>
struct CastInfo<To, std::unique_ptr<From>> : public UniquePtrCast<To, From> {};
-/// Provide a CastInfo specialized for Optional<From>. It's assumed that if the
-/// input is Optional<From> that the output can be Optional<To>. If that's not
-/// the case, specialize CastInfo for your use case.
+/// Provide a CastInfo specialized for std::optional<From>. It's assumed that if
+/// the input is std::optional<From> that the output can be std::optional<To>.
+/// If that's not the case, specialize CastInfo for your use case.
template <typename To, typename From>
-struct CastInfo<To, Optional<From>> : public OptionalValueCast<To, From> {};
+struct CastInfo<To, std::optional<From>> : public OptionalValueCast<To, From> {
+};
/// isa<X> - Return true if the parameter to the template is an instance of one
/// of the template type arguments. Used like this:
@@ -606,10 +607,14 @@ template <typename T, typename Enable = void> struct ValueIsPresent {
};
// Optional provides its own way to check if something is present.
-template <typename T> struct ValueIsPresent<Optional<T>> {
+template <typename T> struct ValueIsPresent<std::optional<T>> {
using UnwrappedType = T;
- static inline bool isPresent(const Optional<T> &t) { return t.has_value(); }
- static inline decltype(auto) unwrapValue(Optional<T> &t) { return t.value(); }
+ static inline bool isPresent(const std::optional<T> &t) {
+ return t.has_value();
+ }
+ static inline decltype(auto) unwrapValue(std::optional<T> &t) {
+ return t.value();
+ }
};
// If something is "nullable" then we just compare it to nullptr to see if it
diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h
index c5eb4b3..d821ab5 100644
--- a/llvm/include/llvm/Support/Error.h
+++ b/llvm/include/llvm/Support/Error.h
@@ -1039,7 +1039,7 @@ inline std::string toString(Error E) {
///
/// Uses of this method are potentially indicative of design problems: If it's
/// legitimate to do nothing while processing an "error", the error-producer
-/// might be more clearly refactored to return an Optional<T>.
+/// might be more clearly refactored to return an std::optional<T>.
inline void consumeError(Error Err) {
handleAllErrors(std::move(Err), [](const ErrorInfoBase &) {});
}
@@ -1298,7 +1298,7 @@ public:
static char ID;
private:
- FileError(const Twine &F, Optional<size_t> LineNum,
+ FileError(const Twine &F, std::optional<size_t> LineNum,
std::unique_ptr<ErrorInfoBase> E) {
assert(E && "Cannot create FileError from Error success value.");
FileName = F.str();
@@ -1306,7 +1306,7 @@ private:
Line = std::move(LineNum);
}
- static Error build(const Twine &F, Optional<size_t> Line, Error E) {
+ static Error build(const Twine &F, std::optional<size_t> Line, Error E) {
std::unique_ptr<ErrorInfoBase> Payload;
handleAllErrors(std::move(E),
[&](std::unique_ptr<ErrorInfoBase> EIB) -> Error {
@@ -1318,20 +1318,20 @@ private:
}
std::string FileName;
- Optional<size_t> Line;
+ std::optional<size_t> Line;
std::unique_ptr<ErrorInfoBase> Err;
};
/// Concatenate a source file path and/or name with an Error. The resulting
/// Error is unchecked.
inline Error createFileError(const Twine &F, Error E) {
- return FileError::build(F, Optional<size_t>(), std::move(E));
+ return FileError::build(F, std::optional<size_t>(), std::move(E));
}
/// Concatenate a source file path and/or name with line number and an Error.
/// The resulting Error is unchecked.
inline Error createFileError(const Twine &F, size_t Line, Error E) {
- return FileError::build(F, Optional<size_t>(Line), std::move(E));
+ return FileError::build(F, std::optional<size_t>(Line), std::move(E));
}
/// Concatenate a source file path and/or name with a std::error_code
diff --git a/llvm/include/llvm/Support/FileUtilities.h b/llvm/include/llvm/Support/FileUtilities.h
index b641781..c9a72d5 100644
--- a/llvm/include/llvm/Support/FileUtilities.h
+++ b/llvm/include/llvm/Support/FileUtilities.h
@@ -121,8 +121,9 @@ namespace llvm {
/// Apply stored permissions to the \p OutputFilename.
/// 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 = std::nullopt);
+ Error
+ apply(StringRef OutputFilename, bool CopyDates = false,
+ std::optional<sys::fs::perms> OverwritePermissions = std::nullopt);
private:
FilePermissionsApplier(StringRef InputFilename, sys::fs::file_status Status)
diff --git a/llvm/include/llvm/Support/FormatProviders.h b/llvm/include/llvm/Support/FormatProviders.h
index ab1245c..3fcd1b3 100644
--- a/llvm/include/llvm/Support/FormatProviders.h
+++ b/llvm/include/llvm/Support/FormatProviders.h
@@ -59,9 +59,9 @@ struct use_double_formatter
class HelperFunctions {
protected:
- static Optional<size_t> parseNumericPrecision(StringRef Str) {
+ static std::optional<size_t> parseNumericPrecision(StringRef Str) {
size_t Prec;
- Optional<size_t> Result;
+ std::optional<size_t> Result;
if (Str.empty())
Result = std::nullopt;
else if (Str.getAsInteger(10, Prec)) {
@@ -312,7 +312,7 @@ struct format_provider<T,
else
S = FloatStyle::Fixed;
- Optional<size_t> Precision = parseNumericPrecision(Style);
+ std::optional<size_t> Precision = parseNumericPrecision(Style);
if (!Precision)
Precision = getDefaultPrecision(S);
diff --git a/llvm/include/llvm/Support/FormatVariadic.h b/llvm/include/llvm/Support/FormatVariadic.h
index bc5cd3e..ddd80d8 100644
--- a/llvm/include/llvm/Support/FormatVariadic.h
+++ b/llvm/include/llvm/Support/FormatVariadic.h
@@ -26,7 +26,6 @@
#define LLVM_SUPPORT_FORMATVARIADIC_H
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
@@ -37,6 +36,7 @@
#include "llvm/Support/raw_ostream.h"
#include <array>
#include <cstddef>
+#include <optional>
#include <string>
#include <tuple>
#include <utility>
@@ -103,7 +103,7 @@ public:
}
static SmallVector<ReplacementItem, 2> parseFormatString(StringRef Fmt);
- static Optional<ReplacementItem> parseReplacementItem(StringRef Spec);
+ static std::optional<ReplacementItem> parseReplacementItem(StringRef Spec);
std::string str() const {
std::string Result;
diff --git a/llvm/include/llvm/Support/KnownBits.h b/llvm/include/llvm/Support/KnownBits.h
index dbb3237..f20d3e1 100644
--- a/llvm/include/llvm/Support/KnownBits.h
+++ b/llvm/include/llvm/Support/KnownBits.h
@@ -15,7 +15,7 @@
#define LLVM_SUPPORT_KNOWNBITS_H
#include "llvm/ADT/APInt.h"
-#include "llvm/ADT/Optional.h"
+#include <optional>
namespace llvm {
@@ -373,34 +373,34 @@ public:
static KnownBits ashr(const KnownBits &LHS, const KnownBits &RHS);
/// Determine if these known bits always give the same ICMP_EQ result.
- static Optional<bool> eq(const KnownBits &LHS, const KnownBits &RHS);
+ static std::optional<bool> eq(const KnownBits &LHS, const KnownBits &RHS);
/// Determine if these known bits always give the same ICMP_NE result.
- static Optional<bool> ne(const KnownBits &LHS, const KnownBits &RHS);
+ static std::optional<bool> ne(const KnownBits &LHS, const KnownBits &RHS);
/// Determine if these known bits always give the same ICMP_UGT result.
- static Optional<bool> ugt(const KnownBits &LHS, const KnownBits &RHS);
+ static std::optional<bool> ugt(const KnownBits &LHS, const KnownBits &RHS);
/// Determine if these known bits always give the same ICMP_UGE result.
- static Optional<bool> uge(const KnownBits &LHS, const KnownBits &RHS);
+ static std::optional<bool> uge(const KnownBits &LHS, const KnownBits &RHS);
/// Determine if these known bits always give the same ICMP_ULT result.
- static Optional<bool> ult(const KnownBits &LHS, const KnownBits &RHS);
+ static std::optional<bool> ult(const KnownBits &LHS, const KnownBits &RHS);
/// Determine if these known bits always give the same ICMP_ULE result.
- static Optional<bool> ule(const KnownBits &LHS, const KnownBits &RHS);
+ static std::optional<bool> ule(const KnownBits &LHS, const KnownBits &RHS);
/// Determine if these known bits always give the same ICMP_SGT result.
- static Optional<bool> sgt(const KnownBits &LHS, const KnownBits &RHS);
+ static std::optional<bool> sgt(const KnownBits &LHS, const KnownBits &RHS);
/// Determine if these known bits always give the same ICMP_SGE result.
- static Optional<bool> sge(const KnownBits &LHS, const KnownBits &RHS);
+ static std::optional<bool> sge(const KnownBits &LHS, const KnownBits &RHS);
/// Determine if these known bits always give the same ICMP_SLT result.
- static Optional<bool> slt(const KnownBits &LHS, const KnownBits &RHS);
+ static std::optional<bool> slt(const KnownBits &LHS, const KnownBits &RHS);
/// Determine if these known bits always give the same ICMP_SLE result.
- static Optional<bool> sle(const KnownBits &LHS, const KnownBits &RHS);
+ static std::optional<bool> sle(const KnownBits &LHS, const KnownBits &RHS);
/// Update known bits based on ANDing with RHS.
KnownBits &operator&=(const KnownBits &RHS);
diff --git a/llvm/include/llvm/Support/LockFileManager.h b/llvm/include/llvm/Support/LockFileManager.h
index ab66621..92c7cee 100644
--- a/llvm/include/llvm/Support/LockFileManager.h
+++ b/llvm/include/llvm/Support/LockFileManager.h
@@ -8,8 +8,8 @@
#ifndef LLVM_SUPPORT_LOCKFILEMANAGER_H
#define LLVM_SUPPORT_LOCKFILEMANAGER_H
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallString.h"
+#include <optional>
#include <system_error>
#include <utility> // for std::pair
@@ -54,14 +54,14 @@ private:
SmallString<128> LockFileName;
SmallString<128> UniqueLockFileName;
- Optional<std::pair<std::string, int> > Owner;
+ std::optional<std::pair<std::string, int>> Owner;
std::error_code ErrorCode;
std::string ErrorDiagMsg;
LockFileManager(const LockFileManager &) = delete;
LockFileManager &operator=(const LockFileManager &) = delete;
- static Optional<std::pair<std::string, int> >
+ static std::optional<std::pair<std::string, int>>
readLockFile(StringRef LockFileName);
static bool processStillExecuting(StringRef Hostname, int PID);
diff --git a/llvm/include/llvm/Support/MemoryBuffer.h b/llvm/include/llvm/Support/MemoryBuffer.h
index d6ae98e..b3477f1d 100644
--- a/llvm/include/llvm/Support/MemoryBuffer.h
+++ b/llvm/include/llvm/Support/MemoryBuffer.h
@@ -97,7 +97,7 @@ public:
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getFile(const Twine &Filename, bool IsText = false,
bool RequiresNullTerminator = true, bool IsVolatile = false,
- Optional<Align> Alignment = std::nullopt);
+ std::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 @@ public:
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 = std::nullopt);
+ std::optional<Align> Alignment = std::nullopt);
/// Given an already-open file descriptor, read the file and return a
/// MemoryBuffer.
@@ -125,7 +125,7 @@ public:
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 = std::nullopt);
+ std::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,13 +149,13 @@ public:
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getFileOrSTDIN(const Twine &Filename, bool IsText = false,
bool RequiresNullTerminator = true,
- Optional<Align> Alignment = std::nullopt);
+ std::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 = std::nullopt);
+ std::optional<Align> Alignment = std::nullopt);
//===--------------------------------------------------------------------===//
// Provided for performance analysis.
@@ -201,13 +201,13 @@ public:
static ErrorOr<std::unique_ptr<WritableMemoryBuffer>>
getFile(const Twine &Filename, bool IsVolatile = false,
- Optional<Align> Alignment = std::nullopt);
+ std::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 = std::nullopt);
+ std::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
@@ -217,7 +217,7 @@ public:
/// least the specified alignment.
static std::unique_ptr<WritableMemoryBuffer>
getNewUninitMemBuffer(size_t Size, const Twine &BufferName = "",
- Optional<Align> Alignment = std::nullopt);
+ std::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 f94b017..6fc1ee8 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 = std::nullopt);
+ std::optional<size_t> Width = std::nullopt);
void write_double(raw_ostream &S, double D, FloatStyle Style,
- Optional<size_t> Precision = std::nullopt);
+ std::optional<size_t> Precision = std::nullopt);
}
#endif
diff --git a/llvm/include/llvm/Support/SMTAPI.h b/llvm/include/llvm/Support/SMTAPI.h
index 24dcd12..9389c96 100644
--- a/llvm/include/llvm/Support/SMTAPI.h
+++ b/llvm/include/llvm/Support/SMTAPI.h
@@ -419,7 +419,7 @@ public:
llvm::APFloat &Float) = 0;
/// Check if the constraints are satisfiable
- virtual Optional<bool> check() const = 0;
+ virtual std::optional<bool> check() const = 0;
/// Push the current solver state
virtual void push() = 0;
diff --git a/llvm/include/llvm/Support/Unicode.h b/llvm/include/llvm/Support/Unicode.h
index 7297754..8615487 100644
--- a/llvm/include/llvm/Support/Unicode.h
+++ b/llvm/include/llvm/Support/Unicode.h
@@ -14,8 +14,8 @@
#ifndef LLVM_SUPPORT_UNICODE_H
#define LLVM_SUPPORT_UNICODE_H
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallString.h"
+#include <optional>
#include <string>
namespace llvm {
@@ -67,14 +67,14 @@ int foldCharSimple(int C);
/// For compatibility with the semantics of named character escape sequences in
/// C++, this mapping does an exact match sensitive to casing and spacing.
/// \return The codepoint of the corresponding character, if any.
-Optional<char32_t> nameToCodepointStrict(StringRef Name);
+std::optional<char32_t> nameToCodepointStrict(StringRef Name);
struct LooseMatchingResult {
char32_t CodePoint;
SmallString<64> Name;
};
-Optional<LooseMatchingResult> nameToCodepointLooseMatching(StringRef Name);
+std::optional<LooseMatchingResult> nameToCodepointLooseMatching(StringRef Name);
struct MatchForCodepointName {
std::string Name;
diff --git a/llvm/include/llvm/Support/VersionTuple.h b/llvm/include/llvm/Support/VersionTuple.h
index a525fbe..1483252 100644
--- a/llvm/include/llvm/Support/VersionTuple.h
+++ b/llvm/include/llvm/Support/VersionTuple.h
@@ -72,21 +72,21 @@ public:
unsigned getMajor() const { return Major; }
/// Retrieve the minor version number, if provided.
- Optional<unsigned> getMinor() const {
+ std::optional<unsigned> getMinor() const {
if (!HasMinor)
return std::nullopt;
return Minor;
}
/// Retrieve the subminor version number, if provided.
- Optional<unsigned> getSubminor() const {
+ std::optional<unsigned> getSubminor() const {
if (!HasSubminor)
return std::nullopt;
return Subminor;
}
/// Retrieve the build version number, if provided.
- Optional<unsigned> getBuild() const {
+ std::optional<unsigned> getBuild() const {
if (!HasBuild)
return std::nullopt;
return Build;
diff --git a/llvm/include/llvm/Support/VirtualFileSystem.h b/llvm/include/llvm/Support/VirtualFileSystem.h
index a2ce22e..295ed63 100644
--- a/llvm/include/llvm/Support/VirtualFileSystem.h
+++ b/llvm/include/llvm/Support/VirtualFileSystem.h
@@ -509,9 +509,9 @@ class InMemoryFileSystem : public FileSystem {
/// Create node with \p MakeNode and add it into this filesystem at \p Path.
bool addFile(const Twine &Path, time_t ModificationTime,
std::unique_ptr<llvm::MemoryBuffer> Buffer,
- Optional<uint32_t> User, Optional<uint32_t> Group,
- Optional<llvm::sys::fs::file_type> Type,
- Optional<llvm::sys::fs::perms> Perms, MakeNodeFn MakeNode);
+ std::optional<uint32_t> User, std::optional<uint32_t> Group,
+ std::optional<llvm::sys::fs::file_type> Type,
+ std::optional<llvm::sys::fs::perms> Perms, MakeNodeFn MakeNode);
/// Looks up the in-memory node for the path \p P.
/// If \p FollowFinalSymlink is true, the returned node is guaranteed to
@@ -533,10 +533,10 @@ public:
/// different contents.
bool addFile(const Twine &Path, time_t ModificationTime,
std::unique_ptr<llvm::MemoryBuffer> Buffer,
- 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::optional<uint32_t> User = std::nullopt,
+ std::optional<uint32_t> Group = std::nullopt,
+ std::optional<llvm::sys::fs::file_type> Type = std::nullopt,
+ std::optional<llvm::sys::fs::perms> Perms = std::nullopt);
/// Add a hard link to a file.
///
@@ -561,11 +561,12 @@ public:
/// Add a symbolic link. Unlike a HardLink, because \p Target doesn't need
/// 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 = std::nullopt,
- Optional<uint32_t> Group = std::nullopt,
- Optional<llvm::sys::fs::perms> Perms = std::nullopt);
+ bool
+ addSymbolicLink(const Twine &NewLink, const Twine &Target,
+ time_t ModificationTime,
+ std::optional<uint32_t> User = std::nullopt,
+ std::optional<uint32_t> Group = std::nullopt,
+ std::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
@@ -575,10 +576,10 @@ public:
/// different contents.
bool addFileNoOwn(const Twine &Path, time_t ModificationTime,
const llvm::MemoryBufferRef &Buffer,
- 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::optional<uint32_t> User = std::nullopt,
+ std::optional<uint32_t> Group = std::nullopt,
+ std::optional<llvm::sys::fs::file_type> Type = std::nullopt,
+ std::optional<llvm::sys::fs::perms> Perms = std::nullopt);
std::string toString() const;
@@ -858,7 +859,7 @@ public:
/// When the found Entry is a DirectoryRemapEntry, stores the path in the
/// external file system that the looked-up path in the virtual file system
// corresponds to.
- Optional<std::string> ExternalRedirect;
+ std::optional<std::string> ExternalRedirect;
public:
LookupResult(Entry *E, sys::path::const_iterator Start,
@@ -867,7 +868,7 @@ public:
/// If the found Entry maps the the input path to a path in the external
/// file system (i.e. it is a FileEntry or DirectoryRemapEntry), returns
/// that path.
- Optional<StringRef> getExternalRedirect() const {
+ std::optional<StringRef> getExternalRedirect() const {
if (isa<DirectoryRemapEntry>(E))
return StringRef(*ExternalRedirect);
if (auto *FE = dyn_cast<FileEntry>(E))
@@ -1016,9 +1017,9 @@ void collectVFSFromYAML(
class YAMLVFSWriter {
std::vector<YAMLVFSEntry> Mappings;
- Optional<bool> IsCaseSensitive;
- Optional<bool> IsOverlayRelative;
- Optional<bool> UseExternalNames;
+ std::optional<bool> IsCaseSensitive;
+ std::optional<bool> IsOverlayRelative;
+ std::optional<bool> UseExternalNames;
std::string OverlayDir;
void addEntry(StringRef VirtualPath, StringRef RealPath, bool IsDirectory);
diff --git a/llvm/include/llvm/Support/thread.h b/llvm/include/llvm/Support/thread.h
index 660d315..32599b9 100644
--- a/llvm/include/llvm/Support/thread.h
+++ b/llvm/include/llvm/Support/thread.h
@@ -16,8 +16,8 @@
#ifndef LLVM_SUPPORT_THREAD_H
#define LLVM_SUPPORT_THREAD_H
-#include "llvm/ADT/Optional.h"
#include "llvm/Config/llvm-config.h"
+#include <optional>
#ifdef _WIN32
typedef unsigned long DWORD;
@@ -72,7 +72,7 @@ public:
}
#endif
- static const llvm::Optional<unsigned> DefaultStackSize;
+ static const std::optional<unsigned> DefaultStackSize;
thread() : Thread(native_handle_type()) {}
thread(thread &&Other) noexcept
@@ -83,7 +83,7 @@ public:
: thread(DefaultStackSize, f, args...) {}
template <class Function, class... Args>
- explicit thread(llvm::Optional<unsigned> StackSizeInBytes, Function &&f,
+ explicit thread(std::optional<unsigned> StackSizeInBytes, Function &&f,
Args &&...args);
thread(const thread &) = delete;
@@ -120,14 +120,14 @@ private:
thread::native_handle_type
llvm_execute_on_thread_impl(thread::start_routine_type ThreadFunc, void *Arg,
- llvm::Optional<unsigned> StackSizeInBytes);
+ std::optional<unsigned> StackSizeInBytes);
void llvm_thread_join_impl(thread::native_handle_type Thread);
void llvm_thread_detach_impl(thread::native_handle_type Thread);
thread::id llvm_thread_get_id_impl(thread::native_handle_type Thread);
thread::id llvm_thread_get_current_id_impl();
template <class Function, class... Args>
-thread::thread(llvm::Optional<unsigned> StackSizeInBytes, Function &&f,
+thread::thread(std::optional<unsigned> StackSizeInBytes, Function &&f,
Args &&...args) {
typedef std::tuple<std::decay_t<Function>, std::decay_t<Args>...> CalleeTuple;
std::unique_ptr<CalleeTuple> Callee(
@@ -171,7 +171,7 @@ public:
: Thread(std::exchange(Other.Thread, std::thread())) {}
template <class Function, class... Args>
- explicit thread(llvm::Optional<unsigned> StackSizeInBytes, Function &&f,
+ explicit thread(std::optional<unsigned> StackSizeInBytes, Function &&f,
Args &&...args)
: Thread(std::forward<Function>(f), std::forward<Args>(args)...) {}
@@ -224,7 +224,7 @@ struct thread {
thread() {}
thread(thread &&other) {}
template <class Function, class... Args>
- explicit thread(llvm::Optional<unsigned> StackSizeInBytes, Function &&f,
+ explicit thread(std::optional<unsigned> StackSizeInBytes, Function &&f,
Args &&...args) {
f(std::forward<Args>(args)...);
}
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index c5d5d68..5ff3dd2 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -4216,7 +4216,7 @@ bool CombinerHelper::matchICmpToTrueFalseKnownBits(MachineInstr &MI,
auto Pred = static_cast<CmpInst::Predicate>(MI.getOperand(1).getPredicate());
auto KnownLHS = KB->getKnownBits(MI.getOperand(2).getReg());
auto KnownRHS = KB->getKnownBits(MI.getOperand(3).getReg());
- Optional<bool> KnownVal;
+ std::optional<bool> KnownVal;
switch (Pred) {
default:
llvm_unreachable("Unexpected G_ICMP predicate?");
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index a0e7705..a7716e8 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -2103,9 +2103,9 @@ bool TargetLowering::SimplifyDemandedBits(
KnownBits Known0 = TLO.DAG.computeKnownBits(Op0, DemandedElts, Depth + 1);
KnownBits Known1 = TLO.DAG.computeKnownBits(Op1, DemandedElts, Depth + 1);
Known = KnownBits::umin(Known0, Known1);
- if (Optional<bool> IsULE = KnownBits::ule(Known0, Known1))
+ if (std::optional<bool> IsULE = KnownBits::ule(Known0, Known1))
return TLO.CombineTo(Op, IsULE.value() ? Op0 : Op1);
- if (Optional<bool> IsULT = KnownBits::ult(Known0, Known1))
+ if (std::optional<bool> IsULT = KnownBits::ult(Known0, Known1))
return TLO.CombineTo(Op, IsULT.value() ? Op0 : Op1);
break;
}
@@ -2116,9 +2116,9 @@ bool TargetLowering::SimplifyDemandedBits(
KnownBits Known0 = TLO.DAG.computeKnownBits(Op0, DemandedElts, Depth + 1);
KnownBits Known1 = TLO.DAG.computeKnownBits(Op1, DemandedElts, Depth + 1);
Known = KnownBits::umax(Known0, Known1);
- if (Optional<bool> IsUGE = KnownBits::uge(Known0, Known1))
+ if (std::optional<bool> IsUGE = KnownBits::uge(Known0, Known1))
return TLO.CombineTo(Op, IsUGE.value() ? Op0 : Op1);
- if (Optional<bool> IsUGT = KnownBits::ugt(Known0, Known1))
+ if (std::optional<bool> IsUGT = KnownBits::ugt(Known0, Known1))
return TLO.CombineTo(Op, IsUGT.value() ? Op0 : Op1);
break;
}
diff --git a/llvm/lib/Support/BinaryStreamRef.cpp b/llvm/lib/Support/BinaryStreamRef.cpp
index 6d79d95..06b4999 100644
--- a/llvm/lib/Support/BinaryStreamRef.cpp
+++ b/llvm/lib/Support/BinaryStreamRef.cpp
@@ -67,7 +67,7 @@ private:
BinaryStreamRef::BinaryStreamRef(BinaryStream &Stream)
: BinaryStreamRefBase(Stream) {}
BinaryStreamRef::BinaryStreamRef(BinaryStream &Stream, uint64_t Offset,
- Optional<uint64_t> Length)
+ std::optional<uint64_t> Length)
: BinaryStreamRefBase(Stream, Offset, Length) {}
BinaryStreamRef::BinaryStreamRef(ArrayRef<uint8_t> Data, endianness Endian)
: BinaryStreamRefBase(std::make_shared<ArrayRefImpl>(Data, Endian), 0,
@@ -105,7 +105,7 @@ WritableBinaryStreamRef::WritableBinaryStreamRef(WritableBinaryStream &Stream)
WritableBinaryStreamRef::WritableBinaryStreamRef(WritableBinaryStream &Stream,
uint64_t Offset,
- Optional<uint64_t> Length)
+ std::optional<uint64_t> Length)
: BinaryStreamRefBase(Stream, Offset, Length) {}
WritableBinaryStreamRef::WritableBinaryStreamRef(MutableArrayRef<uint8_t> Data,
diff --git a/llvm/lib/Support/CrashRecoveryContext.cpp b/llvm/lib/Support/CrashRecoveryContext.cpp
index 7fe09eb9..c7c384c 100644
--- a/llvm/lib/Support/CrashRecoveryContext.cpp
+++ b/llvm/lib/Support/CrashRecoveryContext.cpp
@@ -519,7 +519,7 @@ bool CrashRecoveryContext::RunSafelyOnThread(function_ref<void()> Fn,
RunSafelyOnThreadInfo Info = { Fn, this, UseBackgroundPriority, false };
llvm::thread Thread(RequestedStackSize == 0
? std::nullopt
- : llvm::Optional<unsigned>(RequestedStackSize),
+ : std::optional<unsigned>(RequestedStackSize),
RunSafelyOnThread_Dispatch, &Info);
Thread.join();
diff --git a/llvm/lib/Support/DJB.cpp b/llvm/lib/Support/DJB.cpp
index 2701d5d..b9d159c 100644
--- a/llvm/lib/Support/DJB.cpp
+++ b/llvm/lib/Support/DJB.cpp
@@ -57,7 +57,8 @@ static UTF32 foldCharDwarf(UTF32 C) {
return sys::unicode::foldCharSimple(C);
}
-static Optional<uint32_t> fastCaseFoldingDjbHash(StringRef Buffer, uint32_t H) {
+static std::optional<uint32_t> fastCaseFoldingDjbHash(StringRef Buffer,
+ uint32_t H) {
bool AllASCII = true;
for (unsigned char C : Buffer) {
H = H * 33 + ('A' <= C && C <= 'Z' ? C - 'A' + 'a' : C);
@@ -69,7 +70,7 @@ static Optional<uint32_t> fastCaseFoldingDjbHash(StringRef Buffer, uint32_t H) {
}
uint32_t llvm::caseFoldingDjbHash(StringRef Buffer, uint32_t H) {
- if (Optional<uint32_t> Result = fastCaseFoldingDjbHash(Buffer, H))
+ if (std::optional<uint32_t> Result = fastCaseFoldingDjbHash(Buffer, H))
return *Result;
std::array<UTF8, UNI_MAX_UTF8_BYTES_PER_CODE_POINT> Storage;
diff --git a/llvm/lib/Support/FileUtilities.cpp b/llvm/lib/Support/FileUtilities.cpp
index 24960cc..d01a41a 100644
--- a/llvm/lib/Support/FileUtilities.cpp
+++ b/llvm/lib/Support/FileUtilities.cpp
@@ -341,7 +341,7 @@ FilePermissionsApplier::create(StringRef InputFilename) {
Error FilePermissionsApplier::apply(
StringRef OutputFilename, bool CopyDates,
- Optional<sys::fs::perms> OverwritePermissions) {
+ std::optional<sys::fs::perms> OverwritePermissions) {
sys::fs::file_status Status = InputStatus;
if (OverwritePermissions)
diff --git a/llvm/lib/Support/FormatVariadic.cpp b/llvm/lib/Support/FormatVariadic.cpp
index 169cea4..10de7f1 100644
--- a/llvm/lib/Support/FormatVariadic.cpp
+++ b/llvm/lib/Support/FormatVariadic.cpp
@@ -55,7 +55,7 @@ bool formatv_object_base::consumeFieldLayout(StringRef &Spec, AlignStyle &Where,
return !Failed;
}
-Optional<ReplacementItem>
+std::optional<ReplacementItem>
formatv_object_base::parseReplacementItem(StringRef Spec) {
StringRef RepString = Spec.trim("{}");
diff --git a/llvm/lib/Support/KnownBits.cpp b/llvm/lib/Support/KnownBits.cpp
index c62a1a3..745c46f 100644
--- a/llvm/lib/Support/KnownBits.cpp
+++ b/llvm/lib/Support/KnownBits.cpp
@@ -330,65 +330,65 @@ KnownBits KnownBits::ashr(const KnownBits &LHS, const KnownBits &RHS) {
return Known;
}
-Optional<bool> KnownBits::eq(const KnownBits &LHS, const KnownBits &RHS) {
+std::optional<bool> KnownBits::eq(const KnownBits &LHS, const KnownBits &RHS) {
if (LHS.isConstant() && RHS.isConstant())
- return Optional<bool>(LHS.getConstant() == RHS.getConstant());
+ return std::optional<bool>(LHS.getConstant() == RHS.getConstant());
if (LHS.One.intersects(RHS.Zero) || RHS.One.intersects(LHS.Zero))
- return Optional<bool>(false);
+ return std::optional<bool>(false);
return std::nullopt;
}
-Optional<bool> KnownBits::ne(const KnownBits &LHS, const KnownBits &RHS) {
- if (Optional<bool> KnownEQ = eq(LHS, RHS))
- return Optional<bool>(!*KnownEQ);
+std::optional<bool> KnownBits::ne(const KnownBits &LHS, const KnownBits &RHS) {
+ if (std::optional<bool> KnownEQ = eq(LHS, RHS))
+ return std::optional<bool>(!*KnownEQ);
return std::nullopt;
}
-Optional<bool> KnownBits::ugt(const KnownBits &LHS, const KnownBits &RHS) {
+std::optional<bool> KnownBits::ugt(const KnownBits &LHS, const KnownBits &RHS) {
// LHS >u RHS -> false if umax(LHS) <= umax(RHS)
if (LHS.getMaxValue().ule(RHS.getMinValue()))
- return Optional<bool>(false);
+ return std::optional<bool>(false);
// LHS >u RHS -> true if umin(LHS) > umax(RHS)
if (LHS.getMinValue().ugt(RHS.getMaxValue()))
- return Optional<bool>(true);
+ return std::optional<bool>(true);
return std::nullopt;
}
-Optional<bool> KnownBits::uge(const KnownBits &LHS, const KnownBits &RHS) {
- if (Optional<bool> IsUGT = ugt(RHS, LHS))
- return Optional<bool>(!*IsUGT);
+std::optional<bool> KnownBits::uge(const KnownBits &LHS, const KnownBits &RHS) {
+ if (std::optional<bool> IsUGT = ugt(RHS, LHS))
+ return std::optional<bool>(!*IsUGT);
return std::nullopt;
}
-Optional<bool> KnownBits::ult(const KnownBits &LHS, const KnownBits &RHS) {
+std::optional<bool> KnownBits::ult(const KnownBits &LHS, const KnownBits &RHS) {
return ugt(RHS, LHS);
}
-Optional<bool> KnownBits::ule(const KnownBits &LHS, const KnownBits &RHS) {
+std::optional<bool> KnownBits::ule(const KnownBits &LHS, const KnownBits &RHS) {
return uge(RHS, LHS);
}
-Optional<bool> KnownBits::sgt(const KnownBits &LHS, const KnownBits &RHS) {
+std::optional<bool> KnownBits::sgt(const KnownBits &LHS, const KnownBits &RHS) {
// LHS >s RHS -> false if smax(LHS) <= smax(RHS)
if (LHS.getSignedMaxValue().sle(RHS.getSignedMinValue()))
- return Optional<bool>(false);
+ return std::optional<bool>(false);
// LHS >s RHS -> true if smin(LHS) > smax(RHS)
if (LHS.getSignedMinValue().sgt(RHS.getSignedMaxValue()))
- return Optional<bool>(true);
+ return std::optional<bool>(true);
return std::nullopt;
}
-Optional<bool> KnownBits::sge(const KnownBits &LHS, const KnownBits &RHS) {
- if (Optional<bool> KnownSGT = sgt(RHS, LHS))
- return Optional<bool>(!*KnownSGT);
+std::optional<bool> KnownBits::sge(const KnownBits &LHS, const KnownBits &RHS) {
+ if (std::optional<bool> KnownSGT = sgt(RHS, LHS))
+ return std::optional<bool>(!*KnownSGT);
return std::nullopt;
}
-Optional<bool> KnownBits::slt(const KnownBits &LHS, const KnownBits &RHS) {
+std::optional<bool> KnownBits::slt(const KnownBits &LHS, const KnownBits &RHS) {
return sgt(RHS, LHS);
}
-Optional<bool> KnownBits::sle(const KnownBits &LHS, const KnownBits &RHS) {
+std::optional<bool> KnownBits::sle(const KnownBits &LHS, const KnownBits &RHS) {
return sge(RHS, LHS);
}
diff --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp
index 9059473..b64d483 100644
--- a/llvm/lib/Support/LockFileManager.cpp
+++ b/llvm/lib/Support/LockFileManager.cpp
@@ -51,7 +51,7 @@ using namespace llvm;
/// \param LockFileName The name of the lock file to read.
///
/// \returns The process ID of the process that owns this lock file
-Optional<std::pair<std::string, int> >
+std::optional<std::pair<std::string, int>>
LockFileManager::readLockFile(StringRef LockFileName) {
// Read the owning host and PID out of the lock file. If it appears that the
// owning process is dead, the lock file is invalid.
diff --git a/llvm/lib/Support/MemoryBuffer.cpp b/llvm/lib/Support/MemoryBuffer.cpp
index 77c509c..0bb1172 100644
--- a/llvm/lib/Support/MemoryBuffer.cpp
+++ b/llvm/lib/Support/MemoryBuffer.cpp
@@ -114,7 +114,7 @@ template <typename MB>
static ErrorOr<std::unique_ptr<MB>>
getFileAux(const Twine &Filename, uint64_t MapSize, uint64_t Offset,
bool IsText, bool RequiresNullTerminator, bool IsVolatile,
- Optional<Align> Alignment);
+ std::optional<Align> Alignment);
std::unique_ptr<MemoryBuffer>
MemoryBuffer::getMemBuffer(StringRef InputData, StringRef BufferName,
@@ -150,7 +150,7 @@ MemoryBuffer::getMemBufferCopy(StringRef InputData, const Twine &BufferName) {
ErrorOr<std::unique_ptr<MemoryBuffer>>
MemoryBuffer::getFileOrSTDIN(const Twine &Filename, bool IsText,
bool RequiresNullTerminator,
- Optional<Align> Alignment) {
+ std::optional<Align> Alignment) {
SmallString<256> NameBuf;
StringRef NameRef = Filename.toStringRef(NameBuf);
@@ -163,7 +163,7 @@ MemoryBuffer::getFileOrSTDIN(const Twine &Filename, bool IsText,
ErrorOr<std::unique_ptr<MemoryBuffer>>
MemoryBuffer::getFileSlice(const Twine &FilePath, uint64_t MapSize,
uint64_t Offset, bool IsVolatile,
- Optional<Align> Alignment) {
+ std::optional<Align> Alignment) {
return getFileAux<MemoryBuffer>(FilePath, MapSize, Offset, /*IsText=*/false,
/*RequiresNullTerminator=*/false, IsVolatile,
Alignment);
@@ -247,7 +247,7 @@ getMemoryBufferForStream(sys::fs::file_t FD, const Twine &BufferName) {
ErrorOr<std::unique_ptr<MemoryBuffer>>
MemoryBuffer::getFile(const Twine &Filename, bool IsText,
bool RequiresNullTerminator, bool IsVolatile,
- Optional<Align> Alignment) {
+ std::optional<Align> Alignment) {
return getFileAux<MemoryBuffer>(Filename, /*MapSize=*/-1, /*Offset=*/0,
IsText, RequiresNullTerminator, IsVolatile,
Alignment);
@@ -257,13 +257,13 @@ template <typename MB>
static ErrorOr<std::unique_ptr<MB>>
getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize,
uint64_t MapSize, int64_t Offset, bool RequiresNullTerminator,
- bool IsVolatile, Optional<Align> Alignment);
+ bool IsVolatile, std::optional<Align> Alignment);
template <typename MB>
static ErrorOr<std::unique_ptr<MB>>
getFileAux(const Twine &Filename, uint64_t MapSize, uint64_t Offset,
bool IsText, bool RequiresNullTerminator, bool IsVolatile,
- Optional<Align> Alignment) {
+ std::optional<Align> Alignment) {
Expected<sys::fs::file_t> FDOrErr = sys::fs::openNativeFileForRead(
Filename, IsText ? sys::fs::OF_TextWithCRLF : sys::fs::OF_None);
if (!FDOrErr)
@@ -277,7 +277,7 @@ getFileAux(const Twine &Filename, uint64_t MapSize, uint64_t Offset,
ErrorOr<std::unique_ptr<WritableMemoryBuffer>>
WritableMemoryBuffer::getFile(const Twine &Filename, bool IsVolatile,
- Optional<Align> Alignment) {
+ std::optional<Align> Alignment) {
return getFileAux<WritableMemoryBuffer>(
Filename, /*MapSize=*/-1, /*Offset=*/0, /*IsText=*/false,
/*RequiresNullTerminator=*/false, IsVolatile, Alignment);
@@ -286,7 +286,7 @@ WritableMemoryBuffer::getFile(const Twine &Filename, bool IsVolatile,
ErrorOr<std::unique_ptr<WritableMemoryBuffer>>
WritableMemoryBuffer::getFileSlice(const Twine &Filename, uint64_t MapSize,
uint64_t Offset, bool IsVolatile,
- Optional<Align> Alignment) {
+ std::optional<Align> Alignment) {
return getFileAux<WritableMemoryBuffer>(
Filename, MapSize, Offset, /*IsText=*/false,
/*RequiresNullTerminator=*/false, IsVolatile, Alignment);
@@ -295,7 +295,7 @@ WritableMemoryBuffer::getFileSlice(const Twine &Filename, uint64_t MapSize,
std::unique_ptr<WritableMemoryBuffer>
WritableMemoryBuffer::getNewUninitMemBuffer(size_t Size,
const Twine &BufferName,
- Optional<Align> Alignment) {
+ std::optional<Align> Alignment) {
using MemBuffer = MemoryBufferMem<WritableMemoryBuffer>;
// Use 16-byte alignment if no alignment is specified.
@@ -447,7 +447,7 @@ template <typename MB>
static ErrorOr<std::unique_ptr<MB>>
getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize,
uint64_t MapSize, int64_t Offset, bool RequiresNullTerminator,
- bool IsVolatile, Optional<Align> Alignment) {
+ bool IsVolatile, std::optional<Align> Alignment) {
static int PageSize = sys::Process::getPageSizeEstimate();
// Default is to map the full file.
@@ -518,16 +518,15 @@ getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize,
ErrorOr<std::unique_ptr<MemoryBuffer>>
MemoryBuffer::getOpenFile(sys::fs::file_t FD, const Twine &Filename,
uint64_t FileSize, bool RequiresNullTerminator,
- bool IsVolatile, Optional<Align> Alignment) {
+ bool IsVolatile, std::optional<Align> Alignment) {
return getOpenFileImpl<MemoryBuffer>(FD, Filename, FileSize, FileSize, 0,
RequiresNullTerminator, IsVolatile,
Alignment);
}
-ErrorOr<std::unique_ptr<MemoryBuffer>>
-MemoryBuffer::getOpenFileSlice(sys::fs::file_t FD, const Twine &Filename,
- uint64_t MapSize, int64_t Offset,
- bool IsVolatile, Optional<Align> Alignment) {
+ErrorOr<std::unique_ptr<MemoryBuffer>> MemoryBuffer::getOpenFileSlice(
+ sys::fs::file_t FD, const Twine &Filename, uint64_t MapSize, int64_t Offset,
+ bool IsVolatile, std::optional<Align> Alignment) {
assert(MapSize != uint64_t(-1));
return getOpenFileImpl<MemoryBuffer>(FD, Filename, -1, MapSize, Offset, false,
IsVolatile, Alignment);
diff --git a/llvm/lib/Support/NativeFormatting.cpp b/llvm/lib/Support/NativeFormatting.cpp
index ee2d885..fb02de7 100644
--- a/llvm/lib/Support/NativeFormatting.cpp
+++ b/llvm/lib/Support/NativeFormatting.cpp
@@ -136,7 +136,7 @@ void llvm::write_integer(raw_ostream &S, long long N, size_t MinDigits,
}
void llvm::write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style,
- Optional<size_t> Width) {
+ std::optional<size_t> Width) {
const size_t kMaxWidth = 128u;
size_t W = std::min(kMaxWidth, Width.value_or(0u));
@@ -166,7 +166,7 @@ void llvm::write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style,
}
void llvm::write_double(raw_ostream &S, double N, FloatStyle Style,
- Optional<size_t> Precision) {
+ std::optional<size_t> Precision) {
size_t Prec = Precision.value_or(getDefaultPrecision(Style));
if (std::isnan(N)) {
diff --git a/llvm/lib/Support/OptimizedStructLayout.cpp b/llvm/lib/Support/OptimizedStructLayout.cpp
index 8f04311..c64eff6 100644
--- a/llvm/lib/Support/OptimizedStructLayout.cpp
+++ b/llvm/lib/Support/OptimizedStructLayout.cpp
@@ -346,9 +346,8 @@ llvm::performOptimizedStructLayout(MutableArrayRef<Field> Fields) {
// Helper function to try to find a field in the given queue that'll
// fit starting at StartOffset but before EndOffset (if present).
// Note that this never fails if EndOffset is not provided.
- auto tryAddFillerFromQueue = [&](AlignmentQueue *Queue,
- uint64_t StartOffset,
- Optional<uint64_t> EndOffset) -> bool {
+ auto tryAddFillerFromQueue = [&](AlignmentQueue *Queue, uint64_t StartOffset,
+ std::optional<uint64_t> EndOffset) -> bool {
assert(Queue->Head);
assert(StartOffset == alignTo(LastEnd, Queue->Alignment));
assert(!EndOffset || StartOffset < *EndOffset);
@@ -357,7 +356,8 @@ llvm::performOptimizedStructLayout(MutableArrayRef<Field> Fields) {
// queue if there's nothing in it that small.
auto MaxViableSize =
(EndOffset ? *EndOffset - StartOffset : ~(uint64_t)0);
- if (Queue->MinSize > MaxViableSize) return false;
+ if (Queue->MinSize > MaxViableSize)
+ return false;
// Find the matching field. Note that this should always find
// something because of the MinSize check above.
@@ -373,7 +373,7 @@ llvm::performOptimizedStructLayout(MutableArrayRef<Field> Fields) {
// Helper function to find the "best" flexible-offset field according
// to the criteria described above.
- auto tryAddBestField = [&](Optional<uint64_t> BeforeOffset) -> bool {
+ auto tryAddBestField = [&](std::optional<uint64_t> BeforeOffset) -> bool {
assert(!BeforeOffset || LastEnd < *BeforeOffset);
auto QueueB = FlexibleFieldsByAlignment.begin();
auto QueueE = FlexibleFieldsByAlignment.end();
diff --git a/llvm/lib/Support/SymbolRemappingReader.cpp b/llvm/lib/Support/SymbolRemappingReader.cpp
index 3cae577..0082696 100644
--- a/llvm/lib/Support/SymbolRemappingReader.cpp
+++ b/llvm/lib/Support/SymbolRemappingReader.cpp
@@ -48,11 +48,11 @@ Error SymbolRemappingReader::read(MemoryBuffer &B) {
"found '" + Line + "'");
using FK = ItaniumManglingCanonicalizer::FragmentKind;
- Optional<FK> FragmentKind = StringSwitch<Optional<FK>>(Parts[0])
- .Case("name", FK::Name)
- .Case("type", FK::Type)
- .Case("encoding", FK::Encoding)
- .Default(std::nullopt);
+ std::optional<FK> FragmentKind = StringSwitch<std::optional<FK>>(Parts[0])
+ .Case("name", FK::Name)
+ .Case("type", FK::Type)
+ .Case("encoding", FK::Encoding)
+ .Default(std::nullopt);
if (!FragmentKind)
return ReportError("Invalid kind, expected 'name', 'type', or 'encoding',"
" found '" + Parts[0] + "'");
diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp
index 24962ae..f4e3331 100644
--- a/llvm/lib/Support/Threading.cpp
+++ b/llvm/lib/Support/Threading.cpp
@@ -82,9 +82,9 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
// which is not enough for some/many normal LLVM compilations. This implements
// the same interface as std::thread but requests the same stack size as the
// main thread (8MB) before creation.
-const llvm::Optional<unsigned> llvm::thread::DefaultStackSize = 8 * 1024 * 1024;
+const std::optional<unsigned> llvm::thread::DefaultStackSize = 8 * 1024 * 1024;
#else
-const llvm::Optional<unsigned> llvm::thread::DefaultStackSize;
+const std::optional<unsigned> llvm::thread::DefaultStackSize;
#endif
diff --git a/llvm/lib/Support/UnicodeNameToCodepoint.cpp b/llvm/lib/Support/UnicodeNameToCodepoint.cpp
index 5fb6125..a10a7e8 100644
--- a/llvm/lib/Support/UnicodeNameToCodepoint.cpp
+++ b/llvm/lib/Support/UnicodeNameToCodepoint.cpp
@@ -285,7 +285,7 @@ static std::size_t findSyllable(StringRef Name, bool Strict,
return size_t(Len);
}
-static llvm::Optional<char32_t>
+static std::optional<char32_t>
nameToHangulCodePoint(StringRef Name, bool Strict, BufferType &Buffer) {
Buffer.clear();
// Hangul Syllable Decomposition
@@ -343,7 +343,7 @@ static const GeneratedNamesData GeneratedNamesDataTable[] = {
{"CJK COMPATIBILITY IDEOGRAPH-", 0x2F800, 0x2FA1D},
};
-static llvm::Optional<char32_t>
+static std::optional<char32_t>
nameToGeneratedCodePoint(StringRef Name, bool Strict, BufferType &Buffer) {
for (auto &&Item : GeneratedNamesDataTable) {
Buffer.clear();
@@ -370,12 +370,12 @@ nameToGeneratedCodePoint(StringRef Name, bool Strict, BufferType &Buffer) {
return std::nullopt;
}
-static llvm::Optional<char32_t> nameToCodepoint(StringRef Name, bool Strict,
- BufferType &Buffer) {
+static std::optional<char32_t> nameToCodepoint(StringRef Name, bool Strict,
+ BufferType &Buffer) {
if (Name.empty())
return std::nullopt;
- llvm::Optional<char32_t> Res = nameToHangulCodePoint(Name, Strict, Buffer);
+ std::optional<char32_t> Res = nameToHangulCodePoint(Name, Strict, Buffer);
if (!Res)
Res = nameToGeneratedCodePoint(Name, Strict, Buffer);
if (Res)
@@ -400,14 +400,14 @@ static llvm::Optional<char32_t> nameToCodepoint(StringRef Name, bool Strict,
return std::nullopt;
}
-llvm::Optional<char32_t> nameToCodepointStrict(StringRef Name) {
+std::optional<char32_t> nameToCodepointStrict(StringRef Name) {
BufferType Buffer;
auto Opt = nameToCodepoint(Name, true, Buffer);
return Opt;
}
-llvm::Optional<LooseMatchingResult>
+std::optional<LooseMatchingResult>
nameToCodepointLooseMatching(StringRef Name) {
BufferType Buffer;
auto Opt = nameToCodepoint(Name, false, Buffer);
diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc
index def6afa..819748d 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -58,7 +58,7 @@
namespace llvm {
pthread_t
llvm_execute_on_thread_impl(void *(*ThreadFunc)(void *), void *Arg,
- llvm::Optional<unsigned> StackSizeInBytes) {
+ std::optional<unsigned> StackSizeInBytes) {
int errnum;
// Construct the attributes object.
diff --git a/llvm/lib/Support/VersionTuple.cpp b/llvm/lib/Support/VersionTuple.cpp
index 6a51648..c0e0072 100644
--- a/llvm/lib/Support/VersionTuple.cpp
+++ b/llvm/lib/Support/VersionTuple.cpp
@@ -29,11 +29,11 @@ std::string VersionTuple::getAsString() const {
raw_ostream &llvm::operator<<(raw_ostream &Out, const VersionTuple &V) {
Out << V.getMajor();
- if (Optional<unsigned> Minor = V.getMinor())
+ if (std::optional<unsigned> Minor = V.getMinor())
Out << '.' << *Minor;
- if (Optional<unsigned> Subminor = V.getSubminor())
+ if (std::optional<unsigned> Subminor = V.getSubminor())
Out << '.' << *Subminor;
- if (Optional<unsigned> Build = V.getBuild())
+ if (std::optional<unsigned> Build = V.getBuild())
Out << '.' << *Build;
return Out;
}
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index f210143..eac6fc9 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -814,10 +814,10 @@ std::string InMemoryFileSystem::toString() const {
bool InMemoryFileSystem::addFile(const Twine &P, time_t ModificationTime,
std::unique_ptr<llvm::MemoryBuffer> Buffer,
- Optional<uint32_t> User,
- Optional<uint32_t> Group,
- Optional<llvm::sys::fs::file_type> Type,
- Optional<llvm::sys::fs::perms> Perms,
+ std::optional<uint32_t> User,
+ std::optional<uint32_t> Group,
+ std::optional<llvm::sys::fs::file_type> Type,
+ std::optional<llvm::sys::fs::perms> Perms,
MakeNodeFn MakeNode) {
SmallString<128> Path;
P.toVector(Path);
@@ -891,10 +891,10 @@ bool InMemoryFileSystem::addFile(const Twine &P, time_t ModificationTime,
bool InMemoryFileSystem::addFile(const Twine &P, time_t ModificationTime,
std::unique_ptr<llvm::MemoryBuffer> Buffer,
- Optional<uint32_t> User,
- Optional<uint32_t> Group,
- Optional<llvm::sys::fs::file_type> Type,
- Optional<llvm::sys::fs::perms> Perms) {
+ std::optional<uint32_t> User,
+ std::optional<uint32_t> Group,
+ std::optional<llvm::sys::fs::file_type> Type,
+ std::optional<llvm::sys::fs::perms> Perms) {
return addFile(P, ModificationTime, std::move(Buffer), User, Group, Type,
Perms,
[](detail::NewInMemoryNodeInfo NNI)
@@ -907,12 +907,11 @@ bool InMemoryFileSystem::addFile(const Twine &P, time_t ModificationTime,
});
}
-bool InMemoryFileSystem::addFileNoOwn(const Twine &P, time_t ModificationTime,
- const llvm::MemoryBufferRef &Buffer,
- Optional<uint32_t> User,
- Optional<uint32_t> Group,
- Optional<llvm::sys::fs::file_type> Type,
- Optional<llvm::sys::fs::perms> Perms) {
+bool InMemoryFileSystem::addFileNoOwn(
+ const Twine &P, time_t ModificationTime,
+ const llvm::MemoryBufferRef &Buffer, std::optional<uint32_t> User,
+ std::optional<uint32_t> Group, std::optional<llvm::sys::fs::file_type> Type,
+ std::optional<llvm::sys::fs::perms> Perms) {
return addFile(P, ModificationTime, llvm::MemoryBuffer::getMemBuffer(Buffer),
std::move(User), std::move(Group), std::move(Type),
std::move(Perms),
@@ -1020,12 +1019,10 @@ bool InMemoryFileSystem::addHardLink(const Twine &NewLink,
});
}
-bool InMemoryFileSystem::addSymbolicLink(const Twine &NewLink,
- const Twine &Target,
- time_t ModificationTime,
- Optional<uint32_t> User,
- Optional<uint32_t> Group,
- Optional<llvm::sys::fs::perms> Perms) {
+bool InMemoryFileSystem::addSymbolicLink(
+ const Twine &NewLink, const Twine &Target, time_t ModificationTime,
+ std::optional<uint32_t> User, std::optional<uint32_t> Group,
+ std::optional<llvm::sys::fs::perms> Perms) {
auto NewLinkNode = lookupNode(NewLink, /*FollowFinalSymlink=*/false);
if (NewLinkNode)
return false;
@@ -2272,7 +2269,7 @@ static Status getRedirectedFileStatus(const Twine &OriginalPath,
ErrorOr<Status> RedirectingFileSystem::status(
const Twine &CanonicalPath, const Twine &OriginalPath,
const RedirectingFileSystem::LookupResult &Result) {
- if (Optional<StringRef> ExtRedirect = Result.getExternalRedirect()) {
+ if (std::optional<StringRef> ExtRedirect = Result.getExternalRedirect()) {
SmallString<256> CanonicalRemappedPath((*ExtRedirect).str());
if (std::error_code EC = makeCanonical(CanonicalRemappedPath))
return EC;
@@ -2603,9 +2600,10 @@ class JSONWriter {
public:
JSONWriter(llvm::raw_ostream &OS) : OS(OS) {}
- void write(ArrayRef<YAMLVFSEntry> Entries, Optional<bool> UseExternalNames,
- Optional<bool> IsCaseSensitive, Optional<bool> IsOverlayRelative,
- StringRef OverlayDir);
+ void write(ArrayRef<YAMLVFSEntry> Entries,
+ std::optional<bool> UseExternalNames,
+ std::optional<bool> IsCaseSensitive,
+ std::optional<bool> IsOverlayRelative, StringRef OverlayDir);
};
} // namespace
@@ -2660,9 +2658,9 @@ void JSONWriter::writeEntry(StringRef VPath, StringRef RPath) {
}
void JSONWriter::write(ArrayRef<YAMLVFSEntry> Entries,
- Optional<bool> UseExternalNames,
- Optional<bool> IsCaseSensitive,
- Optional<bool> IsOverlayRelative,
+ std::optional<bool> UseExternalNames,
+ std::optional<bool> IsCaseSensitive,
+ std::optional<bool> IsOverlayRelative,
StringRef OverlayDir) {
using namespace llvm::sys;
diff --git a/llvm/lib/Support/Windows/Threading.inc b/llvm/lib/Support/Windows/Threading.inc
index aaeda2f..2c16fe4 100644
--- a/llvm/lib/Support/Windows/Threading.inc
+++ b/llvm/lib/Support/Windows/Threading.inc
@@ -26,7 +26,7 @@
namespace llvm {
HANDLE
llvm_execute_on_thread_impl(unsigned(__stdcall *ThreadFunc)(void *), void *Arg,
- llvm::Optional<unsigned> StackSizeInBytes) {
+ std::optional<unsigned> StackSizeInBytes) {
HANDLE hThread = (HANDLE)::_beginthreadex(NULL, StackSizeInBytes.value_or(0),
ThreadFunc, Arg, 0, NULL);
diff --git a/llvm/lib/Support/Z3Solver.cpp b/llvm/lib/Support/Z3Solver.cpp
index 499548e..a49bedc 100644
--- a/llvm/lib/Support/Z3Solver.cpp
+++ b/llvm/lib/Support/Z3Solver.cpp
@@ -870,7 +870,7 @@ public:
return toAPFloat(Sort, Assign, Float, true);
}
- Optional<bool> check() const override {
+ std::optional<bool> check() const override {
Z3_lbool res = Z3_solver_check(Context.Context, Solver);
if (res == Z3_L_TRUE)
return true;
diff --git a/llvm/unittests/ADT/StatisticTest.cpp b/llvm/unittests/ADT/StatisticTest.cpp
index e4c1442..91bc7f2 100644
--- a/llvm/unittests/ADT/StatisticTest.cpp
+++ b/llvm/unittests/ADT/StatisticTest.cpp
@@ -11,7 +11,7 @@
#include "gtest/gtest.h"
using namespace llvm;
-using OptionalStatistic = Optional<std::pair<StringRef, uint64_t>>;
+using OptionalStatistic = std::optional<std::pair<StringRef, uint64_t>>;
namespace {
#define DEBUG_TYPE "unittest"
diff --git a/llvm/unittests/Support/Casting.cpp b/llvm/unittests/Support/Casting.cpp
index 8ccabae..ed05963 100644
--- a/llvm/unittests/Support/Casting.cpp
+++ b/llvm/unittests/Support/Casting.cpp
@@ -235,7 +235,7 @@ TEST(CastingTest, dyn_cast_or_null) {
TEST(CastingTest, dyn_cast_value_types) {
T1 t1;
- Optional<T2> t2 = dyn_cast<T2>(t1);
+ std::optional<T2> t2 = dyn_cast<T2>(t1);
EXPECT_TRUE(t2);
T2 *t2ptr = dyn_cast<T2>(&t1);
@@ -246,12 +246,12 @@ TEST(CastingTest, dyn_cast_value_types) {
}
TEST(CastingTest, dyn_cast_if_present) {
- Optional<T1> empty{};
- Optional<T2> F1 = dyn_cast_if_present<T2>(empty);
+ std::optional<T1> empty{};
+ std::optional<T2> F1 = dyn_cast_if_present<T2>(empty);
EXPECT_FALSE(F1.has_value());
T1 t1;
- Optional<T2> F2 = dyn_cast_if_present<T2>(t1);
+ std::optional<T2> F2 = dyn_cast_if_present<T2>(t1);
EXPECT_TRUE(F2.has_value());
T1 *t1Null = nullptr;
diff --git a/llvm/unittests/Support/ErrorTest.cpp b/llvm/unittests/Support/ErrorTest.cpp
index 16118a9..11f9320 100644
--- a/llvm/unittests/Support/ErrorTest.cpp
+++ b/llvm/unittests/Support/ErrorTest.cpp
@@ -1070,7 +1070,7 @@ static Error createAnyError() {
}
struct MoveOnlyBox {
- Optional<int> Box;
+ std::optional<int> Box;
explicit MoveOnlyBox(int I) : Box(I) {}
MoveOnlyBox() = default;
@@ -1117,7 +1117,7 @@ TEST(Error, moveInto) {
// Check that this works with optionals too.
{
// Same cases as above.
- Optional<MoveOnlyBox> MaybeV;
+ std::optional<MoveOnlyBox> MaybeV;
EXPECT_THAT_ERROR(makeFailure().moveInto(MaybeV), Failed());
EXPECT_EQ(std::nullopt, MaybeV);
diff --git a/llvm/unittests/Support/KnownBitsTest.cpp b/llvm/unittests/Support/KnownBitsTest.cpp
index 1d609e9..0c3d9df 100644
--- a/llvm/unittests/Support/KnownBitsTest.cpp
+++ b/llvm/unittests/Support/KnownBitsTest.cpp
@@ -347,16 +347,16 @@ TEST(KnownBitsTest, ICmpExhaustive) {
});
});
- Optional<bool> KnownEQ = KnownBits::eq(Known1, Known2);
- Optional<bool> KnownNE = KnownBits::ne(Known1, Known2);
- Optional<bool> KnownUGT = KnownBits::ugt(Known1, Known2);
- Optional<bool> KnownUGE = KnownBits::uge(Known1, Known2);
- Optional<bool> KnownULT = KnownBits::ult(Known1, Known2);
- Optional<bool> KnownULE = KnownBits::ule(Known1, Known2);
- Optional<bool> KnownSGT = KnownBits::sgt(Known1, Known2);
- Optional<bool> KnownSGE = KnownBits::sge(Known1, Known2);
- Optional<bool> KnownSLT = KnownBits::slt(Known1, Known2);
- Optional<bool> KnownSLE = KnownBits::sle(Known1, Known2);
+ std::optional<bool> KnownEQ = KnownBits::eq(Known1, Known2);
+ std::optional<bool> KnownNE = KnownBits::ne(Known1, Known2);
+ std::optional<bool> KnownUGT = KnownBits::ugt(Known1, Known2);
+ std::optional<bool> KnownUGE = KnownBits::uge(Known1, Known2);
+ std::optional<bool> KnownULT = KnownBits::ult(Known1, Known2);
+ std::optional<bool> KnownULE = KnownBits::ule(Known1, Known2);
+ std::optional<bool> KnownSGT = KnownBits::sgt(Known1, Known2);
+ std::optional<bool> KnownSGE = KnownBits::sge(Known1, Known2);
+ std::optional<bool> KnownSLT = KnownBits::slt(Known1, Known2);
+ std::optional<bool> KnownSLE = KnownBits::sle(Known1, Known2);
EXPECT_EQ(AllEQ || NoneEQ, KnownEQ.has_value());
EXPECT_EQ(AllNE || NoneNE, KnownNE.has_value());
diff --git a/llvm/unittests/Support/NativeFormatTests.cpp b/llvm/unittests/Support/NativeFormatTests.cpp
index 591a68f..197fad1 100644
--- a/llvm/unittests/Support/NativeFormatTests.cpp
+++ b/llvm/unittests/Support/NativeFormatTests.cpp
@@ -26,7 +26,7 @@ template <typename T> std::string format_number(T N, IntegerStyle Style) {
}
std::string format_number(uint64_t N, HexPrintStyle Style,
- Optional<size_t> Width = std::nullopt) {
+ std::optional<size_t> Width = std::nullopt) {
std::string S;
llvm::raw_string_ostream Str(S);
write_hex(Str, N, Style, Width);
@@ -35,7 +35,7 @@ std::string format_number(uint64_t N, HexPrintStyle Style,
}
std::string format_number(double D, FloatStyle Style,
- Optional<size_t> Precision = std::nullopt) {
+ std::optional<size_t> Precision = std::nullopt) {
std::string S;
llvm::raw_string_ostream Str(S);
write_double(Str, D, Style, Precision);
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index d649deb..16e0f04 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -454,7 +454,7 @@ std::string getEnvWin(const wchar_t *Var) {
// RAII helper to set and restore an environment variable.
class WithEnv {
const char *Var;
- llvm::Optional<std::string> OriginalValue;
+ std::optional<std::string> OriginalValue;
public:
WithEnv(const char *Var, const char *Value) : Var(Var) {
@@ -1767,7 +1767,7 @@ static void verifyFileContents(const Twine &Path, StringRef Contents) {
TEST_F(FileSystemTest, CreateNew) {
int FD;
- Optional<FileDescriptorCloser> Closer;
+ std::optional<FileDescriptorCloser> Closer;
// Succeeds if the file does not exist.
ASSERT_FALSE(fs::exists(NonExistantFile));
@@ -1791,7 +1791,7 @@ TEST_F(FileSystemTest, CreateNew) {
TEST_F(FileSystemTest, CreateAlways) {
int FD;
- Optional<FileDescriptorCloser> Closer;
+ std::optional<FileDescriptorCloser> Closer;
// Succeeds if the file does not exist.
ASSERT_FALSE(fs::exists(NonExistantFile));
@@ -1869,7 +1869,7 @@ TEST_F(FileSystemTest, AppendSetsCorrectFileOffset) {
// the specified disposition.
for (fs::CreationDisposition Disp : Disps) {
int FD;
- Optional<FileDescriptorCloser> Closer;
+ std::optional<FileDescriptorCloser> Closer;
createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "Fizz");
@@ -1975,7 +1975,7 @@ TEST_F(FileSystemTest, readNativeFileToEOF) {
createFileWithData(NonExistantFile, false, fs::CD_CreateNew, Content);
FileRemover Cleanup(NonExistantFile);
const auto &Read = [&](SmallVectorImpl<char> &V,
- Optional<ssize_t> ChunkSize) {
+ std::optional<ssize_t> ChunkSize) {
Expected<fs::file_t> FD = fs::openNativeFileForRead(NonExistantFile);
if (!FD)
return FD.takeError();
diff --git a/llvm/unittests/Support/TypeTraitsTest.cpp b/llvm/unittests/Support/TypeTraitsTest.cpp
index 734e50a..71383ac 100644
--- a/llvm/unittests/Support/TypeTraitsTest.cpp
+++ b/llvm/unittests/Support/TypeTraitsTest.cpp
@@ -118,7 +118,7 @@ TEST(Triviality, ADT) {
TrivialityTester<llvm::StringRef, true, true>();
TrivialityTester<llvm::ArrayRef<int>, true, true>();
TrivialityTester<llvm::PointerIntPair<int *, 2>, true, true>();
- TrivialityTester<llvm::Optional<int>, true, true>();
+ TrivialityTester<std::optional<int>, true, true>();
}
} // namespace triviality