[flang-commits] [flang] [flang] Fix deprecation warning (PR #147932)
via flang-commits
flang-commits at lists.llvm.org
Thu Jul 10 03:18:25 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
@llvm/pr-subscribers-flang-codegen
Author: Tom Eccles (tblah)
<details>
<summary>Changes</summary>
I started getting deprecation warnings from operations constructors which seem to be doing implicit construction of mlir::ValueRange from a std::nullopt by relying on implicit conversion from std::nullopt into llvm::ArrayRef. ArrayRef{std::nullopt} is what has been deprecated.
---
Full diff: https://github.com/llvm/llvm-project/pull/147932.diff
2 Files Affected:
- (modified) flang/lib/Optimizer/CodeGen/CodeGen.cpp (+4-4)
- (modified) flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp (+4-3)
``````````diff
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index 1bc981516e226..2fe726cbb00e8 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -2240,7 +2240,7 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
if (!rebox.getSubstr().empty())
substringOffset = operands[rebox.getSubstrOperandIndex()];
base = genBoxOffsetGep(rewriter, loc, base, llvmBaseObjectType, zero,
- /*cstInteriorIndices=*/std::nullopt, fieldIndices,
+ /*cstInteriorIndices=*/{}, fieldIndices,
substringOffset);
}
@@ -2248,7 +2248,7 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
// The array section is of the form array[%component][substring], keep
// the input array extents and strides.
return finalizeRebox(rebox, adaptor, destBoxTy, dest, base,
- /*lbounds*/ std::nullopt, inputExtents, inputStrides,
+ /*lbounds*/ {}, inputExtents, inputStrides,
rewriter);
// The slice is of the form array(i:j:k)[%component]. Compute new extents
@@ -2297,7 +2297,7 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
}
}
return finalizeRebox(rebox, adaptor, destBoxTy, dest, base,
- /*lbounds*/ std::nullopt, slicedExtents, slicedStrides,
+ /*lbounds*/ {}, slicedExtents, slicedStrides,
rewriter);
}
@@ -3396,7 +3396,7 @@ static void genBrOp(A caseOp, mlir::Block *dest, std::optional<B> destOps,
if (destOps)
rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, *destOps, dest);
else
- rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, std::nullopt, dest);
+ rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, B{}, 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 d09d7d397e8b7..b60ac11c7795a 100644
--- a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
+++ b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
@@ -107,9 +107,10 @@ class EmboxConversion : public mlir::OpRewritePattern<fir::EmboxOp> {
shapeOpers.push_back(extVal);
}
auto xbox = rewriter.create<fir::cg::XEmboxOp>(
- loc, embox.getType(), embox.getMemref(), shapeOpers, std::nullopt,
- std::nullopt, std::nullopt, std::nullopt, embox.getTypeparams(),
- embox.getSourceBox(), embox.getAllocatorIdxAttr());
+ loc, embox.getType(), embox.getMemref(), shapeOpers, mlir::ValueRange{},
+ mlir::ValueRange{}, mlir::ValueRange{}, mlir::ValueRange{},
+ embox.getTypeparams(), embox.getSourceBox(),
+ embox.getAllocatorIdxAttr());
LLVM_DEBUG(llvm::dbgs() << "rewriting " << embox << " to " << xbox << '\n');
rewriter.replaceOp(embox, xbox.getOperation()->getResults());
return mlir::success();
``````````
</details>
https://github.com/llvm/llvm-project/pull/147932
More information about the flang-commits
mailing list