Skip to content

Commit

Permalink
Remove obsoleted is_loaded checks
Browse files Browse the repository at this point in the history
It is not clear what version of libclang these supported.

Refer to #1321, #1304, #916, #915.
  • Loading branch information
kulp committed Jul 17, 2020
1 parent 5f35974 commit c30b753
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions src/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ impl Cursor {

/// Get the mangled name of this cursor's referent.
pub fn mangling(&self) -> String {
if clang_Cursor_getMangling::is_loaded() {
unsafe { cxstring_into_string(clang_Cursor_getMangling(self.x)) }
} else {
self.spelling()
}
unsafe { cxstring_into_string(clang_Cursor_getMangling(self.x)) }
}

/// Gets the C++ manglings for this cursor, or an error if the manglings
Expand Down Expand Up @@ -632,10 +628,6 @@ impl Cursor {

/// 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 {
Expand Down Expand Up @@ -1102,13 +1094,6 @@ impl Type {
/// Get the number of template arguments this type has, or `None` if it is
/// not some kind of template.
pub fn num_template_args(&self) -> Option<u32> {
// If an old libclang is loaded, we have no hope of answering this
// question correctly. However, that's no reason to panic when
// generating bindings for simple C headers with an old libclang.
if !clang_Type_getNumTemplateArguments::is_loaded() {
return None;
}

let n = unsafe { clang_Type_getNumTemplateArguments(self.x) };
if n >= 0 {
Some(n as u32)
Expand Down Expand Up @@ -1848,11 +1833,7 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
format!(" {}spelling = \"{}\"", prefix, ty.spelling()),
);
let num_template_args =
if clang_Type_getNumTemplateArguments::is_loaded() {
unsafe { clang_Type_getNumTemplateArguments(ty.x) }
} else {
-1
};
unsafe { clang_Type_getNumTemplateArguments(ty.x) };
if num_template_args >= 0 {
print_indent(
depth,
Expand Down

0 comments on commit c30b753

Please sign in to comment.