@@ -1159,36 +1159,29 @@ class alignas(1 << PatternAlignInBits) CaseLabelItem {
11591159// / FallthroughStmt - The keyword "fallthrough".
11601160class FallthroughStmt : public Stmt {
11611161 SourceLoc Loc;
1162- CaseStmt *FallthroughSource;
1163- CaseStmt *FallthroughDest;
1162+ DeclContext *DC;
11641163
1165- public:
1166- FallthroughStmt (SourceLoc Loc, std::optional<bool > implicit = std::nullopt )
1164+ FallthroughStmt (SourceLoc Loc, DeclContext *DC,
1165+ std::optional<bool > implicit = std::nullopt )
11671166 : Stmt(StmtKind::Fallthrough, getDefaultImplicitFlag(implicit, Loc)),
1168- Loc (Loc), FallthroughSource(nullptr ), FallthroughDest(nullptr ) {}
1167+ Loc (Loc), DC(DC) {}
1168+ public:
1169+ static FallthroughStmt *createParsed (SourceLoc Loc, DeclContext *DC);
11691170
11701171 SourceLoc getLoc () const { return Loc; }
11711172
11721173 SourceRange getSourceRange () const { return Loc; }
11731174
1175+ DeclContext *getDeclContext () const { return DC; }
1176+ void setDeclContext (DeclContext *newDC) { DC = newDC; }
1177+
11741178 // / Get the CaseStmt block from which the fallthrough transfers control.
1175- // / Set during Sema. (May stay null if fallthrough is invalid.)
1176- CaseStmt *getFallthroughSource () const { return FallthroughSource; }
1177- void setFallthroughSource (CaseStmt *C) {
1178- assert (!FallthroughSource && " fallthrough source already set?!" );
1179- FallthroughSource = C;
1180- }
1179+ // / Returns \c nullptr if the fallthrough is invalid.
1180+ CaseStmt *getFallthroughSource () const ;
11811181
11821182 // / Get the CaseStmt block to which the fallthrough transfers control.
1183- // / Set during Sema.
1184- CaseStmt *getFallthroughDest () const {
1185- assert (FallthroughDest && " fallthrough dest is not set until Sema" );
1186- return FallthroughDest;
1187- }
1188- void setFallthroughDest (CaseStmt *C) {
1189- assert (!FallthroughDest && " fallthrough dest already set?!" );
1190- FallthroughDest = C;
1191- }
1183+ // / Returns \c nullptr if the fallthrough is invalid.
1184+ CaseStmt *getFallthroughDest () const ;
11921185
11931186 static bool classof (const Stmt *S) {
11941187 return S->getKind () == StmtKind::Fallthrough;
@@ -1613,6 +1606,7 @@ class BreakStmt : public Stmt {
16131606 }
16141607
16151608 DeclContext *getDeclContext () const { return DC; }
1609+ void setDeclContext (DeclContext *newDC) { DC = newDC; }
16161610
16171611 static bool classof (const Stmt *S) {
16181612 return S->getKind () == StmtKind::Break;
@@ -1648,6 +1642,7 @@ class ContinueStmt : public Stmt {
16481642 }
16491643
16501644 DeclContext *getDeclContext () const { return DC; }
1645+ void setDeclContext (DeclContext *newDC) { DC = newDC; }
16511646
16521647 static bool classof (const Stmt *S) {
16531648 return S->getKind () == StmtKind::Continue;
0 commit comments