<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jan 28, 2013, at 18:43 , Anna Zaks <<a href="mailto:ganna@apple.com">ganna@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br>On Jan 24, 2013, at 5:35 PM, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:<br><br>+    // Note that we have to be careful here because constructors embedded<br>+    // in DeclStmts are not marked as lvalues.<br>+    if (!E->isGLValue())<br>+      if (const MemRegion *MR = ThisV.getAsRegion())<br>+        if (isa<CXXTempObjectRegion>(MR))<br>I do not fully understand what the comment means and why the test for CXXTempObjectRegion is needed (if I comment it out all tests pass). So maybe better comment and more tests?<br></blockquote></div><br><div>The first line of the comment is "If the constructed object is a prvalue, get its bindings", meaning that the rvalue representation of a struct is its bindings rather than a region. I'll change the comment, though, to say "If the constructed object is a <b>temporary</b> prvalue, get its bindings."</div><div><br></div><div>The reason all the tests pass with the CXXTempObjectRegion test commented out is because then a statement like this:</div><div><br></div><div>IntWrapper w(3);</div><div><br></div><div>will turn into</div><div><br></div><div>- Construct '3' in 'w'.</div><div>- Set the bindings of 'w' as the "return value" of the constructor.</div><div>- Store the bindings of 'w' into 'w'.</div><div><br></div><div>That last bit is unnecessary and inefficient (more so because it means keeping an old Store alive for LazyCompoundVal), but doesn't actually affect behavior. By having the constructor return the 'w' region instead, though, it's dead simple to check in VisitDeclStmt if the constructor has done all the necessary initialization of the region. And this is true for <i>any</i> constructor that knows what it's constructing into, so only temporaries actually appear in a legitimate prvalue context.</div><div><br></div><div>Jordan</div></body></html>