[PATCH] D153423: [clang-tidy] Allow explicit throwing in bugprone-exception-escape for special functions

Domján Dániel via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 23 11:46:33 PDT 2023


isuckatcs added a comment.

Apart from some nits I think this patch looks good.



================
Comment at: clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp:26
+
+AST_MATCHER(FunctionDecl, isExplicitThrow) {
+  switch (Node.getExceptionSpecType()) {
----------------
How about creating an `isExplicitThrow()` helper function inside `ExceptionSpecificationType.h`, where these enums are defined? That way if one more enum is added, it will be more convenient to update the explicit throw checks, not to mention it can also be reused in other checkers if needed.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-escape.rst:14
 * ``swap()`` functions
-* Functions marked with ``throw()`` or ``noexcept``
+* Functions marked with ``throw()``, ``noexcept``, ``noexcept(true)``
 * Other functions given as option
----------------
Why remove `noexcept(true)`?


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-escape.rst:25-29
+Functions declared explicitly with ``noexcept(false)`` or ``throw(exception)``
+will be excluded from the analysis, as even though it is not recommended for
+functions like ``swap``, ``main``, move constructors and assignment operators,
+and destructors, it is a clear indication of the developer's intention and
+should be respected..
----------------



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153423



More information about the cfe-commits mailing list