Skip to content
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
5 changes: 4 additions & 1 deletion src/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ impl Cursor {
/// Return the number of template arguments used by this cursor's referent,
/// if the referent is either a template specialization or
/// declaration. Returns -1 otherwise.
///
/// NOTE: This may not return `Some` for some non-fully specialized
/// templates, see #193 and #194.
pub fn num_template_args(&self) -> Option<u32> {
let n: c_int = unsafe { clang_Cursor_getNumTemplateArguments(self.x) };

Expand Down Expand Up @@ -193,7 +196,7 @@ impl Cursor {
/// Is the referent a fully specialized template specialization without any
/// remaining free template arguments?
pub fn is_fully_specialized_template(&self) -> bool {
self.is_template() && self.num_template_args().unwrap() > 0
self.is_template() && self.num_template_args().unwrap_or(0) > 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave a TODO comment with a reference to the issue that @bholley filed?

}

/// Is the referent a template specialization that still has remaining free
Expand Down
19 changes: 19 additions & 0 deletions tests/expectations/base-to-derived.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]


#[repr(C)]
#[derive(Debug, Copy)]
pub struct false_type {
pub _address: u8,
}
#[test]
fn bindgen_test_layout_false_type() {
assert_eq!(::std::mem::size_of::<false_type>() , 1usize);
assert_eq!(::std::mem::align_of::<false_type>() , 1usize);
}
impl Clone for false_type {
fn clone(&self) -> Self { *self }
}
19 changes: 19 additions & 0 deletions tests/headers/base-to-derived.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// bindgen-flags: -- -std=c++11

struct false_type {};

template<typename _From, typename _To, bool>
struct __is_base_to_derived_ref;

template<typename _From, typename _To>
struct __is_base_to_derived_ref<_From, _To, true>
{
typedef _To type;

static constexpr bool value = type::value;
};

template<typename _From, typename _To>
struct __is_base_to_derived_ref<_From, _To, false>
: public false_type
{ };