[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
Tue Dec 9 11:48:05 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:

> That's a valid point, but it feels slightly divergent from the primary goal of this check, which focuses on preventing crashes/UB rather than enforcing noexcept usage for optimization or style. IMO this can be done with a seperate check (maybe under `modernize-`?)

I think that should rather go under `misc` as it changes the behavior as it does not modernize stuff per se (suggesting `noexcept` instead of `throw(false)` would be a modernization in my eyes). But it would be along the lines of suggesting `[[nodiscard]]` which is `modernize-`...

> I think it might be better to land the current Enum-based implementation first and consider a more granular split or a dedicated check in a future patch. WDYT?

Since it requires an opt-in by the user it should be fine. But it might change the behavior of the opt-in afterwards so it might make sense to at least lay out the path beforehand to avoid that.






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


More information about the cfe-commits mailing list