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]);
83 :
Stmt(ObjCAtCatchStmtClass), ExceptionDecl(catchVarDecl),
84 Body(atCatchStmt), AtCatchLoc(atCatchLoc), RParenLoc(rparenloc) { }
87 Stmt(ObjCAtCatchStmtClass, Empty) { }
109 bool hasEllipsis()
const {
return getCatchParamDecl() ==
nullptr; }
125 :
Stmt(ObjCAtFinallyStmtClass), AtFinallyLoc(atFinallyLoc),
126 AtFinallyStmt(atFinallyStmt) {}
129 Stmt(ObjCAtFinallyStmtClass, Empty) { }
148 return child_range(&AtFinallyStmt, &AtFinallyStmt+1);
159 unsigned NumCatchStmts : 16;
169 Stmt **getStmts() {
return reinterpret_cast<Stmt **
> (
this + 1); }
170 const Stmt*
const *getStmts()
const {
171 return reinterpret_cast<const Stmt * const*
> (
this + 1);
175 Stmt **CatchStmts,
unsigned NumCatchStmts,
176 Stmt *atFinallyStmt);
180 :
Stmt(ObjCAtTryStmtClass, Empty), NumCatchStmts(NumCatchStmts),
181 HasFinally(HasFinally) { }
186 Stmt **CatchStmts,
unsigned NumCatchStmts,
187 Stmt *atFinallyStmt);
189 unsigned NumCatchStmts,
bool HasFinally);
206 assert(I < NumCatchStmts &&
"Out-of-bounds @catch index");
207 return cast_or_null<ObjCAtCatchStmt>(getStmts()[I + 1]);
212 assert(I < NumCatchStmts &&
"Out-of-bounds @catch index");
213 return cast_or_null<ObjCAtCatchStmt>(getStmts()[I + 1]);
218 assert(I < NumCatchStmts &&
"Out-of-bounds @catch index");
219 getStmts()[I + 1] = S;
227 return cast_or_null<ObjCAtFinallyStmt>(getStmts()[1 + NumCatchStmts]);
233 return cast_or_null<ObjCAtFinallyStmt>(getStmts()[1 + NumCatchStmts]);
236 assert(HasFinally &&
"@try does not have a @finally slot!");
237 getStmts()[1 + NumCatchStmts] = S;
249 getStmts() + 1 + NumCatchStmts + HasFinally);
264 enum { SYNC_EXPR, SYNC_BODY, END_EXPR };
265 Stmt* SubStmts[END_EXPR];
270 :
Stmt(ObjCAtSynchronizedStmtClass) {
271 SubStmts[SYNC_EXPR] = synchExpr;
272 SubStmts[SYNC_BODY] = synchBody;
273 AtSynchronizedLoc = atSynchronizedLoc;
276 Stmt(ObjCAtSynchronizedStmtClass, Empty) { }
282 return reinterpret_cast<CompoundStmt*
>(SubStmts[SYNC_BODY]);
285 return reinterpret_cast<CompoundStmt*
>(SubStmts[SYNC_BODY]);
290 return reinterpret_cast<Expr*
>(SubStmts[SYNC_EXPR]);
293 return reinterpret_cast<Expr*
>(SubStmts[SYNC_EXPR]);
299 return getSynchBody()->getEndLoc();
303 return T->
getStmtClass() == ObjCAtSynchronizedStmtClass;
307 return child_range(&SubStmts[0], &SubStmts[0]+END_EXPR);
318 :
Stmt(ObjCAtThrowStmtClass), Throw(throwExpr) {
319 AtThrowLoc = atThrowLoc;
322 Stmt(ObjCAtThrowStmtClass, Empty) { }
333 return Throw ? Throw->
getEndLoc() : AtThrowLoc;
350 :
Stmt(ObjCAutoreleasePoolStmtClass), AtLoc(atLoc), SubStmt(subStmt) {}
353 Stmt(ObjCAutoreleasePoolStmtClass, Empty) { }
368 return T->
getStmtClass() == ObjCAutoreleasePoolStmtClass;
static bool classof(const Stmt *T)
ObjCAtSynchronizedStmt(SourceLocation atSynchronizedLoc, Stmt *synchExpr, Stmt *synchBody)
VarDecl * getCatchParamDecl()
ObjCForCollectionStmt(EmptyShell Empty)
SourceLocation getRParenLoc() const
ObjCAutoreleasePoolStmt(EmptyShell Empty)
Stmt - This represents one statement.
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
ObjCAtCatchStmt(EmptyShell Empty)
SourceLocation getEndLoc() const LLVM_READONLY
void setThrowExpr(Stmt *S)
Represents Objective-C's @throw statement.
llvm::iterator_range< child_iterator > child_range
static bool classof(const Stmt *T)
Represents a variable declaration or definition.
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
const Stmt * getSubStmt() const
static bool classof(const Stmt *T)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceLocation getEndLoc() const LLVM_READONLY
const Stmt * getElement() const
SourceLocation getEndLoc() const LLVM_READONLY
Represents Objective-C's @catch statement.
SourceLocation getEndLoc() const LLVM_READONLY
static bool classof(const Stmt *T)
const Expr * getThrowExpr() const
void setSynchBody(Stmt *S)
static bool classof(const Stmt *T)
ObjCAtSynchronizedStmt(EmptyShell Empty)
ObjCAtFinallyStmt * getFinallyStmt()
SourceLocation getBeginLoc() const LLVM_READONLY
const Stmt * getBody() const
void setRParenLoc(SourceLocation Loc)
ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc, VarDecl *catchVarDecl, Stmt *atCatchStmt)
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
const Expr * getCollection() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
CompoundStmt * getSynchBody()
SourceLocation getThrowLoc() const LLVM_READONLY
ObjCAtFinallyStmt(SourceLocation atFinallyLoc, Stmt *atFinallyStmt)
void setRParenLoc(SourceLocation Loc)
This represents one expression.
ObjCAtThrowStmt(SourceLocation atThrowLoc, Stmt *throwExpr)
ObjCForCollectionStmt(Stmt *Elem, Expr *Collect, Stmt *Body, SourceLocation FCL, SourceLocation RPL)
ObjCAtCatchStmt * getCatchStmt(unsigned I)
Retrieve a @catch statement.
const CompoundStmt * getSynchBody() const
Represents Objective-C's @synchronized statement.
void setFinallyBody(Stmt *S)
SourceLocation getAtTryLoc() const
Retrieve the location of the @ in the @try.
SourceLocation getBeginLoc() const LLVM_READONLY
void setFinallyStmt(Stmt *S)
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
SourceLocation getEndLoc() const LLVM_READONLY
const Stmt * getTryBody() const
Retrieve the @try body.
SourceLocation getAtLoc() const
static bool classof(const Stmt *T)
void setForLoc(SourceLocation Loc)
SourceLocation getForLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getEndLoc() const LLVM_READONLY
void setAtTryLoc(SourceLocation Loc)
void setSynchExpr(Stmt *S)
Encodes a location in the source.
const Stmt * getCatchBody() const
SourceLocation getBeginLoc() const LLVM_READONLY
void setAtCatchLoc(SourceLocation Loc)
void setCatchParamDecl(VarDecl *D)
SourceLocation getAtFinallyLoc() const
void setThrowLoc(SourceLocation Loc)
SourceLocation getAtCatchLoc() const
ObjCAutoreleasePoolStmt(SourceLocation atLoc, Stmt *subStmt)
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
Dataflow Directional Tag Classes.
const Stmt * getFinallyBody() const
void setCollection(Expr *E)
SourceLocation getBeginLoc() const LLVM_READONLY
StmtClass getStmtClass() const
static bool classof(const Stmt *T)
const Expr * getSynchExpr() const
SourceLocation getRParenLoc() const
void setCatchStmt(unsigned I, ObjCAtCatchStmt *S)
Set a particular catch statement.
Represents Objective-C's collection statement.
void setAtFinallyLoc(SourceLocation Loc)
Represents Objective-C's @finally statement.
void setCatchBody(Stmt *S)
void setAtSynchronizedLoc(SourceLocation Loc)
ObjCAtFinallyStmt(EmptyShell Empty)
ObjCAtThrowStmt(EmptyShell Empty)
SourceLocation getAtSynchronizedLoc() const
Represents Objective-C's @try ... @catch ... @finally statement.
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
SourceLocation getBeginLoc() const LLVM_READONLY
const VarDecl * getCatchParamDecl() const
SourceLocation getEndLoc() const LLVM_READONLY
Represents Objective-C's @autoreleasepool Statement.
SourceLocation getBeginLoc() const LLVM_READONLY
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
void setAtLoc(SourceLocation Loc)