Skip to content
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

Compute sizedness with a fixed-point analysis #1102

Merged
merged 3 commits into from
Oct 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use self::struct_layout::StructLayoutTracker;

use super::BindgenOptions;

use ir::analysis::HasVtable;
use ir::analysis::{HasVtable, Sizedness};
use ir::annotations::FieldAccessorKind;
use ir::comment;
use ir::comp::{Base, Bitfield, BitfieldUnit, CompInfo, CompKind, Field,
Expand Down Expand Up @@ -1534,7 +1534,7 @@ impl CodeGenerator for CompInfo {
warn!("Opaque type without layout! Expect dragons!");
}
}
} else if !is_union && !self.is_unsized(ctx, item.id().expect_type_id(ctx)) {
} else if !is_union && !item.is_zero_sized(ctx) {
if let Some(padding_field) =
layout.and_then(|layout| struct_layout.pad_struct(layout))
{
Expand Down Expand Up @@ -1565,7 +1565,7 @@ impl CodeGenerator for CompInfo {
//
// NOTE: This check is conveniently here to avoid the dummy fields we
// may add for unused template parameters.
if self.is_unsized(ctx, item.id().expect_type_id(ctx)) {
if item.is_zero_sized(ctx) {
let has_address = if is_opaque {
// Generate the address field if it's an opaque type and
// couldn't determine the layout of the blob.
Expand Down Expand Up @@ -1643,8 +1643,8 @@ impl CodeGenerator for CompInfo {
{
derives.push("Copy");

if ctx.options().rust_features().builtin_clone_impls() ||
used_template_params.is_some()
if ctx.options().rust_features().builtin_clone_impls() ||
used_template_params.is_some()
{
// FIXME: This requires extra logic if you have a big array in a
// templated struct. The reason for this is that the magic:
Expand Down
3 changes: 3 additions & 0 deletions src/ir/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ mod derive_partial_eq_or_partial_ord;
pub use self::derive_partial_eq_or_partial_ord::CannotDerivePartialEqOrPartialOrd;
mod has_float;
pub use self::has_float::HasFloat;
mod sizedness;
pub use self::sizedness::{Sizedness, SizednessAnalysis, SizednessResult};

use ir::context::{BindgenContext, ItemId};

use ir::traversal::{EdgeKind, Trace};
Expand Down
Loading