diff options
author | Oliver Geller <oliver.geller@rochester.edu> | 2017-10-04 18:24:58 -0400 |
---|---|---|
committer | Oliver Geller <oliver.geller@rochester.edu> | 2017-10-04 19:14:28 -0400 |
commit | aa27283d7ed482613897ea115345c6531fb24db3 (patch) | |
tree | 17ddb582ce38ec3235864ba16bb3a2b5e53ae2f2 /src | |
parent | 2930a85388db97461b3c4dc678c3ad119c10d2a3 (diff) |
Make bitfields larger than type opaque.
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/comp.rs | 21 | ||||
-rw-r--r-- | src/ir/context.rs | 4 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/ir/comp.rs b/src/ir/comp.rs index 69dc8e58..80c2bde1 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -1473,8 +1473,25 @@ impl DotAttributes for CompInfo { impl IsOpaque for CompInfo { type Extra = (); - fn is_opaque(&self, _: &BindgenContext, _: &()) -> bool { - self.has_non_type_template_params + fn is_opaque(&self, ctx: &BindgenContext, _: &()) -> bool { + // Early return to avoid extra computation + if self.has_non_type_template_params { + return true + } + + self.fields().iter().any(|f| match *f { + Field::DataMember(_) => { + false + }, + Field::Bitfields(ref unit) => { + unit.bitfields().iter().any(|bf| { + let bitfield_layout = ctx.resolve_type(bf.ty()) + .layout(ctx) + .expect("Bitfield without layout? Gah!"); + bf.width() / 8 > bitfield_layout.size as u32 + }) + } + }) } } diff --git a/src/ir/context.rs b/src/ir/context.rs index 27a34162..e9a9b504 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -1137,8 +1137,6 @@ impl BindgenContext { { self.in_codegen = true; - self.assert_no_dangling_references(); - if !self.collected_typerefs() { self.resolve_typerefs(); self.compute_bitfield_units(); @@ -1147,8 +1145,6 @@ impl BindgenContext { self.deanonymize_fields(); - // And assert once again, because resolving type refs and processing - // replacements both mutate the IR graph. self.assert_no_dangling_references(); // Compute the whitelisted set after processing replacements and |