|
We've been mostly interested in JIT compilation, rather than source- code analysis, and part of the current work is finding out what is the most natural fit for a binding to Clang (its API isn't as amenable to binding as LLVM's is), and part of it is dealing with the complexities of translating includes, defines, target machine details and other typical compiler command-line flags into a form suitable for a JIT compiler in a dynamic library...
You could include a header and inspect the functions and struct definitions, including offsets and so on. Though you might have to instantiate some dummy stub to force the declarations in your module's IR; unless at some point we start binding clang's lexer/AST directly. Given the recent discussion of parsing large header files to auto- generate bindings, perhaps this wouldn't be a bad idea at all...
On Jan 1, 2010, at 2:05 AM, Florian Weimer wrote:
* Graham Wakefield:We've been mucking around with bindings to LLVM/clang to achieve runtime codegen of structs, functions and FFI into existing libraries from within Lua scripts,I guess the clang interface is still useful for obtaining C structs from include files and calculating the offsets of members (which isn't entirely straightforward). Perhaps you can make it available in some form?