[clang] [clang] Respect field alignment in layout compatibility of structs (PR #84313)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 7 06:16:02 PST 2024


================
@@ -19185,7 +19185,8 @@ static bool isLayoutCompatible(ASTContext &C, EnumDecl *ED1, EnumDecl *ED2) {
 
 /// Check if two fields are layout-compatible.
 static bool isLayoutCompatible(ASTContext &C, FieldDecl *Field1,
-                               FieldDecl *Field2) {
+                               FieldDecl *Field2,
+                               bool IgnoreAlignment = false) {
----------------
erichkeane wrote:

Yeah,I agree with Corentin, but mostly because it is from the wrong 'direction'.  Bools like this should be named in a way that makes it easy for a user of this function, with no understanding of the implementation to understand.

So it should be, "I want to know if these two are layout compatible... Why would I ignore alignment?" vs "Oh, I'm not dealing with a union member, so I can set this false!".

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


More information about the cfe-commits mailing list