On Thu, Aug 24, 2017 at 1:04 PM, Reid Kleckner via Phabricator via cfe-commits <cfe-commits@lists.llvm.org> wrote:
> rnk added a comment. > > Re: jumps out of __try, I wonder if you can tie __finally into whatever > the CFG does for C++ destructors. > Given $ cat test.cc struct C { C(); ~C(); }; bool g(); void h(); void f() { C c; if (g()) return; h(); } Then `bin/clang-cl /c test.cc -Xclang -analyze -Xclang -analyzer-checker=debug.ViewCFG` produces this CFG: http://imgur.com/SoGSFNY So it looks like dtor calls just get duplicated into every branch end at the moment, instead of producing proper cleanup blocks like codegen does :-/ Since the __finally body isn't callable, this won't work. I think I'll try to implement something like codegen's cleanup stuff (EmitBranchThroughCleanup etc) and use that for __finally, and maybe we can then use that for dtors some time later too. And maybe we can even use the CFG for codegen one day. > > > > ================ > Comment at: test/Sema/warn-unreachable-ms.c:49 > __try { > - f(); > + throw 1; > } __except (1) { > ---------------- > Nice. Would any noreteurn call work here to eliminate the re-run and ifdef? > Nice, that works. Just `f(); return;` instead of `throw 1;` does the trick. (Call to f() isn't really needed but without it the test case is confusing to humans – how could the __except possibly be entered?) > > > https://reviews.llvm.org/D37090 > > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits