[PATCH] D108905: [ItaniumCXXABI] Add -fassume-nothrow-exception-dtor to assume that an exception object' destructor is nothrow

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 1 19:13:58 PDT 2023


MaskRay added a comment.

In D108905#4655694 <https://reviews.llvm.org/D108905#4655694>, @ChuanqiXu wrote:

> Oh, I am not saying the legacy and old comment. I mean you need to touch ReleaseNotes.rst and UserManual.rst since we add a new flag. Also we need either add a TODO/FIXME saying we need to emit an error in Sema if we find the the dtor of the exception we're throwing may throw or implement the semantics actually.

Thanks for the reminder about `ReleaseNotes.rst` and `UsersManual.rst`!

I think many changes don't update `UsersManual.rst` but this option is probably quite useful and therefore deserves an entry. Added.
The primary change is to `clang/lib/CodeGen/ItaniumCXXABI.cpp`, which does not report warnings.
If we want to implement a warning, we should probably do it in clang/lib/Sema/SemaDeclCXX.cpp `Sema::BuildExceptionDeclaration`, which is not touched in this file, so a TODO seems not appropriate...

Is the warning to warn about `noexcept(false)` destructor in an exception-declaration <https://eel.is/c++draft/except.pre>? When?
If at catch handlers, unfortunately we are cannot determine the exception object for a `catch (...) { ... }` (used by coroutines).
Technically, even if a destructor is `noexcept(false)`, the destructor may not throw when `__cxa_end_catch` destroys the object.

So we probably should warn about throw expressions, which can be done in `Sema::CheckCXXThrowOperand` and I will investigate it.
However, this warning appears orthogonal to `-fassume-nothrow-exception-dtor`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108905/new/

https://reviews.llvm.org/D108905



More information about the cfe-commits mailing list