]> granicus.if.org Git - clang/commit
Implement CFG construction for __try / __except / __leave.
authorNico Weber <nicolasweber@gmx.de>
Wed, 23 Aug 2017 15:33:16 +0000 (15:33 +0000)
committerNico Weber <nicolasweber@gmx.de>
Wed, 23 Aug 2017 15:33:16 +0000 (15:33 +0000)
commit7ed95d923631f84fd6679c8b9e32d7d6aca24c8b
tree11e46f6eb256ba887adb4a12a65f7230cc352f7d
parentd2a520ee9ed8f9f67f561bd8e074781cef7a202c
Implement CFG construction for __try / __except / __leave.

This makes -Wunreachable-code work for programs containing SEH (except for
__finally, which is still missing for now).

__try is modeled like try (but simpler since it can only have a single __except
or __finally), __except is fairly similar to catch (but simpler, since it can't
contain declarations). __leave is implemented similarly to break / continue.

Use the existing addTryDispatchBlock infrastructure (which
FindUnreachableCode() in ReachableCode.cpp uses via cfg->try_blocks_begin()) to
mark things in the __except blocks as reachable.

Re-use TryTerminatedBlock. This means we add EH edges from calls to the __try
block, but not from all other statements. While this is incomplete, it matches
LLVM's SEH codegen support. Also, in practice, BuildOpts.AddEHEdges is always
false in practice from what I can tell, so we never even insert the call EH
edges either.

https://reviews.llvm.org/D36914

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311561 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/CFG.cpp
test/Sema/warn-unreachable-ms.c [new file with mode: 0644]