Skip to content

Commit fa2d4dc

Browse files
committed
[AST] DoStmt always contains a BraceStmt
1 parent 98522b0 commit fa2d4dc

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

include/swift/AST/Stmt.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,11 +539,11 @@ class LabeledStmt : public Stmt {
539539
/// DoStmt - do statement, without any trailing clauses.
540540
class DoStmt : public LabeledStmt {
541541
SourceLoc DoLoc;
542-
Stmt *Body;
542+
BraceStmt *Body;
543543

544544
public:
545545
DoStmt(LabeledStmtInfo labelInfo, SourceLoc doLoc,
546-
Stmt *body, Optional<bool> implicit = None)
546+
BraceStmt *body, Optional<bool> implicit = None)
547547
: LabeledStmt(StmtKind::Do, getDefaultImplicitFlag(implicit, doLoc),
548548
labelInfo),
549549
DoLoc(doLoc), Body(body) {}
@@ -553,8 +553,8 @@ class DoStmt : public LabeledStmt {
553553
SourceLoc getStartLoc() const { return getLabelLocOrKeywordLoc(DoLoc); }
554554
SourceLoc getEndLoc() const { return Body->getEndLoc(); }
555555

556-
Stmt *getBody() const { return Body; }
557-
void setBody(Stmt *s) { Body = s; }
556+
BraceStmt *getBody() const { return Body; }
557+
void setBody(BraceStmt *s) { Body = s; }
558558

559559
static bool classof(const Stmt *S) { return S->getKind() == StmtKind::Do; }
560560
};

lib/AST/ASTWalker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ Stmt *Traversal::visitGuardStmt(GuardStmt *US) {
14931493
}
14941494

14951495
Stmt *Traversal::visitDoStmt(DoStmt *DS) {
1496-
if (Stmt *S2 = doIt(DS->getBody()))
1496+
if (BraceStmt *S2 = cast_or_null<BraceStmt>(doIt(DS->getBody())))
14971497
DS->setBody(S2);
14981498
else
14991499
return nullptr;

lib/Sema/TypeCheckStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
658658

659659
Stmt *visitDoStmt(DoStmt *DS) {
660660
AddLabeledStmt loopNest(*this, DS);
661-
Stmt *S = DS->getBody();
661+
BraceStmt *S = DS->getBody();
662662
typeCheckStmt(S);
663663
DS->setBody(S);
664664
return DS;

0 commit comments

Comments
 (0)