[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

Jennifer Yu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun May 21 07:52:53 PDT 2017


jyu2 added a comment.



In https://reviews.llvm.org/D33333#760149, @aaron.ballman wrote:

> As an FYI, there is a related check currently under development in clang-tidy; we probably should not duplicate this functionality in both places. See https://reviews.llvm.org/D19201 for the other review.


To my understanding, clang-tidy is kind of source check tool.  It does more intensive checking than compiler.  
My purpose here is to emit minimum warning form compiler, in case, clang-tidy is not used.

In https://reviews.llvm.org/D33333#760353, @Prazek wrote:

> Could you add similar tests as the ones that Stanislaw provied in his patch?
>  Like the one with checking if throw is catched, or the conditional noexcept (by a macro, etc)


Good idea!  Could add “marco” test for this.  But I am not sure compiler want to add check for throw caught by different catch handler.  Because at compile time, compiler can not statically determine which catch handler will be used to caught the exception on all time.   I would think that is pragma's responsibility.

For example:

  If (a) throw A else throw B;  

My main concern there is implicit noexcept gets set by compiler, which cause runtime to termination.


https://reviews.llvm.org/D33333





More information about the cfe-commits mailing list