<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 26, 2017, at 2:42 AM, Ilya Palachev via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi everyone,<br class=""><br class="">Recently we've noticed a strange behaviour in CFG construction for function try blocks. Clang test suite has a test case SemaCXX/return-noreturn.cpp with functions functionTryBlock{1,2,3}, and at least for functionTryBlock2 control flow graph looks a bit strange:<br class=""><br class="">$ .../clang -cc1 -nostdsysteminc .../llvm/tools/clang/test/SemaCXX/return-noreturn.cpp -fsyntax-only -fcxx-exceptions -Wreturn-type -Wmissing-noreturn -Wno-unreachable-code -Wno-covered-switch-default -analyze -analyzer-checker debug.DumpCFG 2>&1 | grep functionTryBlock2 -A 19<br class=""><br class="">   int functionTryBlock2(int s)<br class="">     [B3 (ENTRY)]<br class="">       Succs (1): B0<br class=""><br class="">     [B1]<br class="">       T: try ...<br class="">       Succs (1): B2<br class=""><br class="">     [B2]<br class="">      catch (...):<br class="">       1: catch (...) {<br class="">   [B2.3]}<br class="">       2: 0<br class="">       3: return [B2.2];<br class="">       Preds (1): B1<br class="">       Succs (1): B0<br class=""><br class="">     [B0 (EXIT)]<br class="">       Preds (2): B2 B3<br class=""><br class="">The strange place here is in the fact that block [B3] goes directly to [B0], leaving the block [B1] non-visited. Moreover, for the below three code examples the generated CFG looks the same:<br class=""><br class="">============ 1 =============<br class=""><br class="">int foo();<br class=""><br class="">int functionTryBlock2(int s) try {<br class="">  s += foo();<br class="">} catch (...) {<br class="">  return s;<br class="">}<br class=""><br class="">============ 2 =============<br class=""><br class="">int foo();<br class=""><br class="">int functionTryBlock2(int s) {<br class="">  try {<br class="">    s += foo();<br class="">  } catch (...) {<br class="">    return s;<br class="">  }<br class="">}<br class=""><br class="">============ 3 =============<br class=""><br class="">int foo();<br class=""><br class="">int functionTryBlock2(int s) {<br class="">  s += foo();<br class="">  try {<br class="">  } catch (...) {<br class="">    return s;<br class="">  }<br class="">}<br class=""><br class="">Is it a bug? It seems that `catch' blocks can be stayed without any predecessors, since they are visited not by `control flow', but by the exception. But why `try' blocks are not correctly included into CFG? And how should the correct CFG look like?<br class=""><br class=""></div></div></blockquote><div><br class=""></div><div>Unfortunately, support for exceptions in the CFG has not been fully implemented.</div><div><br class=""></div><div><span style="color: rgb(34, 34, 34); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, Verdana, Helvetica, sans-serif; font-size: small; background-color: rgb(255, 255, 255);" class="">"Currently exceptions are treated as "black holes", and exception-handling control structures are poorly modeled (to be conservative). This could be much improved for both C++ and Objective-C exceptions.</span><font color="#222222" face="Lucida Grande, Lucida Sans Unicode, Arial, Verdana, Helvetica, sans-serif" size="2" class="">”</font></div><div><span style="color: rgb(34, 34, 34); background-color: rgb(255, 255, 255);" class="">from </span><font color="#222222" class=""><a href="https://clang-analyzer.llvm.org/open_projects.html" class="">https://clang-analyzer.llvm.org/open_projects.html</a></font></div></div><div><br class=""></div><div>Anna<br class=""><blockquote type="cite" class=""><div class=""><div class="">--<br class="">Best regards,<br class="">Ilya Palachev<br class="">_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></div></div></blockquote></div><br class=""></body></html>