<div>The assertion maintains a correct invariant: F should be "deeper" than L in the scope tree.</div><div><includetail><div> </div><div> </div><div style="font:Verdana normal 14px;color:#000;"><div style="FONT-SIZE: 12px;FONT-FAMILY: Arial Narrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="FONT-SIZE: 12px;background:#efefef;padding:8px;"><div id="menu_sender"><b>From: </b> "Xu Zhongxing"<xuzhongxing@foxmail.com>;</div><div><b>Date: </b> Fri, Aug 12, 2011 12:44 PM</div><div><b>To: </b> "kremenek"<kremenek@apple.com>; "cfe-commits"<cfe-commits@cs.uiuc.edu>; <wbr></div><div></div><div><b>Subject: </b> Re:[cfe-commits] r137426 - in /cfe/trunk: lib/Analysis/CFG.cpptest/SemaCXX/cfg.cpp</div></div><div> </div>
<div>Hi Ted,</div><div><br></div><div>This code is ill-formed per n3242: 6.7 p3. gcc rejects it. But clang accepts it. Do we need to handle it?</div><div><div> </div><div> </div><div style="font:Verdana normal 14px;color:#000;"><div style="FONT-SIZE: 12px;FONT-FAMILY: Arial Narrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="FONT-SIZE: 12px;background:#efefef;padding:8px;"><div id="menu_sender"><b>From: </b> "kremenek"<kremenek@apple.com>;</div><div><b>Date: </b> Fri, Aug 12, 2011 12:09 PM</div><div><b>To: </b> "cfe-commits"<cfe-commits@cs.uiuc.edu>; <wbr></div><div></div><div><b>Subject: </b> [cfe-commits] r137426 - in /cfe/trunk: lib/Analysis/CFG.cpptest/SemaCXX/cfg.cpp</div></div><div> </div>
Author: kremenek<br>Date: Thu Aug 11 23:09:00 2011<br>New Revision: 137426<br><br>URL: http://llvm.org/viewvc/llvm-project?rev=137426&view=rev<br>Log:<br>Fix crash in CFGBuilder involving implicit destructor calls and gotos jumping after an object was declared. Fixes PR 10620.<br><br>Added:<br> cfe/trunk/test/SemaCXX/cfg.cpp<br>Modified:<br> cfe/trunk/lib/Analysis/CFG.cpp<br><br>Modified: cfe/trunk/lib/Analysis/CFG.cpp<br>URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=137426&r1=137425&r2=137426&view=diff<br>==============================================================================<br>--- cfe/trunk/lib/Analysis/CFG.cpp (original)<br>+++ cfe/trunk/lib/Analysis/CFG.cpp Thu Aug 11 23:09:00 2011<br>@@ -191,8 +191,8 @@<br> int D = 0;<br> const_iterator F = *this;<br> while (F.Scope != L.Scope) {<br>- assert (F != const_iterator()<br>- && "L iterator is not reachable from F iterator.");<br>+ if (F == const_iterator())<br>+ return D;<br> D += F.VarIter;<br> F = F.Scope->Prev;<br> }<br>@@ -816,10 +816,12 @@<br> /// performed in place specified with iterator.<br> void CFGBuilder::insertAutomaticObjDtors(CFGBlock* Blk, CFGBlock::iterator I,<br> LocalScope::const_iterator B, LocalScope::const_iterator E, Stmt* S) {<br>- BumpVectorContext& C = cfg->getBumpVectorContext();<br>- I = Blk->beginAutomaticObjDtorsInsert(I, B.distance(E), C);<br>- while (B != E)<br>- I = Blk->insertAutomaticObjDtor(I, *B++, S);<br>+ if (int Cnt = B.distance(E)) {<br>+ BumpVectorContext& C = cfg->getBumpVectorContext();<br>+ I = Blk->beginAutomaticObjDtorsInsert(I, Cnt, C);<br>+ while (B != E)<br>+ I = Blk->insertAutomaticObjDtor(I, *B++, S);<br>+ }<br> }<br> <br> /// appendAutomaticObjDtors - Append destructor CFGElements for variables with<br><br>Added: cfe/trunk/test/SemaCXX/cfg.cpp<br>URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cfg.cpp?rev=137426&view=auto<br>==============================================================================<br>--- cfe/trunk/test/SemaCXX/cfg.cpp (added)<br>+++ cfe/trunk/test/SemaCXX/cfg.cpp Thu Aug 11 23:09:00 2011<br>@@ -0,0 +1,23 @@<br>+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -fsyntax-only %s<br>+<br>+// Test that the CFG builder handles destructors and gotos jumping between<br>+// scope boundaries. Previously this crashed (PR 10620).<br>+struct S_10620 {<br>+ S_10620(const S_10620 &x);<br>+ ~S_10620();<br>+};<br>+void PR10620(int x, const S_10620& s) {<br>+ if (x) {<br>+ goto done;<br>+ }<br>+ const S_10620 s2(s);<br>+done:<br>+ ;<br>+}<br>+void PR10620_2(int x, const S_10620& s) {<br>+ if (x)<br>+ goto done;<br>+ const S_10620 s2(s);<br>+done:<br>+ ;<br>+}<br>\ No newline at end of file<br><br><br>_______________________________________________<br>cfe-commits mailing list<br>cfe-commits@cs.uiuc.edu<br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits<br><br></div></div></div></includetail></div>