================
@@ -2097,6 +2092,53 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl *Var,
llvm::DIType *RecordTy,
C = llvm::ConstantInt::get(CGM.getLLVMContext(), Value->getInt());
if (Value->isFloat())
C = llvm::ConstantFP::get(CGM.getLLVMContext(), Value->getFloat());
+ if (Value->isArray()) {
+ // Handle constexpr array constants for debug info
+ // We handle arrays of integer types (char, short, int, long),
+ // which covers the most common and useful cases.
+ if (const auto *ArrayTy =
+ CGM.getContext().getAsArrayType(Var->getType())) {
+ QualType ElemQTy = ArrayTy->getElementType();
+ if (ElemQTy->isIntegerType()) {
+ unsigned ElemBitWidth = CGM.getContext().getTypeSize(ElemQTy);
+ unsigned NumElts = Value->getArraySize();
+ unsigned NumInits = Value->getArrayInitializedElts();
+ SmallVector<uint64_t, 64> Vals;
+ Vals.reserve(NumElts);
+ bool Success = true;
+ for (unsigned I = 0; I < NumInits && Success; ++I) {
+ const APValue &Elt = Value->getArrayInitializedElt(I);
+ if (Elt.isInt())
+ Vals.push_back(Elt.getInt().getZExtValue());
----------------
phyBrackets wrote:
Good catch, thanks! Added an early bail-out for ElemBitWidth > 64 before any
getZExtValue() calls. ConstantDataArray only supports up to 64-bit elements
anyway, so this is the right place to reject wider types like __int128.
https://github.com/llvm/llvm-project/pull/182442
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits