[PATCH] D19668: [ubsan] Minimize size of data for type_mismatch

Ben Craig via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 28 11:23:55 PDT 2016


bcraig added a subscriber: bcraig.
bcraig added a comment.

If we want to be able to reuse old objects, then you could put a Version member between Alignment and TypeCheckKind.

In the old version, alignment always stored a power of two.  That means that only a single bit was set in the four bytes available.  If you put something with more than one bit in any one of those bytes, then we can tell that it isn't a version zero struct.

  //exposition only
  #define VERSION_ZERO 0x00
  #define VERSION_ONE 0x80 | 0x01
  #define VERSION_TWO 0x80 | 0x02
  
  struct TypeMismatchData {
    SourceLocation Loc;
    const TypeDescriptor &Type;
    unsigned char Alignment;
    unsigned char Version = VERSION_ONE;
    unsigned char TypeCheckKind;
  };


http://reviews.llvm.org/D19668





More information about the llvm-commits mailing list