diff options
author | Fangrui Song <i@maskray.me> | 2022-12-16 08:49:10 +0000 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2022-12-16 08:49:10 +0000 |
commit | b1df3a2c0b6a42570042934cb79ca0e4359f863b (patch) | |
tree | 2cededee6eea9ccc6a38a25ea468edd352253f43 /llvm/lib | |
parent | 61a124db5647f83422476797a761d2ec22a2d17f (diff) | |
download | llvm-b1df3a2c0b6a42570042934cb79ca0e4359f863b.zip llvm-b1df3a2c0b6a42570042934cb79ca0e4359f863b.tar.gz llvm-b1df3a2c0b6a42570042934cb79ca0e4359f863b.tar.bz2 |
[Support] llvm::Optional => std::optional
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/Support/BinaryStreamRef.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Support/CrashRecoveryContext.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Support/DJB.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/Support/FileUtilities.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Support/FormatVariadic.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Support/KnownBits.cpp | 44 | ||||
-rw-r--r-- | llvm/lib/Support/LockFileManager.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Support/MemoryBuffer.cpp | 29 | ||||
-rw-r--r-- | llvm/lib/Support/NativeFormatting.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Support/OptimizedStructLayout.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/Support/SymbolRemappingReader.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/Support/Threading.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Support/UnicodeNameToCodepoint.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/Support/Unix/Threading.inc | 2 | ||||
-rw-r--r-- | llvm/lib/Support/VersionTuple.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Support/VirtualFileSystem.cpp | 52 | ||||
-rw-r--r-- | llvm/lib/Support/Windows/Threading.inc | 2 | ||||
-rw-r--r-- | llvm/lib/Support/Z3Solver.cpp | 2 |
20 files changed, 102 insertions, 104 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp index c5d5d68..5ff3dd2 100644 --- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp @@ -4216,7 +4216,7 @@ bool CombinerHelper::matchICmpToTrueFalseKnownBits(MachineInstr &MI, auto Pred = static_cast<CmpInst::Predicate>(MI.getOperand(1).getPredicate()); auto KnownLHS = KB->getKnownBits(MI.getOperand(2).getReg()); auto KnownRHS = KB->getKnownBits(MI.getOperand(3).getReg()); - Optional<bool> KnownVal; + std::optional<bool> KnownVal; switch (Pred) { default: llvm_unreachable("Unexpected G_ICMP predicate?"); diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index a0e7705..a7716e8 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -2103,9 +2103,9 @@ bool TargetLowering::SimplifyDemandedBits( KnownBits Known0 = TLO.DAG.computeKnownBits(Op0, DemandedElts, Depth + 1); KnownBits Known1 = TLO.DAG.computeKnownBits(Op1, DemandedElts, Depth + 1); Known = KnownBits::umin(Known0, Known1); - if (Optional<bool> IsULE = KnownBits::ule(Known0, Known1)) + if (std::optional<bool> IsULE = KnownBits::ule(Known0, Known1)) return TLO.CombineTo(Op, IsULE.value() ? Op0 : Op1); - if (Optional<bool> IsULT = KnownBits::ult(Known0, Known1)) + if (std::optional<bool> IsULT = KnownBits::ult(Known0, Known1)) return TLO.CombineTo(Op, IsULT.value() ? Op0 : Op1); break; } @@ -2116,9 +2116,9 @@ bool TargetLowering::SimplifyDemandedBits( KnownBits Known0 = TLO.DAG.computeKnownBits(Op0, DemandedElts, Depth + 1); KnownBits Known1 = TLO.DAG.computeKnownBits(Op1, DemandedElts, Depth + 1); Known = KnownBits::umax(Known0, Known1); - if (Optional<bool> IsUGE = KnownBits::uge(Known0, Known1)) + if (std::optional<bool> IsUGE = KnownBits::uge(Known0, Known1)) return TLO.CombineTo(Op, IsUGE.value() ? Op0 : Op1); - if (Optional<bool> IsUGT = KnownBits::ugt(Known0, Known1)) + if (std::optional<bool> IsUGT = KnownBits::ugt(Known0, Known1)) return TLO.CombineTo(Op, IsUGT.value() ? Op0 : Op1); break; } diff --git a/llvm/lib/Support/BinaryStreamRef.cpp b/llvm/lib/Support/BinaryStreamRef.cpp index 6d79d95..06b4999 100644 --- a/llvm/lib/Support/BinaryStreamRef.cpp +++ b/llvm/lib/Support/BinaryStreamRef.cpp @@ -67,7 +67,7 @@ private: BinaryStreamRef::BinaryStreamRef(BinaryStream &Stream) : BinaryStreamRefBase(Stream) {} BinaryStreamRef::BinaryStreamRef(BinaryStream &Stream, uint64_t Offset, - Optional<uint64_t> Length) + std::optional<uint64_t> Length) : BinaryStreamRefBase(Stream, Offset, Length) {} BinaryStreamRef::BinaryStreamRef(ArrayRef<uint8_t> Data, endianness Endian) : BinaryStreamRefBase(std::make_shared<ArrayRefImpl>(Data, Endian), 0, @@ -105,7 +105,7 @@ WritableBinaryStreamRef::WritableBinaryStreamRef(WritableBinaryStream &Stream) WritableBinaryStreamRef::WritableBinaryStreamRef(WritableBinaryStream &Stream, uint64_t Offset, - Optional<uint64_t> Length) + std::optional<uint64_t> Length) : BinaryStreamRefBase(Stream, Offset, Length) {} WritableBinaryStreamRef::WritableBinaryStreamRef(MutableArrayRef<uint8_t> Data, diff --git a/llvm/lib/Support/CrashRecoveryContext.cpp b/llvm/lib/Support/CrashRecoveryContext.cpp index 7fe09eb9..c7c384c 100644 --- a/llvm/lib/Support/CrashRecoveryContext.cpp +++ b/llvm/lib/Support/CrashRecoveryContext.cpp @@ -519,7 +519,7 @@ bool CrashRecoveryContext::RunSafelyOnThread(function_ref<void()> Fn, RunSafelyOnThreadInfo Info = { Fn, this, UseBackgroundPriority, false }; llvm::thread Thread(RequestedStackSize == 0 ? std::nullopt - : llvm::Optional<unsigned>(RequestedStackSize), + : std::optional<unsigned>(RequestedStackSize), RunSafelyOnThread_Dispatch, &Info); Thread.join(); diff --git a/llvm/lib/Support/DJB.cpp b/llvm/lib/Support/DJB.cpp index 2701d5d..b9d159c 100644 --- a/llvm/lib/Support/DJB.cpp +++ b/llvm/lib/Support/DJB.cpp @@ -57,7 +57,8 @@ static UTF32 foldCharDwarf(UTF32 C) { return sys::unicode::foldCharSimple(C); } -static Optional<uint32_t> fastCaseFoldingDjbHash(StringRef Buffer, uint32_t H) { +static std::optional<uint32_t> fastCaseFoldingDjbHash(StringRef Buffer, + uint32_t H) { bool AllASCII = true; for (unsigned char C : Buffer) { H = H * 33 + ('A' <= C && C <= 'Z' ? C - 'A' + 'a' : C); @@ -69,7 +70,7 @@ static Optional<uint32_t> fastCaseFoldingDjbHash(StringRef Buffer, uint32_t H) { } uint32_t llvm::caseFoldingDjbHash(StringRef Buffer, uint32_t H) { - if (Optional<uint32_t> Result = fastCaseFoldingDjbHash(Buffer, H)) + if (std::optional<uint32_t> Result = fastCaseFoldingDjbHash(Buffer, H)) return *Result; std::array<UTF8, UNI_MAX_UTF8_BYTES_PER_CODE_POINT> Storage; diff --git a/llvm/lib/Support/FileUtilities.cpp b/llvm/lib/Support/FileUtilities.cpp index 24960cc..d01a41a 100644 --- a/llvm/lib/Support/FileUtilities.cpp +++ b/llvm/lib/Support/FileUtilities.cpp @@ -341,7 +341,7 @@ FilePermissionsApplier::create(StringRef InputFilename) { Error FilePermissionsApplier::apply( StringRef OutputFilename, bool CopyDates, - Optional<sys::fs::perms> OverwritePermissions) { + std::optional<sys::fs::perms> OverwritePermissions) { sys::fs::file_status Status = InputStatus; if (OverwritePermissions) diff --git a/llvm/lib/Support/FormatVariadic.cpp b/llvm/lib/Support/FormatVariadic.cpp index 169cea4..10de7f1 100644 --- a/llvm/lib/Support/FormatVariadic.cpp +++ b/llvm/lib/Support/FormatVariadic.cpp @@ -55,7 +55,7 @@ bool formatv_object_base::consumeFieldLayout(StringRef &Spec, AlignStyle &Where, return !Failed; } -Optional<ReplacementItem> +std::optional<ReplacementItem> formatv_object_base::parseReplacementItem(StringRef Spec) { StringRef RepString = Spec.trim("{}"); diff --git a/llvm/lib/Support/KnownBits.cpp b/llvm/lib/Support/KnownBits.cpp index c62a1a3..745c46f 100644 --- a/llvm/lib/Support/KnownBits.cpp +++ b/llvm/lib/Support/KnownBits.cpp @@ -330,65 +330,65 @@ KnownBits KnownBits::ashr(const KnownBits &LHS, const KnownBits &RHS) { return Known; } -Optional<bool> KnownBits::eq(const KnownBits &LHS, const KnownBits &RHS) { +std::optional<bool> KnownBits::eq(const KnownBits &LHS, const KnownBits &RHS) { if (LHS.isConstant() && RHS.isConstant()) - return Optional<bool>(LHS.getConstant() == RHS.getConstant()); + return std::optional<bool>(LHS.getConstant() == RHS.getConstant()); if (LHS.One.intersects(RHS.Zero) || RHS.One.intersects(LHS.Zero)) - return Optional<bool>(false); + return std::optional<bool>(false); return std::nullopt; } -Optional<bool> KnownBits::ne(const KnownBits &LHS, const KnownBits &RHS) { - if (Optional<bool> KnownEQ = eq(LHS, RHS)) - return Optional<bool>(!*KnownEQ); +std::optional<bool> KnownBits::ne(const KnownBits &LHS, const KnownBits &RHS) { + if (std::optional<bool> KnownEQ = eq(LHS, RHS)) + return std::optional<bool>(!*KnownEQ); return std::nullopt; } -Optional<bool> KnownBits::ugt(const KnownBits &LHS, const KnownBits &RHS) { +std::optional<bool> KnownBits::ugt(const KnownBits &LHS, const KnownBits &RHS) { // LHS >u RHS -> false if umax(LHS) <= umax(RHS) if (LHS.getMaxValue().ule(RHS.getMinValue())) - return Optional<bool>(false); + return std::optional<bool>(false); // LHS >u RHS -> true if umin(LHS) > umax(RHS) if (LHS.getMinValue().ugt(RHS.getMaxValue())) - return Optional<bool>(true); + return std::optional<bool>(true); return std::nullopt; } -Optional<bool> KnownBits::uge(const KnownBits &LHS, const KnownBits &RHS) { - if (Optional<bool> IsUGT = ugt(RHS, LHS)) - return Optional<bool>(!*IsUGT); +std::optional<bool> KnownBits::uge(const KnownBits &LHS, const KnownBits &RHS) { + if (std::optional<bool> IsUGT = ugt(RHS, LHS)) + return std::optional<bool>(!*IsUGT); return std::nullopt; } -Optional<bool> KnownBits::ult(const KnownBits &LHS, const KnownBits &RHS) { +std::optional<bool> KnownBits::ult(const KnownBits &LHS, const KnownBits &RHS) { return ugt(RHS, LHS); } -Optional<bool> KnownBits::ule(const KnownBits &LHS, const KnownBits &RHS) { +std::optional<bool> KnownBits::ule(const KnownBits &LHS, const KnownBits &RHS) { return uge(RHS, LHS); } -Optional<bool> KnownBits::sgt(const KnownBits &LHS, const KnownBits &RHS) { +std::optional<bool> KnownBits::sgt(const KnownBits &LHS, const KnownBits &RHS) { // LHS >s RHS -> false if smax(LHS) <= smax(RHS) if (LHS.getSignedMaxValue().sle(RHS.getSignedMinValue())) - return Optional<bool>(false); + return std::optional<bool>(false); // LHS >s RHS -> true if smin(LHS) > smax(RHS) if (LHS.getSignedMinValue().sgt(RHS.getSignedMaxValue())) - return Optional<bool>(true); + return std::optional<bool>(true); return std::nullopt; } -Optional<bool> KnownBits::sge(const KnownBits &LHS, const KnownBits &RHS) { - if (Optional<bool> KnownSGT = sgt(RHS, LHS)) - return Optional<bool>(!*KnownSGT); +std::optional<bool> KnownBits::sge(const KnownBits &LHS, const KnownBits &RHS) { + if (std::optional<bool> KnownSGT = sgt(RHS, LHS)) + return std::optional<bool>(!*KnownSGT); return std::nullopt; } -Optional<bool> KnownBits::slt(const KnownBits &LHS, const KnownBits &RHS) { +std::optional<bool> KnownBits::slt(const KnownBits &LHS, const KnownBits &RHS) { return sgt(RHS, LHS); } -Optional<bool> KnownBits::sle(const KnownBits &LHS, const KnownBits &RHS) { +std::optional<bool> KnownBits::sle(const KnownBits &LHS, const KnownBits &RHS) { return sge(RHS, LHS); } diff --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp index 9059473..b64d483 100644 --- a/llvm/lib/Support/LockFileManager.cpp +++ b/llvm/lib/Support/LockFileManager.cpp @@ -51,7 +51,7 @@ using namespace llvm; /// \param LockFileName The name of the lock file to read. /// /// \returns The process ID of the process that owns this lock file -Optional<std::pair<std::string, int> > +std::optional<std::pair<std::string, int>> LockFileManager::readLockFile(StringRef LockFileName) { // Read the owning host and PID out of the lock file. If it appears that the // owning process is dead, the lock file is invalid. diff --git a/llvm/lib/Support/MemoryBuffer.cpp b/llvm/lib/Support/MemoryBuffer.cpp index 77c509c..0bb1172 100644 --- a/llvm/lib/Support/MemoryBuffer.cpp +++ b/llvm/lib/Support/MemoryBuffer.cpp @@ -114,7 +114,7 @@ template <typename MB> static ErrorOr<std::unique_ptr<MB>> getFileAux(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsText, bool RequiresNullTerminator, bool IsVolatile, - Optional<Align> Alignment); + std::optional<Align> Alignment); std::unique_ptr<MemoryBuffer> MemoryBuffer::getMemBuffer(StringRef InputData, StringRef BufferName, @@ -150,7 +150,7 @@ MemoryBuffer::getMemBufferCopy(StringRef InputData, const Twine &BufferName) { ErrorOr<std::unique_ptr<MemoryBuffer>> MemoryBuffer::getFileOrSTDIN(const Twine &Filename, bool IsText, bool RequiresNullTerminator, - Optional<Align> Alignment) { + std::optional<Align> Alignment) { SmallString<256> NameBuf; StringRef NameRef = Filename.toStringRef(NameBuf); @@ -163,7 +163,7 @@ MemoryBuffer::getFileOrSTDIN(const Twine &Filename, bool IsText, ErrorOr<std::unique_ptr<MemoryBuffer>> MemoryBuffer::getFileSlice(const Twine &FilePath, uint64_t MapSize, uint64_t Offset, bool IsVolatile, - Optional<Align> Alignment) { + std::optional<Align> Alignment) { return getFileAux<MemoryBuffer>(FilePath, MapSize, Offset, /*IsText=*/false, /*RequiresNullTerminator=*/false, IsVolatile, Alignment); @@ -247,7 +247,7 @@ getMemoryBufferForStream(sys::fs::file_t FD, const Twine &BufferName) { ErrorOr<std::unique_ptr<MemoryBuffer>> MemoryBuffer::getFile(const Twine &Filename, bool IsText, bool RequiresNullTerminator, bool IsVolatile, - Optional<Align> Alignment) { + std::optional<Align> Alignment) { return getFileAux<MemoryBuffer>(Filename, /*MapSize=*/-1, /*Offset=*/0, IsText, RequiresNullTerminator, IsVolatile, Alignment); @@ -257,13 +257,13 @@ template <typename MB> static ErrorOr<std::unique_ptr<MB>> getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, uint64_t MapSize, int64_t Offset, bool RequiresNullTerminator, - bool IsVolatile, Optional<Align> Alignment); + bool IsVolatile, std::optional<Align> Alignment); template <typename MB> static ErrorOr<std::unique_ptr<MB>> getFileAux(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsText, bool RequiresNullTerminator, bool IsVolatile, - Optional<Align> Alignment) { + std::optional<Align> Alignment) { Expected<sys::fs::file_t> FDOrErr = sys::fs::openNativeFileForRead( Filename, IsText ? sys::fs::OF_TextWithCRLF : sys::fs::OF_None); if (!FDOrErr) @@ -277,7 +277,7 @@ getFileAux(const Twine &Filename, uint64_t MapSize, uint64_t Offset, ErrorOr<std::unique_ptr<WritableMemoryBuffer>> WritableMemoryBuffer::getFile(const Twine &Filename, bool IsVolatile, - Optional<Align> Alignment) { + std::optional<Align> Alignment) { return getFileAux<WritableMemoryBuffer>( Filename, /*MapSize=*/-1, /*Offset=*/0, /*IsText=*/false, /*RequiresNullTerminator=*/false, IsVolatile, Alignment); @@ -286,7 +286,7 @@ WritableMemoryBuffer::getFile(const Twine &Filename, bool IsVolatile, ErrorOr<std::unique_ptr<WritableMemoryBuffer>> WritableMemoryBuffer::getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsVolatile, - Optional<Align> Alignment) { + std::optional<Align> Alignment) { return getFileAux<WritableMemoryBuffer>( Filename, MapSize, Offset, /*IsText=*/false, /*RequiresNullTerminator=*/false, IsVolatile, Alignment); @@ -295,7 +295,7 @@ WritableMemoryBuffer::getFileSlice(const Twine &Filename, uint64_t MapSize, std::unique_ptr<WritableMemoryBuffer> WritableMemoryBuffer::getNewUninitMemBuffer(size_t Size, const Twine &BufferName, - Optional<Align> Alignment) { + std::optional<Align> Alignment) { using MemBuffer = MemoryBufferMem<WritableMemoryBuffer>; // Use 16-byte alignment if no alignment is specified. @@ -447,7 +447,7 @@ template <typename MB> static ErrorOr<std::unique_ptr<MB>> getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, uint64_t MapSize, int64_t Offset, bool RequiresNullTerminator, - bool IsVolatile, Optional<Align> Alignment) { + bool IsVolatile, std::optional<Align> Alignment) { static int PageSize = sys::Process::getPageSizeEstimate(); // Default is to map the full file. @@ -518,16 +518,15 @@ getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, ErrorOr<std::unique_ptr<MemoryBuffer>> MemoryBuffer::getOpenFile(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, bool RequiresNullTerminator, - bool IsVolatile, Optional<Align> Alignment) { + bool IsVolatile, std::optional<Align> Alignment) { return getOpenFileImpl<MemoryBuffer>(FD, Filename, FileSize, FileSize, 0, RequiresNullTerminator, IsVolatile, Alignment); } -ErrorOr<std::unique_ptr<MemoryBuffer>> -MemoryBuffer::getOpenFileSlice(sys::fs::file_t FD, const Twine &Filename, - uint64_t MapSize, int64_t Offset, - bool IsVolatile, Optional<Align> Alignment) { +ErrorOr<std::unique_ptr<MemoryBuffer>> MemoryBuffer::getOpenFileSlice( + sys::fs::file_t FD, const Twine &Filename, uint64_t MapSize, int64_t Offset, + bool IsVolatile, std::optional<Align> Alignment) { assert(MapSize != uint64_t(-1)); return getOpenFileImpl<MemoryBuffer>(FD, Filename, -1, MapSize, Offset, false, IsVolatile, Alignment); diff --git a/llvm/lib/Support/NativeFormatting.cpp b/llvm/lib/Support/NativeFormatting.cpp index ee2d885..fb02de7 100644 --- a/llvm/lib/Support/NativeFormatting.cpp +++ b/llvm/lib/Support/NativeFormatting.cpp @@ -136,7 +136,7 @@ void llvm::write_integer(raw_ostream &S, long long N, size_t MinDigits, } void llvm::write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, - Optional<size_t> Width) { + std::optional<size_t> Width) { const size_t kMaxWidth = 128u; size_t W = std::min(kMaxWidth, Width.value_or(0u)); @@ -166,7 +166,7 @@ void llvm::write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, } void llvm::write_double(raw_ostream &S, double N, FloatStyle Style, - Optional<size_t> Precision) { + std::optional<size_t> Precision) { size_t Prec = Precision.value_or(getDefaultPrecision(Style)); if (std::isnan(N)) { diff --git a/llvm/lib/Support/OptimizedStructLayout.cpp b/llvm/lib/Support/OptimizedStructLayout.cpp index 8f04311..c64eff6 100644 --- a/llvm/lib/Support/OptimizedStructLayout.cpp +++ b/llvm/lib/Support/OptimizedStructLayout.cpp @@ -346,9 +346,8 @@ llvm::performOptimizedStructLayout(MutableArrayRef<Field> Fields) { // Helper function to try to find a field in the given queue that'll // fit starting at StartOffset but before EndOffset (if present). // Note that this never fails if EndOffset is not provided. - auto tryAddFillerFromQueue = [&](AlignmentQueue *Queue, - uint64_t StartOffset, - Optional<uint64_t> EndOffset) -> bool { + auto tryAddFillerFromQueue = [&](AlignmentQueue *Queue, uint64_t StartOffset, + std::optional<uint64_t> EndOffset) -> bool { assert(Queue->Head); assert(StartOffset == alignTo(LastEnd, Queue->Alignment)); assert(!EndOffset || StartOffset < *EndOffset); @@ -357,7 +356,8 @@ llvm::performOptimizedStructLayout(MutableArrayRef<Field> Fields) { // queue if there's nothing in it that small. auto MaxViableSize = (EndOffset ? *EndOffset - StartOffset : ~(uint64_t)0); - if (Queue->MinSize > MaxViableSize) return false; + if (Queue->MinSize > MaxViableSize) + return false; // Find the matching field. Note that this should always find // something because of the MinSize check above. @@ -373,7 +373,7 @@ llvm::performOptimizedStructLayout(MutableArrayRef<Field> Fields) { // Helper function to find the "best" flexible-offset field according // to the criteria described above. - auto tryAddBestField = [&](Optional<uint64_t> BeforeOffset) -> bool { + auto tryAddBestField = [&](std::optional<uint64_t> BeforeOffset) -> bool { assert(!BeforeOffset || LastEnd < *BeforeOffset); auto QueueB = FlexibleFieldsByAlignment.begin(); auto QueueE = FlexibleFieldsByAlignment.end(); diff --git a/llvm/lib/Support/SymbolRemappingReader.cpp b/llvm/lib/Support/SymbolRemappingReader.cpp index 3cae577..0082696 100644 --- a/llvm/lib/Support/SymbolRemappingReader.cpp +++ b/llvm/lib/Support/SymbolRemappingReader.cpp @@ -48,11 +48,11 @@ Error SymbolRemappingReader::read(MemoryBuffer &B) { "found '" + Line + "'"); using FK = ItaniumManglingCanonicalizer::FragmentKind; - Optional<FK> FragmentKind = StringSwitch<Optional<FK>>(Parts[0]) - .Case("name", FK::Name) - .Case("type", FK::Type) - .Case("encoding", FK::Encoding) - .Default(std::nullopt); + std::optional<FK> FragmentKind = StringSwitch<std::optional<FK>>(Parts[0]) + .Case("name", FK::Name) + .Case("type", FK::Type) + .Case("encoding", FK::Encoding) + .Default(std::nullopt); if (!FragmentKind) return ReportError("Invalid kind, expected 'name', 'type', or 'encoding'," " found '" + Parts[0] + "'"); diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp index 24962ae..f4e3331 100644 --- a/llvm/lib/Support/Threading.cpp +++ b/llvm/lib/Support/Threading.cpp @@ -82,9 +82,9 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const { // which is not enough for some/many normal LLVM compilations. This implements // the same interface as std::thread but requests the same stack size as the // main thread (8MB) before creation. -const llvm::Optional<unsigned> llvm::thread::DefaultStackSize = 8 * 1024 * 1024; +const std::optional<unsigned> llvm::thread::DefaultStackSize = 8 * 1024 * 1024; #else -const llvm::Optional<unsigned> llvm::thread::DefaultStackSize; +const std::optional<unsigned> llvm::thread::DefaultStackSize; #endif diff --git a/llvm/lib/Support/UnicodeNameToCodepoint.cpp b/llvm/lib/Support/UnicodeNameToCodepoint.cpp index 5fb6125..a10a7e8 100644 --- a/llvm/lib/Support/UnicodeNameToCodepoint.cpp +++ b/llvm/lib/Support/UnicodeNameToCodepoint.cpp @@ -285,7 +285,7 @@ static std::size_t findSyllable(StringRef Name, bool Strict, return size_t(Len); } -static llvm::Optional<char32_t> +static std::optional<char32_t> nameToHangulCodePoint(StringRef Name, bool Strict, BufferType &Buffer) { Buffer.clear(); // Hangul Syllable Decomposition @@ -343,7 +343,7 @@ static const GeneratedNamesData GeneratedNamesDataTable[] = { {"CJK COMPATIBILITY IDEOGRAPH-", 0x2F800, 0x2FA1D}, }; -static llvm::Optional<char32_t> +static std::optional<char32_t> nameToGeneratedCodePoint(StringRef Name, bool Strict, BufferType &Buffer) { for (auto &&Item : GeneratedNamesDataTable) { Buffer.clear(); @@ -370,12 +370,12 @@ nameToGeneratedCodePoint(StringRef Name, bool Strict, BufferType &Buffer) { return std::nullopt; } -static llvm::Optional<char32_t> nameToCodepoint(StringRef Name, bool Strict, - BufferType &Buffer) { +static std::optional<char32_t> nameToCodepoint(StringRef Name, bool Strict, + BufferType &Buffer) { if (Name.empty()) return std::nullopt; - llvm::Optional<char32_t> Res = nameToHangulCodePoint(Name, Strict, Buffer); + std::optional<char32_t> Res = nameToHangulCodePoint(Name, Strict, Buffer); if (!Res) Res = nameToGeneratedCodePoint(Name, Strict, Buffer); if (Res) @@ -400,14 +400,14 @@ static llvm::Optional<char32_t> nameToCodepoint(StringRef Name, bool Strict, return std::nullopt; } -llvm::Optional<char32_t> nameToCodepointStrict(StringRef Name) { +std::optional<char32_t> nameToCodepointStrict(StringRef Name) { BufferType Buffer; auto Opt = nameToCodepoint(Name, true, Buffer); return Opt; } -llvm::Optional<LooseMatchingResult> +std::optional<LooseMatchingResult> nameToCodepointLooseMatching(StringRef Name) { BufferType Buffer; auto Opt = nameToCodepoint(Name, false, Buffer); diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc index def6afa..819748d 100644 --- a/llvm/lib/Support/Unix/Threading.inc +++ b/llvm/lib/Support/Unix/Threading.inc @@ -58,7 +58,7 @@ namespace llvm { pthread_t llvm_execute_on_thread_impl(void *(*ThreadFunc)(void *), void *Arg, - llvm::Optional<unsigned> StackSizeInBytes) { + std::optional<unsigned> StackSizeInBytes) { int errnum; // Construct the attributes object. diff --git a/llvm/lib/Support/VersionTuple.cpp b/llvm/lib/Support/VersionTuple.cpp index 6a51648..c0e0072 100644 --- a/llvm/lib/Support/VersionTuple.cpp +++ b/llvm/lib/Support/VersionTuple.cpp @@ -29,11 +29,11 @@ std::string VersionTuple::getAsString() const { raw_ostream &llvm::operator<<(raw_ostream &Out, const VersionTuple &V) { Out << V.getMajor(); - if (Optional<unsigned> Minor = V.getMinor()) + if (std::optional<unsigned> Minor = V.getMinor()) Out << '.' << *Minor; - if (Optional<unsigned> Subminor = V.getSubminor()) + if (std::optional<unsigned> Subminor = V.getSubminor()) Out << '.' << *Subminor; - if (Optional<unsigned> Build = V.getBuild()) + if (std::optional<unsigned> Build = V.getBuild()) Out << '.' << *Build; return Out; } diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index f210143..eac6fc9 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -814,10 +814,10 @@ std::string InMemoryFileSystem::toString() const { bool InMemoryFileSystem::addFile(const Twine &P, time_t ModificationTime, std::unique_ptr<llvm::MemoryBuffer> Buffer, - Optional<uint32_t> User, - Optional<uint32_t> Group, - Optional<llvm::sys::fs::file_type> Type, - Optional<llvm::sys::fs::perms> Perms, + std::optional<uint32_t> User, + std::optional<uint32_t> Group, + std::optional<llvm::sys::fs::file_type> Type, + std::optional<llvm::sys::fs::perms> Perms, MakeNodeFn MakeNode) { SmallString<128> Path; P.toVector(Path); @@ -891,10 +891,10 @@ bool InMemoryFileSystem::addFile(const Twine &P, time_t ModificationTime, bool InMemoryFileSystem::addFile(const Twine &P, time_t ModificationTime, std::unique_ptr<llvm::MemoryBuffer> Buffer, - Optional<uint32_t> User, - Optional<uint32_t> Group, - Optional<llvm::sys::fs::file_type> Type, - Optional<llvm::sys::fs::perms> Perms) { + std::optional<uint32_t> User, + std::optional<uint32_t> Group, + std::optional<llvm::sys::fs::file_type> Type, + std::optional<llvm::sys::fs::perms> Perms) { return addFile(P, ModificationTime, std::move(Buffer), User, Group, Type, Perms, [](detail::NewInMemoryNodeInfo NNI) @@ -907,12 +907,11 @@ bool InMemoryFileSystem::addFile(const Twine &P, time_t ModificationTime, }); } -bool InMemoryFileSystem::addFileNoOwn(const Twine &P, time_t ModificationTime, - const llvm::MemoryBufferRef &Buffer, - Optional<uint32_t> User, - Optional<uint32_t> Group, - Optional<llvm::sys::fs::file_type> Type, - Optional<llvm::sys::fs::perms> Perms) { +bool InMemoryFileSystem::addFileNoOwn( + const Twine &P, time_t ModificationTime, + const llvm::MemoryBufferRef &Buffer, std::optional<uint32_t> User, + std::optional<uint32_t> Group, std::optional<llvm::sys::fs::file_type> Type, + std::optional<llvm::sys::fs::perms> Perms) { return addFile(P, ModificationTime, llvm::MemoryBuffer::getMemBuffer(Buffer), std::move(User), std::move(Group), std::move(Type), std::move(Perms), @@ -1020,12 +1019,10 @@ bool InMemoryFileSystem::addHardLink(const Twine &NewLink, }); } -bool InMemoryFileSystem::addSymbolicLink(const Twine &NewLink, - const Twine &Target, - time_t ModificationTime, - Optional<uint32_t> User, - Optional<uint32_t> Group, - Optional<llvm::sys::fs::perms> Perms) { +bool InMemoryFileSystem::addSymbolicLink( + const Twine &NewLink, const Twine &Target, time_t ModificationTime, + std::optional<uint32_t> User, std::optional<uint32_t> Group, + std::optional<llvm::sys::fs::perms> Perms) { auto NewLinkNode = lookupNode(NewLink, /*FollowFinalSymlink=*/false); if (NewLinkNode) return false; @@ -2272,7 +2269,7 @@ static Status getRedirectedFileStatus(const Twine &OriginalPath, ErrorOr<Status> RedirectingFileSystem::status( const Twine &CanonicalPath, const Twine &OriginalPath, const RedirectingFileSystem::LookupResult &Result) { - if (Optional<StringRef> ExtRedirect = Result.getExternalRedirect()) { + if (std::optional<StringRef> ExtRedirect = Result.getExternalRedirect()) { SmallString<256> CanonicalRemappedPath((*ExtRedirect).str()); if (std::error_code EC = makeCanonical(CanonicalRemappedPath)) return EC; @@ -2603,9 +2600,10 @@ class JSONWriter { public: JSONWriter(llvm::raw_ostream &OS) : OS(OS) {} - void write(ArrayRef<YAMLVFSEntry> Entries, Optional<bool> UseExternalNames, - Optional<bool> IsCaseSensitive, Optional<bool> IsOverlayRelative, - StringRef OverlayDir); + void write(ArrayRef<YAMLVFSEntry> Entries, + std::optional<bool> UseExternalNames, + std::optional<bool> IsCaseSensitive, + std::optional<bool> IsOverlayRelative, StringRef OverlayDir); }; } // namespace @@ -2660,9 +2658,9 @@ void JSONWriter::writeEntry(StringRef VPath, StringRef RPath) { } void JSONWriter::write(ArrayRef<YAMLVFSEntry> Entries, - Optional<bool> UseExternalNames, - Optional<bool> IsCaseSensitive, - Optional<bool> IsOverlayRelative, + std::optional<bool> UseExternalNames, + std::optional<bool> IsCaseSensitive, + std::optional<bool> IsOverlayRelative, StringRef OverlayDir) { using namespace llvm::sys; diff --git a/llvm/lib/Support/Windows/Threading.inc b/llvm/lib/Support/Windows/Threading.inc index aaeda2f..2c16fe4 100644 --- a/llvm/lib/Support/Windows/Threading.inc +++ b/llvm/lib/Support/Windows/Threading.inc @@ -26,7 +26,7 @@ namespace llvm { HANDLE llvm_execute_on_thread_impl(unsigned(__stdcall *ThreadFunc)(void *), void *Arg, - llvm::Optional<unsigned> StackSizeInBytes) { + std::optional<unsigned> StackSizeInBytes) { HANDLE hThread = (HANDLE)::_beginthreadex(NULL, StackSizeInBytes.value_or(0), ThreadFunc, Arg, 0, NULL); diff --git a/llvm/lib/Support/Z3Solver.cpp b/llvm/lib/Support/Z3Solver.cpp index 499548e..a49bedc 100644 --- a/llvm/lib/Support/Z3Solver.cpp +++ b/llvm/lib/Support/Z3Solver.cpp @@ -870,7 +870,7 @@ public: return toAPFloat(Sort, Assign, Float, true); } - Optional<bool> check() const override { + std::optional<bool> check() const override { Z3_lbool res = Z3_solver_check(Context.Context, Solver); if (res == Z3_L_TRUE) return true; |