[cfe-dev] Feeding a CompilerInstance with raw data, not a file

Denis Steckelmacher steckdenis at yahoo.fr
Fri Apr 29 01:38:48 PDT 2011


Hello,

I'm a belgian student, and my participation to the Google Summer of Code was 
accepted. My project is to implement an Open Source OpenCL compiler.

I looked at Clang and saw it is used by Apple and nVidia for their own OpenCL 
implementations. Clang also has a fairly good support of the OpenCL C subset, 
that can be tried out by using "clang -x cl ...". I will also use it for my 
work.

I'll base my OpenCL library on Mesa's Clover, which also uses Clang, but is 
far from being usable. When I looked at the code, I read this :

static void
setupFrontendOpts(FrontendOptions &opts, const std::string &fileLoc)
{
   opts.ProgramAction = frontend::EmitLLVMOnly;
   opts.DisableFree = true;

   /* XXX HACK
    * just matches whatever garbage Compiler::prepareInput
    * creates */
   opts.Inputs.push_back(
      std::make_pair(IK_OpenCL, fileLoc));
}

Clover writes the code given by the application to a file, and then passes 
this file to Clang. This solution can work for simple cases, but it's not very 
elegant.

So I am asking for a way to avoid writing the source code given by the 
application to a temporary file, that is then read by Clang. I quickly looked 
at the CompilerInstance class and its related classes, but I haven't found 
anything. 

Thanks for your help, and sorry if I'm not at the right place to ask my 
questions.

Best regards,
Denis Steckelmacher.



More information about the cfe-dev mailing list