[PATCH] D21489: [codeview] Added support for bitfield type
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 21 11:31:36 PDT 2016
majnemer added a comment.
In http://reviews.llvm.org/D21489#463372, @aaboud wrote:
> In http://reviews.llvm.org/D21489#462178, @majnemer wrote:
>
> > This approach still seems a little problematic, consider:
> >
> > #pragma pack(1)
> > struct S {
> > char : 0;
> > int y : 1;
> > };
> > S s;
> >
> >
> > Your code will produce:
> >
> > BitField (0x1001) {
> > TypeLeafKind: LF_BITFIELD (0x1205)
> > Type: int (0x74)
> > BitSize: 1
> > BitOffset: 8
> > }
> > UnknownLeaf (0x1002) {
> > TypeLeafKind: LF_FIELDLIST (0x1203)
> > DataMember {
> > AccessSpecifier: Public (0x3)
> > Type: 0x1001
> > FieldOffset: 0x0
> > Name: y
> > }
> > }
> >
> >
> > However, I think it should produce:
> >
> > BitField (0x1001) {
> > TypeLeafKind: LF_BITFIELD (0x1205)
> > Type: int (0x74)
> > BitSize: 1
> > BitOffset: 0
> > }
> > UnknownLeaf (0x1002) {
> > TypeLeafKind: LF_FIELDLIST (0x1203)
> > DataMember {
> > AccessSpecifier: Public (0x3)
> > Type: 0x1001
> > FieldOffset: 0x1
> > Name: y
> > }
> > }
> >
> >
> > I'm pretty sure that the only real way to get bitfields right is by encoding the storage offset in the DI metadata.
>
>
> I think my code will produce:
>
> BitField (0x1001) {
> TypeLeafKind: LF_BITFIELD (0x1205)
> Type: int (0x74)
> BitSize: 1
> BitOffset: 0
> }
> UnknownLeaf (0x1002) {
> TypeLeafKind: LF_FIELDLIST (0x1203)
> DataMember {
> AccessSpecifier: Public (0x3)
> Type: 0x1001
> FieldOffset: 0x0
> Name: y
> }
> }
>
>
> Which is the same as MS cl.
Would you mind adding it as a test case? Also, can you please rebase your patch? I cannot seem to apply it to trunk.
http://reviews.llvm.org/D21489
More information about the llvm-commits
mailing list