[cfe-dev] Compile a string?

Eric Christopher echristo at apple.com
Sat Jun 19 12:48:33 PDT 2010


On Jun 19, 2010, at 5:22 AM, Daniel Waterworth wrote:

> Sorry, what I mean is I've trying to make/find a function like this:
> 
> Module *compile_string(const char *source)
> 
> that could be used like this:
> 
> Module *m = compile_string("int function(int a, int b) { return a + b; }");
> 
> I hope that makes things clearer. Does such a function exist within
> clang, or will I have to setup the components to do that? As far as I
> can tell, I'll have to use a Preprocessor to start with, but how do I
> then generate the AST in order to lower to LLVM's IR.

Aaah.  Entirely differently.  I'd look through the clang driver for ideas
on how to generate a module based on incoming C code (this is C
code yes?). 

-eric



More information about the cfe-dev mailing list