clang: include/clang/AST/StmtObjC.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12#ifndef LLVM_CLANG_AST_STMTOBJC_H

13#define LLVM_CLANG_AST_STMTOBJC_H

14

16#include "llvm/Support/Compiler.h"

17

19

20

21

22

24 enum { ELEM, COLLECTION, BODY, END_EXPR };

25 Stmt* SubExprs[END_EXPR];

28public:

32 Stmt(ObjCForCollectionStmtClass, Empty) { }

33

36 return reinterpret_cast<Expr*>(SubExprs[COLLECTION]);

37 }

39

42 return reinterpret_cast<Expr*>(SubExprs[COLLECTION]);

43 }

44 const Stmt *getBody() const { return SubExprs[BODY]; }

45

48 SubExprs[COLLECTION] = reinterpret_cast<Stmt*>(E);

49 }

51

56

59 return SubExprs[BODY]->getEndLoc();

60 }

61

63 return T->getStmtClass() == ObjCForCollectionStmtClass;

64 }

65

66

68 return child_range(&SubExprs[0], &SubExprs[END_EXPR]);

69 }

70

73 }

74};

75

76

78private:

82

83public:

86 Stmt *atCatchStmt)

87 : Stmt(ObjCAtCatchStmtClass), ExceptionDecl(catchVarDecl),

88 Body(atCatchStmt), AtCatchLoc(atCatchLoc), RParenLoc(rparenloc) { }

89

91 Stmt(ObjCAtCatchStmtClass, Empty) { }

92

96

98 return ExceptionDecl;

99 }

101 return ExceptionDecl;

102 }

104

109

112

114

116 return T->getStmtClass() == ObjCAtCatchStmtClass;

117 }

118

120

123 }

124};

125

126

129 Stmt *AtFinallyStmt;

130

131public:

133 : Stmt(ObjCAtFinallyStmtClass), AtFinallyLoc(atFinallyLoc),

134 AtFinallyStmt(atFinallyStmt) {}

135

137 Stmt(ObjCAtFinallyStmtClass, Empty) { }

138

142

145 return AtFinallyStmt->getEndLoc();

146 }

147

150

152 return T->getStmtClass() == ObjCAtFinallyStmtClass;

153 }

154

156 return child_range(&AtFinallyStmt, &AtFinallyStmt+1);

157 }

158

161 }

162};

163

164

166 : public Stmt,

167 private llvm::TrailingObjects<ObjCAtTryStmt, Stmt *> {

168 friend TrailingObjects;

169 size_t numTrailingObjects(OverloadToken<Stmt *>) const {

170 return 1 + NumCatchStmts + HasFinally;

171 }

172

173

175

176

177 unsigned NumCatchStmts : 16;

178

179

180 LLVM_PREFERRED_TYPE(bool)

181 unsigned HasFinally : 1;

182

183

184

185

186

187

188 Stmt **getStmts() { return getTrailingObjects<Stmt *>(); }

189 Stmt *const *getStmts() const { return getTrailingObjects<Stmt *>(); }

190

192 Stmt **CatchStmts, unsigned NumCatchStmts,

193 Stmt *atFinallyStmt);

194

196 bool HasFinally)

197 : Stmt(ObjCAtTryStmtClass, Empty), NumCatchStmts(NumCatchStmts),

198 HasFinally(HasFinally) { }

199

200public:

203 Stmt **CatchStmts, unsigned NumCatchStmts,

204 Stmt *atFinallyStmt);

206 unsigned NumCatchStmts, bool HasFinally);

207

208

211

212

216

217

218

220

221

223 assert(I < NumCatchStmts && "Out-of-bounds @catch index");

224 return cast_or_null(getStmts()[I + 1]);

225 }

226

227

229 assert(I < NumCatchStmts && "Out-of-bounds @catch index");

230 return cast_or_null(getStmts()[I + 1]);

231 }

232

233

235 assert(I < NumCatchStmts && "Out-of-bounds @catch index");

236 getStmts()[I + 1] = S;

237 }

238

239

241 if (!HasFinally)

242 return nullptr;

243

244 return cast_or_null(getStmts()[1 + NumCatchStmts]);

245 }

247 if (!HasFinally)

248 return nullptr;

249

250 return cast_or_null(getStmts()[1 + NumCatchStmts]);

251 }

253 assert(HasFinally && "@try does not have a @finally slot!");

254 getStmts()[1 + NumCatchStmts] = S;

255 }

256

259

261 return T->getStmtClass() == ObjCAtTryStmtClass;

262 }

263

266 getStmts(), getStmts() + numTrailingObjects(OverloadToken<Stmt *>()));

267 }

268

271 }

272

275 using catch_range = llvm::iterator_range<catch_stmt_iterator>;

277

281 }

284 }

285

289 }

292 }

293};

294

295

296

297

298

299

300

301

302

304private:

306 enum { SYNC_EXPR, SYNC_BODY, END_EXPR };

307 Stmt* SubStmts[END_EXPR];

308

309public:

311 Stmt *synchBody)

312 : Stmt(ObjCAtSynchronizedStmtClass) {

313 SubStmts[SYNC_EXPR] = synchExpr;

314 SubStmts[SYNC_BODY] = synchBody;

315 AtSynchronizedLoc = atSynchronizedLoc;

316 }

318 Stmt(ObjCAtSynchronizedStmtClass, Empty) { }

319

322

324 return reinterpret_cast<CompoundStmt*>(SubStmts[SYNC_BODY]);

325 }

327 return reinterpret_cast<CompoundStmt*>(SubStmts[SYNC_BODY]);

328 }

330

332 return reinterpret_cast<Expr*>(SubStmts[SYNC_EXPR]);

333 }

335 return reinterpret_cast<Expr*>(SubStmts[SYNC_EXPR]);

336 }

338

342 }

343

345 return T->getStmtClass() == ObjCAtSynchronizedStmtClass;

346 }

347

349 return child_range(&SubStmts[0], &SubStmts[0]+END_EXPR);

350 }

351

354 }

355};

356

357

361

362public:

364 : Stmt(ObjCAtThrowStmtClass), Throw(throwExpr) {

365 AtThrowLoc = atThrowLoc;

366 }

368 Stmt(ObjCAtThrowStmtClass, Empty) { }

369

373

376

379 return Throw ? Throw->getEndLoc() : AtThrowLoc;

380 }

381

383 return T->getStmtClass() == ObjCAtThrowStmtClass;

384 }

385

387

390 }

391};

392

393

396 Stmt *SubStmt;

397

398public:

400 : Stmt(ObjCAutoreleasePoolStmtClass), AtLoc(atLoc), SubStmt(subStmt) {}

401

403 Stmt(ObjCAutoreleasePoolStmtClass, Empty) { }

404

408

412 }

413

416

418 return T->getStmtClass() == ObjCAutoreleasePoolStmtClass;

419 }

420

422

425 }

426};

427

428}

429

430#endif

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 * 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

llvm::iterator_range< child_iterator > child_range

llvm::iterator_range< const_child_iterator > const_child_range

Represents a variable declaration or definition.

The JSON file list parser is used to communicate input to InstallAPI.

@ Create

'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...

const FunctionProtoType * T

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....