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

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 15 10:08:51 PST 2025


================
@@ -124,12 +140,20 @@ class ExceptionAnalyzer {
     /// after filtering.
     bool ContainsUnknown;
 
+    bool UnknownFromMissingDefinition = false;
+    bool UnknownFromKnownUnannotated = false;
----------------
vbvictor wrote:

Do we need to store this in `ExceptionInfo` and pass it each time?
I think it's the responsibility of `ExeceptionAnalyzer` to store behavior when encountering an unknown function, and `ExceptionInfo` is just a "dataclass", not storage for options.
So we wouldn't have to write this piece of code:
```cpp
const bool ReportUnknown =
      IsUnknown && ((TreatFunctionsWithoutSpecificationAsThrowing ==
                         FunctionsThatShouldNotThrowPolicy::All &&
                     Info.hasUnknownFromKnownUnannotated()) ||
                    (TreatFunctionsWithoutSpecificationAsThrowing !=
                         FunctionsThatShouldNotThrowPolicy::None &&
                     Info.hasUnknownFromMissingDefinition()));
```
`ExceptionInfo` would already know by itself whether it throws or not (depending on what `ExeceptionAnalyzer` produced).



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


More information about the cfe-commits mailing list