Skip to content
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

Provide a dependency analysis mechanism for emitting only required includes #14

Closed
esseks opened this issue Dec 5, 2014 · 2 comments
Closed
Assignees

Comments

@esseks
Copy link
Owner

esseks commented Dec 5, 2014

As per the title. For instance, if assert() is never used in the program, then:

#include <cassert>

should not be emitted.

@esseks esseks self-assigned this Dec 5, 2014
@massix
Copy link

massix commented Dec 8, 2014

My guess is that we could be able to do it by analyzing the AST built from Clang (cr #17) and emitting the dependencies of the module.
The idea is that we begin by including everything, then we parse the dependencies and we remove what is unnecessary, unluckily we have to include everything first, otherwise the libclang will refuse to compile.

Otherwise we can just do something static and analyze the keywords emitted by the Nodes, easier to implement.

@esseks
Copy link
Owner Author

esseks commented Dec 8, 2014

An easier strategy could be keeping a set of requirements at Program level and pushing new Module objects to it from semantic rules at parse time. For instance, every time an assert_stmt is parsed, the semantic rule could contain:

program.addModule(Module("cassert"));

esseks added a commit that referenced this issue Dec 10, 2014
@esseks esseks closed this as completed Feb 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants