[PATCH] D23035: [Support] Add LLVM_BITFIELD_WIDTH and LLVM_CHECKED_BITFIELD_ASSIGN macros.

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 1 17:13:36 PDT 2016


rnk added a subscriber: rnk.
rnk added a comment.

Do we really need this macro? I think we should just encourage this pattern:

  class Foo {
  private:
    unsigned Data : 12;
    ...
  public:
    MyEnum getData() { return MyEnum(Data); }
    void setData(MyEnum V) { Data = V; assert(Data == V && "bitfield too small"); }
    ...
  };

Sure, it's not compile time checked, but I hope we have tests exercising the use of all enums in our data structures.


https://reviews.llvm.org/D23035





More information about the llvm-commits mailing list