@@ -643,10 +643,7 @@ bool isKnownToAlwaysThrow(const FunctionDecl *FD) {
643643 OnlyStmt = EWC->getSubExpr ();
644644 }
645645 // Check if the only statement is a throw expression.
646- if (isa<CXXThrowExpr>(OnlyStmt)) {
647- return true ; // Known to always throw.
648- }
649- return false ; // Not known to always throw.
646+ return isa<CXXThrowExpr>(OnlyStmt);
650647}
651648
652649} // anonymous namespace
@@ -708,25 +705,23 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,
708705 // If the final statement is a call to an always-throwing function,
709706 // don't warn about the fall-through.
710707 if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
711- if (const auto *CS = dyn_cast<CompoundStmt>(Body)) {
712- if (!CS->body_empty ()) {
713- const Stmt *LastStmt = CS->body_back ();
714- // Unwrap ExprWithCleanups if necessary.
715- if (const auto *EWC = dyn_cast<ExprWithCleanups>(LastStmt)) {
716- LastStmt = EWC->getSubExpr ();
717- }
718- if (const auto *CE = dyn_cast<CallExpr>(LastStmt)) {
719- if (const FunctionDecl *Callee = CE->getDirectCallee ()) {
720- if (isKnownToAlwaysThrow (Callee)) {
721- return ; // Don't warn about fall-through.
722- }
723- }
724- }
725- // Direct throw.
726- if (isa<CXXThrowExpr>(LastStmt)) {
708+ if (const auto *CS = dyn_cast<CompoundStmt>(Body);
709+ CS && !CS->body_empty ()) {
710+ const Stmt *LastStmt = CS->body_back ();
711+ // Unwrap ExprWithCleanups if necessary.
712+ if (const auto *EWC = dyn_cast<ExprWithCleanups>(LastStmt)) {
713+ LastStmt = EWC->getSubExpr ();
714+ }
715+ if (const auto *CE = dyn_cast<CallExpr>(LastStmt)) {
716+ if (const FunctionDecl *Callee = CE->getDirectCallee ();
717+ Callee && isKnownToAlwaysThrow (Callee)) {
727718 return ; // Don't warn about fall-through.
728719 }
729720 }
721+ // Direct throw.
722+ if (isa<CXXThrowExpr>(LastStmt)) {
723+ return ; // Don't warn about fall-through.
724+ }
730725 }
731726 }
732727 bool NotInAllControlPaths = FallThroughType == MaybeFallThrough;
0 commit comments