diff options
Diffstat (limited to 'clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp')
| -rw-r--r-- | clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp index 5fd1b73..8ead264 100644 --- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp +++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp @@ -562,17 +562,6 @@ ExceptionAnalyzer::throwsException(const Stmt *St, } } Results.merge(Uncaught); - } else if (const auto *Call = dyn_cast<CallExpr>(St)) { - if (const FunctionDecl *Func = Call->getDirectCallee()) { - const ExceptionInfo Excs = - throwsException(Func, Caught, CallStack, Call->getBeginLoc()); - Results.merge(Excs); - } - } else if (const auto *Construct = dyn_cast<CXXConstructExpr>(St)) { - const ExceptionInfo Excs = - throwsException(Construct->getConstructor(), Caught, CallStack, - Construct->getBeginLoc()); - Results.merge(Excs); } else if (const auto *DefaultInit = dyn_cast<CXXDefaultInitExpr>(St)) { const ExceptionInfo Excs = throwsException(DefaultInit->getExpr(), Caught, CallStack); @@ -602,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()) { const 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)) { + ExceptionInfo Excs = throwsException(Construct->getConstructor(), Caught, + CallStack, Construct->getBeginLoc()); + Results.merge(Excs); + } } return Results; } |
