[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
Thu Jun 1 21:59:35 PDT 2017
jyu2 marked 12 inline comments as done.
jyu2 added inline comments.
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6341
+ : Warning<"%0 has a non-throwing exception specification but can still "
+ "throw, may result in unexpected program termination.">,
+ InGroup<Exceptions>;
----------------
aaron.ballman wrote:
> throw, may -> throw, which may
>
> Also, remove the period at the end of the diagnostic.
use you suggested.
================
Comment at: lib/Sema/AnalysisBasedWarnings.cpp:290
+
+static bool mayThrowBeCaughted(const CXXThrowExpr *Throw,
+ const CXXCatchStmt *Catch) {
----------------
aaron.ballman wrote:
> Caughted -> Caught
:-(
================
Comment at: lib/Sema/AnalysisBasedWarnings.cpp:304
+ if (CaughtAsRecordType && ThrowTypeAsRecordType) {
+ if (CaughtAsRecordType == ThrowTypeAsRecordType)
+ MayCaught = true;
----------------
aaron.ballman wrote:
> This does not seem quite correct. Consider:
> ```
> struct S{};
>
> void f() {
> try {
> throw S{};
> } catch (const S *s) {
> }
> }
> ```
Good catch. Remove that check.
https://reviews.llvm.org/D33333
More information about the cfe-commits
mailing list