12#ifndef LLVM_CLANG_AST_STMTOBJC_H
13#define LLVM_CLANG_AST_STMTOBJC_H
16#include "llvm/Support/Compiler.h"
24 enum { ELEM, COLLECTION, BODY, END_EXPR };
25 Stmt* SubExprs[END_EXPR];
32 Stmt(ObjCForCollectionStmtClass, Empty) { }
36 return reinterpret_cast<Expr*
>(SubExprs[COLLECTION]);
42 return reinterpret_cast<Expr*
>(SubExprs[COLLECTION]);
48 SubExprs[COLLECTION] =
reinterpret_cast<Stmt*
>(E);
68 return child_range(&SubExprs[0], &SubExprs[END_EXPR]);
87 :
Stmt(ObjCAtCatchStmtClass), ExceptionDecl(catchVarDecl),
88 Body(atCatchStmt), AtCatchLoc(atCatchLoc), RParenLoc(rparenloc) { }
91 Stmt(ObjCAtCatchStmtClass, Empty) { }
101 return ExceptionDecl;
133 :
Stmt(ObjCAtFinallyStmtClass), AtFinallyLoc(atFinallyLoc),
134 AtFinallyStmt(atFinallyStmt) {}
137 Stmt(ObjCAtFinallyStmtClass, Empty) { }
156 return child_range(&AtFinallyStmt, &AtFinallyStmt+1);
167 private llvm::TrailingObjects<ObjCAtTryStmt, Stmt *> {
168 friend TrailingObjects;
169 size_t numTrailingObjects(OverloadToken<Stmt *>)
const {
170 return 1 + NumCatchStmts + HasFinally;
177 unsigned NumCatchStmts : 16;
187 Stmt **getStmts() {
return getTrailingObjects<Stmt *>(); }
188 Stmt *
const *getStmts()
const {
return getTrailingObjects<Stmt *>(); }
191 Stmt **CatchStmts,
unsigned NumCatchStmts,
192 Stmt *atFinallyStmt);
196 :
Stmt(ObjCAtTryStmtClass, Empty), NumCatchStmts(NumCatchStmts),
197 HasFinally(HasFinally) { }
202 Stmt **CatchStmts,
unsigned NumCatchStmts,
203 Stmt *atFinallyStmt);
205 unsigned NumCatchStmts,
bool HasFinally);
222 assert(I < NumCatchStmts &&
"Out-of-bounds @catch index");
223 return cast_or_null<ObjCAtCatchStmt>(getStmts()[I + 1]);
228 assert(I < NumCatchStmts &&
"Out-of-bounds @catch index");
229 return cast_or_null<ObjCAtCatchStmt>(getStmts()[I + 1]);
234 assert(I < NumCatchStmts &&
"Out-of-bounds @catch index");
235 getStmts()[I + 1] = S;
243 return cast_or_null<ObjCAtFinallyStmt>(getStmts()[1 + NumCatchStmts]);
249 return cast_or_null<ObjCAtFinallyStmt>(getStmts()[1 + NumCatchStmts]);
252 assert(HasFinally &&
"@try does not have a @finally slot!");
253 getStmts()[1 + NumCatchStmts] = S;
260 return T->getStmtClass() == ObjCAtTryStmtClass;
265 getStmts(), getStmts() + numTrailingObjects(OverloadToken<Stmt *>()));
305 enum { SYNC_EXPR, SYNC_BODY, END_EXPR };
306 Stmt* SubStmts[END_EXPR];
311 :
Stmt(ObjCAtSynchronizedStmtClass) {
312 SubStmts[SYNC_EXPR] = synchExpr;
313 SubStmts[SYNC_BODY] = synchBody;
314 AtSynchronizedLoc = atSynchronizedLoc;
317 Stmt(ObjCAtSynchronizedStmtClass, Empty) { }
323 return reinterpret_cast<CompoundStmt*
>(SubStmts[SYNC_BODY]);
326 return reinterpret_cast<CompoundStmt*
>(SubStmts[SYNC_BODY]);
331 return reinterpret_cast<Expr*
>(SubStmts[SYNC_EXPR]);
334 return reinterpret_cast<Expr*
>(SubStmts[SYNC_EXPR]);
344 return T->
getStmtClass() == ObjCAtSynchronizedStmtClass;
348 return child_range(&SubStmts[0], &SubStmts[0]+END_EXPR);
363 :
Stmt(ObjCAtThrowStmtClass), Throw(throwExpr) {
364 AtThrowLoc = atThrowLoc;
367 Stmt(ObjCAtThrowStmtClass, Empty) { }
378 return Throw ? Throw->
getEndLoc() : AtThrowLoc;
399 :
Stmt(ObjCAutoreleasePoolStmtClass), AtLoc(atLoc), SubStmt(subStmt) {}
402 Stmt(ObjCAutoreleasePoolStmtClass, Empty) { }
417 return T->
getStmtClass() == ObjCAutoreleasePoolStmtClass;
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CompoundStmt - This represents a group of statements like { stmt stmt }.
SourceLocation getEndLoc() const
This represents one expression.
Represents Objective-C's @catch statement.
const VarDecl * getCatchParamDecl() const
const_child_range children() const
const Stmt * getCatchBody() const
SourceLocation getEndLoc() const LLVM_READONLY
ObjCAtCatchStmt(EmptyShell Empty)
void setCatchParamDecl(VarDecl *D)
void setCatchBody(Stmt *S)
static bool classof(const Stmt *T)
void setRParenLoc(SourceLocation Loc)
SourceLocation getAtCatchLoc() const
VarDecl * getCatchParamDecl()
ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc, VarDecl *catchVarDecl, Stmt *atCatchStmt)
SourceLocation getBeginLoc() const LLVM_READONLY
void setAtCatchLoc(SourceLocation Loc)
SourceLocation getRParenLoc() const
Represents Objective-C's @finally statement.
const Stmt * getFinallyBody() const
void setFinallyBody(Stmt *S)
SourceLocation getBeginLoc() const LLVM_READONLY
ObjCAtFinallyStmt(SourceLocation atFinallyLoc, Stmt *atFinallyStmt)
static bool classof(const Stmt *T)
void setAtFinallyLoc(SourceLocation Loc)
ObjCAtFinallyStmt(EmptyShell Empty)
SourceLocation getAtFinallyLoc() const
const_child_range children() const
SourceLocation getEndLoc() const LLVM_READONLY
Represents Objective-C's @synchronized statement.
const Expr * getSynchExpr() const
CompoundStmt * getSynchBody()
ObjCAtSynchronizedStmt(SourceLocation atSynchronizedLoc, Stmt *synchExpr, Stmt *synchBody)
void setSynchBody(Stmt *S)
const CompoundStmt * getSynchBody() const
void setAtSynchronizedLoc(SourceLocation Loc)
SourceLocation getAtSynchronizedLoc() const
const_child_range children() const
SourceLocation getBeginLoc() const LLVM_READONLY
ObjCAtSynchronizedStmt(EmptyShell Empty)
void setSynchExpr(Stmt *S)
static bool classof(const Stmt *T)
SourceLocation getEndLoc() const LLVM_READONLY
Represents Objective-C's @throw statement.
const Expr * getThrowExpr() const
void setThrowLoc(SourceLocation Loc)
static bool classof(const Stmt *T)
ObjCAtThrowStmt(SourceLocation atThrowLoc, Stmt *throwExpr)
const_child_range children() const
SourceLocation getThrowLoc() const LLVM_READONLY
void setThrowExpr(Stmt *S)
SourceLocation getBeginLoc() const LLVM_READONLY
ObjCAtThrowStmt(EmptyShell Empty)
SourceLocation getEndLoc() const LLVM_READONLY
Represents Objective-C's @try ... @catch ... @finally statement.
void setAtTryLoc(SourceLocation Loc)
llvm::iterator_range< const_catch_stmt_iterator > catch_const_range
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
void setFinallyStmt(Stmt *S)
catch_stmt_iterator catch_stmts_end()
const_child_range children() const
static ObjCAtTryStmt * Create(const ASTContext &Context, SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt)
static ObjCAtTryStmt * CreateEmpty(const ASTContext &Context, unsigned NumCatchStmts, bool HasFinally)
llvm::iterator_range< catch_stmt_iterator > catch_range
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
catch_stmt_iterator catch_stmts_begin()
ObjCAtFinallyStmt * getFinallyStmt()
SourceLocation getBeginLoc() const LLVM_READONLY
void setCatchStmt(unsigned I, ObjCAtCatchStmt *S)
Set a particular catch statement.
static bool classof(const Stmt *T)
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
const Stmt * getTryBody() const
Retrieve the @try body.
catch_const_range catch_stmts() const
SourceLocation getEndLoc() const LLVM_READONLY
const_catch_stmt_iterator catch_stmts_begin() const
SourceLocation getAtTryLoc() const
Retrieve the location of the @ in the @try.
const_catch_stmt_iterator catch_stmts_end() const
ObjCAtCatchStmt * getCatchStmt(unsigned I)
Retrieve a @catch statement.
catch_range catch_stmts()
Represents Objective-C's @autoreleasepool Statement.
void setAtLoc(SourceLocation Loc)
const_child_range children() const
ObjCAutoreleasePoolStmt(EmptyShell Empty)
SourceLocation getAtLoc() const
static bool classof(const Stmt *T)
SourceLocation getBeginLoc() const LLVM_READONLY
ObjCAutoreleasePoolStmt(SourceLocation atLoc, Stmt *subStmt)
const Stmt * getSubStmt() const
SourceLocation getEndLoc() const LLVM_READONLY
Represents Objective-C's collection statement.
ObjCForCollectionStmt(EmptyShell Empty)
const Stmt * getElement() const
void setCollection(Expr *E)
void setForLoc(SourceLocation Loc)
SourceLocation getForLoc() const
const_child_range children() const
static bool classof(const Stmt *T)
void setRParenLoc(SourceLocation Loc)
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getRParenLoc() const
const Expr * getCollection() const
const Stmt * getBody() const
SourceLocation getBeginLoc() const LLVM_READONLY
Encodes a location in the source.
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
StmtClass getStmtClass() const
llvm::iterator_range< child_iterator > child_range
llvm::iterator_range< const_child_iterator > const_child_range
Represents a variable declaration or definition.
Iterator for iterating over Stmt * arrays that contain only T *.
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....