Lines Matching defs:STMT
1 //===--- Stmt.cpp - Statement AST Node Implementation ---------------------===//
10 // This file implements the Stmt class and statement subclasses.
18 #include "clang/AST/Stmt.h"
33 } StmtClassInfo[Stmt::lastStmtConstant+1];
35 static StmtClassNameTable &getStmtInfoTableEntry(Stmt::StmtClass E) {
42 #define ABSTRACT_STMT(STMT)
43 #define STMT(CLASS, PARENT) \
44 StmtClassInfo[(unsigned)Stmt::CLASS##Class].Name = #CLASS; \
45 StmtClassInfo[(unsigned)Stmt::CLASS##Class].Size = sizeof(CLASS);
51 void *Stmt::operator new(size_t bytes, ASTContext& C,
56 void *Stmt::operator new(size_t bytes, ASTContext* C,
61 const char *Stmt::getStmtClassName() const {
65 void Stmt::PrintStats() {
67 getStmtInfoTableEntry(Stmt::NullStmtClass);
70 llvm::errs() << "\n*** Stmt/Expr Stats:\n";
71 for (int i = 0; i != Stmt::lastStmtConstant+1; i++) {
77 for (int i = 0; i != Stmt::lastStmtConstant+1; i++) {
90 void Stmt::addStmtClass(StmtClass s) {
94 bool Stmt::StatisticsEnabled = false;
95 void Stmt::EnableStatistics() {
99 Stmt *Stmt::IgnoreImplicit() {
100 Stmt *s = this;
115 const Stmt *Stmt::stripLabelLikeStatements() const {
116 const Stmt *S = this;
138 typedef Stmt::child_range children_t();
142 static inline bad implements_children(children_t Stmt::*) {
150 static inline bad implements_getLocStart(getLocStart_t Stmt::*) {
158 static inline bad implements_getLocEnd(getLocEnd_t Stmt::*) {
170 /// Check whether the various Stmt classes implement their member
174 #define STMT(type, base) \
181 Stmt::child_range Stmt::children() {
183 case Stmt::NoStmtClass: llvm_unreachable("statement without class");
185 #define STMT(type, base) \
186 case Stmt::type##Class: \
201 SourceRange getSourceRangeImpl(const Stmt *stmt,
203 return static_cast<const S*>(stmt)->getSourceRange();
211 SourceRange getSourceRangeImpl(const Stmt *stmt,
212 SourceRange (Stmt::*v)() const) {
213 return SourceRange(static_cast<const S*>(stmt)->getLocStart(),
214 static_cast<const S*>(stmt)->getLocEnd());
218 SourceRange Stmt::getSourceRange() const {
220 case Stmt::NoStmtClass: llvm_unreachable("statement without class");
222 #define STMT(type, base) \
223 case Stmt::type##Class: \
230 SourceLocation Stmt::getLocStart() const {
233 case Stmt::NoStmtClass: llvm_unreachable("statement without class");
235 #define STMT(type, base) \
236 case Stmt::type##Class: \
243 SourceLocation Stmt::getLocEnd() const {
245 case Stmt::NoStmtClass: llvm_unreachable("statement without class");
247 #define STMT(type, base) \
248 case Stmt::type##Class: \
255 CompoundStmt::CompoundStmt(ASTContext &C, ArrayRef<Stmt*> Stmts,
257 : Stmt(CompoundStmtClass), LBracLoc(LB), RBracLoc(RB) {
267 Body = new (C) Stmt*[Stmts.size()];
271 void CompoundStmt::setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts) {
276 Body = new (C) Stmt*[NumStmts];
277 memcpy(Body, Stmts, sizeof(Stmt *) * NumStmts);
286 Stmt *SubStmt) {
301 bool Stmt::hasImplicitControlFlow() const {
313 case Stmt::BinaryOperatorClass: {
412 Stmt **Exprs,
428 this->Exprs = new (C) Stmt*[NumExprs];
663 Exprs = new (C) Stmt*[NumExprs];
690 Exprs = new (C) Stmt*[NumExprs];
716 ObjCForCollectionStmt::ObjCForCollectionStmt(Stmt *Elem, Expr *Collect,
717 Stmt *Body, SourceLocation FCL,
719 : Stmt(ObjCForCollectionStmtClass) {
721 SubExprs[COLLECTION] = reinterpret_cast<Stmt*>(Collect);
727 ObjCAtTryStmt::ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt,
728 Stmt **CatchStmts, unsigned NumCatchStmts,
729 Stmt *atFinallyStmt)
730 : Stmt(ObjCAtTryStmtClass), AtTryLoc(atTryLoc),
733 Stmt **Stmts = getStmts();
744 Stmt *atTryStmt,
745 Stmt **CatchStmts,
747 Stmt *atFinallyStmt) {
749 (1 + NumCatchStmts + (atFinallyStmt != 0)) * sizeof(Stmt *);
759 (1 + NumCatchStmts + HasFinally) * sizeof(Stmt *);
773 Stmt *tryBlock, ArrayRef<Stmt*> handlers) {
775 Size += ((handlers.size() + 1) * sizeof(Stmt));
784 Size += ((numHandlers + 1) * sizeof(Stmt));
790 CXXTryStmt::CXXTryStmt(SourceLocation tryLoc, Stmt *tryBlock,
791 ArrayRef<Stmt*> handlers)
792 : Stmt(CXXTryStmtClass), TryLoc(tryLoc), NumHandlers(handlers.size()) {
793 Stmt **Stmts = reinterpret_cast<Stmt **>(this + 1);
800 Stmt *Body, SourceLocation FL,
802 : Stmt(CXXForRangeStmtClass), ForLoc(FL), ColonLoc(CL), RParenLoc(RPL) {
805 SubExprs[COND] = reinterpret_cast<Stmt*>(Cond);
806 SubExprs[INC] = reinterpret_cast<Stmt*>(Inc);
833 Stmt *then, SourceLocation EL, Stmt *elsev)
834 : Stmt(IfStmtClass), IfLoc(IL), ElseLoc(EL)
837 SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
861 ForStmt::ForStmt(ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar,
862 Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP,
864 : Stmt(ForStmtClass), ForLoc(FL), LParenLoc(LP), RParenLoc(RP)
868 SubExprs[COND] = reinterpret_cast<Stmt*>(Cond);
869 SubExprs[INC] = reinterpret_cast<Stmt*>(Inc);
893 : Stmt(SwitchStmtClass), FirstCase(0), AllEnumCasesCovered(0)
896 SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
919 Stmt *SwitchCase::getSubStmt() {
925 WhileStmt::WhileStmt(ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body,
927 : Stmt(WhileStmtClass) {
929 SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
971 Stmt *TryBlock,
972 Stmt *Handler)
973 : Stmt(SEHTryStmtClass),
984 Stmt *TryBlock,
985 Stmt *Handler) {
999 Stmt *Block)
1000 : Stmt(SEHExceptStmtClass),
1003 Children[FILTER_EXPR] = reinterpret_cast<Stmt*>(FilterExpr);
1010 Stmt *Block) {
1015 Stmt *Block)
1016 : Stmt(SEHFinallyStmtClass),
1023 Stmt *Block) {