[clang-tools-extra] [clang-tidy] Fix `bugprone-exception-escape` not diagnosing throws in argument lists (PR #165955)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 8 02:07:51 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)) {
----------------
vbvictor wrote:

I'm fine with things as is, we can merge it.

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


More information about the cfe-commits mailing list