From: Fangrui Song Date: Fri, 16 Dec 2022 08:49:10 +0000 (+0000) Subject: [Support] llvm::Optional => std::optional X-Git-Tag: upstream/17.0.6~23591 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b1df3a2c0b6a42570042934cb79ca0e4359f863b;p=platform%2Fupstream%2Fllvm.git [Support] llvm::Optional => std::optional https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 --- diff --git a/clang-tools-extra/clangd/support/Threading.cpp b/clang-tools-extra/clangd/support/Threading.cpp index 06d00c3..be0d84c 100644 --- a/clang-tools-extra/clangd/support/Threading.cpp +++ b/clang-tools-extra/clangd/support/Threading.cpp @@ -104,7 +104,7 @@ void AsyncTaskRunner::runAsync(const llvm::Twine &Name, // Ensure our worker threads have big enough stacks to run clang. llvm::thread Thread( - /*clang::DesiredStackSize*/ llvm::Optional(8 << 20), + /*clang::DesiredStackSize*/ std::optional(8 << 20), std::move(Task)); Thread.detach(); } diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h index cf515c5..c4ed790 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h @@ -128,7 +128,7 @@ public: addStateConstraints(State); // Constraints are unsatisfiable - Optional isSat = Solver->check(); + std::optional isSat = Solver->check(); if (!isSat || !*isSat) return nullptr; @@ -145,7 +145,7 @@ public: Solver->addConstraint(NotExp); - Optional isNotSat = Solver->check(); + std::optional isNotSat = Solver->check(); if (!isNotSat || *isNotSat) return nullptr; @@ -340,7 +340,7 @@ protected: Solver->reset(); addStateConstraints(NewState); - Optional res = Solver->check(); + std::optional res = Solver->check(); if (!res) Cached[hash] = ConditionTruthVal(); else diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index 961410c..42c766a 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -3984,7 +3984,8 @@ static llvm::Value *emitIsPlatformVersionAtLeast(CodeGenFunction &CGF, llvm::SmallVector Args; auto EmitArgs = [&](const VersionTuple &Version, const llvm::Triple &TT) { - Optional Min = Version.getMinor(), SMin = Version.getSubminor(); + std::optional 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())); @@ -4022,7 +4023,8 @@ CodeGenFunction::EmitBuiltinAvailable(const VersionTuple &Version) { CGM.CreateRuntimeFunction(FTy, "__isOSVersionAtLeast"); } - Optional Min = Version.getMinor(), SMin = Version.getSubminor(); + std::optional 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)), diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index 4a9c5b5..c93d334 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -3355,9 +3355,9 @@ llvm::Optional Lexer::tryReadNamedUCN(const char *&StartPtr, } StringRef Name(Buffer.data(), Buffer.size()); - llvm::Optional Match = + std::optional Match = llvm::sys::unicode::nameToCodepointStrict(Name); - llvm::Optional LooseMatch; + std::optional LooseMatch; if (!Match) { LooseMatch = llvm::sys::unicode::nameToCodepointLooseMatching(Name); if (Diagnose) { diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index 4ba4d94..05575e8 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -358,7 +358,7 @@ void clang::expandUCNs(SmallVectorImpl &Buf, StringRef Input) { ++I; auto Delim = std::find(I, Input.end(), '}'); assert(Delim != Input.end()); - llvm::Optional Res = + std::optional Res = llvm::sys::unicode::nameToCodepointLooseMatching( StringRef(I, std::distance(I, Delim))); assert(Res); @@ -487,7 +487,7 @@ static void DiagnoseInvalidUnicodeCharacterName( namespace u = llvm::sys::unicode; - llvm::Optional Res = + std::optional Res = u::nameToCodepointLooseMatching(Name); if (Res) { Diag(Diags, Features, Loc, TokBegin, TokRangeBegin, TokRangeEnd, @@ -565,8 +565,7 @@ static bool ProcessNamedUCNEscape(const char *ThisTokBegin, } StringRef Name(ThisTokBuf, ClosingBrace - ThisTokBuf); ThisTokBuf = ClosingBrace + 1; - llvm::Optional Res = - llvm::sys::unicode::nameToCodepointStrict(Name); + std::optional Res = llvm::sys::unicode::nameToCodepointStrict(Name); if (!Res) { if (Diags) DiagnoseInvalidUnicodeCharacterName(Diags, Features, Loc, ThisTokBegin, diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 93cc897..a9fe447 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2634,7 +2634,7 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { } if (II->isStr("fuchsia")) { - Optional Min, Sub; + std::optional Min, Sub; if ((Min = Introduced.Version.getMinor()) || (Sub = Introduced.Version.getSubminor())) { S.Diag(AL.getLoc(), diag::warn_availability_fuchsia_unavailable_minor); diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 7469bca..935f3e7 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -4466,11 +4466,11 @@ void ASTWriter::EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record, void ASTWriter::AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record) { Record.push_back(Version.getMajor()); - if (Optional Minor = Version.getMinor()) + if (std::optional Minor = Version.getMinor()) Record.push_back(*Minor + 1); else Record.push_back(0); - if (Optional Subminor = Version.getSubminor()) + if (std::optional Subminor = Version.getSubminor()) Record.push_back(*Subminor + 1); else Record.push_back(0); diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index e36716f..f47a524 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -3449,7 +3449,7 @@ void FalsePositiveRefutationBRVisitor::finalizeVisitor( } // And check for satisfiability - Optional IsSAT = RefutationSolver->check(); + std::optional IsSAT = RefutationSolver->check(); if (!IsSAT) return; diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 2c75e95..f99275e 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -7032,7 +7032,7 @@ void clang_enableStackTraces(void) { void clang_executeOnThread(void (*fn)(void *), void *user_data, unsigned stack_size) { llvm::thread Thread(stack_size == 0 ? clang::DesiredStackSize - : llvm::Optional(stack_size), + : std::optional(stack_size), fn, user_data); Thread.join(); } @@ -8236,13 +8236,13 @@ static CXVersion convertVersion(VersionTuple In) { Out.Major = In.getMajor(); - Optional Minor = In.getMinor(); + std::optional Minor = In.getMinor(); if (Minor) Out.Minor = *Minor; else return Out; - Optional Subminor = In.getSubminor(); + std::optional Subminor = In.getSubminor(); if (Subminor) Out.Subminor = *Subminor; 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 identifyObject(const void *Ptr) { + std::optional identifyObject(const void *Ptr) { const char *P = static_cast(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 Out = identifyObject(Ptr); + std::optional 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 #include +#include namespace llvm { @@ -30,11 +30,11 @@ protected: } BinaryStreamRefBase(std::shared_ptr SharedImpl, uint64_t Offset, - Optional Length) + std::optional Length) : SharedImpl(SharedImpl), BorrowedImpl(SharedImpl.get()), ViewOffset(Offset), Length(Length) {} BinaryStreamRefBase(StreamType &BorrowedImpl, uint64_t Offset, - Optional Length) + std::optional 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 SharedImpl; StreamType *BorrowedImpl = nullptr; uint64_t ViewOffset = 0; - Optional Length; + std::optional Length; }; /// BinaryStreamRef is to BinaryStream what ArrayRef is to an Array. It @@ -157,14 +157,14 @@ class BinaryStreamRef friend BinaryStreamRefBase; friend class WritableBinaryStreamRef; BinaryStreamRef(std::shared_ptr Impl, uint64_t ViewOffset, - Optional Length) + std::optional Length) : BinaryStreamRefBase(Impl, ViewOffset, Length) {} public: BinaryStreamRef() = default; BinaryStreamRef(BinaryStream &Stream); BinaryStreamRef(BinaryStream &Stream, uint64_t Offset, - Optional Length); + std::optional Length); explicit BinaryStreamRef(ArrayRef Data, llvm::support::endianness Endian); explicit BinaryStreamRef(StringRef Data, llvm::support::endianness Endian); @@ -222,7 +222,7 @@ class WritableBinaryStreamRef WritableBinaryStream> { friend BinaryStreamRefBase; WritableBinaryStreamRef(std::shared_ptr Impl, - uint64_t ViewOffset, Optional Length) + uint64_t ViewOffset, std::optional 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 Length); + std::optional Length); explicit WritableBinaryStreamRef(MutableArrayRef 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 #include +#include #include namespace llvm { @@ -263,8 +263,8 @@ struct CastIsPossible { // over. In fact, some of the isa_impl templates should be moved over to // CastIsPossible. template -struct CastIsPossible> { - static inline bool isPossible(const Optional &f) { +struct CastIsPossible> { + static inline bool isPossible(const std::optional &f) { assert(f && "CastIsPossible::isPossible called on a nullopt!"); return isa_impl_wrap< To, const From, @@ -359,18 +359,18 @@ struct UniquePtrCast : public CastIsPossible { } }; -/// This cast trait provides Optional 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. +/// This cast trait provides std::optional 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. template struct OptionalValueCast : public CastIsPossible, public DefaultDoCastIfPossible< - Optional, From, + std::optional, From, detail::SelfType>> { - static inline Optional castFailed() { return Optional{}; } + static inline std::optional castFailed() { return std::optional{}; } - static inline Optional doCast(const From &f) { return To(f); } + static inline std::optional 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::value>> { template struct CastInfo> : public UniquePtrCast {}; -/// Provide a CastInfo specialized for Optional. It's assumed that if the -/// input is Optional that the output can be Optional. If that's not -/// the case, specialize CastInfo for your use case. +/// Provide a CastInfo specialized for std::optional. It's assumed that if +/// the input is std::optional that the output can be std::optional. +/// If that's not the case, specialize CastInfo for your use case. template -struct CastInfo> : public OptionalValueCast {}; +struct CastInfo> : public OptionalValueCast { +}; /// isa - 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 struct ValueIsPresent { }; // Optional provides its own way to check if something is present. -template struct ValueIsPresent> { +template struct ValueIsPresent> { using UnwrappedType = T; - static inline bool isPresent(const Optional &t) { return t.has_value(); } - static inline decltype(auto) unwrapValue(Optional &t) { return t.value(); } + static inline bool isPresent(const std::optional &t) { + return t.has_value(); + } + static inline decltype(auto) unwrapValue(std::optional &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. +/// might be more clearly refactored to return an std::optional. 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 LineNum, + FileError(const Twine &F, std::optional LineNum, std::unique_ptr 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 Line, Error E) { + static Error build(const Twine &F, std::optional Line, Error E) { std::unique_ptr Payload; handleAllErrors(std::move(E), [&](std::unique_ptr EIB) -> Error { @@ -1318,20 +1318,20 @@ private: } std::string FileName; - Optional Line; + std::optional Line; std::unique_ptr 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(), std::move(E)); + return FileError::build(F, std::optional(), 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(Line), std::move(E)); + return FileError::build(F, std::optional(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 OverwritePermissions = std::nullopt); + Error + apply(StringRef OutputFilename, bool CopyDates = false, + std::optional 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 parseNumericPrecision(StringRef Str) { + static std::optional parseNumericPrecision(StringRef Str) { size_t Prec; - Optional Result; + std::optional Result; if (Str.empty()) Result = std::nullopt; else if (Str.getAsInteger(10, Prec)) { @@ -312,7 +312,7 @@ struct format_provider Precision = parseNumericPrecision(Style); + std::optional 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 #include +#include #include #include #include @@ -103,7 +103,7 @@ public: } static SmallVector parseFormatString(StringRef Fmt); - static Optional parseReplacementItem(StringRef Spec); + static std::optional 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 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 eq(const KnownBits &LHS, const KnownBits &RHS); + static std::optional eq(const KnownBits &LHS, const KnownBits &RHS); /// Determine if these known bits always give the same ICMP_NE result. - static Optional ne(const KnownBits &LHS, const KnownBits &RHS); + static std::optional ne(const KnownBits &LHS, const KnownBits &RHS); /// Determine if these known bits always give the same ICMP_UGT result. - static Optional ugt(const KnownBits &LHS, const KnownBits &RHS); + static std::optional ugt(const KnownBits &LHS, const KnownBits &RHS); /// Determine if these known bits always give the same ICMP_UGE result. - static Optional uge(const KnownBits &LHS, const KnownBits &RHS); + static std::optional uge(const KnownBits &LHS, const KnownBits &RHS); /// Determine if these known bits always give the same ICMP_ULT result. - static Optional ult(const KnownBits &LHS, const KnownBits &RHS); + static std::optional ult(const KnownBits &LHS, const KnownBits &RHS); /// Determine if these known bits always give the same ICMP_ULE result. - static Optional ule(const KnownBits &LHS, const KnownBits &RHS); + static std::optional ule(const KnownBits &LHS, const KnownBits &RHS); /// Determine if these known bits always give the same ICMP_SGT result. - static Optional sgt(const KnownBits &LHS, const KnownBits &RHS); + static std::optional sgt(const KnownBits &LHS, const KnownBits &RHS); /// Determine if these known bits always give the same ICMP_SGE result. - static Optional sge(const KnownBits &LHS, const KnownBits &RHS); + static std::optional sge(const KnownBits &LHS, const KnownBits &RHS); /// Determine if these known bits always give the same ICMP_SLT result. - static Optional slt(const KnownBits &LHS, const KnownBits &RHS); + static std::optional slt(const KnownBits &LHS, const KnownBits &RHS); /// Determine if these known bits always give the same ICMP_SLE result. - static Optional sle(const KnownBits &LHS, const KnownBits &RHS); + static std::optional 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 #include #include // for std::pair @@ -54,14 +54,14 @@ private: SmallString<128> LockFileName; SmallString<128> UniqueLockFileName; - Optional > Owner; + std::optional> Owner; std::error_code ErrorCode; std::string ErrorDiagMsg; LockFileManager(const LockFileManager &) = delete; LockFileManager &operator=(const LockFileManager &) = delete; - static Optional > + static std::optional> 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> getFile(const Twine &Filename, bool IsText = false, bool RequiresNullTerminator = true, bool IsVolatile = false, - Optional Alignment = std::nullopt); + std::optional 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> getOpenFileSlice(sys::fs::file_t FD, const Twine &Filename, uint64_t MapSize, int64_t Offset, bool IsVolatile = false, - Optional Alignment = std::nullopt); + std::optional Alignment = std::nullopt); /// Given an already-open file descriptor, read the file and return a /// MemoryBuffer. @@ -125,7 +125,7 @@ public: static ErrorOr> getOpenFile(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, bool RequiresNullTerminator = true, bool IsVolatile = false, - Optional Alignment = std::nullopt); + std::optional 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> getFileOrSTDIN(const Twine &Filename, bool IsText = false, bool RequiresNullTerminator = true, - Optional Alignment = std::nullopt); + std::optional Alignment = std::nullopt); /// Map a subrange of the specified file as a MemoryBuffer. static ErrorOr> getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsVolatile = false, - Optional Alignment = std::nullopt); + std::optional Alignment = std::nullopt); //===--------------------------------------------------------------------===// // Provided for performance analysis. @@ -201,13 +201,13 @@ public: static ErrorOr> getFile(const Twine &Filename, bool IsVolatile = false, - Optional Alignment = std::nullopt); + std::optional Alignment = std::nullopt); /// Map a subrange of the specified file as a WritableMemoryBuffer. static ErrorOr> getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsVolatile = false, - Optional Alignment = std::nullopt); + std::optional 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 getNewUninitMemBuffer(size_t Size, const Twine &BufferName = "", - Optional Alignment = std::nullopt); + std::optional 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 Width = std::nullopt); + std::optional Width = std::nullopt); void write_double(raw_ostream &S, double D, FloatStyle Style, - Optional Precision = std::nullopt); + std::optional 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 check() const = 0; + virtual std::optional 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 #include 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 nameToCodepointStrict(StringRef Name); +std::optional nameToCodepointStrict(StringRef Name); struct LooseMatchingResult { char32_t CodePoint; SmallString<64> Name; }; -Optional nameToCodepointLooseMatching(StringRef Name); +std::optional 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 getMinor() const { + std::optional getMinor() const { if (!HasMinor) return std::nullopt; return Minor; } /// Retrieve the subminor version number, if provided. - Optional getSubminor() const { + std::optional getSubminor() const { if (!HasSubminor) return std::nullopt; return Subminor; } /// Retrieve the build version number, if provided. - Optional getBuild() const { + std::optional 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 Buffer, - Optional User, Optional Group, - Optional Type, - Optional Perms, MakeNodeFn MakeNode); + std::optional User, std::optional Group, + std::optional Type, + std::optional 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 Buffer, - Optional User = std::nullopt, - Optional Group = std::nullopt, - Optional Type = std::nullopt, - Optional Perms = std::nullopt); + std::optional User = std::nullopt, + std::optional Group = std::nullopt, + std::optional Type = std::nullopt, + std::optional 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 User = std::nullopt, - Optional Group = std::nullopt, - Optional Perms = std::nullopt); + bool + addSymbolicLink(const Twine &NewLink, const Twine &Target, + time_t ModificationTime, + std::optional User = std::nullopt, + std::optional Group = std::nullopt, + std::optional 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 User = std::nullopt, - Optional Group = std::nullopt, - Optional Type = std::nullopt, - Optional Perms = std::nullopt); + std::optional User = std::nullopt, + std::optional Group = std::nullopt, + std::optional Type = std::nullopt, + std::optional 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 ExternalRedirect; + std::optional 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 getExternalRedirect() const { + std::optional getExternalRedirect() const { if (isa(E)) return StringRef(*ExternalRedirect); if (auto *FE = dyn_cast(E)) @@ -1016,9 +1017,9 @@ void collectVFSFromYAML( class YAMLVFSWriter { std::vector Mappings; - Optional IsCaseSensitive; - Optional IsOverlayRelative; - Optional UseExternalNames; + std::optional IsCaseSensitive; + std::optional IsOverlayRelative; + std::optional 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 #ifdef _WIN32 typedef unsigned long DWORD; @@ -72,7 +72,7 @@ public: } #endif - static const llvm::Optional DefaultStackSize; + static const std::optional DefaultStackSize; thread() : Thread(native_handle_type()) {} thread(thread &&Other) noexcept @@ -83,7 +83,7 @@ public: : thread(DefaultStackSize, f, args...) {} template - explicit thread(llvm::Optional StackSizeInBytes, Function &&f, + explicit thread(std::optional 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 StackSizeInBytes); + std::optional 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 -thread::thread(llvm::Optional StackSizeInBytes, Function &&f, +thread::thread(std::optional StackSizeInBytes, Function &&f, Args &&...args) { typedef std::tuple, std::decay_t...> CalleeTuple; std::unique_ptr Callee( @@ -171,7 +171,7 @@ public: : Thread(std::exchange(Other.Thread, std::thread())) {} template - explicit thread(llvm::Optional StackSizeInBytes, Function &&f, + explicit thread(std::optional StackSizeInBytes, Function &&f, Args &&...args) : Thread(std::forward(f), std::forward(args)...) {} @@ -224,7 +224,7 @@ struct thread { thread() {} thread(thread &&other) {} template - explicit thread(llvm::Optional StackSizeInBytes, Function &&f, + explicit thread(std::optional StackSizeInBytes, Function &&f, Args &&...args) { f(std::forward(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(MI.getOperand(1).getPredicate()); auto KnownLHS = KB->getKnownBits(MI.getOperand(2).getReg()); auto KnownRHS = KB->getKnownBits(MI.getOperand(3).getReg()); - Optional KnownVal; + std::optional 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 IsULE = KnownBits::ule(Known0, Known1)) + if (std::optional IsULE = KnownBits::ule(Known0, Known1)) return TLO.CombineTo(Op, IsULE.value() ? Op0 : Op1); - if (Optional IsULT = KnownBits::ult(Known0, Known1)) + if (std::optional 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 IsUGE = KnownBits::uge(Known0, Known1)) + if (std::optional IsUGE = KnownBits::uge(Known0, Known1)) return TLO.CombineTo(Op, IsUGE.value() ? Op0 : Op1); - if (Optional IsUGT = KnownBits::ugt(Known0, Known1)) + if (std::optional 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 Length) + std::optional Length) : BinaryStreamRefBase(Stream, Offset, Length) {} BinaryStreamRef::BinaryStreamRef(ArrayRef Data, endianness Endian) : BinaryStreamRefBase(std::make_shared(Data, Endian), 0, @@ -105,7 +105,7 @@ WritableBinaryStreamRef::WritableBinaryStreamRef(WritableBinaryStream &Stream) WritableBinaryStreamRef::WritableBinaryStreamRef(WritableBinaryStream &Stream, uint64_t Offset, - Optional Length) + std::optional Length) : BinaryStreamRefBase(Stream, Offset, Length) {} WritableBinaryStreamRef::WritableBinaryStreamRef(MutableArrayRef Data, diff --git a/llvm/lib/Support/CrashRecoveryContext.cpp b/llvm/lib/Support/CrashRecoveryContext.cpp index 7fe09eb..c7c384c 100644 --- a/llvm/lib/Support/CrashRecoveryContext.cpp +++ b/llvm/lib/Support/CrashRecoveryContext.cpp @@ -519,7 +519,7 @@ bool CrashRecoveryContext::RunSafelyOnThread(function_ref Fn, RunSafelyOnThreadInfo Info = { Fn, this, UseBackgroundPriority, false }; llvm::thread Thread(RequestedStackSize == 0 ? std::nullopt - : llvm::Optional(RequestedStackSize), + : std::optional(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 fastCaseFoldingDjbHash(StringRef Buffer, uint32_t H) { +static std::optional 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 fastCaseFoldingDjbHash(StringRef Buffer, uint32_t H) { } uint32_t llvm::caseFoldingDjbHash(StringRef Buffer, uint32_t H) { - if (Optional Result = fastCaseFoldingDjbHash(Buffer, H)) + if (std::optional Result = fastCaseFoldingDjbHash(Buffer, H)) return *Result; std::array 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 OverwritePermissions) { + std::optional 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 +std::optional 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 KnownBits::eq(const KnownBits &LHS, const KnownBits &RHS) { +std::optional KnownBits::eq(const KnownBits &LHS, const KnownBits &RHS) { if (LHS.isConstant() && RHS.isConstant()) - return Optional(LHS.getConstant() == RHS.getConstant()); + return std::optional(LHS.getConstant() == RHS.getConstant()); if (LHS.One.intersects(RHS.Zero) || RHS.One.intersects(LHS.Zero)) - return Optional(false); + return std::optional(false); return std::nullopt; } -Optional KnownBits::ne(const KnownBits &LHS, const KnownBits &RHS) { - if (Optional KnownEQ = eq(LHS, RHS)) - return Optional(!*KnownEQ); +std::optional KnownBits::ne(const KnownBits &LHS, const KnownBits &RHS) { + if (std::optional KnownEQ = eq(LHS, RHS)) + return std::optional(!*KnownEQ); return std::nullopt; } -Optional KnownBits::ugt(const KnownBits &LHS, const KnownBits &RHS) { +std::optional 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(false); + return std::optional(false); // LHS >u RHS -> true if umin(LHS) > umax(RHS) if (LHS.getMinValue().ugt(RHS.getMaxValue())) - return Optional(true); + return std::optional(true); return std::nullopt; } -Optional KnownBits::uge(const KnownBits &LHS, const KnownBits &RHS) { - if (Optional IsUGT = ugt(RHS, LHS)) - return Optional(!*IsUGT); +std::optional KnownBits::uge(const KnownBits &LHS, const KnownBits &RHS) { + if (std::optional IsUGT = ugt(RHS, LHS)) + return std::optional(!*IsUGT); return std::nullopt; } -Optional KnownBits::ult(const KnownBits &LHS, const KnownBits &RHS) { +std::optional KnownBits::ult(const KnownBits &LHS, const KnownBits &RHS) { return ugt(RHS, LHS); } -Optional KnownBits::ule(const KnownBits &LHS, const KnownBits &RHS) { +std::optional KnownBits::ule(const KnownBits &LHS, const KnownBits &RHS) { return uge(RHS, LHS); } -Optional KnownBits::sgt(const KnownBits &LHS, const KnownBits &RHS) { +std::optional 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(false); + return std::optional(false); // LHS >s RHS -> true if smin(LHS) > smax(RHS) if (LHS.getSignedMinValue().sgt(RHS.getSignedMaxValue())) - return Optional(true); + return std::optional(true); return std::nullopt; } -Optional KnownBits::sge(const KnownBits &LHS, const KnownBits &RHS) { - if (Optional KnownSGT = sgt(RHS, LHS)) - return Optional(!*KnownSGT); +std::optional KnownBits::sge(const KnownBits &LHS, const KnownBits &RHS) { + if (std::optional KnownSGT = sgt(RHS, LHS)) + return std::optional(!*KnownSGT); return std::nullopt; } -Optional KnownBits::slt(const KnownBits &LHS, const KnownBits &RHS) { +std::optional KnownBits::slt(const KnownBits &LHS, const KnownBits &RHS) { return sgt(RHS, LHS); } -Optional KnownBits::sle(const KnownBits &LHS, const KnownBits &RHS) { +std::optional 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::optional> 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 static ErrorOr> getFileAux(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsText, bool RequiresNullTerminator, bool IsVolatile, - Optional Alignment); + std::optional Alignment); std::unique_ptr MemoryBuffer::getMemBuffer(StringRef InputData, StringRef BufferName, @@ -150,7 +150,7 @@ MemoryBuffer::getMemBufferCopy(StringRef InputData, const Twine &BufferName) { ErrorOr> MemoryBuffer::getFileOrSTDIN(const Twine &Filename, bool IsText, bool RequiresNullTerminator, - Optional Alignment) { + std::optional Alignment) { SmallString<256> NameBuf; StringRef NameRef = Filename.toStringRef(NameBuf); @@ -163,7 +163,7 @@ MemoryBuffer::getFileOrSTDIN(const Twine &Filename, bool IsText, ErrorOr> MemoryBuffer::getFileSlice(const Twine &FilePath, uint64_t MapSize, uint64_t Offset, bool IsVolatile, - Optional Alignment) { + std::optional Alignment) { return getFileAux(FilePath, MapSize, Offset, /*IsText=*/false, /*RequiresNullTerminator=*/false, IsVolatile, Alignment); @@ -247,7 +247,7 @@ getMemoryBufferForStream(sys::fs::file_t FD, const Twine &BufferName) { ErrorOr> MemoryBuffer::getFile(const Twine &Filename, bool IsText, bool RequiresNullTerminator, bool IsVolatile, - Optional Alignment) { + std::optional Alignment) { return getFileAux(Filename, /*MapSize=*/-1, /*Offset=*/0, IsText, RequiresNullTerminator, IsVolatile, Alignment); @@ -257,13 +257,13 @@ template static ErrorOr> getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, uint64_t MapSize, int64_t Offset, bool RequiresNullTerminator, - bool IsVolatile, Optional Alignment); + bool IsVolatile, std::optional Alignment); template static ErrorOr> getFileAux(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsText, bool RequiresNullTerminator, bool IsVolatile, - Optional Alignment) { + std::optional Alignment) { Expected 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> WritableMemoryBuffer::getFile(const Twine &Filename, bool IsVolatile, - Optional Alignment) { + std::optional Alignment) { return getFileAux( Filename, /*MapSize=*/-1, /*Offset=*/0, /*IsText=*/false, /*RequiresNullTerminator=*/false, IsVolatile, Alignment); @@ -286,7 +286,7 @@ WritableMemoryBuffer::getFile(const Twine &Filename, bool IsVolatile, ErrorOr> WritableMemoryBuffer::getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsVolatile, - Optional Alignment) { + std::optional Alignment) { return getFileAux( 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::getNewUninitMemBuffer(size_t Size, const Twine &BufferName, - Optional Alignment) { + std::optional Alignment) { using MemBuffer = MemoryBufferMem; // Use 16-byte alignment if no alignment is specified. @@ -447,7 +447,7 @@ template static ErrorOr> getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, uint64_t MapSize, int64_t Offset, bool RequiresNullTerminator, - bool IsVolatile, Optional Alignment) { + bool IsVolatile, std::optional 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> MemoryBuffer::getOpenFile(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, bool RequiresNullTerminator, - bool IsVolatile, Optional Alignment) { + bool IsVolatile, std::optional Alignment) { return getOpenFileImpl(FD, Filename, FileSize, FileSize, 0, RequiresNullTerminator, IsVolatile, Alignment); } -ErrorOr> -MemoryBuffer::getOpenFileSlice(sys::fs::file_t FD, const Twine &Filename, - uint64_t MapSize, int64_t Offset, - bool IsVolatile, Optional Alignment) { +ErrorOr> MemoryBuffer::getOpenFileSlice( + sys::fs::file_t FD, const Twine &Filename, uint64_t MapSize, int64_t Offset, + bool IsVolatile, std::optional Alignment) { assert(MapSize != uint64_t(-1)); return getOpenFileImpl(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 Width) { + std::optional 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 Precision) { + std::optional 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 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 EndOffset) -> bool { + auto tryAddFillerFromQueue = [&](AlignmentQueue *Queue, uint64_t StartOffset, + std::optional EndOffset) -> bool { assert(Queue->Head); assert(StartOffset == alignTo(LastEnd, Queue->Alignment)); assert(!EndOffset || StartOffset < *EndOffset); @@ -357,7 +356,8 @@ llvm::performOptimizedStructLayout(MutableArrayRef 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 Fields) { // Helper function to find the "best" flexible-offset field according // to the criteria described above. - auto tryAddBestField = [&](Optional BeforeOffset) -> bool { + auto tryAddBestField = [&](std::optional 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 FragmentKind = StringSwitch>(Parts[0]) - .Case("name", FK::Name) - .Case("type", FK::Type) - .Case("encoding", FK::Encoding) - .Default(std::nullopt); + std::optional FragmentKind = StringSwitch>(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 llvm::thread::DefaultStackSize = 8 * 1024 * 1024; +const std::optional llvm::thread::DefaultStackSize = 8 * 1024 * 1024; #else -const llvm::Optional llvm::thread::DefaultStackSize; +const std::optional 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 +static std::optional 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 +static std::optional 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 nameToCodepoint(StringRef Name, bool Strict, - BufferType &Buffer) { +static std::optional nameToCodepoint(StringRef Name, bool Strict, + BufferType &Buffer) { if (Name.empty()) return std::nullopt; - llvm::Optional Res = nameToHangulCodePoint(Name, Strict, Buffer); + std::optional Res = nameToHangulCodePoint(Name, Strict, Buffer); if (!Res) Res = nameToGeneratedCodePoint(Name, Strict, Buffer); if (Res) @@ -400,14 +400,14 @@ static llvm::Optional nameToCodepoint(StringRef Name, bool Strict, return std::nullopt; } -llvm::Optional nameToCodepointStrict(StringRef Name) { +std::optional nameToCodepointStrict(StringRef Name) { BufferType Buffer; auto Opt = nameToCodepoint(Name, true, Buffer); return Opt; } -llvm::Optional +std::optional 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 StackSizeInBytes) { + std::optional 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 Minor = V.getMinor()) + if (std::optional Minor = V.getMinor()) Out << '.' << *Minor; - if (Optional Subminor = V.getSubminor()) + if (std::optional Subminor = V.getSubminor()) Out << '.' << *Subminor; - if (Optional Build = V.getBuild()) + if (std::optional 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 Buffer, - Optional User, - Optional Group, - Optional Type, - Optional Perms, + std::optional User, + std::optional Group, + std::optional Type, + std::optional 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 Buffer, - Optional User, - Optional Group, - Optional Type, - Optional Perms) { + std::optional User, + std::optional Group, + std::optional Type, + std::optional 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 User, - Optional Group, - Optional Type, - Optional Perms) { +bool InMemoryFileSystem::addFileNoOwn( + const Twine &P, time_t ModificationTime, + const llvm::MemoryBufferRef &Buffer, std::optional User, + std::optional Group, std::optional Type, + std::optional 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 User, - Optional Group, - Optional Perms) { +bool InMemoryFileSystem::addSymbolicLink( + const Twine &NewLink, const Twine &Target, time_t ModificationTime, + std::optional User, std::optional Group, + std::optional Perms) { auto NewLinkNode = lookupNode(NewLink, /*FollowFinalSymlink=*/false); if (NewLinkNode) return false; @@ -2272,7 +2269,7 @@ static Status getRedirectedFileStatus(const Twine &OriginalPath, ErrorOr RedirectingFileSystem::status( const Twine &CanonicalPath, const Twine &OriginalPath, const RedirectingFileSystem::LookupResult &Result) { - if (Optional ExtRedirect = Result.getExternalRedirect()) { + if (std::optional 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 Entries, Optional UseExternalNames, - Optional IsCaseSensitive, Optional IsOverlayRelative, - StringRef OverlayDir); + void write(ArrayRef Entries, + std::optional UseExternalNames, + std::optional IsCaseSensitive, + std::optional IsOverlayRelative, StringRef OverlayDir); }; } // namespace @@ -2660,9 +2658,9 @@ void JSONWriter::writeEntry(StringRef VPath, StringRef RPath) { } void JSONWriter::write(ArrayRef Entries, - Optional UseExternalNames, - Optional IsCaseSensitive, - Optional IsOverlayRelative, + std::optional UseExternalNames, + std::optional IsCaseSensitive, + std::optional 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 StackSizeInBytes) { + std::optional 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 check() const override { + std::optional 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>; +using OptionalStatistic = std::optional>; 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 = dyn_cast(t1); + std::optional t2 = dyn_cast(t1); EXPECT_TRUE(t2); T2 *t2ptr = dyn_cast(&t1); @@ -246,12 +246,12 @@ TEST(CastingTest, dyn_cast_value_types) { } TEST(CastingTest, dyn_cast_if_present) { - Optional empty{}; - Optional F1 = dyn_cast_if_present(empty); + std::optional empty{}; + std::optional F1 = dyn_cast_if_present(empty); EXPECT_FALSE(F1.has_value()); T1 t1; - Optional F2 = dyn_cast_if_present(t1); + std::optional F2 = dyn_cast_if_present(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 Box; + std::optional 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 MaybeV; + std::optional 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 KnownEQ = KnownBits::eq(Known1, Known2); - Optional KnownNE = KnownBits::ne(Known1, Known2); - Optional KnownUGT = KnownBits::ugt(Known1, Known2); - Optional KnownUGE = KnownBits::uge(Known1, Known2); - Optional KnownULT = KnownBits::ult(Known1, Known2); - Optional KnownULE = KnownBits::ule(Known1, Known2); - Optional KnownSGT = KnownBits::sgt(Known1, Known2); - Optional KnownSGE = KnownBits::sge(Known1, Known2); - Optional KnownSLT = KnownBits::slt(Known1, Known2); - Optional KnownSLE = KnownBits::sle(Known1, Known2); + std::optional KnownEQ = KnownBits::eq(Known1, Known2); + std::optional KnownNE = KnownBits::ne(Known1, Known2); + std::optional KnownUGT = KnownBits::ugt(Known1, Known2); + std::optional KnownUGE = KnownBits::uge(Known1, Known2); + std::optional KnownULT = KnownBits::ult(Known1, Known2); + std::optional KnownULE = KnownBits::ule(Known1, Known2); + std::optional KnownSGT = KnownBits::sgt(Known1, Known2); + std::optional KnownSGE = KnownBits::sge(Known1, Known2); + std::optional KnownSLT = KnownBits::slt(Known1, Known2); + std::optional 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 std::string format_number(T N, IntegerStyle Style) { } std::string format_number(uint64_t N, HexPrintStyle Style, - Optional Width = std::nullopt) { + std::optional 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 Precision = std::nullopt) { + std::optional 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 OriginalValue; + std::optional 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 Closer; + std::optional 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 Closer; + std::optional 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 Closer; + std::optional 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 &V, - Optional ChunkSize) { + std::optional ChunkSize) { Expected 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(); TrivialityTester, true, true>(); TrivialityTester, true, true>(); - TrivialityTester, true, true>(); + TrivialityTester, true, true>(); } } // namespace triviality diff --git a/mlir/lib/Support/FileUtilities.cpp b/mlir/lib/Support/FileUtilities.cpp index 9fc86fc..a5c44d3 100644 --- a/mlir/lib/Support/FileUtilities.cpp +++ b/mlir/lib/Support/FileUtilities.cpp @@ -21,7 +21,7 @@ using namespace mlir; static std::unique_ptr openInputFileImpl(StringRef inputFilename, std::string *errorMessage, - Optional alignment) { + std::optional alignment) { auto fileOrErr = llvm::MemoryBuffer::getFileOrSTDIN( inputFilename, /*IsText=*/false, /*RequiresNullTerminator=*/true, alignment);