[flang-commits] [flang] [flang] Fix deprecation warning (PR #147932)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Thu Jul 10 03:17:50 PDT 2025
https://github.com/tblah created https://github.com/llvm/llvm-project/pull/147932
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.
>From 86b7f2f9668b88b675e6f195b7d1933fc7aef874 Mon Sep 17 00:00:00 2001
From: Tom Eccles <tom.eccles at arm.com>
Date: Thu, 10 Jul 2025 10:13:06 +0000
Subject: [PATCH] [flang] Fix deprecation warning
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.
---
flang/lib/Optimizer/CodeGen/CodeGen.cpp | 8 ++++----
flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp | 7 ++++---
2 files changed, 8 insertions(+), 7 deletions(-)
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();
More information about the flang-commits
mailing list