diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-02-08 14:18:29 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-08 14:18:29 -0800 |
commit | ac4732079f5a15b028e4d9d15fe51574e9b4536e (patch) | |
tree | cda007a8213c10a9db58dfdf8f4992c0bbeef2e7 | |
parent | 041ee54ca264c132a882ae95e518382ede2e7a74 (diff) | |
parent | 51c3ac628fd96ded822f12a60f3940bbff205564 (diff) |
Auto merge of #498 - pornel:clang35, r=emilio
Clang 3.5 support
Fixes #496
-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 { |