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

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 22 10:50:24 PDT 2017


rnk added a comment.

Re: clang-tidy, I would rather implement this as a traditional compiler warning.

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

> In https://reviews.llvm.org/D33333#761126, @jyu2 wrote:
>
> > As I said, I don't think checking throw type matching catch handler type is compiler's job.  I'd like either silence all warning for that.  What do you think?
>
>
> Consider the following cases:
>  ...
>  I think the expected behavior in these cases is reasonable (and can be done with a CFG) rather than manually looking at the scope stack like you're doing.


I agree with @jyu2, we should do something simple. I think it would be simple to handle all cases except for `h`, which requires semantic analysis to figure out if the thrown object would be caught by the catch parameter. Implementing that is more likely to introduce bugs in the compiler than it is to find bugs in user code. I doubt we need the CFG for any of this. The later examples are all throwing exceptions from catch blocks, which is the same as not having an open try scope.


https://reviews.llvm.org/D33333





More information about the cfe-commits mailing list