================
@@ -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:
Thinking out loud, I think it's more readable if instead of placing
`dyn_cast<CallExpr>` in `else` branch, we would extract "check for children"
part in a separate function and use it like this:
```cpp
} else if (const auto *Call = dyn_cast<CallExpr>(St)) {
Results.merge(CheckChildren(St)); // New code!
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)) {
Results.merge(CheckChildren(St)); // New code!
ExceptionInfo Excs = throwsException(Construct->getConstructor(), Caught,
CallStack, Construct->getBeginLoc());
Results.merge(Excs);
}
```
I'd rather see this more straightforward solution instead of twisting order of
branches, which seem to me more bugprone and harder to read, WDYT?
https://github.com/llvm/llvm-project/pull/165955
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits