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

steve naroff snaroff at apple.com
Tue Sep 1 08:14:01 PDT 2009


On Sep 1, 2009, at 1:51 AM, 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
> 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).
>
> 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?

This looks great.

I much prefer (a), poking the .ast. From my perspective, it's simpler  
and less error-prone.

snaroff

>
> 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