[PATCH] D37090: Implement CFG construction for __finally.
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 25 08:54:03 PDT 2017
On Thu, Aug 24, 2017 at 1:04 PM, Reid Kleckner via Phabricator via
cfe-commits <cfe-commits at 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 at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170825/29f81432/attachment-0001.html>
More information about the cfe-commits
mailing list