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);
71 return child_range(&SubExprs[0], &SubExprs[END_EXPR]);
86 :
Stmt(ObjCAtCatchStmtClass), ExceptionDecl(catchVarDecl),
87 Body(atCatchStmt), AtCatchLoc(atCatchLoc), RParenLoc(rparenloc) { }
90 Stmt(ObjCAtCatchStmtClass, Empty) { }
100 return ExceptionDecl;
114 bool hasEllipsis()
const {
return getCatchParamDecl() ==
nullptr; }
130 :
Stmt(ObjCAtFinallyStmtClass), AtFinallyLoc(atFinallyLoc),
131 AtFinallyStmt(atFinallyStmt) {}
134 Stmt(ObjCAtFinallyStmtClass, Empty) { }
155 return child_range(&AtFinallyStmt, &AtFinallyStmt+1);
166 unsigned NumCatchStmts : 16;
176 Stmt **getStmts() {
return reinterpret_cast<Stmt **
> (
this + 1); }
177 const Stmt*
const *getStmts()
const {
178 return reinterpret_cast<const Stmt * const*
> (
this + 1);
182 Stmt **CatchStmts,
unsigned NumCatchStmts,
183 Stmt *atFinallyStmt);
187 :
Stmt(ObjCAtTryStmtClass, Empty), NumCatchStmts(NumCatchStmts),
188 HasFinally(HasFinally) { }
193 Stmt **CatchStmts,
unsigned NumCatchStmts,
194 Stmt *atFinallyStmt);
196 unsigned NumCatchStmts,
bool HasFinally);
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 return cast_or_null<ObjCAtCatchStmt>(getStmts()[I + 1]);
225 assert(I < NumCatchStmts &&
"Out-of-bounds @catch index");
226 getStmts()[I + 1] = S;
234 return cast_or_null<ObjCAtFinallyStmt>(getStmts()[1 + NumCatchStmts]);
240 return cast_or_null<ObjCAtFinallyStmt>(getStmts()[1 + NumCatchStmts]);
243 assert(HasFinally &&
"@try does not have a @finally slot!");
244 getStmts()[1 + NumCatchStmts] = S;
258 getStmts() + 1 + NumCatchStmts + HasFinally);
273 enum { SYNC_EXPR, SYNC_BODY, END_EXPR };
274 Stmt* SubStmts[END_EXPR];
279 :
Stmt(ObjCAtSynchronizedStmtClass) {
280 SubStmts[SYNC_EXPR] = synchExpr;
281 SubStmts[SYNC_BODY] = synchBody;
282 AtSynchronizedLoc = atSynchronizedLoc;
285 Stmt(ObjCAtSynchronizedStmtClass, Empty) { }
291 return reinterpret_cast<CompoundStmt*
>(SubStmts[SYNC_BODY]);
294 return reinterpret_cast<CompoundStmt*
>(SubStmts[SYNC_BODY]);
299 return reinterpret_cast<Expr*
>(SubStmts[SYNC_EXPR]);
302 return reinterpret_cast<Expr*
>(SubStmts[SYNC_EXPR]);
310 return getSynchBody()->getLocEnd();
314 return T->
getStmtClass() == ObjCAtSynchronizedStmtClass;
318 return child_range(&SubStmts[0], &SubStmts[0]+END_EXPR);
329 :
Stmt(ObjCAtThrowStmtClass), Throw(throwExpr) {
330 AtThrowLoc = atThrowLoc;
333 Stmt(ObjCAtThrowStmtClass, Empty) { }
346 return Throw ? Throw->
getLocEnd() : AtThrowLoc;
363 :
Stmt(ObjCAutoreleasePoolStmtClass), AtLoc(atLoc), SubStmt(subStmt) {}
366 Stmt(ObjCAutoreleasePoolStmtClass, Empty) { }
383 return T->
getStmtClass() == ObjCAutoreleasePoolStmtClass;
SourceLocation getLocStart() const LLVM_READONLY
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
SourceLocation getLocStart() const LLVM_READONLY
static bool classof(const Stmt *T)
SourceLocation getLocStart() const LLVM_READONLY
Represents a variable declaration or definition.
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
const Stmt * getSubStmt() const
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 getEndLoc() const LLVM_READONLY
const Stmt * getElement() const
SourceLocation getLocEnd() const LLVM_READONLY
SourceLocation getEndLoc() const LLVM_READONLY
Represents Objective-C's @catch statement.
SourceLocation getEndLoc() const LLVM_READONLY
static bool classof(const Stmt *T)
SourceLocation getLocEnd() const LLVM_READONLY
const Expr * getThrowExpr() const
void setSynchBody(Stmt *S)
static bool classof(const Stmt *T)
ObjCAtSynchronizedStmt(EmptyShell Empty)
SourceLocation getLocEnd() const LLVM_READONLY
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 }.
SourceLocation getLocEnd() const LLVM_READONLY
CompoundStmt * getSynchBody()
SourceLocation getThrowLoc() const LLVM_READONLY
ObjCAtFinallyStmt(SourceLocation atFinallyLoc, Stmt *atFinallyStmt)
void setRParenLoc(SourceLocation Loc)
SourceLocation getLocStart() const LLVM_READONLY
Expr - 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
void setAtTryLoc(SourceLocation Loc)
void setSynchExpr(Stmt *S)
SourceLocation getLocStart() const LLVM_READONLY
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
SourceLocation getLocEnd() const LLVM_READONLY
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)
SourceLocation getLocEnd() const LLVM_READONLY
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 getLocEnd() const LLVM_READONLY
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getLocStart() const LLVM_READONLY
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)