Clang Library

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Clang Library

Glenn R. Martin
I am currently working on a personal project that would use on demand compilation of C code to load in new modules. I have been looking at clang and llvm and it seems like it has the capability to provide this ability. Is there anywhere i can look to see how i would be able to accomplish this programmatically? I have gone through the documentation on the Clang site as well as downloading and reviewing the source code from SVN. I have not seen anything directly on accessing the C preprocessing/compiler functionality programmatically.

Thanks.

Glenn R. Martin


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang Library

Charles Davis-3
Glenn R. Martin wrote:
> I am currently working on a personal project that would use on demand
> compilation of C code to load in new modules. I have been looking at
> clang and llvm and it seems like it has the capability to provide this
> ability. Is there anywhere i can look to see how i would be able to
> accomplish this programmatically? I have gone through the documentation
> on the Clang site as well as downloading and reviewing the source code
> from SVN. I have not seen anything directly on accessing the C
> preprocessing/compiler functionality programmatically.
There's several different objects you need to look into creating:

- Preprocessing is handled by a Preprocessor object.
- If you want to compile C code, you need to create an ASTContext (in
addition to a Preprocessor).
- The Sema (SEMAntic analyzer) object handles semantic checking, etc.
- The CodeGen library turns a fully-annotated AST into LLVM IR, which
you can then pass to LLVM libraries (like LLVM CodeGen and the Target
family) to generate executable code.
- The Frontend library handles much of the tedious process of setting up
these objects for you. In particular, look into the "CompilerInvocation"
and "CompilerInstance" classes.

HTH

Chip
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang Library

Glenn R. Martin
On 16 Feb 2010, at 19:23 , Charles Davis wrote:
There's several different objects you need to look into creating:

- Preprocessing is handled by a Preprocessor object.
- If you want to compile C code, you need to create an ASTContext (in
addition to a Preprocessor).
- The Sema (SEMAntic analyzer) object handles semantic checking, etc.
- The CodeGen library turns a fully-annotated AST into LLVM IR, which
you can then pass to LLVM libraries (like LLVM CodeGen and the Target
family) to generate executable code.
- The Frontend library handles much of the tedious process of setting up
these objects for you. In particular, look into the "CompilerInvocation"
and "CompilerInstance" classes.

HTH

Chip

Chip,
Thank you for the insight. I shall look in to it shortly.


                                                                          

Glenn R. Martin

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang Library

Jean-Daniel Dupas-2

Le 17 févr. 2010 à 01:57, Glenn R. Martin a écrit :

> On 16 Feb 2010, at 19:23 , Charles Davis wrote:
>> There's several different objects you need to look into creating:
>>
>> - Preprocessing is handled by a Preprocessor object.
>> - If you want to compile C code, you need to create an ASTContext (in
>> addition to a Preprocessor).
>> - The Sema (SEMAntic analyzer) object handles semantic checking, etc.
>> - The CodeGen library turns a fully-annotated AST into LLVM IR, which
>> you can then pass to LLVM libraries (like LLVM CodeGen and the Target
>> family) to generate executable code.
>> - The Frontend library handles much of the tedious process of setting up
>> these objects for you. In particular, look into the "CompilerInvocation"
>> and "CompilerInstance" classes.
>>
>> HTH
>>
>> Chip
>
> Chip,
> Thank you for the insight. I shall look in to it shortly.
>

And you may also have a look at lib/Driver. It contains the code that take care of all of this when you use the command line clang tool.

-- Jean-Daniel





_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev