[flang-commits] [flang] c092158 - [flang] Use std::optional instead of llvm::Optional (NFC)
Kazu Hirata via flang-commits
flang-commits at lists.llvm.org
Sat Jan 7 22:26:55 PST 2023
Author: Kazu Hirata
Date: 2023-01-07T22:26:48-08:00
New Revision: c09215860fd5c32012ef4fdc5a001485a04fe85a
URL: https://github.com/llvm/llvm-project/commit/c09215860fd5c32012ef4fdc5a001485a04fe85a
DIFF: https://github.com/llvm/llvm-project/commit/c09215860fd5c32012ef4fdc5a001485a04fe85a.diff
LOG: [flang] 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
Added:
Modified:
flang/include/flang/Lower/BoxAnalyzer.h
flang/include/flang/Lower/ComponentPath.h
flang/include/flang/Lower/ConvertCall.h
flang/include/flang/Lower/ConvertExpr.h
flang/include/flang/Lower/CustomIntrinsicCall.h
flang/include/flang/Lower/IntrinsicCall.h
flang/include/flang/Lower/IterationSpace.h
flang/include/flang/Lower/Runtime.h
flang/include/flang/Lower/SymbolMap.h
flang/include/flang/Optimizer/Builder/FIRBuilder.h
flang/include/flang/Optimizer/Builder/HLFIRTools.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/CallInterface.cpp
flang/lib/Lower/ConvertCall.cpp
flang/lib/Lower/ConvertExpr.cpp
flang/lib/Lower/ConvertExprToHLFIR.cpp
flang/lib/Lower/ConvertVariable.cpp
flang/lib/Lower/CustomIntrinsicCall.cpp
flang/lib/Lower/HostAssociations.cpp
flang/lib/Lower/IO.cpp
flang/lib/Lower/IntrinsicCall.cpp
flang/lib/Lower/IterationSpace.cpp
flang/lib/Lower/Mangler.cpp
flang/lib/Lower/Runtime.cpp
flang/lib/Lower/SymbolMap.cpp
flang/lib/Optimizer/Builder/FIRBuilder.cpp
flang/lib/Optimizer/Builder/HLFIRTools.cpp
flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
flang/lib/Optimizer/Support/InternalNames.cpp
flang/lib/Optimizer/Transforms/AffinePromotion.cpp
flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp
flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Lower/BoxAnalyzer.h b/flang/include/flang/Lower/BoxAnalyzer.h
index 07588e8410c9..52cded8b219d 100644
--- a/flang/include/flang/Lower/BoxAnalyzer.h
+++ b/flang/include/flang/Lower/BoxAnalyzer.h
@@ -77,7 +77,7 @@ struct ScalarDynamicChar : ScalarSym {
ScalarDynamicChar(const Fortran::semantics::Symbol &sym)
: ScalarSym{sym}, len{FromBox{}} {}
- llvm::Optional<Fortran::lower::SomeExpr> charLen() const {
+ std::optional<Fortran::lower::SomeExpr> charLen() const {
if (auto *l = std::get_if<Fortran::lower::SomeExpr>(&len))
return {*l};
return std::nullopt;
@@ -318,8 +318,8 @@ class BoxAnalyzer : public fir::details::matcher<BoxAnalyzer> {
[](const auto &x) { return x.staticSize(); });
}
- llvm::Optional<int64_t> getCharLenConst() const {
- using A = llvm::Optional<int64_t>;
+ std::optional<int64_t> getCharLenConst() const {
+ using A = std::optional<int64_t>;
return match(
[](const ScalarStaticChar &x) -> A { return {x.charLen()}; },
[](const StaticArrayStaticChar &x) -> A { return {x.charLen()}; },
@@ -327,8 +327,8 @@ class BoxAnalyzer : public fir::details::matcher<BoxAnalyzer> {
[](const auto &) -> A { return std::nullopt; });
}
- llvm::Optional<Fortran::lower::SomeExpr> getCharLenExpr() const {
- using A = llvm::Optional<Fortran::lower::SomeExpr>;
+ std::optional<Fortran::lower::SomeExpr> getCharLenExpr() const {
+ using A = std::optional<Fortran::lower::SomeExpr>;
return match([](const ScalarDynamicChar &x) { return x.charLen(); },
[](const StaticArrayDynamicChar &x) { return x.charLen(); },
[](const DynamicArrayDynamicChar &x) { return x.charLen(); },
@@ -472,9 +472,9 @@ class BoxAnalyzer : public fir::details::matcher<BoxAnalyzer> {
}
// Get the constant LEN of a CHARACTER, if it exists.
- llvm::Optional<int64_t>
+ std::optional<int64_t>
charLenConstant(const Fortran::semantics::Symbol &sym) {
- if (llvm::Optional<Fortran::lower::SomeExpr> expr = charLenVariable(sym))
+ if (std::optional<Fortran::lower::SomeExpr> expr = charLenVariable(sym))
if (std::optional<int64_t> asInt = Fortran::evaluate::ToInt64(*expr)) {
// Length is max(0, *asInt) (F2018 7.4.4.2 point 5.).
if (*asInt < 0)
@@ -485,7 +485,7 @@ class BoxAnalyzer : public fir::details::matcher<BoxAnalyzer> {
}
// Get the `SomeExpr` that describes the CHARACTER's LEN.
- llvm::Optional<Fortran::lower::SomeExpr>
+ std::optional<Fortran::lower::SomeExpr>
charLenVariable(const Fortran::semantics::Symbol &sym) {
const Fortran::semantics::ParamValue &lenParam =
sym.GetType()->characterTypeSpec().length();
diff --git a/flang/include/flang/Lower/ComponentPath.h b/flang/include/flang/Lower/ComponentPath.h
index fb8395ba008d..69960bad4e05 100644
--- a/flang/include/flang/Lower/ComponentPath.h
+++ b/flang/include/flang/Lower/ComponentPath.h
@@ -69,7 +69,7 @@ class ComponentPath {
/// This optional continuation allows the generation of those dereferences.
/// These accesses are always on Fortran entities of record types, which are
/// implicitly in-memory objects.
- llvm::Optional<ExtendRefFunc> extendCoorRef = std::nullopt;
+ std::optional<ExtendRefFunc> extendCoorRef = std::nullopt;
private:
void setPC(bool isImplicit);
diff --git a/flang/include/flang/Lower/ConvertCall.h b/flang/include/flang/Lower/ConvertCall.h
index 33008a17457f..9336468ec221 100644
--- a/flang/include/flang/Lower/ConvertCall.h
+++ b/flang/include/flang/Lower/ConvertCall.h
@@ -32,7 +32,7 @@ fir::ExtendedValue genCallOpAndResult(
mlir::Location loc, Fortran::lower::AbstractConverter &converter,
Fortran::lower::SymMap &symMap, Fortran::lower::StatementContext &stmtCtx,
Fortran::lower::CallerInterface &caller, mlir::FunctionType callSiteType,
- llvm::Optional<mlir::Type> resultType);
+ std::optional<mlir::Type> resultType);
/// If \p arg is the address of a function with a denoted host-association tuple
/// argument, then return the host-associations tuple value of the current
@@ -42,11 +42,10 @@ mlir::Value argumentHostAssocs(Fortran::lower::AbstractConverter &converter,
/// Lower a ProcedureRef to HLFIR. If this is a function call, return the
/// lowered result value. Return nothing otherwise.
-llvm::Optional<hlfir::EntityWithAttributes> convertCallToHLFIR(
+std::optional<hlfir::EntityWithAttributes> convertCallToHLFIR(
mlir::Location loc, Fortran::lower::AbstractConverter &converter,
- const evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> resultType, Fortran::lower::SymMap &symMap,
- Fortran::lower::StatementContext &stmtCtx);
+ const evaluate::ProcedureRef &procRef, std::optional<mlir::Type> resultType,
+ Fortran::lower::SymMap &symMap, Fortran::lower::StatementContext &stmtCtx);
} // namespace Fortran::lower
#endif // FORTRAN_LOWER_CONVERTCALL_H
diff --git a/flang/include/flang/Lower/ConvertExpr.h b/flang/include/flang/Lower/ConvertExpr.h
index bf681e9a9692..e8b388bd0b7f 100644
--- a/flang/include/flang/Lower/ConvertExpr.h
+++ b/flang/include/flang/Lower/ConvertExpr.h
@@ -176,7 +176,7 @@ void createArrayOfPointerAssignment(
AbstractConverter &converter, const SomeExpr &lhs, const SomeExpr &rhs,
ExplicitIterSpace &explicitIterSpace, ImplicitIterSpace &implicitIterSpace,
const llvm::SmallVector<mlir::Value> &lbounds,
- llvm::Optional<llvm::SmallVector<mlir::Value>> ubounds, SymMap &symMap,
+ std::optional<llvm::SmallVector<mlir::Value>> ubounds, SymMap &symMap,
StatementContext &stmtCtx);
/// Lower an array expression with "parallel" semantics. Such a rhs expression
diff --git a/flang/include/flang/Lower/CustomIntrinsicCall.h b/flang/include/flang/Lower/CustomIntrinsicCall.h
index 9ae84fd62362..bb7e599a4f49 100644
--- a/flang/include/flang/Lower/CustomIntrinsicCall.h
+++ b/flang/include/flang/Lower/CustomIntrinsicCall.h
@@ -54,7 +54,7 @@ using OperandPrepare = std::function<void(const Fortran::lower::SomeExpr &)>;
/// preparation was done. An absent optional means the argument is statically
/// present. An mlir::Value means the presence must be checked at runtime, and
/// that the value contains the "is present" boolean value.
-using OperandPresent = std::function<llvm::Optional<mlir::Value>(std::size_t)>;
+using OperandPresent = std::function<std::optional<mlir::Value>(std::size_t)>;
/// Type of the callback to generate an argument reference after the call
/// preparation was done. For optional arguments, the utility guarantees
@@ -77,7 +77,7 @@ using OperandGetter = std::function<fir::ExtendedValue(std::size_t)>;
void prepareCustomIntrinsicArgument(
const Fortran::evaluate::ProcedureRef &procRef,
const Fortran::evaluate::SpecificIntrinsic &intrinsic,
- llvm::Optional<mlir::Type> retTy,
+ std::optional<mlir::Type> retTy,
const OperandPrepare &prepareOptionalArgument,
const OperandPrepare &prepareOtherArgument, AbstractConverter &converter);
@@ -90,7 +90,7 @@ void prepareCustomIntrinsicArgument(
/// not generate any implicit loop nest on its own).
fir::ExtendedValue
lowerCustomIntrinsic(fir::FirOpBuilder &builder, mlir::Location loc,
- llvm::StringRef name, llvm::Optional<mlir::Type> retTy,
+ llvm::StringRef name, std::optional<mlir::Type> retTy,
const OperandPresent &isPresentCheck,
const OperandGetter &getOperand, std::size_t numOperands,
Fortran::lower::StatementContext &stmtCtx);
diff --git a/flang/include/flang/Lower/IntrinsicCall.h b/flang/include/flang/Lower/IntrinsicCall.h
index cd7c7a622cd0..0d404fe9b43b 100644
--- a/flang/include/flang/Lower/IntrinsicCall.h
+++ b/flang/include/flang/Lower/IntrinsicCall.h
@@ -29,7 +29,7 @@ class StatementContext;
/// Returned mlir::Value is the returned Fortran intrinsic value.
fir::ExtendedValue genIntrinsicCall(fir::FirOpBuilder &, mlir::Location,
llvm::StringRef name,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args,
StatementContext &);
diff --git a/flang/include/flang/Lower/IterationSpace.h b/flang/include/flang/Lower/IterationSpace.h
index a7de970b4c74..1c413a5f0c11 100644
--- a/flang/include/flang/Lower/IterationSpace.h
+++ b/flang/include/flang/Lower/IterationSpace.h
@@ -445,7 +445,7 @@ class ExplicitIterSpace {
}
/// `load` must be a LHS array_load. Returns `std::nullopt` on error.
- llvm::Optional<size_t> findArgPosition(fir::ArrayLoadOp load);
+ std::optional<size_t> findArgPosition(fir::ArrayLoadOp load);
bool isLHS(fir::ArrayLoadOp load) {
return findArgPosition(load).has_value();
@@ -466,7 +466,7 @@ class ExplicitIterSpace {
llvm_unreachable("inner argument value was not found");
}
- llvm::Optional<fir::ArrayLoadOp> getLhsLoad(size_t i) {
+ std::optional<fir::ArrayLoadOp> getLhsLoad(size_t i) {
assert(i < lhsBases.size());
if (lhsBases[counter])
return findBinding(*lhsBases[counter]);
@@ -542,7 +542,7 @@ class ExplicitIterSpace {
// A stack of lists of front-end symbols.
llvm::SmallVector<llvm::SmallVector<FrontEndSymbol>> symbolStack;
- llvm::SmallVector<llvm::Optional<ArrayBases>> lhsBases;
+ llvm::SmallVector<std::optional<ArrayBases>> lhsBases;
llvm::SmallVector<llvm::SmallVector<ArrayBases>> rhsBases;
llvm::DenseMap<ArrayBases, fir::ArrayLoadOp> loadBindings;
@@ -553,9 +553,9 @@ class ExplicitIterSpace {
StatementContext stmtCtx;
llvm::SmallVector<mlir::Value> innerArgs;
llvm::SmallVector<mlir::Value> initialArgs;
- llvm::Optional<fir::DoLoopOp> outerLoop;
+ std::optional<fir::DoLoopOp> outerLoop;
llvm::SmallVector<llvm::SmallVector<fir::DoLoopOp>> loopStack;
- llvm::Optional<std::function<void(fir::FirOpBuilder &)>> loopCleanup;
+ std::optional<std::function<void(fir::FirOpBuilder &)>> loopCleanup;
std::size_t forallContextOpen = 0;
std::size_t counter = 0;
};
diff --git a/flang/include/flang/Lower/Runtime.h b/flang/include/flang/Lower/Runtime.h
index da01d1a87ccc..1c4b98f084e1 100644
--- a/flang/include/flang/Lower/Runtime.h
+++ b/flang/include/flang/Lower/Runtime.h
@@ -78,9 +78,9 @@ void genPointerAssociateRemapping(fir::FirOpBuilder &, mlir::Location,
mlir::Value genCpuTime(fir::FirOpBuilder &, mlir::Location);
void genDateAndTime(fir::FirOpBuilder &, mlir::Location,
- llvm::Optional<fir::CharBoxValue> date,
- llvm::Optional<fir::CharBoxValue> time,
- llvm::Optional<fir::CharBoxValue> zone, mlir::Value values);
+ std::optional<fir::CharBoxValue> date,
+ std::optional<fir::CharBoxValue> time,
+ std::optional<fir::CharBoxValue> zone, mlir::Value values);
void genRandomInit(fir::FirOpBuilder &, mlir::Location, mlir::Value repeatable,
mlir::Value imageDistinct);
diff --git a/flang/include/flang/Lower/SymbolMap.h b/flang/include/flang/Lower/SymbolMap.h
index f3450f5b2356..f65e55168edf 100644
--- a/flang/include/flang/Lower/SymbolMap.h
+++ b/flang/include/flang/Lower/SymbolMap.h
@@ -349,7 +349,7 @@ class SymMap {
symbolMapStack.back().try_emplace(sym, definingOp);
}
- llvm::Optional<fir::FortranVariableOpInterface>
+ std::optional<fir::FortranVariableOpInterface>
lookupVariableDefinition(semantics::SymbolRef sym);
private:
diff --git a/flang/include/flang/Optimizer/Builder/FIRBuilder.h b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
index b44d9faf6fe2..682b45746bd3 100644
--- a/flang/include/flang/Optimizer/Builder/FIRBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
@@ -596,8 +596,8 @@ mlir::Value createZeroValue(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Type type);
/// Get the integer constants of triplet and compute the extent.
-llvm::Optional<std::int64_t>
-getExtentFromTriplet(mlir::Value lb, mlir::Value ub, mlir::Value stride);
+std::optional<std::int64_t> getExtentFromTriplet(mlir::Value lb, mlir::Value ub,
+ mlir::Value stride);
/// Generate max(\p value, 0) where \p value is a scalar integer.
mlir::Value genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
diff --git a/flang/include/flang/Optimizer/Builder/HLFIRTools.h b/flang/include/flang/Optimizer/Builder/HLFIRTools.h
index cb37484a934e..e2886f6058ac 100644
--- a/flang/include/flang/Optimizer/Builder/HLFIRTools.h
+++ b/flang/include/flang/Optimizer/Builder/HLFIRTools.h
@@ -163,7 +163,7 @@ class EntityWithAttributes : public Entity {
/// In that case, a cleanup function is provided to generate the finalization
/// code after the end of the fir::ExtendedValue use.
using CleanupFunction = std::function<void()>;
-std::pair<fir::ExtendedValue, llvm::Optional<CleanupFunction>>
+std::pair<fir::ExtendedValue, std::optional<CleanupFunction>>
translateToExtendedValue(mlir::Location loc, fir::FirOpBuilder &builder,
Entity entity);
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index b17d197ff98b..0e9e94503ad8 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -133,7 +133,7 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
if (const llvm::opt::Arg *A =
args.getLastArg(clang::driver::options::OPT_mrelocation_model)) {
llvm::StringRef ModelName = A->getValue();
- auto RM = llvm::StringSwitch<llvm::Optional<llvm::Reloc::Model>>(ModelName)
+ auto RM = llvm::StringSwitch<std::optional<llvm::Reloc::Model>>(ModelName)
.Case("static", llvm::Reloc::Static)
.Case("pic", llvm::Reloc::PIC_)
.Case("dynamic-no-pic", llvm::Reloc::DynamicNoPIC)
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index c5551ff0810e..9f10ec59a988 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -823,7 +823,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
Fortran::lower::SymbolBox
lookupSymbol(const Fortran::semantics::Symbol &sym) {
if (bridge.getLoweringOptions().getLowerToHighLevelFIR()) {
- if (llvm::Optional<fir::FortranVariableOpInterface> var =
+ if (std::optional<fir::FortranVariableOpInterface> var =
localSymbols.lookupVariableDefinition(sym)) {
auto exv =
hlfir::translateToExtendedValue(toLocation(), *builder, *var);
@@ -1098,7 +1098,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
assert(stmt.typedCall && "Call was not analyzed");
mlir::Value res{};
if (bridge.getLoweringOptions().getLowerToHighLevelFIR()) {
- llvm::Optional<mlir::Type> resultType = std::nullopt;
+ std::optional<mlir::Type> resultType = std::nullopt;
if (stmt.typedCall->hasAlternateReturns())
resultType = builder->getIndexType();
auto hlfirRes = Fortran::lower::convertCallToHLFIR(
@@ -2544,8 +2544,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
void genArrayAssignment(
const Fortran::evaluate::Assignment &assign,
Fortran::lower::StatementContext &localStmtCtx,
- llvm::Optional<llvm::SmallVector<mlir::Value>> lbounds = std::nullopt,
- llvm::Optional<llvm::SmallVector<mlir::Value>> ubounds = std::nullopt) {
+ std::optional<llvm::SmallVector<mlir::Value>> lbounds = std::nullopt,
+ std::optional<llvm::SmallVector<mlir::Value>> ubounds = std::nullopt) {
Fortran::lower::StatementContext &stmtCtx =
explicitIterationSpace()
@@ -2697,8 +2697,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
: genExprAddr(assign.rhs, stmtCtx);
const bool lhsIsWholeAllocatable =
Fortran::lower::isWholeAllocatable(assign.lhs);
- llvm::Optional<fir::factory::MutableBoxReallocation> lhsRealloc;
- llvm::Optional<fir::MutableBoxValue> lhsMutableBox;
+ std::optional<fir::factory::MutableBoxReallocation> lhsRealloc;
+ std::optional<fir::MutableBoxValue> lhsMutableBox;
auto lhs = [&]() -> fir::ExtendedValue {
if (lhsIsWholeAllocatable) {
lhsMutableBox = genExprMutableBox(loc, assign.lhs);
diff --git a/flang/lib/Lower/CallInterface.cpp b/flang/lib/Lower/CallInterface.cpp
index 41be1b0eabcd..2034c7c6055e 100644
--- a/flang/lib/Lower/CallInterface.cpp
+++ b/flang/lib/Lower/CallInterface.cpp
@@ -686,7 +686,7 @@ class Fortran::lower::CallInterfaceImpl {
interface.side().getHostAssociatedTuple(), emptyValue()});
}
- static llvm::Optional<Fortran::evaluate::DynamicType> getResultDynamicType(
+ static std::optional<Fortran::evaluate::DynamicType> getResultDynamicType(
const Fortran::evaluate::characteristics::Procedure &procedure) {
if (const std::optional<Fortran::evaluate::characteristics::FunctionResult>
&result = procedure.functionResult)
@@ -714,7 +714,7 @@ class Fortran::lower::CallInterfaceImpl {
// array function with assumed length (f18 forbides defining such
// interfaces). Hence, passing the length is most likely useless, but stick
// with ifort/nag/xlf interface here.
- if (llvm::Optional<Fortran::evaluate::DynamicType> type =
+ if (std::optional<Fortran::evaluate::DynamicType> type =
getResultDynamicType(procedure))
return type->category() == Fortran::common::TypeCategory::Character;
return false;
@@ -987,7 +987,7 @@ class Fortran::lower::CallInterfaceImpl {
proc.procedure.value();
mlir::Type funcType =
getProcedureDesignatorType(&procedure, interface.converter);
- llvm::Optional<Fortran::evaluate::DynamicType> resultTy =
+ std::optional<Fortran::evaluate::DynamicType> resultTy =
getResultDynamicType(procedure);
if (resultTy && mustPassLengthWithDummyProcedure(procedure)) {
// The result length of dummy procedures that are character functions must
diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp
index 926f6ce207dd..70905d591e6e 100644
--- a/flang/lib/Lower/ConvertCall.cpp
+++ b/flang/lib/Lower/ConvertCall.cpp
@@ -103,7 +103,7 @@ fir::ExtendedValue Fortran::lower::genCallOpAndResult(
mlir::Location loc, Fortran::lower::AbstractConverter &converter,
Fortran::lower::SymMap &symMap, Fortran::lower::StatementContext &stmtCtx,
Fortran::lower::CallerInterface &caller, mlir::FunctionType callSiteType,
- llvm::Optional<mlir::Type> resultType) {
+ std::optional<mlir::Type> resultType) {
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
using PassBy = Fortran::lower::CallerInterface::PassEntityBy;
// Handle cases where caller must allocate the result or a fir.box for it.
@@ -137,7 +137,7 @@ fir::ExtendedValue Fortran::lower::genCallOpAndResult(
return fir::factory::genMaxWithZero(builder, loc, convertExpr);
};
llvm::SmallVector<mlir::Value> resultLengths;
- auto allocatedResult = [&]() -> llvm::Optional<fir::ExtendedValue> {
+ auto allocatedResult = [&]() -> std::optional<fir::ExtendedValue> {
llvm::SmallVector<mlir::Value> extents;
llvm::SmallVector<mlir::Value> lengths;
if (!caller.callerAllocateResult())
@@ -514,7 +514,7 @@ class CallBuilder {
bool handleDynamicOptional;
};
using PreparedActualArguments =
- llvm::SmallVector<llvm::Optional<PreparedActualArgument>>;
+ llvm::SmallVector<std::optional<PreparedActualArgument>>;
using PassBy = Fortran::lower::CallerInterface::PassEntityBy;
public:
@@ -523,9 +523,9 @@ class CallBuilder {
Fortran::lower::StatementContext &stmtCtx)
: converter{converter}, symMap{symMap}, stmtCtx{stmtCtx}, loc{loc} {}
- llvm::Optional<hlfir::EntityWithAttributes>
+ std::optional<hlfir::EntityWithAttributes>
gen(const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> resultType) {
+ std::optional<mlir::Type> resultType) {
mlir::Location loc = getLoc();
if (auto *specific = procRef.proc().GetSpecificIntrinsic()) {
if (isElementalProcWithArrayArgs(procRef))
@@ -571,10 +571,10 @@ class CallBuilder {
}
private:
- llvm::Optional<hlfir::EntityWithAttributes>
+ std::optional<hlfir::EntityWithAttributes>
genUserCall(PreparedActualArguments &loweredActuals,
Fortran::lower::CallerInterface &caller,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
mlir::FunctionType callSiteType) {
mlir::Location loc = getLoc();
fir::FirOpBuilder &builder = getBuilder();
@@ -667,10 +667,10 @@ class CallBuilder {
return extendedValueToHlfirEntity(result, ".tmp.func_result");
}
- llvm::Optional<hlfir::EntityWithAttributes>
+ std::optional<hlfir::EntityWithAttributes>
genElementalUserCall(PreparedActualArguments &loweredActuals,
Fortran::lower::CallerInterface &caller,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
mlir::FunctionType callSiteType, bool isImpure) {
mlir::Location loc = getLoc();
fir::FirOpBuilder &builder = getBuilder();
@@ -747,7 +747,7 @@ class CallBuilder {
hlfir::EntityWithAttributes
genIntrinsicRef(const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
const Fortran::evaluate::SpecificIntrinsic &intrinsic) {
mlir::Location loc = getLoc();
if (Fortran::lower::intrinsicRequiresCustomOptionalHandling(
@@ -822,10 +822,9 @@ class CallBuilder {
};
} // namespace
-llvm::Optional<hlfir::EntityWithAttributes> Fortran::lower::convertCallToHLFIR(
+std::optional<hlfir::EntityWithAttributes> Fortran::lower::convertCallToHLFIR(
mlir::Location loc, Fortran::lower::AbstractConverter &converter,
- const evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> resultType, Fortran::lower::SymMap &symMap,
- Fortran::lower::StatementContext &stmtCtx) {
+ const evaluate::ProcedureRef &procRef, std::optional<mlir::Type> resultType,
+ Fortran::lower::SymMap &symMap, Fortran::lower::StatementContext &stmtCtx) {
return CallBuilder(loc, converter, symMap, stmtCtx).gen(procRef, resultType);
}
diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index bbac1d8967e5..74147db962f9 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -1838,8 +1838,8 @@ class ScalarExprLowering {
/// Generate a call to a Fortran intrinsic or intrinsic module procedure.
ExtValue genIntrinsicRef(
const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> resultType,
- llvm::Optional<const Fortran::evaluate::SpecificIntrinsic> intrinsic =
+ std::optional<mlir::Type> resultType,
+ std::optional<const Fortran::evaluate::SpecificIntrinsic> intrinsic =
std::nullopt) {
llvm::SmallVector<ExtValue> operands;
@@ -1849,7 +1849,7 @@ class ScalarExprLowering {
mlir::Location loc = getLoc();
if (intrinsic && Fortran::lower::intrinsicRequiresCustomOptionalHandling(
procRef, *intrinsic, converter)) {
- using ExvAndPresence = std::pair<ExtValue, llvm::Optional<mlir::Value>>;
+ using ExvAndPresence = std::pair<ExtValue, std::optional<mlir::Value>>;
llvm::SmallVector<ExvAndPresence, 4> operands;
auto prepareOptionalArg = [&](const Fortran::lower::SomeExpr &expr) {
ExtValue optionalArg = lowerIntrinsicArgumentAsInquired(expr);
@@ -1870,7 +1870,7 @@ class ScalarExprLowering {
return genLoad(operands[i].first);
return operands[i].first;
};
- auto isPresent = [&](std::size_t i) -> llvm::Optional<mlir::Value> {
+ auto isPresent = [&](std::size_t i) -> std::optional<mlir::Value> {
return operands[i].second;
};
return Fortran::lower::lowerCustomIntrinsic(
@@ -2045,7 +2045,7 @@ class ScalarExprLowering {
/// Lower a non-elemental procedure reference and read allocatable and pointer
/// results into normal values.
ExtValue genProcedureRef(const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> resultType) {
+ std::optional<mlir::Type> resultType) {
ExtValue res = genRawProcedureRef(procRef, resultType);
// In most contexts, pointers and allocatable do not appear as allocatable
// or pointer variable on the caller side (see 8.5.3 note 1 for
@@ -2130,7 +2130,7 @@ class ScalarExprLowering {
bool argMayBeModifiedByCall;
// Optional boolean value that, if present and false, prevents
// the copy-out and temp deallocation.
- llvm::Optional<mlir::Value> restrictCopyAndFreeAtRuntime;
+ std::optional<mlir::Value> restrictCopyAndFreeAtRuntime;
};
using CopyOutPairs = llvm::SmallVector<CopyOutPair, 4>;
@@ -2153,7 +2153,7 @@ class ScalarExprLowering {
ExtValue genCopyIn(const ExtValue &actualArg,
const Fortran::lower::CallerInterface::PassedEntity &arg,
CopyOutPairs ©OutPairs,
- llvm::Optional<mlir::Value> restrictCopyAtRuntime,
+ std::optional<mlir::Value> restrictCopyAtRuntime,
bool byValue) {
const bool doCopyOut = !byValue && arg.mayBeModifiedByCall();
llvm::StringRef tempName = byValue ? ".copy" : ".copyinout";
@@ -2409,7 +2409,7 @@ class ScalarExprLowering {
/// If the actual argument may be dynamically absent, return an additional
/// boolean mlir::Value that if true means that the actual argument is
/// present.
- std::pair<ExtValue, llvm::Optional<mlir::Value>>
+ std::pair<ExtValue, std::optional<mlir::Value>>
prepareActualToBaseAddressLike(
const Fortran::lower::SomeExpr &expr,
const Fortran::lower::CallerInterface::PassedEntity &arg,
@@ -2432,7 +2432,7 @@ class ScalarExprLowering {
expr, converter.getFoldingContext())));
const bool needsCopy = isStaticConstantByValue || variableNeedsCopy;
auto [argAddr, isPresent] =
- [&]() -> std::pair<ExtValue, llvm::Optional<mlir::Value>> {
+ [&]() -> std::pair<ExtValue, std::optional<mlir::Value>> {
if (!actualArgIsVariable && !needsCopy)
// Actual argument is not a variable. Make sure a variable address is
// not passed.
@@ -2502,7 +2502,7 @@ class ScalarExprLowering {
/// Lower a non-elemental procedure reference.
ExtValue genRawProcedureRef(const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> resultType) {
+ std::optional<mlir::Type> resultType) {
mlir::Location loc = getLoc();
if (isElementalProcWithArrayArgs(procRef))
fir::emitFatalError(loc, "trying to lower elemental procedure with array "
@@ -2752,7 +2752,7 @@ class ScalarExprLowering {
}
ExtValue genval(const Fortran::evaluate::ProcedureRef &procRef) {
- llvm::Optional<mlir::Type> resTy;
+ std::optional<mlir::Type> resTy;
if (procRef.hasAlternateReturns())
resTy = builder.getIndexType();
return genProcedureRef(procRef, resTy);
@@ -3158,7 +3158,7 @@ class ArrayExprLowering {
Fortran::lower::ExplicitIterSpace &explicitSpace,
Fortran::lower::ImplicitIterSpace &implicitSpace,
const llvm::SmallVector<mlir::Value> &lbounds,
- llvm::Optional<llvm::SmallVector<mlir::Value>> ubounds) {
+ std::optional<llvm::SmallVector<mlir::Value>> ubounds) {
ArrayExprLowering ael(converter, stmtCtx, symMap,
ConstituentSemantics::CopyInCopyOut, &explicitSpace,
&implicitSpace);
@@ -3177,7 +3177,7 @@ class ArrayExprLowering {
void lowerArrayOfPointerAssignment(
const Fortran::lower::SomeExpr &lhs, const Fortran::lower::SomeExpr &rhs,
const llvm::SmallVector<mlir::Value> &lbounds,
- llvm::Optional<llvm::SmallVector<mlir::Value>> ubounds) {
+ std::optional<llvm::SmallVector<mlir::Value>> ubounds) {
setPointerAssignmentBounds(lbounds, ubounds);
if (rhs.Rank() == 0 ||
(Fortran::evaluate::UnwrapWholeSymbolOrComponentDataRef(rhs) &&
@@ -4418,8 +4418,8 @@ class ArrayExprLowering {
// A reference to a Fortran elemental intrinsic or intrinsic module procedure.
CC genElementalIntrinsicProcRef(
const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> retTy,
- llvm::Optional<const Fortran::evaluate::SpecificIntrinsic> intrinsic =
+ std::optional<mlir::Type> retTy,
+ std::optional<const Fortran::evaluate::SpecificIntrinsic> intrinsic =
std::nullopt) {
llvm::SmallVector<CC> operands;
@@ -4431,7 +4431,7 @@ class ArrayExprLowering {
mlir::Location loc = getLoc();
if (intrinsic && Fortran::lower::intrinsicRequiresCustomOptionalHandling(
procRef, *intrinsic, converter)) {
- using CcPairT = std::pair<CC, llvm::Optional<mlir::Value>>;
+ using CcPairT = std::pair<CC, std::optional<mlir::Value>>;
llvm::SmallVector<CcPairT> operands;
auto prepareOptionalArg = [&](const Fortran::lower::SomeExpr &expr) {
if (expr.Rank() == 0) {
@@ -4461,7 +4461,7 @@ class ArrayExprLowering {
auto getArgument = [&](std::size_t i) -> ExtValue {
return operands[i].first(iters);
};
- auto isPresent = [&](std::size_t i) -> llvm::Optional<mlir::Value> {
+ auto isPresent = [&](std::size_t i) -> std::optional<mlir::Value> {
return operands[i].second;
};
return Fortran::lower::lowerCustomIntrinsic(
@@ -4534,7 +4534,7 @@ class ArrayExprLowering {
/// Lower a procedure reference to a user-defined elemental procedure.
CC genElementalUserDefinedProcRef(
const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> retTy) {
+ std::optional<mlir::Type> retTy) {
using PassBy = Fortran::lower::CallerInterface::PassEntityBy;
// 10.1.4 p5. Impure elemental procedures must be called in element order.
@@ -4752,7 +4752,7 @@ class ArrayExprLowering {
/// Generate a procedure reference. This code is shared for both functions and
/// subroutines, the
diff erence being reflected by `retTy`.
CC genProcRef(const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> retTy) {
+ std::optional<mlir::Type> retTy) {
mlir::Location loc = getLoc();
setLoweredProcRef(&procRef);
@@ -6135,7 +6135,7 @@ class ArrayExprLowering {
// Any temps created in the loop body must be freed inside the loop body.
stmtCtx.pushScope();
- llvm::Optional<mlir::Value> charLen;
+ std::optional<mlir::Value> charLen;
for (const Fortran::evaluate::ArrayConstructorValue<A> &acv : x.values()) {
auto [exv, copyNeeded] = std::visit(
[&](const auto &v) {
@@ -6219,7 +6219,7 @@ class ArrayExprLowering {
mlir::Type eleRefTy = builder.getRefType(eleTy);
// Populate the buffer with the elements, growing as necessary.
- llvm::Optional<mlir::Value> charLen;
+ std::optional<mlir::Value> charLen;
for (const auto &expr : x) {
auto [exv, copyNeeded] = std::visit(
[&](const auto &e) {
@@ -6983,7 +6983,7 @@ class ArrayExprLowering {
void setPointerAssignmentBounds(
const llvm::SmallVector<mlir::Value> &lbs,
- llvm::Optional<llvm::SmallVector<mlir::Value>> ubs) {
+ std::optional<llvm::SmallVector<mlir::Value>> ubs) {
lbounds = lbs;
ubounds = ubs;
}
@@ -6998,9 +6998,9 @@ class ArrayExprLowering {
bool elementCtx = false;
Fortran::lower::SymMap &symMap;
/// The continuation to generate code to update the destination.
- llvm::Optional<CC> ccStoreToDest;
- llvm::Optional<std::function<void(llvm::ArrayRef<mlir::Value>)>> ccPrelude;
- llvm::Optional<std::function<fir::ArrayLoadOp(llvm::ArrayRef<mlir::Value>)>>
+ std::optional<CC> ccStoreToDest;
+ std::optional<std::function<void(llvm::ArrayRef<mlir::Value>)>> ccPrelude;
+ std::optional<std::function<fir::ArrayLoadOp(llvm::ArrayRef<mlir::Value>)>>
ccLoadDest;
/// The destination is the loaded array into which the results will be
/// merged.
@@ -7016,8 +7016,8 @@ class ArrayExprLowering {
ConstituentSemantics semant = ConstituentSemantics::RefTransparent;
/// `lbounds`, `ubounds` are used in POINTER value assignments, which may only
/// occur in an explicit iteration space.
- llvm::Optional<llvm::SmallVector<mlir::Value>> lbounds;
- llvm::Optional<llvm::SmallVector<mlir::Value>> ubounds;
+ std::optional<llvm::SmallVector<mlir::Value>> lbounds;
+ std::optional<llvm::SmallVector<mlir::Value>> ubounds;
// Can the array expression be evaluated in any order?
// Will be set to false if any of the expression parts prevent this.
bool unordered = true;
@@ -7125,7 +7125,7 @@ void Fortran::lower::createArrayOfPointerAssignment(
Fortran::lower::ExplicitIterSpace &explicitSpace,
Fortran::lower::ImplicitIterSpace &implicitSpace,
const llvm::SmallVector<mlir::Value> &lbounds,
- llvm::Optional<llvm::SmallVector<mlir::Value>> ubounds,
+ std::optional<llvm::SmallVector<mlir::Value>> ubounds,
Fortran::lower::SymMap &symMap, Fortran::lower::StatementContext &stmtCtx) {
LLVM_DEBUG(lhs.AsFortran(llvm::dbgs() << "defining pointer: ") << '\n';
rhs.AsFortran(llvm::dbgs() << "assign expression: ")
@@ -7404,7 +7404,7 @@ void Fortran::lower::createArrayMergeStores(
builder.setInsertionPointAfter(esp.getOuterLoop());
// Gen the fir.array_merge_store ops for all LHS arrays.
for (auto i : llvm::enumerate(esp.getOuterLoop().getResults()))
- if (llvm::Optional<fir::ArrayLoadOp> ldOpt = esp.getLhsLoad(i.index())) {
+ if (std::optional<fir::ArrayLoadOp> ldOpt = esp.getLhsLoad(i.index())) {
fir::ArrayLoadOp load = *ldOpt;
builder.create<fir::ArrayMergeStoreOp>(loc, load, i.value(),
load.getMemref(), load.getSlice(),
diff --git a/flang/lib/Lower/ConvertExprToHLFIR.cpp b/flang/lib/Lower/ConvertExprToHLFIR.cpp
index 35d4047722f3..4b1a54268d02 100644
--- a/flang/lib/Lower/ConvertExprToHLFIR.cpp
+++ b/flang/lib/Lower/ConvertExprToHLFIR.cpp
@@ -121,7 +121,7 @@ class HlfirDesignatorBuilder {
fir::FortranVariableOpInterface
gen(const Fortran::evaluate::SymbolRef &symbolRef) {
- if (llvm::Optional<fir::FortranVariableOpInterface> varDef =
+ if (std::optional<fir::FortranVariableOpInterface> varDef =
getSymMap().lookupVariableDefinition(symbolRef))
return *varDef;
TODO(getLoc(), "lowering symbol to HLFIR");
diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp
index b7931ae9c008..ad586cab7c4f 100644
--- a/flang/lib/Lower/ConvertVariable.cpp
+++ b/flang/lib/Lower/ConvertVariable.cpp
@@ -1281,9 +1281,9 @@ lowerExplicitCharLen(Fortran::lower::AbstractConverter &converter,
return mlir::Value{};
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
mlir::Type lenTy = builder.getCharacterLengthType();
- if (llvm::Optional<int64_t> len = box.getCharLenConst())
+ if (std::optional<int64_t> len = box.getCharLenConst())
return builder.createIntegerConstant(loc, lenTy, *len);
- if (llvm::Optional<Fortran::lower::SomeExpr> lenExpr = box.getCharLenExpr())
+ if (std::optional<Fortran::lower::SomeExpr> lenExpr = box.getCharLenExpr())
// If the length expression is negative, the length is zero. See F2018
// 7.4.4.2 point 5.
return fir::factory::genMaxWithZero(
@@ -1703,14 +1703,14 @@ void Fortran::lower::mapSymbolAttributes(
if (arg.getType().isa<fir::BoxCharType>())
std::tie(addr, len) = charHelp.createUnboxChar(arg);
}
- if (llvm::Optional<int64_t> cstLen = ba.getCharLenConst()) {
+ if (std::optional<int64_t> cstLen = ba.getCharLenConst()) {
// Static length
len = builder.createIntegerConstant(loc, idxTy, *cstLen);
} else {
// Dynamic length
if (genUnusedEntryPointBox())
return;
- if (llvm::Optional<Fortran::lower::SomeExpr> charLenExpr =
+ if (std::optional<Fortran::lower::SomeExpr> charLenExpr =
ba.getCharLenExpr()) {
// Explicit length
mlir::Value rawLen = genValue(*charLenExpr);
diff --git a/flang/lib/Lower/CustomIntrinsicCall.cpp b/flang/lib/Lower/CustomIntrinsicCall.cpp
index b4fb1463a01d..9b35625125aa 100644
--- a/flang/lib/Lower/CustomIntrinsicCall.cpp
+++ b/flang/lib/Lower/CustomIntrinsicCall.cpp
@@ -66,7 +66,7 @@ bool Fortran::lower::intrinsicRequiresCustomOptionalHandling(
static void prepareMinOrMaxArguments(
const Fortran::evaluate::ProcedureRef &procRef,
const Fortran::evaluate::SpecificIntrinsic &intrinsic,
- llvm::Optional<mlir::Type> retTy,
+ std::optional<mlir::Type> retTy,
const Fortran::lower::OperandPrepare &prepareOptionalArgument,
const Fortran::lower::OperandPrepare &prepareOtherArgument,
Fortran::lower::AbstractConverter &converter) {
@@ -96,7 +96,7 @@ static void prepareMinOrMaxArguments(
static fir::ExtendedValue
lowerMinOrMax(fir::FirOpBuilder &builder, mlir::Location loc,
- llvm::StringRef name, llvm::Optional<mlir::Type> retTy,
+ llvm::StringRef name, std::optional<mlir::Type> retTy,
const Fortran::lower::OperandPresent &isPresentCheck,
const Fortran::lower::OperandGetter &getOperand,
std::size_t numOperands,
@@ -112,7 +112,7 @@ lowerMinOrMax(fir::FirOpBuilder &builder, mlir::Location loc,
builder, loc, name, resultType, args, stmtCtx));
for (std::size_t opIndex = 2; opIndex < numOperands; ++opIndex) {
- if (llvm::Optional<mlir::Value> isPresentRuntimeCheck =
+ if (std::optional<mlir::Value> isPresentRuntimeCheck =
isPresentCheck(opIndex)) {
// Argument is dynamically optional.
extremum =
@@ -145,7 +145,7 @@ lowerMinOrMax(fir::FirOpBuilder &builder, mlir::Location loc,
static void prepareIshftcArguments(
const Fortran::evaluate::ProcedureRef &procRef,
const Fortran::evaluate::SpecificIntrinsic &intrinsic,
- llvm::Optional<mlir::Type> retTy,
+ std::optional<mlir::Type> retTy,
const Fortran::lower::OperandPrepare &prepareOptionalArgument,
const Fortran::lower::OperandPrepare &prepareOtherArgument,
Fortran::lower::AbstractConverter &converter) {
@@ -167,7 +167,7 @@ static void prepareIshftcArguments(
static fir::ExtendedValue
lowerIshftc(fir::FirOpBuilder &builder, mlir::Location loc,
- llvm::StringRef name, llvm::Optional<mlir::Type> retTy,
+ llvm::StringRef name, std::optional<mlir::Type> retTy,
const Fortran::lower::OperandPresent &isPresentCheck,
const Fortran::lower::OperandGetter &getOperand,
std::size_t numOperands,
@@ -205,7 +205,7 @@ lowerIshftc(fir::FirOpBuilder &builder, mlir::Location loc,
void Fortran::lower::prepareCustomIntrinsicArgument(
const Fortran::evaluate::ProcedureRef &procRef,
const Fortran::evaluate::SpecificIntrinsic &intrinsic,
- llvm::Optional<mlir::Type> retTy,
+ std::optional<mlir::Type> retTy,
const OperandPrepare &prepareOptionalArgument,
const OperandPrepare &prepareOtherArgument, AbstractConverter &converter) {
llvm::StringRef name = intrinsic.name;
@@ -221,7 +221,7 @@ void Fortran::lower::prepareCustomIntrinsicArgument(
fir::ExtendedValue Fortran::lower::lowerCustomIntrinsic(
fir::FirOpBuilder &builder, mlir::Location loc, llvm::StringRef name,
- llvm::Optional<mlir::Type> retTy, const OperandPresent &isPresentCheck,
+ std::optional<mlir::Type> retTy, const OperandPresent &isPresentCheck,
const OperandGetter &getOperand, std::size_t numOperands,
Fortran::lower::StatementContext &stmtCtx) {
if (name == "min" || name == "max")
diff --git a/flang/lib/Lower/HostAssociations.cpp b/flang/lib/Lower/HostAssociations.cpp
index 90a43bca29a8..a4ab3b905f1f 100644
--- a/flang/lib/Lower/HostAssociations.cpp
+++ b/flang/lib/Lower/HostAssociations.cpp
@@ -293,7 +293,7 @@ class CapturedAllocatableAndPointer
llvm::SmallVector<mlir::Value> nonDeferredLenParams;
if (ba.isChar()) {
mlir::IndexType idxTy = builder.getIndexType();
- if (llvm::Optional<int64_t> len = ba.getCharLenConst()) {
+ if (std::optional<int64_t> len = ba.getCharLenConst()) {
nonDeferredLenParams.push_back(
builder.createIntegerConstant(loc, idxTy, *len));
} else if (Fortran::semantics::IsAssumedLengthCharacter(sym) ||
diff --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp
index d1e9af5d0d8d..0b075cd51e0e 100644
--- a/flang/lib/Lower/IO.cpp
+++ b/flang/lib/Lower/IO.cpp
@@ -114,7 +114,7 @@ namespace {
/// and an IOMSG specifier variable may be set to a description of a condition.
struct ConditionSpecInfo {
const Fortran::lower::SomeExpr *ioStatExpr{};
- llvm::Optional<fir::ExtendedValue> ioMsg;
+ std::optional<fir::ExtendedValue> ioMsg;
bool hasErr{};
bool hasEnd{};
bool hasEor{};
@@ -1337,7 +1337,7 @@ constexpr bool isDataTransferInternal<Fortran::parser::PrintStmt>(
/// If the variable `var` is an array or of a KIND other than the default
/// (normally 1), then a descriptor is required by the runtime IO API. This
/// condition holds even in F77 sources.
-static llvm::Optional<fir::ExtendedValue> getVariableBufferRequiredDescriptor(
+static std::optional<fir::ExtendedValue> getVariableBufferRequiredDescriptor(
Fortran::lower::AbstractConverter &converter, mlir::Location loc,
const Fortran::parser::Variable &var,
Fortran::lower::StatementContext &stmtCtx) {
@@ -1354,7 +1354,7 @@ static llvm::Optional<fir::ExtendedValue> getVariableBufferRequiredDescriptor(
}
template <typename A>
-static llvm::Optional<fir::ExtendedValue>
+static std::optional<fir::ExtendedValue>
maybeGetInternalIODescriptor(Fortran::lower::AbstractConverter &converter,
mlir::Location loc, const A &stmt,
Fortran::lower::StatementContext &stmtCtx) {
@@ -1367,7 +1367,7 @@ maybeGetInternalIODescriptor(Fortran::lower::AbstractConverter &converter,
return std::nullopt;
}
template <>
-inline llvm::Optional<fir::ExtendedValue>
+inline std::optional<fir::ExtendedValue>
maybeGetInternalIODescriptor<Fortran::parser::PrintStmt>(
Fortran::lower::AbstractConverter &, mlir::Location loc,
const Fortran::parser::PrintStmt &, Fortran::lower::StatementContext &) {
@@ -1878,7 +1878,7 @@ void genBeginDataTransferCallArgs(
const A &stmt, mlir::FunctionType ioFuncTy, bool isFormatted,
bool isListOrNml, [[maybe_unused]] bool isInternal,
[[maybe_unused]] bool isAsync,
- const llvm::Optional<fir::ExtendedValue> &descRef, ConditionSpecInfo &csi,
+ const std::optional<fir::ExtendedValue> &descRef, ConditionSpecInfo &csi,
Fortran::lower::StatementContext &stmtCtx) {
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
auto maybeGetFormatArgs = [&]() {
@@ -1955,7 +1955,7 @@ genDataTransferStmt(Fortran::lower::AbstractConverter &converter,
const bool isFormatted = isDataTransferFormatted(stmt);
const bool isList = isFormatted ? isDataTransferList(stmt) : false;
const bool isInternal = isDataTransferInternal(stmt);
- llvm::Optional<fir::ExtendedValue> descRef =
+ std::optional<fir::ExtendedValue> descRef =
isInternal ? maybeGetInternalIODescriptor(converter, loc, stmt, stmtCtx)
: std::nullopt;
const bool isInternalWithDesc = descRef.has_value();
diff --git a/flang/lib/Lower/IntrinsicCall.cpp b/flang/lib/Lower/IntrinsicCall.cpp
index f6bc94cec47a..1ee096f197c1 100644
--- a/flang/lib/Lower/IntrinsicCall.cpp
+++ b/flang/lib/Lower/IntrinsicCall.cpp
@@ -422,7 +422,7 @@ struct IntrinsicLibrary {
/// Generate FIR for call to Fortran intrinsic \p name with arguments \p arg
/// and expected result type \p resultType.
fir::ExtendedValue genIntrinsicCall(llvm::StringRef name,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> arg);
/// Search a runtime function that is associated to the generic intrinsic name
@@ -615,7 +615,7 @@ struct IntrinsicLibrary {
template <typename GeneratorType>
fir::ExtendedValue
outlineInExtendedWrapper(GeneratorType, llvm::StringRef name,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args);
template <typename GeneratorType>
@@ -1770,7 +1770,7 @@ static void checkPrecisionLoss(llvm::StringRef name,
}
/// Helpers to get function type from arguments and result type.
-static mlir::FunctionType getFunctionType(llvm::Optional<mlir::Type> resultType,
+static mlir::FunctionType getFunctionType(std::optional<mlir::Type> resultType,
llvm::ArrayRef<mlir::Value> arguments,
fir::FirOpBuilder &builder) {
llvm::SmallVector<mlir::Type> argTypes;
@@ -1921,7 +1921,7 @@ IntrinsicLibrary::genElementalCall<IntrinsicLibrary::SubroutineGenerator>(
static fir::ExtendedValue
invokeHandler(IntrinsicLibrary::ElementalGenerator generator,
const IntrinsicHandler &handler,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args, bool outline,
IntrinsicLibrary &lib) {
assert(resultType && "expect elemental intrinsic to be functions");
@@ -1932,7 +1932,7 @@ invokeHandler(IntrinsicLibrary::ElementalGenerator generator,
static fir::ExtendedValue
invokeHandler(IntrinsicLibrary::ExtendedGenerator generator,
const IntrinsicHandler &handler,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args, bool outline,
IntrinsicLibrary &lib) {
assert(resultType && "expect intrinsic function");
@@ -1948,7 +1948,7 @@ invokeHandler(IntrinsicLibrary::ExtendedGenerator generator,
static fir::ExtendedValue
invokeHandler(IntrinsicLibrary::SubroutineGenerator generator,
const IntrinsicHandler &handler,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args, bool outline,
IntrinsicLibrary &lib) {
if (handler.isElemental)
@@ -1963,7 +1963,7 @@ invokeHandler(IntrinsicLibrary::SubroutineGenerator generator,
fir::ExtendedValue
IntrinsicLibrary::genIntrinsicCall(llvm::StringRef specificName,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args) {
llvm::StringRef name = genericName(specificName);
if (const IntrinsicHandler *handler = findIntrinsicHandler(name)) {
@@ -2133,7 +2133,7 @@ IntrinsicLibrary::outlineInWrapper(GeneratorType generator,
template <typename GeneratorType>
fir::ExtendedValue IntrinsicLibrary::outlineInExtendedWrapper(
GeneratorType generator, llvm::StringRef name,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args) {
if (hasAbsentOptional(args))
TODO(loc, "cannot outline call to intrinsic " + llvm::Twine(name) +
@@ -3108,7 +3108,7 @@ IntrinsicLibrary::genCshift(mlir::Type resultType,
// DATE_AND_TIME
void IntrinsicLibrary::genDateAndTime(llvm::ArrayRef<fir::ExtendedValue> args) {
assert(args.size() == 4 && "date_and_time has 4 args");
- llvm::SmallVector<llvm::Optional<fir::CharBoxValue>> charArgs(3);
+ llvm::SmallVector<std::optional<fir::CharBoxValue>> charArgs(3);
for (unsigned i = 0; i < 3; ++i)
if (const fir::CharBoxValue *charBox = args[i].getCharBox())
charArgs[i] = *charBox;
@@ -5323,7 +5323,7 @@ Fortran::lower::ArgLoweringRule Fortran::lower::lowerIntrinsicArgumentAs(
fir::ExtendedValue
Fortran::lower::genIntrinsicCall(fir::FirOpBuilder &builder, mlir::Location loc,
llvm::StringRef name,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args,
Fortran::lower::StatementContext &stmtCtx) {
return IntrinsicLibrary{builder, loc, &stmtCtx}.genIntrinsicCall(
diff --git a/flang/lib/Lower/IterationSpace.cpp b/flang/lib/Lower/IterationSpace.cpp
index c41aa0ef0eec..dab15f301081 100644
--- a/flang/lib/Lower/IterationSpace.cpp
+++ b/flang/lib/Lower/IterationSpace.cpp
@@ -861,11 +861,11 @@ void Fortran::lower::ExplicitIterSpace::conditionalCleanup() {
}
}
-llvm::Optional<size_t>
+std::optional<size_t>
Fortran::lower::ExplicitIterSpace::findArgPosition(fir::ArrayLoadOp load) {
if (lhsBases[counter]) {
auto ld = loadBindings.find(*lhsBases[counter]);
- llvm::Optional<size_t> optPos;
+ std::optional<size_t> optPos;
if (ld != loadBindings.end() && ld->second == load)
optPos = static_cast<size_t>(0u);
assert(optPos.has_value() && "load does not correspond to lhs");
@@ -918,7 +918,7 @@ Fortran::lower::operator<<(llvm::raw_ostream &s,
u);
};
s << "LHS bases:\n";
- for (const llvm::Optional<Fortran::lower::ExplicitIterSpace::ArrayBases> &u :
+ for (const std::optional<Fortran::lower::ExplicitIterSpace::ArrayBases> &u :
e.lhsBases)
if (u)
dump(*u);
diff --git a/flang/lib/Lower/Mangler.cpp b/flang/lib/Lower/Mangler.cpp
index 0aec67441155..b4030a05e769 100644
--- a/flang/lib/Lower/Mangler.cpp
+++ b/flang/lib/Lower/Mangler.cpp
@@ -40,7 +40,7 @@ moduleNames(const Fortran::semantics::Symbol &symbol) {
return result;
}
-static llvm::Optional<llvm::StringRef>
+static std::optional<llvm::StringRef>
hostName(const Fortran::semantics::Symbol &symbol) {
const Fortran::semantics::Scope &scope = symbol.owner();
if (scope.kind() == Fortran::semantics::Scope::Kind::Subprogram) {
@@ -120,7 +120,7 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
[&](const Fortran::semantics::ObjectEntityDetails &) {
llvm::SmallVector<llvm::StringRef> modNames =
moduleNames(ultimateSymbol);
- llvm::Optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
+ std::optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
if (Fortran::semantics::IsNamedConstant(ultimateSymbol))
return fir::NameUniquer::doConstant(modNames, optHost,
symbolName);
@@ -129,7 +129,7 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
[&](const Fortran::semantics::NamelistDetails &) {
llvm::SmallVector<llvm::StringRef> modNames =
moduleNames(ultimateSymbol);
- llvm::Optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
+ std::optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
return fir::NameUniquer::doNamelistGroup(modNames, optHost,
symbolName);
},
@@ -158,7 +158,7 @@ std::string Fortran::lower::mangle::mangleName(
derivedType.typeSymbol().GetUltimate();
llvm::StringRef symbolName = toStringRef(ultimateSymbol.name());
llvm::SmallVector<llvm::StringRef> modNames = moduleNames(ultimateSymbol);
- llvm::Optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
+ std::optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
llvm::SmallVector<std::int64_t> kinds;
for (const auto ¶m :
Fortran::semantics::OrderParameterDeclarations(ultimateSymbol)) {
diff --git a/flang/lib/Lower/Runtime.cpp b/flang/lib/Lower/Runtime.cpp
index e0dfdf5696a8..e68b1318b15c 100644
--- a/flang/lib/Lower/Runtime.cpp
+++ b/flang/lib/Lower/Runtime.cpp
@@ -227,17 +227,17 @@ mlir::Value Fortran::lower::genCpuTime(fir::FirOpBuilder &builder,
void Fortran::lower::genDateAndTime(fir::FirOpBuilder &builder,
mlir::Location loc,
- llvm::Optional<fir::CharBoxValue> date,
- llvm::Optional<fir::CharBoxValue> time,
- llvm::Optional<fir::CharBoxValue> zone,
+ std::optional<fir::CharBoxValue> date,
+ std::optional<fir::CharBoxValue> time,
+ std::optional<fir::CharBoxValue> zone,
mlir::Value values) {
mlir::func::FuncOp callee =
fir::runtime::getRuntimeFunc<mkRTKey(DateAndTime)>(loc, builder);
mlir::FunctionType funcTy = callee.getFunctionType();
mlir::Type idxTy = builder.getIndexType();
mlir::Value zero;
- auto splitArg = [&](llvm::Optional<fir::CharBoxValue> arg,
- mlir::Value &buffer, mlir::Value &len) {
+ auto splitArg = [&](std::optional<fir::CharBoxValue> arg, mlir::Value &buffer,
+ mlir::Value &len) {
if (arg) {
buffer = arg->getBuffer();
len = arg->getLen();
diff --git a/flang/lib/Lower/SymbolMap.cpp b/flang/lib/Lower/SymbolMap.cpp
index ff0c75f12db2..f61071150df8 100644
--- a/flang/lib/Lower/SymbolMap.cpp
+++ b/flang/lib/Lower/SymbolMap.cpp
@@ -92,7 +92,7 @@ Fortran::lower::SymMap::lookupImpliedDo(Fortran::lower::SymMap::AcDoVar var) {
return {};
}
-llvm::Optional<fir::FortranVariableOpInterface>
+std::optional<fir::FortranVariableOpInterface>
Fortran::lower::SymMap::lookupVariableDefinition(semantics::SymbolRef symRef) {
Fortran::semantics::SymbolRef sym = symRef.get().GetUltimate();
for (auto jmap = symbolMapStack.rbegin(), jend = symbolMapStack.rend();
diff --git a/flang/lib/Optimizer/Builder/FIRBuilder.cpp b/flang/lib/Optimizer/Builder/FIRBuilder.cpp
index a82c218f4964..0c5bf47e2978 100644
--- a/flang/lib/Optimizer/Builder/FIRBuilder.cpp
+++ b/flang/lib/Optimizer/Builder/FIRBuilder.cpp
@@ -1139,7 +1139,7 @@ static void genComponentByComponentAssignment(fir::FirOpBuilder &builder,
auto fieldRefType = builder.getRefType(lFieldTy);
mlir::Value toCoor = builder.create<fir::CoordinateOp>(
loc, fieldRefType, fir::getBase(lhs), field);
- llvm::Optional<fir::DoLoopOp> outerLoop;
+ std::optional<fir::DoLoopOp> outerLoop;
if (auto sequenceType = lFieldTy.dyn_cast<fir::SequenceType>()) {
// Create loops to assign array components elements by elements.
// Note that, since these are components, they either do not overlap,
@@ -1331,11 +1331,11 @@ mlir::Value fir::factory::createZeroValue(fir::FirOpBuilder &builder,
"numeric or logical type");
}
-llvm::Optional<std::int64_t>
+std::optional<std::int64_t>
fir::factory::getExtentFromTriplet(mlir::Value lb, mlir::Value ub,
mlir::Value stride) {
- std::function<llvm::Optional<std::int64_t>(mlir::Value)> getConstantValue =
- [&](mlir::Value value) -> llvm::Optional<std::int64_t> {
+ std::function<std::optional<std::int64_t>(mlir::Value)> getConstantValue =
+ [&](mlir::Value value) -> std::optional<std::int64_t> {
if (auto valInt = fir::getIntIfConstant(value))
return *valInt;
auto *definingOp = value.getDefiningOp();
diff --git a/flang/lib/Optimizer/Builder/HLFIRTools.cpp b/flang/lib/Optimizer/Builder/HLFIRTools.cpp
index 818347e375eb..fb018c740590 100644
--- a/flang/lib/Optimizer/Builder/HLFIRTools.cpp
+++ b/flang/lib/Optimizer/Builder/HLFIRTools.cpp
@@ -70,7 +70,7 @@ getExplicitTypeParams(fir::FortranVariableOpInterface var) {
return res;
}
-std::pair<fir::ExtendedValue, llvm::Optional<hlfir::CleanupFunction>>
+std::pair<fir::ExtendedValue, std::optional<hlfir::CleanupFunction>>
hlfir::translateToExtendedValue(mlir::Location loc, fir::FirOpBuilder &builder,
hlfir::Entity entity) {
if (auto variable = entity.getIfVariableInterface())
diff --git a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
index b19bb5efb085..223a8bc11aa9 100644
--- a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
+++ b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
@@ -65,7 +65,7 @@ struct FixupTy {
Codes code;
std::size_t index;
std::size_t second{};
- llvm::Optional<std::function<void(mlir::func::FuncOp)>> finalizer{};
+ std::optional<std::function<void(mlir::func::FuncOp)>> finalizer{};
}; // namespace
/// Target-specific rewriting of the FIR. This is a prerequisite pass to code
@@ -215,7 +215,7 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
}
// Determine the rewrite function, `wrap`, for the result value.
- llvm::Optional<std::function<mlir::Value(mlir::Operation *)>> wrap;
+ std::optional<std::function<mlir::Value(mlir::Operation *)>> wrap;
if (fnTy.getResults().size() == 1) {
mlir::Type ty = fnTy.getResult(0);
llvm::TypeSwitch<mlir::Type>(ty)
diff --git a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
index 2111f502aa3d..6c0077713861 100644
--- a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
+++ b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
@@ -363,7 +363,7 @@ static unsigned getCharacterKind(mlir::Type t) {
return hlfir::getFortranElementType(t).cast<fir::CharacterType>().getFKind();
}
-static llvm::Optional<fir::CharacterType::LenType>
+static std::optional<fir::CharacterType::LenType>
getCharacterLengthIfStatic(mlir::Type t) {
if (auto charType =
hlfir::getFortranElementType(t).dyn_cast<fir::CharacterType>())
diff --git a/flang/lib/Optimizer/Support/InternalNames.cpp b/flang/lib/Optimizer/Support/InternalNames.cpp
index 3c455e1bc57e..29596998bc0c 100644
--- a/flang/lib/Optimizer/Support/InternalNames.cpp
+++ b/flang/lib/Optimizer/Support/InternalNames.cpp
@@ -37,7 +37,7 @@ static std::string doModules(llvm::ArrayRef<llvm::StringRef> mods) {
}
static std::string doModulesHost(llvm::ArrayRef<llvm::StringRef> mods,
- llvm::Optional<llvm::StringRef> host) {
+ std::optional<llvm::StringRef> host) {
std::string result = doModules(mods);
if (host)
result.append("F").append(host->lower());
@@ -49,9 +49,9 @@ convertToStringRef(llvm::ArrayRef<std::string> from) {
return {from.begin(), from.end()};
}
-inline llvm::Optional<llvm::StringRef>
-convertToStringRef(const llvm::Optional<std::string> &from) {
- llvm::Optional<llvm::StringRef> to;
+inline std::optional<llvm::StringRef>
+convertToStringRef(const std::optional<std::string> &from) {
+ std::optional<llvm::StringRef> to;
if (from)
to = *from;
return to;
@@ -111,7 +111,7 @@ std::string fir::NameUniquer::doBlockData(llvm::StringRef name) {
std::string
fir::NameUniquer::doConstant(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name) {
std::string result = prefix();
result.append(doModulesHost(modules, host)).append("EC");
@@ -120,7 +120,7 @@ fir::NameUniquer::doConstant(llvm::ArrayRef<llvm::StringRef> modules,
std::string
fir::NameUniquer::doDispatchTable(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name,
llvm::ArrayRef<std::int64_t> kinds) {
std::string result = prefix();
@@ -135,7 +135,7 @@ std::string fir::NameUniquer::doGenerated(llvm::StringRef name) {
std::string fir::NameUniquer::doIntrinsicTypeDescriptor(
llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host, IntrinsicType type,
+ std::optional<llvm::StringRef> host, IntrinsicType type,
std::int64_t kind) {
const char *name = nullptr;
switch (type) {
@@ -163,7 +163,7 @@ std::string fir::NameUniquer::doIntrinsicTypeDescriptor(
std::string
fir::NameUniquer::doProcedure(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name) {
std::string result = prefix();
result.append(doModulesHost(modules, host)).append("P");
@@ -171,7 +171,7 @@ fir::NameUniquer::doProcedure(llvm::ArrayRef<llvm::StringRef> modules,
}
std::string fir::NameUniquer::doType(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name,
llvm::ArrayRef<std::int64_t> kinds) {
std::string result = prefix();
@@ -181,7 +181,7 @@ std::string fir::NameUniquer::doType(llvm::ArrayRef<llvm::StringRef> modules,
std::string
fir::NameUniquer::doTypeDescriptor(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name,
llvm::ArrayRef<std::int64_t> kinds) {
std::string result = prefix();
@@ -190,7 +190,7 @@ fir::NameUniquer::doTypeDescriptor(llvm::ArrayRef<llvm::StringRef> modules,
}
std::string fir::NameUniquer::doTypeDescriptor(
- llvm::ArrayRef<std::string> modules, llvm::Optional<std::string> host,
+ llvm::ArrayRef<std::string> modules, std::optional<std::string> host,
llvm::StringRef name, llvm::ArrayRef<std::int64_t> kinds) {
auto rmodules = convertToStringRef(modules);
auto rhost = convertToStringRef(host);
@@ -199,7 +199,7 @@ std::string fir::NameUniquer::doTypeDescriptor(
std::string
fir::NameUniquer::doVariable(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name) {
std::string result = prefix();
result.append(doModulesHost(modules, host)).append("E");
@@ -208,7 +208,7 @@ fir::NameUniquer::doVariable(llvm::ArrayRef<llvm::StringRef> modules,
std::string
fir::NameUniquer::doNamelistGroup(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name) {
std::string result = prefix();
result.append(doModulesHost(modules, host)).append("G");
@@ -225,7 +225,7 @@ std::pair<fir::NameUniquer::NameKind, fir::NameUniquer::DeconstructedName>
fir::NameUniquer::deconstruct(llvm::StringRef uniq) {
if (uniq.startswith("_Q")) {
llvm::SmallVector<std::string> modules;
- llvm::Optional<std::string> host;
+ std::optional<std::string> host;
std::string name;
llvm::SmallVector<std::int64_t> kinds;
NameKind nk = NameKind::NOT_UNIQUED;
@@ -348,7 +348,7 @@ static std::string getDerivedTypeObjectName(llvm::StringRef mangledTypeName,
llvm::SmallVector<llvm::StringRef> modules;
for (const std::string &mod : result.second.modules)
modules.push_back(mod);
- llvm::Optional<llvm::StringRef> host;
+ std::optional<llvm::StringRef> host;
if (result.second.host)
host = *result.second.host;
return fir::NameUniquer::doVariable(modules, host, varName);
diff --git a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
index 998b063f7d1a..9fde5652c828 100644
--- a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
+++ b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
@@ -169,7 +169,7 @@ namespace {
/// final number of symbols and dimensions of the affine map. Integer set if
/// possible is in Optional IntegerSet.
struct AffineIfCondition {
- using MaybeAffineExpr = llvm::Optional<mlir::AffineExpr>;
+ using MaybeAffineExpr = std::optional<mlir::AffineExpr>;
explicit AffineIfCondition(mlir::Value fc) : firCondition(fc) {
if (auto condDef = firCondition.getDefiningOp<mlir::arith::CmpIOp>())
@@ -248,7 +248,7 @@ struct AffineIfCondition {
dimCount, symCount, {constraintPair->first}, {constraintPair->second});
}
- llvm::Optional<std::pair<AffineExpr, bool>>
+ std::optional<std::pair<AffineExpr, bool>>
constraint(mlir::arith::CmpIPredicate predicate, mlir::AffineExpr basic) {
switch (predicate) {
case mlir::arith::CmpIPredicate::slt:
@@ -267,7 +267,7 @@ struct AffineIfCondition {
}
llvm::SmallVector<mlir::Value> affineArgs;
- llvm::Optional<mlir::IntegerSet> integerSet;
+ std::optional<mlir::IntegerSet> integerSet;
mlir::Value firCondition;
unsigned symCount{0u};
unsigned dimCount{0u};
@@ -330,7 +330,7 @@ static mlir::AffineMap createArrayIndexAffineMap(unsigned dimensions,
return mlir::AffineMap::get(dimensions, dimensions * 3, index);
}
-static Optional<int64_t> constantIntegerLike(const mlir::Value value) {
+static std::optional<int64_t> constantIntegerLike(const mlir::Value value) {
if (auto definition = value.getDefiningOp<mlir::arith::ConstantOp>())
if (auto stepAttr = definition.getValue().dyn_cast<IntegerAttr>())
return stepAttr.getInt();
diff --git a/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp b/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp
index 51e8561dee38..9aad37062ad0 100644
--- a/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp
+++ b/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp
@@ -48,8 +48,8 @@ class LoadStoreForwarding {
// FIXME: This algorithm has a bug. It ignores escaping references between a
// store and a load.
- llvm::Optional<WriteOp> findStoreToForward(ReadOp loadOp,
- std::vector<WriteOp> &&storeOps) {
+ std::optional<WriteOp> findStoreToForward(ReadOp loadOp,
+ std::vector<WriteOp> &&storeOps) {
llvm::SmallVector<WriteOp> candidateSet;
for (auto storeOp : storeOps)
@@ -59,7 +59,7 @@ class LoadStoreForwarding {
if (candidateSet.empty())
return {};
- llvm::Optional<WriteOp> nearestStore;
+ std::optional<WriteOp> nearestStore;
for (auto candidate : candidateSet) {
auto nearerThan = [&](WriteOp otherStore) {
if (candidate == otherStore)
@@ -86,8 +86,8 @@ class LoadStoreForwarding {
return nearestStore;
}
- llvm::Optional<ReadOp> findReadForWrite(WriteOp storeOp,
- std::vector<ReadOp> &&loadOps) {
+ std::optional<ReadOp> findReadForWrite(WriteOp storeOp,
+ std::vector<ReadOp> &&loadOps) {
for (auto &loadOp : loadOps) {
if (domInfo->dominates(storeOp, loadOp))
return loadOp;
diff --git a/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp b/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
index 5628f0c7999d..05ddcfe1abc9 100644
--- a/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
+++ b/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
@@ -510,7 +510,7 @@ static unsigned getDimCount(mlir::Value val) {
/// be reliably found.
/// We expect that the argument is a result of fir.convert
/// with the destination type of !fir.box<none>.
-static llvm::Optional<mlir::Type> getArgElementType(mlir::Value val) {
+static std::optional<mlir::Type> getArgElementType(mlir::Value val) {
mlir::Operation *defOp;
do {
defOp = val.getDefiningOp();
More information about the flang-commits
mailing list