[cfe-dev] Should we build semantically invalid nodes?

Argiris Kirtzidis akyrtzi at gmail.com
Thu Oct 23 13:31:56 PDT 2008

Doug Gregor wrote:
>> I think you underestimate the importance of being able to get a syntax tree
>> as complete as possible even on ill-formed code.
> Yep, that's likely. I think you underestimate the amount of pain that
> having invalid AST nodes will cause.

It's a sacrifice for the Greater Good(tm) ;)

>> There is certainly some middle ground to tread here, not all semantic checks
>> will wreak havoc if they allow the expression; I think it's a worthwhile
>> goal to strive to have an AST as complete as possible, it will be better in
>> the long run for interesting uses of Clang beyond compiling.
> If the AST node that is built is something that is valid for further
> semantic processing (even if it resulted in diagnostics), that's fine.
> So, if we're looking at Sebastian's casting patch, for example, I'm
> fine with generating an AST node for a reinterpret_cast that casts
> away constness, because the resulting expression is still usable for
> type-checking. Anything that requires a "this is an invalid
> expression" flag is, in my opinion, asking for trouble.

Ok, sounds fine!


More information about the cfe-dev mailing list