[clang] Allow packing fields into tail padding of record fields (PR #122197)

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 8 16:12:38 PST 2025


================
@@ -803,10 +804,16 @@ bool ConstStructBuilder::Build(const InitListExpr *ILE, bool AllowOverwrite) {
       if (!AppendField(Field, Layout.getFieldOffset(FieldNo), EltInit,
                        AllowOverwrite))
         return false;
-      // After emitting a non-empty field with [[no_unique_address]], we may
-      // need to overwrite its tail padding.
-      if (Field->hasAttr<NoUniqueAddressAttr>())
-        AllowOverwrite = true;
+
+      // Allow overwrites after a field with tail padding. This allows
+      // overwriting tail padding of fields carrying [[no_unique_address]]
+      // without checking for it, since it is not necessarily present in debug
+      // info.
----------------
dwblaikie wrote:

I'd probably describe this more generally - something about external AST providers "if an external AST provider (such as lldb) says this is what the layout they want"?

Oh, I see, you aren't actually checking for an external AST provider here - but for the layout that implies no_unique_address or similar.

I guess then, maybe "even in the absence of [[no_unique_address]], such as when using an external AST provider like lldb"?

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


More information about the cfe-commits mailing list