[PATCH] D27358: V-base dtor called more than needed when throw happens in v-base ctor in window. Need add "complete object flag" check in eh cleanup code.

Jennifer Yu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 2 11:29:21 PST 2016


jyu2 created this revision.
jyu2 added reviewers: cfe-commits, erichkeane, majnemer, rnk.
jyu2 set the repository for this revision to rL LLVM.
jyu2 added a project: clang-c.

The problem only happen on window ( A MSVC compatibility issues)

The nature of the problem is virtual base dtor called more than it is needed after exception throw in inheriting base class(with virtual bases) ctor.

The root problem is when throw happen, not all virtual base classes have been contructed, so not all virtual base dtors are need to call for ehcleanup.

clang has code to handle vbase initialization: basically add check for "complete object flag" before call to v-base ctor.
But that part is missing for cleanup code.

To fix this add similar code as v-base init to cleanup code, same algorithm.

1> Add new routine:
EmitDtorCompleteObjectHandler

With corresponding to EmitCtorCompleteObjectHandler

2> In the EmitDestructorCal
Call EmitDtorCompleteObjectHandler when generate ehcleanup inside ctor.

Just add check for "complete object flag" before call to v-base dtor.

Please let me know you need more info.


Repository:
  rL LLVM

https://reviews.llvm.org/D27358

Files:
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27358.80097.patch
Type: text/x-patch
Size: 4585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161202/c26084ad/attachment.bin>


More information about the cfe-commits mailing list