[clang-tools-extra] [clang-tidy] Fix `bugprone-exception-escape` not diagnosing throws in argument lists (PR #165955)
Victor Chernyakin via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 7 23:51:13 PST 2025
================
@@ -601,10 +591,25 @@ ExceptionAnalyzer::throwsException(const Stmt *St,
Results.merge(Excs);
}
} else {
+ // Check whether any of this node's subexpressions throws.
for (const Stmt *Child : St->children()) {
ExceptionInfo Excs = throwsException(Child, Caught, CallStack);
Results.merge(Excs);
}
+
+ // If this node is a call to a function or constructor, also check
+ // whether the call itself throws.
+ if (const auto *Call = dyn_cast<CallExpr>(St)) {
+ if (const FunctionDecl *Func = Call->getDirectCallee()) {
+ ExceptionInfo Excs =
+ throwsException(Func, Caught, CallStack, Call->getBeginLoc());
+ Results.merge(Excs);
+ }
+ } else if (const auto *Construct = dyn_cast<CXXConstructExpr>(St)) {
----------------
localspook wrote:
Hmm, I guess I'm just not really bothered by this nesting in the `else` branch, so I don't see the benefit, and at the same time I see some downsides: this would introduce a bit of duplication (3 repetitions of the `Results.merge(CheckChildren(St));` line), and I think having to jump to another function would make the code harder to understand in this case. I can understand where you're coming from though, so if you find that unconvincing, I'm happy to change it.
https://github.com/llvm/llvm-project/pull/165955
More information about the cfe-commits
mailing list