================ @@ -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. + if (const CXXRecordDecl *FieldRD = FieldTy->getAsCXXRecordDecl()) { + const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(FieldRD); + if (Layout.getDataSize() < Layout.getSize()) + AllowOverwrite = true; ---------------- rnk wrote:
I hadn't caught the other one! I only happened to find this one through testing, not inspection. I'll have to figure out how to exercise the other codepath. https://github.com/llvm/llvm-project/pull/122197 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits