[clang] [CLANG][MS-STRUCT] bitfield padding warning presents padding to exact bit count (PR #136062)

Theo de Magalhaes via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 21 15:15:49 PDT 2025


=?utf-8?q?Théo?= de Magalhaes <theodemagalhaes at icloud.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/136062 at github.com>


theomagellan wrote:

It doesn't affect non-ms_struct definitions! The new `PaddingInLastUnit` variable only gets a non-zero value when the following condition is met:
`IsMsStruct && (LastBitfieldStorageUnitSize != StorageUnitSize ||
        UnfilledBitsInLastUnit < FieldSize)`
Otherwise, it remains zero and doesn't impact any calculations.

I could still add tests for that but I am not sure what they would look like as so far the tests only make sure both ABIs (MSVC and Itanium under ms_struct) produce the correct padding warnings.
I'm not entirely sure what new cases you'd like to see covered. 
Do you have something specific in mind?

I gave the `Foo` structure a more descriptive name, thank you.

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


More information about the cfe-commits mailing list