[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 30 08:51:52 PDT 2024
================
@@ -1682,7 +1690,7 @@ class DeclContext {
/// True if a valid hash is stored in ODRHash. This should shave off some
/// extra storage and prevent CXXRecordDecl to store unused bits.
- uint64_t ODRHash : 26;
+ uint64_t ODRHash : 25;
----------------
ilya-biryukov wrote:
Oh, wow, so we have to chip off the bits from an ODR hash when we add a new bit to class state?
This is unfortunate, especially given that it is somewhat hard to measure which trade-offs this entails? (How many bits of ODR hash is too little?)
I don't think it is a reason to block this PR, but it would be nice to come up with a way to measure which number of bits we cannot go under.
A major comment: you also have to update the place that sets the ODRHash. For some reason, we prefer to have the top 26 bits, not the low 26 bits, see: https://github.com/llvm/llvm-project/blob/fb6feb86a7dc324dcb2516397ba3fc5fe05ea584/clang/lib/AST/Decl.cpp#L5219
https://github.com/llvm/llvm-project/pull/102040
More information about the cfe-commits
mailing list