[clang] [clang][NFC] Refactor enums that hold size of `Type` and `DeclContext` bit-fields (PR #70296)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 26 07:49:05 PDT 2023


================
@@ -1819,10 +1812,10 @@ class DeclContext {
     SourceLocation AtStart;
   };
 
-  /// Number of non-inherited bits in ObjCContainerDeclBitfields.
+  /// Number of inherited and non-inherited bits in ObjCContainerDeclBitfields.
   /// Note that here we rely on the fact that SourceLocation is 32 bits
   /// wide. We check this with the static_assert in the ctor of DeclContext.
-  enum { NumObjCContainerDeclBits = 64 - NumDeclContextBits };
+  enum { NumObjCContainerDeclBits = 64 };
----------------
Endilll wrote:

As we discussed in private, `sizeof` yields size in bytes, so there is a mismatch in units. But it doesn't work even after fixing this, because `ObjCContainerDeclBitfields` is a rare Bitfields type that relies on implicit padding bits, and has a non-bit-field member for that. So I'm not applying this suggestion.

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


More information about the cfe-commits mailing list