From c65dd923c23d3b0a1d5558fcd16a387c21ffde45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Duquette?= Date: Fri, 17 Aug 2018 00:06:51 -0400 Subject: [PATCH] Change a call to add_item that was passing a NullCursor. --- src/clang.rs | 7 ------- src/ir/context.rs | 3 ++- src/ir/item.rs | 2 +- src/ir/ty.rs | 8 ++++++++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/clang.rs b/src/clang.rs index eefc7cf1a0..bac29ee343 100644 --- a/src/clang.rs +++ b/src/clang.rs @@ -50,13 +50,6 @@ impl Cursor { unsafe { clang_isDeclaration(self.kind()) != 0 } } - /// Get the null cursor, which has no referent. - pub fn null() -> Self { - Cursor { - x: unsafe { clang_getNullCursor() }, - } - } - /// Get this cursor's referent's spelling. pub fn spelling(&self) -> String { unsafe { cxstring_into_string(clang_getCursorSpelling(self.x)) } diff --git a/src/ir/context.rs b/src/ir/context.rs index ee15bcf544..bd353a5f1f 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -686,7 +686,8 @@ If you encounter an error missing from this list, please file an issue or a PR!" debug_assert!( declaration.is_some() || !item.kind().is_type() || item.kind().expect_type().is_builtin_or_type_param() || - item.kind().expect_type().is_opaque(self, &item), + item.kind().expect_type().is_opaque(self, &item) || + item.kind().expect_type().is_unresolved_ref(), "Adding a type without declaration?" ); diff --git a/src/ir/item.rs b/src/ir/item.rs index 75638ff3ca..a7ced3d0e0 100644 --- a/src/ir/item.rs +++ b/src/ir/item.rs @@ -1409,7 +1409,7 @@ impl ClangItemParser for Item { parent_id.unwrap_or(current_module.into()), ItemKind::Type(Type::new(None, None, kind, is_const)), ), - Some(clang::Cursor::null()), + None, None, ); potential_id.as_type_id_unchecked() diff --git a/src/ir/ty.rs b/src/ir/ty.rs index 9cc097d4ec..ab39c19a0b 100644 --- a/src/ir/ty.rs +++ b/src/ir/ty.rs @@ -216,6 +216,14 @@ impl Type { } } + /// Is this an unresolved reference? + pub fn is_unresolved_ref(&self) -> bool { + match self.kind { + TypeKind::UnresolvedTypeRef(_, _, _) => true, + _ => false, + } + } + /// Is this a incomplete array type? pub fn is_incomplete_array(&self, ctx: &BindgenContext) -> Option { match self.kind {