DWARF bit field offset wrong values in LLVM

I’m trying to extract information about bitfields in a structure using DWARF info.

The info generated by LLVM seems to be incorrect and not following the DWARF standard.

If this isn’t the right mailing list, please let me know.

If you look at DwarfUnit.cpp in the current LLVM src, it is using DIDerivedType.getOffsetInBits() for the value of DW_AT_data_bit_offset.

The DWARF standard states that the bit offset: “is the offset in bits from the beginning of the containing storage to the beginning of the value”, meaning the field the bitfield is packed in, not the structure holding the field.

As a result of this, the values that LLVM emit are completely out of line with the values that I’m seeing come from gcc.

(Of course, you can’t use a naive example where the bitfields are at the beginning of the struct to test this, they need to occur later in the struct).

Yeah, ignore my ramblings. LLVM is fine, I was visually confusing the pre-dwarf4 bit_offset attribute value with new hotness of data_bit_offset. Thanks Matthew for the cfe-dev suggestion.