https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
// Ensure our worker threads have big enough stacks to run clang.
llvm::thread Thread(
- /*clang::DesiredStackSize*/ llvm::Optional<unsigned>(8 << 20),
+ /*clang::DesiredStackSize*/ std::optional<unsigned>(8 << 20),
std::move(Task));
Thread.detach();
}
addStateConstraints(State);
// Constraints are unsatisfiable
- Optional<bool> isSat = Solver->check();
+ std::optional<bool> isSat = Solver->check();
if (!isSat || !*isSat)
return nullptr;
Solver->addConstraint(NotExp);
- Optional<bool> isNotSat = Solver->check();
+ std::optional<bool> isNotSat = Solver->check();
if (!isNotSat || *isNotSat)
return nullptr;
Solver->reset();
addStateConstraints(NewState);
- Optional<bool> res = Solver->check();
+ std::optional<bool> res = Solver->check();
if (!res)
Cached[hash] = ConditionTruthVal();
else
llvm::SmallVector<llvm::Value *, 8> Args;
auto EmitArgs = [&](const VersionTuple &Version, const llvm::Triple &TT) {
- Optional<unsigned> Min = Version.getMinor(), SMin = Version.getSubminor();
+ std::optional<unsigned> Min = Version.getMinor(),
+ SMin = Version.getSubminor();
Args.push_back(
llvm::ConstantInt::get(CGM.Int32Ty, getBaseMachOPlatformID(TT)));
Args.push_back(llvm::ConstantInt::get(CGM.Int32Ty, Version.getMajor()));
CGM.CreateRuntimeFunction(FTy, "__isOSVersionAtLeast");
}
- Optional<unsigned> Min = Version.getMinor(), SMin = Version.getSubminor();
+ std::optional<unsigned> Min = Version.getMinor(),
+ SMin = Version.getSubminor();
llvm::Value *Args[] = {
llvm::ConstantInt::get(CGM.Int32Ty, Version.getMajor()),
llvm::ConstantInt::get(CGM.Int32Ty, Min.value_or(0)),
}
StringRef Name(Buffer.data(), Buffer.size());
- llvm::Optional<char32_t> Match =
+ std::optional<char32_t> Match =
llvm::sys::unicode::nameToCodepointStrict(Name);
- llvm::Optional<llvm::sys::unicode::LooseMatchingResult> LooseMatch;
+ std::optional<llvm::sys::unicode::LooseMatchingResult> LooseMatch;
if (!Match) {
LooseMatch = llvm::sys::unicode::nameToCodepointLooseMatching(Name);
if (Diagnose) {
++I;
auto Delim = std::find(I, Input.end(), '}');
assert(Delim != Input.end());
- llvm::Optional<llvm::sys::unicode::LooseMatchingResult> Res =
+ std::optional<llvm::sys::unicode::LooseMatchingResult> Res =
llvm::sys::unicode::nameToCodepointLooseMatching(
StringRef(I, std::distance(I, Delim)));
assert(Res);
namespace u = llvm::sys::unicode;
- llvm::Optional<u::LooseMatchingResult> Res =
+ std::optional<u::LooseMatchingResult> Res =
u::nameToCodepointLooseMatching(Name);
if (Res) {
Diag(Diags, Features, Loc, TokBegin, TokRangeBegin, TokRangeEnd,
}
StringRef Name(ThisTokBuf, ClosingBrace - ThisTokBuf);
ThisTokBuf = ClosingBrace + 1;
- llvm::Optional<char32_t> Res =
- llvm::sys::unicode::nameToCodepointStrict(Name);
+ std::optional<char32_t> Res = llvm::sys::unicode::nameToCodepointStrict(Name);
if (!Res) {
if (Diags)
DiagnoseInvalidUnicodeCharacterName(Diags, Features, Loc, ThisTokBegin,
}
if (II->isStr("fuchsia")) {
- Optional<unsigned> Min, Sub;
+ std::optional<unsigned> Min, Sub;
if ((Min = Introduced.Version.getMinor()) ||
(Sub = Introduced.Version.getSubminor())) {
S.Diag(AL.getLoc(), diag::warn_availability_fuchsia_unavailable_minor);
void ASTWriter::AddVersionTuple(const VersionTuple &Version,
RecordDataImpl &Record) {
Record.push_back(Version.getMajor());
- if (Optional<unsigned> Minor = Version.getMinor())
+ if (std::optional<unsigned> Minor = Version.getMinor())
Record.push_back(*Minor + 1);
else
Record.push_back(0);
- if (Optional<unsigned> Subminor = Version.getSubminor())
+ if (std::optional<unsigned> Subminor = Version.getSubminor())
Record.push_back(*Subminor + 1);
else
Record.push_back(0);
}
// And check for satisfiability
- Optional<bool> IsSAT = RefutationSolver->check();
+ std::optional<bool> IsSAT = RefutationSolver->check();
if (!IsSAT)
return;
void clang_executeOnThread(void (*fn)(void *), void *user_data,
unsigned stack_size) {
llvm::thread Thread(stack_size == 0 ? clang::DesiredStackSize
- : llvm::Optional<unsigned>(stack_size),
+ : std::optional<unsigned>(stack_size),
fn, user_data);
Thread.join();
}
Out.Major = In.getMajor();
- Optional<unsigned> Minor = In.getMinor();
+ std::optional<unsigned> Minor = In.getMinor();
if (Minor)
Out.Minor = *Minor;
else
return Out;
- Optional<unsigned> Subminor = In.getSubminor();
+ std::optional<unsigned> Subminor = In.getSubminor();
if (Subminor)
Out.Subminor = *Subminor;
/// 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++) {
/// \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;
}
#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 {
}
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;
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
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);
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 {
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;
#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 {
// 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,
}
};
-/// 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
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:
};
// 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
///
/// 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 &) {});
}
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();
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 {
}
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
/// 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)
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)) {
else
S = FloatStyle::Fixed;
- Optional<size_t> Precision = parseNumericPrecision(Style);
+ std::optional<size_t> Precision = parseNumericPrecision(Style);
if (!Precision)
Precision = getDefaultPrecision(S);
#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"
#include "llvm/Support/raw_ostream.h"
#include <array>
#include <cstddef>
+#include <optional>
#include <string>
#include <tuple>
#include <utility>
}
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;
#define LLVM_SUPPORT_KNOWNBITS_H
#include "llvm/ADT/APInt.h"
-#include "llvm/ADT/Optional.h"
+#include <optional>
namespace llvm {
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);
#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
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);
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
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.
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.
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.
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
/// 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.
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
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;
#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 {
/// 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;
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;
/// 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
/// 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.
///
/// 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
/// 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;
/// 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,
/// 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))
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);
#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;
}
#endif
- static const llvm::Optional<unsigned> DefaultStackSize;
+ static const std::optional<unsigned> DefaultStackSize;
thread() : Thread(native_handle_type()) {}
thread(thread &&Other) noexcept
: 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;
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(
: 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)...) {}
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)...);
}
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?");
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;
}
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;
}
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,
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,
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();
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);
}
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;
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)
return !Failed;
}
-Optional<ReplacementItem>
+std::optional<ReplacementItem>
formatv_object_base::parseReplacementItem(StringRef Spec) {
StringRef RepString = Spec.trim("{}");
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);
}
/// \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.
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,
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);
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);
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);
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)
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);
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);
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.
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.
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);
}
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));
}
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)) {
// 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);
// 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.
// 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();
"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] + "'");
// 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
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
{"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();
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)
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);
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.
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;
}
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);
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)
});
}
-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),
});
}
-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;
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;
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
}
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;
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);
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;
#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"
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);
}
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;
}
struct MoveOnlyBox {
- Optional<int> Box;
+ std::optional<int> Box;
explicit MoveOnlyBox(int I) : Box(I) {}
MoveOnlyBox() = default;
// 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);
});
});
- 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());
}
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);
}
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);
// 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) {
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));
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));
// the specified disposition.
for (fs::CreationDisposition Disp : Disps) {
int FD;
- Optional<FileDescriptorCloser> Closer;
+ std::optional<FileDescriptorCloser> Closer;
createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "Fizz");
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();
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
static std::unique_ptr<llvm::MemoryBuffer>
openInputFileImpl(StringRef inputFilename, std::string *errorMessage,
- Optional<llvm::Align> alignment) {
+ std::optional<llvm::Align> alignment) {
auto fileOrErr = llvm::MemoryBuffer::getFileOrSTDIN(
inputFilename, /*IsText=*/false, /*RequiresNullTerminator=*/true,
alignment);