diff options
-rw-r--r-- | src/clang.rs | 9 | ||||
-rw-r--r-- | src/lib.rs | 7 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/clang.rs b/src/clang.rs index b8086d99..fc7950dc 100644 --- a/src/clang.rs +++ b/src/clang.rs @@ -77,6 +77,12 @@ impl Cursor { } } + /// Returns whether the cursor refers to a built-in definition. + pub fn is_builtin(&self) -> bool { + let (file, _, _, _) = self.location().location(); + file.name().is_none() + } + /// Get the `Cursor` for this cursor's referent's lexical parent. /// /// The lexical parent is the parent of the definition. The semantic parent @@ -1445,6 +1451,9 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult { } fn print_cursor<S: AsRef<str>>(depth: isize, prefix: S, c: &Cursor) { + if c.is_builtin() { + return; + } let prefix = prefix.as_ref(); print_indent(depth, format!(" {}kind = {}", prefix, kind_to_str(c.kind()))); @@ -826,12 +826,7 @@ impl<'ctx> Bindings<'ctx> { /// Determines whether the given cursor is in any of the files matched by the /// options. fn filter_builtins(ctx: &BindgenContext, cursor: &clang::Cursor) -> bool { - let (file, _, _, _) = cursor.location().location(); - - match file.name() { - None => ctx.options().builtins, - Some(..) => true, - } + ctx.options().builtins || !cursor.is_builtin() } /// Parse one `Item` from the Clang cursor. |