[clang] [CIR] Fix getNewInitValue on string-literal arrays (PR #206538)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 29 12:46:27 PDT 2026
================
@@ -1063,8 +1063,13 @@ static mlir::Attribute getNewInitValue(CIRGenModule &cgm, cir::GlobalOp newGlob,
};
if (auto oldArray = mlir::dyn_cast<cir::ConstArrayAttr>(oldInit)) {
- mlir::Attribute newElements =
- getNewInitElements(mlir::cast<mlir::ArrayAttr>(oldArray.getElts()));
+ // A ConstArrayAttr backed by a StringAttr (a string-literal initializer)
----------------
erichkeane wrote:
This comment seems very incomplete, and this fix does as well. Why would any non-array-attr be fine here? Are there any other cases we need to consider?
In fact, the example seems to be cir::ArrayAttr (vs an mlir::ArrayAttr) which could contain basically anything, and could very well contain global references, right? So I think we actually DO need to handle those as well.
https://github.com/llvm/llvm-project/pull/206538
More information about the cfe-commits
mailing list