[clang] [llvm] [DebugInfo] Fix endianness in DW_AT_const_value for constexpr arrays (PR #184804)

Michael Buch via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 6 07:15:10 PST 2026


================
@@ -2036,8 +2040,20 @@ DIE *DwarfUnit::getOrCreateStaticMemberDIE(const DIDerivedType *DT) {
 
   if (const ConstantInt *CI = dyn_cast_or_null<ConstantInt>(DT->getConstant()))
     addConstantValue(StaticMemberDIE, CI, Ty);
-  if (const ConstantFP *CFP = dyn_cast_or_null<ConstantFP>(DT->getConstant()))
+  else if (const ConstantFP *CFP =
+               dyn_cast_or_null<ConstantFP>(DT->getConstant()))
     addConstantFPValue(StaticMemberDIE, CFP);
+  else if (auto *CDS =
+               dyn_cast_or_null<ConstantDataSequential>(DT->getConstant())) {
+    // Emit each array element in target byte order using addIntToBlock,
+    // which correctly handles endianness via getElementAsAPInt().
----------------
Michael137 wrote:

Can add an assert here that this is in fact a container of integers?
E.g.,
```
assert (CDS->getElementType()->isIntegerTy() && "Non-integer arrays not supported.")
```

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


More information about the cfe-commits mailing list