================ @@ -3056,25 +3045,42 @@ class IndirectGotoStmt : public Stmt { } }; -/// ContinueStmt - This represents a continue. -class ContinueStmt : public Stmt { +/// 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); + } + + LoopControlStmt(StmtClass Class, EmptyShell ES) : Stmt(Class, ES) {} + public: - ContinueStmt(SourceLocation CL) : Stmt(ContinueStmtClass) { - setContinueLoc(CL); + SourceLocation getKwLoc() const { return LoopControlStmtBits.KwLoc; } + void setKwLoc(SourceLocation L) { LoopControlStmtBits.KwLoc = L; } + + SourceLocation getBeginLoc() const { return getKwLoc(); } + SourceLocation getEndLoc() const { + return isLabeled() ? getLabelLoc() : getKwLoc(); } - /// Build an empty continue statement. - explicit ContinueStmt(EmptyShell Empty) : Stmt(ContinueStmtClass, Empty) {} + bool isLabeled() const { return TargetLabel; } ---------------- shafik wrote:
I think I would prefer `TargetLabel != nullptr` so it is clear we are working w/ a pointer. 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