[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 30 10:29:09 PDT 2024
================
@@ -5214,9 +5215,9 @@ unsigned RecordDecl::getODRHash() {
// Only calculate hash on first call of getODRHash per record.
ODRHash Hash;
Hash.AddRecordDecl(this);
- // For RecordDecl the ODRHash is stored in the remaining 26
- // bit of RecordDeclBits, adjust the hash to accomodate.
- setODRHash(Hash.CalculateHash() >> 6);
+ // For RecordDecl the ODRHash is stored in the remaining
+ // bit of RecordDeclBits, adjust the hash to accommodate.
+ setODRHash(Hash.CalculateHash() >> (32 - 25));
----------------
erichkeane wrote:
I'd love it if we could put something beyond magic numbers here? Could we do a sizeof(something?) - static-constexpr in the `RecordDeclBits` for the num 25?
Perhaps a `static_assert` as well to make sure the bits is always 32.
https://github.com/llvm/llvm-project/pull/102040
More information about the cfe-commits
mailing list