[mlir] Use std::optional instead of llvm::Optional (NFC)

This patch replaces (llvm::|)Optional< with std::optional<.  I'll post
a separate patch to remove #include "llvm/ADT/Optional.h".

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
This commit is contained in:
Kazu Hirata
2023-01-14 01:25:58 -08:00
parent bb83dc10f5
commit 0a81ace004
244 changed files with 1210 additions and 1121 deletions

View File

@@ -1121,8 +1121,8 @@ private:
// Resource Section
LogicalResult
parseResourceSection(Optional<ArrayRef<uint8_t>> resourceData,
Optional<ArrayRef<uint8_t>> resourceOffsetData);
parseResourceSection(std::optional<ArrayRef<uint8_t>> resourceData,
std::optional<ArrayRef<uint8_t>> resourceOffsetData);
//===--------------------------------------------------------------------===//
// IR Section
@@ -1269,7 +1269,8 @@ LogicalResult BytecodeReader::read(llvm::MemoryBufferRef buffer, Block *block) {
});
// Parse the raw data for each of the top-level sections of the bytecode.
Optional<ArrayRef<uint8_t>> sectionDatas[bytecode::Section::kNumSections];
std::optional<ArrayRef<uint8_t>>
sectionDatas[bytecode::Section::kNumSections];
while (!reader.empty()) {
// Read the next section from the bytecode.
bytecode::Section::ID sectionID;
@@ -1389,8 +1390,8 @@ FailureOr<OperationName> BytecodeReader::parseOpName(EncodingReader &reader) {
// Resource Section
LogicalResult BytecodeReader::parseResourceSection(
Optional<ArrayRef<uint8_t>> resourceData,
Optional<ArrayRef<uint8_t>> resourceOffsetData) {
std::optional<ArrayRef<uint8_t>> resourceData,
std::optional<ArrayRef<uint8_t>> resourceOffsetData) {
// Ensure both sections are either present or not.
if (resourceData.has_value() != resourceOffsetData.has_value()) {
if (resourceOffsetData)