[clang] [CLANG-CL] ignores Wpadded (PR #134426)

Theo de Magalhaes via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 8 15:48:15 PDT 2025


=?utf-8?q?Théo?= De Magalhaes <theo.de-magalhaes at epita.fr>,
=?utf-8?q?Théo?= De Magalhaes <theo.de-magalhaes at epita.fr>,
=?utf-8?q?Théo?= De Magalhaes <theo.de-magalhaes at epita.fr>,
=?utf-8?q?Théo?= De Magalhaes <theo.de-magalhaes at epita.fr>,
=?utf-8?q?Théo?= De Magalhaes <theo.de-magalhaes at epita.fr>,
=?utf-8?q?Théo?= De Magalhaes <theo.de-magalhaes at epita.fr>,
=?utf-8?q?Théo?= De Magalhaes <theo.de-magalhaes at epita.fr>,
=?utf-8?q?Théo?= De Magalhaes <theo.de-magalhaes at epita.fr>,Theo de
 Magalhaes <theodemagalhaes at icloud.com>,
=?utf-8?q?Théo?= De Magalhaes <theo.de-magalhaes at epita.fr>,
=?utf-8?q?Théo?= De Magalhaes <theo.de-magalhaes at epita.fr>,
=?utf-8?q?Théo?= De Magalhaes <theo.de-magalhaes at epita.fr>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/134426 at github.com>


================
@@ -3231,6 +3259,22 @@ void MicrosoftRecordLayoutBuilder::finalizeLayout(const RecordDecl *RD) {
     Size = Context.toCharUnitsFromBits(External.Size);
     if (External.Align)
       Alignment = Context.toCharUnitsFromBits(External.Align);
+    return;
+  }
+  unsigned CharBitNum = Context.getTargetInfo().getCharWidth();
+  uint64_t DataSizeInBits = Context.toBits(DataSize);
----------------
theomagellan wrote:

You were right, using DataSize did create issues while using certain alignment attributes. I added some in the test file.
Now, 1 byte is artificially added to `UnpaddedSizeInBits` when `Size` is zero before aligning the empty struct to its alignment. This allows to keep the checks as they used to be (using Size instead of DataSize) and also takes care of the empty struct case.

Thank you for catching that case!

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


More information about the cfe-commits mailing list