[llvm] [DWARF] Emit 0/1 for constant boolean values (PR #151225)
Michael Buch via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 19 07:15:08 PDT 2025
================
@@ -820,6 +833,22 @@ void DwarfCompileUnit::applyConcreteDbgVariableAttributes(
}
if (!DVal->isVariadic()) {
const DbgValueLocEntry *Entry = DVal->getLocEntries().begin();
+
+ // Helper function to handle boolean constant values with type safety
+ auto addConstantValueWithBooleanNormalization =
+ [&](DIE &VariableDie, uint64_t intValue, const DIType *Type) {
+ if (auto *BasicType = dyn_cast_or_null<DIBasicType>(Type)) {
+ if (BasicType->getEncoding() == dwarf::DW_ATE_boolean) {
+ // Normalize boolean values: any non-zero becomes 1, zero stays 0
+ uint64_t normalizedBoolValue = (intValue) ? 1 : 0;
+ addConstantValue(VariableDie, normalizedBoolValue, Type);
----------------
Michael137 wrote:
Why don't we call `addBooleanConstant` here?
https://github.com/llvm/llvm-project/pull/151225
More information about the llvm-commits
mailing list