| 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 | |
| 15 | #include "clang/AST/Stmt.h" |
| 16 | #include "llvm/Support/Compiler.h" |
| 17 | |
| 18 | namespace clang { |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | class ObjCForCollectionStmt : public Stmt { |
| 24 | enum { ELEM, COLLECTION, BODY, END_EXPR }; |
| 25 | Stmt* SubExprs[END_EXPR]; |
| 26 | SourceLocation ForLoc; |
| 27 | SourceLocation RParenLoc; |
| 28 | public: |
| 29 | ObjCForCollectionStmt(Stmt *Elem, Expr *Collect, Stmt *Body, |
| 30 | SourceLocation FCL, SourceLocation RPL); |
| 31 | explicit ObjCForCollectionStmt(EmptyShell Empty) : |
| 32 | Stmt(ObjCForCollectionStmtClass, Empty) { } |
| 33 | |
| 34 | Stmt *getElement() { return SubExprs[ELEM]; } |
| 35 | Expr *getCollection() { |
| 36 | return reinterpret_cast<Expr*>(SubExprs[COLLECTION]); |
| 37 | } |
| 38 | Stmt *getBody() { return SubExprs[BODY]; } |
| 39 | |
| 40 | const Stmt *getElement() const { return SubExprs[ELEM]; } |
| 41 | const Expr *getCollection() const { |
| 42 | return reinterpret_cast<Expr*>(SubExprs[COLLECTION]); |
| 43 | } |
| 44 | const Stmt *getBody() const { return SubExprs[BODY]; } |
| 45 | |
| 46 | void setElement(Stmt *S) { SubExprs[ELEM] = S; } |
| 47 | void setCollection(Expr *E) { |
| 48 | SubExprs[COLLECTION] = reinterpret_cast<Stmt*>(E); |
| 49 | } |
| 50 | void setBody(Stmt *S) { SubExprs[BODY] = S; } |
| 51 | |
| 52 | SourceLocation getForLoc() const { return ForLoc; } |
| 53 | void setForLoc(SourceLocation Loc) { ForLoc = Loc; } |
| 54 | SourceLocation getRParenLoc() const { return RParenLoc; } |
| 55 | void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } |
| 56 | |
| 57 | SourceLocation getBeginLoc() const LLVM_READONLY { return ForLoc; } |
| 58 | SourceLocation getEndLoc() const LLVM_READONLY { |
| 59 | return SubExprs[BODY]->getEndLoc(); |
| 60 | } |
| 61 | |
| 62 | static bool classof(const Stmt *T) { |
| 63 | return T->getStmtClass() == ObjCForCollectionStmtClass; |
| 64 | } |
| 65 | |
| 66 | |
| 67 | child_range children() { |
| 68 | return child_range(&SubExprs[0], &SubExprs[END_EXPR]); |
| 69 | } |
| 70 | }; |
| 71 | |
| 72 | |
| 73 | class ObjCAtCatchStmt : public Stmt { |
| 74 | private: |
| 75 | VarDecl *ExceptionDecl; |
| 76 | Stmt *Body; |
| 77 | SourceLocation AtCatchLoc, RParenLoc; |
| 78 | |
| 79 | public: |
| 80 | ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc, |
| 81 | VarDecl *catchVarDecl, |
| 82 | Stmt *atCatchStmt) |
| 83 | : Stmt(ObjCAtCatchStmtClass), ExceptionDecl(catchVarDecl), |
| 84 | Body(atCatchStmt), AtCatchLoc(atCatchLoc), RParenLoc(rparenloc) { } |
| 85 | |
| 86 | explicit ObjCAtCatchStmt(EmptyShell Empty) : |
| 87 | Stmt(ObjCAtCatchStmtClass, Empty) { } |
| 88 | |
| 89 | const Stmt *getCatchBody() const { return Body; } |
| 90 | Stmt *getCatchBody() { return Body; } |
| 91 | void setCatchBody(Stmt *S) { Body = S; } |
| 92 | |
| 93 | const VarDecl *getCatchParamDecl() const { |
| 94 | return ExceptionDecl; |
| 95 | } |
| 96 | VarDecl *getCatchParamDecl() { |
| 97 | return ExceptionDecl; |
| 98 | } |
| 99 | void setCatchParamDecl(VarDecl *D) { ExceptionDecl = D; } |
| 100 | |
| 101 | SourceLocation getAtCatchLoc() const { return AtCatchLoc; } |
| 102 | void setAtCatchLoc(SourceLocation Loc) { AtCatchLoc = Loc; } |
| 103 | SourceLocation getRParenLoc() const { return RParenLoc; } |
| 104 | void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } |
| 105 | |
| 106 | SourceLocation getBeginLoc() const LLVM_READONLY { return AtCatchLoc; } |
| 107 | SourceLocation getEndLoc() const LLVM_READONLY { return Body->getEndLoc(); } |
| 108 | |
| 109 | bool hasEllipsis() const { return getCatchParamDecl() == nullptr; } |
| 110 | |
| 111 | static bool classof(const Stmt *T) { |
| 112 | return T->getStmtClass() == ObjCAtCatchStmtClass; |
| 113 | } |
| 114 | |
| 115 | child_range children() { return child_range(&Body, &Body + 1); } |
| 116 | }; |
| 117 | |
| 118 | |
| 119 | class ObjCAtFinallyStmt : public Stmt { |
| 120 | SourceLocation AtFinallyLoc; |
| 121 | Stmt *AtFinallyStmt; |
| 122 | |
| 123 | public: |
| 124 | ObjCAtFinallyStmt(SourceLocation atFinallyLoc, Stmt *atFinallyStmt) |
| 125 | : Stmt(ObjCAtFinallyStmtClass), AtFinallyLoc(atFinallyLoc), |
| 126 | AtFinallyStmt(atFinallyStmt) {} |
| 127 | |
| 128 | explicit ObjCAtFinallyStmt(EmptyShell Empty) : |
| 129 | Stmt(ObjCAtFinallyStmtClass, Empty) { } |
| 130 | |
| 131 | const Stmt *getFinallyBody() const { return AtFinallyStmt; } |
| 132 | Stmt *getFinallyBody() { return AtFinallyStmt; } |
| 133 | void setFinallyBody(Stmt *S) { AtFinallyStmt = S; } |
| 134 | |
| 135 | SourceLocation getBeginLoc() const LLVM_READONLY { return AtFinallyLoc; } |
| 136 | SourceLocation getEndLoc() const LLVM_READONLY { |
| 137 | return AtFinallyStmt->getEndLoc(); |
| 138 | } |
| 139 | |
| 140 | SourceLocation getAtFinallyLoc() const { return AtFinallyLoc; } |
| 141 | void setAtFinallyLoc(SourceLocation Loc) { AtFinallyLoc = Loc; } |
| 142 | |
| 143 | static bool classof(const Stmt *T) { |
| 144 | return T->getStmtClass() == ObjCAtFinallyStmtClass; |
| 145 | } |
| 146 | |
| 147 | child_range children() { |
| 148 | return child_range(&AtFinallyStmt, &AtFinallyStmt+1); |
| 149 | } |
| 150 | }; |
| 151 | |
| 152 | |
| 153 | class ObjCAtTryStmt : public Stmt { |
| 154 | private: |
| 155 | |
| 156 | SourceLocation AtTryLoc; |
| 157 | |
| 158 | |
| 159 | unsigned NumCatchStmts : 16; |
| 160 | |
| 161 | |
| 162 | bool HasFinally : 1; |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | Stmt **getStmts() { return reinterpret_cast<Stmt **> (this + 1); } |
| 170 | const Stmt* const *getStmts() const { |
| 171 | return reinterpret_cast<const Stmt * const*> (this + 1); |
| 172 | } |
| 173 | |
| 174 | ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt, |
| 175 | Stmt **CatchStmts, unsigned NumCatchStmts, |
| 176 | Stmt *atFinallyStmt); |
| 177 | |
| 178 | explicit ObjCAtTryStmt(EmptyShell Empty, unsigned NumCatchStmts, |
| 179 | bool HasFinally) |
| 180 | : Stmt(ObjCAtTryStmtClass, Empty), NumCatchStmts(NumCatchStmts), |
| 181 | HasFinally(HasFinally) { } |
| 182 | |
| 183 | public: |
| 184 | static ObjCAtTryStmt *Create(const ASTContext &Context, |
| 185 | SourceLocation atTryLoc, Stmt *atTryStmt, |
| 186 | Stmt **CatchStmts, unsigned NumCatchStmts, |
| 187 | Stmt *atFinallyStmt); |
| 188 | static ObjCAtTryStmt *CreateEmpty(const ASTContext &Context, |
| 189 | unsigned NumCatchStmts, bool HasFinally); |
| 190 | |
| 191 | |
| 192 | SourceLocation getAtTryLoc() const { return AtTryLoc; } |
| 193 | void setAtTryLoc(SourceLocation Loc) { AtTryLoc = Loc; } |
| 194 | |
| 195 | |
| 196 | const Stmt *getTryBody() const { return getStmts()[0]; } |
| 197 | Stmt *getTryBody() { return getStmts()[0]; } |
| 198 | void setTryBody(Stmt *S) { getStmts()[0] = S; } |
| 199 | |
| 200 | |
| 201 | |
| 202 | unsigned getNumCatchStmts() const { return NumCatchStmts; } |
| 203 | |
| 204 | |
| 205 | const ObjCAtCatchStmt *getCatchStmt(unsigned I) const { |
| 206 | (0) . __assert_fail ("I < NumCatchStmts && \"Out-of-bounds @catch index\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/StmtObjC.h", 206, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(I < NumCatchStmts && "Out-of-bounds @catch index"); |
| 207 | return cast_or_null<ObjCAtCatchStmt>(getStmts()[I + 1]); |
| 208 | } |
| 209 | |
| 210 | |
| 211 | ObjCAtCatchStmt *getCatchStmt(unsigned I) { |
| 212 | (0) . __assert_fail ("I < NumCatchStmts && \"Out-of-bounds @catch index\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/StmtObjC.h", 212, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(I < NumCatchStmts && "Out-of-bounds @catch index"); |
| 213 | return cast_or_null<ObjCAtCatchStmt>(getStmts()[I + 1]); |
| 214 | } |
| 215 | |
| 216 | |
| 217 | void setCatchStmt(unsigned I, ObjCAtCatchStmt *S) { |
| 218 | (0) . __assert_fail ("I < NumCatchStmts && \"Out-of-bounds @catch index\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/StmtObjC.h", 218, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(I < NumCatchStmts && "Out-of-bounds @catch index"); |
| 219 | getStmts()[I + 1] = S; |
| 220 | } |
| 221 | |
| 222 | |
| 223 | const ObjCAtFinallyStmt *getFinallyStmt() const { |
| 224 | if (!HasFinally) |
| 225 | return nullptr; |
| 226 | |
| 227 | return cast_or_null<ObjCAtFinallyStmt>(getStmts()[1 + NumCatchStmts]); |
| 228 | } |
| 229 | ObjCAtFinallyStmt *getFinallyStmt() { |
| 230 | if (!HasFinally) |
| 231 | return nullptr; |
| 232 | |
| 233 | return cast_or_null<ObjCAtFinallyStmt>(getStmts()[1 + NumCatchStmts]); |
| 234 | } |
| 235 | void setFinallyStmt(Stmt *S) { |
| 236 | (0) . __assert_fail ("HasFinally && \"@try does not have a @finally slot!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/StmtObjC.h", 236, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(HasFinally && "@try does not have a @finally slot!"); |
| 237 | getStmts()[1 + NumCatchStmts] = S; |
| 238 | } |
| 239 | |
| 240 | SourceLocation getBeginLoc() const LLVM_READONLY { return AtTryLoc; } |
| 241 | SourceLocation getEndLoc() const LLVM_READONLY; |
| 242 | |
| 243 | static bool classof(const Stmt *T) { |
| 244 | return T->getStmtClass() == ObjCAtTryStmtClass; |
| 245 | } |
| 246 | |
| 247 | child_range children() { |
| 248 | return child_range(getStmts(), |
| 249 | getStmts() + 1 + NumCatchStmts + HasFinally); |
| 250 | } |
| 251 | }; |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | class ObjCAtSynchronizedStmt : public Stmt { |
| 262 | private: |
| 263 | SourceLocation AtSynchronizedLoc; |
| 264 | enum { SYNC_EXPR, SYNC_BODY, END_EXPR }; |
| 265 | Stmt* SubStmts[END_EXPR]; |
| 266 | |
| 267 | public: |
| 268 | ObjCAtSynchronizedStmt(SourceLocation atSynchronizedLoc, Stmt *synchExpr, |
| 269 | Stmt *synchBody) |
| 270 | : Stmt(ObjCAtSynchronizedStmtClass) { |
| 271 | SubStmts[SYNC_EXPR] = synchExpr; |
| 272 | SubStmts[SYNC_BODY] = synchBody; |
| 273 | AtSynchronizedLoc = atSynchronizedLoc; |
| 274 | } |
| 275 | explicit ObjCAtSynchronizedStmt(EmptyShell Empty) : |
| 276 | Stmt(ObjCAtSynchronizedStmtClass, Empty) { } |
| 277 | |
| 278 | SourceLocation getAtSynchronizedLoc() const { return AtSynchronizedLoc; } |
| 279 | void setAtSynchronizedLoc(SourceLocation Loc) { AtSynchronizedLoc = Loc; } |
| 280 | |
| 281 | const CompoundStmt *getSynchBody() const { |
| 282 | return reinterpret_cast<CompoundStmt*>(SubStmts[SYNC_BODY]); |
| 283 | } |
| 284 | CompoundStmt *getSynchBody() { |
| 285 | return reinterpret_cast<CompoundStmt*>(SubStmts[SYNC_BODY]); |
| 286 | } |
| 287 | void setSynchBody(Stmt *S) { SubStmts[SYNC_BODY] = S; } |
| 288 | |
| 289 | const Expr *getSynchExpr() const { |
| 290 | return reinterpret_cast<Expr*>(SubStmts[SYNC_EXPR]); |
| 291 | } |
| 292 | Expr *getSynchExpr() { |
| 293 | return reinterpret_cast<Expr*>(SubStmts[SYNC_EXPR]); |
| 294 | } |
| 295 | void setSynchExpr(Stmt *S) { SubStmts[SYNC_EXPR] = S; } |
| 296 | |
| 297 | SourceLocation getBeginLoc() const LLVM_READONLY { return AtSynchronizedLoc; } |
| 298 | SourceLocation getEndLoc() const LLVM_READONLY { |
| 299 | return getSynchBody()->getEndLoc(); |
| 300 | } |
| 301 | |
| 302 | static bool classof(const Stmt *T) { |
| 303 | return T->getStmtClass() == ObjCAtSynchronizedStmtClass; |
| 304 | } |
| 305 | |
| 306 | child_range children() { |
| 307 | return child_range(&SubStmts[0], &SubStmts[0]+END_EXPR); |
| 308 | } |
| 309 | }; |
| 310 | |
| 311 | |
| 312 | class ObjCAtThrowStmt : public Stmt { |
| 313 | SourceLocation AtThrowLoc; |
| 314 | Stmt *Throw; |
| 315 | |
| 316 | public: |
| 317 | ObjCAtThrowStmt(SourceLocation atThrowLoc, Stmt *throwExpr) |
| 318 | : Stmt(ObjCAtThrowStmtClass), Throw(throwExpr) { |
| 319 | AtThrowLoc = atThrowLoc; |
| 320 | } |
| 321 | explicit ObjCAtThrowStmt(EmptyShell Empty) : |
| 322 | Stmt(ObjCAtThrowStmtClass, Empty) { } |
| 323 | |
| 324 | const Expr *getThrowExpr() const { return reinterpret_cast<Expr*>(Throw); } |
| 325 | Expr *getThrowExpr() { return reinterpret_cast<Expr*>(Throw); } |
| 326 | void setThrowExpr(Stmt *S) { Throw = S; } |
| 327 | |
| 328 | SourceLocation getThrowLoc() const LLVM_READONLY { return AtThrowLoc; } |
| 329 | void setThrowLoc(SourceLocation Loc) { AtThrowLoc = Loc; } |
| 330 | |
| 331 | SourceLocation getBeginLoc() const LLVM_READONLY { return AtThrowLoc; } |
| 332 | SourceLocation getEndLoc() const LLVM_READONLY { |
| 333 | return Throw ? Throw->getEndLoc() : AtThrowLoc; |
| 334 | } |
| 335 | |
| 336 | static bool classof(const Stmt *T) { |
| 337 | return T->getStmtClass() == ObjCAtThrowStmtClass; |
| 338 | } |
| 339 | |
| 340 | child_range children() { return child_range(&Throw, &Throw+1); } |
| 341 | }; |
| 342 | |
| 343 | |
| 344 | class ObjCAutoreleasePoolStmt : public Stmt { |
| 345 | SourceLocation AtLoc; |
| 346 | Stmt *SubStmt; |
| 347 | |
| 348 | public: |
| 349 | ObjCAutoreleasePoolStmt(SourceLocation atLoc, Stmt *subStmt) |
| 350 | : Stmt(ObjCAutoreleasePoolStmtClass), AtLoc(atLoc), SubStmt(subStmt) {} |
| 351 | |
| 352 | explicit ObjCAutoreleasePoolStmt(EmptyShell Empty) : |
| 353 | Stmt(ObjCAutoreleasePoolStmtClass, Empty) { } |
| 354 | |
| 355 | const Stmt *getSubStmt() const { return SubStmt; } |
| 356 | Stmt *getSubStmt() { return SubStmt; } |
| 357 | void setSubStmt(Stmt *S) { SubStmt = S; } |
| 358 | |
| 359 | SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; } |
| 360 | SourceLocation getEndLoc() const LLVM_READONLY { |
| 361 | return SubStmt->getEndLoc(); |
| 362 | } |
| 363 | |
| 364 | SourceLocation getAtLoc() const { return AtLoc; } |
| 365 | void setAtLoc(SourceLocation Loc) { AtLoc = Loc; } |
| 366 | |
| 367 | static bool classof(const Stmt *T) { |
| 368 | return T->getStmtClass() == ObjCAutoreleasePoolStmtClass; |
| 369 | } |
| 370 | |
| 371 | child_range children() { return child_range(&SubStmt, &SubStmt + 1); } |
| 372 | }; |
| 373 | |
| 374 | } |
| 375 | |
| 376 | #endif |
| 377 | |