<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Aug 14, 2013, at 4:52 AM, Pavel Labath <<a href="mailto:labath@google.com">labath@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On 14 August 2013 12:47, Abramo Bagnara <span dir="ltr"><<a href="mailto:abramo.bagnara@bugseng.com" target="_blank">abramo.bagnara@bugseng.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Il 14/08/2013 12:33, Pavel Labath ha scritto:<br>
<div class="im">><br>
><br>
>> Could you please elaborate on that? I'm not sure what you mean by<br></div><div><div class="h5">
> repeated initializers. Do you know of a situation where an AST node can<br>
> be present in the tree twice?<br>
><br>
</div></div>$ cat p.c<br>
void f() {<br>
int a[10] = {[1 ... 8] = 2};<br>
}<br>
$ clang -cc1 -ast-dump p.c<br>
TranslationUnitDecl 0x54ae6e0 <<invalid sloc>><br>
|-TypedefDecl 0x54aebc0 <<invalid sloc>> __int128_t '__int128'<br>
|-TypedefDecl 0x54aec20 <<invalid sloc>> __uint128_t 'unsigned __int128'<br>
|-TypedefDecl 0x54aef70 <<invalid sloc>> __builtin_va_list<br>
'__va_list_tag [1]'<br>
`-FunctionDecl 0x54af010 <p.c:1:1, line:3:1> f 'void ()'<br>
`-CompoundStmt 0x54af330 <line:1:10, line:3:1><br>
`-DeclStmt 0x54af318 <line:2:3, col:30><br>
`-VarDecl 0x54af130 <col:3, col:29> a 'int [10]'<br>
`-InitListExpr 0x54af280 <col:15, col:29> 'int [10]'<br>
|-ImplicitValueInitExpr 0x54af308 <<invalid sloc>> 'int'<br>
|-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
|-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
|-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
|-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
|-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
|-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
|-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
`-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
<br></blockquote><div><div><br class="">Wow.. I didn't even know such syntax exists. This is a nice example, thanks.</div><div><br></div><div>Right now, the static analyzer seems to get this code right (which is quite surprising, since even the compiler does not support this right now), but as soon as I replace 2 by something more complicated (a function call), it stops for some reason, which I didn't investigate yet. But in any case, the analyzers approach to this is wrong, as it tries to evaluate the expression multiple times, which, I guess, it shouldn't (gcc doesn't).</div>
</div><div><br></div><div>Since the compiler doesn't support this yet, I guess this is not such an important issue yet, but it's definitely a thing to keep an eye on.</div></div></div></div></blockquote><div><br></div>It’s a GNU extension that isn’t used all that often.</div><div><br><blockquote type="cite" dir="auto"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Soon or later I personally hope that such node replication will<br>
disappear, but currently we have it and I don't know if there is the<br>
intention to get rid of it.<br><br></blockquote><div><br></div><div>I think I would also prefer a different AST representation of the above code, because the current one gives the impression that the RHS expression is to be evaluated multiple times.</div>
</div></div></div></blockquote><br></div><div>Right. This is a non-trivial refactoring of the AST to introduce either some kind of run-length encoding for repeated expressions or additional uses of OpaqueValueExprs.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>- Doug</div><div><br></div><br></body></html>