[flang-commits] [flang] [flang][fir] Add fir.if -> scf.if and add filecheck test file (PR #142938)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Thu Jun 5 05:29:06 PDT 2025


================
@@ -87,13 +87,67 @@ struct DoLoopConversion : public OpRewritePattern<fir::DoLoopOp> {
     return success();
   }
 };
+
+struct IfConversion : public OpRewritePattern<fir::IfOp> {
+  using OpRewritePattern<fir::IfOp>::OpRewritePattern;
+  LogicalResult matchAndRewrite(fir::IfOp ifOp,
+                                PatternRewriter &rewriter) const override {
+    auto loc = ifOp.getLoc();
----------------
tblah wrote:

Please could you only use `auto` when the type is written in the initialization expression (or in a few fringe cases where the type is an unreliable implementation detail). For example

This is okay because `scf::IfOp` is made very clear by the expression
```
auto scfIfOp = rewriter.create<scf::IfOp>(...);
```

This would be better with `mlir::Location` spelled out
```
auto loc = ifOp.getLoc();
```

https://github.com/llvm/llvm-project/pull/142938


More information about the flang-commits mailing list