[PATCH] D21489: [codeview] Added support for bitfield type

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 20 09:27:06 PDT 2016


majnemer added a comment.

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.


http://reviews.llvm.org/D21489





More information about the llvm-commits mailing list