================ @@ -3056,26 +3045,50 @@ class IndirectGotoStmt : public Stmt { } }; -/// ContinueStmt - This represents a continue. -class ContinueStmt : public Stmt { -public: - ContinueStmt(SourceLocation CL) : Stmt(ContinueStmtClass) { - setContinueLoc(CL); +/// Base class for BreakStmt and ContinueStmt. +class LoopControlStmt : public Stmt { + /// If this is a labeled break/continue, the label whose statement we're + /// targeting. + LabelDecl *TargetLabel = nullptr; + + /// Location of the label, if any. + SourceLocation Label; + +protected: + LoopControlStmt(StmtClass Class, SourceLocation Loc) : Stmt(Class) { + setKwLoc(Loc); } - /// Build an empty continue statement. - explicit ContinueStmt(EmptyShell Empty) : Stmt(ContinueStmtClass, Empty) {} + LoopControlStmt(StmtClass Class, SourceLocation Loc, SourceLocation LabelLoc, + LabelDecl *Target) + : LoopControlStmt(Class, Loc) { + setLabelLoc(LabelLoc); + setLabelDecl(Target); + } - SourceLocation getContinueLoc() const { return ContinueStmtBits.ContinueLoc; } - void setContinueLoc(SourceLocation L) { ContinueStmtBits.ContinueLoc = L; } + LoopControlStmt(StmtClass Class, EmptyShell ES) : Stmt(Class, ES) {} - SourceLocation getBeginLoc() const { return getContinueLoc(); } - SourceLocation getEndLoc() const { return getContinueLoc(); } +public: + SourceLocation getKwLoc() const { return LoopControlStmtBits.KwLoc; } + void setKwLoc(SourceLocation L) { LoopControlStmtBits.KwLoc = L; } - static bool classof(const Stmt *T) { - return T->getStmtClass() == ContinueStmtClass; + SourceLocation getBeginLoc() const { return getKwLoc(); } + SourceLocation getEndLoc() const { + return isLabeled() ? getLabelLoc() : getKwLoc(); } + bool isLabeled() const { return TargetLabel != nullptr; } + + SourceLocation getLabelLoc() const { return Label; } + void setLabelLoc(SourceLocation L) { Label = L; } + + LabelDecl *getLabelDecl() const { return TargetLabel; } ---------------- AaronBallman wrote:
```suggestion const LabelDecl *getLabelDecl() const { return TargetLabel; } LabelDecl *getLabelDecl() { return TargetLabel; } ``` https://github.com/llvm/llvm-project/pull/152870 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits