 |
|
 |
|
| Files: |
1 |
|
Branches Taken: |
58.3% |
168 / 288 |
| Generated: |
2010-02-10 01:31 |
|
Branches Executed: |
88.2% |
254 / 288 |
| |
|
Line Coverage: |
81.4% |
603 / 741 |
| |
 |
|
 |
1 : //===--- PCHReaderStmt.cpp - Stmt/Expr Deserialization ----------*- 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 : // Statement/expression deserialization. This implements the
11 : // PCHReader::ReadStmt method.
12 : //
13 : //===----------------------------------------------------------------------===//
14 :
15 : #include "clang/Frontend/PCHReader.h"
16 : #include "clang/AST/DeclCXX.h"
17 : #include "clang/AST/StmtVisitor.h"
18 : using namespace clang;
19 :
20 : namespace {
21 : class PCHStmtReader : public StmtVisitor<PCHStmtReader, unsigned> {
22 : PCHReader &Reader;
23 : const PCHReader::RecordData &Record;
24 : unsigned &Idx;
25 : llvm::SmallVectorImpl<Stmt *> &StmtStack;
26 :
27 : public:
28 : PCHStmtReader(PCHReader &Reader, const PCHReader::RecordData &Record,
29 105: unsigned &Idx, llvm::SmallVectorImpl<Stmt *> &StmtStack)
30 105: : Reader(Reader), Record(Record), Idx(Idx), StmtStack(StmtStack) { }
31 :
32 : /// \brief The number of record fields required for the Stmt class
33 : /// itself.
34 : static const unsigned NumStmtFields = 0;
35 :
36 : /// \brief The number of record fields required for the Expr class
37 : /// itself.
38 : static const unsigned NumExprFields = NumStmtFields + 3;
39 :
40 : // Each of the Visit* functions reads in part of the expression
41 : // from the given record and the current expression stack, then
42 : // return the total number of operands that it read from the
43 : // expression stack.
44 :
45 : unsigned VisitStmt(Stmt *S);
46 : unsigned VisitNullStmt(NullStmt *S);
47 : unsigned VisitCompoundStmt(CompoundStmt *S);
48 : unsigned VisitSwitchCase(SwitchCase *S);
49 : unsigned VisitCaseStmt(CaseStmt *S);
50 : unsigned VisitDefaultStmt(DefaultStmt *S);
51 : unsigned VisitLabelStmt(LabelStmt *S);
52 : unsigned VisitIfStmt(IfStmt *S);
53 : unsigned VisitSwitchStmt(SwitchStmt *S);
54 : unsigned VisitWhileStmt(WhileStmt *S);
55 : unsigned VisitDoStmt(DoStmt *S);
56 : unsigned VisitForStmt(ForStmt *S);
57 : unsigned VisitGotoStmt(GotoStmt *S);
58 : unsigned VisitIndirectGotoStmt(IndirectGotoStmt *S);
59 : unsigned VisitContinueStmt(ContinueStmt *S);
60 : unsigned VisitBreakStmt(BreakStmt *S);
61 : unsigned VisitReturnStmt(ReturnStmt *S);
62 : unsigned VisitDeclStmt(DeclStmt *S);
63 : unsigned VisitAsmStmt(AsmStmt *S);
64 : unsigned VisitExpr(Expr *E);
65 : unsigned VisitPredefinedExpr(PredefinedExpr *E);
66 : unsigned VisitDeclRefExpr(DeclRefExpr *E);
67 : unsigned VisitIntegerLiteral(IntegerLiteral *E);
68 : unsigned VisitFloatingLiteral(FloatingLiteral *E);
69 : unsigned VisitImaginaryLiteral(ImaginaryLiteral *E);
70 : unsigned VisitStringLiteral(StringLiteral *E);
71 : unsigned VisitCharacterLiteral(CharacterLiteral *E);
72 : unsigned VisitParenExpr(ParenExpr *E);
73 : unsigned VisitUnaryOperator(UnaryOperator *E);
74 : unsigned VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E);
75 : unsigned VisitArraySubscriptExpr(ArraySubscriptExpr *E);
76 : unsigned VisitCallExpr(CallExpr *E);
77 : unsigned VisitMemberExpr(MemberExpr *E);
78 : unsigned VisitCastExpr(CastExpr *E);
79 : unsigned VisitBinaryOperator(BinaryOperator *E);
80 : unsigned VisitCompoundAssignOperator(CompoundAssignOperator *E);
81 : unsigned VisitConditionalOperator(ConditionalOperator *E);
82 : unsigned VisitImplicitCastExpr(ImplicitCastExpr *E);
83 : unsigned VisitExplicitCastExpr(ExplicitCastExpr *E);
84 : unsigned VisitCStyleCastExpr(CStyleCastExpr *E);
85 : unsigned VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
86 : unsigned VisitExtVectorElementExpr(ExtVectorElementExpr *E);
87 : unsigned VisitInitListExpr(InitListExpr *E);
88 : unsigned VisitDesignatedInitExpr(DesignatedInitExpr *E);
89 : unsigned VisitImplicitValueInitExpr(ImplicitValueInitExpr *E);
90 : unsigned VisitVAArgExpr(VAArgExpr *E);
91 : unsigned VisitAddrLabelExpr(AddrLabelExpr *E);
92 : unsigned VisitStmtExpr(StmtExpr *E);
93 : unsigned VisitTypesCompatibleExpr(TypesCompatibleExpr *E);
94 : unsigned VisitChooseExpr(ChooseExpr *E);
95 : unsigned VisitGNUNullExpr(GNUNullExpr *E);
96 : unsigned VisitShuffleVectorExpr(ShuffleVectorExpr *E);
97 : unsigned VisitBlockExpr(BlockExpr *E);
98 : unsigned VisitBlockDeclRefExpr(BlockDeclRefExpr *E);
99 : unsigned VisitObjCStringLiteral(ObjCStringLiteral *E);
100 : unsigned VisitObjCEncodeExpr(ObjCEncodeExpr *E);
101 : unsigned VisitObjCSelectorExpr(ObjCSelectorExpr *E);
102 : unsigned VisitObjCProtocolExpr(ObjCProtocolExpr *E);
103 : unsigned VisitObjCIvarRefExpr(ObjCIvarRefExpr *E);
104 : unsigned VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E);
105 : unsigned VisitObjCImplicitSetterGetterRefExpr(
106 : ObjCImplicitSetterGetterRefExpr *E);
107 : unsigned VisitObjCMessageExpr(ObjCMessageExpr *E);
108 : unsigned VisitObjCSuperExpr(ObjCSuperExpr *E);
109 : unsigned VisitObjCIsaExpr(ObjCIsaExpr *E);
110 :
111 : unsigned VisitObjCForCollectionStmt(ObjCForCollectionStmt *);
112 : unsigned VisitObjCAtCatchStmt(ObjCAtCatchStmt *);
113 : unsigned VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *);
114 : unsigned VisitObjCAtTryStmt(ObjCAtTryStmt *);
115 : unsigned VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *);
116 : unsigned VisitObjCAtThrowStmt(ObjCAtThrowStmt *);
117 :
118 : unsigned VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E);
119 : unsigned VisitCXXConstructExpr(CXXConstructExpr *E);
120 : unsigned VisitCXXNamedCastExpr(CXXNamedCastExpr *E);
121 : unsigned VisitCXXStaticCastExpr(CXXStaticCastExpr *E);
122 : unsigned VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E);
123 : unsigned VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E);
124 : unsigned VisitCXXConstCastExpr(CXXConstCastExpr *E);
125 : unsigned VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E);
126 : unsigned VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
127 : unsigned VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E);
128 : };
129 : }
130 :
131 544: unsigned PCHStmtReader::VisitStmt(Stmt *S) {
0: branch 0 not taken
544: branch 1 taken
132 544: assert(Idx == NumStmtFields && "Incorrect statement field count");
133 544: return 0;
134 : }
135 :
136 2: unsigned PCHStmtReader::VisitNullStmt(NullStmt *S) {
137 2: VisitStmt(S);
138 2: S->setSemiLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
139 2: return 0;
140 : }
141 :
142 39: unsigned PCHStmtReader::VisitCompoundStmt(CompoundStmt *S) {
143 39: VisitStmt(S);
144 39: unsigned NumStmts = Record[Idx++];
145 : S->setStmts(*Reader.getContext(),
146 39: StmtStack.data() + StmtStack.size() - NumStmts, NumStmts);
147 39: S->setLBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
148 39: S->setRBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
149 39: return NumStmts;
150 : }
151 :
152 8: unsigned PCHStmtReader::VisitSwitchCase(SwitchCase *S) {
153 8: VisitStmt(S);
154 8: Reader.RecordSwitchCaseID(S, Record[Idx++]);
155 8: return 0;
156 : }
157 :
158 6: unsigned PCHStmtReader::VisitCaseStmt(CaseStmt *S) {
159 6: VisitSwitchCase(S);
160 6: S->setLHS(cast<Expr>(StmtStack[StmtStack.size() - 3]));
161 6: S->setRHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2]));
162 6: S->setSubStmt(StmtStack.back());
163 6: S->setCaseLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
164 6: S->setEllipsisLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
165 6: S->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
166 6: return 3;
167 : }
168 :
169 2: unsigned PCHStmtReader::VisitDefaultStmt(DefaultStmt *S) {
170 2: VisitSwitchCase(S);
171 2: S->setSubStmt(StmtStack.back());
172 2: S->setDefaultLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
173 2: S->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
174 2: return 1;
175 : }
176 :
177 4: unsigned PCHStmtReader::VisitLabelStmt(LabelStmt *S) {
178 4: VisitStmt(S);
179 4: S->setID(Reader.GetIdentifierInfo(Record, Idx));
180 4: S->setSubStmt(StmtStack.back());
181 4: S->setIdentLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
182 4: Reader.RecordLabelStmt(S, Record[Idx++]);
183 4: return 1;
184 : }
185 :
186 8: unsigned PCHStmtReader::VisitIfStmt(IfStmt *S) {
187 8: VisitStmt(S);
188 8: S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
189 8: S->setCond(cast<Expr>(StmtStack[StmtStack.size() - 3]));
190 8: S->setThen(StmtStack[StmtStack.size() - 2]);
191 8: S->setElse(StmtStack[StmtStack.size() - 1]);
192 8: S->setIfLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
193 8: S->setElseLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
194 8: return 3;
195 : }
196 :
197 4: unsigned PCHStmtReader::VisitSwitchStmt(SwitchStmt *S) {
198 4: VisitStmt(S);
199 4: S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
200 4: S->setCond(cast<Expr>(StmtStack[StmtStack.size() - 2]));
201 4: S->setBody(StmtStack.back());
202 4: S->setSwitchLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
203 4: SwitchCase *PrevSC = 0;
8: branch 1 taken
4: branch 2 taken
204 12: for (unsigned N = Record.size(); Idx != N; ++Idx) {
205 8: SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
4: branch 0 taken
4: branch 1 taken
206 8: if (PrevSC)
207 4: PrevSC->setNextSwitchCase(SC);
208 : else
209 4: S->setSwitchCaseList(SC);
210 :
211 : // Retain this SwitchCase, since SwitchStmt::addSwitchCase() would
212 : // normally retain it (but we aren't calling addSwitchCase).
213 8: SC->Retain();
214 8: PrevSC = SC;
215 : }
216 4: return 2;
217 : }
218 :
219 2: unsigned PCHStmtReader::VisitWhileStmt(WhileStmt *S) {
220 2: VisitStmt(S);
221 2: S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
222 2: S->setCond(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2]));
223 2: S->setBody(StmtStack.back());
224 2: S->setWhileLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
225 2: return 2;
226 : }
227 :
228 1: unsigned PCHStmtReader::VisitDoStmt(DoStmt *S) {
229 1: VisitStmt(S);
230 1: S->setCond(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2]));
231 1: S->setBody(StmtStack.back());
232 1: S->setDoLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
233 1: S->setWhileLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
234 1: S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
235 1: return 2;
236 : }
237 :
238 1: unsigned PCHStmtReader::VisitForStmt(ForStmt *S) {
239 1: VisitStmt(S);
240 1: S->setInit(StmtStack[StmtStack.size() - 4]);
241 1: S->setCond(cast_or_null<Expr>(StmtStack[StmtStack.size() - 3]));
242 1: S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
243 1: S->setInc(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2]));
244 1: S->setBody(StmtStack.back());
245 1: S->setForLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
246 1: S->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
247 1: S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
248 1: return 4;
249 : }
250 :
251 2: unsigned PCHStmtReader::VisitGotoStmt(GotoStmt *S) {
252 2: VisitStmt(S);
253 2: Reader.SetLabelOf(S, Record[Idx++]);
254 2: S->setGotoLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
255 2: S->setLabelLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
256 2: return 0;
257 : }
258 :
259 1: unsigned PCHStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
260 1: VisitStmt(S);
261 1: S->setGotoLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
262 1: S->setStarLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
263 1: S->setTarget(cast_or_null<Expr>(StmtStack.back()));
264 1: return 1;
265 : }
266 :
267 1: unsigned PCHStmtReader::VisitContinueStmt(ContinueStmt *S) {
268 1: VisitStmt(S);
269 1: S->setContinueLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
270 1: return 0;
271 : }
272 :
273 6: unsigned PCHStmtReader::VisitBreakStmt(BreakStmt *S) {
274 6: VisitStmt(S);
275 6: S->setBreakLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
276 6: return 0;
277 : }
278 :
279 13: unsigned PCHStmtReader::VisitReturnStmt(ReturnStmt *S) {
280 13: VisitStmt(S);
281 13: S->setRetValue(cast_or_null<Expr>(StmtStack.back()));
282 13: S->setReturnLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
283 13: return 1;
284 : }
285 :
286 21: unsigned PCHStmtReader::VisitDeclStmt(DeclStmt *S) {
287 21: VisitStmt(S);
288 21: S->setStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
289 21: S->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
290 :
19: branch 1 taken
2: branch 2 taken
291 21: if (Idx + 1 == Record.size()) {
292 : // Single declaration
293 19: S->setDeclGroup(DeclGroupRef(Reader.GetDecl(Record[Idx++])));
294 : } else {
295 2: llvm::SmallVector<Decl *, 16> Decls;
296 2: Decls.reserve(Record.size() - Idx);
5: branch 1 taken
2: branch 2 taken
297 7: for (unsigned N = Record.size(); Idx != N; ++Idx)
298 5: Decls.push_back(Reader.GetDecl(Record[Idx]));
299 : S->setDeclGroup(DeclGroupRef(DeclGroup::Create(*Reader.getContext(),
300 : Decls.data(),
301 2: Decls.size())));
302 : }
303 21: return 0;
304 : }
305 :
306 5: unsigned PCHStmtReader::VisitAsmStmt(AsmStmt *S) {
307 5: VisitStmt(S);
308 5: unsigned NumOutputs = Record[Idx++];
309 5: unsigned NumInputs = Record[Idx++];
310 5: unsigned NumClobbers = Record[Idx++];
311 5: S->setAsmLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
312 5: S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
313 5: S->setVolatile(Record[Idx++]);
314 5: S->setSimple(Record[Idx++]);
315 5: S->setMSAsm(Record[Idx++]);
316 :
317 : unsigned StackIdx
318 5: = StmtStack.size() - (NumOutputs*2 + NumInputs*2 + NumClobbers + 1);
319 5: S->setAsmString(cast_or_null<StringLiteral>(StmtStack[StackIdx++]));
320 :
321 : // Outputs and inputs
322 5: llvm::SmallVector<IdentifierInfo *, 16> Names;
323 5: llvm::SmallVector<StringLiteral*, 16> Constraints;
324 5: llvm::SmallVector<Stmt*, 16> Exprs;
3: branch 0 taken
5: branch 1 taken
325 8: for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
326 3: Names.push_back(Reader.GetIdentifierInfo(Record, Idx));
327 3: Constraints.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++]));
328 3: Exprs.push_back(StmtStack[StackIdx++]);
329 : }
330 :
331 : // Constraints
332 5: llvm::SmallVector<StringLiteral*, 16> Clobbers;
10: branch 0 taken
5: branch 1 taken
333 15: for (unsigned I = 0; I != NumClobbers; ++I)
334 10: Clobbers.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++]));
335 :
336 : S->setOutputsAndInputsAndClobbers(*Reader.getContext(),
337 : Names.data(), Constraints.data(),
338 : Exprs.data(), NumOutputs, NumInputs,
339 5: Clobbers.data(), NumClobbers);
340 :
5: branch 1 taken
0: branch 2 not taken
341 5: assert(StackIdx == StmtStack.size() && "Error deserializing AsmStmt");
342 5: return NumOutputs*2 + NumInputs*2 + NumClobbers + 1;
343 : }
344 :
345 426: unsigned PCHStmtReader::VisitExpr(Expr *E) {
346 426: VisitStmt(E);
347 426: E->setType(Reader.GetType(Record[Idx++]));
348 426: E->setTypeDependent(Record[Idx++]);
349 426: E->setValueDependent(Record[Idx++]);
0: branch 0 not taken
426: branch 1 taken
350 426: assert(Idx == NumExprFields && "Incorrect expression field count");
351 426: return 0;
352 : }
353 :
354 1: unsigned PCHStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
355 1: VisitExpr(E);
356 1: E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
357 1: E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
358 1: return 0;
359 : }
360 :
361 107: unsigned PCHStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
362 107: VisitExpr(E);
363 107: E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++])));
364 107: E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
365 : // FIXME: read qualifier
366 : // FIXME: read explicit template arguments
367 107: return 0;
368 : }
369 :
370 75: unsigned PCHStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
371 75: VisitExpr(E);
372 75: E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
373 75: E->setValue(Reader.ReadAPInt(Record, Idx));
374 75: return 0;
375 : }
376 :
377 12: unsigned PCHStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
378 12: VisitExpr(E);
379 12: E->setValue(Reader.ReadAPFloat(Record, Idx));
380 12: E->setExact(Record[Idx++]);
381 12: E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
382 12: return 0;
383 : }
384 :
385 1: unsigned PCHStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
386 1: VisitExpr(E);
387 1: E->setSubExpr(cast<Expr>(StmtStack.back()));
388 1: return 1;
389 : }
390 :
391 25: unsigned PCHStmtReader::VisitStringLiteral(StringLiteral *E) {
392 25: VisitExpr(E);
393 25: unsigned Len = Record[Idx++];
394 : assert(Record[Idx] == E->getNumConcatenated() &&
25: branch 2 taken
0: branch 3 not taken
395 25: "Wrong number of concatenated tokens!");
396 25: ++Idx;
397 25: E->setWide(Record[Idx++]);
398 :
399 : // Read string data
400 25: llvm::SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
401 25: E->setString(*Reader.getContext(), Str.str());
402 25: Idx += Len;
403 :
404 : // Read source locations
28: branch 1 taken
25: branch 2 taken
405 53: for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
406 28: E->setStrTokenLoc(I, SourceLocation::getFromRawEncoding(Record[Idx++]));
407 :
408 25: return 0;
409 : }
410 :
411 1: unsigned PCHStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
412 1: VisitExpr(E);
413 1: E->setValue(Record[Idx++]);
414 1: E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
415 1: E->setWide(Record[Idx++]);
416 1: return 0;
417 : }
418 :
419 42: unsigned PCHStmtReader::VisitParenExpr(ParenExpr *E) {
420 42: VisitExpr(E);
421 42: E->setLParen(SourceLocation::getFromRawEncoding(Record[Idx++]));
422 42: E->setRParen(SourceLocation::getFromRawEncoding(Record[Idx++]));
423 42: E->setSubExpr(cast<Expr>(StmtStack.back()));
424 42: return 1;
425 : }
426 :
427 8: unsigned PCHStmtReader::VisitUnaryOperator(UnaryOperator *E) {
428 8: VisitExpr(E);
429 8: E->setSubExpr(cast<Expr>(StmtStack.back()));
430 8: E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
431 8: E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
432 8: return 1;
433 : }
434 :
435 2: unsigned PCHStmtReader::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) {
436 2: VisitExpr(E);
437 2: E->setSizeof(Record[Idx++]);
1: branch 1 taken
1: branch 2 taken
438 2: if (Record[Idx] == 0) {
439 1: E->setArgument(cast<Expr>(StmtStack.back()));
440 1: ++Idx;
441 : } else {
442 1: E->setArgument(Reader.GetTypeSourceInfo(Record, Idx));
443 : }
444 2: E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
445 2: E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
1: branch 1 taken
1: branch 2 taken
446 2: return E->isArgumentType()? 0 : 1;
447 : }
448 :
449 1: unsigned PCHStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
450 1: VisitExpr(E);
451 1: E->setLHS(cast<Expr>(StmtStack[StmtStack.size() - 2]));
452 1: E->setRHS(cast<Expr>(StmtStack[StmtStack.size() - 1]));
453 1: E->setRBracketLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
454 1: return 2;
455 : }
456 :
457 11: unsigned PCHStmtReader::VisitCallExpr(CallExpr *E) {
458 11: VisitExpr(E);
459 11: E->setNumArgs(*Reader.getContext(), Record[Idx++]);
460 11: E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
461 11: E->setCallee(cast<Expr>(StmtStack[StmtStack.size() - E->getNumArgs() - 1]));
24: branch 1 taken
11: branch 2 taken
462 35: for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
463 24: E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I]));
464 11: return E->getNumArgs() + 1;
465 : }
466 :
467 1: unsigned PCHStmtReader::VisitMemberExpr(MemberExpr *E) {
468 1: VisitExpr(E);
469 1: E->setBase(cast<Expr>(StmtStack.back()));
470 1: E->setMemberDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++])));
471 1: E->setMemberLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
472 1: E->setArrow(Record[Idx++]);
473 1: return 1;
474 : }
475 :
476 0: unsigned PCHStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
477 0: VisitExpr(E);
478 0: E->setBase(cast<Expr>(StmtStack.back()));
479 0: E->setIsaMemberLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
480 0: E->setArrow(Record[Idx++]);
481 0: return 1;
482 : }
483 :
484 52: unsigned PCHStmtReader::VisitCastExpr(CastExpr *E) {
485 52: VisitExpr(E);
486 52: E->setSubExpr(cast<Expr>(StmtStack.back()));
487 52: E->setCastKind((CastExpr::CastKind)Record[Idx++]);
488 :
489 52: return 1;
490 : }
491 :
492 38: unsigned PCHStmtReader::VisitBinaryOperator(BinaryOperator *E) {
493 38: VisitExpr(E);
494 38: E->setLHS(cast<Expr>(StmtStack.end()[-2]));
495 38: E->setRHS(cast<Expr>(StmtStack.end()[-1]));
496 38: E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
497 38: E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
498 38: return 2;
499 : }
500 :
501 2: unsigned PCHStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
502 2: VisitBinaryOperator(E);
503 2: E->setComputationLHSType(Reader.GetType(Record[Idx++]));
504 2: E->setComputationResultType(Reader.GetType(Record[Idx++]));
505 2: return 2;
506 : }
507 :
508 2: unsigned PCHStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
509 2: VisitExpr(E);
510 2: E->setCond(cast<Expr>(StmtStack[StmtStack.size() - 3]));
511 2: E->setLHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2]));
512 2: E->setRHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 1]));
513 2: E->setQuestionLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
514 2: E->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
515 2: return 3;
516 : }
517 :
518 43: unsigned PCHStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
519 43: VisitCastExpr(E);
520 43: E->setLvalueCast(Record[Idx++]);
521 43: return 1;
522 : }
523 :
524 9: unsigned PCHStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
525 9: VisitCastExpr(E);
526 9: E->setTypeInfoAsWritten(Reader.GetTypeSourceInfo(Record, Idx));
527 9: return 1;
528 : }
529 :
530 4: unsigned PCHStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
531 4: VisitExplicitCastExpr(E);
532 4: E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
533 4: E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
534 4: return 1;
535 : }
536 :
537 1: unsigned PCHStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
538 1: VisitExpr(E);
539 1: E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
540 1: E->setTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx));
541 1: E->setInitializer(cast<Expr>(StmtStack.back()));
542 1: E->setFileScope(Record[Idx++]);
543 1: return 1;
544 : }
545 :
546 1: unsigned PCHStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
547 1: VisitExpr(E);
548 1: E->setBase(cast<Expr>(StmtStack.back()));
549 1: E->setAccessor(Reader.GetIdentifierInfo(Record, Idx));
550 1: E->setAccessorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
551 1: return 1;
552 : }
553 :
554 10: unsigned PCHStmtReader::VisitInitListExpr(InitListExpr *E) {
555 10: VisitExpr(E);
556 10: unsigned NumInits = Record[Idx++];
557 10: E->reserveInits(NumInits);
16: branch 0 taken
10: branch 1 taken
558 26: for (unsigned I = 0; I != NumInits; ++I)
559 : E->updateInit(I,
560 16: cast<Expr>(StmtStack[StmtStack.size() - NumInits - 1 + I]));
561 10: E->setSyntacticForm(cast_or_null<InitListExpr>(StmtStack.back()));
562 10: E->setLBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
563 10: E->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
564 : E->setInitializedFieldInUnion(
565 10: cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++])));
566 10: E->sawArrayRangeDesignator(Record[Idx++]);
567 10: return NumInits + 1;
568 : }
569 :
570 3: unsigned PCHStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
571 : typedef DesignatedInitExpr::Designator Designator;
572 :
573 3: VisitExpr(E);
574 3: unsigned NumSubExprs = Record[Idx++];
3: branch 1 taken
0: branch 2 not taken
575 3: assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
5: branch 0 taken
3: branch 1 taken
576 8: for (unsigned I = 0; I != NumSubExprs; ++I)
577 5: E->setSubExpr(I, cast<Expr>(StmtStack[StmtStack.size() - NumSubExprs + I]));
578 3: E->setEqualOrColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
579 3: E->setGNUSyntax(Record[Idx++]);
580 :
581 3: llvm::SmallVector<Designator, 4> Designators;
5: branch 1 taken
3: branch 2 taken
582 11: while (Idx < Record.size()) {
3: branch 1 taken
0: branch 2 not taken
2: branch 3 taken
0: branch 4 not taken
0: branch 5 not taken
583 5: switch ((pch::DesignatorTypes)Record[Idx++]) {
584 : case pch::DESIG_FIELD_DECL: {
585 3: FieldDecl *Field = cast<FieldDecl>(Reader.GetDecl(Record[Idx++]));
586 : SourceLocation DotLoc
587 3: = SourceLocation::getFromRawEncoding(Record[Idx++]);
588 : SourceLocation FieldLoc
589 3: = SourceLocation::getFromRawEncoding(Record[Idx++]);
590 : Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
591 3: FieldLoc));
592 3: Designators.back().setField(Field);
593 3: break;
594 : }
595 :
596 : case pch::DESIG_FIELD_NAME: {
597 0: const IdentifierInfo *Name = Reader.GetIdentifierInfo(Record, Idx);
598 : SourceLocation DotLoc
599 0: = SourceLocation::getFromRawEncoding(Record[Idx++]);
600 : SourceLocation FieldLoc
601 0: = SourceLocation::getFromRawEncoding(Record[Idx++]);
602 0: Designators.push_back(Designator(Name, DotLoc, FieldLoc));
603 0: break;
604 : }
605 :
606 : case pch::DESIG_ARRAY: {
607 2: unsigned Index = Record[Idx++];
608 : SourceLocation LBracketLoc
609 2: = SourceLocation::getFromRawEncoding(Record[Idx++]);
610 : SourceLocation RBracketLoc
611 2: = SourceLocation::getFromRawEncoding(Record[Idx++]);
612 2: Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
613 2: break;
614 : }
615 :
616 : case pch::DESIG_ARRAY_RANGE: {
617 0: unsigned Index = Record[Idx++];
618 : SourceLocation LBracketLoc
619 0: = SourceLocation::getFromRawEncoding(Record[Idx++]);
620 : SourceLocation EllipsisLoc
621 0: = SourceLocation::getFromRawEncoding(Record[Idx++]);
622 : SourceLocation RBracketLoc
623 0: = SourceLocation::getFromRawEncoding(Record[Idx++]);
624 : Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
625 0: RBracketLoc));
626 : break;
627 : }
628 : }
629 : }
630 : E->setDesignators(*Reader.getContext(),
631 3: Designators.data(), Designators.size());
632 :
633 3: return NumSubExprs;
634 : }
635 :
636 2: unsigned PCHStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
637 2: VisitExpr(E);
638 2: return 0;
639 : }
640 :
641 1: unsigned PCHStmtReader::VisitVAArgExpr(VAArgExpr *E) {
642 1: VisitExpr(E);
643 1: E->setSubExpr(cast<Expr>(StmtStack.back()));
644 1: E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
645 1: E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
646 1: return 1;
647 : }
648 :
649 2: unsigned PCHStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
650 2: VisitExpr(E);
651 2: E->setAmpAmpLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
652 2: E->setLabelLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
653 2: Reader.SetLabelOf(E, Record[Idx++]);
654 2: return 0;
655 : }
656 :
657 1: unsigned PCHStmtReader::VisitStmtExpr(StmtExpr *E) {
658 1: VisitExpr(E);
659 1: E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
660 1: E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
661 1: E->setSubStmt(cast_or_null<CompoundStmt>(StmtStack.back()));
662 1: return 1;
663 : }
664 :
665 1: unsigned PCHStmtReader::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) {
666 1: VisitExpr(E);
667 1: E->setArgType1(Reader.GetType(Record[Idx++]));
668 1: E->setArgType2(Reader.GetType(Record[Idx++]));
669 1: E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
670 1: E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
671 1: return 0;
672 : }
673 :
674 1: unsigned PCHStmtReader::VisitChooseExpr(ChooseExpr *E) {
675 1: VisitExpr(E);
676 1: E->setCond(cast<Expr>(StmtStack[StmtStack.size() - 3]));
677 1: E->setLHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2]));
678 1: E->setRHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 1]));
679 1: E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
680 1: E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
681 1: return 3;
682 : }
683 :
684 0: unsigned PCHStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
685 0: VisitExpr(E);
686 0: E->setTokenLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
687 0: return 0;
688 : }
689 :
690 1: unsigned PCHStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
691 1: VisitExpr(E);
692 1: unsigned NumExprs = Record[Idx++];
693 : E->setExprs(*Reader.getContext(),
694 1: (Expr **)&StmtStack[StmtStack.size() - NumExprs], NumExprs);
695 1: E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
696 1: E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
697 1: return NumExprs;
698 : }
699 :
700 2: unsigned PCHStmtReader::VisitBlockExpr(BlockExpr *E) {
701 2: VisitExpr(E);
702 2: E->setBlockDecl(cast_or_null<BlockDecl>(Reader.GetDecl(Record[Idx++])));
703 2: E->setHasBlockDeclRefExprs(Record[Idx++]);
704 2: return 0;
705 : }
706 :
707 1: unsigned PCHStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
708 1: VisitExpr(E);
709 1: E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++])));
710 1: E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
711 1: E->setByRef(Record[Idx++]);
712 1: E->setConstQualAdded(Record[Idx++]);
713 1: return 0;
714 : }
715 :
716 : //===----------------------------------------------------------------------===//
717 : // Objective-C Expressions and Statements
718 :
719 1: unsigned PCHStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
720 1: VisitExpr(E);
721 1: E->setString(cast<StringLiteral>(StmtStack.back()));
722 1: E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
723 1: return 1;
724 : }
725 :
726 1: unsigned PCHStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
727 1: VisitExpr(E);
728 1: E->setEncodedType(Reader.GetType(Record[Idx++]));
729 1: E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
730 1: E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
731 1: return 0;
732 : }
733 :
734 3: unsigned PCHStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
735 3: VisitExpr(E);
736 3: E->setSelector(Reader.GetSelector(Record, Idx));
737 3: E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
738 3: E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
739 3: return 0;
740 : }
741 :
742 1: unsigned PCHStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
743 1: VisitExpr(E);
744 1: E->setProtocol(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++])));
745 1: E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
746 1: E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
747 1: return 0;
748 : }
749 :
750 0: unsigned PCHStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
751 0: VisitExpr(E);
752 0: E->setDecl(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++])));
753 0: E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
754 0: E->setBase(cast<Expr>(StmtStack.back()));
755 0: E->setIsArrow(Record[Idx++]);
756 0: E->setIsFreeIvar(Record[Idx++]);
757 0: return 1;
758 : }
759 :
760 0: unsigned PCHStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
761 0: VisitExpr(E);
762 0: E->setProperty(cast<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++])));
763 0: E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
764 0: E->setBase(cast<Expr>(StmtStack.back()));
765 0: return 1;
766 : }
767 :
768 : unsigned PCHStmtReader::VisitObjCImplicitSetterGetterRefExpr(
769 0: ObjCImplicitSetterGetterRefExpr *E) {
770 0: VisitExpr(E);
771 : E->setGetterMethod(
772 0: cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
773 : E->setSetterMethod(
774 0: cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
775 : E->setInterfaceDecl(
776 0: cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
777 0: E->setBase(cast_or_null<Expr>(StmtStack.back()));
778 0: E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
779 0: E->setClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
780 0: return 1;
781 : }
782 :
783 10: unsigned PCHStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
784 10: VisitExpr(E);
785 10: E->setNumArgs(Record[Idx++]);
786 10: E->setLeftLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
787 10: E->setRightLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
788 10: E->setSelector(Reader.GetSelector(Record, Idx));
789 10: E->setMethodDecl(cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
790 :
791 : E->setReceiver(
792 10: cast_or_null<Expr>(StmtStack[StmtStack.size() - E->getNumArgs() - 1]));
2: branch 1 taken
8: branch 2 taken
793 10: if (!E->getReceiver()) {
794 2: ObjCMessageExpr::ClassInfo CI;
795 2: CI.first = cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]));
796 2: CI.second = Reader.GetIdentifierInfo(Record, Idx);
797 2: E->setClassInfo(CI);
798 : }
799 :
2: branch 1 taken
10: branch 2 taken
800 12: for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
801 2: E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I]));
802 10: return E->getNumArgs() + 1;
803 : }
804 :
805 0: unsigned PCHStmtReader::VisitObjCSuperExpr(ObjCSuperExpr *E) {
806 0: VisitExpr(E);
807 0: E->setLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
808 0: return 0;
809 : }
810 :
811 0: unsigned PCHStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
812 0: VisitStmt(S);
813 0: S->setElement(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 3]));
814 0: S->setCollection(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2]));
815 0: S->setBody(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 1]));
816 0: S->setForLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
817 0: S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
818 0: return 3;
819 : }
820 :
821 0: unsigned PCHStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
822 0: VisitStmt(S);
823 0: S->setCatchBody(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 2]));
824 0: S->setNextCatchStmt(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 1]));
825 0: S->setCatchParamDecl(cast_or_null<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
826 0: S->setAtCatchLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
827 0: S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
828 0: return 2;
829 : }
830 :
831 0: unsigned PCHStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
832 0: VisitStmt(S);
833 0: S->setFinallyBody(StmtStack.back());
834 0: S->setAtFinallyLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
835 0: return 1;
836 : }
837 :
838 0: unsigned PCHStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
839 0: VisitStmt(S);
840 0: S->setTryBody(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 3]));
841 0: S->setCatchStmts(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 2]));
842 0: S->setFinallyStmt(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 1]));
843 0: S->setAtTryLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
844 0: return 3;
845 : }
846 :
847 0: unsigned PCHStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
848 0: VisitStmt(S);
849 0: S->setSynchExpr(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 2]));
850 0: S->setSynchBody(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 1]));
851 0: S->setAtSynchronizedLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
852 0: return 2;
853 : }
854 :
855 0: unsigned PCHStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
856 0: VisitStmt(S);
857 0: S->setThrowExpr(StmtStack.back());
858 0: S->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
859 0: return 1;
860 : }
861 :
862 : //===----------------------------------------------------------------------===//
863 : // C++ Expressions and Statements
864 :
865 0: unsigned PCHStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
866 0: unsigned num = VisitCallExpr(E);
867 0: E->setOperator((OverloadedOperatorKind)Record[Idx++]);
868 0: return num;
869 : }
870 :
871 0: unsigned PCHStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
872 0: VisitExpr(E);
873 0: E->setConstructor(cast<CXXConstructorDecl>(Reader.GetDecl(Record[Idx++])));
874 0: E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
875 0: E->setElidable(Record[Idx++]);
876 0: E->setRequiresZeroInitialization(Record[Idx++]);
0: branch 1 not taken
0: branch 2 not taken
877 0: for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
878 0: E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I]));
879 0: return E->getNumArgs();
880 : }
881 :
882 4: unsigned PCHStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
883 4: unsigned num = VisitExplicitCastExpr(E);
884 4: E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
885 4: return num;
886 : }
887 :
888 1: unsigned PCHStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
889 1: return VisitCXXNamedCastExpr(E);
890 : }
891 :
892 1: unsigned PCHStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
893 1: return VisitCXXNamedCastExpr(E);
894 : }
895 :
896 1: unsigned PCHStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
897 1: return VisitCXXNamedCastExpr(E);
898 : }
899 :
900 1: unsigned PCHStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
901 1: return VisitCXXNamedCastExpr(E);
902 : }
903 :
904 1: unsigned PCHStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
905 1: unsigned num = VisitExplicitCastExpr(E);
906 1: E->setTypeBeginLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
907 1: E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
908 1: return num;
909 : }
910 :
911 3: unsigned PCHStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
912 3: VisitExpr(E);
913 3: E->setValue(Record[Idx++]);
914 3: E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
915 3: return 0;
916 : }
917 :
918 1: unsigned PCHStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
919 1: VisitExpr(E);
920 1: E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
921 1: return 0;
922 : }
923 :
924 : // Within the bitstream, expressions are stored in Reverse Polish
925 : // Notation, with each of the subexpressions preceding the
926 : // expression they are stored in. To evaluate expressions, we
927 : // continue reading expressions and placing them on the stack, with
928 : // expressions having operands removing those operands from the
929 : // stack. Evaluation terminates when we see a STMT_STOP record, and
930 : // the single remaining expression on the stack is our result.
931 105: Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) {
932 105: RecordData Record;
933 : unsigned Idx;
934 105: llvm::SmallVector<Stmt *, 16> StmtStack;
935 105: PCHStmtReader Reader(*this, Record, Idx, StmtStack);
936 : Stmt::EmptyShell Empty;
937 :
938 564: while (true) {
939 669: unsigned Code = Cursor.ReadCode();
0: branch 0 not taken
669: branch 1 taken
940 669: if (Code == llvm::bitc::END_BLOCK) {
0: branch 1 not taken
0: branch 2 not taken
941 0: if (Cursor.ReadBlockEnd()) {
942 0: Error("error at end of block in PCH file");
943 0: return 0;
944 : }
945 0: break;
946 : }
947 :
0: branch 0 not taken
669: branch 1 taken
948 669: if (Code == llvm::bitc::ENTER_SUBBLOCK) {
949 : // No known subblocks, always skip them.
950 0: Cursor.ReadSubBlockID();
0: branch 1 not taken
0: branch 2 not taken
951 0: if (Cursor.SkipBlock()) {
952 0: Error("malformed block record in PCH file");
953 0: return 0;
954 : }
955 0: continue;
956 : }
957 :
0: branch 0 not taken
669: branch 1 taken
958 669: if (Code == llvm::bitc::DEFINE_ABBREV) {
959 0: Cursor.ReadAbbrevRecord();
960 0: continue;
961 : }
962 :
963 669: Stmt *S = 0;
964 669: Idx = 0;
965 669: Record.clear();
966 669: bool Finished = false;
105: branch 1 taken
20: branch 2 taken
2: branch 3 taken
39: branch 4 taken
6: branch 5 taken
2: branch 6 taken
4: branch 7 taken
8: branch 8 taken
4: branch 9 taken
2: branch 10 taken
1: branch 11 taken
1: branch 12 taken
2: branch 13 taken
1: branch 14 taken
1: branch 15 taken
6: branch 16 taken
13: branch 17 taken
21: branch 18 taken
5: branch 19 taken
1: branch 20 taken
107: branch 21 taken
75: branch 22 taken
12: branch 23 taken
1: branch 24 taken
25: branch 25 taken
1: branch 26 taken
42: branch 27 taken
8: branch 28 taken
2: branch 29 taken
1: branch 30 taken
11: branch 31 taken
1: branch 32 taken
36: branch 33 taken
2: branch 34 taken
2: branch 35 taken
43: branch 36 taken
4: branch 37 taken
1: branch 38 taken
1: branch 39 taken
10: branch 40 taken
3: branch 41 taken
2: branch 42 taken
1: branch 43 taken
2: branch 44 taken
1: branch 45 taken
1: branch 46 taken
1: branch 47 taken
0: branch 48 not taken
1: branch 49 taken
2: branch 50 taken
1: branch 51 taken
1: branch 52 taken
1: branch 53 taken
3: branch 54 taken
1: branch 55 taken
0: branch 56 not taken
0: branch 57 not taken
0: branch 58 not taken
10: branch 59 taken
0: branch 60 not taken
0: branch 61 not taken
0: branch 62 not taken
0: branch 63 not taken
0: branch 64 not taken
0: branch 65 not taken
0: branch 66 not taken
0: branch 67 not taken
0: branch 68 not taken
0: branch 69 not taken
1: branch 70 taken
1: branch 71 taken
1: branch 72 taken
1: branch 73 taken
1: branch 74 taken
3: branch 75 taken
1: branch 76 taken
0: branch 77 not taken
967 669: switch ((pch::StmtCode)Cursor.ReadRecord(Code, Record)) {
968 : case pch::STMT_STOP:
969 105: Finished = true;
970 105: break;
971 :
972 : case pch::STMT_NULL_PTR:
973 20: S = 0;
974 20: break;
975 :
976 : case pch::STMT_NULL:
2: branch 1 taken
0: branch 2 not taken
977 2: S = new (Context) NullStmt(Empty);
978 2: break;
979 :
980 : case pch::STMT_COMPOUND:
39: branch 1 taken
0: branch 2 not taken
981 39: S = new (Context) CompoundStmt(Empty);
982 39: break;
983 :
984 : case pch::STMT_CASE:
6: branch 1 taken
0: branch 2 not taken
985 6: S = new (Context) CaseStmt(Empty);
986 6: break;
987 :
988 : case pch::STMT_DEFAULT:
2: branch 1 taken
0: branch 2 not taken
989 2: S = new (Context) DefaultStmt(Empty);
990 2: break;
991 :
992 : case pch::STMT_LABEL:
4: branch 1 taken
0: branch 2 not taken
993 4: S = new (Context) LabelStmt(Empty);
994 4: break;
995 :
996 : case pch::STMT_IF:
8: branch 1 taken
0: branch 2 not taken
997 8: S = new (Context) IfStmt(Empty);
998 8: break;
999 :
1000 : case pch::STMT_SWITCH:
4: branch 1 taken
0: branch 2 not taken
1001 4: S = new (Context) SwitchStmt(Empty);
1002 4: break;
1003 :
1004 : case pch::STMT_WHILE:
2: branch 1 taken
0: branch 2 not taken
1005 2: S = new (Context) WhileStmt(Empty);
1006 2: break;
1007 :
1008 : case pch::STMT_DO:
1: branch 1 taken
0: branch 2 not taken
1009 1: S = new (Context) DoStmt(Empty);
1010 1: break;
1011 :
1012 : case pch::STMT_FOR:
1: branch 1 taken
0: branch 2 not taken
1013 1: S = new (Context) ForStmt(Empty);
1014 1: break;
1015 :
1016 : case pch::STMT_GOTO:
2: branch 1 taken
0: branch 2 not taken
1017 2: S = new (Context) GotoStmt(Empty);
1018 2: break;
1019 :
1020 : case pch::STMT_INDIRECT_GOTO:
1: branch 1 taken
0: branch 2 not taken
1021 1: S = new (Context) IndirectGotoStmt(Empty);
1022 1: break;
1023 :
1024 : case pch::STMT_CONTINUE:
1: branch 1 taken
0: branch 2 not taken
1025 1: S = new (Context) ContinueStmt(Empty);
1026 1: break;
1027 :
1028 : case pch::STMT_BREAK:
6: branch 1 taken
0: branch 2 not taken
1029 6: S = new (Context) BreakStmt(Empty);
1030 6: break;
1031 :
1032 : case pch::STMT_RETURN:
13: branch 1 taken
0: branch 2 not taken
1033 13: S = new (Context) ReturnStmt(Empty);
1034 13: break;
1035 :
1036 : case pch::STMT_DECL:
21: branch 1 taken
0: branch 2 not taken
1037 21: S = new (Context) DeclStmt(Empty);
1038 21: break;
1039 :
1040 : case pch::STMT_ASM:
5: branch 1 taken
0: branch 2 not taken
1041 5: S = new (Context) AsmStmt(Empty);
1042 5: break;
1043 :
1044 : case pch::EXPR_PREDEFINED:
1: branch 1 taken
0: branch 2 not taken
1045 1: S = new (Context) PredefinedExpr(Empty);
1046 1: break;
1047 :
1048 : case pch::EXPR_DECL_REF:
107: branch 1 taken
0: branch 2 not taken
1049 107: S = new (Context) DeclRefExpr(Empty);
1050 107: break;
1051 :
1052 : case pch::EXPR_INTEGER_LITERAL:
75: branch 1 taken
0: branch 2 not taken
1053 75: S = new (Context) IntegerLiteral(Empty);
1054 75: break;
1055 :
1056 : case pch::EXPR_FLOATING_LITERAL:
12: branch 1 taken
0: branch 2 not taken
1057 12: S = new (Context) FloatingLiteral(Empty);
1058 12: break;
1059 :
1060 : case pch::EXPR_IMAGINARY_LITERAL:
1: branch 1 taken
0: branch 2 not taken
1061 1: S = new (Context) ImaginaryLiteral(Empty);
1062 1: break;
1063 :
1064 : case pch::EXPR_STRING_LITERAL:
1065 : S = StringLiteral::CreateEmpty(*Context,
1066 25: Record[PCHStmtReader::NumExprFields + 1]);
1067 25: break;
1068 :
1069 : case pch::EXPR_CHARACTER_LITERAL:
1: branch 1 taken
0: branch 2 not taken
1070 1: S = new (Context) CharacterLiteral(Empty);
1071 1: break;
1072 :
1073 : case pch::EXPR_PAREN:
42: branch 1 taken
0: branch 2 not taken
1074 42: S = new (Context) ParenExpr(Empty);
1075 42: break;
1076 :
1077 : case pch::EXPR_UNARY_OPERATOR:
8: branch 1 taken
0: branch 2 not taken
1078 8: S = new (Context) UnaryOperator(Empty);
1079 8: break;
1080 :
1081 : case pch::EXPR_SIZEOF_ALIGN_OF:
2: branch 1 taken
0: branch 2 not taken
1082 2: S = new (Context) SizeOfAlignOfExpr(Empty);
1083 2: break;
1084 :
1085 : case pch::EXPR_ARRAY_SUBSCRIPT:
1: branch 1 taken
0: branch 2 not taken
1086 1: S = new (Context) ArraySubscriptExpr(Empty);
1087 1: break;
1088 :
1089 : case pch::EXPR_CALL:
11: branch 1 taken
0: branch 2 not taken
1090 11: S = new (Context) CallExpr(*Context, Stmt::CallExprClass, Empty);
1091 11: break;
1092 :
1093 : case pch::EXPR_MEMBER:
1: branch 1 taken
0: branch 2 not taken
1094 1: S = new (Context) MemberExpr(Empty);
1095 1: break;
1096 :
1097 : case pch::EXPR_BINARY_OPERATOR:
36: branch 1 taken
0: branch 2 not taken
1098 36: S = new (Context) BinaryOperator(Empty);
1099 36: break;
1100 :
1101 : case pch::EXPR_COMPOUND_ASSIGN_OPERATOR:
2: branch 1 taken
0: branch 2 not taken
1102 2: S = new (Context) CompoundAssignOperator(Empty);
1103 2: break;
1104 :
1105 : case pch::EXPR_CONDITIONAL_OPERATOR:
2: branch 1 taken
0: branch 2 not taken
1106 2: S = new (Context) ConditionalOperator(Empty);
1107 2: break;
1108 :
1109 : case pch::EXPR_IMPLICIT_CAST:
43: branch 1 taken
0: branch 2 not taken
1110 43: S = new (Context) ImplicitCastExpr(Empty);
1111 43: break;
1112 :
1113 : case pch::EXPR_CSTYLE_CAST:
4: branch 1 taken
0: branch 2 not taken
1114 4: S = new (Context) CStyleCastExpr(Empty);
1115 4: break;
1116 :
1117 : case pch::EXPR_COMPOUND_LITERAL:
1: branch 1 taken
0: branch 2 not taken
1118 1: S = new (Context) CompoundLiteralExpr(Empty);
1119 1: break;
1120 :
1121 : case pch::EXPR_EXT_VECTOR_ELEMENT:
1: branch 1 taken
0: branch 2 not taken
1122 1: S = new (Context) ExtVectorElementExpr(Empty);
1123 1: break;
1124 :
1125 : case pch::EXPR_INIT_LIST:
10: branch 1 taken
0: branch 2 not taken
1126 10: S = new (Context) InitListExpr(Empty);
1127 10: break;
1128 :
1129 : case pch::EXPR_DESIGNATED_INIT:
1130 : S = DesignatedInitExpr::CreateEmpty(*Context,
1131 3: Record[PCHStmtReader::NumExprFields] - 1);
1132 :
1133 3: break;
1134 :
1135 : case pch::EXPR_IMPLICIT_VALUE_INIT:
2: branch 1 taken
0: branch 2 not taken
1136 2: S = new (Context) ImplicitValueInitExpr(Empty);
1137 2: break;
1138 :
1139 : case pch::EXPR_VA_ARG:
1: branch 1 taken
0: branch 2 not taken
1140 1: S = new (Context) VAArgExpr(Empty);
1141 1: break;
1142 :
1143 : case pch::EXPR_ADDR_LABEL:
2: branch 1 taken
0: branch 2 not taken
1144 2: S = new (Context) AddrLabelExpr(Empty);
1145 2: break;
1146 :
1147 : case pch::EXPR_STMT:
1: branch 1 taken
0: branch 2 not taken
1148 1: S = new (Context) StmtExpr(Empty);
1149 1: break;
1150 :
1151 : case pch::EXPR_TYPES_COMPATIBLE:
1: branch 1 taken
0: branch 2 not taken
1152 1: S = new (Context) TypesCompatibleExpr(Empty);
1153 1: break;
1154 :
1155 : case pch::EXPR_CHOOSE:
1: branch 1 taken
0: branch 2 not taken
1156 1: S = new (Context) ChooseExpr(Empty);
1157 1: break;
1158 :
1159 : case pch::EXPR_GNU_NULL:
0: branch 1 not taken
0: branch 2 not taken
1160 0: S = new (Context) GNUNullExpr(Empty);
1161 0: break;
1162 :
1163 : case pch::EXPR_SHUFFLE_VECTOR:
1: branch 1 taken
0: branch 2 not taken
1164 1: S = new (Context) ShuffleVectorExpr(Empty);
1165 1: break;
1166 :
1167 : case pch::EXPR_BLOCK:
2: branch 1 taken
0: branch 2 not taken
1168 2: S = new (Context) BlockExpr(Empty);
1169 2: break;
1170 :
1171 : case pch::EXPR_BLOCK_DECL_REF:
1: branch 1 taken
0: branch 2 not taken
1172 1: S = new (Context) BlockDeclRefExpr(Empty);
1173 1: break;
1174 :
1175 : case pch::EXPR_OBJC_STRING_LITERAL:
1: branch 1 taken
0: branch 2 not taken
1176 1: S = new (Context) ObjCStringLiteral(Empty);
1177 1: break;
1178 : case pch::EXPR_OBJC_ENCODE:
1: branch 1 taken
0: branch 2 not taken
1179 1: S = new (Context) ObjCEncodeExpr(Empty);
1180 1: break;
1181 : case pch::EXPR_OBJC_SELECTOR_EXPR:
3: branch 1 taken
0: branch 2 not taken
1182 3: S = new (Context) ObjCSelectorExpr(Empty);
1183 3: break;
1184 : case pch::EXPR_OBJC_PROTOCOL_EXPR:
1: branch 1 taken
0: branch 2 not taken
1185 1: S = new (Context) ObjCProtocolExpr(Empty);
1186 1: break;
1187 : case pch::EXPR_OBJC_IVAR_REF_EXPR:
0: branch 1 not taken
0: branch 2 not taken
1188 0: S = new (Context) ObjCIvarRefExpr(Empty);
1189 0: break;
1190 : case pch::EXPR_OBJC_PROPERTY_REF_EXPR:
0: branch 1 not taken
0: branch 2 not taken
1191 0: S = new (Context) ObjCPropertyRefExpr(Empty);
1192 0: break;
1193 : case pch::EXPR_OBJC_KVC_REF_EXPR:
0: branch 1 not taken
0: branch 2 not taken
1194 0: S = new (Context) ObjCImplicitSetterGetterRefExpr(Empty);
1195 0: break;
1196 : case pch::EXPR_OBJC_MESSAGE_EXPR:
10: branch 1 taken
0: branch 2 not taken
1197 10: S = new (Context) ObjCMessageExpr(Empty);
1198 10: break;
1199 : case pch::EXPR_OBJC_SUPER_EXPR:
0: branch 1 not taken
0: branch 2 not taken
1200 0: S = new (Context) ObjCSuperExpr(Empty);
1201 0: break;
1202 : case pch::EXPR_OBJC_ISA:
0: branch 1 not taken
0: branch 2 not taken
1203 0: S = new (Context) ObjCIsaExpr(Empty);
1204 0: break;
1205 : case pch::STMT_OBJC_FOR_COLLECTION:
0: branch 1 not taken
0: branch 2 not taken
1206 0: S = new (Context) ObjCForCollectionStmt(Empty);
1207 0: break;
1208 : case pch::STMT_OBJC_CATCH:
0: branch 1 not taken
0: branch 2 not taken
1209 0: S = new (Context) ObjCAtCatchStmt(Empty);
1210 0: break;
1211 : case pch::STMT_OBJC_FINALLY:
0: branch 1 not taken
0: branch 2 not taken
1212 0: S = new (Context) ObjCAtFinallyStmt(Empty);
1213 0: break;
1214 : case pch::STMT_OBJC_AT_TRY:
0: branch 1 not taken
0: branch 2 not taken
1215 0: S = new (Context) ObjCAtTryStmt(Empty);
1216 0: break;
1217 : case pch::STMT_OBJC_AT_SYNCHRONIZED:
0: branch 1 not taken
0: branch 2 not taken
1218 0: S = new (Context) ObjCAtSynchronizedStmt(Empty);
1219 0: break;
1220 : case pch::STMT_OBJC_AT_THROW:
0: branch 1 not taken
0: branch 2 not taken
1221 0: S = new (Context) ObjCAtThrowStmt(Empty);
1222 0: break;
1223 :
1224 : case pch::EXPR_CXX_OPERATOR_CALL:
0: branch 1 not taken
0: branch 2 not taken
1225 0: S = new (Context) CXXOperatorCallExpr(*Context, Empty);
1226 0: break;
1227 :
1228 : case pch::EXPR_CXX_CONSTRUCT:
1229 : S = new (Context) CXXConstructExpr(Empty, *Context,
0: branch 2 not taken
0: branch 3 not taken
1230 0: Record[PCHStmtReader::NumExprFields + 2]);
1231 0: break;
1232 :
1233 : case pch::EXPR_CXX_STATIC_CAST:
1: branch 1 taken
0: branch 2 not taken
1234 1: S = new (Context) CXXStaticCastExpr(Empty);
1235 1: break;
1236 :
1237 : case pch::EXPR_CXX_DYNAMIC_CAST:
1: branch 1 taken
0: branch 2 not taken
1238 1: S = new (Context) CXXDynamicCastExpr(Empty);
1239 1: break;
1240 :
1241 : case pch::EXPR_CXX_REINTERPRET_CAST:
1: branch 1 taken
0: branch 2 not taken
1242 1: S = new (Context) CXXReinterpretCastExpr(Empty);
1243 1: break;
1244 :
1245 : case pch::EXPR_CXX_CONST_CAST:
1: branch 1 taken
0: branch 2 not taken
1246 1: S = new (Context) CXXConstCastExpr(Empty);
1247 1: break;
1248 :
1249 : case pch::EXPR_CXX_FUNCTIONAL_CAST:
1: branch 1 taken
0: branch 2 not taken
1250 1: S = new (Context) CXXFunctionalCastExpr(Empty);
1251 1: break;
1252 :
1253 : case pch::EXPR_CXX_BOOL_LITERAL:
3: branch 1 taken
0: branch 2 not taken
1254 3: S = new (Context) CXXBoolLiteralExpr(Empty);
1255 3: break;
1256 :
1257 : case pch::EXPR_CXX_NULL_PTR_LITERAL:
1: branch 1 taken
0: branch 2 not taken
1258 1: S = new (Context) CXXNullPtrLiteralExpr(Empty);
1259 : break;
1260 : }
1261 :
1262 : // We hit a STMT_STOP, so we're done with this expression.
564: branch 0 taken
105: branch 1 taken
1263 669: if (Finished)
1264 105: break;
1265 :
1266 564: ++NumStatementsRead;
1267 :
544: branch 0 taken
20: branch 1 taken
1268 564: if (S) {
1269 544: unsigned NumSubStmts = Reader.Visit(S);
459: branch 0 taken
544: branch 1 taken
1270 1547: while (NumSubStmts > 0) {
1271 459: StmtStack.pop_back();
1272 459: --NumSubStmts;
1273 : }
1274 : }
1275 :
564: branch 1 taken
0: branch 2 not taken
1276 564: assert(Idx == Record.size() && "Invalid deserialization of statement");
1277 564: StmtStack.push_back(S);
1278 : }
105: branch 1 taken
0: branch 2 not taken
1279 105: assert(StmtStack.size() == 1 && "Extra expressions on stack!");
1280 210: return StmtStack.back();
1281 : }
Generated: 2010-02-10 01:31 by zcov