llvm_unreachable("unknown category");
}
if (lhsIsWholeAllocatable)
- fir::factory::finalizeRealloc(
- *builder, loc, lhsMutableBox.value(),
- /*lbounds=*/std::nullopt, /*takeLboundsIfRealloc=*/false,
- lhsRealloc.value());
+ fir::factory::finalizeRealloc(*builder, loc, *lhsMutableBox,
+ /*lbounds=*/std::nullopt,
+ /*takeLboundsIfRealloc=*/false,
+ *lhsRealloc);
},
// [2] User defined assignment. If the context is a scalar
if (con.Rank() > 0)
return genArrayLit(con);
if (auto ctor = con.GetScalarValue())
- return genval(ctor.value());
+ return genval(*ctor);
fir::emitFatalError(getLoc(),
"constant of derived type has no constructor");
}
mlir::Value oldInnerArg = modifyOp.getSequence();
std::size_t offset = explicitSpace->argPosition(oldInnerArg);
explicitSpace->setInnerArg(offset, fir::getBase(lexv));
- fir::ExtendedValue exv =
- arrayModifyToExv(builder, loc, explicitSpace->getLhsLoad(0).value(),
- modifyOp.getResult(0));
+ fir::ExtendedValue exv = arrayModifyToExv(
+ builder, loc, *explicitSpace->getLhsLoad(0), modifyOp.getResult(0));
genScalarUserDefinedAssignmentCall(builder, loc, userAssignment, exv,
elementalExv);
} else {
}
mlir::Value val = builder.createConvert(loc, eleTy, origVal);
if (isBoundsSpec()) {
- auto lbs = lbounds.value();
+ auto lbs = *lbounds;
if (lbs.size() > 0) {
// Rebox the value with user-specified shift.
auto shiftTy = fir::ShiftType::get(eleTy.getContext(), lbs.size());
mlir::Value{});
}
} else if (isBoundsRemap()) {
- auto lbs = lbounds.value();
+ auto lbs = *lbounds;
if (lbs.size() > 0) {
// Rebox the value with user-specified shift and shape.
- auto shapeShiftArgs = flatZip(lbs, ubounds.value());
+ auto shapeShiftArgs = flatZip(lbs, *ubounds);
auto shapeTy = fir::ShapeShiftType::get(eleTy.getContext(), lbs.size());
mlir::Value shapeShift =
builder.create<fir::ShapeShiftOp>(loc, shapeTy, shapeShiftArgs);
charLen = builder.createTemporary(loc, builder.getI64Type());
mlir::Value castLen =
builder.createConvert(loc, builder.getI64Type(), fir::getLen(exv));
- builder.create<fir::StoreOp>(loc, castLen, charLen.value());
+ builder.create<fir::StoreOp>(loc, castLen, *charLen);
}
}
stmtCtx.finalizeAndPop();
// Convert to extended value.
if (fir::isa_char(seqTy.getEleTy())) {
- auto len = builder.create<fir::LoadOp>(loc, charLen.value());
+ auto len = builder.create<fir::LoadOp>(loc, *charLen);
return {fir::CharArrayBoxValue{mem, len, extents}, /*needCopy=*/false};
}
return {fir::ArrayBoxValue{mem, extents}, /*needCopy=*/false};
charLen = builder.createTemporary(loc, builder.getI64Type());
mlir::Value castLen =
builder.createConvert(loc, builder.getI64Type(), fir::getLen(exv));
- builder.create<fir::StoreOp>(loc, castLen, charLen.value());
+ builder.create<fir::StoreOp>(loc, castLen, *charLen);
}
}
mem = builder.createConvert(loc, fir::HeapType::get(resTy), mem);
auto cmp = fir::runtime::genCharCompare(
builder, loc, translateRelational(op.opr), lhsExv, rhsExv);
if (lhsCleanUp)
- lhsCleanUp.value()();
+ (*lhsCleanUp)();
if (rhsCleanUp)
- rhsCleanUp.value()();
+ (*rhsCleanUp)();
return hlfir::EntityWithAttributes{cmp};
}
};
gen(const Fortran::evaluate::FunctionRef<T> &expr) {
mlir::Type resType =
Fortran::lower::TypeBuilder<T>::genType(getConverter(), expr);
- return Fortran::lower::convertCallToHLFIR(getLoc(), getConverter(), expr,
- resType, getSymMap(),
- getStmtCtx())
- .value();
+ return *Fortran::lower::convertCallToHLFIR(
+ getLoc(), getConverter(), expr, resType, getSymMap(), getStmtCtx());
}
template <typename T>
isPresentCheck(2) &&
"only ISHFTC SIZE arg is expected to be dynamically optional here");
assert(retTy && "ISFHTC must have a return type");
- mlir::Type resultType = retTy.value();
+ mlir::Type resultType = *retTy;
llvm::SmallVector<fir::ExtendedValue> args;
args.push_back(getOperand(0));
args.push_back(getOperand(1));
args.push_back(builder
- .genIfOp(loc, {resultType}, isPresentCheck(2).value(),
+ .genIfOp(loc, {resultType}, *isPresentCheck(2),
/*withElseRegion=*/true)
.genThen([&]() {
fir::ExtendedValue sizeExv = getOperand(2);