-
Notifications
You must be signed in to change notification settings - Fork 711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix template union forward declaration, close #1768 #2423
base: main
Are you sure you want to change the base?
Conversation
380937f
to
0a09719
Compare
Any review progress? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one LGTM @emilio
@@ -1275,6 +1275,9 @@ impl CompInfo { | |||
CXCursor_ParmDecl => true, | |||
CXCursor_StructDecl | CXCursor_UnionDecl | | |||
CXCursor_ClassDecl => !cur.is_definition(), | |||
CXCursor_ClassTemplate => { | |||
kind == CompKind::Union && !cur.is_definition() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not an issue for structs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below is a sample union XXX
item failing. The panic happens because no layout
can be obtained from the item. This happens because layout: None
and (in case of Unions) fields: []
. In case of struct XXX
, the codepath is different, the layout
is simply not mandatory. See audocxx-bindgen/.../codegen/mod.rs:
impl CodeGenerator for CompInfo {
fn codegen(...) {
...
if is_opaque {
...
} else if !is_union && !zero_sized {
... struct handled here, basically nothing is done without a `layout`
} else if is_union && !forward_decl {
// TODO(emilio): It'd be nice to unify this with the struct path
// above somehow.
let layout = layout.expect("Unable to get layout information?");
...
}
...
}
cargo:warning=MESSAGE:<CompInfo as CodeGenerator>::codegen: item = Item { id: ItemId(23), local_id: OnceCell(<uninit>), next_child_local_id: Cell { value: 1 }, canonical_name: OnceCell(<uninit>), path_for_allowlisting: OnceCell(["root", "Sandwich"]), comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, disallow_debug: false, disallow_default: false, must_use_type: false, visibility_kind: None, accessor_kind: None, constify_enum_variant: false, derives: [] }, parent_id: ItemId(0), kind: Type(Type { name: Some("Sandwich"), layout: None, kind: Comp(CompInfo { kind: Union, visibility: Public, fields: After { fields: [], has_bitfield_units: false }, template_params: [TypeId(ItemId(24))], methods: [], constructors: [], destructor: None, base_members: [], inner_types: [], inner_vars: [], has_own_virtual_method: false, has_destructor: false, has_nonempty_base: false, has_non_type_template_params: false, has_unevaluable_bit_field_width: false, packed_attr: false, found_unknown_attr: false, is_forward_declaration: false }), is_const: false }), location: Some(include/aaa.hh:3:7) }
cargo:warning=MESSAGE:Offset: _address: 0 -> 1
thread 'main' panicked at /home/minion/.cargo/registry/src/index.crates.io-6f17d22bba15001f/autocxx-bindgen-0.69.5/codegen/mod.rs:2291:33:
Unable to get layout information?
(obtained from https://github.com/aleb/autocxx-test/tree/v1 with RUST_LOG=debug RUST_BACKTRACE=full cargo build -r
with this include.h)
No description provided.