@@ -553,7 +553,7 @@ struct CheckFallThroughDiagnostics {
553553 static CheckFallThroughDiagnostics MakeForFunction (const Decl *Func) {
554554 CheckFallThroughDiagnostics D;
555555 D.FuncLoc = Func->getLocation ();
556- D.diag_FallThrough_HasNoReturn = diag::warn_falloff_noreturn_function ;
556+ D.diag_FallThrough_HasNoReturn = diag::warn_noreturn_has_return_expr ;
557557 D.diag_FallThrough_ReturnsNonVoid = diag::warn_falloff_nonvoid;
558558
559559 // Don't suggest that virtual functions be marked "noreturn", since they
@@ -588,7 +588,7 @@ struct CheckFallThroughDiagnostics {
588588
589589 static CheckFallThroughDiagnostics MakeForBlock () {
590590 CheckFallThroughDiagnostics D;
591- D.diag_FallThrough_HasNoReturn = diag::err_noreturn_block_has_return_expr ;
591+ D.diag_FallThrough_HasNoReturn = diag::err_noreturn_has_return_expr ;
592592 D.diag_FallThrough_ReturnsNonVoid = diag::err_falloff_nonvoid;
593593 D.diag_NeverFallThroughOrReturn = 0 ;
594594 D.funMode = Block;
@@ -597,7 +597,7 @@ struct CheckFallThroughDiagnostics {
597597
598598 static CheckFallThroughDiagnostics MakeForLambda () {
599599 CheckFallThroughDiagnostics D;
600- D.diag_FallThrough_HasNoReturn = diag::err_noreturn_lambda_has_return_expr ;
600+ D.diag_FallThrough_HasNoReturn = diag::err_noreturn_has_return_expr ;
601601 D.diag_FallThrough_ReturnsNonVoid = diag::warn_falloff_nonvoid;
602602 D.diag_NeverFallThroughOrReturn = 0 ;
603603 D.funMode = Lambda;
@@ -610,7 +610,7 @@ struct CheckFallThroughDiagnostics {
610610 return (ReturnsVoid ||
611611 D.isIgnored (diag::warn_falloff_nonvoid, FuncLoc)) &&
612612 (!HasNoReturn ||
613- D.isIgnored (diag::warn_noreturn_function_has_return_expr ,
613+ D.isIgnored (diag::warn_noreturn_has_return_expr ,
614614 FuncLoc)) &&
615615 (!ReturnsVoid ||
616616 D.isIgnored (diag::warn_suggest_noreturn_block, FuncLoc));
@@ -634,12 +634,10 @@ struct CheckFallThroughDiagnostics {
634634static void CheckFallThroughForBody (Sema &S, const Decl *D, const Stmt *Body,
635635 QualType BlockType,
636636 const CheckFallThroughDiagnostics &CD,
637- AnalysisDeclContext &AC,
638- sema::FunctionScopeInfo *FSI) {
637+ AnalysisDeclContext &AC) {
639638
640639 bool ReturnsVoid = false ;
641640 bool HasNoReturn = false ;
642- bool IsCoroutine = FSI->isCoroutine ();
643641
644642 if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
645643 if (const auto *CBody = dyn_cast<CoroutineBodyStmt>(Body))
@@ -668,12 +666,6 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,
668666 if (CD.checkDiagnostics (Diags, ReturnsVoid, HasNoReturn))
669667 return ;
670668 SourceLocation LBrace = Body->getBeginLoc (), RBrace = Body->getEndLoc ();
671- auto EmitDiag = [&](SourceLocation Loc, unsigned DiagID) {
672- if (IsCoroutine)
673- S.Diag (Loc, DiagID) << FSI->CoroutinePromise ->getType ();
674- else
675- S.Diag (Loc, DiagID);
676- };
677669
678670 // cpu_dispatch functions permit empty function bodies for ICC compatibility.
679671 if (D->getAsFunction () && D->getAsFunction ()->isCPUDispatchMultiVersion ())
@@ -686,13 +678,13 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,
686678
687679 case MaybeFallThrough:
688680 if (HasNoReturn)
689- EmitDiag (RBrace, CD.diag_FallThrough_HasNoReturn );
681+ S. Diag (RBrace, CD.diag_FallThrough_HasNoReturn ) << CD. funMode ;
690682 else if (!ReturnsVoid)
691683 S.Diag (RBrace, CD.diag_FallThrough_ReturnsNonVoid ) << CD.funMode << 1 ;
692684 break ;
693685 case AlwaysFallThrough:
694686 if (HasNoReturn)
695- EmitDiag (RBrace, CD.diag_FallThrough_HasNoReturn );
687+ S. Diag (RBrace, CD.diag_FallThrough_HasNoReturn ) << CD. funMode ;
696688 else if (!ReturnsVoid)
697689 S.Diag (RBrace, CD.diag_FallThrough_ReturnsNonVoid ) << CD.funMode << 0 ;
698690 break ;
@@ -2735,7 +2727,7 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings(
27352727 : (fscope->isCoroutine ()
27362728 ? CheckFallThroughDiagnostics::MakeForCoroutine (D)
27372729 : CheckFallThroughDiagnostics::MakeForFunction (D)));
2738- CheckFallThroughForBody (S, D, Body, BlockType, CD, AC, fscope );
2730+ CheckFallThroughForBody (S, D, Body, BlockType, CD, AC);
27392731 }
27402732
27412733 // Warning: check for unreachable code
0 commit comments