 |
|
 |
|
| Files: |
1 |
|
Branches Taken: |
7.7% |
2 / 26 |
| Generated: |
2010-02-10 01:31 |
|
Branches Executed: |
7.7% |
2 / 26 |
| |
|
Line Coverage: |
66.4% |
85 / 128 |
| |
 |
|
 |
1 : //===--- StmtObjC.h - Classes for representing ObjC statements --*- C++ -*-===//
2 : //
3 : // The LLVM Compiler Infrastructure
4 : //
5 : // This file is distributed under the University of Illinois Open Source
6 : // License. See LICENSE.TXT for details.
7 : //
8 : //===----------------------------------------------------------------------===//
9 : //
10 : // This file defines the Objective-C statement AST node classes.
11 : //
12 : //===----------------------------------------------------------------------===//
13 :
14 : #ifndef LLVM_CLANG_AST_STMTOBJC_H
15 : #define LLVM_CLANG_AST_STMTOBJC_H
16 :
17 : #include "clang/AST/Stmt.h"
18 :
19 : namespace clang {
20 :
21 : /// ObjCForCollectionStmt - This represents Objective-c's collection statement;
22 : /// represented as 'for (element 'in' collection-expression)' stmt.
23 : ///
0: branch 1 not taken
0: branch 2 not taken
0: branch 5 not taken
0: branch 6 not taken
24 0: class ObjCForCollectionStmt : public Stmt {
25 : enum { ELEM, COLLECTION, BODY, END_EXPR };
26 : Stmt* SubExprs[END_EXPR]; // SubExprs[ELEM] is an expression or declstmt.
27 : SourceLocation ForLoc;
28 : SourceLocation RParenLoc;
29 : public:
30 : ObjCForCollectionStmt(Stmt *Elem, Expr *Collect, Stmt *Body,
31 : SourceLocation FCL, SourceLocation RPL);
32 0: explicit ObjCForCollectionStmt(EmptyShell Empty) :
33 0: Stmt(ObjCForCollectionStmtClass, Empty) { }
34 :
35 129: Stmt *getElement() { return SubExprs[ELEM]; }
36 64: Expr *getCollection() {
37 64: return reinterpret_cast<Expr*>(SubExprs[COLLECTION]);
38 : }
39 37: Stmt *getBody() { return SubExprs[BODY]; }
40 :
41 5: const Stmt *getElement() const { return SubExprs[ELEM]; }
42 5: const Expr *getCollection() const {
43 5: return reinterpret_cast<Expr*>(SubExprs[COLLECTION]);
44 : }
45 5: const Stmt *getBody() const { return SubExprs[BODY]; }
46 :
47 0: void setElement(Stmt *S) { SubExprs[ELEM] = S; }
48 0: void setCollection(Expr *E) {
49 0: SubExprs[COLLECTION] = reinterpret_cast<Stmt*>(E);
50 0: }
51 0: void setBody(Stmt *S) { SubExprs[BODY] = S; }
52 :
53 0: SourceLocation getForLoc() const { return ForLoc; }
54 0: void setForLoc(SourceLocation Loc) { ForLoc = Loc; }
55 16: SourceLocation getRParenLoc() const { return RParenLoc; }
56 0: void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
57 :
58 124: virtual SourceRange getSourceRange() const {
59 124: return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd());
60 : }
61 2149: static bool classof(const Stmt *T) {
62 2149: return T->getStmtClass() == ObjCForCollectionStmtClass;
63 : }
64 : static bool classof(const ObjCForCollectionStmt *) { return true; }
65 :
66 : // Iterators
67 : virtual child_iterator child_begin();
68 : virtual child_iterator child_end();
69 : };
70 :
71 : /// ObjCAtCatchStmt - This represents objective-c's @catch statement.
0: branch 1 not taken
0: branch 2 not taken
0: branch 5 not taken
0: branch 6 not taken
72 0: class ObjCAtCatchStmt : public Stmt {
73 : private:
74 : enum { BODY, NEXT_CATCH, END_EXPR };
75 : ParmVarDecl *ExceptionDecl;
76 : Stmt *SubExprs[END_EXPR];
77 : SourceLocation AtCatchLoc, RParenLoc;
78 :
79 : public:
80 : ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc,
81 : ParmVarDecl *catchVarDecl,
82 : Stmt *atCatchStmt, Stmt *atCatchList);
83 :
84 0: explicit ObjCAtCatchStmt(EmptyShell Empty) :
85 0: Stmt(ObjCAtCatchStmtClass, Empty) { }
86 :
87 17: const Stmt *getCatchBody() const { return SubExprs[BODY]; }
88 63: Stmt *getCatchBody() { return SubExprs[BODY]; }
89 0: void setCatchBody(Stmt *S) { SubExprs[BODY] = S; }
90 :
91 12: const ObjCAtCatchStmt *getNextCatchStmt() const {
92 12: return static_cast<const ObjCAtCatchStmt*>(SubExprs[NEXT_CATCH]);
93 : }
94 88: ObjCAtCatchStmt *getNextCatchStmt() {
95 88: return static_cast<ObjCAtCatchStmt*>(SubExprs[NEXT_CATCH]);
96 : }
97 0: void setNextCatchStmt(Stmt *S) { SubExprs[NEXT_CATCH] = S; }
98 :
99 23: const ParmVarDecl *getCatchParamDecl() const {
100 23: return ExceptionDecl;
101 : }
102 10: ParmVarDecl *getCatchParamDecl() {
103 10: return ExceptionDecl;
104 : }
105 0: void setCatchParamDecl(ParmVarDecl *D) { ExceptionDecl = D; }
106 :
107 55: SourceLocation getAtCatchLoc() const { return AtCatchLoc; }
108 0: void setAtCatchLoc(SourceLocation Loc) { AtCatchLoc = Loc; }
109 6: SourceLocation getRParenLoc() const { return RParenLoc; }
110 0: void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
111 :
112 14: virtual SourceRange getSourceRange() const {
113 14: return SourceRange(AtCatchLoc, SubExprs[BODY]->getLocEnd());
114 : }
115 :
116 6: bool hasEllipsis() const { return getCatchParamDecl() == 0; }
117 :
118 112: static bool classof(const Stmt *T) {
119 112: return T->getStmtClass() == ObjCAtCatchStmtClass;
120 : }
121 : static bool classof(const ObjCAtCatchStmt *) { return true; }
122 :
123 : virtual child_iterator child_begin();
124 : virtual child_iterator child_end();
125 : };
126 :
127 : /// ObjCAtFinallyStmt - This represent objective-c's @finally Statement
0: branch 1 not taken
0: branch 2 not taken
0: branch 5 not taken
0: branch 6 not taken
128 0: class ObjCAtFinallyStmt : public Stmt {
129 : Stmt *AtFinallyStmt;
130 : SourceLocation AtFinallyLoc;
131 : public:
132 21: ObjCAtFinallyStmt(SourceLocation atFinallyLoc, Stmt *atFinallyStmt)
133 : : Stmt(ObjCAtFinallyStmtClass),
134 21: AtFinallyStmt(atFinallyStmt), AtFinallyLoc(atFinallyLoc) {}
135 :
136 0: explicit ObjCAtFinallyStmt(EmptyShell Empty) :
137 0: Stmt(ObjCAtFinallyStmtClass, Empty) { }
138 :
139 4: const Stmt *getFinallyBody() const { return AtFinallyStmt; }
140 5: Stmt *getFinallyBody() { return AtFinallyStmt; }
141 0: void setFinallyBody(Stmt *S) { AtFinallyStmt = S; }
142 :
143 9: virtual SourceRange getSourceRange() const {
144 9: return SourceRange(AtFinallyLoc, AtFinallyStmt->getLocEnd());
145 : }
146 :
147 21: SourceLocation getAtFinallyLoc() const { return AtFinallyLoc; }
148 0: void setAtFinallyLoc(SourceLocation Loc) { AtFinallyLoc = Loc; }
149 :
150 60: static bool classof(const Stmt *T) {
151 60: return T->getStmtClass() == ObjCAtFinallyStmtClass;
152 : }
153 : static bool classof(const ObjCAtFinallyStmt *) { return true; }
154 :
155 : virtual child_iterator child_begin();
156 : virtual child_iterator child_end();
157 : };
158 :
159 : /// ObjCAtTryStmt - This represent objective-c's over-all
160 : /// @try ... @catch ... @finally statement.
0: branch 1 not taken
0: branch 2 not taken
0: branch 5 not taken
0: branch 6 not taken
161 0: class ObjCAtTryStmt : public Stmt {
162 : private:
163 : enum { TRY, CATCH, FINALLY, END_EXPR };
164 : Stmt* SubStmts[END_EXPR];
165 :
166 : SourceLocation AtTryLoc;
167 : public:
168 : ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt,
169 : Stmt *atCatchStmt,
170 46: Stmt *atFinallyStmt)
171 46: : Stmt(ObjCAtTryStmtClass) {
172 46: SubStmts[TRY] = atTryStmt;
173 46: SubStmts[CATCH] = atCatchStmt;
174 46: SubStmts[FINALLY] = atFinallyStmt;
175 46: AtTryLoc = atTryLoc;
176 46: }
177 0: explicit ObjCAtTryStmt(EmptyShell Empty) :
178 0: Stmt(ObjCAtTryStmtClass, Empty) { }
179 :
180 46: SourceLocation getAtTryLoc() const { return AtTryLoc; }
181 0: void setAtTryLoc(SourceLocation Loc) { AtTryLoc = Loc; }
182 :
183 : const Stmt *getTryBody() const { return SubStmts[TRY]; }
184 75: Stmt *getTryBody() { return SubStmts[TRY]; }
185 0: void setTryBody(Stmt *S) { SubStmts[TRY] = S; }
186 :
187 : const ObjCAtCatchStmt *getCatchStmts() const {
188 : return dyn_cast_or_null<ObjCAtCatchStmt>(SubStmts[CATCH]);
189 : }
190 72: ObjCAtCatchStmt *getCatchStmts() {
191 72: return dyn_cast_or_null<ObjCAtCatchStmt>(SubStmts[CATCH]);
192 : }
193 0: void setCatchStmts(Stmt *S) { SubStmts[CATCH] = S; }
194 :
195 : const ObjCAtFinallyStmt *getFinallyStmt() const {
196 : return dyn_cast_or_null<ObjCAtFinallyStmt>(SubStmts[FINALLY]);
197 : }
198 70: ObjCAtFinallyStmt *getFinallyStmt() {
199 70: return dyn_cast_or_null<ObjCAtFinallyStmt>(SubStmts[FINALLY]);
200 : }
201 0: void setFinallyStmt(Stmt *S) { SubStmts[FINALLY] = S; }
202 :
203 18: virtual SourceRange getSourceRange() const {
204 18: return SourceRange(AtTryLoc, SubStmts[TRY]->getLocEnd());
205 : }
206 :
207 3179: static bool classof(const Stmt *T) {
208 3179: return T->getStmtClass() == ObjCAtTryStmtClass;
209 : }
210 : static bool classof(const ObjCAtTryStmt *) { return true; }
211 :
212 : virtual child_iterator child_begin();
213 : virtual child_iterator child_end();
214 : };
215 :
216 : /// ObjCAtSynchronizedStmt - This is for objective-c's @synchronized statement.
217 : /// Example: @synchronized (sem) {
218 : /// do-something;
219 : /// }
220 : ///
0: branch 1 not taken
0: branch 2 not taken
0: branch 5 not taken
0: branch 6 not taken
221 0: class ObjCAtSynchronizedStmt : public Stmt {
222 : private:
223 : enum { SYNC_EXPR, SYNC_BODY, END_EXPR };
224 : Stmt* SubStmts[END_EXPR];
225 : SourceLocation AtSynchronizedLoc;
226 :
227 : public:
228 : ObjCAtSynchronizedStmt(SourceLocation atSynchronizedLoc, Stmt *synchExpr,
229 20: Stmt *synchBody)
230 20: : Stmt(ObjCAtSynchronizedStmtClass) {
231 20: SubStmts[SYNC_EXPR] = synchExpr;
232 20: SubStmts[SYNC_BODY] = synchBody;
233 20: AtSynchronizedLoc = atSynchronizedLoc;
234 20: }
235 0: explicit ObjCAtSynchronizedStmt(EmptyShell Empty) :
236 0: Stmt(ObjCAtSynchronizedStmtClass, Empty) { }
237 :
238 20: SourceLocation getAtSynchronizedLoc() const { return AtSynchronizedLoc; }
239 0: void setAtSynchronizedLoc(SourceLocation Loc) { AtSynchronizedLoc = Loc; }
240 :
241 20: const CompoundStmt *getSynchBody() const {
242 20: return reinterpret_cast<CompoundStmt*>(SubStmts[SYNC_BODY]);
243 : }
244 46: CompoundStmt *getSynchBody() {
245 46: return reinterpret_cast<CompoundStmt*>(SubStmts[SYNC_BODY]);
246 : }
247 0: void setSynchBody(Stmt *S) { SubStmts[SYNC_BODY] = S; }
248 :
249 : const Expr *getSynchExpr() const {
250 : return reinterpret_cast<Expr*>(SubStmts[SYNC_EXPR]);
251 : }
252 38: Expr *getSynchExpr() {
253 38: return reinterpret_cast<Expr*>(SubStmts[SYNC_EXPR]);
254 : }
255 0: void setSynchExpr(Stmt *S) { SubStmts[SYNC_EXPR] = S; }
256 :
257 20: virtual SourceRange getSourceRange() const {
258 20: return SourceRange(AtSynchronizedLoc, getSynchBody()->getLocEnd());
259 : }
260 :
261 3053: static bool classof(const Stmt *T) {
262 3053: return T->getStmtClass() == ObjCAtSynchronizedStmtClass;
263 : }
264 : static bool classof(const ObjCAtSynchronizedStmt *) { return true; }
265 :
266 : virtual child_iterator child_begin();
267 : virtual child_iterator child_end();
268 : };
269 :
270 : /// ObjCAtThrowStmt - This represents objective-c's @throw statement.
0: branch 1 not taken
0: branch 2 not taken
0: branch 5 not taken
0: branch 6 not taken
271 0: class ObjCAtThrowStmt : public Stmt {
272 : Stmt *Throw;
273 : SourceLocation AtThrowLoc;
274 : public:
275 24: ObjCAtThrowStmt(SourceLocation atThrowLoc, Stmt *throwExpr)
276 24: : Stmt(ObjCAtThrowStmtClass), Throw(throwExpr) {
277 24: AtThrowLoc = atThrowLoc;
278 24: }
279 0: explicit ObjCAtThrowStmt(EmptyShell Empty) :
280 0: Stmt(ObjCAtThrowStmtClass, Empty) { }
281 :
282 8: const Expr *getThrowExpr() const { return reinterpret_cast<Expr*>(Throw); }
283 5: Expr *getThrowExpr() { return reinterpret_cast<Expr*>(Throw); }
284 0: void setThrowExpr(Stmt *S) { Throw = S; }
285 :
286 0: SourceLocation getThrowLoc() { return AtThrowLoc; }
287 0: void setThrowLoc(SourceLocation Loc) { AtThrowLoc = Loc; }
288 :
289 8: virtual SourceRange getSourceRange() const {
2: branch 0 taken
6: branch 1 taken
290 8: if (Throw)
291 2: return SourceRange(AtThrowLoc, Throw->getLocEnd());
292 : else
293 6: return SourceRange(AtThrowLoc);
294 : }
295 :
296 1087: static bool classof(const Stmt *T) {
297 1087: return T->getStmtClass() == ObjCAtThrowStmtClass;
298 : }
299 : static bool classof(const ObjCAtThrowStmt *) { return true; }
300 :
301 : virtual child_iterator child_begin();
302 : virtual child_iterator child_end();
303 : };
304 :
305 : } // end namespace clang
306 :
307 : #endif
Generated: 2010-02-10 01:31 by zcov