@@ -2409,6 +2409,61 @@ class IfStmt final
24092409 }
24102410};
24112411
2412+ // / WhenStmt - This represents a '_When' stmt.
2413+ class WhenStmt : public Stmt , private llvm ::TrailingObjects<WhenStmt, Stmt *> {
2414+ SourceLocation WhenLoc;
2415+ Expr *Condition;
2416+ bool IsAccept;
2417+ IdentifierInfo *VarName;
2418+ Stmt *Body;
2419+
2420+ /*
2421+ * WhenStmt is followed by several trailing objects, some of which optional.
2422+ * Note that it would be more convenient to put the optional trailing objects
2423+ * at the end but this would change the order in children().
2424+ * The trailing objects are in order:
2425+ *
2426+ * * A "Stmt *" for the condition.
2427+ * Always present. This is in fact an "Expr *".
2428+ *
2429+ * * A "Stmt *" for the body.
2430+ * Always present.
2431+ */
2432+ enum {
2433+ NumMandatoryStmtPtr = 2
2434+ };
2435+
2436+ public:
2437+ // WhenStmt(SourceLocation Loc, Expr *Cond, bool Accept, IdentifierInfo *Var, Stmt *BodyStmt)
2438+ WhenStmt (SourceLocation Loc, Expr *Cond, Stmt *BodyStmt)
2439+ : Stmt(Stmt::WhenStmtClass), WhenLoc(Loc), Condition(Cond),
2440+ Body (BodyStmt) {}
2441+ // IsAccept(Accept), VarName(Var), Body(BodyStmt) {}
2442+
2443+ explicit WhenStmt (EmptyShell Empty)
2444+ : Stmt(Stmt::WhenStmtClass) {}
2445+
2446+ // static WhenStmt* Create(const ASTContext &Ctx, SourceLocation Loc, Expr *Cond, bool Accept, IdentifierInfo *Var, Stmt *BodyStmt);
2447+ static WhenStmt* Create (const ASTContext &Ctx, SourceLocation Loc, Expr *Cond, Stmt *BodyStmt);
2448+ static WhenStmt* CreateEmpty (const ASTContext &Ctx);
2449+
2450+ SourceLocation getBeginLoc () const { return WhenLoc; }
2451+ SourceLocation getEndLoc () const { return Body ? Body->getEndLoc () : WhenLoc; }
2452+ child_range children () { return child_range (&Body, &Body + 1 ); }
2453+ static bool classof (const Stmt *S) { return S->getStmtClass () == WhenStmtClass; }
2454+
2455+ bool isAccept () const { return IsAccept; }
2456+ IdentifierInfo *getVarName () const { return VarName; }
2457+ Expr *getCondition () const { return Condition; }
2458+ void setCondition (Expr *Cond) { Condition = Cond; }
2459+ Stmt *getBody () const { return Body; }
2460+ void setBody (Stmt *B) { Body = B; }
2461+
2462+ SourceLocation getWhenLoc () const { return WhenLoc; }
2463+ SourceLocation setWhenLoc (SourceLocation Loc) { return WhenLoc = Loc; }
2464+
2465+ };
2466+
24122467// / SwitchStmt - This represents a 'switch' stmt.
24132468class SwitchStmt final : public Stmt,
24142469 private llvm::TrailingObjects<SwitchStmt, Stmt *> {
0 commit comments