[clang] [llvm] [NFC] Address bit-field storage sizes to ensure ideal packing (PR #139825)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Thu May 15 15:08:53 PDT 2025


================
@@ -74,18 +74,18 @@ enum DiagnosticClass {
 struct StaticDiagInfoRec {
   uint16_t DiagID;
   LLVM_PREFERRED_TYPE(diag::Severity)
-  uint8_t DefaultSeverity : 3;
+  uint16_t DefaultSeverity : 3;
   LLVM_PREFERRED_TYPE(DiagnosticClass)
-  uint8_t Class : 3;
+  uint16_t Class : 3;
   LLVM_PREFERRED_TYPE(DiagnosticIDs::SFINAEResponse)
-  uint8_t SFINAE : 2;
-  uint8_t Category : 6;
+  uint16_t SFINAE : 2;
+  uint16_t Category : 6;
   LLVM_PREFERRED_TYPE(bool)
-  uint8_t WarnNoWerror : 1;
+  uint16_t WarnNoWerror : 1;
   LLVM_PREFERRED_TYPE(bool)
-  uint8_t WarnShowInSystemHeader : 1;
+  uint16_t WarnShowInSystemHeader : 1;
   LLVM_PREFERRED_TYPE(bool)
-  uint8_t WarnShowInSystemMacro : 1;
+  uint16_t WarnShowInSystemMacro : 1;
----------------
ojhunt wrote:

I really wish we had some way of directly asserting the size/packing/offsets, imagine a hyopthetical

```cpp
static_assert(__builtin_current_offset() == x)
```

It would make reasoning about layout significantly easier

https://github.com/llvm/llvm-project/pull/139825


More information about the cfe-commits mailing list