Skip to content

Filtering out builtins from --emit-clang-ast only half-works #571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fitzgen opened this issue Mar 9, 2017 · 3 comments · Fixed by #604
Closed

Filtering out builtins from --emit-clang-ast only half-works #571

fitzgen opened this issue Mar 9, 2017 · 3 comments · Fixed by #604

Comments

@fitzgen
Copy link
Member

fitzgen commented Mar 9, 2017

#566 only fixed half the situation it seems. When I run with --emit-clang-ast, the builtin types are only half-filtered:

(

 type.kind = Invalid
)
(

 type.kind = Invalid
)
(

 type.kind = Invalid
)
(

 type.kind = Invalid
)
(

 type.kind = Invalid
)
(

 type.kind = Invalid
)
(

 type.kind = Invalid
)

Etc...

We should finish the job and not even print those shells out. @tsliang, want to finish this?

@fitzgen
Copy link
Member Author

fitzgen commented Mar 9, 2017

I think the check needs to be earlier.

@tsliang
Copy link

tsliang commented Mar 13, 2017

@fitzgen can do! It seems that the easiest thing to do would be to simply move the short-circuit in print_type (line 1559:1561) above the call to print_indent (line 1558). Alternatively, could we move both of these checks to ast_dump itself? There's no way that a builtin would have children that would need to be dumped, right?

@fitzgen
Copy link
Member Author

fitzgen commented Mar 13, 2017

Alternatively, could we move both of these checks to ast_dump itself?

This sounds pretty good to me. The only concern is that if someone explicitly calls ast_dump(some_builtin, 0) then they should get the dump for it.

One sorta hacky way to do this would be to check the indent level and whether it is zero or not. The other way would be to make ast_dump always dump the builtins and filter the builtins before we call ast_dump in the parse function in src/lib.rs:

    if context.options().emit_ast {
        cursor.visit(|cur| clang::ast_dump(&cur, 0)); // <---- add filtering here
    }

I like the latter idea.

There's no way that a builtin would have children that would need to be dumped, right?

Not AFAIK

tsliang pushed a commit to tsliang/rust-bindgen that referenced this issue Mar 30, 2017
tsliang pushed a commit to tsliang/rust-bindgen that referenced this issue Mar 31, 2017
bors-servo pushed a commit that referenced this issue Mar 31, 2017
This should resolve #571. As discussed with @fitzgen I have moved the builtin-filtering out of `ast_dump` itself; this logic now happens at the point of call in `src/lib.rs`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants