[clang-tools-extra] [clang-tidy] Add options to throw unannotated functions in `bugprone-exception-escape` (PR #168324)

Oliver Stöneberg via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 28 09:33:50 PST 2025


================
@@ -71,3 +71,15 @@ Options
 
    Comma separated list containing type names which are not counted as thrown
    exceptions in the check. Default value is an empty string.
+
+.. option:: KnownUnannotatedAsThrowing
+
+   When `true`, treat calls to functions with visible definitions that are not
+   explicitly declared as non-throwing (i.e. lack ``noexcept`` or ``throw()``)
+   as potentially throwing, even if their bodies are visible and no explicit
+   throw is found. Default value is `false`.
+
+.. option:: UnknownAsThrowing
+
+   When `true`, treat calls to functions without visible definitions as
+   potentially throwing. Default value is `false`.
----------------
firewave wrote:

Sorry for replying so late but I was out sick.

I think `KnownUnannotatedAsThrowing` does not make sense...?

Assuming the function is known and unannotated...

- if it has no additional function calls it cannot throw. So that would trigger false positives.
- if it has any calls that would not need to be evaluated. So it would be identical to the first case.

So I see no point in having it and the suggested replacement makes more sense.

https://github.com/llvm/llvm-project/pull/168324


More information about the cfe-commits mailing list