Add base class subobjects to the Rust struct.
This is documented in a new markdown file, along with the existing layout tweaks for empty classes.
The tl;dr is: use unaligned bytes to represent base classes, and fix the alignment after the fact using `#[repr(align(N))]`. The base classes are not exposed as struct subobjects, because this would not be correct if they have tail padding: they really must be unaligned bytes.
PiperOrigin-RevId: 426021613
diff --git a/rs_bindings_from_cc/ir.h b/rs_bindings_from_cc/ir.h
index 6a8c976..49b9db9 100644
--- a/rs_bindings_from_cc/ir.h
+++ b/rs_bindings_from_cc/ir.h
@@ -388,6 +388,23 @@
int64_t size;
int64_t alignment;
+ // The size of the base class subobjects, or null if there are none.
+ //
+ // More information: docs/struct_layout
+ std::optional<size_t> base_size = std::nullopt;
+
+ // True if the alignment may differ from what the fields would imply.
+ //
+ // For example, a base class or [[no_unique_address]] of alignment 8 should
+ // cause the record to have alignment at least 8. Since the field cannot be
+ // aligned due to layout issues, the parent struct must instead receive an
+ // alignment adjustment as necessary, via .override_alignment=true.
+ //
+ // TODO(b/216726709): use this for [[no_unique_address]].
+ //
+ // More information: docs/struct_layout
+ bool override_alignment = false;
+
// Special member functions.
SpecialMemberFunc copy_constructor = {};
SpecialMemberFunc move_constructor = {};