[flang] Restore Optional::value() (NFC)
This patch restores several calls to Optional::value() in preference to Optional::operator*. The Flang C++ Style Guide tells us to use x.value() where no presence test is obviously protecting a *x reference to the contents. Differential Revision: https://reviews.llvm.org/D128590
This commit is contained in:
parent
066043c84f
commit
dc97886fa3
|
@ -3950,8 +3950,9 @@ public:
|
|||
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), modifyOp.getResult(0));
|
||||
fir::ExtendedValue exv =
|
||||
arrayModifyToExv(builder, loc, explicitSpace->getLhsLoad(0).value(),
|
||||
modifyOp.getResult(0));
|
||||
genScalarUserDefinedAssignmentCall(builder, loc, userAssignment, exv,
|
||||
elementalExv);
|
||||
} else {
|
||||
|
@ -4101,7 +4102,7 @@ private:
|
|||
mlir::Value origVal) {
|
||||
mlir::Value val = builder.createConvert(loc, eleTy, origVal);
|
||||
if (isBoundsSpec()) {
|
||||
auto lbs = *lbounds;
|
||||
auto lbs = lbounds.value();
|
||||
if (lbs.size() > 0) {
|
||||
// Rebox the value with user-specified shift.
|
||||
auto shiftTy = fir::ShiftType::get(eleTy.getContext(), lbs.size());
|
||||
|
@ -6368,7 +6369,7 @@ private:
|
|||
charLen = builder.createTemporary(loc, builder.getI64Type());
|
||||
mlir::Value castLen =
|
||||
builder.createConvert(loc, builder.getI64Type(), fir::getLen(exv));
|
||||
builder.create<fir::StoreOp>(loc, castLen, *charLen);
|
||||
builder.create<fir::StoreOp>(loc, castLen, charLen.value());
|
||||
}
|
||||
}
|
||||
stmtCtx.finalize(/*popScope=*/true);
|
||||
|
@ -6382,7 +6383,7 @@ private:
|
|||
|
||||
// Convert to extended value.
|
||||
if (fir::isa_char(seqTy.getEleTy())) {
|
||||
auto len = builder.create<fir::LoadOp>(loc, *charLen);
|
||||
auto len = builder.create<fir::LoadOp>(loc, charLen.value());
|
||||
return {fir::CharArrayBoxValue{mem, len, extents}, /*needCopy=*/false};
|
||||
}
|
||||
return {fir::ArrayBoxValue{mem, extents}, /*needCopy=*/false};
|
||||
|
@ -6450,7 +6451,7 @@ private:
|
|||
charLen = builder.createTemporary(loc, builder.getI64Type());
|
||||
mlir::Value castLen =
|
||||
builder.createConvert(loc, builder.getI64Type(), fir::getLen(exv));
|
||||
builder.create<fir::StoreOp>(loc, castLen, *charLen);
|
||||
builder.create<fir::StoreOp>(loc, castLen, charLen.value());
|
||||
}
|
||||
}
|
||||
mem = builder.createConvert(loc, fir::HeapType::get(resTy), mem);
|
||||
|
|
|
@ -2818,7 +2818,7 @@ struct SelectCaseOpConversion : public FIROpConversion<fir::SelectCaseOp> {
|
|||
caseOp.getSuccessorOperands(adaptor.getOperands(), t);
|
||||
llvm::Optional<mlir::ValueRange> cmpOps =
|
||||
*caseOp.getCompareOperands(adaptor.getOperands(), t);
|
||||
mlir::Value caseArg = *(cmpOps->begin());
|
||||
mlir::Value caseArg = *(cmpOps.value().begin());
|
||||
mlir::Attribute attr = cases[t];
|
||||
if (attr.isa<fir::PointIntervalAttr>()) {
|
||||
auto cmp = rewriter.create<mlir::LLVM::ICmpOp>(
|
||||
|
@ -2847,7 +2847,7 @@ struct SelectCaseOpConversion : public FIROpConversion<fir::SelectCaseOp> {
|
|||
rewriter.setInsertionPointToEnd(thisBlock);
|
||||
rewriter.create<mlir::LLVM::CondBrOp>(loc, cmp, newBlock1, newBlock2);
|
||||
rewriter.setInsertionPointToEnd(newBlock1);
|
||||
mlir::Value caseArg0 = *(cmpOps->begin() + 1);
|
||||
mlir::Value caseArg0 = *(cmpOps.value().begin() + 1);
|
||||
auto cmp0 = rewriter.create<mlir::LLVM::ICmpOp>(
|
||||
loc, mlir::LLVM::ICmpPredicate::sle, selector, caseArg0);
|
||||
genCondBrOp(loc, cmp0, dest, destOps, rewriter, newBlock2);
|
||||
|
|
Loading…
Reference in a new issue