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

Richard Smith richard at metafoo.co.uk
Mon Aug 13 14:01:59 PDT 2012


According to the documentation I can find[1], multiple __asm constructs are
separate statements. In particular, the documentation suggests that here:

void f() {
  if (false)
    __asm mov eax, ebx
  __asm mov ebx, eax
}

the second __asm statement is not controlled by the 'if'. If the
documentation is correct, we currently misparse this.

[1] http://msdn.microsoft.com/en-us/library/45yd4tzz(v=vs.110).aspx

On Mon, Aug 13, 2012 at 1:36 PM, Chandler Carruth <chandlerc at google.com>wrote:

> 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. =]
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120813/5a091ece/attachment.html>


More information about the cfe-commits mailing list