danix800 added a comment. I also investigated whether we could count those bits at compile time and statically assert on them, because a small typo or missed update could spend us a lot of time to dig for the cause.
My first step is trying to count number of bits for a single bitfield, this is promising based on this <https://gist.github.com/RMDarth/6357ddd6e09b4117efe84fc3347a732a> but with a restriction, it only works on `struct` (default public fields), not `class` (default to private fields). If we can implement this `bitsizeof` then we could have: enum { NumFunctionDeclBits = offsetof(FunctionDeclBitfields, SClass) + offsetof(FunctionDeclBitfields, IsInline) + ... }; This can automatically update total number of bits if any of the existing one is updated. The second step is trying to enumerate all bit fields at compile time so that we can totally fix this kind of issue, but it seems not possible. Any suggestions or advices? Is it even worth it to do it like this? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D158145/new/ https://reviews.llvm.org/D158145 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits