[cfe-dev] Using Clang AST classes to generate LLVM IR for a compiler front-end

Douglas Gregor dgregor at apple.com
Tue Dec 25 14:16:59 PST 2012


On Dec 24, 2012, at 2:50 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:

> On Mon, Dec 24, 2012 at 9:31 PM, Sean Silva <silvas at purdue.edu> wrote:
>>> So my question is: Would it be worth the trouble to learn and use the Clang
>>> AST library so that my font-end can use it, and would it be a good option
>>> for the future?
>> 
>> In short: it probably won't be worth your effort. Clang's AST is
>> extremely complicated (reflective of the complexity of C++).
> 
> I agree.  But it is a good idea to look briefly at Clang architecture
> and copy it as much as makes sense for your project.  You can even
> take whole classes like SourceManager/SourceLocation or diagnostics
> infrastructure (after decoupling from preprocessor since you don't
> have one), or use LLVM's ADT library.

If you want a source manager and diagnostic engine, but don't need a C preprocessor, use LLVM's SourceMgr. It's far simpler. 

> Dmitri
> 
> -- 
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list