[clang] [CIR][CodeGen] Support DesignatedInitUpdateExpr in constant emission (PR #194238)

via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 26 08:08:31 PDT 2026


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 origin/main HEAD --extensions cpp,c -- clang/test/CIR/CodeGen/designated-init-update.c clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
index 93d06097d..c40fb0464 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
@@ -892,13 +892,11 @@ static bool emitDesignatedInitUpdater(ConstantEmitter &emitter,
     return ConstRecordBuilder::updateRecord(
         emitter, constant, offset, const_cast<InitListExpr *>(updater));
 
-  auto *cat =
-      emitter.cgm.getASTContext().getAsConstantArrayType(type);
+  auto *cat = emitter.cgm.getASTContext().getAsConstantArrayType(type);
   if (!cat)
     return false;
   QualType elemType = cat->getElementType();
-  CharUnits elemSize =
-      emitter.cgm.getASTContext().getTypeSizeInChars(elemType);
+  CharUnits elemSize = emitter.cgm.getASTContext().getTypeSizeInChars(elemType);
   mlir::Type elemTy = emitter.cgm.getTypes().convertTypeForMem(elemType);
 
   mlir::TypedAttr fillC;
@@ -931,8 +929,7 @@ static bool emitDesignatedInitUpdater(ConstantEmitter &emitter,
       // Attempt to reduce the array element to a single constant if necessary.
       constant.condense(offset, elemTy);
     } else {
-      mlir::Attribute val =
-          emitter.tryEmitPrivateForMemory(init, elemType);
+      mlir::Attribute val = emitter.tryEmitPrivateForMemory(init, elemType);
       if (!val)
         return false;
       if (!constant.add(mlir::cast<mlir::TypedAttr>(val), offset, true))

``````````

</details>


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


More information about the cfe-commits mailing list