[flang-commits] [flang] dc97886 - [flang] Restore Optional::value() (NFC)
Kazu Hirata via flang-commits
flang-commits at lists.llvm.org
Sat Jun 25 13:21:40 PDT 2022
Author: Kazu Hirata
Date: 2022-06-25T13:21:34-07:00
New Revision: dc97886fa36df582ed8957d13e4e51321507dc18
URL: https://github.com/llvm/llvm-project/commit/dc97886fa36df582ed8957d13e4e51321507dc18
DIFF: https://github.com/llvm/llvm-project/commit/dc97886fa36df582ed8957d13e4e51321507dc18.diff
LOG: [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
Added:
Modified:
flang/lib/Lower/ConvertExpr.cpp
flang/lib/Optimizer/CodeGen/CodeGen.cpp
Removed:
################################################################################
diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index 07eceb74e400a..20e7c33df5a6d 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -3950,8 +3950,9 @@ class ArrayExprLowering {
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 @@ class ArrayExprLowering {
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 @@ class ArrayExprLowering {
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 @@ class ArrayExprLowering {
// 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 @@ class ArrayExprLowering {
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);
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index ad59bd734fd05..a451a5da1dcfa 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -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);
More information about the flang-commits
mailing list