[flang-commits] [flang] 9a41739 - [flang] Use std::nullopt instead of None (NFC)
Kazu Hirata via flang-commits
flang-commits at lists.llvm.org
Sat Dec 3 12:14:31 PST 2022
Author: Kazu Hirata
Date: 2022-12-03T12:14:21-08:00
New Revision: 9a41739565d9f7ce94da5e7d83947ead73d9bd54
URL: https://github.com/llvm/llvm-project/commit/9a41739565d9f7ce94da5e7d83947ead73d9bd54
DIFF: https://github.com/llvm/llvm-project/commit/9a41739565d9f7ce94da5e7d83947ead73d9bd54.diff
LOG: [flang] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated. The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.
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/AbstractConverter.h
flang/include/flang/Lower/BoxAnalyzer.h
flang/include/flang/Lower/ComponentPath.h
flang/include/flang/Lower/IterationSpace.h
flang/include/flang/Optimizer/Builder/FIRBuilder.h
flang/include/flang/Optimizer/Support/KindMapping.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/lib/Lower/Allocatable.cpp
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/CallInterface.cpp
flang/lib/Lower/ConvertCall.cpp
flang/lib/Lower/ConvertConstant.cpp
flang/lib/Lower/ConvertExpr.cpp
flang/lib/Lower/ConvertExprToHLFIR.cpp
flang/lib/Lower/ConvertVariable.cpp
flang/lib/Lower/HostAssociations.cpp
flang/lib/Lower/IO.cpp
flang/lib/Lower/IterationSpace.cpp
flang/lib/Lower/Mangler.cpp
flang/lib/Lower/Runtime.cpp
flang/lib/Lower/SymbolMap.cpp
flang/lib/Lower/VectorSubscripts.cpp
flang/lib/Optimizer/Builder/Character.cpp
flang/lib/Optimizer/Builder/FIRBuilder.cpp
flang/lib/Optimizer/Builder/LowLevelIntrinsics.cpp
flang/lib/Optimizer/Builder/MutableBox.cpp
flang/lib/Optimizer/Builder/Runtime/Stop.cpp
flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
flang/lib/Optimizer/CodeGen/TypeConverter.h
flang/lib/Optimizer/Dialect/FIROps.cpp
flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp
flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
flang/tools/f18-parse-demo/f18-parse-demo.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Lower/AbstractConverter.h b/flang/include/flang/Lower/AbstractConverter.h
index 358a6193438bc..f7529499432f9 100644
--- a/flang/include/flang/Lower/AbstractConverter.h
+++ b/flang/include/flang/Lower/AbstractConverter.h
@@ -193,7 +193,7 @@ class AbstractConverter {
/// Generate the type from a category and kind and length parameters.
virtual mlir::Type
genType(Fortran::common::TypeCategory tc, int kind,
- llvm::ArrayRef<std::int64_t> lenParameters = llvm::None) = 0;
+ llvm::ArrayRef<std::int64_t> lenParameters = std::nullopt) = 0;
/// Generate the type from a DerivedTypeSpec.
virtual mlir::Type genType(const Fortran::semantics::DerivedTypeSpec &) = 0;
/// Generate the type from a Variable
diff --git a/flang/include/flang/Lower/BoxAnalyzer.h b/flang/include/flang/Lower/BoxAnalyzer.h
index 28ad0d5433b19..2543c443acc96 100644
--- a/flang/include/flang/Lower/BoxAnalyzer.h
+++ b/flang/include/flang/Lower/BoxAnalyzer.h
@@ -79,7 +79,7 @@ struct ScalarDynamicChar : ScalarSym {
llvm::Optional<Fortran::lower::SomeExpr> charLen() const {
if (auto *l = std::get_if<Fortran::lower::SomeExpr>(&len))
return {*l};
- return llvm::None;
+ return std::nullopt;
}
static constexpr bool staticSize() { return false; }
@@ -323,7 +323,7 @@ class BoxAnalyzer : public fir::details::matcher<BoxAnalyzer> {
[](const ScalarStaticChar &x) -> A { return {x.charLen()}; },
[](const StaticArrayStaticChar &x) -> A { return {x.charLen()}; },
[](const DynamicArrayStaticChar &x) -> A { return {x.charLen()}; },
- [](const auto &) -> A { return llvm::None; });
+ [](const auto &) -> A { return std::nullopt; });
}
llvm::Optional<Fortran::lower::SomeExpr> getCharLenExpr() const {
@@ -331,7 +331,7 @@ class BoxAnalyzer : public fir::details::matcher<BoxAnalyzer> {
return match([](const ScalarDynamicChar &x) { return x.charLen(); },
[](const StaticArrayDynamicChar &x) { return x.charLen(); },
[](const DynamicArrayDynamicChar &x) { return x.charLen(); },
- [](const auto &) -> A { return llvm::None; });
+ [](const auto &) -> A { return std::nullopt; });
}
/// Is the origin of this array the default of vector of `1`?
@@ -480,7 +480,7 @@ class BoxAnalyzer : public fir::details::matcher<BoxAnalyzer> {
return 0;
return *asInt;
}
- return llvm::None;
+ return std::nullopt;
}
// Get the `SomeExpr` that describes the CHARACTER's LEN.
@@ -503,7 +503,7 @@ class BoxAnalyzer : public fir::details::matcher<BoxAnalyzer> {
if (Fortran::semantics::MaybeSubscriptIntExpr expr =
charExpr->LEN())
return {Fortran::evaluate::AsGenericExpr(std::move(*expr))};
- return llvm::None;
+ return std::nullopt;
}
VT box;
diff --git a/flang/include/flang/Lower/ComponentPath.h b/flang/include/flang/Lower/ComponentPath.h
index 3b5c3d3c21b09..b95f4a38dba2b 100644
--- a/flang/include/flang/Lower/ComponentPath.h
+++ b/flang/include/flang/Lower/ComponentPath.h
@@ -51,7 +51,7 @@ class ComponentPath {
bool hasExtendCoorRef() const { return extendCoorRef.has_value(); }
ExtendRefFunc getExtendCoorRef() const;
- void resetExtendCoorRef() { extendCoorRef = llvm::None; }
+ void resetExtendCoorRef() { extendCoorRef = std::nullopt; }
void resetPC();
llvm::SmallVector<PathComponent> reversePath;
@@ -68,7 +68,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 = llvm::None;
+ llvm::Optional<ExtendRefFunc> extendCoorRef = std::nullopt;
private:
void setPC(bool isImplicit);
diff --git a/flang/include/flang/Lower/IterationSpace.h b/flang/include/flang/Lower/IterationSpace.h
index 82b77aac8296e..1bd83097ab204 100644
--- a/flang/include/flang/Lower/IterationSpace.h
+++ b/flang/include/flang/Lower/IterationSpace.h
@@ -469,7 +469,7 @@ class ExplicitIterSpace {
assert(i < lhsBases.size());
if (lhsBases[counter])
return findBinding(*lhsBases[counter]);
- return llvm::None;
+ return std::nullopt;
}
/// Return the outermost loop in this FORALL nest.
diff --git a/flang/include/flang/Optimizer/Builder/FIRBuilder.h b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
index 560b991ab53e6..148f21880e295 100644
--- a/flang/include/flang/Optimizer/Builder/FIRBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
@@ -385,14 +385,14 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
/// Create an IfOp with no "else" region, and no result values.
/// Usage: genIfThen(loc, cdt).genThen(lambda).end();
IfBuilder genIfThen(mlir::Location loc, mlir::Value cdt) {
- auto op = create<fir::IfOp>(loc, llvm::None, cdt, false);
+ auto op = create<fir::IfOp>(loc, std::nullopt, cdt, false);
return IfBuilder(op, *this);
}
/// Create an IfOp with an "else" region, and no result values.
/// Usage: genIfThenElse(loc, cdt).genThen(lambda).genElse(lambda).end();
IfBuilder genIfThenElse(mlir::Location loc, mlir::Value cdt) {
- auto op = create<fir::IfOp>(loc, llvm::None, cdt, true);
+ auto op = create<fir::IfOp>(loc, std::nullopt, cdt, true);
return IfBuilder(op, *this);
}
diff --git a/flang/include/flang/Optimizer/Support/KindMapping.h b/flang/include/flang/Optimizer/Support/KindMapping.h
index cdde38599782a..138123b7b48ba 100644
--- a/flang/include/flang/Optimizer/Support/KindMapping.h
+++ b/flang/include/flang/Optimizer/Support/KindMapping.h
@@ -66,7 +66,7 @@ class KindMapping {
/// of 6 KindTy must be passed. The kinds must be the given in the following
/// order: CHARACTER, COMPLEX, DOUBLE PRECISION, INTEGER, LOGICAL, and REAL.
explicit KindMapping(mlir::MLIRContext *context, llvm::StringRef map,
- llvm::ArrayRef<KindTy> defs = llvm::None);
+ llvm::ArrayRef<KindTy> defs = std::nullopt);
explicit KindMapping(mlir::MLIRContext *context, llvm::StringRef map,
llvm::StringRef defs)
: KindMapping{context, map, toDefaultKinds(defs)} {}
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index e24d816383808..e5fa38efae170 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -139,7 +139,7 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
.Case("ropi", llvm::Reloc::ROPI)
.Case("rwpi", llvm::Reloc::RWPI)
.Case("ropi-rwpi", llvm::Reloc::ROPI_RWPI)
- .Default(llvm::None);
+ .Default(std::nullopt);
if (RM.has_value())
opts.setRelocationModel(*RM);
else
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 82d472dd8fd2f..a422b054137a8 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -609,7 +609,7 @@ void CodeGenAction::setUpTargetMachine() {
theTriple, /*CPU=*/targetOpts.cpu,
/*Features=*/featuresStr, llvm::TargetOptions(),
/*Reloc::Model=*/CGOpts.getRelocationModel(),
- /*CodeModel::Model=*/llvm::None, OptLevel));
+ /*CodeModel::Model=*/std::nullopt, OptLevel));
assert(tm && "Failed to create TargetMachine");
}
diff --git a/flang/lib/Lower/Allocatable.cpp b/flang/lib/Lower/Allocatable.cpp
index 65f7e9c75b53b..e58a3c2c6be3f 100644
--- a/flang/lib/Lower/Allocatable.cpp
+++ b/flang/lib/Lower/Allocatable.cpp
@@ -692,19 +692,19 @@ createMutableProperties(Fortran::lower::AbstractConverter &converter,
baseAddrTy = boxType.getEleTy();
// Allocate and set a variable to hold the address.
// It will be set to null in setUnallocatedStatus.
- mutableProperties.addr =
- builder.allocateLocal(loc, baseAddrTy, name + ".addr", "",
- /*shape=*/llvm::None, /*typeparams=*/llvm::None);
+ mutableProperties.addr = builder.allocateLocal(
+ loc, baseAddrTy, name + ".addr", "",
+ /*shape=*/std::nullopt, /*typeparams=*/std::nullopt);
// Allocate variables to hold lower bounds and extents.
int rank = sym.Rank();
mlir::Type idxTy = builder.getIndexType();
for (decltype(rank) i = 0; i < rank; ++i) {
- mlir::Value lboundVar =
- builder.allocateLocal(loc, idxTy, name + ".lb" + std::to_string(i), "",
- /*shape=*/llvm::None, /*typeparams=*/llvm::None);
- mlir::Value extentVar =
- builder.allocateLocal(loc, idxTy, name + ".ext" + std::to_string(i), "",
- /*shape=*/llvm::None, /*typeparams=*/llvm::None);
+ mlir::Value lboundVar = builder.allocateLocal(
+ loc, idxTy, name + ".lb" + std::to_string(i), "",
+ /*shape=*/std::nullopt, /*typeparams=*/std::nullopt);
+ mlir::Value extentVar = builder.allocateLocal(
+ loc, idxTy, name + ".ext" + std::to_string(i), "",
+ /*shape=*/std::nullopt, /*typeparams=*/std::nullopt);
mutableProperties.lbounds.emplace_back(lboundVar);
mutableProperties.extents.emplace_back(extentVar);
}
@@ -721,8 +721,8 @@ createMutableProperties(Fortran::lower::AbstractConverter &converter,
if (fir::isa_char(eleTy) && nonDeferredParams.empty()) {
mlir::Value lenVar =
builder.allocateLocal(loc, builder.getCharacterLengthType(),
- name + ".len", "", /*shape=*/llvm::None,
- /*typeparams=*/llvm::None);
+ name + ".len", "", /*shape=*/std::nullopt,
+ /*typeparams=*/std::nullopt);
mutableProperties.deferredParams.emplace_back(lenVar);
}
return mutableProperties;
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 9020dd99b252e..9dcff61c94f24 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -603,7 +603,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
mlir::Type genType(Fortran::common::TypeCategory tc) override final {
return Fortran::lower::getFIRType(
&getMLIRContext(), tc, bridge.getDefaultKinds().GetDefaultKind(tc),
- llvm::None);
+ std::nullopt);
}
bool createHostAssociateVarClone(
@@ -960,8 +960,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
assert(falseTarget && "missing conditional branch false block");
mlir::Location loc = toLocation();
mlir::Value bcc = builder->createConvert(loc, builder->getI1Type(), cond);
- builder->create<mlir::cf::CondBranchOp>(loc, bcc, trueTarget, llvm::None,
- falseTarget, llvm::None);
+ builder->create<mlir::cf::CondBranchOp>(loc, bcc, trueTarget, std::nullopt,
+ falseTarget, std::nullopt);
}
void genFIRConditionalBranch(mlir::Value cond,
Fortran::lower::pft::Evaluation *trueTarget,
@@ -1101,7 +1101,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 = llvm::None;
+ llvm::Optional<mlir::Type> resultType = std::nullopt;
if (stmt.typedCall->hasAlternateReturns())
resultType = builder->getIndexType();
auto hlfirRes = Fortran::lower::convertCallToHLFIR(
@@ -2509,8 +2509,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 = llvm::None,
- llvm::Optional<llvm::SmallVector<mlir::Value>> ubounds = llvm::None) {
+ llvm::Optional<llvm::SmallVector<mlir::Value>> lbounds = std::nullopt,
+ llvm::Optional<llvm::SmallVector<mlir::Value>> ubounds = std::nullopt) {
Fortran::lower::StatementContext &stmtCtx =
explicitIterationSpace()
@@ -2675,7 +2675,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
"LEN parameters");
lhsRealloc = fir::factory::genReallocIfNeeded(
*builder, loc, *lhsMutableBox,
- /*shape=*/llvm::None, lengthParams);
+ /*shape=*/std::nullopt, lengthParams);
return lhsRealloc->newValue;
}
return genExprAddr(assign.lhs, stmtCtx);
@@ -2716,7 +2716,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
if (lhsIsWholeAllocatable)
fir::factory::finalizeRealloc(
*builder, loc, lhsMutableBox.value(),
- /*lbounds=*/llvm::None, /*takeLboundsIfRealloc=*/false,
+ /*lbounds=*/std::nullopt, /*takeLboundsIfRealloc=*/false,
lhsRealloc.value());
},
@@ -3358,7 +3358,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
mlir::func::FuncOp func = fir::FirOpBuilder::createFunction(
mlir::UnknownLoc::get(context), getModuleOp(),
fir::NameUniquer::doGenerated("Sham"),
- mlir::FunctionType::get(context, llvm::None, llvm::None));
+ mlir::FunctionType::get(context, std::nullopt, std::nullopt));
func.addEntryBlock();
builder = new fir::FirOpBuilder(func, bridge.getKindMap());
assert(builder && "FirOpBuilder did not instantiate");
diff --git a/flang/lib/Lower/CallInterface.cpp b/flang/lib/Lower/CallInterface.cpp
index 4f6779e5f23da..2fae18bb35fb4 100644
--- a/flang/lib/Lower/CallInterface.cpp
+++ b/flang/lib/Lower/CallInterface.cpp
@@ -683,7 +683,7 @@ class Fortran::lower::CallInterfaceImpl {
&result = procedure.functionResult)
if (const auto *resultTypeAndShape = result->GetTypeAndShape())
return resultTypeAndShape->type();
- return llvm::None;
+ return std::nullopt;
}
static bool mustPassLengthWithDummyProcedure(
@@ -1060,15 +1060,15 @@ class Fortran::lower::CallInterfaceImpl {
getConverter().getFoldingContext(), toEvExpr(*expr)));
return std::nullopt;
}
- void
- addFirOperand(mlir::Type type, int entityPosition, Property p,
- llvm::ArrayRef<mlir::NamedAttribute> attributes = llvm::None) {
+ void addFirOperand(
+ mlir::Type type, int entityPosition, Property p,
+ llvm::ArrayRef<mlir::NamedAttribute> attributes = std::nullopt) {
interface.inputs.emplace_back(
FirPlaceHolder{type, entityPosition, p, attributes});
}
void
addFirResult(mlir::Type type, int entityPosition, Property p,
- llvm::ArrayRef<mlir::NamedAttribute> attributes = llvm::None) {
+ llvm::ArrayRef<mlir::NamedAttribute> attributes = std::nullopt) {
interface.outputs.emplace_back(
FirPlaceHolder{type, entityPosition, p, attributes});
}
diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp
index 0b093503fd774..5b0a6498d1ba2 100644
--- a/flang/lib/Lower/ConvertCall.cpp
+++ b/flang/lib/Lower/ConvertCall.cpp
@@ -290,7 +290,8 @@ fir::ExtendedValue Fortran::lower::genCallOpAndResult(
auto *context = builder.getContext();
if (snd.isa<fir::BoxProcType>() &&
fst.getType().isa<mlir::FunctionType>()) {
- auto funcTy = mlir::FunctionType::get(context, llvm::None, llvm::None);
+ auto funcTy =
+ mlir::FunctionType::get(context, std::nullopt, std::nullopt);
auto boxProcTy = builder.getBoxProcType(funcTy);
if (mlir::Value host = argumentHostAssocs(converter, fst)) {
cast = builder.create<fir::EmboxProcOp>(
@@ -462,7 +463,7 @@ class CallBuilder {
loc, getConverter(), *expr, getSymMap(), getStmtCtx()));
} else {
// Optional dummy argument for which there is no actual argument.
- loweredActuals.emplace_back(llvm::None);
+ loweredActuals.emplace_back(std::nullopt);
}
llvm::SmallVector<hlfir::AssociateOp> exprAssociations;
@@ -553,7 +554,7 @@ class CallBuilder {
for (auto associate : exprAssociations)
builder.create<hlfir::EndAssociateOp>(loc, associate);
if (!resultFirBase)
- return llvm::None; // subroutine call.
+ return std::nullopt; // subroutine call.
if (fir::isa_trivial(resultFirBase.getType()))
return hlfir::EntityWithAttributes{resultFirBase};
return hlfir::genDeclare(loc, builder, result, "tmp.funcresult",
diff --git a/flang/lib/Lower/ConvertConstant.cpp b/flang/lib/Lower/ConvertConstant.cpp
index 3cd3555516b3c..958fa129a2022 100644
--- a/flang/lib/Lower/ConvertConstant.cpp
+++ b/flang/lib/Lower/ConvertConstant.cpp
@@ -126,8 +126,8 @@ class DenseGlobalBuilder {
auto attrTc = TC == Fortran::common::TypeCategory::Logical
? Fortran::common::TypeCategory::Integer
: TC;
- attributeElementType = Fortran::lower::getFIRType(builder.getContext(),
- attrTc, KIND, llvm::None);
+ attributeElementType = Fortran::lower::getFIRType(
+ builder.getContext(), attrTc, KIND, std::nullopt);
for (auto element : constant.values())
attributes.push_back(
convertToAttribute<TC, KIND>(builder, element, attributeElementType));
@@ -198,8 +198,8 @@ static mlir::Value genScalarLit(
fir::FirOpBuilder &builder, mlir::Location loc,
const Fortran::evaluate::Scalar<Fortran::evaluate::Type<TC, KIND>> &value) {
if constexpr (TC == Fortran::common::TypeCategory::Integer) {
- mlir::Type ty =
- Fortran::lower::getFIRType(builder.getContext(), TC, KIND, llvm::None);
+ mlir::Type ty = Fortran::lower::getFIRType(builder.getContext(), TC, KIND,
+ std::nullopt);
if (KIND == 16) {
auto bigInt =
llvm::APInt(ty.getIntOrFloatBitWidth(), value.SignedDecimal(), 10);
@@ -272,7 +272,7 @@ createStringLitOp(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::NamedAttribute sizeAttr(sizeTag, builder.getI64IntegerAttr(len));
llvm::SmallVector<mlir::NamedAttribute> attrs = {dataAttr, sizeAttr};
return builder.create<fir::StringLitOp>(
- loc, llvm::ArrayRef<mlir::Type>{type}, llvm::None, attrs);
+ loc, llvm::ArrayRef<mlir::Type>{type}, std::nullopt, attrs);
}
}
diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index 59a546590a1f3..3ecb217a717c4 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -554,7 +554,7 @@ absentBoxToUnallocatedBox(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Type boxType = box.getType();
assert(boxType.isa<fir::BoxType>() && "argument must be a fir.box");
mlir::Value emptyBox =
- fir::factory::createUnallocatedBox(builder, loc, boxType, llvm::None);
+ fir::factory::createUnallocatedBox(builder, loc, boxType, std::nullopt);
auto safeToReadBox =
builder.create<mlir::arith::SelectOp>(loc, isPresent, box, emptyBox);
return fir::substBase(exv, safeToReadBox);
@@ -1086,8 +1086,9 @@ class ScalarExprLowering {
},
[&](const fir::MutableBoxValue &toBox) {
if (toBox.isPointer()) {
- Fortran::lower::associateMutableBox(
- converter, loc, toBox, expr, /*lbounds=*/llvm::None, stmtCtx);
+ Fortran::lower::associateMutableBox(converter, loc, toBox, expr,
+ /*lbounds=*/std::nullopt,
+ stmtCtx);
return;
}
// For allocatable components, a deep copy is needed.
@@ -1929,7 +1930,7 @@ class ScalarExprLowering {
const Fortran::evaluate::ProcedureRef &procRef,
llvm::Optional<mlir::Type> resultType,
llvm::Optional<const Fortran::evaluate::SpecificIntrinsic> intrinsic =
- llvm::None) {
+ std::nullopt) {
llvm::SmallVector<ExtValue> operands;
std::string name =
@@ -1947,7 +1948,7 @@ class ScalarExprLowering {
operands.emplace_back(optionalArg, isPresent);
};
auto prepareOtherArg = [&](const Fortran::lower::SomeExpr &expr) {
- operands.emplace_back(genval(expr), llvm::None);
+ operands.emplace_back(genval(expr), std::nullopt);
};
Fortran::lower::prepareCustomIntrinsicArgument(
procRef, *intrinsic, resultType, prepareOptionalArg, prepareOtherArg,
@@ -2492,7 +2493,7 @@ class ScalarExprLowering {
if (!actualArgIsVariable && !needsCopy)
// Actual argument is not a variable. Make sure a variable address is
// not passed.
- return {genTempExtAddr(expr), llvm::None};
+ return {genTempExtAddr(expr), std::nullopt};
ExtValue baseAddr;
if (arg.isOptional() && Fortran::evaluate::MayBePassedAsAbsentOptional(
expr, converter.getFoldingContext())) {
@@ -2532,18 +2533,19 @@ class ScalarExprLowering {
ExtValue box = genBoxArg(expr);
if (needsCopy)
return {genCopyIn(box, arg, copyOutPairs,
- /*restrictCopyAtRuntime=*/llvm::None, byValue),
- llvm::None};
+ /*restrictCopyAtRuntime=*/std::nullopt, byValue),
+ std::nullopt};
// Contiguous: just use the box we created above!
// This gets "unboxed" below, if needed.
- return {box, llvm::None};
+ return {box, std::nullopt};
}
// Actual argument is a non-optional, non-pointer, non-allocatable
// scalar.
ExtValue actualArg = genExtAddr(expr);
if (needsCopy)
- return {createInMemoryScalarCopy(builder, loc, actualArg), llvm::None};
- return {actualArg, llvm::None};
+ return {createInMemoryScalarCopy(builder, loc, actualArg),
+ std::nullopt};
+ return {actualArg, std::nullopt};
}();
// Scalar and contiguous expressions may be lowered to a fir.box,
// either to account for potential polymorphism, or because lowering
@@ -2640,7 +2642,8 @@ class ScalarExprLowering {
/*nonDeferredParams=*/mlir::ValueRange{},
/*mutableProperties=*/{});
Fortran::lower::associateMutableBox(converter, loc, pointer, *expr,
- /*lbounds=*/llvm::None, stmtCtx);
+ /*lbounds=*/std::nullopt,
+ stmtCtx);
caller.placeInput(arg, irBox);
continue;
}
@@ -3453,7 +3456,7 @@ class ArrayExprLowering {
builder.createConvert(loc, fir::HeapType::get(seqTy), load);
mlir::Value shapeOp = builder.genShape(loc, shape);
return builder.create<fir::ArrayLoadOp>(
- loc, seqTy, castTo, shapeOp, /*slice=*/mlir::Value{}, llvm::None);
+ loc, seqTy, castTo, shapeOp, /*slice=*/mlir::Value{}, std::nullopt);
};
// Custom lowering of the element store to deal with the extra indirection
// to the lazy allocated buffer.
@@ -4000,7 +4003,7 @@ class ArrayExprLowering {
auto addr =
builder->create<fir::ArrayCoorOp>(loc, eleRefTy, tmp, shape,
/*slice=*/mlir::Value{}, indices,
- /*typeParams=*/llvm::None);
+ /*typeParams=*/std::nullopt);
auto load = builder->create<fir::LoadOp>(loc, addr);
return builder->createConvert(loc, i1Ty, load);
};
@@ -4314,14 +4317,14 @@ class ArrayExprLowering {
mlir::Value temp = !seqTy.hasDynamicExtents()
? builder.create<fir::AllocMemOp>(loc, type)
: builder.create<fir::AllocMemOp>(
- loc, type, ".array.expr", llvm::None, shape);
+ loc, type, ".array.expr", std::nullopt, shape);
fir::FirOpBuilder *bldr = &converter.getFirOpBuilder();
stmtCtx.attachCleanup(
[bldr, loc, temp]() { bldr->create<fir::FreeMemOp>(loc, temp); });
mlir::Value shapeOp = genShapeOp(shape);
return builder.create<fir::ArrayLoadOp>(loc, seqTy, temp, shapeOp,
/*slice=*/mlir::Value{},
- llvm::None);
+ std::nullopt);
}
static fir::ShapeOp genShapeOp(mlir::Location loc, fir::FirOpBuilder &builder,
@@ -4431,7 +4434,7 @@ class ArrayExprLowering {
const Fortran::evaluate::ProcedureRef &procRef,
llvm::Optional<mlir::Type> retTy,
llvm::Optional<const Fortran::evaluate::SpecificIntrinsic> intrinsic =
- llvm::None) {
+ std::nullopt) {
llvm::SmallVector<CC> operands;
std::string name =
@@ -4461,7 +4464,7 @@ class ArrayExprLowering {
};
auto prepareOtherArg = [&](const Fortran::lower::SomeExpr &expr) {
PushSemantics(ConstituentSemantics::RefTransparent);
- operands.emplace_back(genElementalArgument(expr), llvm::None);
+ operands.emplace_back(genElementalArgument(expr), std::nullopt);
};
Fortran::lower::prepareCustomIntrinsicArgument(
procRef, *intrinsic, retTy, prepareOptionalArg, prepareOtherArg,
@@ -4790,7 +4793,7 @@ class ArrayExprLowering {
if (x.hasAlternateReturns())
fir::emitFatalError(getLoc(),
"array procedure reference with alt-return");
- return genProcRef(x, llvm::None);
+ return genProcRef(x, std::nullopt);
}
template <typename A>
CC genScalarAndForwardValue(const A &x) {
@@ -6198,7 +6201,7 @@ class ArrayExprLowering {
mlir::Value initBuffSz =
builder.createIntegerConstant(loc, idxTy, clInitialBufferSize);
mem = builder.create<fir::AllocMemOp>(
- loc, eleTy, /*typeparams=*/llvm::None, initBuffSz);
+ loc, eleTy, /*typeparams=*/std::nullopt, initBuffSz);
builder.create<fir::StoreOp>(loc, initBuffSz, buffSize);
}
} else {
@@ -7400,11 +7403,11 @@ void Fortran::lower::createArrayMergeStores(
}
if (esp.loopCleanup) {
(*esp.loopCleanup)(builder);
- esp.loopCleanup = llvm::None;
+ esp.loopCleanup = std::nullopt;
}
esp.initialArgs.clear();
esp.innerArgs.clear();
- esp.outerLoop = llvm::None;
+ esp.outerLoop = std::nullopt;
esp.resetBindings();
esp.incrementCounter();
}
diff --git a/flang/lib/Lower/ConvertExprToHLFIR.cpp b/flang/lib/Lower/ConvertExprToHLFIR.cpp
index 2c1223e1e6296..c29c6034e7695 100644
--- a/flang/lib/Lower/ConvertExprToHLFIR.cpp
+++ b/flang/lib/Lower/ConvertExprToHLFIR.cpp
@@ -290,7 +290,7 @@ struct BinaryOp<Fortran::evaluate::Power<Fortran::evaluate::Type<TC, KIND>>> {
fir::FirOpBuilder &builder, const Op &,
hlfir::Entity lhs, hlfir::Entity rhs) {
mlir::Type ty = Fortran::lower::getFIRType(builder.getContext(), TC, KIND,
- /*params=*/llvm::None);
+ /*params=*/std::nullopt);
return hlfir::EntityWithAttributes{
Fortran::lower::genPow(builder, loc, ty, lhs, rhs)};
}
@@ -305,7 +305,7 @@ struct BinaryOp<
fir::FirOpBuilder &builder, const Op &,
hlfir::Entity lhs, hlfir::Entity rhs) {
mlir::Type ty = Fortran::lower::getFIRType(builder.getContext(), TC, KIND,
- /*params=*/llvm::None);
+ /*params=*/std::nullopt);
return hlfir::EntityWithAttributes{
Fortran::lower::genPow(builder, loc, ty, lhs, rhs)};
}
@@ -534,7 +534,7 @@ struct UnaryOp<Fortran::evaluate::Negate<
// Like LLVM, integer negation is the binary op "0 - value"
mlir::Type type = Fortran::lower::getFIRType(
builder.getContext(), Fortran::common::TypeCategory::Integer, KIND,
- /*params=*/llvm::None);
+ /*params=*/std::nullopt);
mlir::Value zero = builder.createIntegerConstant(loc, type, 0);
return hlfir::EntityWithAttributes{
builder.create<mlir::arith::SubIOp>(loc, zero, lhs)};
@@ -601,7 +601,7 @@ struct UnaryOp<
TODO(loc, "character conversion in HLFIR");
}
mlir::Type type = Fortran::lower::getFIRType(builder.getContext(), TC1,
- KIND, /*params=*/llvm::None);
+ KIND, /*params=*/std::nullopt);
mlir::Value res = builder.convertWithSemantics(loc, type, lhs);
return hlfir::EntityWithAttributes{res};
}
diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp
index af75e6050b872..f734b7a0a0b8b 100644
--- a/flang/lib/Lower/ConvertVariable.cpp
+++ b/flang/lib/Lower/ConvertVariable.cpp
@@ -198,8 +198,9 @@ mlir::Value Fortran::lower::genInitialDataTarget(
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
if (Fortran::evaluate::UnwrapExpr<Fortran::evaluate::NullPointer>(
initialTarget))
- return fir::factory::createUnallocatedBox(builder, loc, boxType,
- /*nonDeferredParams=*/llvm::None);
+ return fir::factory::createUnallocatedBox(
+ builder, loc, boxType,
+ /*nonDeferredParams=*/std::nullopt);
// Pointer initial data target, and NULL(mold).
for (const auto &sym : Fortran::evaluate::CollectSymbols(initialTarget)) {
// Length parameters processing will need care in global initializer
@@ -343,7 +344,7 @@ static mlir::Value genDefaultInitializerValue(
// need to be disassociated, but for sanity and simplicity, do it in
// global constructor since this has no runtime cost.
componentValue = fir::factory::createUnallocatedBox(
- builder, loc, componentTy, llvm::None);
+ builder, loc, componentTy, std::nullopt);
} else if (hasDefaultInitialization(component)) {
// Component type has default initialization.
componentValue = genDefaultInitializerValue(converter, loc, component,
@@ -471,7 +472,7 @@ static fir::GlobalOp defineGlobal(Fortran::lower::AbstractConverter &converter,
Fortran::lower::createGlobalInitialization(
builder, global, [&](fir::FirOpBuilder &b) {
mlir::Value box =
- fir::factory::createUnallocatedBox(b, loc, symTy, llvm::None);
+ fir::factory::createUnallocatedBox(b, loc, symTy, std::nullopt);
b.create<fir::HasValueOp>(loc, box);
});
}
@@ -842,7 +843,7 @@ instantiateAggregateStore(Fortran::lower::AbstractConverter &converter,
fir::SequenceType::Shape shape(1, size);
auto seqTy = fir::SequenceType::get(shape, i8Ty);
mlir::Value local =
- builder.allocateLocal(loc, seqTy, aggName, "", llvm::None, llvm::None,
+ builder.allocateLocal(loc, seqTy, aggName, "", std::nullopt, std::nullopt,
/*target=*/false);
insertAggregateStore(storeMap, var, local);
}
@@ -1347,8 +1348,8 @@ static void genDeclareSymbol(Fortran::lower::AbstractConverter &converter,
Fortran::lower::SymMap &symMap,
const Fortran::semantics::Symbol &sym,
mlir::Value base, mlir::Value len = {},
- llvm::ArrayRef<mlir::Value> shape = llvm::None,
- llvm::ArrayRef<mlir::Value> lbounds = llvm::None,
+ llvm::ArrayRef<mlir::Value> shape = std::nullopt,
+ llvm::ArrayRef<mlir::Value> lbounds = std::nullopt,
bool force = false) {
if (converter.getLoweringOptions().getLowerToHighLevelFIR()) {
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
diff --git a/flang/lib/Lower/HostAssociations.cpp b/flang/lib/Lower/HostAssociations.cpp
index d1145da63cd43..65bc518b83b4a 100644
--- a/flang/lib/Lower/HostAssociations.cpp
+++ b/flang/lib/Lower/HostAssociations.cpp
@@ -321,15 +321,15 @@ class CapturedArrays : public CapturedSymbols<CapturedArrays> {
.genThen([&]() {
fir::factory::associateMutableBox(builder, loc, boxInTuple,
args.hostValue,
- /*lbounds=*/llvm::None);
+ /*lbounds=*/std::nullopt);
})
.genElse([&]() {
fir::factory::disassociateMutableBox(builder, loc, boxInTuple);
})
.end();
} else {
- fir::factory::associateMutableBox(builder, loc, boxInTuple,
- args.hostValue, /*lbounds=*/llvm::None);
+ fir::factory::associateMutableBox(
+ builder, loc, boxInTuple, args.hostValue, /*lbounds=*/std::nullopt);
}
}
@@ -360,7 +360,7 @@ class CapturedArrays : public CapturedSymbols<CapturedArrays> {
}
if (canReadCapturedBoxValue(converter, sym)) {
- fir::BoxValue boxValue(box, lbounds, /*explicitParams=*/llvm::None);
+ fir::BoxValue boxValue(box, lbounds, /*explicitParams=*/std::nullopt);
args.symMap.addSymbol(sym,
fir::factory::readBoxValue(builder, loc, boxValue));
} else {
@@ -380,7 +380,7 @@ class CapturedArrays : public CapturedSymbols<CapturedArrays> {
box = builder.create<mlir::arith::SelectOp>(loc, isPresent, box,
absentBox);
}
- fir::BoxValue boxValue(box, lbounds, /*explicitParams=*/llvm::None);
+ fir::BoxValue boxValue(box, lbounds, /*explicitParams=*/std::nullopt);
args.symMap.addSymbol(sym, boxValue);
}
}
diff --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp
index 317bd5d9597d6..1e4bd7e0227de 100644
--- a/flang/lib/Lower/IO.cpp
+++ b/flang/lib/Lower/IO.cpp
@@ -352,7 +352,7 @@ getNamelistGroup(Fortran::lower::AbstractConverter &converter,
descAddr = builder.createTemporary(loc, boxType);
fir::MutableBoxValue box = fir::MutableBoxValue(descAddr, {}, {});
fir::factory::associateMutableBox(builder, loc, box, exv,
- /*lbounds=*/llvm::None);
+ /*lbounds=*/std::nullopt);
}
descAddr = builder.createConvert(loc, descRefTy, descAddr);
list = builder.create<fir::InsertValueOp>(loc, listTy, list, descAddr,
@@ -1348,7 +1348,7 @@ static llvm::Optional<fir::ExtendedValue> getVariableBufferRequiredDescriptor(
return varBox;
if (fir::factory::CharacterExprHelper::isArray(varAddr.getType()))
return varBox;
- return llvm::None;
+ return std::nullopt;
}
template <typename A>
@@ -1362,14 +1362,14 @@ maybeGetInternalIODescriptor(Fortran::lower::AbstractConverter &converter,
if (auto *unit = getIOControl<Fortran::parser::IoUnit>(stmt))
if (auto *var = std::get_if<Fortran::parser::Variable>(&unit->u))
return getVariableBufferRequiredDescriptor(converter, loc, *var, stmtCtx);
- return llvm::None;
+ return std::nullopt;
}
template <>
inline llvm::Optional<fir::ExtendedValue>
maybeGetInternalIODescriptor<Fortran::parser::PrintStmt>(
Fortran::lower::AbstractConverter &, mlir::Location loc,
const Fortran::parser::PrintStmt &, Fortran::lower::StatementContext &) {
- return llvm::None;
+ return std::nullopt;
}
template <typename A>
@@ -1955,7 +1955,7 @@ genDataTransferStmt(Fortran::lower::AbstractConverter &converter,
const bool isInternal = isDataTransferInternal(stmt);
llvm::Optional<fir::ExtendedValue> descRef =
isInternal ? maybeGetInternalIODescriptor(converter, loc, stmt, stmtCtx)
- : llvm::None;
+ : std::nullopt;
const bool isInternalWithDesc = descRef.has_value();
const bool isAsync = isDataTransferAsynchronous(loc, stmt);
const bool isNml = isDataTransferNamelist(stmt);
diff --git a/flang/lib/Lower/IterationSpace.cpp b/flang/lib/Lower/IterationSpace.cpp
index d39cb9bd69565..0bcdae6845f70 100644
--- a/flang/lib/Lower/IterationSpace.cpp
+++ b/flang/lib/Lower/IterationSpace.cpp
@@ -822,7 +822,7 @@ void Fortran::lower::ExplicitIterSpace::exprBase(Fortran::lower::FrontEndExpr x,
endAssign();
if (lhs) {
if (bases.empty()) {
- lhsBases.push_back(llvm::None);
+ lhsBases.push_back(std::nullopt);
return;
}
assert(bases.size() >= 1 && "must detect an array reference on lhs");
@@ -854,7 +854,7 @@ void Fortran::lower::ExplicitIterSpace::conditionalCleanup() {
loadBindings.clear();
ccLoopNest.clear();
innerArgs.clear();
- outerLoop = llvm::None;
+ outerLoop = std::nullopt;
clearLoops();
counter = 0;
}
@@ -870,7 +870,7 @@ Fortran::lower::ExplicitIterSpace::findArgPosition(fir::ArrayLoadOp load) {
assert(optPos.has_value() && "load does not correspond to lhs");
return optPos;
}
- return llvm::None;
+ return std::nullopt;
}
llvm::SmallVector<Fortran::lower::FrontEndSymbol>
diff --git a/flang/lib/Lower/Mangler.cpp b/flang/lib/Lower/Mangler.cpp
index 9f6ac8cbe0312..f284a55dbc782 100644
--- a/flang/lib/Lower/Mangler.cpp
+++ b/flang/lib/Lower/Mangler.cpp
@@ -104,7 +104,7 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
// Mangle external procedure without any scope prefix.
if (!keepExternalInScope &&
Fortran::semantics::IsExternal(ultimateSymbol))
- return fir::NameUniquer::doProcedure(llvm::None, llvm::None,
+ return fir::NameUniquer::doProcedure(std::nullopt, std::nullopt,
symbolName);
// Separate module subprograms must be mangled according to the
// scope where they were declared (the symbol we have is the
@@ -127,7 +127,7 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
// Otherwise, this is an external procedure, even if it does not
// have an explicit EXTERNAL attribute. Mangle it without any
// prefix.
- return fir::NameUniquer::doProcedure(llvm::None, llvm::None,
+ return fir::NameUniquer::doProcedure(std::nullopt, std::nullopt,
symbolName);
},
[&](const Fortran::semantics::ObjectEntityDetails &) {
diff --git a/flang/lib/Lower/Runtime.cpp b/flang/lib/Lower/Runtime.cpp
index ef93d4db10312..31a1d0e91153c 100644
--- a/flang/lib/Lower/Runtime.cpp
+++ b/flang/lib/Lower/Runtime.cpp
@@ -114,7 +114,7 @@ void Fortran::lower::genFailImageStatement(
mlir::Location loc = converter.getCurrentLocation();
mlir::func::FuncOp callee =
fir::runtime::getRuntimeFunc<mkRTKey(FailImageStatement)>(loc, builder);
- builder.create<fir::CallOp>(loc, callee, llvm::None);
+ builder.create<fir::CallOp>(loc, callee, std::nullopt);
genUnreachable(builder, loc);
}
@@ -173,7 +173,7 @@ void Fortran::lower::genPauseStatement(
mlir::Location loc = converter.getCurrentLocation();
mlir::func::FuncOp callee =
fir::runtime::getRuntimeFunc<mkRTKey(PauseStatement)>(loc, builder);
- builder.create<fir::CallOp>(loc, callee, llvm::None);
+ builder.create<fir::CallOp>(loc, callee, std::nullopt);
}
mlir::Value Fortran::lower::genAssociated(fir::FirOpBuilder &builder,
@@ -203,7 +203,7 @@ mlir::Value Fortran::lower::genCpuTime(fir::FirOpBuilder &builder,
mlir::Location loc) {
mlir::func::FuncOp func =
fir::runtime::getRuntimeFunc<mkRTKey(CpuTime)>(loc, builder);
- return builder.create<fir::CallOp>(loc, func, llvm::None).getResult(0);
+ return builder.create<fir::CallOp>(loc, func, std::nullopt).getResult(0);
}
void Fortran::lower::genDateAndTime(fir::FirOpBuilder &builder,
diff --git a/flang/lib/Lower/SymbolMap.cpp b/flang/lib/Lower/SymbolMap.cpp
index 84f07c88b9379..d15bb6a8efb85 100644
--- a/flang/lib/Lower/SymbolMap.cpp
+++ b/flang/lib/Lower/SymbolMap.cpp
@@ -101,10 +101,10 @@ Fortran::lower::SymMap::lookupVariableDefinition(semantics::SymbolRef sym) {
std::get_if<fir::FortranVariableOpInterface>(&iter->second))
return *varDef;
else
- return llvm::None;
+ return std::nullopt;
}
}
- return llvm::None;
+ return std::nullopt;
}
llvm::raw_ostream &
diff --git a/flang/lib/Lower/VectorSubscripts.cpp b/flang/lib/Lower/VectorSubscripts.cpp
index 890346f91598e..ca5dfc836e5dc 100644
--- a/flang/lib/Lower/VectorSubscripts.cpp
+++ b/flang/lib/Lower/VectorSubscripts.cpp
@@ -121,7 +121,7 @@ class VectorSubscriptBoxBuilder {
TODO(loc, "threading length parameters in field index op");
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
componentPath.emplace_back(builder.create<fir::FieldIndexOp>(
- loc, fldTy, componentName, recTy, /*typeParams*/ llvm::None));
+ loc, fldTy, componentName, recTy, /*typeParams*/ std::nullopt));
return fir::unwrapSequenceType(recTy.getType(componentName));
}
diff --git a/flang/lib/Optimizer/Builder/Character.cpp b/flang/lib/Optimizer/Builder/Character.cpp
index 89a8e8c7e310c..476187620e0fe 100644
--- a/flang/lib/Optimizer/Builder/Character.cpp
+++ b/flang/lib/Optimizer/Builder/Character.cpp
@@ -372,7 +372,7 @@ fir::factory::CharacterExprHelper::createCharacterTemp(mlir::Type type,
if (typeLen == fir::CharacterType::unknownLen())
lenParams.push_back(len);
auto ref = builder.allocateLocal(loc, charTy, "", ".chrtmp",
- /*shape=*/llvm::None, lenParams);
+ /*shape=*/std::nullopt, lenParams);
return {ref, len};
}
diff --git a/flang/lib/Optimizer/Builder/FIRBuilder.cpp b/flang/lib/Optimizer/Builder/FIRBuilder.cpp
index bb35910f71bfb..a4644a64afc4e 100644
--- a/flang/lib/Optimizer/Builder/FIRBuilder.cpp
+++ b/flang/lib/Optimizer/Builder/FIRBuilder.cpp
@@ -374,7 +374,7 @@ fir::StringLitOp fir::FirOpBuilder::createStringLitOp(mlir::Location loc,
mlir::NamedAttribute sizeAttr(sizeTag, getI64IntegerAttr(data.size()));
llvm::SmallVector<mlir::NamedAttribute> attrs{dataAttr, sizeAttr};
return create<fir::StringLitOp>(loc, llvm::ArrayRef<mlir::Type>{type},
- llvm::None, attrs);
+ std::nullopt, attrs);
}
mlir::Value fir::FirOpBuilder::genShape(mlir::Location loc,
diff --git a/flang/lib/Optimizer/Builder/LowLevelIntrinsics.cpp b/flang/lib/Optimizer/Builder/LowLevelIntrinsics.cpp
index e7335aa194f01..eea4385b1904b 100644
--- a/flang/lib/Optimizer/Builder/LowLevelIntrinsics.cpp
+++ b/flang/lib/Optimizer/Builder/LowLevelIntrinsics.cpp
@@ -26,7 +26,7 @@ mlir::func::FuncOp fir::factory::getLlvmMemcpy(fir::FirOpBuilder &builder) {
llvm::SmallVector<mlir::Type> args = {ptrTy, ptrTy, builder.getI64Type(),
builder.getI1Type()};
auto memcpyTy =
- mlir::FunctionType::get(builder.getContext(), args, llvm::None);
+ mlir::FunctionType::get(builder.getContext(), args, std::nullopt);
return builder.addNamedFunction(builder.getUnknownLoc(),
"llvm.memcpy.p0.p0.i64", memcpyTy);
}
@@ -36,7 +36,7 @@ mlir::func::FuncOp fir::factory::getLlvmMemmove(fir::FirOpBuilder &builder) {
llvm::SmallVector<mlir::Type> args = {ptrTy, ptrTy, builder.getI64Type(),
builder.getI1Type()};
auto memmoveTy =
- mlir::FunctionType::get(builder.getContext(), args, llvm::None);
+ mlir::FunctionType::get(builder.getContext(), args, std::nullopt);
return builder.addNamedFunction(builder.getUnknownLoc(),
"llvm.memmove.p0.p0.i64", memmoveTy);
}
@@ -46,7 +46,7 @@ mlir::func::FuncOp fir::factory::getLlvmMemset(fir::FirOpBuilder &builder) {
llvm::SmallVector<mlir::Type> args = {ptrTy, ptrTy, builder.getI64Type(),
builder.getI1Type()};
auto memsetTy =
- mlir::FunctionType::get(builder.getContext(), args, llvm::None);
+ mlir::FunctionType::get(builder.getContext(), args, std::nullopt);
return builder.addNamedFunction(builder.getUnknownLoc(),
"llvm.memset.p0.p0.i64", memsetTy);
}
@@ -62,7 +62,7 @@ mlir::func::FuncOp fir::factory::getRealloc(fir::FirOpBuilder &builder) {
mlir::func::FuncOp fir::factory::getLlvmStackSave(fir::FirOpBuilder &builder) {
auto ptrTy = builder.getRefType(builder.getIntegerType(8));
auto funcTy =
- mlir::FunctionType::get(builder.getContext(), llvm::None, {ptrTy});
+ mlir::FunctionType::get(builder.getContext(), std::nullopt, {ptrTy});
return builder.addNamedFunction(builder.getUnknownLoc(), "llvm.stacksave",
funcTy);
}
@@ -71,7 +71,7 @@ mlir::func::FuncOp
fir::factory::getLlvmStackRestore(fir::FirOpBuilder &builder) {
auto ptrTy = builder.getRefType(builder.getIntegerType(8));
auto funcTy =
- mlir::FunctionType::get(builder.getContext(), {ptrTy}, llvm::None);
+ mlir::FunctionType::get(builder.getContext(), {ptrTy}, std::nullopt);
return builder.addNamedFunction(builder.getUnknownLoc(), "llvm.stackrestore",
funcTy);
}
@@ -80,7 +80,7 @@ mlir::func::FuncOp
fir::factory::getLlvmInitTrampoline(fir::FirOpBuilder &builder) {
auto ptrTy = builder.getRefType(builder.getIntegerType(8));
auto funcTy = mlir::FunctionType::get(builder.getContext(),
- {ptrTy, ptrTy, ptrTy}, llvm::None);
+ {ptrTy, ptrTy, ptrTy}, std::nullopt);
return builder.addNamedFunction(builder.getUnknownLoc(),
"llvm.init.trampoline", funcTy);
}
diff --git a/flang/lib/Optimizer/Builder/MutableBox.cpp b/flang/lib/Optimizer/Builder/MutableBox.cpp
index 3788554211efc..c470044f5c96b 100644
--- a/flang/lib/Optimizer/Builder/MutableBox.cpp
+++ b/flang/lib/Optimizer/Builder/MutableBox.cpp
@@ -336,7 +336,7 @@ fir::factory::createUnallocatedBox(fir::FirOpBuilder &builder,
auto zero = builder.createIntegerConstant(loc, builder.getIndexType(), 0);
llvm::SmallVector<mlir::Value> extents(seqTy.getDimension(), zero);
shape = builder.createShape(
- loc, fir::ArrayBoxValue{nullAddr, extents, /*lbounds=*/llvm::None});
+ loc, fir::ArrayBoxValue{nullAddr, extents, /*lbounds=*/std::nullopt});
}
// Provide dummy length parameters if they are dynamic. If a length parameter
// is deferred. It is set to zero here and will be set on allocation.
@@ -481,22 +481,23 @@ void fir::factory::associateMutableBox(fir::FirOpBuilder &builder,
mlir::Value tdesc;
if (auto polyBox = source.getBoxOf<fir::PolymorphicValue>())
tdesc = polyBox->getTdesc();
- writer.updateMutableBox(p.getAddr(), /*lbounds=*/llvm::None,
- /*extents=*/llvm::None, /*lengths=*/llvm::None,
- tdesc);
+ writer.updateMutableBox(p.getAddr(), /*lbounds=*/std::nullopt,
+ /*extents=*/std::nullopt,
+ /*lengths=*/std::nullopt, tdesc);
},
[&](const fir::UnboxedValue &addr) {
- writer.updateMutableBox(addr, /*lbounds=*/llvm::None,
- /*extents=*/llvm::None, /*lengths=*/llvm::None);
+ writer.updateMutableBox(addr, /*lbounds=*/std::nullopt,
+ /*extents=*/std::nullopt,
+ /*lengths=*/std::nullopt);
},
[&](const fir::CharBoxValue &ch) {
- writer.updateMutableBox(ch.getAddr(), /*lbounds=*/llvm::None,
- /*extents=*/llvm::None, {ch.getLen()});
+ writer.updateMutableBox(ch.getAddr(), /*lbounds=*/std::nullopt,
+ /*extents=*/std::nullopt, {ch.getLen()});
},
[&](const fir::ArrayBoxValue &arr) {
writer.updateMutableBox(arr.getAddr(),
lbounds.empty() ? arr.getLBounds() : lbounds,
- arr.getExtents(), /*lengths=*/llvm::None);
+ arr.getExtents(), /*lengths=*/std::nullopt);
},
[&](const fir::CharArrayBoxValue &arr) {
writer.updateMutableBox(arr.getAddr(),
@@ -586,11 +587,11 @@ void fir::factory::associateMutableBoxWithRemap(
source.match(
[&](const fir::PolymorphicValue &p) {
writer.updateMutableBox(cast(p.getAddr()), lbounds, extents,
- /*lengths=*/llvm::None);
+ /*lengths=*/std::nullopt);
},
[&](const fir::UnboxedValue &addr) {
writer.updateMutableBox(cast(addr), lbounds, extents,
- /*lengths=*/llvm::None);
+ /*lengths=*/std::nullopt);
},
[&](const fir::CharBoxValue &ch) {
writer.updateMutableBox(cast(ch.getAddr()), lbounds, extents,
@@ -598,7 +599,7 @@ void fir::factory::associateMutableBoxWithRemap(
},
[&](const fir::ArrayBoxValue &arr) {
writer.updateMutableBox(cast(arr.getAddr()), lbounds, extents,
- /*lengths=*/llvm::None);
+ /*lengths=*/std::nullopt);
},
[&](const fir::CharArrayBoxValue &arr) {
writer.updateMutableBox(cast(arr.getAddr()), lbounds, extents,
@@ -705,7 +706,7 @@ static mlir::Value allocateAndInitNewStorage(fir::FirOpBuilder &builder,
// information is available at compile time and could be reflected here
// somehow.
mlir::Value irBox = createNewFirBox(builder, loc, box, newStorage,
- llvm::None, extents, lengths);
+ std::nullopt, extents, lengths);
fir::runtime::genDerivedTypeInitialize(builder, loc, irBox);
}
return newStorage;
diff --git a/flang/lib/Optimizer/Builder/Runtime/Stop.cpp b/flang/lib/Optimizer/Builder/Runtime/Stop.cpp
index fdbd9cd4c2ba6..411181cc6dd1c 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Stop.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Stop.cpp
@@ -25,7 +25,7 @@ void fir::runtime::genExit(fir::FirOpBuilder &builder, mlir::Location loc,
void fir::runtime::genAbort(fir::FirOpBuilder &builder, mlir::Location loc) {
mlir::func::FuncOp abortFunc =
fir::runtime::getRuntimeFunc<mkRTKey(Abort)>(loc, builder);
- builder.create<fir::CallOp>(loc, abortFunc, llvm::None);
+ builder.create<fir::CallOp>(loc, abortFunc, std::nullopt);
}
void fir::runtime::genReportFatalUserError(fir::FirOpBuilder &builder,
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index ffc3a882c3bad..3918e72d2a4c7 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -2047,14 +2047,14 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
if (!rebox.getSubstr().empty())
substringOffset = operands[rebox.substrOffset()];
base = genBoxOffsetGep(rewriter, loc, base, zero,
- /*cstInteriorIndices=*/llvm::None, fieldIndices,
+ /*cstInteriorIndices=*/std::nullopt, fieldIndices,
substringOffset);
}
if (rebox.getSlice().empty())
// The array section is of the form array[%component][substring], keep
// the input array extents and strides.
- return finalizeRebox(rebox, dest, base, /*lbounds*/ llvm::None,
+ return finalizeRebox(rebox, dest, base, /*lbounds*/ std::nullopt,
inputExtents, inputStrides, rewriter);
// Strides from the fir.box are in bytes.
@@ -2104,7 +2104,7 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
slicedStrides.emplace_back(stride);
}
}
- return finalizeRebox(rebox, dest, base, /*lbounds*/ llvm::None,
+ return finalizeRebox(rebox, dest, base, /*lbounds*/ std::nullopt,
slicedExtents, slicedStrides, rewriter);
}
@@ -3012,7 +3012,7 @@ static void genBrOp(A caseOp, mlir::Block *dest, llvm::Optional<B> destOps,
if (destOps)
rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, *destOps, dest);
else
- rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, llvm::None, dest);
+ rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, std::nullopt, dest);
}
static void genCaseLadderStep(mlir::Location loc, mlir::Value cmp,
diff --git a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
index 813dfa566ea47..a8d5925458182 100644
--- a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
+++ b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
@@ -106,8 +106,8 @@ class EmboxConversion : public mlir::OpRewritePattern<fir::EmboxOp> {
shapeOpers.push_back(extVal);
}
auto xbox = rewriter.create<fir::cg::XEmboxOp>(
- loc, embox.getType(), embox.getMemref(), shapeOpers, llvm::None,
- llvm::None, llvm::None, llvm::None, embox.getTypeparams(),
+ loc, embox.getType(), embox.getMemref(), shapeOpers, std::nullopt,
+ std::nullopt, std::nullopt, std::nullopt, embox.getTypeparams(),
embox.getTdesc());
LLVM_DEBUG(llvm::dbgs() << "rewriting " << embox << " to " << xbox << '\n');
rewriter.replaceOp(embox, xbox.getOperation()->getResults());
diff --git a/flang/lib/Optimizer/CodeGen/TypeConverter.h b/flang/lib/Optimizer/CodeGen/TypeConverter.h
index 92d4ade1fdb77..737c28193f2d6 100644
--- a/flang/lib/Optimizer/CodeGen/TypeConverter.h
+++ b/flang/lib/Optimizer/CodeGen/TypeConverter.h
@@ -62,7 +62,7 @@ class LLVMTypeConverter : public mlir::LLVMTypeConverter {
addConversion([&](BoxProcType boxproc) {
// TODO: Support for this type will be added later when the Fortran 2003
// procedure pointer feature is implemented.
- return llvm::None;
+ return std::nullopt;
});
addConversion(
[&](fir::ClassType classTy) { return convertBoxType(classTy); });
@@ -128,7 +128,7 @@ class LLVMTypeConverter : public mlir::LLVMTypeConverter {
});
addConversion([&](mlir::NoneType none) {
return mlir::LLVM::LLVMStructType::getLiteral(
- none.getContext(), llvm::None, /*isPacked=*/false);
+ none.getContext(), std::nullopt, /*isPacked=*/false);
});
// FIXME: https://reviews.llvm.org/D82831 introduced an automatic
// materialization of conversion around function calls that is not working
@@ -140,7 +140,7 @@ class LLVMTypeConverter : public mlir::LLVMTypeConverter {
mlir::ValueRange inputs,
mlir::Location loc) -> llvm::Optional<mlir::Value> {
if (inputs.size() != 1)
- return llvm::None;
+ return std::nullopt;
return inputs[0];
});
// Similar FIXME workaround here (needed for compare.fir/select-type.fir
@@ -150,7 +150,7 @@ class LLVMTypeConverter : public mlir::LLVMTypeConverter {
mlir::ValueRange inputs,
mlir::Location loc) -> llvm::Optional<mlir::Value> {
if (inputs.size() != 1)
- return llvm::None;
+ return std::nullopt;
return inputs[0];
});
}
diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index 409b64b9825bb..e0ca4fef9efaa 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -3353,7 +3353,7 @@ mlir::LogicalResult fir::UnboxProcOp::verify() {
void fir::IfOp::build(mlir::OpBuilder &builder, mlir::OperationState &result,
mlir::Value cond, bool withElseRegion) {
- build(builder, result, llvm::None, cond, withElseRegion);
+ build(builder, result, std::nullopt, cond, withElseRegion);
}
void fir::IfOp::build(mlir::OpBuilder &builder, mlir::OperationState &result,
diff --git a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
index 6cb3170ebe8ab..5bfa0a660be17 100644
--- a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
+++ b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
@@ -351,7 +351,7 @@ getCharacterLengthIfStatic(mlir::Type t) {
hlfir::getFortranElementType(t).dyn_cast<fir::CharacterType>())
if (charType.hasConstantLen())
return charType.getLen();
- return llvm::None;
+ return std::nullopt;
}
mlir::LogicalResult hlfir::ConcatOp::verify() {
diff --git a/flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp b/flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp
index 14e8c5868b758..66bfd2ff4a203 100644
--- a/flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp
+++ b/flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp
@@ -547,7 +547,7 @@ class CfgSelectTypeConv : public OpConversionPattern<fir::SelectTypeOp> {
rewriter.setInsertionPointToEnd(thisBlock);
if (destOps.has_value())
rewriter.create<mlir::cf::CondBranchOp>(loc, cmp, dest, destOps.value(),
- newBlock, llvm::None);
+ newBlock, std::nullopt);
else
rewriter.create<mlir::cf::CondBranchOp>(loc, cmp, dest, newBlock);
rewriter.setInsertionPointToEnd(newBlock);
diff --git a/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp b/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
index f74fe35bc3af0..cc38d9e4b5ea7 100644
--- a/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
+++ b/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
@@ -515,7 +515,7 @@ static llvm::Optional<mlir::Type> getArgElementType(mlir::Value val) {
defOp = val.getDefiningOp();
// Analyze only sequences of convert operations.
if (!mlir::isa<fir::ConvertOp>(defOp))
- return llvm::None;
+ return std::nullopt;
val = defOp->getOperand(0);
// The convert operation is expected to convert from one
// box type to another box type.
diff --git a/flang/tools/f18-parse-demo/f18-parse-demo.cpp b/flang/tools/f18-parse-demo/f18-parse-demo.cpp
index d251154381a15..ae0a3c4fb9877 100644
--- a/flang/tools/f18-parse-demo/f18-parse-demo.cpp
+++ b/flang/tools/f18-parse-demo/f18-parse-demo.cpp
@@ -111,7 +111,7 @@ void Exec(std::vector<llvm::StringRef> &argv, bool verbose = false) {
ErrMsg = Program.getError().message();
if (!Program ||
llvm::sys::ExecuteAndWait(
- Program.get(), argv, llvm::None, {}, 0, 0, &ErrMsg)) {
+ Program.get(), argv, std::nullopt, {}, 0, 0, &ErrMsg)) {
llvm::errs() << "execvp(" << argv[0] << ") failed: " << ErrMsg << '\n';
exit(EXIT_FAILURE);
}
More information about the flang-commits
mailing list