Skip to content

Commit 3e2566d

Browse files
kulpemilio
authored andcommitted
Remove obsoleted is_loaded checks
It is not clear what version of libclang these supported. Refer to #1321, #1304, #916, #915.
1 parent 03dbd1a commit 3e2566d

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

src/clang.rs

+2-21
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ impl Cursor {
7070

7171
/// Get the mangled name of this cursor's referent.
7272
pub fn mangling(&self) -> String {
73-
if clang_Cursor_getMangling::is_loaded() {
74-
unsafe { cxstring_into_string(clang_Cursor_getMangling(self.x)) }
75-
} else {
76-
self.spelling()
77-
}
73+
unsafe { cxstring_into_string(clang_Cursor_getMangling(self.x)) }
7874
}
7975

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

633629
/// Get the offset of the field represented by the Cursor.
634630
pub fn offset_of_field(&self) -> Result<usize, LayoutError> {
635-
if !clang_Cursor_getOffsetOfField::is_loaded() {
636-
return Err(LayoutError::from(-1));
637-
}
638-
639631
let offset = unsafe { clang_Cursor_getOffsetOfField(self.x) };
640632

641633
if offset < 0 {
@@ -1102,13 +1094,6 @@ impl Type {
11021094
/// Get the number of template arguments this type has, or `None` if it is
11031095
/// not some kind of template.
11041096
pub fn num_template_args(&self) -> Option<u32> {
1105-
// If an old libclang is loaded, we have no hope of answering this
1106-
// question correctly. However, that's no reason to panic when
1107-
// generating bindings for simple C headers with an old libclang.
1108-
if !clang_Type_getNumTemplateArguments::is_loaded() {
1109-
return None;
1110-
}
1111-
11121097
let n = unsafe { clang_Type_getNumTemplateArguments(self.x) };
11131098
if n >= 0 {
11141099
Some(n as u32)
@@ -1848,11 +1833,7 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
18481833
format!(" {}spelling = \"{}\"", prefix, ty.spelling()),
18491834
);
18501835
let num_template_args =
1851-
if clang_Type_getNumTemplateArguments::is_loaded() {
1852-
unsafe { clang_Type_getNumTemplateArguments(ty.x) }
1853-
} else {
1854-
-1
1855-
};
1836+
unsafe { clang_Type_getNumTemplateArguments(ty.x) };
18561837
if num_template_args >= 0 {
18571838
print_indent(
18581839
depth,

0 commit comments

Comments
 (0)