Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] CDT as a Standalone API

Well, if you look at that from the C++ compiler perspective (Clang is a C++ compiler, first and foremost), it is quite understandable.

An overly simplified helicopter view:
Preprocessor takes characters stream on input and produces preprocessor tokens stream on output. Preprocessor is very "anarchic": sequences of tokens produced by preprocessor statements and macro expansions don't have to correspond to well-formed subtrees in AST. 
Parser consumes preprocessor token streams and produces ASTs.

Of cause, there are some back annotations (e.g., you can determine the whole macro expansion hierarchy or an include location hierarchy for a particular source location). As a compiler, Clang needs to know just enough to produce readable diagnostics.
There are some little hacks here and there (most likely for XCode) - e.g., comment to declaration matching mentioned above. But no special magic for more complex preprocessor statements <-> AST relations.

On Wed, Oct 29, 2014 at 7:06 PM, Nathan Ridge <zeratul976@xxxxxxxxxxx> wrote:
> Clang doesn't represent preprocessor statements in AST.

I stand corrected (and surprised).


cdt-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top