From 91f279f735e3501cd738e4bff0371b41a830410c Mon Sep 17 00:00:00 2001 From: Emilio Cobos Álvarez Date: Mon, 21 Nov 2016 10:19:05 +0100 Subject: ir: Pass the location instead of the declaration for TemplateRef's. --- libbindgen/src/ir/ty.rs | 19 +++++++++++++------ .../tests/expectations/tests/templateref_opaque.rs | 20 ++++++++++++++++++++ libbindgen/tests/headers/templateref_opaque.hpp | 11 +++++++++++ 3 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 libbindgen/tests/expectations/tests/templateref_opaque.rs create mode 100644 libbindgen/tests/headers/templateref_opaque.hpp diff --git a/libbindgen/src/ir/ty.rs b/libbindgen/src/ir/ty.rs index 1980b088..1e4c40ef 100644 --- a/libbindgen/src/ir/ty.rs +++ b/libbindgen/src/ir/ty.rs @@ -685,26 +685,33 @@ impl Type { CXCursor_TemplateRef => { let referenced = location.referenced().unwrap(); let referenced_ty = referenced.cur_type(); - let referenced_declaration = - Some(referenced_ty.declaration()); + + debug!("TemplateRef {:?} {:?} {:?}", + location, + referenced, + referenced_ty); return Self::from_clang_ty(potential_id, &referenced_ty, - referenced_declaration, + Some(referenced), parent_id, ctx); } CXCursor_TypeRef => { let referenced = location.referenced().unwrap(); let referenced_ty = referenced.cur_type(); - let referenced_declaration = - Some(referenced_ty.declaration()); + let declaration = referenced_ty.declaration(); + + debug!("TypeRef {:?} {:?} {:?}", + location, + referenced, + referenced_ty); let item = Item::from_ty_or_ref_with_id( potential_id, referenced_ty, - referenced_declaration, + Some(declaration), parent_id, ctx); return Ok(ParseResult::AlreadyResolved(item)); diff --git a/libbindgen/tests/expectations/tests/templateref_opaque.rs b/libbindgen/tests/expectations/tests/templateref_opaque.rs new file mode 100644 index 00000000..d69254c8 --- /dev/null +++ b/libbindgen/tests/expectations/tests/templateref_opaque.rs @@ -0,0 +1,20 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct detail_PointerType { + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData, +} +pub type detail_PointerType_Type = *mut T; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct UniquePtr { + pub _address: u8, + pub _phantom_0: ::std::marker::PhantomData, +} +pub type UniquePtr_Pointer = detail_PointerType; diff --git a/libbindgen/tests/headers/templateref_opaque.hpp b/libbindgen/tests/headers/templateref_opaque.hpp new file mode 100644 index 00000000..ca154c34 --- /dev/null +++ b/libbindgen/tests/headers/templateref_opaque.hpp @@ -0,0 +1,11 @@ + +namespace detail { +template +struct PointerType { + typedef T* Type; +}; +} +template +class UniquePtr { + typedef typename detail::PointerType Pointer; +}; -- cgit v1.2.3