Home | History | Annotate | Download | only in AST

Lines Matching refs:STMT

1 //===--- Stmt.h - Classes for representing statements -----------*- C++ -*-===//
10 // This file defines the Stmt interface and subclasses.
45 // ExprIterator - Iterators for iterating over Stmt* arrays that contain
46 // only Expr*. This is needed because AST nodes use Stmt* arrays to store
50 class Stmt;
54 Stmt** I;
56 ExprIterator(Stmt** i) : I(i) {}
73 const Stmt * const *I;
75 ConstExprIterator(const Stmt * const *i) : I(i) {}
94 /// Stmt - This represents one statement.
96 class Stmt {
100 #define STMT(CLASS, PARENT) CLASS##Class,
105 #define ABSTRACT_STMT(STMT)
119 friend class Stmt;
333 explicit Stmt(StmtClass SC, EmptyShell) {
335 if (StatisticsEnabled) Stmt::addStmtClass(SC);
339 Stmt(StmtClass SC) {
341 if (StatisticsEnabled) Stmt::addStmtClass(SC);
385 /// viewAST - Visualize an AST rooted at this Stmt* using GraphViz. Only
391 Stmt *IgnoreImplicit();
393 const Stmt *stripLabelLikeStatements() const;
394 Stmt *stripLabelLikeStatements() {
395 return const_cast<Stmt*>(
396 const_cast<const Stmt*>(this)->stripLabelLikeStatements());
400 static bool classof(const Stmt *) { return true; }
420 return const_cast<Stmt*>(this)->children();
450 class DeclStmt : public Stmt {
456 SourceLocation endLoc) : Stmt(DeclStmtClass), DG(dg),
460 explicit DeclStmt(EmptyShell Empty) : Stmt(DeclStmtClass, Empty) { }
484 static bool classof(const Stmt *T) {
506 class NullStmt : public Stmt {
517 : Stmt(NullStmtClass), SemiLoc(L),
521 explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty),
531 static bool classof(const Stmt *T) {
542 /// CompoundStmt - This represents a group of statements like { stmt stmt }.
544 class CompoundStmt : public Stmt {
545 Stmt** Body;
548 CompoundStmt(ASTContext& C, Stmt **StmtStart, unsigned NumStmts,
550 : Stmt(CompoundStmtClass), LBracLoc(LB), RBracLoc(RB) {
560 Body = new (C) Stmt*[NumStmts];
566 : Stmt(CompoundStmtClass, Empty), Body(0) {
570 void setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts);
575 typedef Stmt** body_iterator;
578 Stmt *body_back() { return !body_empty() ? Body[size()-1] : 0; }
580 void setLastStmt(Stmt *S) {
585 typedef Stmt* const * const_body_iterator;
588 const Stmt *body_back() const { return !body_empty() ? Body[size()-1] : 0; }
618 static bool classof(const Stmt *T) {
634 class SwitchCase : public Stmt {
640 SwitchCase(StmtClass SC) : Stmt(SC), NextSwitchCase(0) {}
649 Stmt *getSubStmt();
650 const Stmt *getSubStmt() const {
656 static bool classof(const Stmt *T) {
665 Stmt* SubExprs[END_EXPR]; // The expression for the RHS is Non-null for
675 SubExprs[LHS] = reinterpret_cast<Stmt*>(lhs);
676 SubExprs[RHS] = reinterpret_cast<Stmt*>(rhs);
694 Stmt *getSubStmt() { return SubExprs[SUBSTMT]; }
702 const Stmt *getSubStmt() const { return SubExprs[SUBSTMT]; }
704 void setSubStmt(Stmt *S) { SubExprs[SUBSTMT] = S; }
705 void setLHS(Expr *Val) { SubExprs[LHS] = reinterpret_cast<Stmt*>(Val); }
706 void setRHS(Expr *Val) { SubExprs[RHS] = reinterpret_cast<Stmt*>(Val); }
717 static bool classof(const Stmt *T) {
729 Stmt* SubStmt;
733 DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt) :
740 Stmt *getSubStmt() { return SubStmt; }
741 const Stmt *getSubStmt() const { return SubStmt; }
742 void setSubStmt(Stmt *S) { SubStmt = S; }
752 static bool classof(const Stmt *T) {
765 class LabelStmt : public Stmt {
767 Stmt *SubStmt;
770 LabelStmt(SourceLocation IL, LabelDecl *D, Stmt *substmt)
771 : Stmt(LabelStmtClass), TheDecl(D), SubStmt(substmt), IdentLoc(IL) {
775 explicit LabelStmt(EmptyShell Empty) : Stmt(LabelStmtClass, Empty) { }
781 Stmt *getSubStmt() { return SubStmt; }
782 const Stmt *getSubStmt() const { return SubStmt; }
784 void setSubStmt(Stmt *SS) { SubStmt = SS; }
791 static bool classof(const Stmt *T) {
803 class AttributedStmt : public Stmt {
804 Stmt *SubStmt;
813 AttributedStmt(SourceLocation loc, const AttrVec &attrs, Stmt *substmt)
814 : Stmt(AttributedStmtClass), SubStmt(substmt), AttrLoc(loc), Attrs(attrs) {
819 : Stmt(AttributedStmtClass, Empty) {
824 Stmt *getSubStmt() { return SubStmt; }
825 const Stmt *getSubStmt() const { return SubStmt; }
832 static bool classof(const Stmt *T) {
841 class IfStmt : public Stmt {
843 Stmt* SubExprs[END_EXPR];
850 Stmt *then, SourceLocation EL = SourceLocation(), Stmt *elsev = 0);
853 explicit IfStmt(EmptyShell Empty) : Stmt(IfStmtClass, Empty) { }
873 void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt *>(E); }
874 const Stmt *getThen() const { return SubExprs[THEN]; }
875 void setThen(Stmt *S) { SubExprs[THEN] = S; }
876 const Stmt *getElse() const { return SubExprs[ELSE]; }
877 void setElse(Stmt *S) { SubExprs[ELSE] = S; }
880 Stmt *getThen() { return SubExprs[THEN]; }
881 Stmt *getElse() { return SubExprs[ELSE]; }
901 static bool classof(const Stmt *T) {
907 /// SwitchStmt - This represents a 'switch' stmt.
909 class SwitchStmt : public Stmt {
911 Stmt* SubExprs[END_EXPR];
925 explicit SwitchStmt(EmptyShell Empty) : Stmt(SwitchStmtClass, Empty) { }
946 const Stmt *getBody() const { return SubExprs[BODY]; }
950 void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt *>(E); }
951 Stmt *getBody() { return SubExprs[BODY]; }
952 void setBody(Stmt *S) { SubExprs[BODY] = S; }
964 void setBody(Stmt *S, SourceLocation SL) {
995 static bool classof(const Stmt *T) {
1002 /// WhileStmt - This represents a 'while' stmt.
1004 class WhileStmt : public Stmt {
1006 Stmt* SubExprs[END_EXPR];
1009 WhileStmt(ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body,
1013 explicit WhileStmt(EmptyShell Empty) : Stmt(WhileStmtClass, Empty) { }
1034 void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
1035 Stmt *getBody() { return SubExprs[BODY]; }
1036 const Stmt *getBody() const { return SubExprs[BODY]; }
1037 void setBody(Stmt *S) { SubExprs[BODY] = S; }
1045 static bool classof(const Stmt *T) {
1056 /// DoStmt - This represents a 'do/while' stmt.
1058 class DoStmt : public Stmt {
1060 Stmt* SubExprs[END_EXPR];
1063 SourceLocation RParenLoc; // Location of final ')' in do stmt condition.
1066 DoStmt(Stmt *body, Expr *cond, SourceLocation DL, SourceLocation WL,
1068 : Stmt(DoStmtClass), DoLoc(DL), WhileLoc(WL), RParenLoc(RP) {
1069 SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
1074 explicit DoStmt(EmptyShell Empty) : Stmt(DoStmtClass, Empty) { }
1078 void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
1079 Stmt *getBody() { return SubExprs[BODY]; }
1080 const Stmt *getBody() const { return SubExprs[BODY]; }
1081 void setBody(Stmt *S) { SubExprs[BODY] = S; }
1094 static bool classof(const Stmt *T) {
1106 /// ForStmt - This represents a 'for (init;cond;inc)' stmt. Note that any of
1110 class ForStmt : public Stmt {
1112 Stmt* SubExprs[END_EXPR]; // SubExprs[INIT] is an expression or declstmt.
1117 ForStmt(ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, Expr *Inc,
1118 Stmt *Body, SourceLocation FL, SourceLocation LP, SourceLocation RP);
1121 explicit ForStmt(EmptyShell Empty) : Stmt(ForStmtClass, Empty) { }
1123 Stmt *getInit() { return SubExprs[INIT]; }
1144 Stmt *getBody() { return SubExprs[BODY]; }
1146 const Stmt *getInit() const { return SubExprs[INIT]; }
1149 const Stmt *getBody() const { return SubExprs[BODY]; }
1151 void setInit(Stmt *S) { SubExprs[INIT] = S; }
1152 void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
1153 void setInc(Expr *E) { SubExprs[INC] = reinterpret_cast<Stmt*>(E); }
1154 void setBody(Stmt *S) { SubExprs[BODY] = S; }
1166 static bool classof(const Stmt *T) {
1179 class GotoStmt : public Stmt {
1185 : Stmt(GotoStmtClass), Label(label), GotoLoc(GL), LabelLoc(LL) {}
1188 explicit GotoStmt(EmptyShell Empty) : Stmt(GotoStmtClass, Empty) { }
1201 static bool classof(const Stmt *T) {
1212 class IndirectGotoStmt : public Stmt {
1215 Stmt *Target;
1219 : Stmt(IndirectGotoStmtClass), GotoLoc(gotoLoc), StarLoc(starLoc),
1220 Target((Stmt*)target) {}
1224 : Stmt(IndirectGotoStmtClass, Empty) { }
1233 void setTarget(Expr *E) { Target = reinterpret_cast<Stmt*>(E); }
1246 static bool classof(const Stmt *T) {
1258 class ContinueStmt : public Stmt {
1261 ContinueStmt(SourceLocation CL) : Stmt(ContinueStmtClass), ContinueLoc(CL) {}
1264 explicit ContinueStmt(EmptyShell Empty) : Stmt(ContinueStmtClass, Empty) { }
1273 static bool classof(const Stmt *T) {
1284 class BreakStmt : public Stmt {
1287 BreakStmt(SourceLocation BL) : Stmt(BreakStmtClass), BreakLoc(BL) {}
1290 explicit BreakStmt(EmptyShell Empty) : Stmt(BreakStmtClass, Empty) { }
1297 static bool classof(const Stmt *T) {
1316 class ReturnStmt : public Stmt {
1317 Stmt *RetExpr;
1323 : Stmt(ReturnStmtClass), RetExpr(0), RetLoc(RL), NRVOCandidate(0) { }
1326 : Stmt(ReturnStmtClass), RetExpr((Stmt*) E), RetLoc(RL),
1330 explicit ReturnStmt(EmptyShell Empty) : Stmt(ReturnStmtClass, Empty) { }
1334 void setRetValue(Expr *E) { RetExpr = reinterpret_cast<Stmt*>(E); }
1349 static bool classof(const Stmt *T) {
1363 class AsmStmt : public Stmt {
1378 Stmt **Exprs;
1389 explicit AsmStmt(EmptyShell Empty) : Stmt(AsmStmtClass, Empty),
1540 Stmt **Exprs,
1561 static bool classof(const Stmt *T) {return T->getStmtClass() == AsmStmtClass;}
1609 class SEHExceptStmt : public Stmt {
1611 Stmt *Children[2];
1617 Stmt *Block);
1621 explicit SEHExceptStmt(EmptyShell E) : Stmt(SEHExceptStmtClass, E) { }
1627 Stmt *Block);
1647 static bool classof(const Stmt *T) {
1655 class SEHFinallyStmt : public Stmt {
1657 Stmt *Block;
1660 Stmt *Block);
1664 explicit SEHFinallyStmt(EmptyShell E) : Stmt(SEHFinallyStmtClass, E) { }
1669 Stmt *Block);
1684 static bool classof(const Stmt *T) {
1692 class SEHTryStmt : public Stmt {
1695 Stmt *Children[2];
1701 Stmt *TryBlock,
1702 Stmt *Handler);
1706 explicit SEHTryStmt(EmptyShell E) : Stmt(SEHTryStmtClass, E) { }
1712 Stmt *TryBlock,
1713 Stmt *Handler);
1728 Stmt *getHandler() const { return Children[HANDLER]; }
1738 static bool classof(const Stmt *T) {