Lines Matching defs:Stmt

1 //===- Stmt.h - Classes for representing statements -------------*- C++ -*-===//
9 // This file defines the Stmt interface and subclasses.
82 /// Stmt - This represents one statement.
84 class alignas(void *) Stmt {
115 friend class Stmt;
864 /// Do we allocate an array? If so, the first trailing "Stmt *" is the
1309 /// Iterator for iterating over Stmt * arrays that contain only T *.
1311 /// This is needed because AST nodes use Stmt* arrays to store
1313 template<typename T, typename TPtr = T *, typename StmtPtr = Stmt *>
1327 /// Const iterator for iterating over Stmt * arrays that contain only T *.
1329 using ConstCastIterator = CastIterator<T, const T *const, const Stmt *const>;
1340 explicit Stmt(StmtClass SC, EmptyShell) : Stmt(SC) {}
1343 Stmt() = delete;
1344 Stmt(const Stmt &) = delete;
1345 Stmt(Stmt &&) = delete;
1346 Stmt &operator=(const Stmt &) = delete;
1347 Stmt &operator=(Stmt &&) = delete;
1349 Stmt(StmtClass SC) {
1351 "changing bitfields changed sizeof(Stmt)");
1355 if (StatisticsEnabled) Stmt::addStmtClass(SC);
1380 static Likelihood getLikelihood(const Stmt *S);
1383 static const Attr *getLikelihoodAttr(const Stmt *S);
1388 static Likelihood getLikelihood(const Stmt *Then, const Stmt *Else);
1392 /// the Attr's are the conflicting attributes of the Then and Else Stmt.
1394 determineLikelihoodConflict(const Stmt *Then, const Stmt *Else);
1424 /// viewAST - Visualize an AST rooted at this Stmt* using GraphViz. Only
1430 Stmt *IgnoreContainers(bool IgnoreCaptured = false);
1431 const Stmt *IgnoreContainers(bool IgnoreCaptured = false) const {
1432 return const_cast<Stmt *>(this)->IgnoreContainers(IgnoreCaptured);
1435 const Stmt *stripLabelLikeStatements() const;
1436 Stmt *stripLabelLikeStatements() {
1437 return const_cast<Stmt*>(
1438 const_cast<const Stmt*>(this)->stripLabelLikeStatements());
1453 auto Children = const_cast<Stmt *>(this)->children();
1497 class DeclStmt : public Stmt {
1503 : Stmt(DeclStmtClass), DG(dg), StartLoc(startLoc), EndLoc(endLoc) {}
1506 explicit DeclStmt(EmptyShell Empty) : Stmt(DeclStmtClass, Empty) {}
1525 static bool classof(const Stmt *T) {
1569 class NullStmt : public Stmt {
1572 : Stmt(NullStmtClass) {
1578 explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty) {}
1590 static bool classof(const Stmt *T) {
1605 : public Stmt,
1606 private llvm::TrailingObjects<CompoundStmt, Stmt *, FPOptionsOverride> {
1616 CompoundStmt(ArrayRef<Stmt *> Stmts, FPOptionsOverride FPFeatures,
1618 explicit CompoundStmt(EmptyShell Empty) : Stmt(CompoundStmtClass, Empty) {}
1620 void setStmts(ArrayRef<Stmt *> Stmts);
1628 size_t numTrailingObjects(OverloadToken<Stmt *>) const {
1633 static CompoundStmt *Create(const ASTContext &C, ArrayRef<Stmt *> Stmts,
1641 : Stmt(CompoundStmtClass), LBraceLoc(Loc), RBraceLoc(EndLoc) {
1666 using body_iterator = Stmt **;
1670 body_iterator body_begin() { return getTrailingObjects<Stmt *>(); }
1672 Stmt *body_front() { return !body_empty() ? body_begin()[0] : nullptr; }
1674 Stmt *body_back() {
1678 using const_body_iterator = Stmt *const *;
1686 return getTrailingObjects<Stmt *>();
1691 const Stmt *body_front() const {
1695 const Stmt *body_back() const {
1720 // Get the Stmt that StmtExpr would consider to be the result of this
1727 // Stmt.
1728 Stmt *getStmtExprResult() {
1736 const Stmt *getStmtExprResult() const {
1746 static bool classof(const Stmt *T) {
1759 class SwitchCase : public Stmt {
1772 : Stmt(SC), ColonLoc(ColonLoc) {
1776 SwitchCase(StmtClass SC, EmptyShell) : Stmt(SC) {}
1788 inline Stmt *getSubStmt();
1789 const Stmt *getSubStmt() const {
1796 static bool classof(const Stmt *T) {
1806 private llvm::TrailingObjects<CaseStmt, Stmt *, SourceLocation> {
1814 // * A "Stmt *" for the LHS of the case statement. Always present.
1816 // * A "Stmt *" for the RHS of the case statement. This is a GNU extension
1820 // * A "Stmt *" for the substatement of the case statement. Always present.
1827 unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
1894 return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[lhsOffset()]);
1898 return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[lhsOffset()]);
1902 getTrailingObjects<Stmt *>()[lhsOffset()] = reinterpret_cast<Stmt *>(Val);
1907 getTrailingObjects<Stmt *>()[rhsOffset()])
1913 getTrailingObjects<Stmt *>()[rhsOffset()])
1920 getTrailingObjects<Stmt *>()[rhsOffset()] = reinterpret_cast<Stmt *>(Val);
1923 Stmt *getSubStmt() { return getTrailingObjects<Stmt *>()[subStmtOffset()]; }
1924 const Stmt *getSubStmt() const {
1925 return getTrailingObjects<Stmt *>()[subStmtOffset()];
1928 void setSubStmt(Stmt *S) {
1929 getTrailingObjects<Stmt *>()[subStmtOffset()] = S;
1942 static bool classof(const Stmt *T) {
1948 return child_range(getTrailingObjects<Stmt *>(),
1949 getTrailingObjects<Stmt *>() +
1950 numTrailingObjects(OverloadToken<Stmt *>()));
1954 return const_child_range(getTrailingObjects<Stmt *>(),
1955 getTrailingObjects<Stmt *>() +
1956 numTrailingObjects(OverloadToken<Stmt *>()));
1961 Stmt *SubStmt;
1964 DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt)
1971 Stmt *getSubStmt() { return SubStmt; }
1972 const Stmt *getSubStmt() const { return SubStmt; }
1973 void setSubStmt(Stmt *S) { SubStmt = S; }
1983 static bool classof(const Stmt *T) {
2003 Stmt *SwitchCase::getSubStmt() {
2017 class ValueStmt : public Stmt {
2019 using Stmt::Stmt;
2028 static bool classof(const Stmt *T) {
2038 Stmt *SubStmt;
2043 LabelStmt(SourceLocation IL, LabelDecl *D, Stmt *substmt)
2058 Stmt *getSubStmt() { return SubStmt; }
2060 const Stmt *getSubStmt() const { return SubStmt; }
2061 void setSubStmt(Stmt *SS) { SubStmt = SS; }
2072 static bool classof(const Stmt *T) {
2089 Stmt *SubStmt;
2092 Stmt *SubStmt)
2113 ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
2123 Stmt *getSubStmt() { return SubStmt; }
2124 const Stmt *getSubStmt() const { return SubStmt; }
2135 static bool classof(const Stmt *T) {
2142 : public Stmt,
2143 private llvm::TrailingObjects<IfStmt, Stmt *, SourceLocation> {
2151 // * A "Stmt *" for the init statement.
2154 // * A "Stmt *" for the condition variable.
2157 // * A "Stmt *" for the condition.
2160 // * A "Stmt *" for the then statement.
2163 // * A "Stmt *" for the else statement.
2173 unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
2192 Stmt *Init, VarDecl *Var, Expr *Cond, SourceLocation LParenLoc,
2193 SourceLocation RParenLoc, Stmt *Then, SourceLocation EL, Stmt *Else);
2201 IfStatementKind Kind, Stmt *Init, VarDecl *Var,
2203 Stmt *Then, SourceLocation EL = SourceLocation(),
2204 Stmt *Else = nullptr);
2221 return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
2225 return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
2229 getTrailingObjects<Stmt *>()[condOffset()] = reinterpret_cast<Stmt *>(Cond);
2232 Stmt *getThen() { return getTrailingObjects<Stmt *>()[thenOffset()]; }
2233 const Stmt *getThen() const {
2234 return getTrailingObjects<Stmt *>()[thenOffset()];
2237 void setThen(Stmt *Then) {
2238 getTrailingObjects<Stmt *>()[thenOffset()] = Then;
2241 Stmt *getElse() {
2242 return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
2246 const Stmt *getElse() const {
2247 return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
2251 void setElse(Stmt *Else) {
2254 getTrailingObjects<Stmt *>()[elseOffset()] = Else;
2278 getTrailingObjects<Stmt *>()[varOffset()])
2284 getTrailingObjects<Stmt *>()[varOffset()])
2290 getTrailingObjects<Stmt *>()[varOffset()] = CondVar;
2293 Stmt *getInit() {
2294 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2298 const Stmt *getInit() const {
2299 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2303 void setInit(Stmt *Init) {
2306 getTrailingObjects<Stmt *>()[initOffset()] = Init;
2350 std::optional<const Stmt *> getNondiscardedCase(const ASTContext &Ctx) const;
2351 std::optional<Stmt *> getNondiscardedCase(const ASTContext &Ctx);
2371 return child_range(getTrailingObjects<Stmt *>() +
2373 getTrailingObjects<Stmt *>() +
2374 numTrailingObjects(OverloadToken<Stmt *>()));
2380 return const_child_range(getTrailingObjects<Stmt *>() +
2382 getTrailingObjects<Stmt *>() +
2383 numTrailingObjects(OverloadToken<Stmt *>()));
2386 static bool classof(const Stmt *T) {
2392 class SwitchStmt final : public Stmt,
2393 private llvm::TrailingObjects<SwitchStmt, Stmt *> {
2405 // * A "Stmt *" for the init statement.
2408 // * A "Stmt *" for the condition variable.
2411 // * A "Stmt *" for the condition.
2414 // * A "Stmt *" for the body.
2421 unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
2433 SwitchStmt(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, Expr *Cond,
2441 static SwitchStmt *Create(const ASTContext &Ctx, Stmt *Init, VarDecl *Var,
2457 return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
2461 return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
2465 getTrailingObjects<Stmt *>()[condOffset()] = reinterpret_cast<Stmt *>(Cond);
2468 Stmt *getBody() { return getTrailingObjects<Stmt *>()[bodyOffset()]; }
2469 const Stmt *getBody() const {
2470 return getTrailingObjects<Stmt *>()[bodyOffset()];
2473 void setBody(Stmt *Body) {
2474 getTrailingObjects<Stmt *>()[bodyOffset()] = Body;
2477 Stmt *getInit() {
2478 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2482 const Stmt *getInit() const {
2483 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2487 void setInit(Stmt *Init) {
2490 getTrailingObjects<Stmt *>()[initOffset()] = Init;
2515 getTrailingObjects<Stmt *>()[varOffset()])
2521 getTrailingObjects<Stmt *>()[varOffset()])
2527 getTrailingObjects<Stmt *>()[varOffset()] = CondVar;
2541 void setBody(Stmt *S, SourceLocation SL) {
2566 : reinterpret_cast<const Stmt *>(getCond())->getEndLoc();
2571 return child_range(getTrailingObjects<Stmt *>(),
2572 getTrailingObjects<Stmt *>() +
2573 numTrailingObjects(OverloadToken<Stmt *>()));
2577 return const_child_range(getTrailingObjects<Stmt *>(),
2578 getTrailingObjects<Stmt *>() +
2579 numTrailingObjects(OverloadToken<Stmt *>()));
2582 static bool classof(const Stmt *T) {
2588 class WhileStmt final : public Stmt,
2589 private llvm::TrailingObjects<WhileStmt, Stmt *> {
2598 // * A "Stmt *" for the condition variable.
2601 // * A "Stmt *" for the condition.
2604 // * A "Stmt *" for the body.
2616 unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
2621 WhileStmt(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, Stmt *Body,
2631 Stmt *Body, SourceLocation WL,
2642 return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
2646 return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
2650 getTrailingObjects<Stmt *>()[condOffset()] = reinterpret_cast<Stmt *>(Cond);
2653 Stmt *getBody() { return getTrailingObjects<Stmt *>()[bodyOffset()]; }
2654 const Stmt *getBody() const {
2655 return getTrailingObjects<Stmt *>()[bodyOffset()];
2658 void setBody(Stmt *Body) {
2659 getTrailingObjects<Stmt *>()[bodyOffset()] = Body;
2683 getTrailingObjects<Stmt *>()[varOffset()])
2689 getTrailingObjects<Stmt *>()[varOffset()])
2695 getTrailingObjects<Stmt *>()[varOffset()] = CondVar;
2711 static bool classof(const Stmt *T) {
2717 return child_range(getTrailingObjects<Stmt *>(),
2718 getTrailingObjects<Stmt *>() +
2719 numTrailingObjects(OverloadToken<Stmt *>()));
2723 return const_child_range(getTrailingObjects<Stmt *>(),
2724 getTrailingObjects<Stmt *>() +
2725 numTrailingObjects(OverloadToken<Stmt *>()));
2730 class DoStmt : public Stmt {
2732 Stmt *SubExprs[END_EXPR];
2737 DoStmt(Stmt *Body, Expr *Cond, SourceLocation DL, SourceLocation WL,
2739 : Stmt(DoStmtClass), WhileLoc(WL), RParenLoc(RP) {
2746 explicit DoStmt(EmptyShell Empty) : Stmt(DoStmtClass, Empty) {}
2753 void setCond(Expr *Cond) { SubExprs[COND] = reinterpret_cast<Stmt *>(Cond); }
2755 Stmt *getBody() { return SubExprs[BODY]; }
2756 const Stmt *getBody() const { return SubExprs[BODY]; }
2757 void setBody(Stmt *Body) { SubExprs[BODY] = Body; }
2769 static bool classof(const Stmt *T) {
2786 class ForStmt : public Stmt {
2790 Stmt* SubExprs[END_EXPR]; // SubExprs[INIT] is an expression or declstmt.
2794 ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar,
2795 Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP,
2799 explicit ForStmt(EmptyShell Empty) : Stmt(ForStmtClass, Empty) {}
2801 Stmt *getInit() { return SubExprs[INIT]; }
2830 Stmt *getBody() { return SubExprs[BODY]; }
2832 const Stmt *getInit() const { return SubExprs[INIT]; }
2835 const Stmt *getBody() const { return SubExprs[BODY]; }
2837 void setInit(Stmt *S) { SubExprs[INIT] = S; }
2838 void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
2839 void setInc(Expr *E) { SubExprs[INC] = reinterpret_cast<Stmt*>(E); }
2840 void setBody(Stmt *S) { SubExprs[BODY] = S; }
2852 static bool classof(const Stmt *T) {
2867 class GotoStmt : public Stmt {
2873 : Stmt(GotoStmtClass), Label(label), LabelLoc(LL) {
2878 explicit GotoStmt(EmptyShell Empty) : Stmt(GotoStmtClass, Empty) {}
2891 static bool classof(const Stmt *T) {
2906 class IndirectGotoStmt : public Stmt {
2908 Stmt *Target;
2912 : Stmt(IndirectGotoStmtClass), StarLoc(starLoc) {
2919 : Stmt(IndirectGotoStmtClass, Empty) {}
2930 void setTarget(Expr *E) { Target = reinterpret_cast<Stmt *>(E); }
2942 static bool classof(const Stmt *T) {
2955 class ContinueStmt : public Stmt {
2957 ContinueStmt(SourceLocation CL) : Stmt(ContinueStmtClass) {
2962 explicit ContinueStmt(EmptyShell Empty) : Stmt(ContinueStmtClass, Empty) {}
2970 static bool classof(const Stmt *T) {
2985 class BreakStmt : public Stmt {
2987 BreakStmt(SourceLocation BL) : Stmt(BreakStmtClass) {
2992 explicit BreakStmt(EmptyShell Empty) : Stmt(BreakStmtClass, Empty) {}
3000 static bool classof(const Stmt *T) {
3023 : public Stmt,
3028 Stmt *RetExpr;
3057 void setRetValue(Expr *E) { RetExpr = reinterpret_cast<Stmt *>(E); }
3086 static bool classof(const Stmt *T) {
3105 class AsmStmt : public Stmt {
3123 Stmt **Exprs = nullptr;
3127 : Stmt (SC), AsmLoc(asmloc), IsSimple(issimple), IsVolatile(isvolatile),
3133 explicit AsmStmt(StmtClass SC, EmptyShell Empty) : Stmt(SC, Empty) {}
3189 static bool classof(const Stmt *T) {
3456 Stmt **Exprs,
3481 static bool classof(const Stmt *T) {
3578 static bool classof(const Stmt *T) {
3591 class SEHExceptStmt : public Stmt {
3596 Stmt *Children[2];
3600 SEHExceptStmt(SourceLocation Loc, Expr *FilterExpr, Stmt *Block);
3601 explicit SEHExceptStmt(EmptyShell E) : Stmt(SEHExceptStmtClass, E) {}
3607 Stmt *Block);
3630 static bool classof(const Stmt *T) {
3635 class SEHFinallyStmt : public Stmt {
3640 Stmt *Block;
3642 SEHFinallyStmt(SourceLocation Loc, Stmt *Block);
3643 explicit SEHFinallyStmt(EmptyShell E) : Stmt(SEHFinallyStmtClass, E) {}
3648 Stmt *Block);
3665 static bool classof(const Stmt *T) {
3670 class SEHTryStmt : public Stmt {
3676 Stmt *Children[2];
3682 Stmt *TryBlock,
3683 Stmt *Handler);
3685 explicit SEHTryStmt(EmptyShell E) : Stmt(SEHTryStmtClass, E) {}
3689 SourceLocation TryLoc, Stmt *TryBlock,
3690 Stmt *Handler);
3703 Stmt *getHandler() const { return Children[HANDLER]; }
3717 static bool classof(const Stmt *T) {
3723 class SEHLeaveStmt : public Stmt {
3728 : Stmt(SEHLeaveStmtClass), LeaveLoc(LL) {}
3731 explicit SEHLeaveStmt(EmptyShell Empty) : Stmt(SEHLeaveStmtClass, Empty) {}
3739 static bool classof(const Stmt *T) {
3762 class CapturedStmt : public Stmt {
3837 CapturedStmt(Stmt *S, CapturedRegionKind Kind, ArrayRef<Capture> Captures,
3843 Stmt **getStoredStmts() { return reinterpret_cast<Stmt **>(this + 1); }
3845 Stmt *const *getStoredStmts() const {
3846 return reinterpret_cast<Stmt *const *>(this + 1);
3851 void setCapturedStmt(Stmt *S) { getStoredStmts()[NumCaptures] = S; }
3856 static CapturedStmt *Create(const ASTContext &Context, Stmt *S,
3866 Stmt *getCapturedStmt() { return getStoredStmts()[NumCaptures]; }
3867 const Stmt *getCapturedStmt() const { return getStoredStmts()[NumCaptures]; }
3969 static bool classof(const Stmt *T) {