[clang] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 25 09:11:36 PDT 2025
================
@@ -19213,6 +19213,29 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl,
if (Record && FD->getType().isVolatileQualified())
Record->setHasVolatileMember(true);
+ auto IsNonDependentBitField = [](const FieldDecl *FD) {
+ if (!FD->isBitField())
+ return false;
+ if (FD->getType()->isDependentType())
+ return false;
+ return true;
+ };
+
+ if (Record && PreviousField && IsNonDependentBitField(FD) &&
+ IsNonDependentBitField(*PreviousField)) {
+ unsigned FDStorageSize =
+ Context.getTypeSizeInChars(FD->getType()).getQuantity();
----------------
ojhunt wrote:
@rnk eep, thanks! I think the reason I switched to getQuantity was because diagprinter can't handle char units (I may just add that in a later patch as it seems like an obvious thing to support)
https://github.com/llvm/llvm-project/pull/117428
More information about the cfe-commits
mailing list