diff options
-rw-r--r-- | src/clang.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/clang.rs b/src/clang.rs index ffe9d5d0..a2b4ee0f 100644 --- a/src/clang.rs +++ b/src/clang.rs @@ -69,7 +69,11 @@ impl Cursor { /// Get the mangled name of this cursor's referent. pub fn mangling(&self) -> String { - unsafe { cxstring_into_string(clang_Cursor_getMangling(self.x)) } + if clang_Cursor_getMangling::is_loaded() { + unsafe { cxstring_into_string(clang_Cursor_getMangling(self.x)) } + } else { + self.spelling() + } } /// Get the `Cursor` for this cursor's referent's lexical parent. @@ -448,7 +452,11 @@ impl Cursor { /// Get the visibility of this cursor's referent. pub fn visibility(&self) -> CXVisibilityKind { - unsafe { clang_getCursorVisibility(self.x) } + if clang_getCursorVisibility::is_loaded() { + unsafe { clang_getCursorVisibility(self.x) } + } else { + CXVisibility_Default + } } /// Given that this cursor's referent is a function, return cursors to its @@ -496,11 +504,16 @@ impl Cursor { /// Is this cursor's referent a field declaration that is marked as /// `mutable`? pub fn is_mutable_field(&self) -> bool { + clang_CXXField_isMutable::is_loaded() && unsafe { clang_CXXField_isMutable(self.x) != 0 } } /// Get the offset of the field represented by the Cursor. pub fn offset_of_field(&self) -> Result<usize, LayoutError> { + if !clang_Cursor_getOffsetOfField::is_loaded() { + return Err(LayoutError::from(-1)); + } + let offset = unsafe { clang_Cursor_getOffsetOfField(self.x) }; if offset < 0 { |