[cfe-commits] r161703 - in /cfe/trunk: include/clang/AST/Stmt.h lib/AST/Stmt.cpp

Chandler Carruth chandlerc at google.com
Mon Aug 13 13:36:06 PDT 2012


Just to explain perhaps a bit more, as I too agree with Eli and Chad here...

On Mon, Aug 13, 2012 at 4:36 AM, João Matos <ripzonetriton at gmail.com> wrote:

> I agree, it would be best to store one node per statement in the AST, even
> if semantically they will be handled as one.
>

This is a pretty fundamental deviation from the model for the AST.

We have AST nodes to represent the structural semantics of the program.
Many of these do not even correspond to syntax in the source program. They
are there to expose the underlying semantics of the structure after parsing
has taken place. The inverse applies here: even though there may be syntax
recognized by the parser that resembles that of multiple statements, if the
actual semantic model is that of a single statement, the AST should reflect
that.

When you say "It would be best to store one node per statement in the AST"
you are begging the question by assuming there are multiple statements in
the source program. I think what Eli and Chad are arguing is that there is
exactly one node per statement in the AST, and all of the inline asm
instructions are part of a single statement due to their semantic model.

None of this should preclude us exposing source locations and other
information about the syntax used to spell the collection of assembly
instructions that goes into the statement. We have more tools available
than just Stmt nodes in the AST. =]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120813/1fa3a997/attachment.html>


More information about the cfe-commits mailing list