[cfe-dev] Driver support for AST features (UI Proposal)

Fariborz Jahanian fjahanian at apple.com
Tue Sep 1 08:15:42 PDT 2009

On Aug 31, 2009, at 10:51 PM, Daniel Dunbar wrote:

> Hi all,
> This is a UI design proposal for the clang driver for providing user /
> tool access to clang AST based features.
> 1. Support '-emit-ast'; this will be an option like '-S' in that it
> stops compilation at the AST production phase, and will generate files
> with a '.ast' suffix.
> 2. Recognize '.ast' files as source inputs which can be compiled.
> Obviously this will start at the compilation phase, in the same way
> that '.i' etc inputs bypass the preprocessing phase.
>    a. clang will call clang with an explicit argument telling it to
clang will call clang-cc ?
> compile from .ast (-compile-ast) instead of -S.
>    b. The compile-ast action will skip passing preprocessing specific
> options to clang (but still pass options used by the code generator).

Shouldn't the option for back-end be stored in the AST node during - 
phase? This helps, among other things with language specific issues,  
and maybe
for debug info. (if we chose to putout additional ASTs for such  
Also, the compiler rev number would be a plus to prevent nasty bugs.

- fariborz

> Eventually we will probably also want a feature '-write-ast' (or so)
> which will output an AST while doing other things (like compiling),
> but that is not part of this proposal.
> One salient design point is that the default suffix for AST files is
> '.ast', which does not indicate the source language. This means the
> driver won't be able to make decisions about things like code
> generator options based on its language. I'm not sure yet if this
> matters. If it did we would either (a) have to poke the .ast to figure
> out its language, or (b) use -x with new options like c++-ast etc
> (like for preprocessed inputs) and optionally use suffixes like
> '.c-ast', '.cpp-ast', etc.
> Comments?
> A patch following this design is attached. The compile-ast option is
> not implemented in clang, and I don't know exactly what model we want
> for compile options passed to an ast -> .s compile step (most of them
> are backed in the .ast, but not all of them).
> - Daniel
> <0001-Initial-emit-ast- 
> support.patch>_______________________________________________
> 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