[clang-tools-extra] [clang-tidy] Improve `bugprone-exception-escape`: add stacktrace of escaped exception (PR #134375)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 13 12:07:55 PDT 2025
================
@@ -28,6 +29,12 @@ class ExceptionAnalyzer {
///< definition.
};
+ /// We use a SetVector to preserve the order of the functions in the call
+ /// stack as well as have fast lookup.
+ using CallStack = llvm::SetVector<const FunctionDecl *,
+ llvm::SmallVector<const FunctionDecl *, 32>,
+ llvm::DenseSet<const FunctionDecl *>, 32>;
----------------
vbvictor wrote:
I can see a possible solution when we change `throwsException` method signature to
```cpp
throwsException(const FunctionDecl *Func,
const ExceptionInfo::Throwables &Caught,
CallStack &CallStack,
SourceLocation CalledLoc); // new parameter to track from where 'Func' was called
```
and later `CalledLoc` should be saved in `CallStack`
```cpp
if (const Stmt *Body = Func->getBody()) {
CallStack.insert({Func, CalledLoc}); // saved in llvm::MapVector<>
ExceptionInfo Result = throwsException(Body, Caught, CallStack);
```
I will try to implement this new logic and fall back to initial implementation if something goes wrong.
https://github.com/llvm/llvm-project/pull/134375
More information about the cfe-commits
mailing list