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);
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) { }
110 bool hasEllipsis()
const {
return getCatchParamDecl() ==
nullptr; }
126 :
Stmt(ObjCAtFinallyStmtClass), AtFinallyLoc(atFinallyLoc),
127 AtFinallyStmt(atFinallyStmt) {}
130 Stmt(ObjCAtFinallyStmtClass, Empty) { }
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);
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;
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]);
300 return getSynchBody()->getEndLoc();
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->
getEndLoc() : AtThrowLoc;
351 :
Stmt(ObjCAutoreleasePoolStmtClass), AtLoc(atLoc), SubStmt(subStmt) {}
354 Stmt(ObjCAutoreleasePoolStmtClass, Empty) { }
369 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)