[clang] [llvm] [DebugInfo] Emit DW_AT_const_value for constexpr array static members (PR #182442)
Shivam Kunwar via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 22 22:45:15 PST 2026
================
@@ -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;
----------------
phyBrackets wrote:
Addressed this differently following @dzhidzhoev suggestion, with preallocating the vector with the filler value and then overwriting with initialized elements. This avoids the Success bool pattern entirely
https://github.com/llvm/llvm-project/pull/182442
More information about the cfe-commits
mailing list