diff options
-rwxr-xr-x | src/clang.rs | 9 | ||||
-rw-r--r-- | src/ir/function.rs | 3 | ||||
-rw-r--r-- | src/ir/ty.rs | 2 |
3 files changed, 9 insertions, 5 deletions
diff --git a/src/clang.rs b/src/clang.rs index c0934055..543c52a9 100755 --- a/src/clang.rs +++ b/src/clang.rs @@ -714,9 +714,12 @@ impl Type { /// Given that this type is a function type, get the type of its return /// value. - pub fn ret_type(&self) -> Type { - unsafe { - Type { x: clang_getResultType(self.x) } + pub fn ret_type(&self) -> Option<Type> { + let rt = Type { x: unsafe { clang_getResultType(self.x) } }; + if rt.kind() == CXType_Invalid { + None + } else { + Some(rt) } } diff --git a/src/ir/function.rs b/src/ir/function.rs index 2693eddf..0cf23f43 100644 --- a/src/ir/function.rs +++ b/src/ir/function.rs @@ -186,7 +186,8 @@ impl FunctionSig { } } - let ret = try!(Item::from_ty(&ty.ret_type(), None, None, ctx)); + let ty_ret_type = try!(ty.ret_type().ok_or(ParseError::Continue)); + let ret = try!(Item::from_ty(&ty_ret_type, None, None, ctx)); let abi = get_abi(ty.call_conv()); Ok(Self::new(ret, args, ty.is_variadic(), abi)) diff --git a/src/ir/ty.rs b/src/ir/ty.rs index bbb666bc..7c640f30 100644 --- a/src/ir/ty.rs +++ b/src/ir/ty.rs @@ -499,7 +499,7 @@ impl Type { // tests/headers/func_ptr_in_struct.h), so we do a // guess here trying to see if it has a valid return // type. - if ty.ret_type().kind() != CXType_Invalid { + if ty.ret_type().is_some() { let signature = try!(FunctionSig::from_ty(ty, &location.unwrap_or(cursor), ctx)); TypeKind::Function(signature) |