2007-07-11 21:01:13 +04:00
|
|
|
//===--- Stmt.cpp - Statement AST Node Implementation ---------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 22:59:25 +03:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-07-11 21:01:13 +04:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the Stmt class and statement subclasses.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/AST/Stmt.h"
|
|
|
|
#include "clang/AST/ExprCXX.h"
|
2008-05-30 01:12:08 +04:00
|
|
|
#include "clang/AST/ExprObjC.h"
|
2008-12-22 22:15:10 +03:00
|
|
|
#include "clang/AST/Type.h"
|
2009-02-06 04:42:09 +03:00
|
|
|
#include "clang/AST/ASTContext.h"
|
2007-07-11 21:01:13 +04:00
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
static struct StmtClassNameTable {
|
2007-08-25 05:42:24 +04:00
|
|
|
const char *Name;
|
|
|
|
unsigned Counter;
|
|
|
|
unsigned Size;
|
2007-08-25 05:55:00 +04:00
|
|
|
} StmtClassInfo[Stmt::lastExprConstant+1];
|
2007-08-25 05:42:24 +04:00
|
|
|
|
|
|
|
static StmtClassNameTable &getStmtInfoTableEntry(Stmt::StmtClass E) {
|
|
|
|
static bool Initialized = false;
|
|
|
|
if (Initialized)
|
|
|
|
return StmtClassInfo[E];
|
|
|
|
|
|
|
|
// Intialize the table on the first use.
|
|
|
|
Initialized = true;
|
2008-11-14 15:46:07 +03:00
|
|
|
#define STMT(CLASS, PARENT) \
|
|
|
|
StmtClassInfo[(unsigned)Stmt::CLASS##Class].Name = #CLASS; \
|
|
|
|
StmtClassInfo[(unsigned)Stmt::CLASS##Class].Size = sizeof(CLASS);
|
2007-07-11 21:01:13 +04:00
|
|
|
#include "clang/AST/StmtNodes.def"
|
2008-08-06 03:15:29 +04:00
|
|
|
|
2007-08-25 05:42:24 +04:00
|
|
|
return StmtClassInfo[E];
|
|
|
|
}
|
|
|
|
|
2007-07-11 21:01:13 +04:00
|
|
|
const char *Stmt::getStmtClassName() const {
|
2007-08-25 05:42:24 +04:00
|
|
|
return getStmtInfoTableEntry(sClass).Name;
|
2007-07-11 21:01:13 +04:00
|
|
|
}
|
|
|
|
|
2009-03-04 07:23:07 +03:00
|
|
|
void Stmt::DestroyChildren(ASTContext &C) {
|
|
|
|
for (child_iterator I = child_begin(), E = child_end(); I !=E; )
|
2009-01-16 09:50:08 +03:00
|
|
|
if (Stmt* Child = *I++) Child->Destroy(C);
|
2008-05-20 04:43:19 +04:00
|
|
|
}
|
|
|
|
|
2009-03-04 07:23:07 +03:00
|
|
|
void Stmt::Destroy(ASTContext &C) {
|
2008-05-20 04:43:19 +04:00
|
|
|
DestroyChildren(C);
|
2008-05-20 08:10:52 +04:00
|
|
|
// FIXME: Eventually all Stmts should be allocated with the allocator
|
|
|
|
// in ASTContext, just like with Decls.
|
2009-02-06 04:42:09 +03:00
|
|
|
this->~Stmt();
|
|
|
|
C.Deallocate((void *)this);
|
2008-05-20 02:02:12 +04:00
|
|
|
}
|
|
|
|
|
2009-03-04 07:23:07 +03:00
|
|
|
void DeclStmt::Destroy(ASTContext &C) {
|
2009-02-06 04:42:09 +03:00
|
|
|
this->~DeclStmt();
|
|
|
|
C.Deallocate((void *)this);
|
2008-05-21 19:53:55 +04:00
|
|
|
}
|
|
|
|
|
2007-07-11 21:01:13 +04:00
|
|
|
void Stmt::PrintStats() {
|
2007-08-25 05:42:24 +04:00
|
|
|
// Ensure the table is primed.
|
|
|
|
getStmtInfoTableEntry(Stmt::NullStmtClass);
|
2008-08-06 03:15:29 +04:00
|
|
|
|
2007-07-11 21:01:13 +04:00
|
|
|
unsigned sum = 0;
|
|
|
|
fprintf(stderr, "*** Stmt/Expr Stats:\n");
|
2007-08-25 05:55:00 +04:00
|
|
|
for (int i = 0; i != Stmt::lastExprConstant+1; i++) {
|
2007-08-25 05:42:24 +04:00
|
|
|
if (StmtClassInfo[i].Name == 0) continue;
|
|
|
|
sum += StmtClassInfo[i].Counter;
|
2007-07-11 21:01:13 +04:00
|
|
|
}
|
|
|
|
fprintf(stderr, " %d stmts/exprs total.\n", sum);
|
|
|
|
sum = 0;
|
2007-08-25 05:55:00 +04:00
|
|
|
for (int i = 0; i != Stmt::lastExprConstant+1; i++) {
|
2007-08-25 05:42:24 +04:00
|
|
|
if (StmtClassInfo[i].Name == 0) continue;
|
2008-08-06 03:15:29 +04:00
|
|
|
fprintf(stderr, " %d %s, %d each (%d bytes)\n",
|
2007-08-25 05:42:24 +04:00
|
|
|
StmtClassInfo[i].Counter, StmtClassInfo[i].Name,
|
|
|
|
StmtClassInfo[i].Size,
|
|
|
|
StmtClassInfo[i].Counter*StmtClassInfo[i].Size);
|
|
|
|
sum += StmtClassInfo[i].Counter*StmtClassInfo[i].Size;
|
2007-07-11 21:01:13 +04:00
|
|
|
}
|
|
|
|
fprintf(stderr, "Total bytes = %d\n", sum);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Stmt::addStmtClass(StmtClass s) {
|
2007-08-25 05:42:24 +04:00
|
|
|
++getStmtInfoTableEntry(s).Counter;
|
2007-07-11 21:01:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool StatSwitch = false;
|
|
|
|
|
|
|
|
bool Stmt::CollectingStats(bool enable) {
|
|
|
|
if (enable) StatSwitch = true;
|
2007-08-25 05:42:24 +04:00
|
|
|
return StatSwitch;
|
2007-07-11 21:01:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char *LabelStmt::getName() const {
|
|
|
|
return getID()->getName();
|
|
|
|
}
|
|
|
|
|
2007-09-01 03:49:30 +04:00
|
|
|
// This is defined here to avoid polluting Stmt.h with importing Expr.h
|
2008-08-06 03:15:29 +04:00
|
|
|
SourceRange ReturnStmt::getSourceRange() const {
|
2007-09-01 03:49:30 +04:00
|
|
|
if (RetExpr)
|
|
|
|
return SourceRange(RetLoc, RetExpr->getLocEnd());
|
|
|
|
else
|
|
|
|
return SourceRange(RetLoc);
|
|
|
|
}
|
|
|
|
|
2007-10-01 20:34:52 +04:00
|
|
|
bool Stmt::hasImplicitControlFlow() const {
|
|
|
|
switch (sClass) {
|
|
|
|
default:
|
|
|
|
return false;
|
2008-08-06 03:15:29 +04:00
|
|
|
|
2007-10-01 20:34:52 +04:00
|
|
|
case CallExprClass:
|
|
|
|
case ConditionalOperatorClass:
|
|
|
|
case ChooseExprClass:
|
|
|
|
case StmtExprClass:
|
|
|
|
case DeclStmtClass:
|
2008-08-06 03:15:29 +04:00
|
|
|
return true;
|
|
|
|
|
2007-10-01 20:34:52 +04:00
|
|
|
case Stmt::BinaryOperatorClass: {
|
|
|
|
const BinaryOperator* B = cast<BinaryOperator>(this);
|
|
|
|
if (B->isLogicalOp() || B->getOpcode() == BinaryOperator::Comma)
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-10 07:59:06 +03:00
|
|
|
Expr *AsmStmt::getOutputExpr(unsigned i) {
|
2008-10-27 21:40:21 +03:00
|
|
|
return cast<Expr>(Exprs[i]);
|
|
|
|
}
|
2009-03-10 07:59:06 +03:00
|
|
|
|
|
|
|
/// getOutputConstraint - Return the constraint string for the specified
|
|
|
|
/// output operand. All output constraints are known to be non-empty (either
|
|
|
|
/// '=' or '+').
|
|
|
|
std::string AsmStmt::getOutputConstraint(unsigned i) const {
|
|
|
|
return std::string(Constraints[i]->getStrData(),
|
|
|
|
Constraints[i]->getByteLength());
|
2008-10-27 21:40:21 +03:00
|
|
|
}
|
2009-03-10 07:59:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
Expr *AsmStmt::getInputExpr(unsigned i) {
|
2008-10-27 21:40:21 +03:00
|
|
|
return cast<Expr>(Exprs[i + NumOutputs]);
|
|
|
|
}
|
2009-03-10 07:59:06 +03:00
|
|
|
|
|
|
|
/// getInputConstraint - Return the specified input constraint. Unlike output
|
|
|
|
/// constraints, these can be empty.
|
|
|
|
std::string AsmStmt::getInputConstraint(unsigned i) const {
|
|
|
|
return std::string(Constraints[i + NumOutputs]->getStrData(),
|
|
|
|
Constraints[i + NumOutputs]->getByteLength());
|
2008-10-27 21:40:21 +03:00
|
|
|
}
|
|
|
|
|
2008-01-30 08:01:46 +03:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Constructors
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-02-06 02:03:50 +03:00
|
|
|
AsmStmt::AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile,
|
2008-01-30 08:01:46 +03:00
|
|
|
unsigned numoutputs, unsigned numinputs,
|
|
|
|
std::string *names, StringLiteral **constraints,
|
|
|
|
Expr **exprs, StringLiteral *asmstr, unsigned numclobbers,
|
|
|
|
StringLiteral **clobbers, SourceLocation rparenloc)
|
2007-11-22 04:36:19 +03:00
|
|
|
: Stmt(AsmStmtClass), AsmLoc(asmloc), RParenLoc(rparenloc), AsmStr(asmstr)
|
2008-02-06 02:03:50 +03:00
|
|
|
, IsSimple(issimple), IsVolatile(isvolatile)
|
|
|
|
, NumOutputs(numoutputs), NumInputs(numinputs) {
|
2007-11-22 04:36:19 +03:00
|
|
|
for (unsigned i = 0, e = numinputs + numoutputs; i != e; i++) {
|
|
|
|
Names.push_back(names[i]);
|
|
|
|
Exprs.push_back(exprs[i]);
|
2008-08-06 03:15:29 +04:00
|
|
|
Constraints.push_back(constraints[i]);
|
2007-11-22 04:36:19 +03:00
|
|
|
}
|
2008-08-06 03:15:29 +04:00
|
|
|
|
2007-11-22 04:36:19 +03:00
|
|
|
for (unsigned i = 0; i != numclobbers; i++)
|
|
|
|
Clobbers.push_back(clobbers[i]);
|
|
|
|
}
|
|
|
|
|
2008-01-30 08:01:46 +03:00
|
|
|
ObjCForCollectionStmt::ObjCForCollectionStmt(Stmt *Elem, Expr *Collect,
|
|
|
|
Stmt *Body, SourceLocation FCL,
|
2008-08-06 03:15:29 +04:00
|
|
|
SourceLocation RPL)
|
2008-01-30 08:01:46 +03:00
|
|
|
: Stmt(ObjCForCollectionStmtClass) {
|
|
|
|
SubExprs[ELEM] = Elem;
|
|
|
|
SubExprs[COLLECTION] = reinterpret_cast<Stmt*>(Collect);
|
|
|
|
SubExprs[BODY] = Body;
|
|
|
|
ForLoc = FCL;
|
|
|
|
RParenLoc = RPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-06 03:15:29 +04:00
|
|
|
ObjCAtCatchStmt::ObjCAtCatchStmt(SourceLocation atCatchLoc,
|
|
|
|
SourceLocation rparenloc,
|
2009-03-03 22:52:17 +03:00
|
|
|
ParmVarDecl *catchVarDecl, Stmt *atCatchStmt,
|
2008-01-30 08:01:46 +03:00
|
|
|
Stmt *atCatchList)
|
|
|
|
: Stmt(ObjCAtCatchStmtClass) {
|
2009-03-03 22:52:17 +03:00
|
|
|
ExceptionDecl = catchVarDecl;
|
2008-01-30 08:01:46 +03:00
|
|
|
SubExprs[BODY] = atCatchStmt;
|
2008-05-25 08:34:57 +04:00
|
|
|
SubExprs[NEXT_CATCH] = NULL;
|
2009-03-01 07:28:32 +03:00
|
|
|
// FIXME: O(N^2) in number of catch blocks.
|
2008-05-25 08:34:57 +04:00
|
|
|
if (atCatchList) {
|
2008-02-02 00:28:59 +03:00
|
|
|
ObjCAtCatchStmt *AtCatchList = static_cast<ObjCAtCatchStmt*>(atCatchList);
|
|
|
|
|
2008-08-06 03:15:29 +04:00
|
|
|
while (ObjCAtCatchStmt* NextCatch = AtCatchList->getNextCatchStmt())
|
2008-02-02 00:28:59 +03:00
|
|
|
AtCatchList = NextCatch;
|
2008-08-06 03:15:29 +04:00
|
|
|
|
2008-02-02 00:28:59 +03:00
|
|
|
AtCatchList->SubExprs[NEXT_CATCH] = this;
|
2008-01-30 08:01:46 +03:00
|
|
|
}
|
|
|
|
AtCatchLoc = atCatchLoc;
|
|
|
|
RParenLoc = rparenloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-25 01:09:09 +04:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Child Iterators for iterating over subexpressions/substatements
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// DeclStmt
|
2008-10-08 03:09:49 +04:00
|
|
|
Stmt::child_iterator DeclStmt::child_begin() {
|
|
|
|
return StmtIterator(DG.begin(), DG.end());
|
2008-08-06 00:46:55 +04:00
|
|
|
}
|
|
|
|
|
2008-10-08 03:09:49 +04:00
|
|
|
Stmt::child_iterator DeclStmt::child_end() {
|
|
|
|
return StmtIterator(DG.end(), DG.end());
|
2008-10-07 00:54:44 +04:00
|
|
|
}
|
|
|
|
|
2007-08-25 01:09:09 +04:00
|
|
|
// NullStmt
|
2007-10-19 03:28:49 +04:00
|
|
|
Stmt::child_iterator NullStmt::child_begin() { return child_iterator(); }
|
|
|
|
Stmt::child_iterator NullStmt::child_end() { return child_iterator(); }
|
2007-08-25 01:09:09 +04:00
|
|
|
|
|
|
|
// CompoundStmt
|
|
|
|
Stmt::child_iterator CompoundStmt::child_begin() { return &Body[0]; }
|
2009-02-07 04:47:29 +03:00
|
|
|
Stmt::child_iterator CompoundStmt::child_end() { return &Body[0]+NumStmts; }
|
2007-08-25 01:09:09 +04:00
|
|
|
|
2007-08-30 20:50:46 +04:00
|
|
|
// CaseStmt
|
|
|
|
Stmt::child_iterator CaseStmt::child_begin() { return &SubExprs[0]; }
|
|
|
|
Stmt::child_iterator CaseStmt::child_end() { return &SubExprs[END_EXPR]; }
|
|
|
|
|
|
|
|
// DefaultStmt
|
|
|
|
Stmt::child_iterator DefaultStmt::child_begin() { return &SubStmt; }
|
|
|
|
Stmt::child_iterator DefaultStmt::child_end() { return &SubStmt+1; }
|
2007-08-25 01:09:09 +04:00
|
|
|
|
|
|
|
// LabelStmt
|
|
|
|
Stmt::child_iterator LabelStmt::child_begin() { return &SubStmt; }
|
2007-08-30 04:53:54 +04:00
|
|
|
Stmt::child_iterator LabelStmt::child_end() { return &SubStmt+1; }
|
2007-08-25 01:09:09 +04:00
|
|
|
|
|
|
|
// IfStmt
|
|
|
|
Stmt::child_iterator IfStmt::child_begin() { return &SubExprs[0]; }
|
|
|
|
Stmt::child_iterator IfStmt::child_end() { return &SubExprs[0]+END_EXPR; }
|
|
|
|
|
|
|
|
// SwitchStmt
|
|
|
|
Stmt::child_iterator SwitchStmt::child_begin() { return &SubExprs[0]; }
|
|
|
|
Stmt::child_iterator SwitchStmt::child_end() { return &SubExprs[0]+END_EXPR; }
|
|
|
|
|
|
|
|
// WhileStmt
|
|
|
|
Stmt::child_iterator WhileStmt::child_begin() { return &SubExprs[0]; }
|
|
|
|
Stmt::child_iterator WhileStmt::child_end() { return &SubExprs[0]+END_EXPR; }
|
|
|
|
|
|
|
|
// DoStmt
|
|
|
|
Stmt::child_iterator DoStmt::child_begin() { return &SubExprs[0]; }
|
|
|
|
Stmt::child_iterator DoStmt::child_end() { return &SubExprs[0]+END_EXPR; }
|
|
|
|
|
|
|
|
// ForStmt
|
|
|
|
Stmt::child_iterator ForStmt::child_begin() { return &SubExprs[0]; }
|
|
|
|
Stmt::child_iterator ForStmt::child_end() { return &SubExprs[0]+END_EXPR; }
|
|
|
|
|
2008-01-07 22:49:32 +03:00
|
|
|
// ObjCForCollectionStmt
|
2008-08-06 03:15:29 +04:00
|
|
|
Stmt::child_iterator ObjCForCollectionStmt::child_begin() {
|
|
|
|
return &SubExprs[0];
|
2008-01-03 01:54:34 +03:00
|
|
|
}
|
2008-08-06 03:15:29 +04:00
|
|
|
Stmt::child_iterator ObjCForCollectionStmt::child_end() {
|
|
|
|
return &SubExprs[0]+END_EXPR;
|
2008-01-03 01:54:34 +03:00
|
|
|
}
|
|
|
|
|
2007-08-25 01:09:09 +04:00
|
|
|
// GotoStmt
|
2007-10-19 03:28:49 +04:00
|
|
|
Stmt::child_iterator GotoStmt::child_begin() { return child_iterator(); }
|
|
|
|
Stmt::child_iterator GotoStmt::child_end() { return child_iterator(); }
|
2007-08-25 01:09:09 +04:00
|
|
|
|
|
|
|
// IndirectGotoStmt
|
2008-06-17 07:11:08 +04:00
|
|
|
Expr* IndirectGotoStmt::getTarget() { return cast<Expr>(Target); }
|
|
|
|
const Expr* IndirectGotoStmt::getTarget() const { return cast<Expr>(Target); }
|
2007-08-25 01:09:09 +04:00
|
|
|
|
2008-06-17 07:11:08 +04:00
|
|
|
Stmt::child_iterator IndirectGotoStmt::child_begin() { return &Target; }
|
|
|
|
Stmt::child_iterator IndirectGotoStmt::child_end() { return &Target+1; }
|
2007-08-25 01:09:09 +04:00
|
|
|
|
|
|
|
// ContinueStmt
|
2007-10-19 03:28:49 +04:00
|
|
|
Stmt::child_iterator ContinueStmt::child_begin() { return child_iterator(); }
|
|
|
|
Stmt::child_iterator ContinueStmt::child_end() { return child_iterator(); }
|
2007-08-25 01:09:09 +04:00
|
|
|
|
|
|
|
// BreakStmt
|
2007-10-19 03:28:49 +04:00
|
|
|
Stmt::child_iterator BreakStmt::child_begin() { return child_iterator(); }
|
|
|
|
Stmt::child_iterator BreakStmt::child_end() { return child_iterator(); }
|
2007-08-25 01:09:09 +04:00
|
|
|
|
|
|
|
// ReturnStmt
|
2008-06-17 07:11:08 +04:00
|
|
|
const Expr* ReturnStmt::getRetValue() const {
|
|
|
|
return cast_or_null<Expr>(RetExpr);
|
|
|
|
}
|
|
|
|
Expr* ReturnStmt::getRetValue() {
|
|
|
|
return cast_or_null<Expr>(RetExpr);
|
2007-08-25 01:09:09 +04:00
|
|
|
}
|
|
|
|
|
2008-06-17 07:11:08 +04:00
|
|
|
Stmt::child_iterator ReturnStmt::child_begin() {
|
|
|
|
return &RetExpr;
|
|
|
|
}
|
|
|
|
Stmt::child_iterator ReturnStmt::child_end() {
|
|
|
|
return RetExpr ? &RetExpr+1 : &RetExpr;
|
2007-08-28 00:58:16 +04:00
|
|
|
}
|
2007-08-25 01:09:09 +04:00
|
|
|
|
2007-10-29 07:04:16 +03:00
|
|
|
// AsmStmt
|
2008-10-27 21:40:21 +03:00
|
|
|
Stmt::child_iterator AsmStmt::child_begin() {
|
|
|
|
return Exprs.empty() ? 0 : &Exprs[0];
|
|
|
|
}
|
|
|
|
Stmt::child_iterator AsmStmt::child_end() {
|
|
|
|
return Exprs.empty() ? 0 : &Exprs[0] + Exprs.size();
|
|
|
|
}
|
2007-10-29 07:04:16 +03:00
|
|
|
|
2008-01-07 22:49:32 +03:00
|
|
|
// ObjCAtCatchStmt
|
|
|
|
Stmt::child_iterator ObjCAtCatchStmt::child_begin() { return &SubExprs[0]; }
|
2008-08-06 03:15:29 +04:00
|
|
|
Stmt::child_iterator ObjCAtCatchStmt::child_end() {
|
|
|
|
return &SubExprs[0]+END_EXPR;
|
2007-11-02 02:59:59 +03:00
|
|
|
}
|
2007-11-02 00:12:44 +03:00
|
|
|
|
2008-01-07 22:49:32 +03:00
|
|
|
// ObjCAtFinallyStmt
|
|
|
|
Stmt::child_iterator ObjCAtFinallyStmt::child_begin() { return &AtFinallyStmt; }
|
|
|
|
Stmt::child_iterator ObjCAtFinallyStmt::child_end() { return &AtFinallyStmt+1; }
|
2007-11-02 00:12:44 +03:00
|
|
|
|
2008-01-07 22:49:32 +03:00
|
|
|
// ObjCAtTryStmt
|
|
|
|
Stmt::child_iterator ObjCAtTryStmt::child_begin() { return &SubStmts[0]; }
|
2008-08-06 03:15:29 +04:00
|
|
|
Stmt::child_iterator ObjCAtTryStmt::child_end() {
|
|
|
|
return &SubStmts[0]+END_EXPR;
|
2007-11-02 02:59:59 +03:00
|
|
|
}
|
2007-11-02 00:12:44 +03:00
|
|
|
|
2008-01-07 22:49:32 +03:00
|
|
|
// ObjCAtThrowStmt
|
|
|
|
Stmt::child_iterator ObjCAtThrowStmt::child_begin() {
|
2007-11-07 05:00:49 +03:00
|
|
|
return &Throw;
|
|
|
|
}
|
|
|
|
|
2008-01-07 22:49:32 +03:00
|
|
|
Stmt::child_iterator ObjCAtThrowStmt::child_end() {
|
2007-11-07 05:00:49 +03:00
|
|
|
return &Throw+1;
|
|
|
|
}
|
2008-01-29 22:14:59 +03:00
|
|
|
|
|
|
|
// ObjCAtSynchronizedStmt
|
|
|
|
Stmt::child_iterator ObjCAtSynchronizedStmt::child_begin() {
|
2008-01-30 01:59:37 +03:00
|
|
|
return &SubStmts[0];
|
2008-01-29 22:14:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Stmt::child_iterator ObjCAtSynchronizedStmt::child_end() {
|
2008-01-30 01:59:37 +03:00
|
|
|
return &SubStmts[0]+END_EXPR;
|
2008-01-29 22:14:59 +03:00
|
|
|
}
|
|
|
|
|
2008-12-22 22:15:10 +03:00
|
|
|
// CXXCatchStmt
|
|
|
|
Stmt::child_iterator CXXCatchStmt::child_begin() {
|
|
|
|
return &HandlerBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
Stmt::child_iterator CXXCatchStmt::child_end() {
|
|
|
|
return &HandlerBlock + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
QualType CXXCatchStmt::getCaughtType() {
|
|
|
|
if (ExceptionDecl)
|
|
|
|
return llvm::cast<VarDecl>(ExceptionDecl)->getType();
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CXXCatchStmt::Destroy(ASTContext& C) {
|
2008-12-23 00:35:02 +03:00
|
|
|
if (ExceptionDecl)
|
|
|
|
ExceptionDecl->Destroy(C);
|
2008-12-22 22:15:10 +03:00
|
|
|
Stmt::Destroy(C);
|
|
|
|
}
|
2008-12-23 00:35:02 +03:00
|
|
|
|
|
|
|
// CXXTryStmt
|
|
|
|
Stmt::child_iterator CXXTryStmt::child_begin() { return &Stmts[0]; }
|
|
|
|
Stmt::child_iterator CXXTryStmt::child_end() { return &Stmts[0]+Stmts.size(); }
|
|
|
|
|
|
|
|
CXXTryStmt::CXXTryStmt(SourceLocation tryLoc, Stmt *tryBlock,
|
|
|
|
Stmt **handlers, unsigned numHandlers)
|
|
|
|
: Stmt(CXXTryStmtClass), TryLoc(tryLoc) {
|
|
|
|
Stmts.push_back(tryBlock);
|
|
|
|
Stmts.insert(Stmts.end(), handlers, handlers + numHandlers);
|
|
|
|
}
|