[clang] [CIR] [Upstream local initialization for ArrayType (PR #132974)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 25 17:59:12 PDT 2025
================
@@ -0,0 +1,150 @@
+//====- LoweringHelpers.cpp - Lowering helper functions -------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains helper functions for lowering from CIR to LLVM or MLIR.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/CIR/LoweringHelpers.h"
+
+mlir::DenseElementsAttr
+convertStringAttrToDenseElementsAttr(cir::ConstArrayAttr attr,
+ mlir::Type type) {
+ auto values = llvm::SmallVector<mlir::APInt, 8>{};
+ const auto stringAttr = mlir::dyn_cast<mlir::StringAttr>(attr.getElts());
----------------
andykaylor wrote:
```suggestion
const auto stringAttr = mlir::cast<mlir::StringAttr>(attr.getElts());
```
Then the assert below is not needed.
https://github.com/llvm/llvm-project/pull/132974
More information about the cfe-commits
mailing list