13 #ifndef LLVM_CLANG_AST_STMTOBJC_H
14 #define LLVM_CLANG_AST_STMTOBJC_H
17 #include "llvm/Support/Compiler.h"
25 enum { ELEM, COLLECTION, BODY, END_EXPR };
26 Stmt* SubExprs[END_EXPR];
33 Stmt(ObjCForCollectionStmtClass, Empty) { }
37 return reinterpret_cast<Expr*
>(SubExprs[COLLECTION]);
43 return reinterpret_cast<Expr*
>(SubExprs[COLLECTION]);
49 SubExprs[COLLECTION] =
reinterpret_cast<Stmt*
>(E);
60 return SubExprs[BODY]->getLocEnd();
64 return T->getStmtClass() == ObjCForCollectionStmtClass;
69 return child_range(&SubExprs[0], &SubExprs[END_EXPR]);
84 :
Stmt(ObjCAtCatchStmtClass), ExceptionDecl(catchVarDecl),
85 Body(atCatchStmt), AtCatchLoc(atCatchLoc), RParenLoc(rparenloc) { }
88 Stmt(ObjCAtCatchStmtClass, Empty) { }
113 return T->getStmtClass() == ObjCAtCatchStmtClass;
116 child_range
children() {
return child_range(&Body, &Body + 1); }
126 :
Stmt(ObjCAtFinallyStmtClass), AtFinallyLoc(atFinallyLoc),
127 AtFinallyStmt(atFinallyStmt) {}
130 Stmt(ObjCAtFinallyStmtClass, Empty) { }
138 return AtFinallyStmt->getLocEnd();
145 return T->getStmtClass() == ObjCAtFinallyStmtClass;
149 return child_range(&AtFinallyStmt, &AtFinallyStmt+1);
160 unsigned NumCatchStmts : 16;
170 Stmt **getStmts() {
return reinterpret_cast<Stmt **
> (
this + 1); }
171 const Stmt*
const *getStmts()
const {
172 return reinterpret_cast<const Stmt * const*
> (
this + 1);
176 Stmt **CatchStmts,
unsigned NumCatchStmts,
177 Stmt *atFinallyStmt);
179 explicit ObjCAtTryStmt(EmptyShell Empty,
unsigned NumCatchStmts,
181 :
Stmt(ObjCAtTryStmtClass, Empty), NumCatchStmts(NumCatchStmts),
182 HasFinally(HasFinally) { }
187 Stmt **CatchStmts,
unsigned NumCatchStmts,
188 Stmt *atFinallyStmt);
190 unsigned NumCatchStmts,
bool HasFinally);
207 assert(I < NumCatchStmts &&
"Out-of-bounds @catch index");
208 return cast_or_null<ObjCAtCatchStmt>(getStmts()[I + 1]);
213 assert(I < NumCatchStmts &&
"Out-of-bounds @catch index");
214 return cast_or_null<ObjCAtCatchStmt>(getStmts()[I + 1]);
219 assert(I < NumCatchStmts &&
"Out-of-bounds @catch index");
220 getStmts()[I + 1] =
S;
228 return cast_or_null<ObjCAtFinallyStmt>(getStmts()[1 + NumCatchStmts]);
234 return cast_or_null<ObjCAtFinallyStmt>(getStmts()[1 + NumCatchStmts]);
237 assert(HasFinally &&
"@try does not have a @finally slot!");
238 getStmts()[1 + NumCatchStmts] =
S;
245 return T->getStmtClass() == ObjCAtTryStmtClass;
249 return child_range(getStmts(),
250 getStmts() + 1 + NumCatchStmts + HasFinally);
265 enum { SYNC_EXPR, SYNC_BODY, END_EXPR };
266 Stmt* SubStmts[END_EXPR];
271 :
Stmt(ObjCAtSynchronizedStmtClass) {
272 SubStmts[SYNC_EXPR] = synchExpr;
273 SubStmts[SYNC_BODY] = synchBody;
274 AtSynchronizedLoc = atSynchronizedLoc;
277 Stmt(ObjCAtSynchronizedStmtClass, Empty) { }
283 return reinterpret_cast<CompoundStmt*
>(SubStmts[SYNC_BODY]);
286 return reinterpret_cast<CompoundStmt*
>(SubStmts[SYNC_BODY]);
291 return reinterpret_cast<Expr*
>(SubStmts[SYNC_EXPR]);
294 return reinterpret_cast<Expr*
>(SubStmts[SYNC_EXPR]);
304 return T->getStmtClass() == ObjCAtSynchronizedStmtClass;
308 return child_range(&SubStmts[0], &SubStmts[0]+END_EXPR);
319 :
Stmt(ObjCAtThrowStmtClass), Throw(throwExpr) {
320 AtThrowLoc = atThrowLoc;
323 Stmt(ObjCAtThrowStmtClass, Empty) { }
334 return Throw ? Throw->getLocEnd() : AtThrowLoc;
338 return T->getStmtClass() == ObjCAtThrowStmtClass;
341 child_range
children() {
return child_range(&Throw, &Throw+1); }
351 :
Stmt(ObjCAutoreleasePoolStmtClass), AtLoc(atLoc), SubStmt(subStmt) {}
354 Stmt(ObjCAutoreleasePoolStmtClass, Empty) { }
367 return T->getStmtClass() == ObjCAutoreleasePoolStmtClass;
370 child_range
children() {
return child_range(&SubStmt, &SubStmt + 1); }
SourceLocation getLocEnd() const LLVM_READONLY
const Stmt * getElement() const
SourceLocation getLocStart() const LLVM_READONLY
static bool classof(const Stmt *T)
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
ObjCAtSynchronizedStmt(SourceLocation atSynchronizedLoc, Stmt *synchExpr, Stmt *synchBody)
VarDecl * getCatchParamDecl()
ObjCForCollectionStmt(EmptyShell Empty)
ObjCAutoreleasePoolStmt(EmptyShell Empty)
ObjCAtCatchStmt(EmptyShell Empty)
SourceLocation getForLoc() const
void setThrowExpr(Stmt *S)
const Stmt * getBody() const
Represents Objective-C's @throw statement.
SourceLocation getLocStart() const LLVM_READONLY
static bool classof(const Stmt *T)
SourceLocation getLocStart() const LLVM_READONLY
static bool classof(const Stmt *T)
SourceLocation getLocEnd() const LLVM_READONLY
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceLocation getLocEnd() const LLVM_READONLY
const VarDecl * getCatchParamDecl() const
Represents Objective-C's @catch statement.
const CompoundStmt * getSynchBody() const
const Stmt * getFinallyBody() const
static bool classof(const Stmt *T)
SourceLocation getLocEnd() const LLVM_READONLY
void setSynchBody(Stmt *S)
SourceLocation getAtFinallyLoc() const
static bool classof(const Stmt *T)
ObjCAtSynchronizedStmt(EmptyShell Empty)
SourceLocation getLocEnd() const LLVM_READONLY
ObjCAtFinallyStmt * getFinallyStmt()
SourceLocation getThrowLoc()
const Stmt * getCatchBody() const
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
SourceLocation getLocEnd() const LLVM_READONLY
void setRParenLoc(SourceLocation Loc)
ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc, VarDecl *catchVarDecl, Stmt *atCatchStmt)
SourceLocation getLocEnd() const LLVM_READONLY
CompoundStmt * getSynchBody()
ObjCAtFinallyStmt(SourceLocation atFinallyLoc, Stmt *atFinallyStmt)
void setRParenLoc(SourceLocation Loc)
SourceLocation getLocStart() const LLVM_READONLY
ObjCAtThrowStmt(SourceLocation atThrowLoc, Stmt *throwExpr)
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThrowExpr > throwExpr
Matches throw expressions.
ObjCForCollectionStmt(Stmt *Elem, Expr *Collect, Stmt *Body, SourceLocation FCL, SourceLocation RPL)
ObjCAtCatchStmt * getCatchStmt(unsigned I)
Retrieve a @catch statement.
const Expr * getCollection() const
SourceLocation getRParenLoc() const
Represents Objective-C's @synchronized statement.
void setFinallyBody(Stmt *S)
void setFinallyStmt(Stmt *S)
static bool classof(const Stmt *T)
void setForLoc(SourceLocation Loc)
SourceLocation getAtLoc() const
void setAtTryLoc(SourceLocation Loc)
void setSynchExpr(Stmt *S)
SourceLocation getLocStart() const LLVM_READONLY
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
void setAtCatchLoc(SourceLocation Loc)
static ObjCAtTryStmt * CreateEmpty(const ASTContext &Context, unsigned NumCatchStmts, bool HasFinally)
void setCatchParamDecl(VarDecl *D)
void setThrowLoc(SourceLocation Loc)
ObjCAutoreleasePoolStmt(SourceLocation atLoc, Stmt *subStmt)
SourceLocation getAtSynchronizedLoc() const
void setCollection(Expr *E)
const Expr * getSynchExpr() const
static bool classof(const Stmt *T)
SourceLocation getAtCatchLoc() const
SourceLocation getRParenLoc() const
void setCatchStmt(unsigned I, ObjCAtCatchStmt *S)
Set a particular catch statement.
const Stmt * getSubStmt() const
Represents Objective-C's collection statement.
SourceLocation getAtTryLoc() const
Retrieve the location of the @ in the @try.
void setAtFinallyLoc(SourceLocation Loc)
Represents Objective-C's @finally statement.
void setCatchBody(Stmt *S)
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
void setAtSynchronizedLoc(SourceLocation Loc)
SourceLocation getLocEnd() const LLVM_READONLY
ObjCAtFinallyStmt(EmptyShell Empty)
ObjCAtThrowStmt(EmptyShell Empty)
Represents Objective-C's @try ... @catch ... @finally statement.
const Expr * getThrowExpr() const
const Stmt * getTryBody() const
Retrieve the @try body.
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getLocStart() const LLVM_READONLY
Represents Objective-C's @autoreleasepool Statement.
static ObjCAtTryStmt * Create(const ASTContext &Context, SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt)
void setAtLoc(SourceLocation Loc)