1 //===--- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Statement/expression deserialization. This implements the
11 // ASTReader::ReadStmt method.
13 //===----------------------------------------------------------------------===//
15 #include "clang/Serialization/ASTReader.h"
16 #include "clang/AST/ASTContext.h"
17 #include "clang/AST/DeclCXX.h"
18 #include "clang/AST/DeclTemplate.h"
19 #include "clang/AST/StmtVisitor.h"
20 #include "clang/Lex/Token.h"
21 #include "llvm/ADT/SmallString.h"
22 using namespace clang;
23 using namespace clang::serialization;
27 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
28 friend class OMPClauseReader;
29 typedef ASTReader::RecordData RecordData;
33 llvm::BitstreamCursor &DeclsCursor;
34 const ASTReader::RecordData &Record;
37 Token ReadToken(const RecordData &R, unsigned &I) {
38 return Reader.ReadToken(F, R, I);
41 SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
42 return Reader.ReadSourceLocation(F, R, I);
45 SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
46 return Reader.ReadSourceRange(F, R, I);
49 std::string ReadString(const RecordData &R, unsigned &I) {
50 return Reader.ReadString(R, I);
53 TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) {
54 return Reader.GetTypeSourceInfo(F, R, I);
57 serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) {
58 return Reader.ReadDeclID(F, R, I);
61 Decl *ReadDecl(const RecordData &R, unsigned &I) {
62 return Reader.ReadDecl(F, R, I);
66 T *ReadDeclAs(const RecordData &R, unsigned &I) {
67 return Reader.ReadDeclAs<T>(F, R, I);
70 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
71 const ASTReader::RecordData &R, unsigned &I) {
72 Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
75 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo,
76 const ASTReader::RecordData &R, unsigned &I) {
77 Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
81 ASTStmtReader(ASTReader &Reader, ModuleFile &F,
82 llvm::BitstreamCursor &Cursor,
83 const ASTReader::RecordData &Record, unsigned &Idx)
84 : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
86 /// \brief The number of record fields required for the Stmt class
88 static const unsigned NumStmtFields = 0;
90 /// \brief The number of record fields required for the Expr class
92 static const unsigned NumExprFields = NumStmtFields + 7;
94 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
95 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
96 unsigned NumTemplateArgs);
97 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
98 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
99 unsigned NumTemplateArgs);
101 void VisitStmt(Stmt *S);
102 #define STMT(Type, Base) \
103 void Visit##Type(Type *);
104 #include "clang/AST/StmtNodes.inc"
109 ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
110 unsigned NumTemplateArgs) {
111 SourceLocation TemplateKWLoc = ReadSourceLocation(Record, Idx);
112 TemplateArgumentListInfo ArgInfo;
113 ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx));
114 ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx));
115 for (unsigned i = 0; i != NumTemplateArgs; ++i)
117 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
118 Args.initializeFrom(TemplateKWLoc, ArgInfo);
121 void ASTStmtReader::VisitStmt(Stmt *S) {
122 assert(Idx == NumStmtFields && "Incorrect statement field count");
125 void ASTStmtReader::VisitNullStmt(NullStmt *S) {
127 S->setSemiLoc(ReadSourceLocation(Record, Idx));
128 S->HasLeadingEmptyMacro = Record[Idx++];
131 void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
133 SmallVector<Stmt *, 16> Stmts;
134 unsigned NumStmts = Record[Idx++];
136 Stmts.push_back(Reader.ReadSubStmt());
137 S->setStmts(Reader.getContext(), Stmts.data(), Stmts.size());
138 S->setLBracLoc(ReadSourceLocation(Record, Idx));
139 S->setRBracLoc(ReadSourceLocation(Record, Idx));
142 void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
144 Reader.RecordSwitchCaseID(S, Record[Idx++]);
145 S->setKeywordLoc(ReadSourceLocation(Record, Idx));
146 S->setColonLoc(ReadSourceLocation(Record, Idx));
149 void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
151 S->setLHS(Reader.ReadSubExpr());
152 S->setRHS(Reader.ReadSubExpr());
153 S->setSubStmt(Reader.ReadSubStmt());
154 S->setEllipsisLoc(ReadSourceLocation(Record, Idx));
157 void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
159 S->setSubStmt(Reader.ReadSubStmt());
162 void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
164 LabelDecl *LD = ReadDeclAs<LabelDecl>(Record, Idx);
167 S->setSubStmt(Reader.ReadSubStmt());
168 S->setIdentLoc(ReadSourceLocation(Record, Idx));
171 void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
173 uint64_t NumAttrs = Record[Idx++];
175 Reader.ReadAttributes(F, Attrs, Record, Idx);
177 assert(NumAttrs == S->NumAttrs);
178 assert(NumAttrs == Attrs.size());
179 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
180 S->SubStmt = Reader.ReadSubStmt();
181 S->AttrLoc = ReadSourceLocation(Record, Idx);
184 void ASTStmtReader::VisitIfStmt(IfStmt *S) {
186 S->setConditionVariable(Reader.getContext(),
187 ReadDeclAs<VarDecl>(Record, Idx));
188 S->setCond(Reader.ReadSubExpr());
189 S->setThen(Reader.ReadSubStmt());
190 S->setElse(Reader.ReadSubStmt());
191 S->setIfLoc(ReadSourceLocation(Record, Idx));
192 S->setElseLoc(ReadSourceLocation(Record, Idx));
195 void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
197 S->setConditionVariable(Reader.getContext(),
198 ReadDeclAs<VarDecl>(Record, Idx));
199 S->setCond(Reader.ReadSubExpr());
200 S->setBody(Reader.ReadSubStmt());
201 S->setSwitchLoc(ReadSourceLocation(Record, Idx));
203 S->setAllEnumCasesCovered();
205 SwitchCase *PrevSC = nullptr;
206 for (unsigned N = Record.size(); Idx != N; ++Idx) {
207 SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
209 PrevSC->setNextSwitchCase(SC);
211 S->setSwitchCaseList(SC);
217 void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
219 S->setConditionVariable(Reader.getContext(),
220 ReadDeclAs<VarDecl>(Record, Idx));
222 S->setCond(Reader.ReadSubExpr());
223 S->setBody(Reader.ReadSubStmt());
224 S->setWhileLoc(ReadSourceLocation(Record, Idx));
227 void ASTStmtReader::VisitDoStmt(DoStmt *S) {
229 S->setCond(Reader.ReadSubExpr());
230 S->setBody(Reader.ReadSubStmt());
231 S->setDoLoc(ReadSourceLocation(Record, Idx));
232 S->setWhileLoc(ReadSourceLocation(Record, Idx));
233 S->setRParenLoc(ReadSourceLocation(Record, Idx));
236 void ASTStmtReader::VisitForStmt(ForStmt *S) {
238 S->setInit(Reader.ReadSubStmt());
239 S->setCond(Reader.ReadSubExpr());
240 S->setConditionVariable(Reader.getContext(),
241 ReadDeclAs<VarDecl>(Record, Idx));
242 S->setInc(Reader.ReadSubExpr());
243 S->setBody(Reader.ReadSubStmt());
244 S->setForLoc(ReadSourceLocation(Record, Idx));
245 S->setLParenLoc(ReadSourceLocation(Record, Idx));
246 S->setRParenLoc(ReadSourceLocation(Record, Idx));
249 void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
251 S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
252 S->setGotoLoc(ReadSourceLocation(Record, Idx));
253 S->setLabelLoc(ReadSourceLocation(Record, Idx));
256 void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
258 S->setGotoLoc(ReadSourceLocation(Record, Idx));
259 S->setStarLoc(ReadSourceLocation(Record, Idx));
260 S->setTarget(Reader.ReadSubExpr());
263 void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
265 S->setContinueLoc(ReadSourceLocation(Record, Idx));
268 void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
270 S->setBreakLoc(ReadSourceLocation(Record, Idx));
273 void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
275 S->setRetValue(Reader.ReadSubExpr());
276 S->setReturnLoc(ReadSourceLocation(Record, Idx));
277 S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx));
280 void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
282 S->setStartLoc(ReadSourceLocation(Record, Idx));
283 S->setEndLoc(ReadSourceLocation(Record, Idx));
285 if (Idx + 1 == Record.size()) {
286 // Single declaration
287 S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx)));
289 SmallVector<Decl *, 16> Decls;
290 Decls.reserve(Record.size() - Idx);
291 for (unsigned N = Record.size(); Idx != N; )
292 Decls.push_back(ReadDecl(Record, Idx));
293 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(),
299 void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
301 S->NumOutputs = Record[Idx++];
302 S->NumInputs = Record[Idx++];
303 S->NumClobbers = Record[Idx++];
304 S->setAsmLoc(ReadSourceLocation(Record, Idx));
305 S->setVolatile(Record[Idx++]);
306 S->setSimple(Record[Idx++]);
309 void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
311 S->setRParenLoc(ReadSourceLocation(Record, Idx));
312 S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
314 unsigned NumOutputs = S->getNumOutputs();
315 unsigned NumInputs = S->getNumInputs();
316 unsigned NumClobbers = S->getNumClobbers();
318 // Outputs and inputs
319 SmallVector<IdentifierInfo *, 16> Names;
320 SmallVector<StringLiteral*, 16> Constraints;
321 SmallVector<Stmt*, 16> Exprs;
322 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
323 Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx));
324 Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
325 Exprs.push_back(Reader.ReadSubStmt());
329 SmallVector<StringLiteral*, 16> Clobbers;
330 for (unsigned I = 0; I != NumClobbers; ++I)
331 Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
333 S->setOutputsAndInputsAndClobbers(Reader.getContext(),
334 Names.data(), Constraints.data(),
335 Exprs.data(), NumOutputs, NumInputs,
336 Clobbers.data(), NumClobbers);
339 void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
341 S->LBraceLoc = ReadSourceLocation(Record, Idx);
342 S->EndLoc = ReadSourceLocation(Record, Idx);
343 S->NumAsmToks = Record[Idx++];
344 std::string AsmStr = ReadString(Record, Idx);
347 SmallVector<Token, 16> AsmToks;
348 AsmToks.reserve(S->NumAsmToks);
349 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
350 AsmToks.push_back(ReadToken(Record, Idx));
353 // The calls to reserve() for the FooData vectors are mandatory to
354 // prevent dead StringRefs in the Foo vectors.
356 // Read the clobbers.
357 SmallVector<std::string, 16> ClobbersData;
358 SmallVector<StringRef, 16> Clobbers;
359 ClobbersData.reserve(S->NumClobbers);
360 Clobbers.reserve(S->NumClobbers);
361 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
362 ClobbersData.push_back(ReadString(Record, Idx));
363 Clobbers.push_back(ClobbersData.back());
366 // Read the operands.
367 unsigned NumOperands = S->NumOutputs + S->NumInputs;
368 SmallVector<Expr*, 16> Exprs;
369 SmallVector<std::string, 16> ConstraintsData;
370 SmallVector<StringRef, 16> Constraints;
371 Exprs.reserve(NumOperands);
372 ConstraintsData.reserve(NumOperands);
373 Constraints.reserve(NumOperands);
374 for (unsigned i = 0; i != NumOperands; ++i) {
375 Exprs.push_back(cast<Expr>(Reader.ReadSubStmt()));
376 ConstraintsData.push_back(ReadString(Record, Idx));
377 Constraints.push_back(ConstraintsData.back());
380 S->initialize(Reader.getContext(), AsmStr, AsmToks,
381 Constraints, Exprs, Clobbers);
384 void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
387 S->setCapturedDecl(ReadDeclAs<CapturedDecl>(Record, Idx));
388 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record[Idx++]));
389 S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>(Record, Idx));
392 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
393 E = S->capture_init_end();
395 *I = Reader.ReadSubExpr();
398 S->setCapturedStmt(Reader.ReadSubStmt());
399 S->getCapturedDecl()->setBody(S->getCapturedStmt());
402 for (auto &I : S->captures()) {
403 I.VarAndKind.setPointer(ReadDeclAs<VarDecl>(Record, Idx));
405 .setInt(static_cast<CapturedStmt::VariableCaptureKind>(Record[Idx++]));
406 I.Loc = ReadSourceLocation(Record, Idx);
410 void ASTStmtReader::VisitExpr(Expr *E) {
412 E->setType(Reader.readType(F, Record, Idx));
413 E->setTypeDependent(Record[Idx++]);
414 E->setValueDependent(Record[Idx++]);
415 E->setInstantiationDependent(Record[Idx++]);
416 E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
417 E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
418 E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
419 assert(Idx == NumExprFields && "Incorrect expression field count");
422 void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
424 E->setLocation(ReadSourceLocation(Record, Idx));
425 E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
428 void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
431 E->DeclRefExprBits.HasQualifier = Record[Idx++];
432 E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
433 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record[Idx++];
434 E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
435 E->DeclRefExprBits.RefersToEnclosingLocal = Record[Idx++];
436 unsigned NumTemplateArgs = 0;
437 if (E->hasTemplateKWAndArgsInfo())
438 NumTemplateArgs = Record[Idx++];
440 if (E->hasQualifier())
441 E->getInternalQualifierLoc()
442 = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
444 if (E->hasFoundDecl())
445 E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx);
447 if (E->hasTemplateKWAndArgsInfo())
448 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
451 E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
452 E->setLocation(ReadSourceLocation(Record, Idx));
453 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
456 void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
458 E->setLocation(ReadSourceLocation(Record, Idx));
459 E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
462 void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
464 E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record[Idx++]));
465 E->setExact(Record[Idx++]);
466 E->setValue(Reader.getContext(),
467 Reader.ReadAPFloat(Record, E->getSemantics(), Idx));
468 E->setLocation(ReadSourceLocation(Record, Idx));
471 void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
473 E->setSubExpr(Reader.ReadSubExpr());
476 void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
478 unsigned Len = Record[Idx++];
479 assert(Record[Idx] == E->getNumConcatenated() &&
480 "Wrong number of concatenated tokens!");
482 StringLiteral::StringKind kind =
483 static_cast<StringLiteral::StringKind>(Record[Idx++]);
484 bool isPascal = Record[Idx++];
487 SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
488 E->setString(Reader.getContext(), Str.str(), kind, isPascal);
491 // Read source locations
492 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
493 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
496 void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
498 E->setValue(Record[Idx++]);
499 E->setLocation(ReadSourceLocation(Record, Idx));
500 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
503 void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
505 E->setLParen(ReadSourceLocation(Record, Idx));
506 E->setRParen(ReadSourceLocation(Record, Idx));
507 E->setSubExpr(Reader.ReadSubExpr());
510 void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
512 unsigned NumExprs = Record[Idx++];
513 E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
514 for (unsigned i = 0; i != NumExprs; ++i)
515 E->Exprs[i] = Reader.ReadSubStmt();
516 E->NumExprs = NumExprs;
517 E->LParenLoc = ReadSourceLocation(Record, Idx);
518 E->RParenLoc = ReadSourceLocation(Record, Idx);
521 void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
523 E->setSubExpr(Reader.ReadSubExpr());
524 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
525 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
528 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
529 typedef OffsetOfExpr::OffsetOfNode Node;
531 assert(E->getNumComponents() == Record[Idx]);
533 assert(E->getNumExpressions() == Record[Idx]);
535 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
536 E->setRParenLoc(ReadSourceLocation(Record, Idx));
537 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
538 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
539 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
540 SourceLocation Start = ReadSourceLocation(Record, Idx);
541 SourceLocation End = ReadSourceLocation(Record, Idx);
544 E->setComponent(I, Node(Start, Record[Idx++], End));
548 E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
551 case Node::Identifier:
554 Reader.GetIdentifierInfo(F, Record, Idx),
559 CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
560 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
561 E->setComponent(I, Node(Base));
567 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
568 E->setIndexExpr(I, Reader.ReadSubExpr());
571 void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
573 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
574 if (Record[Idx] == 0) {
575 E->setArgument(Reader.ReadSubExpr());
578 E->setArgument(GetTypeSourceInfo(Record, Idx));
580 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
581 E->setRParenLoc(ReadSourceLocation(Record, Idx));
584 void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
586 E->setLHS(Reader.ReadSubExpr());
587 E->setRHS(Reader.ReadSubExpr());
588 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
591 void ASTStmtReader::VisitCallExpr(CallExpr *E) {
593 E->setNumArgs(Reader.getContext(), Record[Idx++]);
594 E->setRParenLoc(ReadSourceLocation(Record, Idx));
595 E->setCallee(Reader.ReadSubExpr());
596 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
597 E->setArg(I, Reader.ReadSubExpr());
600 void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
604 void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
605 // Don't call VisitExpr, this is fully initialized at creation.
606 assert(E->getStmtClass() == Stmt::MemberExprClass &&
607 "It's a subclass, we must advance Idx!");
610 void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
612 E->setBase(Reader.ReadSubExpr());
613 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
614 E->setOpLoc(ReadSourceLocation(Record, Idx));
615 E->setArrow(Record[Idx++]);
619 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
621 E->Operand = Reader.ReadSubExpr();
622 E->setShouldCopy(Record[Idx++]);
625 void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
626 VisitExplicitCastExpr(E);
627 E->LParenLoc = ReadSourceLocation(Record, Idx);
628 E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
629 E->Kind = Record[Idx++];
632 void ASTStmtReader::VisitCastExpr(CastExpr *E) {
634 unsigned NumBaseSpecs = Record[Idx++];
635 assert(NumBaseSpecs == E->path_size());
636 E->setSubExpr(Reader.ReadSubExpr());
637 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
638 CastExpr::path_iterator BaseI = E->path_begin();
639 while (NumBaseSpecs--) {
640 CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
641 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
646 void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
648 E->setLHS(Reader.ReadSubExpr());
649 E->setRHS(Reader.ReadSubExpr());
650 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
651 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
652 E->setFPContractable((bool)Record[Idx++]);
655 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
656 VisitBinaryOperator(E);
657 E->setComputationLHSType(Reader.readType(F, Record, Idx));
658 E->setComputationResultType(Reader.readType(F, Record, Idx));
661 void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
663 E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
664 E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
665 E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
666 E->QuestionLoc = ReadSourceLocation(Record, Idx);
667 E->ColonLoc = ReadSourceLocation(Record, Idx);
671 ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
673 E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
674 E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
675 E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
676 E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
677 E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
678 E->QuestionLoc = ReadSourceLocation(Record, Idx);
679 E->ColonLoc = ReadSourceLocation(Record, Idx);
682 void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
686 void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
688 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
691 void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
692 VisitExplicitCastExpr(E);
693 E->setLParenLoc(ReadSourceLocation(Record, Idx));
694 E->setRParenLoc(ReadSourceLocation(Record, Idx));
697 void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
699 E->setLParenLoc(ReadSourceLocation(Record, Idx));
700 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
701 E->setInitializer(Reader.ReadSubExpr());
702 E->setFileScope(Record[Idx++]);
705 void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
707 E->setBase(Reader.ReadSubExpr());
708 E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
709 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
712 void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
714 if (InitListExpr *SyntForm = cast_or_null<InitListExpr>(Reader.ReadSubStmt()))
715 E->setSyntacticForm(SyntForm);
716 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
717 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
718 bool isArrayFiller = Record[Idx++];
719 Expr *filler = nullptr;
721 filler = Reader.ReadSubExpr();
722 E->ArrayFillerOrUnionFieldInit = filler;
724 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
725 E->sawArrayRangeDesignator(Record[Idx++]);
726 unsigned NumInits = Record[Idx++];
727 E->reserveInits(Reader.getContext(), NumInits);
729 for (unsigned I = 0; I != NumInits; ++I) {
730 Expr *init = Reader.ReadSubExpr();
731 E->updateInit(Reader.getContext(), I, init ? init : filler);
734 for (unsigned I = 0; I != NumInits; ++I)
735 E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
739 void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
740 typedef DesignatedInitExpr::Designator Designator;
743 unsigned NumSubExprs = Record[Idx++];
744 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
745 for (unsigned I = 0; I != NumSubExprs; ++I)
746 E->setSubExpr(I, Reader.ReadSubExpr());
747 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
748 E->setGNUSyntax(Record[Idx++]);
750 SmallVector<Designator, 4> Designators;
751 while (Idx < Record.size()) {
752 switch ((DesignatorTypes)Record[Idx++]) {
753 case DESIG_FIELD_DECL: {
754 FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
755 SourceLocation DotLoc
756 = ReadSourceLocation(Record, Idx);
757 SourceLocation FieldLoc
758 = ReadSourceLocation(Record, Idx);
759 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
761 Designators.back().setField(Field);
765 case DESIG_FIELD_NAME: {
766 const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
767 SourceLocation DotLoc
768 = ReadSourceLocation(Record, Idx);
769 SourceLocation FieldLoc
770 = ReadSourceLocation(Record, Idx);
771 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
776 unsigned Index = Record[Idx++];
777 SourceLocation LBracketLoc
778 = ReadSourceLocation(Record, Idx);
779 SourceLocation RBracketLoc
780 = ReadSourceLocation(Record, Idx);
781 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
785 case DESIG_ARRAY_RANGE: {
786 unsigned Index = Record[Idx++];
787 SourceLocation LBracketLoc
788 = ReadSourceLocation(Record, Idx);
789 SourceLocation EllipsisLoc
790 = ReadSourceLocation(Record, Idx);
791 SourceLocation RBracketLoc
792 = ReadSourceLocation(Record, Idx);
793 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
799 E->setDesignators(Reader.getContext(),
800 Designators.data(), Designators.size());
803 void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
807 void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
809 E->setSubExpr(Reader.ReadSubExpr());
810 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
811 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
812 E->setRParenLoc(ReadSourceLocation(Record, Idx));
815 void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
817 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
818 E->setLabelLoc(ReadSourceLocation(Record, Idx));
819 E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
822 void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
824 E->setLParenLoc(ReadSourceLocation(Record, Idx));
825 E->setRParenLoc(ReadSourceLocation(Record, Idx));
826 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
829 void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
831 E->setCond(Reader.ReadSubExpr());
832 E->setLHS(Reader.ReadSubExpr());
833 E->setRHS(Reader.ReadSubExpr());
834 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
835 E->setRParenLoc(ReadSourceLocation(Record, Idx));
836 E->setIsConditionTrue(Record[Idx++]);
839 void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
841 E->setTokenLocation(ReadSourceLocation(Record, Idx));
844 void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
846 SmallVector<Expr *, 16> Exprs;
847 unsigned NumExprs = Record[Idx++];
849 Exprs.push_back(Reader.ReadSubExpr());
850 E->setExprs(Reader.getContext(), Exprs);
851 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
852 E->setRParenLoc(ReadSourceLocation(Record, Idx));
855 void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
857 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
858 E->RParenLoc = ReadSourceLocation(Record, Idx);
859 E->TInfo = GetTypeSourceInfo(Record, Idx);
860 E->SrcExpr = Reader.ReadSubExpr();
863 void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
865 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
868 void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
870 E->NumAssocs = Record[Idx++];
871 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
873 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
875 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
876 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
877 E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
878 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
880 E->ResultIndex = Record[Idx++];
882 E->GenericLoc = ReadSourceLocation(Record, Idx);
883 E->DefaultLoc = ReadSourceLocation(Record, Idx);
884 E->RParenLoc = ReadSourceLocation(Record, Idx);
887 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
889 unsigned numSemanticExprs = Record[Idx++];
890 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
891 E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
893 // Read the syntactic expression.
894 E->getSubExprsBuffer()[0] = Reader.ReadSubExpr();
896 // Read all the semantic expressions.
897 for (unsigned i = 0; i != numSemanticExprs; ++i) {
898 Expr *subExpr = Reader.ReadSubExpr();
899 E->getSubExprsBuffer()[i+1] = subExpr;
903 void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
905 E->Op = AtomicExpr::AtomicOp(Record[Idx++]);
906 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
907 for (unsigned I = 0; I != E->NumSubExprs; ++I)
908 E->SubExprs[I] = Reader.ReadSubExpr();
909 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
910 E->RParenLoc = ReadSourceLocation(Record, Idx);
913 //===----------------------------------------------------------------------===//
914 // Objective-C Expressions and Statements
916 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
918 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
919 E->setAtLoc(ReadSourceLocation(Record, Idx));
922 void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
924 // could be one of several IntegerLiteral, FloatLiteral, etc.
925 E->SubExpr = Reader.ReadSubStmt();
926 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
927 E->Range = ReadSourceRange(Record, Idx);
930 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
932 unsigned NumElements = Record[Idx++];
933 assert(NumElements == E->getNumElements() && "Wrong number of elements");
934 Expr **Elements = E->getElements();
935 for (unsigned I = 0, N = NumElements; I != N; ++I)
936 Elements[I] = Reader.ReadSubExpr();
937 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
938 E->Range = ReadSourceRange(Record, Idx);
941 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
943 unsigned NumElements = Record[Idx++];
944 assert(NumElements == E->getNumElements() && "Wrong number of elements");
945 bool HasPackExpansions = Record[Idx++];
946 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
947 ObjCDictionaryLiteral::KeyValuePair *KeyValues = E->getKeyValues();
948 ObjCDictionaryLiteral::ExpansionData *Expansions = E->getExpansionData();
949 for (unsigned I = 0; I != NumElements; ++I) {
950 KeyValues[I].Key = Reader.ReadSubExpr();
951 KeyValues[I].Value = Reader.ReadSubExpr();
952 if (HasPackExpansions) {
953 Expansions[I].EllipsisLoc = ReadSourceLocation(Record, Idx);
954 Expansions[I].NumExpansionsPlusOne = Record[Idx++];
957 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
958 E->Range = ReadSourceRange(Record, Idx);
961 void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
963 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
964 E->setAtLoc(ReadSourceLocation(Record, Idx));
965 E->setRParenLoc(ReadSourceLocation(Record, Idx));
968 void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
970 E->setSelector(Reader.ReadSelector(F, Record, Idx));
971 E->setAtLoc(ReadSourceLocation(Record, Idx));
972 E->setRParenLoc(ReadSourceLocation(Record, Idx));
975 void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
977 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
978 E->setAtLoc(ReadSourceLocation(Record, Idx));
979 E->ProtoLoc = ReadSourceLocation(Record, Idx);
980 E->setRParenLoc(ReadSourceLocation(Record, Idx));
983 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
985 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
986 E->setLocation(ReadSourceLocation(Record, Idx));
987 E->setOpLoc(ReadSourceLocation(Record, Idx));
988 E->setBase(Reader.ReadSubExpr());
989 E->setIsArrow(Record[Idx++]);
990 E->setIsFreeIvar(Record[Idx++]);
993 void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
995 unsigned MethodRefFlags = Record[Idx++];
996 bool Implicit = Record[Idx++] != 0;
998 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
999 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
1000 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
1002 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx),
1005 E->setLocation(ReadSourceLocation(Record, Idx));
1006 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
1007 switch (Record[Idx++]) {
1009 E->setBase(Reader.ReadSubExpr());
1012 E->setSuperReceiver(Reader.readType(F, Record, Idx));
1015 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
1020 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1022 E->setRBracket(ReadSourceLocation(Record, Idx));
1023 E->setBaseExpr(Reader.ReadSubExpr());
1024 E->setKeyExpr(Reader.ReadSubExpr());
1025 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
1026 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
1029 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1031 assert(Record[Idx] == E->getNumArgs());
1033 unsigned NumStoredSelLocs = Record[Idx++];
1034 E->SelLocsKind = Record[Idx++];
1035 E->setDelegateInitCall(Record[Idx++]);
1036 E->IsImplicit = Record[Idx++];
1037 ObjCMessageExpr::ReceiverKind Kind
1038 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
1040 case ObjCMessageExpr::Instance:
1041 E->setInstanceReceiver(Reader.ReadSubExpr());
1044 case ObjCMessageExpr::Class:
1045 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
1048 case ObjCMessageExpr::SuperClass:
1049 case ObjCMessageExpr::SuperInstance: {
1050 QualType T = Reader.readType(F, Record, Idx);
1051 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
1052 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1057 assert(Kind == E->getReceiverKind());
1060 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
1062 E->setSelector(Reader.ReadSelector(F, Record, Idx));
1064 E->LBracLoc = ReadSourceLocation(Record, Idx);
1065 E->RBracLoc = ReadSourceLocation(Record, Idx);
1067 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1068 E->setArg(I, Reader.ReadSubExpr());
1070 SourceLocation *Locs = E->getStoredSelLocs();
1071 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1072 Locs[I] = ReadSourceLocation(Record, Idx);
1075 void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1077 S->setElement(Reader.ReadSubStmt());
1078 S->setCollection(Reader.ReadSubExpr());
1079 S->setBody(Reader.ReadSubStmt());
1080 S->setForLoc(ReadSourceLocation(Record, Idx));
1081 S->setRParenLoc(ReadSourceLocation(Record, Idx));
1084 void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1086 S->setCatchBody(Reader.ReadSubStmt());
1087 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
1088 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
1089 S->setRParenLoc(ReadSourceLocation(Record, Idx));
1092 void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1094 S->setFinallyBody(Reader.ReadSubStmt());
1095 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
1098 void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1100 S->setSubStmt(Reader.ReadSubStmt());
1101 S->setAtLoc(ReadSourceLocation(Record, Idx));
1104 void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1106 assert(Record[Idx] == S->getNumCatchStmts());
1108 bool HasFinally = Record[Idx++];
1109 S->setTryBody(Reader.ReadSubStmt());
1110 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
1111 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
1114 S->setFinallyStmt(Reader.ReadSubStmt());
1115 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
1118 void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1120 S->setSynchExpr(Reader.ReadSubStmt());
1121 S->setSynchBody(Reader.ReadSubStmt());
1122 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
1125 void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1127 S->setThrowExpr(Reader.ReadSubStmt());
1128 S->setThrowLoc(ReadSourceLocation(Record, Idx));
1131 void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1133 E->setValue(Record[Idx++]);
1134 E->setLocation(ReadSourceLocation(Record, Idx));
1137 //===----------------------------------------------------------------------===//
1138 // C++ Expressions and Statements
1139 //===----------------------------------------------------------------------===//
1141 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
1143 S->CatchLoc = ReadSourceLocation(Record, Idx);
1144 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
1145 S->HandlerBlock = Reader.ReadSubStmt();
1148 void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
1150 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
1152 S->TryLoc = ReadSourceLocation(Record, Idx);
1153 S->getStmts()[0] = Reader.ReadSubStmt();
1154 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1155 S->getStmts()[i + 1] = Reader.ReadSubStmt();
1158 void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1160 S->setForLoc(ReadSourceLocation(Record, Idx));
1161 S->setColonLoc(ReadSourceLocation(Record, Idx));
1162 S->setRParenLoc(ReadSourceLocation(Record, Idx));
1163 S->setRangeStmt(Reader.ReadSubStmt());
1164 S->setBeginEndStmt(Reader.ReadSubStmt());
1165 S->setCond(Reader.ReadSubExpr());
1166 S->setInc(Reader.ReadSubExpr());
1167 S->setLoopVarStmt(Reader.ReadSubStmt());
1168 S->setBody(Reader.ReadSubStmt());
1171 void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1173 S->KeywordLoc = ReadSourceLocation(Record, Idx);
1174 S->IsIfExists = Record[Idx++];
1175 S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1176 ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1177 S->SubStmt = Reader.ReadSubStmt();
1180 void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1182 E->Operator = (OverloadedOperatorKind)Record[Idx++];
1183 E->Range = Reader.ReadSourceRange(F, Record, Idx);
1184 E->setFPContractable((bool)Record[Idx++]);
1187 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
1189 E->NumArgs = Record[Idx++];
1191 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
1192 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1193 E->setArg(I, Reader.ReadSubExpr());
1194 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
1195 E->setLocation(ReadSourceLocation(Record, Idx));
1196 E->setElidable(Record[Idx++]);
1197 E->setHadMultipleCandidates(Record[Idx++]);
1198 E->setListInitialization(Record[Idx++]);
1199 E->setStdInitListInitialization(Record[Idx++]);
1200 E->setRequiresZeroInitialization(Record[Idx++]);
1201 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
1202 E->ParenOrBraceRange = ReadSourceRange(Record, Idx);
1205 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1206 VisitCXXConstructExpr(E);
1207 E->Type = GetTypeSourceInfo(Record, Idx);
1210 void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1212 unsigned NumCaptures = Record[Idx++];
1213 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1214 unsigned NumArrayIndexVars = Record[Idx++];
1215 E->IntroducerRange = ReadSourceRange(Record, Idx);
1216 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record[Idx++]);
1217 E->CaptureDefaultLoc = ReadSourceLocation(Record, Idx);
1218 E->ExplicitParams = Record[Idx++];
1219 E->ExplicitResultType = Record[Idx++];
1220 E->ClosingBrace = ReadSourceLocation(Record, Idx);
1222 // Read capture initializers.
1223 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1224 CEnd = E->capture_init_end();
1226 *C = Reader.ReadSubExpr();
1228 // Read array capture index variables.
1229 if (NumArrayIndexVars > 0) {
1230 unsigned *ArrayIndexStarts = E->getArrayIndexStarts();
1231 for (unsigned I = 0; I != NumCaptures + 1; ++I)
1232 ArrayIndexStarts[I] = Record[Idx++];
1234 VarDecl **ArrayIndexVars = E->getArrayIndexVars();
1235 for (unsigned I = 0; I != NumArrayIndexVars; ++I)
1236 ArrayIndexVars[I] = ReadDeclAs<VarDecl>(Record, Idx);
1241 ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1243 E->SubExpr = Reader.ReadSubExpr();
1246 void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1247 VisitExplicitCastExpr(E);
1248 SourceRange R = ReadSourceRange(Record, Idx);
1249 E->Loc = R.getBegin();
1250 E->RParenLoc = R.getEnd();
1251 R = ReadSourceRange(Record, Idx);
1252 E->AngleBrackets = R;
1255 void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1256 return VisitCXXNamedCastExpr(E);
1259 void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1260 return VisitCXXNamedCastExpr(E);
1263 void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1264 return VisitCXXNamedCastExpr(E);
1267 void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1268 return VisitCXXNamedCastExpr(E);
1271 void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1272 VisitExplicitCastExpr(E);
1273 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1274 E->setRParenLoc(ReadSourceLocation(Record, Idx));
1277 void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1279 E->UDSuffixLoc = ReadSourceLocation(Record, Idx);
1282 void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1284 E->setValue(Record[Idx++]);
1285 E->setLocation(ReadSourceLocation(Record, Idx));
1288 void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1290 E->setLocation(ReadSourceLocation(Record, Idx));
1293 void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1295 E->setSourceRange(ReadSourceRange(Record, Idx));
1296 if (E->isTypeOperand()) { // typeid(int)
1297 E->setTypeOperandSourceInfo(
1298 GetTypeSourceInfo(Record, Idx));
1303 E->setExprOperand(Reader.ReadSubExpr());
1306 void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
1308 E->setLocation(ReadSourceLocation(Record, Idx));
1309 E->setImplicit(Record[Idx++]);
1312 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
1314 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1315 E->Op = Reader.ReadSubExpr();
1316 E->IsThrownVariableInScope = Record[Idx++];
1319 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1322 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
1323 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
1324 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
1325 E->Loc = ReadSourceLocation(Record, Idx);
1328 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1330 E->Field = ReadDeclAs<FieldDecl>(Record, Idx);
1331 E->Loc = ReadSourceLocation(Record, Idx);
1334 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1336 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
1337 E->setSubExpr(Reader.ReadSubExpr());
1340 void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1342 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1343 E->RParenLoc = ReadSourceLocation(Record, Idx);
1346 void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
1348 E->GlobalNew = Record[Idx++];
1349 bool isArray = Record[Idx++];
1350 E->UsualArrayDeleteWantsSize = Record[Idx++];
1351 unsigned NumPlacementArgs = Record[Idx++];
1352 E->StoredInitializationStyle = Record[Idx++];
1353 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1354 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
1355 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
1356 E->TypeIdParens = ReadSourceRange(Record, Idx);
1357 E->Range = ReadSourceRange(Record, Idx);
1358 E->DirectInitRange = ReadSourceRange(Record, Idx);
1360 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
1361 E->StoredInitializationStyle != 0);
1363 // Install all the subexpressions.
1364 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1366 *I = Reader.ReadSubStmt();
1369 void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1371 E->GlobalDelete = Record[Idx++];
1372 E->ArrayForm = Record[Idx++];
1373 E->ArrayFormAsWritten = Record[Idx++];
1374 E->UsualArrayDeleteWantsSize = Record[Idx++];
1375 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
1376 E->Argument = Reader.ReadSubExpr();
1377 E->Loc = ReadSourceLocation(Record, Idx);
1380 void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1383 E->Base = Reader.ReadSubExpr();
1384 E->IsArrow = Record[Idx++];
1385 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1386 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1387 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1388 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1389 E->TildeLoc = ReadSourceLocation(Record, Idx);
1391 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
1393 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
1395 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
1398 void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
1401 unsigned NumObjects = Record[Idx++];
1402 assert(NumObjects == E->getNumObjects());
1403 for (unsigned i = 0; i != NumObjects; ++i)
1404 E->getObjectsBuffer()[i] = ReadDeclAs<BlockDecl>(Record, Idx);
1406 E->SubExpr = Reader.ReadSubExpr();
1410 ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
1413 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1414 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1415 /*NumTemplateArgs=*/Record[Idx++]);
1417 E->Base = Reader.ReadSubExpr();
1418 E->BaseType = Reader.readType(F, Record, Idx);
1419 E->IsArrow = Record[Idx++];
1420 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1421 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1422 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
1423 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
1427 ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
1430 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1431 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1432 /*NumTemplateArgs=*/Record[Idx++]);
1434 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1435 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
1439 ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
1441 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1443 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
1444 E->setArg(I, Reader.ReadSubExpr());
1445 E->Type = GetTypeSourceInfo(Record, Idx);
1446 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1447 E->setRParenLoc(ReadSourceLocation(Record, Idx));
1450 void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
1453 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1454 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1455 /*NumTemplateArgs=*/Record[Idx++]);
1457 unsigned NumDecls = Record[Idx++];
1458 UnresolvedSet<8> Decls;
1459 for (unsigned i = 0; i != NumDecls; ++i) {
1460 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
1461 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1462 Decls.addDecl(D, AS);
1464 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
1466 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
1467 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1470 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
1471 VisitOverloadExpr(E);
1472 E->IsArrow = Record[Idx++];
1473 E->HasUnresolvedUsing = Record[Idx++];
1474 E->Base = Reader.ReadSubExpr();
1475 E->BaseType = Reader.readType(F, Record, Idx);
1476 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1479 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
1480 VisitOverloadExpr(E);
1481 E->RequiresADL = Record[Idx++];
1482 E->Overloaded = Record[Idx++];
1483 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
1486 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1488 E->TypeTraitExprBits.NumArgs = Record[Idx++];
1489 E->TypeTraitExprBits.Kind = Record[Idx++];
1490 E->TypeTraitExprBits.Value = Record[Idx++];
1491 SourceRange Range = ReadSourceRange(Record, Idx);
1492 E->Loc = Range.getBegin();
1493 E->RParenLoc = Range.getEnd();
1495 TypeSourceInfo **Args = E->getTypeSourceInfos();
1496 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1497 Args[I] = GetTypeSourceInfo(Record, Idx);
1500 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1502 E->ATT = (ArrayTypeTrait)Record[Idx++];
1503 E->Value = (unsigned int)Record[Idx++];
1504 SourceRange Range = ReadSourceRange(Record, Idx);
1505 E->Loc = Range.getBegin();
1506 E->RParen = Range.getEnd();
1507 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1510 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1512 E->ET = (ExpressionTrait)Record[Idx++];
1513 E->Value = (bool)Record[Idx++];
1514 SourceRange Range = ReadSourceRange(Record, Idx);
1515 E->QueriedExpression = Reader.ReadSubExpr();
1516 E->Loc = Range.getBegin();
1517 E->RParen = Range.getEnd();
1520 void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1522 E->Value = (bool)Record[Idx++];
1523 E->Range = ReadSourceRange(Record, Idx);
1524 E->Operand = Reader.ReadSubExpr();
1527 void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1529 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
1530 E->NumExpansions = Record[Idx++];
1531 E->Pattern = Reader.ReadSubExpr();
1534 void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1536 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1537 E->PackLoc = ReadSourceLocation(Record, Idx);
1538 E->RParenLoc = ReadSourceLocation(Record, Idx);
1539 E->Length = Record[Idx++];
1540 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
1543 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1544 SubstNonTypeTemplateParmExpr *E) {
1546 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
1547 E->NameLoc = ReadSourceLocation(Record, Idx);
1548 E->Replacement = Reader.ReadSubExpr();
1551 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1552 SubstNonTypeTemplateParmPackExpr *E) {
1554 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
1555 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1556 if (ArgPack.getKind() != TemplateArgument::Pack)
1559 E->Arguments = ArgPack.pack_begin();
1560 E->NumArguments = ArgPack.pack_size();
1561 E->NameLoc = ReadSourceLocation(Record, Idx);
1564 void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1566 E->NumParameters = Record[Idx++];
1567 E->ParamPack = ReadDeclAs<ParmVarDecl>(Record, Idx);
1568 E->NameLoc = ReadSourceLocation(Record, Idx);
1569 ParmVarDecl **Parms = reinterpret_cast<ParmVarDecl**>(E+1);
1570 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
1571 Parms[i] = ReadDeclAs<ParmVarDecl>(Record, Idx);
1574 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1576 E->State = Reader.ReadSubExpr();
1577 auto VD = ReadDeclAs<ValueDecl>(Record, Idx);
1578 unsigned ManglingNumber = Record[Idx++];
1579 E->setExtendingDecl(VD, ManglingNumber);
1582 void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1584 E->SourceExpr = Reader.ReadSubExpr();
1585 E->Loc = ReadSourceLocation(Record, Idx);
1588 //===----------------------------------------------------------------------===//
1589 // Microsoft Expressions and Statements
1590 //===----------------------------------------------------------------------===//
1591 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1593 E->IsArrow = (Record[Idx++] != 0);
1594 E->BaseExpr = Reader.ReadSubExpr();
1595 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1596 E->MemberLoc = ReadSourceLocation(Record, Idx);
1597 E->TheDecl = ReadDeclAs<MSPropertyDecl>(Record, Idx);
1600 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1602 E->setSourceRange(ReadSourceRange(Record, Idx));
1603 if (E->isTypeOperand()) { // __uuidof(ComType)
1604 E->setTypeOperandSourceInfo(
1605 GetTypeSourceInfo(Record, Idx));
1610 E->setExprOperand(Reader.ReadSubExpr());
1613 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1615 S->setLeaveLoc(ReadSourceLocation(Record, Idx));
1618 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1620 S->Loc = ReadSourceLocation(Record, Idx);
1621 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1622 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1625 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1627 S->Loc = ReadSourceLocation(Record, Idx);
1628 S->Block = Reader.ReadSubStmt();
1631 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1633 S->IsCXXTry = Record[Idx++];
1634 S->TryLoc = ReadSourceLocation(Record, Idx);
1635 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1636 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1639 //===----------------------------------------------------------------------===//
1640 // CUDA Expressions and Statements
1641 //===----------------------------------------------------------------------===//
1643 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1645 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1648 //===----------------------------------------------------------------------===//
1649 // OpenCL Expressions and Statements.
1650 //===----------------------------------------------------------------------===//
1651 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1653 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1654 E->RParenLoc = ReadSourceLocation(Record, Idx);
1655 E->SrcExpr = Reader.ReadSubExpr();
1658 //===----------------------------------------------------------------------===//
1660 //===----------------------------------------------------------------------===//
1663 class OMPClauseReader : public OMPClauseVisitor<OMPClauseReader> {
1664 ASTStmtReader *Reader;
1665 ASTContext &Context;
1666 const ASTReader::RecordData &Record;
1669 OMPClauseReader(ASTStmtReader *R, ASTContext &C,
1670 const ASTReader::RecordData &Record, unsigned &Idx)
1671 : Reader(R), Context(C), Record(Record), Idx(Idx) { }
1672 #define OPENMP_CLAUSE(Name, Class) \
1673 void Visit##Class(Class *S);
1674 #include "clang/Basic/OpenMPKinds.def"
1675 OMPClause *readClause();
1679 OMPClause *OMPClauseReader::readClause() {
1681 switch (Record[Idx++]) {
1683 C = new (Context) OMPIfClause();
1686 C = new (Context) OMPFinalClause();
1688 case OMPC_num_threads:
1689 C = new (Context) OMPNumThreadsClause();
1692 C = new (Context) OMPSafelenClause();
1695 C = new (Context) OMPCollapseClause();
1698 C = new (Context) OMPDefaultClause();
1700 case OMPC_proc_bind:
1701 C = new (Context) OMPProcBindClause();
1704 C = new (Context) OMPScheduleClause();
1707 C = new (Context) OMPOrderedClause();
1710 C = new (Context) OMPNowaitClause();
1713 C = new (Context) OMPUntiedClause();
1715 case OMPC_mergeable:
1716 C = new (Context) OMPMergeableClause();
1719 C = OMPPrivateClause::CreateEmpty(Context, Record[Idx++]);
1721 case OMPC_firstprivate:
1722 C = OMPFirstprivateClause::CreateEmpty(Context, Record[Idx++]);
1724 case OMPC_lastprivate:
1725 C = OMPLastprivateClause::CreateEmpty(Context, Record[Idx++]);
1728 C = OMPSharedClause::CreateEmpty(Context, Record[Idx++]);
1730 case OMPC_reduction:
1731 C = OMPReductionClause::CreateEmpty(Context, Record[Idx++]);
1734 C = OMPLinearClause::CreateEmpty(Context, Record[Idx++]);
1737 C = OMPAlignedClause::CreateEmpty(Context, Record[Idx++]);
1740 C = OMPCopyinClause::CreateEmpty(Context, Record[Idx++]);
1742 case OMPC_copyprivate:
1743 C = OMPCopyprivateClause::CreateEmpty(Context, Record[Idx++]);
1746 C = OMPFlushClause::CreateEmpty(Context, Record[Idx++]);
1750 C->setLocStart(Reader->ReadSourceLocation(Record, Idx));
1751 C->setLocEnd(Reader->ReadSourceLocation(Record, Idx));
1756 void OMPClauseReader::VisitOMPIfClause(OMPIfClause *C) {
1757 C->setCondition(Reader->Reader.ReadSubExpr());
1758 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1761 void OMPClauseReader::VisitOMPFinalClause(OMPFinalClause *C) {
1762 C->setCondition(Reader->Reader.ReadSubExpr());
1763 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1766 void OMPClauseReader::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {
1767 C->setNumThreads(Reader->Reader.ReadSubExpr());
1768 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1771 void OMPClauseReader::VisitOMPSafelenClause(OMPSafelenClause *C) {
1772 C->setSafelen(Reader->Reader.ReadSubExpr());
1773 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1776 void OMPClauseReader::VisitOMPCollapseClause(OMPCollapseClause *C) {
1777 C->setNumForLoops(Reader->Reader.ReadSubExpr());
1778 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1781 void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) {
1783 static_cast<OpenMPDefaultClauseKind>(Record[Idx++]));
1784 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1785 C->setDefaultKindKwLoc(Reader->ReadSourceLocation(Record, Idx));
1788 void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) {
1790 static_cast<OpenMPProcBindClauseKind>(Record[Idx++]));
1791 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1792 C->setProcBindKindKwLoc(Reader->ReadSourceLocation(Record, Idx));
1795 void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) {
1797 static_cast<OpenMPScheduleClauseKind>(Record[Idx++]));
1798 C->setChunkSize(Reader->Reader.ReadSubExpr());
1799 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1800 C->setScheduleKindLoc(Reader->ReadSourceLocation(Record, Idx));
1801 C->setCommaLoc(Reader->ReadSourceLocation(Record, Idx));
1804 void OMPClauseReader::VisitOMPOrderedClause(OMPOrderedClause *) {}
1806 void OMPClauseReader::VisitOMPNowaitClause(OMPNowaitClause *) {}
1808 void OMPClauseReader::VisitOMPUntiedClause(OMPUntiedClause *) {}
1810 void OMPClauseReader::VisitOMPMergeableClause(OMPMergeableClause *) {}
1812 void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
1813 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1814 unsigned NumVars = C->varlist_size();
1815 SmallVector<Expr *, 16> Vars;
1816 Vars.reserve(NumVars);
1817 for (unsigned i = 0; i != NumVars; ++i)
1818 Vars.push_back(Reader->Reader.ReadSubExpr());
1819 C->setVarRefs(Vars);
1822 void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) {
1823 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1824 unsigned NumVars = C->varlist_size();
1825 SmallVector<Expr *, 16> Vars;
1826 Vars.reserve(NumVars);
1827 for (unsigned i = 0; i != NumVars; ++i)
1828 Vars.push_back(Reader->Reader.ReadSubExpr());
1829 C->setVarRefs(Vars);
1832 void OMPClauseReader::VisitOMPLastprivateClause(OMPLastprivateClause *C) {
1833 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1834 unsigned NumVars = C->varlist_size();
1835 SmallVector<Expr *, 16> Vars;
1836 Vars.reserve(NumVars);
1837 for (unsigned i = 0; i != NumVars; ++i)
1838 Vars.push_back(Reader->Reader.ReadSubExpr());
1839 C->setVarRefs(Vars);
1842 void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) {
1843 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1844 unsigned NumVars = C->varlist_size();
1845 SmallVector<Expr *, 16> Vars;
1846 Vars.reserve(NumVars);
1847 for (unsigned i = 0; i != NumVars; ++i)
1848 Vars.push_back(Reader->Reader.ReadSubExpr());
1849 C->setVarRefs(Vars);
1852 void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
1853 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1854 C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
1855 NestedNameSpecifierLoc NNSL =
1856 Reader->Reader.ReadNestedNameSpecifierLoc(Reader->F, Record, Idx);
1857 DeclarationNameInfo DNI;
1858 Reader->ReadDeclarationNameInfo(DNI, Record, Idx);
1859 C->setQualifierLoc(NNSL);
1860 C->setNameInfo(DNI);
1862 unsigned NumVars = C->varlist_size();
1863 SmallVector<Expr *, 16> Vars;
1864 Vars.reserve(NumVars);
1865 for (unsigned i = 0; i != NumVars; ++i)
1866 Vars.push_back(Reader->Reader.ReadSubExpr());
1867 C->setVarRefs(Vars);
1870 void OMPClauseReader::VisitOMPLinearClause(OMPLinearClause *C) {
1871 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1872 C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
1873 unsigned NumVars = C->varlist_size();
1874 SmallVector<Expr *, 16> Vars;
1875 Vars.reserve(NumVars);
1876 for (unsigned i = 0; i != NumVars; ++i)
1877 Vars.push_back(Reader->Reader.ReadSubExpr());
1878 C->setVarRefs(Vars);
1879 C->setStep(Reader->Reader.ReadSubExpr());
1882 void OMPClauseReader::VisitOMPAlignedClause(OMPAlignedClause *C) {
1883 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1884 C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
1885 unsigned NumVars = C->varlist_size();
1886 SmallVector<Expr *, 16> Vars;
1887 Vars.reserve(NumVars);
1888 for (unsigned i = 0; i != NumVars; ++i)
1889 Vars.push_back(Reader->Reader.ReadSubExpr());
1890 C->setVarRefs(Vars);
1891 C->setAlignment(Reader->Reader.ReadSubExpr());
1894 void OMPClauseReader::VisitOMPCopyinClause(OMPCopyinClause *C) {
1895 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1896 unsigned NumVars = C->varlist_size();
1897 SmallVector<Expr *, 16> Vars;
1898 Vars.reserve(NumVars);
1899 for (unsigned i = 0; i != NumVars; ++i)
1900 Vars.push_back(Reader->Reader.ReadSubExpr());
1901 C->setVarRefs(Vars);
1904 void OMPClauseReader::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) {
1905 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1906 unsigned NumVars = C->varlist_size();
1907 SmallVector<Expr *, 16> Vars;
1908 Vars.reserve(NumVars);
1909 for (unsigned i = 0; i != NumVars; ++i)
1910 Vars.push_back(Reader->Reader.ReadSubExpr());
1911 C->setVarRefs(Vars);
1914 void OMPClauseReader::VisitOMPFlushClause(OMPFlushClause *C) {
1915 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1916 unsigned NumVars = C->varlist_size();
1917 SmallVector<Expr *, 16> Vars;
1918 Vars.reserve(NumVars);
1919 for (unsigned i = 0; i != NumVars; ++i)
1920 Vars.push_back(Reader->Reader.ReadSubExpr());
1921 C->setVarRefs(Vars);
1924 //===----------------------------------------------------------------------===//
1925 // OpenMP Directives.
1926 //===----------------------------------------------------------------------===//
1927 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
1928 E->setLocStart(ReadSourceLocation(Record, Idx));
1929 E->setLocEnd(ReadSourceLocation(Record, Idx));
1930 OMPClauseReader ClauseReader(this, Reader.getContext(), Record, Idx);
1931 SmallVector<OMPClause *, 5> Clauses;
1932 for (unsigned i = 0; i < E->getNumClauses(); ++i)
1933 Clauses.push_back(ClauseReader.readClause());
1934 E->setClauses(Clauses);
1935 if (E->hasAssociatedStmt())
1936 E->setAssociatedStmt(Reader.ReadSubStmt());
1939 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
1941 // The NumClauses field was read in ReadStmtFromStream.
1943 VisitOMPExecutableDirective(D);
1946 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
1948 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
1950 VisitOMPExecutableDirective(D);
1953 void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
1955 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
1957 VisitOMPExecutableDirective(D);
1960 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
1962 // The NumClauses field was read in ReadStmtFromStream.
1964 VisitOMPExecutableDirective(D);
1967 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
1969 VisitOMPExecutableDirective(D);
1972 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
1974 // The NumClauses field was read in ReadStmtFromStream.
1976 VisitOMPExecutableDirective(D);
1979 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
1981 VisitOMPExecutableDirective(D);
1984 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
1986 VisitOMPExecutableDirective(D);
1987 ReadDeclarationNameInfo(D->DirName, Record, Idx);
1990 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
1992 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
1994 VisitOMPExecutableDirective(D);
1997 void ASTStmtReader::VisitOMPParallelSectionsDirective(
1998 OMPParallelSectionsDirective *D) {
2000 // The NumClauses field was read in ReadStmtFromStream.
2002 VisitOMPExecutableDirective(D);
2005 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2007 // The NumClauses field was read in ReadStmtFromStream.
2009 VisitOMPExecutableDirective(D);
2012 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2014 VisitOMPExecutableDirective(D);
2017 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2019 VisitOMPExecutableDirective(D);
2022 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2024 VisitOMPExecutableDirective(D);
2027 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2029 // The NumClauses field was read in ReadStmtFromStream.
2031 VisitOMPExecutableDirective(D);
2034 //===----------------------------------------------------------------------===//
2035 // ASTReader Implementation
2036 //===----------------------------------------------------------------------===//
2038 Stmt *ASTReader::ReadStmt(ModuleFile &F) {
2039 switch (ReadingKind) {
2041 llvm_unreachable("should not call this when not reading anything");
2044 return ReadStmtFromStream(F);
2046 return ReadSubStmt();
2049 llvm_unreachable("ReadingKind not set ?");
2052 Expr *ASTReader::ReadExpr(ModuleFile &F) {
2053 return cast_or_null<Expr>(ReadStmt(F));
2056 Expr *ASTReader::ReadSubExpr() {
2057 return cast_or_null<Expr>(ReadSubStmt());
2060 // Within the bitstream, expressions are stored in Reverse Polish
2061 // Notation, with each of the subexpressions preceding the
2062 // expression they are stored in. Subexpressions are stored from last to first.
2063 // To evaluate expressions, we continue reading expressions and placing them on
2064 // the stack, with expressions having operands removing those operands from the
2065 // stack. Evaluation terminates when we see a STMT_STOP record, and
2066 // the single remaining expression on the stack is our result.
2067 Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
2069 ReadingKindTracker ReadingKind(Read_Stmt, *this);
2070 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
2072 // Map of offset to previously deserialized stmt. The offset points
2073 /// just after the stmt record.
2074 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
2077 unsigned PrevNumStmts = StmtStack.size();
2082 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
2083 Stmt::EmptyShell Empty;
2086 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
2088 switch (Entry.Kind) {
2089 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2090 case llvm::BitstreamEntry::Error:
2091 Error("malformed block record in AST file");
2093 case llvm::BitstreamEntry::EndBlock:
2095 case llvm::BitstreamEntry::Record:
2096 // The interesting case.
2103 bool Finished = false;
2104 bool IsStmtReference = false;
2105 switch ((StmtCode)Cursor.readRecord(Entry.ID, Record)) {
2111 IsStmtReference = true;
2112 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2113 "No stmt was recorded for this offset reference!");
2114 S = StmtEntries[Record[Idx++]];
2122 S = new (Context) NullStmt(Empty);
2126 S = new (Context) CompoundStmt(Empty);
2130 S = new (Context) CaseStmt(Empty);
2134 S = new (Context) DefaultStmt(Empty);
2138 S = new (Context) LabelStmt(Empty);
2141 case STMT_ATTRIBUTED:
2142 S = AttributedStmt::CreateEmpty(
2144 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
2148 S = new (Context) IfStmt(Empty);
2152 S = new (Context) SwitchStmt(Empty);
2156 S = new (Context) WhileStmt(Empty);
2160 S = new (Context) DoStmt(Empty);
2164 S = new (Context) ForStmt(Empty);
2168 S = new (Context) GotoStmt(Empty);
2171 case STMT_INDIRECT_GOTO:
2172 S = new (Context) IndirectGotoStmt(Empty);
2176 S = new (Context) ContinueStmt(Empty);
2180 S = new (Context) BreakStmt(Empty);
2184 S = new (Context) ReturnStmt(Empty);
2188 S = new (Context) DeclStmt(Empty);
2192 S = new (Context) GCCAsmStmt(Empty);
2196 S = new (Context) MSAsmStmt(Empty);
2200 S = CapturedStmt::CreateDeserialized(Context,
2201 Record[ASTStmtReader::NumStmtFields]);
2204 case EXPR_PREDEFINED:
2205 S = new (Context) PredefinedExpr(Empty);
2209 S = DeclRefExpr::CreateEmpty(
2211 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2212 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
2213 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
2214 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
2215 Record[ASTStmtReader::NumExprFields + 5] : 0);
2218 case EXPR_INTEGER_LITERAL:
2219 S = IntegerLiteral::Create(Context, Empty);
2222 case EXPR_FLOATING_LITERAL:
2223 S = FloatingLiteral::Create(Context, Empty);
2226 case EXPR_IMAGINARY_LITERAL:
2227 S = new (Context) ImaginaryLiteral(Empty);
2230 case EXPR_STRING_LITERAL:
2231 S = StringLiteral::CreateEmpty(Context,
2232 Record[ASTStmtReader::NumExprFields + 1]);
2235 case EXPR_CHARACTER_LITERAL:
2236 S = new (Context) CharacterLiteral(Empty);
2240 S = new (Context) ParenExpr(Empty);
2243 case EXPR_PAREN_LIST:
2244 S = new (Context) ParenListExpr(Empty);
2247 case EXPR_UNARY_OPERATOR:
2248 S = new (Context) UnaryOperator(Empty);
2252 S = OffsetOfExpr::CreateEmpty(Context,
2253 Record[ASTStmtReader::NumExprFields],
2254 Record[ASTStmtReader::NumExprFields + 1]);
2257 case EXPR_SIZEOF_ALIGN_OF:
2258 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
2261 case EXPR_ARRAY_SUBSCRIPT:
2262 S = new (Context) ArraySubscriptExpr(Empty);
2266 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
2270 // We load everything here and fully initialize it at creation.
2271 // That way we can use MemberExpr::Create and don't have to duplicate its
2272 // logic with a MemberExpr::CreateEmpty.
2275 NestedNameSpecifierLoc QualifierLoc;
2276 if (Record[Idx++]) { // HasQualifier.
2277 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
2280 SourceLocation TemplateKWLoc;
2281 TemplateArgumentListInfo ArgInfo;
2282 bool HasTemplateKWAndArgsInfo = Record[Idx++];
2283 if (HasTemplateKWAndArgsInfo) {
2284 TemplateKWLoc = ReadSourceLocation(F, Record, Idx);
2285 unsigned NumTemplateArgs = Record[Idx++];
2286 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
2287 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
2288 for (unsigned i = 0; i != NumTemplateArgs; ++i)
2289 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
2292 bool HadMultipleCandidates = Record[Idx++];
2294 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
2295 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
2296 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
2298 QualType T = readType(F, Record, Idx);
2299 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
2300 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
2301 Expr *Base = ReadSubExpr();
2302 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
2303 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
2304 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
2305 bool IsArrow = Record[Idx++];
2307 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
2308 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
2309 HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr,
2311 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
2312 MemberD->getDeclName(), Record, Idx);
2313 if (HadMultipleCandidates)
2314 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
2318 case EXPR_BINARY_OPERATOR:
2319 S = new (Context) BinaryOperator(Empty);
2322 case EXPR_COMPOUND_ASSIGN_OPERATOR:
2323 S = new (Context) CompoundAssignOperator(Empty);
2326 case EXPR_CONDITIONAL_OPERATOR:
2327 S = new (Context) ConditionalOperator(Empty);
2330 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2331 S = new (Context) BinaryConditionalOperator(Empty);
2334 case EXPR_IMPLICIT_CAST:
2335 S = ImplicitCastExpr::CreateEmpty(Context,
2336 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2339 case EXPR_CSTYLE_CAST:
2340 S = CStyleCastExpr::CreateEmpty(Context,
2341 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2344 case EXPR_COMPOUND_LITERAL:
2345 S = new (Context) CompoundLiteralExpr(Empty);
2348 case EXPR_EXT_VECTOR_ELEMENT:
2349 S = new (Context) ExtVectorElementExpr(Empty);
2352 case EXPR_INIT_LIST:
2353 S = new (Context) InitListExpr(Empty);
2356 case EXPR_DESIGNATED_INIT:
2357 S = DesignatedInitExpr::CreateEmpty(Context,
2358 Record[ASTStmtReader::NumExprFields] - 1);
2362 case EXPR_IMPLICIT_VALUE_INIT:
2363 S = new (Context) ImplicitValueInitExpr(Empty);
2367 S = new (Context) VAArgExpr(Empty);
2370 case EXPR_ADDR_LABEL:
2371 S = new (Context) AddrLabelExpr(Empty);
2375 S = new (Context) StmtExpr(Empty);
2379 S = new (Context) ChooseExpr(Empty);
2383 S = new (Context) GNUNullExpr(Empty);
2386 case EXPR_SHUFFLE_VECTOR:
2387 S = new (Context) ShuffleVectorExpr(Empty);
2390 case EXPR_CONVERT_VECTOR:
2391 S = new (Context) ConvertVectorExpr(Empty);
2395 S = new (Context) BlockExpr(Empty);
2398 case EXPR_GENERIC_SELECTION:
2399 S = new (Context) GenericSelectionExpr(Empty);
2402 case EXPR_OBJC_STRING_LITERAL:
2403 S = new (Context) ObjCStringLiteral(Empty);
2405 case EXPR_OBJC_BOXED_EXPRESSION:
2406 S = new (Context) ObjCBoxedExpr(Empty);
2408 case EXPR_OBJC_ARRAY_LITERAL:
2409 S = ObjCArrayLiteral::CreateEmpty(Context,
2410 Record[ASTStmtReader::NumExprFields]);
2412 case EXPR_OBJC_DICTIONARY_LITERAL:
2413 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2414 Record[ASTStmtReader::NumExprFields],
2415 Record[ASTStmtReader::NumExprFields + 1]);
2417 case EXPR_OBJC_ENCODE:
2418 S = new (Context) ObjCEncodeExpr(Empty);
2420 case EXPR_OBJC_SELECTOR_EXPR:
2421 S = new (Context) ObjCSelectorExpr(Empty);
2423 case EXPR_OBJC_PROTOCOL_EXPR:
2424 S = new (Context) ObjCProtocolExpr(Empty);
2426 case EXPR_OBJC_IVAR_REF_EXPR:
2427 S = new (Context) ObjCIvarRefExpr(Empty);
2429 case EXPR_OBJC_PROPERTY_REF_EXPR:
2430 S = new (Context) ObjCPropertyRefExpr(Empty);
2432 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2433 S = new (Context) ObjCSubscriptRefExpr(Empty);
2435 case EXPR_OBJC_KVC_REF_EXPR:
2436 llvm_unreachable("mismatching AST file");
2437 case EXPR_OBJC_MESSAGE_EXPR:
2438 S = ObjCMessageExpr::CreateEmpty(Context,
2439 Record[ASTStmtReader::NumExprFields],
2440 Record[ASTStmtReader::NumExprFields + 1]);
2443 S = new (Context) ObjCIsaExpr(Empty);
2445 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2446 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2448 case EXPR_OBJC_BRIDGED_CAST:
2449 S = new (Context) ObjCBridgedCastExpr(Empty);
2451 case STMT_OBJC_FOR_COLLECTION:
2452 S = new (Context) ObjCForCollectionStmt(Empty);
2454 case STMT_OBJC_CATCH:
2455 S = new (Context) ObjCAtCatchStmt(Empty);
2457 case STMT_OBJC_FINALLY:
2458 S = new (Context) ObjCAtFinallyStmt(Empty);
2460 case STMT_OBJC_AT_TRY:
2461 S = ObjCAtTryStmt::CreateEmpty(Context,
2462 Record[ASTStmtReader::NumStmtFields],
2463 Record[ASTStmtReader::NumStmtFields + 1]);
2465 case STMT_OBJC_AT_SYNCHRONIZED:
2466 S = new (Context) ObjCAtSynchronizedStmt(Empty);
2468 case STMT_OBJC_AT_THROW:
2469 S = new (Context) ObjCAtThrowStmt(Empty);
2471 case STMT_OBJC_AUTORELEASE_POOL:
2472 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2474 case EXPR_OBJC_BOOL_LITERAL:
2475 S = new (Context) ObjCBoolLiteralExpr(Empty);
2477 case STMT_SEH_LEAVE:
2478 S = new (Context) SEHLeaveStmt(Empty);
2480 case STMT_SEH_EXCEPT:
2481 S = new (Context) SEHExceptStmt(Empty);
2483 case STMT_SEH_FINALLY:
2484 S = new (Context) SEHFinallyStmt(Empty);
2487 S = new (Context) SEHTryStmt(Empty);
2489 case STMT_CXX_CATCH:
2490 S = new (Context) CXXCatchStmt(Empty);
2494 S = CXXTryStmt::Create(Context, Empty,
2495 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
2498 case STMT_CXX_FOR_RANGE:
2499 S = new (Context) CXXForRangeStmt(Empty);
2502 case STMT_MS_DEPENDENT_EXISTS:
2503 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2504 NestedNameSpecifierLoc(),
2505 DeclarationNameInfo(),
2509 case STMT_OMP_PARALLEL_DIRECTIVE:
2511 OMPParallelDirective::CreateEmpty(Context,
2512 Record[ASTStmtReader::NumStmtFields],
2516 case STMT_OMP_SIMD_DIRECTIVE: {
2517 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2518 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2519 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
2520 CollapsedNum, Empty);
2524 case STMT_OMP_FOR_DIRECTIVE: {
2525 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2526 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2527 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2532 case STMT_OMP_SECTIONS_DIRECTIVE:
2533 S = OMPSectionsDirective::CreateEmpty(
2534 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2537 case STMT_OMP_SECTION_DIRECTIVE:
2538 S = OMPSectionDirective::CreateEmpty(Context, Empty);
2541 case STMT_OMP_SINGLE_DIRECTIVE:
2542 S = OMPSingleDirective::CreateEmpty(
2543 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2546 case STMT_OMP_MASTER_DIRECTIVE:
2547 S = OMPMasterDirective::CreateEmpty(Context, Empty);
2550 case STMT_OMP_CRITICAL_DIRECTIVE:
2551 S = OMPCriticalDirective::CreateEmpty(Context, Empty);
2554 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
2555 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2556 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2557 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
2558 CollapsedNum, Empty);
2562 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
2563 S = OMPParallelSectionsDirective::CreateEmpty(
2564 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2567 case STMT_OMP_TASK_DIRECTIVE:
2568 S = OMPTaskDirective::CreateEmpty(
2569 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2572 case STMT_OMP_TASKYIELD_DIRECTIVE:
2573 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
2576 case STMT_OMP_BARRIER_DIRECTIVE:
2577 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
2580 case STMT_OMP_TASKWAIT_DIRECTIVE:
2581 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
2584 case STMT_OMP_FLUSH_DIRECTIVE:
2585 S = OMPFlushDirective::CreateEmpty(
2586 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2589 case EXPR_CXX_OPERATOR_CALL:
2590 S = new (Context) CXXOperatorCallExpr(Context, Empty);
2593 case EXPR_CXX_MEMBER_CALL:
2594 S = new (Context) CXXMemberCallExpr(Context, Empty);
2597 case EXPR_CXX_CONSTRUCT:
2598 S = new (Context) CXXConstructExpr(Empty);
2601 case EXPR_CXX_TEMPORARY_OBJECT:
2602 S = new (Context) CXXTemporaryObjectExpr(Empty);
2605 case EXPR_CXX_STATIC_CAST:
2606 S = CXXStaticCastExpr::CreateEmpty(Context,
2607 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2610 case EXPR_CXX_DYNAMIC_CAST:
2611 S = CXXDynamicCastExpr::CreateEmpty(Context,
2612 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2615 case EXPR_CXX_REINTERPRET_CAST:
2616 S = CXXReinterpretCastExpr::CreateEmpty(Context,
2617 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2620 case EXPR_CXX_CONST_CAST:
2621 S = CXXConstCastExpr::CreateEmpty(Context);
2624 case EXPR_CXX_FUNCTIONAL_CAST:
2625 S = CXXFunctionalCastExpr::CreateEmpty(Context,
2626 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2629 case EXPR_USER_DEFINED_LITERAL:
2630 S = new (Context) UserDefinedLiteral(Context, Empty);
2633 case EXPR_CXX_STD_INITIALIZER_LIST:
2634 S = new (Context) CXXStdInitializerListExpr(Empty);
2637 case EXPR_CXX_BOOL_LITERAL:
2638 S = new (Context) CXXBoolLiteralExpr(Empty);
2641 case EXPR_CXX_NULL_PTR_LITERAL:
2642 S = new (Context) CXXNullPtrLiteralExpr(Empty);
2644 case EXPR_CXX_TYPEID_EXPR:
2645 S = new (Context) CXXTypeidExpr(Empty, true);
2647 case EXPR_CXX_TYPEID_TYPE:
2648 S = new (Context) CXXTypeidExpr(Empty, false);
2650 case EXPR_CXX_UUIDOF_EXPR:
2651 S = new (Context) CXXUuidofExpr(Empty, true);
2653 case EXPR_CXX_PROPERTY_REF_EXPR:
2654 S = new (Context) MSPropertyRefExpr(Empty);
2656 case EXPR_CXX_UUIDOF_TYPE:
2657 S = new (Context) CXXUuidofExpr(Empty, false);
2660 S = new (Context) CXXThisExpr(Empty);
2662 case EXPR_CXX_THROW:
2663 S = new (Context) CXXThrowExpr(Empty);
2665 case EXPR_CXX_DEFAULT_ARG: {
2666 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
2667 if (HasOtherExprStored) {
2668 Expr *SubExpr = ReadSubExpr();
2669 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), nullptr,
2672 S = new (Context) CXXDefaultArgExpr(Empty);
2675 case EXPR_CXX_DEFAULT_INIT:
2676 S = new (Context) CXXDefaultInitExpr(Empty);
2678 case EXPR_CXX_BIND_TEMPORARY:
2679 S = new (Context) CXXBindTemporaryExpr(Empty);
2682 case EXPR_CXX_SCALAR_VALUE_INIT:
2683 S = new (Context) CXXScalarValueInitExpr(Empty);
2686 S = new (Context) CXXNewExpr(Empty);
2688 case EXPR_CXX_DELETE:
2689 S = new (Context) CXXDeleteExpr(Empty);
2691 case EXPR_CXX_PSEUDO_DESTRUCTOR:
2692 S = new (Context) CXXPseudoDestructorExpr(Empty);
2695 case EXPR_EXPR_WITH_CLEANUPS:
2696 S = ExprWithCleanups::Create(Context, Empty,
2697 Record[ASTStmtReader::NumExprFields]);
2700 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
2701 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
2702 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
2703 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2704 ? Record[ASTStmtReader::NumExprFields + 1]
2708 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
2709 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
2710 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
2711 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2712 ? Record[ASTStmtReader::NumExprFields + 1]
2716 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
2717 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
2718 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
2721 case EXPR_CXX_UNRESOLVED_MEMBER:
2722 S = UnresolvedMemberExpr::CreateEmpty(Context,
2723 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
2724 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2725 ? Record[ASTStmtReader::NumExprFields + 1]
2729 case EXPR_CXX_UNRESOLVED_LOOKUP:
2730 S = UnresolvedLookupExpr::CreateEmpty(Context,
2731 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
2732 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2733 ? Record[ASTStmtReader::NumExprFields + 1]
2737 case EXPR_TYPE_TRAIT:
2738 S = TypeTraitExpr::CreateDeserialized(Context,
2739 Record[ASTStmtReader::NumExprFields]);
2742 case EXPR_ARRAY_TYPE_TRAIT:
2743 S = new (Context) ArrayTypeTraitExpr(Empty);
2746 case EXPR_CXX_EXPRESSION_TRAIT:
2747 S = new (Context) ExpressionTraitExpr(Empty);
2750 case EXPR_CXX_NOEXCEPT:
2751 S = new (Context) CXXNoexceptExpr(Empty);
2754 case EXPR_PACK_EXPANSION:
2755 S = new (Context) PackExpansionExpr(Empty);
2758 case EXPR_SIZEOF_PACK:
2759 S = new (Context) SizeOfPackExpr(Empty);
2762 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2763 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2766 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2767 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2770 case EXPR_FUNCTION_PARM_PACK:
2771 S = FunctionParmPackExpr::CreateEmpty(Context,
2772 Record[ASTStmtReader::NumExprFields]);
2775 case EXPR_MATERIALIZE_TEMPORARY:
2776 S = new (Context) MaterializeTemporaryExpr(Empty);
2779 case EXPR_OPAQUE_VALUE:
2780 S = new (Context) OpaqueValueExpr(Empty);
2783 case EXPR_CUDA_KERNEL_CALL:
2784 S = new (Context) CUDAKernelCallExpr(Context, Empty);
2788 S = new (Context) AsTypeExpr(Empty);
2791 case EXPR_PSEUDO_OBJECT: {
2792 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
2793 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
2798 S = new (Context) AtomicExpr(Empty);
2802 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
2803 unsigned NumArrayIndexVars = Record[ASTStmtReader::NumExprFields + 1];
2804 S = LambdaExpr::CreateDeserialized(Context, NumCaptures,
2810 // We hit a STMT_STOP, so we're done with this expression.
2814 ++NumStatementsRead;
2816 if (S && !IsStmtReference) {
2818 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2822 assert(Idx == Record.size() && "Invalid deserialization of statement");
2823 StmtStack.push_back(S);
2826 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
2827 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
2828 return StmtStack.pop_back_val();