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

Protected member functions in opaque c++ types #807

Closed
cbourjau opened this issue Jul 12, 2017 · 3 comments
Closed

Protected member functions in opaque c++ types #807

cbourjau opened this issue Jul 12, 2017 · 3 comments

Comments

@cbourjau
Copy link

cbourjau commented Jul 12, 2017

I stumbled over another issue with protected member functions in opaque types. I am using the latest rust-bindgen ( a00db04 ) to get the benefit of those others bugs you guys fixes so quickly. Thanks again!

Input C/C++ Header

class A;
class B {
protected:
  A m_fn1();
};
class C {
  B some_member;
};

Bindgen Invocation

$ bindgen \
    --conservative-inline-namespaces \
    --whitelist-type=C \
    --opaque-type="B" \
    ./pre_processed.hpp \
    -- -x c++ --std=c++11

Actual Results

#[repr(C)]
#[derive(Debug, Copy)]
pub struct B {
    pub _bindgen_opaque_blob: u8,
}
#[test]
fn bindgen_test_layout_B() {
    assert_eq!(::std::mem::size_of::<B>() , 1usize , concat ! (
               "Size of: " , stringify ! ( B ) ));
    assert_eq! (::std::mem::align_of::<B>() , 1usize , concat ! (
                "Alignment of " , stringify ! ( B ) ));
}
extern "C" {
    #[link_name = "_ZN1B5m_fn1Ev"]
    pub fn B_m_fn1(this: *mut B) -> A;
}
impl Clone for B {
    fn clone(&self) -> Self { *self }
}
impl B {
    #[inline]
    pub unsafe fn m_fn1(&mut self) -> A { B_m_fn1(self) }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct C {
    pub some_type: B,
}
#[test]
fn bindgen_test_layout_C() {
    assert_eq!(::std::mem::size_of::<C>() , 1usize , concat ! (
               "Size of: " , stringify ! ( C ) ));
    assert_eq! (::std::mem::align_of::<C>() , 1usize , concat ! (
                "Alignment of " , stringify ! ( C ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const C ) ) . some_type as * const _ as usize }
                , 0usize , concat ! (
                "Alignment of field: " , stringify ! ( C ) , "::" , stringify
                ! ( some_type ) ));
}
impl Clone for C {
    fn clone(&self) -> Self { *self }
}

compilatin with rustc yields:

error[E0412]: cannot find type `A` in this scope
  --> <anon>:17:37
   |
17 |     pub fn B_m_fn1(this: *mut B) -> A;
   |                                     ^ did you mean `B`?

error[E0412]: cannot find type `A` in this scope
  --> <anon>:24:39
   |
24 |     pub unsafe fn m_fn1(&mut self) -> A { B_m_fn1(self) }
   |                                       ^ did you mean `B`?

error[E0601]: main function not found

error: aborting due to 3 previous errors

Expected Results

I would expect all members of the opaque type to not show up in the bindings.

RUST_LOG=bindgen Output

INFO:bindgen: Clang Version: clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
WARN:bindgen: Using clang (3, 8), expected (3, 9)
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children: {} }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: None, loc: None
DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(1)
	ty = Type(A, kind: Record, cconv: 100, decl: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A")), canon: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A"))),
	location = Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A"))
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(A, kind: Record, cconv: 100, decl: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A")), canon: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A"))), Some(Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(A, kind: Record, cconv: 100, decl: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A")), canon: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A"))), Some(Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(1), ty: Type(A, kind: Record, cconv: 100, decl: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A")), canon: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A"))), loc: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A"))
DEBUG:bindgen::ir::ty: currently_parsed_types: [PartialType { decl: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A")), id: ItemId(1) }]
DEBUG:bindgen::ir::comp: CompInfo::from_ty(Struct, Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A")))
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(1), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("A"), layout: None, kind: Comp(CompInfo { kind: Struct, fields: BeforeComputingBitfieldUnits([]), template_params: [], methods: [], constructors: [], destructor: None, base_members: [], inner_types: [], inner_vars: [], has_vtable: false, has_destructor: false, has_nonempty_base: false, has_non_type_template_params: false, packed: false, found_unknown_attr: false, detect_derive_debug_cycle: Cell { value: false }, detect_derive_default_cycle: Cell { value: false }, detect_has_destructor_cycle: Cell { value: false }, is_forward_declaration: true }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A"))), loc: Some(Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A")))
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(1) as child of parent module ItemId(0)
DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(2)
	ty = Type(B, kind: Record, cconv: 100, decl: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")), canon: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))),
	location = Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(B, kind: Record, cconv: 100, decl: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")), canon: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))), Some(Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(B, kind: Record, cconv: 100, decl: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")), canon: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))), Some(Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(2), ty: Type(B, kind: Record, cconv: 100, decl: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")), canon: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))), loc: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))
DEBUG:bindgen::ir::ty: currently_parsed_types: [PartialType { decl: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")), id: ItemId(2) }]
DEBUG:bindgen::ir::comp: CompInfo::from_ty(Struct, Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")))
DEBUG:bindgen::ir::function: Function::parse(Cursor(m_fn1 kind: CXXMethod, loc: ./pre_processed.hpp:4:5, usr: Some("c:@S@B@F@m_fn1#")), Type(A (), kind: FunctionProto, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)))
DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(3)
	ty = Type(A (), kind: FunctionProto, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)),
	location = Cursor(m_fn1 kind: CXXMethod, loc: ./pre_processed.hpp:4:5, usr: Some("c:@S@B@F@m_fn1#"))
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(A (), kind: FunctionProto, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(m_fn1 kind: CXXMethod, loc: ./pre_processed.hpp:4:5, usr: Some("c:@S@B@F@m_fn1#"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(A (), kind: FunctionProto, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(m_fn1 kind: CXXMethod, loc: ./pre_processed.hpp:4:5, usr: Some("c:@S@B@F@m_fn1#"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(3), ty: Type(A (), kind: FunctionProto, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Cursor(m_fn1 kind: CXXMethod, loc: ./pre_processed.hpp:4:5, usr: Some("c:@S@B@F@m_fn1#"))
DEBUG:bindgen::ir::ty: currently_parsed_types: [PartialType { decl: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")), id: ItemId(2) }]
DEBUG:bindgen::ir::function: FunctionSig::from_ty Type(A (), kind: FunctionProto, cconv: 1, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)) Cursor(m_fn1 kind: CXXMethod, loc: ./pre_processed.hpp:4:5, usr: Some("c:@S@B@F@m_fn1#"))
DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(4)
	ty = Type(B, kind: Record, cconv: 100, decl: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")), canon: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))),
	location = Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(B, kind: Record, cconv: 100, decl: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")), canon: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))), Some(Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::item: Avoiding recursion parsing type: Type(B, kind: Record, cconv: 100, decl: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")), canon: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")))
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(5), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: Pointer(ItemId(2)), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: None, loc: None
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(5) as child of parent module ItemId(0)
DEBUG:bindgen::ir::item: from_ty_or_ref_with_id: ItemId(6) Type(A, kind: Record, cconv: 100, decl: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A")), canon: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A"))), Cursor(m_fn1 kind: CXXMethod, loc: ./pre_processed.hpp:4:5, usr: Some("c:@S@B@F@m_fn1#")), None
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(A, kind: Record, cconv: 100, decl: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A")), canon: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A"))), Some(Cursor(m_fn1 kind: CXXMethod, loc: ./pre_processed.hpp:4:5, usr: Some("c:@S@B@F@m_fn1#"))), None
DEBUG:bindgen::ir::context: Already resolved ty ItemId(1), CanonicalTypeDeclaration(Type(A, kind: Record, cconv: 100, decl: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A")), canon: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A"))), Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A"))), Type(A, kind: Record, cconv: 100, decl: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A")), canon: Cursor(A kind: ClassDecl, loc: ./pre_processed.hpp:1:7, usr: Some("c:@S@A"))) Some(Cursor(m_fn1 kind: CXXMethod, loc: ./pre_processed.hpp:4:5, usr: Some("c:@S@B@F@m_fn1#")))
DEBUG:bindgen::ir::context: add_builtin_item: item = Item { id: ItemId(6), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("A"), layout: None, kind: ResolvedTypeRef(ItemId(1)), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(6) as child of parent module ItemId(0)
DEBUG:bindgen::ir::item: ItemId(6) already resolved: Cursor(m_fn1 kind: CXXMethod, loc: ./pre_processed.hpp:4:5, usr: Some("c:@S@B@F@m_fn1#"))
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(3), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: ItemId(6), argument_types: [(Some("this"), ItemId(5))], is_variadic: false, abi: Known(C) }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Some(Cursor(m_fn1 kind: CXXMethod, loc: ./pre_processed.hpp:4:5, usr: Some("c:@S@B@F@m_fn1#")))
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(3) as child of parent module ItemId(0)
DEBUG:bindgen::ir::context: Invalid declaration Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None) found for type Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: ItemId(6), argument_types: [(Some("this"), ItemId(5))], is_variadic: false, abi: Known(C) }), is_const: false }
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(7), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(2), kind: Function(Function { name: "m_fn1", mangled_name: Some("_ZN1B5m_fn1Ev"), signature: ItemId(3), comment: None }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor(m_fn1 kind: CXXMethod, loc: ./pre_processed.hpp:4:5, usr: Some("c:@S@B@F@m_fn1#"))), loc: Some(Cursor(m_fn1 kind: CXXMethod, loc: ./pre_processed.hpp:4:5, usr: Some("c:@S@B@F@m_fn1#")))
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(7) as child of current module ItemId(0)
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("B"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: Comp(CompInfo { kind: Struct, fields: BeforeComputingBitfieldUnits([]), template_params: [], methods: [Method { kind: Normal, signature: ItemId(7), is_const: false }], constructors: [], destructor: None, base_members: [], inner_types: [], inner_vars: [], has_vtable: false, has_destructor: false, has_nonempty_base: false, has_non_type_template_params: false, packed: false, found_unknown_attr: false, detect_derive_debug_cycle: Cell { value: false }, detect_derive_default_cycle: Cell { value: false }, detect_has_destructor_cycle: Cell { value: false }, is_forward_declaration: false }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))), loc: Some(Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")))
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(2) as child of parent module ItemId(0)
DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(8)
	ty = Type(C, kind: Record, cconv: 100, decl: Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C")), canon: Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C"))),
	location = Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C"))
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(C, kind: Record, cconv: 100, decl: Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C")), canon: Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C"))), Some(Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(C, kind: Record, cconv: 100, decl: Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C")), canon: Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C"))), Some(Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(8), ty: Type(C, kind: Record, cconv: 100, decl: Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C")), canon: Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C"))), loc: Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C"))
DEBUG:bindgen::ir::ty: currently_parsed_types: [PartialType { decl: Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C")), id: ItemId(8) }]
DEBUG:bindgen::ir::comp: CompInfo::from_ty(Struct, Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C")))
DEBUG:bindgen::ir::item: from_ty_or_ref_with_id: ItemId(9) Type(B, kind: Record, cconv: 100, decl: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")), canon: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))), Cursor(some_type kind: FieldDecl, loc: ./pre_processed.hpp:7:5, usr: Some("c:@S@C@FI@some_type")), Some(ItemId(8))
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(B, kind: Record, cconv: 100, decl: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")), canon: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))), Some(Cursor(some_type kind: FieldDecl, loc: ./pre_processed.hpp:7:5, usr: Some("c:@S@C@FI@some_type"))), Some(ItemId(8))
DEBUG:bindgen::ir::context: Already resolved ty ItemId(2), CanonicalTypeDeclaration(Type(B, kind: Record, cconv: 100, decl: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")), canon: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))), Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))), Type(B, kind: Record, cconv: 100, decl: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B")), canon: Cursor(B kind: ClassDecl, loc: ./pre_processed.hpp:2:7, usr: Some("c:@S@B"))) Some(Cursor(some_type kind: FieldDecl, loc: ./pre_processed.hpp:7:5, usr: Some("c:@S@C@FI@some_type")))
DEBUG:bindgen::ir::context: add_builtin_item: item = Item { id: ItemId(9), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(8), kind: Type(Type { name: Some("B"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: ResolvedTypeRef(ItemId(2)), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(9) as child of current module ItemId(0)
DEBUG:bindgen::ir::item: ItemId(9) already resolved: Cursor(some_type kind: FieldDecl, loc: ./pre_processed.hpp:7:5, usr: Some("c:@S@C@FI@some_type"))
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(8), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("C"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: Comp(CompInfo { kind: Struct, fields: BeforeComputingBitfieldUnits([RawField(FieldData { name: Some("some_type"), ty: ItemId(9), comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, bitfield: None, mutable: false, offset: Some(0) })]), template_params: [], methods: [], constructors: [], destructor: None, base_members: [], inner_types: [], inner_vars: [], has_vtable: false, has_destructor: false, has_nonempty_base: false, has_non_type_template_params: false, packed: false, found_unknown_attr: false, detect_derive_debug_cycle: Cell { value: false }, detect_derive_default_cycle: Cell { value: false }, detect_has_destructor_cycle: Cell { value: false }, is_forward_declaration: false }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C"))), loc: Some(Cursor(C kind: ClassDecl, loc: ./pre_processed.hpp:6:7, usr: Some("c:@S@C")))
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(8) as child of parent module ItemId(0)
DEBUG:bindgen::ir::context: No replacements to process
DEBUG:bindgen::ir::context: whitelisted_items: testing ""
DEBUG:bindgen::ir::context: whitelisted_items: testing "A"
DEBUG:bindgen::ir::context: whitelisted_items: testing "B"
DEBUG:bindgen::ir::context: whitelisted_items: testing "_bindgen_ty_id_3"
DEBUG:bindgen::ir::context: whitelisted_items: testing "_bindgen_ty_id_5"
DEBUG:bindgen::ir::context: whitelisted_items: testing "A"
DEBUG:bindgen::ir::context: whitelisted_items: testing "B_m_fn1"
DEBUG:bindgen::ir::context: whitelisted_items: testing "C"
DEBUG:bindgen::ir::context: whitelisted_items: testing "B"
DEBUG:bindgen::ir::context: whitelisted_items: testing ""
DEBUG:bindgen::ir::context: whitelisted_items: testing "A"
DEBUG:bindgen::ir::context: whitelisted_items: testing "B"
DEBUG:bindgen::ir::context: whitelisted_items: testing "_bindgen_ty_id_3"
DEBUG:bindgen::ir::context: whitelisted_items: testing "_bindgen_ty_id_5"
DEBUG:bindgen::ir::context: whitelisted_items: testing "A"
DEBUG:bindgen::ir::context: whitelisted_items: testing "B_m_fn1"
DEBUG:bindgen::ir::context: whitelisted_items: testing "C"
DEBUG:bindgen::ir::context: whitelisted_items: testing "B"
TRACE:bindgen::ir::named: constrain ItemId(2)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:   finally, used set is {}
TRACE:bindgen::ir::named: constrain ItemId(2)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:   finally, used set is {}
TRACE:bindgen::ir::named: constrain ItemId(9)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:       union with ItemId(2)'s usage: []
TRACE:bindgen::ir::named:   finally, used set is {}
TRACE:bindgen::ir::named: constrain ItemId(9)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:       union with ItemId(2)'s usage: []
TRACE:bindgen::ir::named:   finally, used set is {}
TRACE:bindgen::ir::named: constrain ItemId(8)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:       union with ItemId(9)'s usage: []
TRACE:bindgen::ir::named:   finally, used set is {}
TRACE:bindgen::ir::named: constrain ItemId(0)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:   finally, used set is {}
DEBUG:bindgen::codegen: codegen: BindgenOptions { hidden_types: RegexSet { items: [], set: Some(RegexSet([])) }, opaque_types: RegexSet { items: ["^B$"], set: Some(RegexSet(["^B$"])) }, whitelisted_types: RegexSet { items: ["^C$"], set: Some(RegexSet(["^C$"])) }, whitelisted_functions: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_vars: RegexSet { items: [], set: Some(RegexSet([])) }, bitfield_enums: RegexSet { items: [], set: Some(RegexSet([])) }, constified_enums: RegexSet { items: [], set: Some(RegexSet([])) }, constified_enum_modules: RegexSet { items: [], set: Some(RegexSet([])) }, builtins: false, links: [], emit_ast: false, emit_ir: false, emit_ir_graphviz: None, enable_cxx_namespaces: false, disable_name_namespacing: false, layout_tests: true, derive_debug: true, derive_default: false, unstable_rust: false, use_core: false, ctypes_prefix: None, namespaced_constants: true, msvc_mangling: false, convert_floats: true, raw_lines: [], clang_args: ["-x", "c++", "--std=c++11", "-isystem", "/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0", "-isystem", "/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0", "-isystem", "/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/backward", "-isystem", "/usr/local/include", "-isystem", "/usr/lib/llvm-3.8/bin/../lib/clang/3.8.0/include", "-isystem", "/usr/include/x86_64-linux-gnu", "-isystem", "/usr/include", "./pre_processed.hpp"], input_header: Some("./pre_processed.hpp"), input_unsaved_files: [], dummy_uses: None, parse_callbacks: None, codegen_config: CodegenConfig { functions: true, types: true, vars: true, methods: true, constructors: true, destructors: true }, conservative_inline_namespaces: true, generate_comments: true, generate_inline_functions: false, whitelist_recursively: true, objc_extern_crate: false, enable_mangling: true, prepend_enum_name: true }
DEBUG:bindgen::ir::context: whitelisted_items: testing ""
DEBUG:bindgen::ir::context: whitelisted_items: testing "A"
DEBUG:bindgen::ir::context: whitelisted_items: testing "B"
DEBUG:bindgen::ir::context: whitelisted_items: testing "_bindgen_ty_id_3"
DEBUG:bindgen::ir::context: whitelisted_items: testing "_bindgen_ty_id_5"
DEBUG:bindgen::ir::context: whitelisted_items: testing "A"
DEBUG:bindgen::ir::context: whitelisted_items: testing "B_m_fn1"
DEBUG:bindgen::ir::context: whitelisted_items: testing "C"
DEBUG:bindgen::ir::context: whitelisted_items: testing "B"
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children: {ItemId(1), ItemId(2), ItemId(3), ItemId(5), ItemId(6), ItemId(7), ItemId(8), ItemId(9)} }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Module as CodeGenerator>::codegen: item = Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children: {ItemId(1), ItemId(2), ItemId(3), ItemId(5), ItemId(6), ItemId(7), ItemId(8), ItemId(9)} }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("B"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: Comp(CompInfo { kind: Struct, fields: AfterComputingBitfieldUnits([]), template_params: [], methods: [Method { kind: Normal, signature: ItemId(7), is_const: false }], constructors: [], destructor: None, base_members: [], inner_types: [], inner_vars: [], has_vtable: false, has_destructor: false, has_nonempty_base: false, has_non_type_template_params: false, packed: false, found_unknown_attr: false, detect_derive_debug_cycle: Cell { value: false }, detect_derive_default_cycle: Cell { value: false }, detect_has_destructor_cycle: Cell { value: false }, is_forward_declaration: false }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("B"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: Comp(CompInfo { kind: Struct, fields: AfterComputingBitfieldUnits([]), template_params: [], methods: [Method { kind: Normal, signature: ItemId(7), is_const: false }], constructors: [], destructor: None, base_members: [], inner_types: [], inner_vars: [], has_vtable: false, has_destructor: false, has_nonempty_base: false, has_non_type_template_params: false, packed: false, found_unknown_attr: false, detect_derive_debug_cycle: Cell { value: false }, detect_derive_default_cycle: Cell { value: false }, detect_has_destructor_cycle: Cell { value: false }, is_forward_declaration: false }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <CompInfo as CodeGenerator>::codegen: item = Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("B"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: Comp(CompInfo { kind: Struct, fields: AfterComputingBitfieldUnits([]), template_params: [], methods: [Method { kind: Normal, signature: ItemId(7), is_const: false }], constructors: [], destructor: None, base_members: [], inner_types: [], inner_vars: [], has_vtable: false, has_destructor: false, has_nonempty_base: false, has_non_type_template_params: false, packed: false, found_unknown_attr: false, detect_derive_debug_cycle: Cell { value: false }, detect_derive_default_cycle: Cell { value: false }, detect_has_destructor_cycle: Cell { value: false }, is_forward_declaration: false }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(7), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(2), kind: Function(Function { name: "m_fn1", mangled_name: Some("_ZN1B5m_fn1Ev"), signature: ItemId(3), comment: None }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
ERROR:bindgen::codegen: Found non-whitelisted item in code generation: Item { id: ItemId(7), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(2), kind: Function(Function { name: "m_fn1", mangled_name: Some("_ZN1B5m_fn1Ev"), signature: ItemId(3), comment: None }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Function as CodeGenerator>::codegen: item = Item { id: ItemId(7), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(2), kind: Function(Function { name: "m_fn1", mangled_name: Some("_ZN1B5m_fn1Ev"), signature: ItemId(3), comment: None }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(8), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("C"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: Comp(CompInfo { kind: Struct, fields: AfterComputingBitfieldUnits([DataMember(FieldData { name: Some("some_type"), ty: ItemId(9), comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, bitfield: None, mutable: false, offset: Some(0) })]), template_params: [], methods: [], constructors: [], destructor: None, base_members: [], inner_types: [], inner_vars: [], has_vtable: false, has_destructor: false, has_nonempty_base: false, has_non_type_template_params: false, packed: false, found_unknown_attr: false, detect_derive_debug_cycle: Cell { value: false }, detect_derive_default_cycle: Cell { value: false }, detect_has_destructor_cycle: Cell { value: false }, is_forward_declaration: false }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(8), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("C"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: Comp(CompInfo { kind: Struct, fields: AfterComputingBitfieldUnits([DataMember(FieldData { name: Some("some_type"), ty: ItemId(9), comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, bitfield: None, mutable: false, offset: Some(0) })]), template_params: [], methods: [], constructors: [], destructor: None, base_members: [], inner_types: [], inner_vars: [], has_vtable: false, has_destructor: false, has_nonempty_base: false, has_non_type_template_params: false, packed: false, found_unknown_attr: false, detect_derive_debug_cycle: Cell { value: false }, detect_derive_default_cycle: Cell { value: false }, detect_has_destructor_cycle: Cell { value: false }, is_forward_declaration: false }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <CompInfo as CodeGenerator>::codegen: item = Item { id: ItemId(8), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("C"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: Comp(CompInfo { kind: Struct, fields: AfterComputingBitfieldUnits([DataMember(FieldData { name: Some("some_type"), ty: ItemId(9), comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, bitfield: None, mutable: false, offset: Some(0) })]), template_params: [], methods: [], constructors: [], destructor: None, base_members: [], inner_types: [], inner_vars: [], has_vtable: false, has_destructor: false, has_nonempty_base: false, has_non_type_template_params: false, packed: false, found_unknown_attr: false, detect_derive_debug_cycle: Cell { value: false }, detect_derive_default_cycle: Cell { value: false }, detect_has_destructor_cycle: Cell { value: false }, is_forward_declaration: false }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen::struct_layout: Offset: <padding>: 0 -> 0
DEBUG:bindgen::codegen::struct_layout: align field some_type to 0/0 with 0 padding bytes Layout { size: 1, align: 1, packed: false }
DEBUG:bindgen::codegen::struct_layout: Offset: some_type: 0 -> 1
DEBUG:bindgen::codegen::struct_layout: pad_struct:
	self = StructLayoutTracker {
    name: "C",
    ctx: BindgenContext {
        items: {
            ItemId(
                0
            ): Item {
                id: ItemId(
                    0
                ),
                local_id: Cell {
                    value: None
                },
                next_child_local_id: Cell {
                    value: 1
                },
                canonical_name_cache: RefCell {
                    value: None
                },
                comment: None,
                annotations: Annotations {
                    opaque: false,
                    hide: false,
                    use_instead_of: None,
                    disallow_copy: false,
                    private_fields: None,
                    accessor_kind: None,
                    constify_enum_variant: false
                },
                parent_id: ItemId(
                    0
                ),
                kind: Module(
                    Module {
                        name: Some(
                            "root"
                        ),
                        kind: Normal,
                        children: {
                            ItemId(
                                1
                            ),
                            ItemId(
                                2
                            ),
                            ItemId(
                                3
                            ),
                            ItemId(
                                5
                            ),
                            ItemId(
                                6
                            ),
                            ItemId(
                                7
                            ),
                            ItemId(
                                8
                            ),
                            ItemId(
                                9
                            )
                        }
                    }
                ),
                detect_derive_debug_cycle: Cell {
                    value: false
                },
                detect_derive_copy_cycle: Cell {
                    value: false
                }
            },
            ItemId(
                1
            ): Item {
                id: ItemId(
                    1
                ),
                local_id: Cell {
                    value: None
                },
                next_child_local_id: Cell {
                    value: 1
                },
                canonical_name_cache: RefCell {
                    value: None
                },
                comment: None,
                annotations: Annotations {
                    opaque: false,
                    hide: false,
                    use_instead_of: None,
                    disallow_copy: false,
                    private_fields: None,
                    accessor_kind: None,
                    constify_enum_variant: false
                },
                parent_id: ItemId(
                    0
                ),
                kind: Type(
                    Type {
                        name: Some(
                            "A"
                        ),
                        layout: None,
                        kind: Comp(
                            CompInfo {
                                kind: Struct,
                                fields: AfterComputingBitfieldUnits(
                                    []
                                ),
                                template_params: [],
                                methods: [],
                                constructors: [],
                                destructor: None,
                                base_members: [],
                                inner_types: [],
                                inner_vars: [],
                                has_vtable: false,
                                has_destructor: false,
                                has_nonempty_base: false,
                                has_non_type_template_params: false,
                                packed: false,
                                found_unknown_attr: false,
                                detect_derive_debug_cycle: Cell {
                                    value: false
                                },
                                detect_derive_default_cycle: Cell {
                                    value: false
                                },
                                detect_has_destructor_cycle: Cell {
                                    value: false
                                },
                                is_forward_declaration: true
                            }
                        ),
                        is_const: false
                    }
                ),
                detect_derive_debug_cycle: Cell {
                    value: false
                },
                detect_derive_copy_cycle: Cell {
                    value: false
                }
            },
            ItemId(
                2
            ): Item {
                id: ItemId(
                    2
                ),
                local_id: Cell {
                    value: None
                },
                next_child_local_id: Cell {
                    value: 1
                },
                canonical_name_cache: RefCell {
                    value: Some(
                        "B"
                    )
                },
                comment: None,
                annotations: Annotations {
                    opaque: false,
                    hide: false,
                    use_instead_of: None,
                    disallow_copy: false,
                    private_fields: None,
                    accessor_kind: None,
                    constify_enum_variant: false
                },
                parent_id: ItemId(
                    0
                ),
                kind: Type(
                    Type {
                        name: Some(
                            "B"
                        ),
                        layout: Some(
                            Layout {
                                size: 1,
                                align: 1,
                                packed: false
                            }
                        ),
                        kind: Comp(
                            CompInfo {
                                kind: Struct,
                                fields: AfterComputingBitfieldUnits(
                                    []
                                ),
                                template_params: [],
                                methods: [
                                    Method {
                                        kind: Normal,
                                        signature: ItemId(
                                            7
                                        ),
                                        is_const: false
                                    }
                                ],
                                constructors: [],
                                destructor: None,
                                base_members: [],
                                inner_types: [],
                                inner_vars: [],
                                has_vtable: false,
                                has_destructor: false,
                                has_nonempty_base: false,
                                has_non_type_template_params: false,
                                packed: false,
                                found_unknown_attr: false,
                                detect_derive_debug_cycle: Cell {
                                    value: false
                                },
                                detect_derive_default_cycle: Cell {
                                    value: false
                                },
                                detect_has_destructor_cycle: Cell {
                                    value: false
                                },
                                is_forward_declaration: false
                            }
                        ),
                        is_const: false
                    }
                ),
                detect_derive_debug_cycle: Cell {
                    value: false
                },
                detect_derive_copy_cycle: Cell {
                    value: false
                }
            },
            ItemId(
                3
            ): Item {
                id: ItemId(
                    3
                ),
                local_id: Cell {
                    value: None
                },
                next_child_local_id: Cell {
                    value: 1
                },
                canonical_name_cache: RefCell {
                    value: None
                },
                comment: None,
                annotations: Annotations {
                    opaque: false,
                    hide: false,
                    use_instead_of: None,
                    disallow_copy: false,
                    private_fields: None,
                    accessor_kind: None,
                    constify_enum_variant: false
                },
                parent_id: ItemId(
                    0
                ),
                kind: Type(
                    Type {
                        name: None,
                        layout: Some(
                            Layout {
                                size: 1,
                                align: 4,
                                packed: false
                            }
                        ),
                        kind: Function(
                            FunctionSig {
                                return_type: ItemId(
                                    6
                                ),
                                argument_types: [
                                    (
                                        Some(
                                            "this"
                                        ),
                                        ItemId(
                                            5
                                        )
                                    )
                                ],
                                is_variadic: false,
                                abi: Known(
                                    C
                                )
                            }
                        ),
                        is_const: false
                    }
                ),
                detect_derive_debug_cycle: Cell {
                    value: false
                },
                detect_derive_copy_cycle: Cell {
                    value: false
                }
            },
            ItemId(
                5
            ): Item {
                id: ItemId(
                    5
                ),
                local_id: Cell {
                    value: None
                },
                next_child_local_id: Cell {
                    value: 1
                },
                canonical_name_cache: RefCell {
                    value: None
                },
                comment: None,
                annotations: Annotations {
                    opaque: false,
                    hide: false,
                    use_instead_of: None,
                    disallow_copy: false,
                    private_fields: None,
                    accessor_kind: None,
                    constify_enum_variant: false
                },
                parent_id: ItemId(
                    0
                ),
                kind: Type(
                    Type {
                        name: None,
                        layout: None,
                        kind: Pointer(
                            ItemId(
                                2
                            )
                        ),
                        is_const: false
                    }
                ),
                detect_derive_debug_cycle: Cell {
                    value: false
                },
                detect_derive_copy_cycle: Cell {
                    value: false
                }
            },
            ItemId(
                6
            ): Item {
                id: ItemId(
                    6
                ),
                local_id: Cell {
                    value: None
                },
                next_child_local_id: Cell {
                    value: 1
                },
                canonical_name_cache: RefCell {
                    value: None
                },
                comment: None,
                annotations: Annotations {
                    opaque: false,
                    hide: false,
                    use_instead_of: None,
                    disallow_copy: false,
                    private_fields: None,
                    accessor_kind: None,
                    constify_enum_variant: false
                },
                parent_id: ItemId(
                    0
                ),
                kind: Type(
                    Type {
                        name: Some(
                            "A"
                        ),
                        layout: None,
                        kind: ResolvedTypeRef(
                            ItemId(
                                1
                            )
                        ),
                        is_const: false
                    }
                ),
                detect_derive_debug_cycle: Cell {
                    value: false
                },
                detect_derive_copy_cycle: Cell {
                    value: false
                }
            },
            ItemId(
                7
            ): Item {
                id: ItemId(
                    7
                ),
                local_id: Cell {
                    value: None
                },
                next_child_local_id: Cell {
                    value: 1
                },
                canonical_name_cache: RefCell {
                    value: Some(
                        "B_m_fn1"
                    )
                },
                comment: None,
                annotations: Annotations {
                    opaque: false,
                    hide: false,
                    use_instead_of: None,
                    disallow_copy: false,
                    private_fields: None,
                    accessor_kind: None,
                    constify_enum_variant: false
                },
                parent_id: ItemId(
                    2
                ),
                kind: Function(
                    Function {
                        name: "m_fn1",
                        mangled_name: Some(
                            "_ZN1B5m_fn1Ev"
                        ),
                        signature: ItemId(
                            3
                        ),
                        comment: None
                    }
                ),
                detect_derive_debug_cycle: Cell {
                    value: false
                },
                detect_derive_copy_cycle: Cell {
                    value: false
                }
            },
            ItemId(
                8
            ): Item {
                id: ItemId(
                    8
                ),
                local_id: Cell {
                    value: None
                },
                next_child_local_id: Cell {
                    value: 1
                },
                canonical_name_cache: RefCell {
                    value: Some(
                        "C"
                    )
                },
                comment: None,
                annotations: Annotations {
                    opaque: false,
                    hide: false,
                    use_instead_of: None,
                    disallow_copy: false,
                    private_fields: None,
                    accessor_kind: None,
                    constify_enum_variant: false
                },
                parent_id: ItemId(
                    0
                ),
                kind: Type(
                    Type {
                        name: Some(
                            "C"
                        ),
                        layout: Some(
                            Layout {
                                size: 1,
                                align: 1,
                                packed: false
                            }
                        ),
                        kind: Comp(
                            CompInfo {
                                kind: Struct,
                                fields: AfterComputingBitfieldUnits(
                                    [
                                        DataMember(
                                            FieldData {
                                                name: Some(
                                                    "some_type"
                                                ),
                                                ty: ItemId(
                                                    9
                                                ),
                                                comment: None,
                                                annotations: Annotations {
                                                    opaque: false,
                                                    hide: false,
                                                    use_instead_of: None,
                                                    disallow_copy: false,
                                                    private_fields: None,
                                                    accessor_kind: None,
                                                    constify_enum_variant: false
                                                },
                                                bitfield: None,
                                                mutable: false,
                                                offset: Some(
                                                    0
                                                )
                                            }
                                        )
                                    ]
                                ),
                                template_params: [],
                                methods: [],
                                constructors: [],
                                destructor: None,
                                base_members: [],
                                inner_types: [],
                                inner_vars: [],
                                has_vtable: false,
                                has_destructor: false,
                                has_nonempty_base: false,
                                has_non_type_template_params: false,
                                packed: false,
                                found_unknown_attr: false,
                                detect_derive_debug_cycle: Cell {
                                    value: false
                                },
                                detect_derive_default_cycle: Cell {
                                    value: false
                                },
                                detect_has_destructor_cycle: Cell {
                                    value: false
                                },
                                is_forward_declaration: false
                            }
                        ),
                        is_const: false
                    }
                ),
                detect_derive_debug_cycle: Cell {
                    value: false
                },
                detect_derive_copy_cycle: Cell {
                    value: false
                }
            },
            ItemId(
                9
            ): Item {
                id: ItemId(
                    9
                ),
                local_id: Cell {
                    value: None
                },
                next_child_local_id: Cell {
                    value: 1
                },
                canonical_name_cache: RefCell {
                    value: None
                },
                comment: None,
                annotations: Annotations {
                    opaque: false,
                    hide: false,
                    use_instead_of: None,
                    disallow_copy: false,
                    private_fields: None,
                    accessor_kind: None,
                    constify_enum_variant: false
                },
                parent_id: ItemId(
                    8
                ),
                kind: Type(
                    Type {
                        name: Some(
                            "B"
                        ),
                        layout: Some(
                            Layout {
                                size: 1,
                                align: 1,
                                packed: false
                            }
                        ),
                        kind: ResolvedTypeRef(
                            ItemId(
                                2
                            )
                        ),
                        is_const: false
                    }
                ),
                detect_derive_debug_cycle: Cell {
                    value: false
                },
                detect_derive_copy_cycle: Cell {
                    value: false
                }
            }
        },
        next_item_id: ItemId(
            10
        ),
        types: {
            USR(
                "c:@S@C"
            ): ItemId(
                8
            ),
            USR(
                "c:@S@A"
            ): ItemId(
                1
            ),
            USR(
                "c:@S@B"
            ): ItemId(
                2
            )
        },
        named_types: {},
        modules: {},
        root_module: ItemId(
            0
        ),
        current_module: ItemId(
            0
        ),
        currently_parsed_types: [],
        parsed_macros: {},
        replacements: {},
        collected_typerefs: true,
        gen_ctx: Some(
            GenContext { ... }
        ),
        span: Span { lo: BytePos(0), hi: BytePos(0), expn_id: ExpnId(4294967295) },
        index: Index { },
        translation_unit: TranslationUnit { },
        options: BindgenOptions {
            hidden_types: RegexSet {
                items: [],
                set: Some(
                    RegexSet([])
                )
            },
            opaque_types: RegexSet {
                items: [
                    "^B$"
                ],
                set: Some(
                    RegexSet(["^B$"])
                )
            },
            whitelisted_types: RegexSet {
                items: [
                    "^C$"
                ],
                set: Some(
                    RegexSet(["^C$"])
                )
            },
            whitelisted_functions: RegexSet {
                items: [],
                set: Some(
                    RegexSet([])
                )
            },
            whitelisted_vars: RegexSet {
                items: [],
                set: Some(
                    RegexSet([])
                )
            },
            bitfield_enums: RegexSet {
                items: [],
                set: Some(
                    RegexSet([])
                )
            },
            constified_enums: RegexSet {
                items: [],
                set: Some(
                    RegexSet([])
                )
            },
            constified_enum_modules: RegexSet {
                items: [],
                set: Some(
                    RegexSet([])
                )
            },
            builtins: false,
            links: [],
            emit_ast: false,
            emit_ir: false,
            emit_ir_graphviz: None,
            enable_cxx_namespaces: false,
            disable_name_namespacing: false,
            layout_tests: true,
            derive_debug: true,
            derive_default: false,
            unstable_rust: false,
            use_core: false,
            ctypes_prefix: None,
            namespaced_constants: true,
            msvc_mangling: false,
            convert_floats: true,
            raw_lines: [],
            clang_args: [
                "-x",
                "c++",
                "--std=c++11",
                "-isystem",
                "/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0",
                "-isystem",
                "/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0",
                "-isystem",
                "/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/backward",
                "-isystem",
                "/usr/local/include",
                "-isystem",
                "/usr/lib/llvm-3.8/bin/../lib/clang/3.8.0/include",
                "-isystem",
                "/usr/include/x86_64-linux-gnu",
                "-isystem",
                "/usr/include",
                "./pre_processed.hpp"
            ],
            input_header: Some(
                "./pre_processed.hpp"
            ),
            input_unsaved_files: [],
            dummy_uses: None,
            parse_callbacks: None,
            codegen_config: CodegenConfig {
                functions: true,
                types: true,
                vars: true,
                methods: true,
                constructors: true,
                destructors: true
            },
            conservative_inline_namespaces: true,
            generate_comments: true,
            generate_inline_functions: false,
            whitelist_recursively: true,
            objc_extern_crate: false,
            enable_mangling: true,
            prepend_enum_name: true
        },
        generated_bindegen_complex: Cell {
            value: false
        },
        used_template_parameters: Some(
            {
                ItemId(
                    9
                ): {},
                ItemId(
                    8
                ): {},
                ItemId(
                    0
                ): {},
                ItemId(
                    2
                ): {}
            }
        ),
        need_bitfield_allocation: [],
        needs_mangling_hack: false
    },
    comp: CompInfo {
        kind: Struct,
        fields: AfterComputingBitfieldUnits(
            [
                DataMember(
                    FieldData {
                        name: Some(
                            "some_type"
                        ),
                        ty: ItemId(
                            9
                        ),
                        comment: None,
                        annotations: Annotations {
                            opaque: false,
                            hide: false,
                            use_instead_of: None,
                            disallow_copy: false,
                            private_fields: None,
                            accessor_kind: None,
                            constify_enum_variant: false
                        },
                        bitfield: None,
                        mutable: false,
                        offset: Some(
                            0
                        )
                    }
                )
            ]
        ),
        template_params: [],
        methods: [],
        constructors: [],
        destructor: None,
        base_members: [],
        inner_types: [],
        inner_vars: [],
        has_vtable: false,
        has_destructor: false,
        has_nonempty_base: false,
        has_non_type_template_params: false,
        packed: false,
        found_unknown_attr: false,
        detect_derive_debug_cycle: Cell {
            value: false
        },
        detect_derive_default_cycle: Cell {
            value: false
        },
        detect_has_destructor_cycle: Cell {
            value: false
        },
        is_forward_declaration: false
    },
    latest_offset: 1,
    padding_count: 0,
    latest_field_layout: Some(
        Layout {
            size: 1,
            align: 1,
            packed: false
        }
    ),
    max_field_align: 1,
    last_field_was_bitfield: false
}
	layout = Layout {
    size: 1,
    align: 1,
    packed: false
}
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(9), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(8), kind: Type(Type { name: Some("B"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: ResolvedTypeRef(ItemId(2)), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(9), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(8), kind: Type(Type { name: Some("B"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: ResolvedTypeRef(ItemId(2)), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
/* automatically generated by rust-bindgen */

#[repr(C)]
#[derive(Debug, Copy)]
pub struct B {
    pub _bindgen_opaque_blob: u8,
}
#[test]
fn bindgen_test_layout_B() {
    assert_eq!(::std::mem::size_of::<B>() , 1usize , concat ! (
               "Size of: " , stringify ! ( B ) ));
    assert_eq! (::std::mem::align_of::<B>() , 1usize , concat ! (
                "Alignment of " , stringify ! ( B ) ));
}
extern "C" {
    #[link_name = "_ZN1B5m_fn1Ev"]
    pub fn B_m_fn1(this: *mut B) -> A;
}
impl Clone for B {
    fn clone(&self) -> Self { *self }
}
impl B {
    #[inline]
    pub unsafe fn m_fn1(&mut self) -> A { B_m_fn1(self) }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct C {
    pub some_type: B,
}
#[test]
fn bindgen_test_layout_C() {
    assert_eq!(::std::mem::size_of::<C>() , 1usize , concat ! (
               "Size of: " , stringify ! ( C ) ));
    assert_eq! (::std::mem::align_of::<C>() , 1usize , concat ! (
                "Alignment of " , stringify ! ( C ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const C ) ) . some_type as * const _ as usize }
                , 0usize , concat ! (
                "Alignment of field: " , stringify ! ( C ) , "::" , stringify
                ! ( some_type ) ));
}
impl Clone for C {
    fn clone(&self) -> Self { *self }
}
@cbourjau cbourjau changed the title Protected members in opaque c++ types Protected member functions in opaque c++ types Jul 12, 2017
@fitzgen
Copy link
Member

fitzgen commented Jul 12, 2017

Thanks for the bug report!

@fitzgen
Copy link
Member

fitzgen commented Jul 12, 2017

It seems to me that we shouldn't be generating B's methods if it is marked opaque.

@fitzgen
Copy link
Member

fitzgen commented Jul 12, 2017

Actually, I think it is desired to still generate an opaque types methods (care to confirm @emilio? at least, I know one person who was requesting this feature just yesterday, and I incorrectly told him that we didn't do it, but that it was possible).

Will fix the tracing code instead of removing the method bindings.

fitzgen added a commit to fitzgen/rust-bindgen that referenced this issue Jul 12, 2017
This makes tracing opaque types' edges match what we codegen for opaque
types. Although we still generate constructors, methods, etc for opaque
types (just not fields and base members) we were not tracing them.

Fixes rust-lang#807
fitzgen added a commit to fitzgen/rust-bindgen that referenced this issue Jul 12, 2017
This makes tracing opaque types' edges match what we codegen for opaque
types. Although we still generate constructors, methods, etc for opaque
types (just not fields and base members) we were not tracing them.

Fixes rust-lang#807
bors-servo pushed a commit that referenced this issue Jul 12, 2017
…enerated, r=emilio

Fix tracing of opaque types

This makes tracing opaque types' edges match what we codegen for opaque types. Although we still generate constructors, methods, etc for opaque types (just not fields and base members) we were not tracing them.

Fixes #807

This miiight be related to https://bugzilla.mozilla.org/show_bug.cgi?id=1366050 too.

r? @emilio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants