[flang-commits] [flang] [Flang] - Handle `BoxCharType` in `fir.box_offset` op (PR #141713)

via flang-commits flang-commits at lists.llvm.org
Tue May 27 20:50:44 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- flang/include/flang/Optimizer/Dialect/FIRType.h flang/lib/Optimizer/CodeGen/CodeGen.cpp flang/lib/Optimizer/Dialect/FIROps.cpp flang/lib/Optimizer/Dialect/FIRType.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index e383c2e3e..82d960a6f 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -3939,11 +3939,11 @@ struct BoxOffsetOpConversion : public fir::FIROpConversion<fir::BoxOffsetOp> {
     mlir::Type llvmBoxTy;
     int fieldId;
     if (auto boxType = mlir::dyn_cast_or_null<fir::BaseBoxType>(boxRefType)) {
-      llvmBoxTy =
-          lowerTy().convertBoxTypeAsStruct(mlir::cast<fir::BaseBoxType>(boxType));
+      llvmBoxTy = lowerTy().convertBoxTypeAsStruct(
+          mlir::cast<fir::BaseBoxType>(boxType));
       fieldId = boxOffset.getField() == fir::BoxFieldAttr::derived_type
-                        ? getTypeDescFieldId(boxType)
-                        : kAddrPosInBox;
+                    ? getTypeDescFieldId(boxType)
+                    : kAddrPosInBox;
     } else {
       auto boxCharType = mlir::cast<fir::BoxCharType>(boxRefType);
       llvmBoxTy = lowerTy().convertType(boxCharType);
diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index 6435886d7..8d3c82d00 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -4490,7 +4490,8 @@ llvm::LogicalResult fir::BoxOffsetOp::verify() {
     boxCharType = mlir::dyn_cast_or_null<fir::BoxCharType>(
         fir::dyn_cast_ptrEleTy(getBoxRef().getType()));
     if (!boxCharType)
-      return emitOpError("box_ref operand must have !fir.ref<!fir.box<T>> or !fir.ref<!fir.boxchar<k>> type");
+      return emitOpError("box_ref operand must have !fir.ref<!fir.box<T>> or "
+                         "!fir.ref<!fir.boxchar<k>> type");
     isBoxChar = true;
   }
   if (getField() != fir::BoxFieldAttr::base_addr &&

``````````

</details>


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


More information about the flang-commits mailing list