[clang] [CIR] Lower global ConstArrayAttr with string elements to LLVM string constant (PR #194988)

via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 29 17:35:46 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 -- clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp clang/test/CIR/Lowering/array.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/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index 0c4d8fd93..9882e6682 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -2497,18 +2497,20 @@ mlir::LogicalResult CIRToLLVMGlobalOpLowering::matchAndRewrite(
         return mlir::failure();
       }
     } else if (mlir::isa<cir::ConstArrayAttr>(init.value())) {
-      if (mlir::failed(lowerInitializerForConstArray(op, init.value(), rewriter)))
+      if (mlir::failed(
+              lowerInitializerForConstArray(op, init.value(), rewriter)))
         return mlir::failure();
       // If lowerInitializerForConstArray converted the initializer to a
       // non-CIR attribute (e.g. StringAttr), fall through to direct global
       // emission below. Otherwise use the region initializer path.
       if (mlir::isa<cir::ConstArrayAttr>(init.value()))
-        return matchAndRewriteRegionInitializedGlobal(op, init.value(), rewriter);
+        return matchAndRewriteRegionInitializedGlobal(op, init.value(),
+                                                      rewriter);
     } else if (mlir::isa<cir::ConstVectorAttr, cir::ConstRecordAttr,
                          cir::ConstPtrAttr, cir::ConstComplexAttr,
                          cir::GlobalViewAttr, cir::TypeInfoAttr, cir::UndefAttr,
-                         cir::PoisonAttr, cir::VTableAttr,
-                         cir::ZeroAttr>(init.value())) {
+                         cir::PoisonAttr, cir::VTableAttr, cir::ZeroAttr>(
+                   init.value())) {
       // TODO(cir): once LLVM's dialect has proper equivalent attributes this
       // should be updated. For now, we use a custom op to initialize globals
       // to the appropriate value.

``````````

</details>


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


More information about the cfe-commits mailing list