@@ -553,7 +553,7 @@ struct CheckFallThroughDiagnostics {
553
553
static CheckFallThroughDiagnostics MakeForFunction (const Decl *Func) {
554
554
CheckFallThroughDiagnostics D;
555
555
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 ;
557
557
D.diag_FallThrough_ReturnsNonVoid = diag::warn_falloff_nonvoid;
558
558
559
559
// Don't suggest that virtual functions be marked "noreturn", since they
@@ -588,7 +588,7 @@ struct CheckFallThroughDiagnostics {
588
588
589
589
static CheckFallThroughDiagnostics MakeForBlock () {
590
590
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 ;
592
592
D.diag_FallThrough_ReturnsNonVoid = diag::err_falloff_nonvoid;
593
593
D.diag_NeverFallThroughOrReturn = 0 ;
594
594
D.funMode = Block;
@@ -597,7 +597,7 @@ struct CheckFallThroughDiagnostics {
597
597
598
598
static CheckFallThroughDiagnostics MakeForLambda () {
599
599
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 ;
601
601
D.diag_FallThrough_ReturnsNonVoid = diag::warn_falloff_nonvoid;
602
602
D.diag_NeverFallThroughOrReturn = 0 ;
603
603
D.funMode = Lambda;
@@ -610,7 +610,7 @@ struct CheckFallThroughDiagnostics {
610
610
return (ReturnsVoid ||
611
611
D.isIgnored (diag::warn_falloff_nonvoid, FuncLoc)) &&
612
612
(!HasNoReturn ||
613
- D.isIgnored (diag::warn_noreturn_function_has_return_expr ,
613
+ D.isIgnored (diag::warn_noreturn_has_return_expr ,
614
614
FuncLoc)) &&
615
615
(!ReturnsVoid ||
616
616
D.isIgnored (diag::warn_suggest_noreturn_block, FuncLoc));
@@ -634,12 +634,10 @@ struct CheckFallThroughDiagnostics {
634
634
static void CheckFallThroughForBody (Sema &S, const Decl *D, const Stmt *Body,
635
635
QualType BlockType,
636
636
const CheckFallThroughDiagnostics &CD,
637
- AnalysisDeclContext &AC,
638
- sema::FunctionScopeInfo *FSI) {
637
+ AnalysisDeclContext &AC) {
639
638
640
639
bool ReturnsVoid = false ;
641
640
bool HasNoReturn = false ;
642
- bool IsCoroutine = FSI->isCoroutine ();
643
641
644
642
if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
645
643
if (const auto *CBody = dyn_cast<CoroutineBodyStmt>(Body))
@@ -668,12 +666,6 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,
668
666
if (CD.checkDiagnostics (Diags, ReturnsVoid, HasNoReturn))
669
667
return ;
670
668
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
- };
677
669
678
670
// cpu_dispatch functions permit empty function bodies for ICC compatibility.
679
671
if (D->getAsFunction () && D->getAsFunction ()->isCPUDispatchMultiVersion ())
@@ -686,13 +678,13 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,
686
678
687
679
case MaybeFallThrough:
688
680
if (HasNoReturn)
689
- EmitDiag (RBrace, CD.diag_FallThrough_HasNoReturn );
681
+ S. Diag (RBrace, CD.diag_FallThrough_HasNoReturn ) << CD. funMode ;
690
682
else if (!ReturnsVoid)
691
683
S.Diag (RBrace, CD.diag_FallThrough_ReturnsNonVoid ) << CD.funMode << 1 ;
692
684
break ;
693
685
case AlwaysFallThrough:
694
686
if (HasNoReturn)
695
- EmitDiag (RBrace, CD.diag_FallThrough_HasNoReturn );
687
+ S. Diag (RBrace, CD.diag_FallThrough_HasNoReturn ) << CD. funMode ;
696
688
else if (!ReturnsVoid)
697
689
S.Diag (RBrace, CD.diag_FallThrough_ReturnsNonVoid ) << CD.funMode << 0 ;
698
690
break ;
@@ -2735,7 +2727,7 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings(
2735
2727
: (fscope->isCoroutine ()
2736
2728
? CheckFallThroughDiagnostics::MakeForCoroutine (D)
2737
2729
: CheckFallThroughDiagnostics::MakeForFunction (D)));
2738
- CheckFallThroughForBody (S, D, Body, BlockType, CD, AC, fscope );
2730
+ CheckFallThroughForBody (S, D, Body, BlockType, CD, AC);
2739
2731
}
2740
2732
2741
2733
// Warning: check for unreachable code
0 commit comments