1 //===- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------------------===//
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 // ASTReader::ReadStmt method.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "clang/Serialization/ASTReader.h"
16 #include "clang/AST/ASTContext.h"
17 #include "clang/AST/AttrIterator.h"
18 #include "clang/AST/Decl.h"
19 #include "clang/AST/DeclAccessPair.h"
20 #include "clang/AST/DeclCXX.h"
21 #include "clang/AST/DeclGroup.h"
22 #include "clang/AST/DeclObjC.h"
23 #include "clang/AST/DeclTemplate.h"
24 #include "clang/AST/DeclarationName.h"
25 #include "clang/AST/Expr.h"
26 #include "clang/AST/ExprCXX.h"
27 #include "clang/AST/ExprObjC.h"
28 #include "clang/AST/ExprOpenMP.h"
29 #include "clang/AST/NestedNameSpecifier.h"
30 #include "clang/AST/OpenMPClause.h"
31 #include "clang/AST/OperationKinds.h"
32 #include "clang/AST/Stmt.h"
33 #include "clang/AST/StmtCXX.h"
34 #include "clang/AST/StmtObjC.h"
35 #include "clang/AST/StmtOpenMP.h"
36 #include "clang/AST/StmtVisitor.h"
37 #include "clang/AST/TemplateBase.h"
38 #include "clang/AST/Type.h"
39 #include "clang/AST/UnresolvedSet.h"
40 #include "clang/Basic/CapturedStmt.h"
41 #include "clang/Basic/ExpressionTraits.h"
42 #include "clang/Basic/LLVM.h"
43 #include "clang/Basic/Lambda.h"
44 #include "clang/Basic/LangOptions.h"
45 #include "clang/Basic/OpenMPKinds.h"
46 #include "clang/Basic/OperatorKinds.h"
47 #include "clang/Basic/SourceLocation.h"
48 #include "clang/Basic/Specifiers.h"
49 #include "clang/Basic/TypeTraits.h"
50 #include "clang/Lex/Token.h"
51 #include "clang/Serialization/ASTBitCodes.h"
52 #include "llvm/ADT/DenseMap.h"
53 #include "llvm/ADT/SmallString.h"
54 #include "llvm/ADT/SmallVector.h"
55 #include "llvm/ADT/StringRef.h"
56 #include "llvm/Bitcode/BitstreamReader.h"
57 #include "llvm/Support/Casting.h"
58 #include "llvm/Support/ErrorHandling.h"
59 #include <algorithm>
60 #include <cassert>
61 #include <cstdint>
62 #include <string>
63 
64 using namespace clang;
65 using namespace serialization;
66 
67 namespace clang {
68 
69   class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
70     friend class OMPClauseReader;
71 
72     ASTRecordReader &Record;
73     llvm::BitstreamCursor &DeclsCursor;
74 
75     SourceLocation ReadSourceLocation() {
76       return Record.readSourceLocation();
77     }
78 
79     SourceRange ReadSourceRange() {
80       return Record.readSourceRange();
81     }
82 
83     std::string ReadString() {
84       return Record.readString();
85     }
86 
87     TypeSourceInfo *GetTypeSourceInfo() {
88       return Record.getTypeSourceInfo();
89     }
90 
91     Decl *ReadDecl() {
92       return Record.readDecl();
93     }
94 
95     template<typename T>
96     T *ReadDeclAs() {
97       return Record.readDeclAs<T>();
98     }
99 
100     void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc,
101                                 DeclarationName Name) {
102       Record.readDeclarationNameLoc(DNLoc, Name);
103     }
104 
105     void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo) {
106       Record.readDeclarationNameInfo(NameInfo);
107     }
108 
109   public:
110     ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
111         : Record(Record), DeclsCursor(Cursor) {}
112 
113     /// The number of record fields required for the Stmt class
114     /// itself.
115     static const unsigned NumStmtFields = 0;
116 
117     /// The number of record fields required for the Expr class
118     /// itself.
119     static const unsigned NumExprFields = NumStmtFields + 7;
120 
121     /// Read and initialize a ExplicitTemplateArgumentList structure.
122     void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
123                                    TemplateArgumentLoc *ArgsLocArray,
124                                    unsigned NumTemplateArgs);
125 
126     /// Read and initialize a ExplicitTemplateArgumentList structure.
127     void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
128                                           unsigned NumTemplateArgs);
129 
130     void VisitStmt(Stmt *S);
131 #define STMT(Type, Base) \
132     void Visit##Type(Type *);
133 #include "clang/AST/StmtNodes.inc"
134   };
135 
136 } // namespace clang
137 
138 void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
139                                               TemplateArgumentLoc *ArgsLocArray,
140                                               unsigned NumTemplateArgs) {
141   SourceLocation TemplateKWLoc = ReadSourceLocation();
142   TemplateArgumentListInfo ArgInfo;
143   ArgInfo.setLAngleLoc(ReadSourceLocation());
144   ArgInfo.setRAngleLoc(ReadSourceLocation());
145   for (unsigned i = 0; i != NumTemplateArgs; ++i)
146     ArgInfo.addArgument(Record.readTemplateArgumentLoc());
147   Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
148 }
149 
150 void ASTStmtReader::VisitStmt(Stmt *S) {
151   assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
152 }
153 
154 void ASTStmtReader::VisitNullStmt(NullStmt *S) {
155   VisitStmt(S);
156   S->setSemiLoc(ReadSourceLocation());
157   S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
158 }
159 
160 void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
161   VisitStmt(S);
162   SmallVector<Stmt *, 16> Stmts;
163   unsigned NumStmts = Record.readInt();
164   while (NumStmts--)
165     Stmts.push_back(Record.readSubStmt());
166   S->setStmts(Stmts);
167   S->CompoundStmtBits.LBraceLoc = ReadSourceLocation();
168   S->RBraceLoc = ReadSourceLocation();
169 }
170 
171 void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
172   VisitStmt(S);
173   Record.recordSwitchCaseID(S, Record.readInt());
174   S->setKeywordLoc(ReadSourceLocation());
175   S->setColonLoc(ReadSourceLocation());
176 }
177 
178 void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
179   VisitSwitchCase(S);
180   bool CaseStmtIsGNURange = Record.readInt();
181   S->setLHS(Record.readSubExpr());
182   S->setSubStmt(Record.readSubStmt());
183   if (CaseStmtIsGNURange) {
184     S->setRHS(Record.readSubExpr());
185     S->setEllipsisLoc(ReadSourceLocation());
186   }
187 }
188 
189 void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
190   VisitSwitchCase(S);
191   S->setSubStmt(Record.readSubStmt());
192 }
193 
194 void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
195   VisitStmt(S);
196   auto *LD = ReadDeclAs<LabelDecl>();
197   LD->setStmt(S);
198   S->setDecl(LD);
199   S->setSubStmt(Record.readSubStmt());
200   S->setIdentLoc(ReadSourceLocation());
201 }
202 
203 void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
204   VisitStmt(S);
205   // NumAttrs in AttributedStmt is set when creating an empty
206   // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
207   // to allocate the right amount of space for the trailing Attr *.
208   uint64_t NumAttrs = Record.readInt();
209   AttrVec Attrs;
210   Record.readAttributes(Attrs);
211   (void)NumAttrs;
212   assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
213   assert(NumAttrs == Attrs.size());
214   std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
215   S->SubStmt = Record.readSubStmt();
216   S->AttributedStmtBits.AttrLoc = ReadSourceLocation();
217 }
218 
219 void ASTStmtReader::VisitIfStmt(IfStmt *S) {
220   VisitStmt(S);
221 
222   S->setConstexpr(Record.readInt());
223   bool HasElse = Record.readInt();
224   bool HasVar = Record.readInt();
225   bool HasInit = Record.readInt();
226 
227   S->setCond(Record.readSubExpr());
228   S->setThen(Record.readSubStmt());
229   if (HasElse)
230     S->setElse(Record.readSubStmt());
231   if (HasVar)
232     S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
233   if (HasInit)
234     S->setInit(Record.readSubStmt());
235 
236   S->setIfLoc(ReadSourceLocation());
237   if (HasElse)
238     S->setElseLoc(ReadSourceLocation());
239 }
240 
241 void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
242   VisitStmt(S);
243 
244   bool HasInit = Record.readInt();
245   bool HasVar = Record.readInt();
246   bool AllEnumCasesCovered = Record.readInt();
247   if (AllEnumCasesCovered)
248     S->setAllEnumCasesCovered();
249 
250   S->setCond(Record.readSubExpr());
251   S->setBody(Record.readSubStmt());
252   if (HasInit)
253     S->setInit(Record.readSubStmt());
254   if (HasVar)
255     S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
256 
257   S->setSwitchLoc(ReadSourceLocation());
258 
259   SwitchCase *PrevSC = nullptr;
260   for (auto E = Record.size(); Record.getIdx() != E; ) {
261     SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
262     if (PrevSC)
263       PrevSC->setNextSwitchCase(SC);
264     else
265       S->setSwitchCaseList(SC);
266 
267     PrevSC = SC;
268   }
269 }
270 
271 void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
272   VisitStmt(S);
273 
274   bool HasVar = Record.readInt();
275 
276   S->setCond(Record.readSubExpr());
277   S->setBody(Record.readSubStmt());
278   if (HasVar)
279     S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
280 
281   S->setWhileLoc(ReadSourceLocation());
282 }
283 
284 void ASTStmtReader::VisitDoStmt(DoStmt *S) {
285   VisitStmt(S);
286   S->setCond(Record.readSubExpr());
287   S->setBody(Record.readSubStmt());
288   S->setDoLoc(ReadSourceLocation());
289   S->setWhileLoc(ReadSourceLocation());
290   S->setRParenLoc(ReadSourceLocation());
291 }
292 
293 void ASTStmtReader::VisitForStmt(ForStmt *S) {
294   VisitStmt(S);
295   S->setInit(Record.readSubStmt());
296   S->setCond(Record.readSubExpr());
297   S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
298   S->setInc(Record.readSubExpr());
299   S->setBody(Record.readSubStmt());
300   S->setForLoc(ReadSourceLocation());
301   S->setLParenLoc(ReadSourceLocation());
302   S->setRParenLoc(ReadSourceLocation());
303 }
304 
305 void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
306   VisitStmt(S);
307   S->setLabel(ReadDeclAs<LabelDecl>());
308   S->setGotoLoc(ReadSourceLocation());
309   S->setLabelLoc(ReadSourceLocation());
310 }
311 
312 void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
313   VisitStmt(S);
314   S->setGotoLoc(ReadSourceLocation());
315   S->setStarLoc(ReadSourceLocation());
316   S->setTarget(Record.readSubExpr());
317 }
318 
319 void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
320   VisitStmt(S);
321   S->setContinueLoc(ReadSourceLocation());
322 }
323 
324 void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
325   VisitStmt(S);
326   S->setBreakLoc(ReadSourceLocation());
327 }
328 
329 void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
330   VisitStmt(S);
331 
332   bool HasNRVOCandidate = Record.readInt();
333 
334   S->setRetValue(Record.readSubExpr());
335   if (HasNRVOCandidate)
336     S->setNRVOCandidate(ReadDeclAs<VarDecl>());
337 
338   S->setReturnLoc(ReadSourceLocation());
339 }
340 
341 void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
342   VisitStmt(S);
343   S->setStartLoc(ReadSourceLocation());
344   S->setEndLoc(ReadSourceLocation());
345 
346   if (Record.size() - Record.getIdx() == 1) {
347     // Single declaration
348     S->setDeclGroup(DeclGroupRef(ReadDecl()));
349   } else {
350     SmallVector<Decl *, 16> Decls;
351     int N = Record.size() - Record.getIdx();
352     Decls.reserve(N);
353     for (int I = 0; I < N; ++I)
354       Decls.push_back(ReadDecl());
355     S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
356                                                    Decls.data(),
357                                                    Decls.size())));
358   }
359 }
360 
361 void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
362   VisitStmt(S);
363   S->NumOutputs = Record.readInt();
364   S->NumInputs = Record.readInt();
365   S->NumClobbers = Record.readInt();
366   S->setAsmLoc(ReadSourceLocation());
367   S->setVolatile(Record.readInt());
368   S->setSimple(Record.readInt());
369 }
370 
371 void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
372   VisitAsmStmt(S);
373   S->setRParenLoc(ReadSourceLocation());
374   S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
375 
376   unsigned NumOutputs = S->getNumOutputs();
377   unsigned NumInputs = S->getNumInputs();
378   unsigned NumClobbers = S->getNumClobbers();
379 
380   // Outputs and inputs
381   SmallVector<IdentifierInfo *, 16> Names;
382   SmallVector<StringLiteral*, 16> Constraints;
383   SmallVector<Stmt*, 16> Exprs;
384   for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
385     Names.push_back(Record.getIdentifierInfo());
386     Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
387     Exprs.push_back(Record.readSubStmt());
388   }
389 
390   // Constraints
391   SmallVector<StringLiteral*, 16> Clobbers;
392   for (unsigned I = 0; I != NumClobbers; ++I)
393     Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
394 
395   S->setOutputsAndInputsAndClobbers(Record.getContext(),
396                                     Names.data(), Constraints.data(),
397                                     Exprs.data(), NumOutputs, NumInputs,
398                                     Clobbers.data(), NumClobbers);
399 }
400 
401 void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
402   VisitAsmStmt(S);
403   S->LBraceLoc = ReadSourceLocation();
404   S->EndLoc = ReadSourceLocation();
405   S->NumAsmToks = Record.readInt();
406   std::string AsmStr = ReadString();
407 
408   // Read the tokens.
409   SmallVector<Token, 16> AsmToks;
410   AsmToks.reserve(S->NumAsmToks);
411   for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
412     AsmToks.push_back(Record.readToken());
413   }
414 
415   // The calls to reserve() for the FooData vectors are mandatory to
416   // prevent dead StringRefs in the Foo vectors.
417 
418   // Read the clobbers.
419   SmallVector<std::string, 16> ClobbersData;
420   SmallVector<StringRef, 16> Clobbers;
421   ClobbersData.reserve(S->NumClobbers);
422   Clobbers.reserve(S->NumClobbers);
423   for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
424     ClobbersData.push_back(ReadString());
425     Clobbers.push_back(ClobbersData.back());
426   }
427 
428   // Read the operands.
429   unsigned NumOperands = S->NumOutputs + S->NumInputs;
430   SmallVector<Expr*, 16> Exprs;
431   SmallVector<std::string, 16> ConstraintsData;
432   SmallVector<StringRef, 16> Constraints;
433   Exprs.reserve(NumOperands);
434   ConstraintsData.reserve(NumOperands);
435   Constraints.reserve(NumOperands);
436   for (unsigned i = 0; i != NumOperands; ++i) {
437     Exprs.push_back(cast<Expr>(Record.readSubStmt()));
438     ConstraintsData.push_back(ReadString());
439     Constraints.push_back(ConstraintsData.back());
440   }
441 
442   S->initialize(Record.getContext(), AsmStr, AsmToks,
443                 Constraints, Exprs, Clobbers);
444 }
445 
446 void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
447   VisitStmt(S);
448   assert(Record.peekInt() == S->NumParams);
449   Record.skipInts(1);
450   auto *StoredStmts = S->getStoredStmts();
451   for (unsigned i = 0;
452        i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
453     StoredStmts[i] = Record.readSubStmt();
454 }
455 
456 void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
457   VisitStmt(S);
458   S->CoreturnLoc = Record.readSourceLocation();
459   for (auto &SubStmt: S->SubStmts)
460     SubStmt = Record.readSubStmt();
461   S->IsImplicit = Record.readInt() != 0;
462 }
463 
464 void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
465   VisitExpr(E);
466   E->KeywordLoc = ReadSourceLocation();
467   for (auto &SubExpr: E->SubExprs)
468     SubExpr = Record.readSubStmt();
469   E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
470   E->setIsImplicit(Record.readInt() != 0);
471 }
472 
473 void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
474   VisitExpr(E);
475   E->KeywordLoc = ReadSourceLocation();
476   for (auto &SubExpr: E->SubExprs)
477     SubExpr = Record.readSubStmt();
478   E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
479 }
480 
481 void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
482   VisitExpr(E);
483   E->KeywordLoc = ReadSourceLocation();
484   for (auto &SubExpr: E->SubExprs)
485     SubExpr = Record.readSubStmt();
486 }
487 
488 void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
489   VisitStmt(S);
490   Record.skipInts(1);
491   S->setCapturedDecl(ReadDeclAs<CapturedDecl>());
492   S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
493   S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>());
494 
495   // Capture inits
496   for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
497                                            E = S->capture_init_end();
498        I != E; ++I)
499     *I = Record.readSubExpr();
500 
501   // Body
502   S->setCapturedStmt(Record.readSubStmt());
503   S->getCapturedDecl()->setBody(S->getCapturedStmt());
504 
505   // Captures
506   for (auto &I : S->captures()) {
507     I.VarAndKind.setPointer(ReadDeclAs<VarDecl>());
508     I.VarAndKind.setInt(
509         static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
510     I.Loc = ReadSourceLocation();
511   }
512 }
513 
514 void ASTStmtReader::VisitExpr(Expr *E) {
515   VisitStmt(E);
516   E->setType(Record.readType());
517   E->setTypeDependent(Record.readInt());
518   E->setValueDependent(Record.readInt());
519   E->setInstantiationDependent(Record.readInt());
520   E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
521   E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
522   E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
523   assert(Record.getIdx() == NumExprFields &&
524          "Incorrect expression field count");
525 }
526 
527 void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
528   VisitExpr(E);
529   E->setSubExpr(Record.readSubExpr());
530 }
531 
532 void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
533   VisitExpr(E);
534   bool HasFunctionName = Record.readInt();
535   E->PredefinedExprBits.HasFunctionName = HasFunctionName;
536   E->PredefinedExprBits.Kind = Record.readInt();
537   E->setLocation(ReadSourceLocation());
538   if (HasFunctionName)
539     E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
540 }
541 
542 void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
543   VisitExpr(E);
544 
545   E->DeclRefExprBits.HasQualifier = Record.readInt();
546   E->DeclRefExprBits.HasFoundDecl = Record.readInt();
547   E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
548   E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
549   E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
550   unsigned NumTemplateArgs = 0;
551   if (E->hasTemplateKWAndArgsInfo())
552     NumTemplateArgs = Record.readInt();
553 
554   if (E->hasQualifier())
555     new (E->getTrailingObjects<NestedNameSpecifierLoc>())
556         NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
557 
558   if (E->hasFoundDecl())
559     *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
560 
561   if (E->hasTemplateKWAndArgsInfo())
562     ReadTemplateKWAndArgsInfo(
563         *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
564         E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
565 
566   E->setDecl(ReadDeclAs<ValueDecl>());
567   E->setLocation(ReadSourceLocation());
568   ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName());
569 }
570 
571 void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
572   VisitExpr(E);
573   E->setLocation(ReadSourceLocation());
574   E->setValue(Record.getContext(), Record.readAPInt());
575 }
576 
577 void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
578   VisitExpr(E);
579   E->setLocation(ReadSourceLocation());
580   E->setValue(Record.getContext(), Record.readAPInt());
581 }
582 
583 void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
584   VisitExpr(E);
585   E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record.readInt()));
586   E->setExact(Record.readInt());
587   E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
588   E->setLocation(ReadSourceLocation());
589 }
590 
591 void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
592   VisitExpr(E);
593   E->setSubExpr(Record.readSubExpr());
594 }
595 
596 void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
597   VisitExpr(E);
598 
599   // NumConcatenated, Length and CharByteWidth are set by the empty
600   // ctor since they are needed to allocate storage for the trailing objects.
601   unsigned NumConcatenated = Record.readInt();
602   unsigned Length = Record.readInt();
603   unsigned CharByteWidth = Record.readInt();
604   assert((NumConcatenated == E->getNumConcatenated()) &&
605          "Wrong number of concatenated tokens!");
606   assert((Length == E->getLength()) && "Wrong Length!");
607   assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
608   E->StringLiteralBits.Kind = Record.readInt();
609   E->StringLiteralBits.IsPascal = Record.readInt();
610 
611   // The character width is originally computed via mapCharByteWidth.
612   // Check that the deserialized character width is consistant with the result
613   // of calling mapCharByteWidth.
614   assert((CharByteWidth ==
615           StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
616                                           E->getKind())) &&
617          "Wrong character width!");
618 
619   // Deserialize the trailing array of SourceLocation.
620   for (unsigned I = 0; I < NumConcatenated; ++I)
621     E->setStrTokenLoc(I, ReadSourceLocation());
622 
623   // Deserialize the trailing array of char holding the string data.
624   char *StrData = E->getStrDataAsChar();
625   for (unsigned I = 0; I < Length * CharByteWidth; ++I)
626     StrData[I] = Record.readInt();
627 }
628 
629 void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
630   VisitExpr(E);
631   E->setValue(Record.readInt());
632   E->setLocation(ReadSourceLocation());
633   E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
634 }
635 
636 void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
637   VisitExpr(E);
638   E->setLParen(ReadSourceLocation());
639   E->setRParen(ReadSourceLocation());
640   E->setSubExpr(Record.readSubExpr());
641 }
642 
643 void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
644   VisitExpr(E);
645   unsigned NumExprs = Record.readInt();
646   assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
647   for (unsigned I = 0; I != NumExprs; ++I)
648     E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
649   E->LParenLoc = ReadSourceLocation();
650   E->RParenLoc = ReadSourceLocation();
651 }
652 
653 void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
654   VisitExpr(E);
655   E->setSubExpr(Record.readSubExpr());
656   E->setOpcode((UnaryOperator::Opcode)Record.readInt());
657   E->setOperatorLoc(ReadSourceLocation());
658   E->setCanOverflow(Record.readInt());
659 }
660 
661 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
662   VisitExpr(E);
663   assert(E->getNumComponents() == Record.peekInt());
664   Record.skipInts(1);
665   assert(E->getNumExpressions() == Record.peekInt());
666   Record.skipInts(1);
667   E->setOperatorLoc(ReadSourceLocation());
668   E->setRParenLoc(ReadSourceLocation());
669   E->setTypeSourceInfo(GetTypeSourceInfo());
670   for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
671     auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
672     SourceLocation Start = ReadSourceLocation();
673     SourceLocation End = ReadSourceLocation();
674     switch (Kind) {
675     case OffsetOfNode::Array:
676       E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
677       break;
678 
679     case OffsetOfNode::Field:
680       E->setComponent(
681           I, OffsetOfNode(Start, ReadDeclAs<FieldDecl>(), End));
682       break;
683 
684     case OffsetOfNode::Identifier:
685       E->setComponent(
686           I,
687           OffsetOfNode(Start, Record.getIdentifierInfo(), End));
688       break;
689 
690     case OffsetOfNode::Base: {
691       auto *Base = new (Record.getContext()) CXXBaseSpecifier();
692       *Base = Record.readCXXBaseSpecifier();
693       E->setComponent(I, OffsetOfNode(Base));
694       break;
695     }
696     }
697   }
698 
699   for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
700     E->setIndexExpr(I, Record.readSubExpr());
701 }
702 
703 void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
704   VisitExpr(E);
705   E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
706   if (Record.peekInt() == 0) {
707     E->setArgument(Record.readSubExpr());
708     Record.skipInts(1);
709   } else {
710     E->setArgument(GetTypeSourceInfo());
711   }
712   E->setOperatorLoc(ReadSourceLocation());
713   E->setRParenLoc(ReadSourceLocation());
714 }
715 
716 void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
717   VisitExpr(E);
718   E->setLHS(Record.readSubExpr());
719   E->setRHS(Record.readSubExpr());
720   E->setRBracketLoc(ReadSourceLocation());
721 }
722 
723 void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
724   VisitExpr(E);
725   E->setBase(Record.readSubExpr());
726   E->setLowerBound(Record.readSubExpr());
727   E->setLength(Record.readSubExpr());
728   E->setColonLoc(ReadSourceLocation());
729   E->setRBracketLoc(ReadSourceLocation());
730 }
731 
732 void ASTStmtReader::VisitCallExpr(CallExpr *E) {
733   VisitExpr(E);
734   E->setNumArgs(Record.getContext(), Record.readInt());
735   E->setRParenLoc(ReadSourceLocation());
736   E->setCallee(Record.readSubExpr());
737   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
738     E->setArg(I, Record.readSubExpr());
739 }
740 
741 void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
742   VisitCallExpr(E);
743 }
744 
745 void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
746   // Don't call VisitExpr, this is fully initialized at creation.
747   assert(E->getStmtClass() == Stmt::MemberExprClass &&
748          "It's a subclass, we must advance Idx!");
749 }
750 
751 void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
752   VisitExpr(E);
753   E->setBase(Record.readSubExpr());
754   E->setIsaMemberLoc(ReadSourceLocation());
755   E->setOpLoc(ReadSourceLocation());
756   E->setArrow(Record.readInt());
757 }
758 
759 void ASTStmtReader::
760 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
761   VisitExpr(E);
762   E->Operand = Record.readSubExpr();
763   E->setShouldCopy(Record.readInt());
764 }
765 
766 void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
767   VisitExplicitCastExpr(E);
768   E->LParenLoc = ReadSourceLocation();
769   E->BridgeKeywordLoc = ReadSourceLocation();
770   E->Kind = Record.readInt();
771 }
772 
773 void ASTStmtReader::VisitCastExpr(CastExpr *E) {
774   VisitExpr(E);
775   unsigned NumBaseSpecs = Record.readInt();
776   assert(NumBaseSpecs == E->path_size());
777   E->setSubExpr(Record.readSubExpr());
778   E->setCastKind((CastKind)Record.readInt());
779   CastExpr::path_iterator BaseI = E->path_begin();
780   while (NumBaseSpecs--) {
781     auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
782     *BaseSpec = Record.readCXXBaseSpecifier();
783     *BaseI++ = BaseSpec;
784   }
785 }
786 
787 void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
788   VisitExpr(E);
789   E->setLHS(Record.readSubExpr());
790   E->setRHS(Record.readSubExpr());
791   E->setOpcode((BinaryOperator::Opcode)Record.readInt());
792   E->setOperatorLoc(ReadSourceLocation());
793   E->setFPFeatures(FPOptions(Record.readInt()));
794 }
795 
796 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
797   VisitBinaryOperator(E);
798   E->setComputationLHSType(Record.readType());
799   E->setComputationResultType(Record.readType());
800 }
801 
802 void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
803   VisitExpr(E);
804   E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
805   E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
806   E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
807   E->QuestionLoc = ReadSourceLocation();
808   E->ColonLoc = ReadSourceLocation();
809 }
810 
811 void
812 ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
813   VisitExpr(E);
814   E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
815   E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
816   E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
817   E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
818   E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
819   E->QuestionLoc = ReadSourceLocation();
820   E->ColonLoc = ReadSourceLocation();
821 }
822 
823 void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
824   VisitCastExpr(E);
825   E->setIsPartOfExplicitCast(Record.readInt());
826 }
827 
828 void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
829   VisitCastExpr(E);
830   E->setTypeInfoAsWritten(GetTypeSourceInfo());
831 }
832 
833 void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
834   VisitExplicitCastExpr(E);
835   E->setLParenLoc(ReadSourceLocation());
836   E->setRParenLoc(ReadSourceLocation());
837 }
838 
839 void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
840   VisitExpr(E);
841   E->setLParenLoc(ReadSourceLocation());
842   E->setTypeSourceInfo(GetTypeSourceInfo());
843   E->setInitializer(Record.readSubExpr());
844   E->setFileScope(Record.readInt());
845 }
846 
847 void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
848   VisitExpr(E);
849   E->setBase(Record.readSubExpr());
850   E->setAccessor(Record.getIdentifierInfo());
851   E->setAccessorLoc(ReadSourceLocation());
852 }
853 
854 void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
855   VisitExpr(E);
856   if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
857     E->setSyntacticForm(SyntForm);
858   E->setLBraceLoc(ReadSourceLocation());
859   E->setRBraceLoc(ReadSourceLocation());
860   bool isArrayFiller = Record.readInt();
861   Expr *filler = nullptr;
862   if (isArrayFiller) {
863     filler = Record.readSubExpr();
864     E->ArrayFillerOrUnionFieldInit = filler;
865   } else
866     E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>();
867   E->sawArrayRangeDesignator(Record.readInt());
868   unsigned NumInits = Record.readInt();
869   E->reserveInits(Record.getContext(), NumInits);
870   if (isArrayFiller) {
871     for (unsigned I = 0; I != NumInits; ++I) {
872       Expr *init = Record.readSubExpr();
873       E->updateInit(Record.getContext(), I, init ? init : filler);
874     }
875   } else {
876     for (unsigned I = 0; I != NumInits; ++I)
877       E->updateInit(Record.getContext(), I, Record.readSubExpr());
878   }
879 }
880 
881 void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
882   using Designator = DesignatedInitExpr::Designator;
883 
884   VisitExpr(E);
885   unsigned NumSubExprs = Record.readInt();
886   assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
887   for (unsigned I = 0; I != NumSubExprs; ++I)
888     E->setSubExpr(I, Record.readSubExpr());
889   E->setEqualOrColonLoc(ReadSourceLocation());
890   E->setGNUSyntax(Record.readInt());
891 
892   SmallVector<Designator, 4> Designators;
893   while (Record.getIdx() < Record.size()) {
894     switch ((DesignatorTypes)Record.readInt()) {
895     case DESIG_FIELD_DECL: {
896       auto *Field = ReadDeclAs<FieldDecl>();
897       SourceLocation DotLoc = ReadSourceLocation();
898       SourceLocation FieldLoc = ReadSourceLocation();
899       Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
900                                        FieldLoc));
901       Designators.back().setField(Field);
902       break;
903     }
904 
905     case DESIG_FIELD_NAME: {
906       const IdentifierInfo *Name = Record.getIdentifierInfo();
907       SourceLocation DotLoc = ReadSourceLocation();
908       SourceLocation FieldLoc = ReadSourceLocation();
909       Designators.push_back(Designator(Name, DotLoc, FieldLoc));
910       break;
911     }
912 
913     case DESIG_ARRAY: {
914       unsigned Index = Record.readInt();
915       SourceLocation LBracketLoc = ReadSourceLocation();
916       SourceLocation RBracketLoc = ReadSourceLocation();
917       Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
918       break;
919     }
920 
921     case DESIG_ARRAY_RANGE: {
922       unsigned Index = Record.readInt();
923       SourceLocation LBracketLoc = ReadSourceLocation();
924       SourceLocation EllipsisLoc = ReadSourceLocation();
925       SourceLocation RBracketLoc = ReadSourceLocation();
926       Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
927                                        RBracketLoc));
928       break;
929     }
930     }
931   }
932   E->setDesignators(Record.getContext(),
933                     Designators.data(), Designators.size());
934 }
935 
936 void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
937   VisitExpr(E);
938   E->setBase(Record.readSubExpr());
939   E->setUpdater(Record.readSubExpr());
940 }
941 
942 void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
943   VisitExpr(E);
944 }
945 
946 void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
947   VisitExpr(E);
948   E->SubExprs[0] = Record.readSubExpr();
949   E->SubExprs[1] = Record.readSubExpr();
950 }
951 
952 void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
953   VisitExpr(E);
954 }
955 
956 void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
957   VisitExpr(E);
958 }
959 
960 void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
961   VisitExpr(E);
962   E->setSubExpr(Record.readSubExpr());
963   E->setWrittenTypeInfo(GetTypeSourceInfo());
964   E->setBuiltinLoc(ReadSourceLocation());
965   E->setRParenLoc(ReadSourceLocation());
966   E->setIsMicrosoftABI(Record.readInt());
967 }
968 
969 void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
970   VisitExpr(E);
971   E->setAmpAmpLoc(ReadSourceLocation());
972   E->setLabelLoc(ReadSourceLocation());
973   E->setLabel(ReadDeclAs<LabelDecl>());
974 }
975 
976 void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
977   VisitExpr(E);
978   E->setLParenLoc(ReadSourceLocation());
979   E->setRParenLoc(ReadSourceLocation());
980   E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
981 }
982 
983 void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
984   VisitExpr(E);
985   E->setCond(Record.readSubExpr());
986   E->setLHS(Record.readSubExpr());
987   E->setRHS(Record.readSubExpr());
988   E->setBuiltinLoc(ReadSourceLocation());
989   E->setRParenLoc(ReadSourceLocation());
990   E->setIsConditionTrue(Record.readInt());
991 }
992 
993 void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
994   VisitExpr(E);
995   E->setTokenLocation(ReadSourceLocation());
996 }
997 
998 void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
999   VisitExpr(E);
1000   SmallVector<Expr *, 16> Exprs;
1001   unsigned NumExprs = Record.readInt();
1002   while (NumExprs--)
1003     Exprs.push_back(Record.readSubExpr());
1004   E->setExprs(Record.getContext(), Exprs);
1005   E->setBuiltinLoc(ReadSourceLocation());
1006   E->setRParenLoc(ReadSourceLocation());
1007 }
1008 
1009 void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1010   VisitExpr(E);
1011   E->BuiltinLoc = ReadSourceLocation();
1012   E->RParenLoc = ReadSourceLocation();
1013   E->TInfo = GetTypeSourceInfo();
1014   E->SrcExpr = Record.readSubExpr();
1015 }
1016 
1017 void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
1018   VisitExpr(E);
1019   E->setBlockDecl(ReadDeclAs<BlockDecl>());
1020 }
1021 
1022 void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1023   VisitExpr(E);
1024   E->NumAssocs = Record.readInt();
1025   E->AssocTypes = new (Record.getContext()) TypeSourceInfo*[E->NumAssocs];
1026   E->SubExprs =
1027    new(Record.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
1028 
1029   E->SubExprs[GenericSelectionExpr::CONTROLLING] = Record.readSubExpr();
1030   for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
1031     E->AssocTypes[I] = GetTypeSourceInfo();
1032     E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Record.readSubExpr();
1033   }
1034   E->ResultIndex = Record.readInt();
1035 
1036   E->GenericLoc = ReadSourceLocation();
1037   E->DefaultLoc = ReadSourceLocation();
1038   E->RParenLoc = ReadSourceLocation();
1039 }
1040 
1041 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1042   VisitExpr(E);
1043   unsigned numSemanticExprs = Record.readInt();
1044   assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
1045   E->PseudoObjectExprBits.ResultIndex = Record.readInt();
1046 
1047   // Read the syntactic expression.
1048   E->getSubExprsBuffer()[0] = Record.readSubExpr();
1049 
1050   // Read all the semantic expressions.
1051   for (unsigned i = 0; i != numSemanticExprs; ++i) {
1052     Expr *subExpr = Record.readSubExpr();
1053     E->getSubExprsBuffer()[i+1] = subExpr;
1054   }
1055 }
1056 
1057 void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1058   VisitExpr(E);
1059   E->Op = AtomicExpr::AtomicOp(Record.readInt());
1060   E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1061   for (unsigned I = 0; I != E->NumSubExprs; ++I)
1062     E->SubExprs[I] = Record.readSubExpr();
1063   E->BuiltinLoc = ReadSourceLocation();
1064   E->RParenLoc = ReadSourceLocation();
1065 }
1066 
1067 //===----------------------------------------------------------------------===//
1068 // Objective-C Expressions and Statements
1069 
1070 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
1071   VisitExpr(E);
1072   E->setString(cast<StringLiteral>(Record.readSubStmt()));
1073   E->setAtLoc(ReadSourceLocation());
1074 }
1075 
1076 void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
1077   VisitExpr(E);
1078   // could be one of several IntegerLiteral, FloatLiteral, etc.
1079   E->SubExpr = Record.readSubStmt();
1080   E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>();
1081   E->Range = ReadSourceRange();
1082 }
1083 
1084 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1085   VisitExpr(E);
1086   unsigned NumElements = Record.readInt();
1087   assert(NumElements == E->getNumElements() && "Wrong number of elements");
1088   Expr **Elements = E->getElements();
1089   for (unsigned I = 0, N = NumElements; I != N; ++I)
1090     Elements[I] = Record.readSubExpr();
1091   E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1092   E->Range = ReadSourceRange();
1093 }
1094 
1095 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1096   VisitExpr(E);
1097   unsigned NumElements = Record.readInt();
1098   assert(NumElements == E->getNumElements() && "Wrong number of elements");
1099   bool HasPackExpansions = Record.readInt();
1100   assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
1101   auto *KeyValues =
1102       E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
1103   auto *Expansions =
1104       E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
1105   for (unsigned I = 0; I != NumElements; ++I) {
1106     KeyValues[I].Key = Record.readSubExpr();
1107     KeyValues[I].Value = Record.readSubExpr();
1108     if (HasPackExpansions) {
1109       Expansions[I].EllipsisLoc = ReadSourceLocation();
1110       Expansions[I].NumExpansionsPlusOne = Record.readInt();
1111     }
1112   }
1113   E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1114   E->Range = ReadSourceRange();
1115 }
1116 
1117 void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
1118   VisitExpr(E);
1119   E->setEncodedTypeSourceInfo(GetTypeSourceInfo());
1120   E->setAtLoc(ReadSourceLocation());
1121   E->setRParenLoc(ReadSourceLocation());
1122 }
1123 
1124 void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
1125   VisitExpr(E);
1126   E->setSelector(Record.readSelector());
1127   E->setAtLoc(ReadSourceLocation());
1128   E->setRParenLoc(ReadSourceLocation());
1129 }
1130 
1131 void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
1132   VisitExpr(E);
1133   E->setProtocol(ReadDeclAs<ObjCProtocolDecl>());
1134   E->setAtLoc(ReadSourceLocation());
1135   E->ProtoLoc = ReadSourceLocation();
1136   E->setRParenLoc(ReadSourceLocation());
1137 }
1138 
1139 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
1140   VisitExpr(E);
1141   E->setDecl(ReadDeclAs<ObjCIvarDecl>());
1142   E->setLocation(ReadSourceLocation());
1143   E->setOpLoc(ReadSourceLocation());
1144   E->setBase(Record.readSubExpr());
1145   E->setIsArrow(Record.readInt());
1146   E->setIsFreeIvar(Record.readInt());
1147 }
1148 
1149 void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
1150   VisitExpr(E);
1151   unsigned MethodRefFlags = Record.readInt();
1152   bool Implicit = Record.readInt() != 0;
1153   if (Implicit) {
1154     auto *Getter = ReadDeclAs<ObjCMethodDecl>();
1155     auto *Setter = ReadDeclAs<ObjCMethodDecl>();
1156     E->setImplicitProperty(Getter, Setter, MethodRefFlags);
1157   } else {
1158     E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
1159   }
1160   E->setLocation(ReadSourceLocation());
1161   E->setReceiverLocation(ReadSourceLocation());
1162   switch (Record.readInt()) {
1163   case 0:
1164     E->setBase(Record.readSubExpr());
1165     break;
1166   case 1:
1167     E->setSuperReceiver(Record.readType());
1168     break;
1169   case 2:
1170     E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>());
1171     break;
1172   }
1173 }
1174 
1175 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1176   VisitExpr(E);
1177   E->setRBracket(ReadSourceLocation());
1178   E->setBaseExpr(Record.readSubExpr());
1179   E->setKeyExpr(Record.readSubExpr());
1180   E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1181   E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1182 }
1183 
1184 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1185   VisitExpr(E);
1186   assert(Record.peekInt() == E->getNumArgs());
1187   Record.skipInts(1);
1188   unsigned NumStoredSelLocs = Record.readInt();
1189   E->SelLocsKind = Record.readInt();
1190   E->setDelegateInitCall(Record.readInt());
1191   E->IsImplicit = Record.readInt();
1192   auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
1193   switch (Kind) {
1194   case ObjCMessageExpr::Instance:
1195     E->setInstanceReceiver(Record.readSubExpr());
1196     break;
1197 
1198   case ObjCMessageExpr::Class:
1199     E->setClassReceiver(GetTypeSourceInfo());
1200     break;
1201 
1202   case ObjCMessageExpr::SuperClass:
1203   case ObjCMessageExpr::SuperInstance: {
1204     QualType T = Record.readType();
1205     SourceLocation SuperLoc = ReadSourceLocation();
1206     E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1207     break;
1208   }
1209   }
1210 
1211   assert(Kind == E->getReceiverKind());
1212 
1213   if (Record.readInt())
1214     E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>());
1215   else
1216     E->setSelector(Record.readSelector());
1217 
1218   E->LBracLoc = ReadSourceLocation();
1219   E->RBracLoc = ReadSourceLocation();
1220 
1221   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1222     E->setArg(I, Record.readSubExpr());
1223 
1224   SourceLocation *Locs = E->getStoredSelLocs();
1225   for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1226     Locs[I] = ReadSourceLocation();
1227 }
1228 
1229 void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1230   VisitStmt(S);
1231   S->setElement(Record.readSubStmt());
1232   S->setCollection(Record.readSubExpr());
1233   S->setBody(Record.readSubStmt());
1234   S->setForLoc(ReadSourceLocation());
1235   S->setRParenLoc(ReadSourceLocation());
1236 }
1237 
1238 void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1239   VisitStmt(S);
1240   S->setCatchBody(Record.readSubStmt());
1241   S->setCatchParamDecl(ReadDeclAs<VarDecl>());
1242   S->setAtCatchLoc(ReadSourceLocation());
1243   S->setRParenLoc(ReadSourceLocation());
1244 }
1245 
1246 void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1247   VisitStmt(S);
1248   S->setFinallyBody(Record.readSubStmt());
1249   S->setAtFinallyLoc(ReadSourceLocation());
1250 }
1251 
1252 void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1253   VisitStmt(S);
1254   S->setSubStmt(Record.readSubStmt());
1255   S->setAtLoc(ReadSourceLocation());
1256 }
1257 
1258 void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1259   VisitStmt(S);
1260   assert(Record.peekInt() == S->getNumCatchStmts());
1261   Record.skipInts(1);
1262   bool HasFinally = Record.readInt();
1263   S->setTryBody(Record.readSubStmt());
1264   for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
1265     S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
1266 
1267   if (HasFinally)
1268     S->setFinallyStmt(Record.readSubStmt());
1269   S->setAtTryLoc(ReadSourceLocation());
1270 }
1271 
1272 void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1273   VisitStmt(S);
1274   S->setSynchExpr(Record.readSubStmt());
1275   S->setSynchBody(Record.readSubStmt());
1276   S->setAtSynchronizedLoc(ReadSourceLocation());
1277 }
1278 
1279 void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1280   VisitStmt(S);
1281   S->setThrowExpr(Record.readSubStmt());
1282   S->setThrowLoc(ReadSourceLocation());
1283 }
1284 
1285 void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1286   VisitExpr(E);
1287   E->setValue(Record.readInt());
1288   E->setLocation(ReadSourceLocation());
1289 }
1290 
1291 void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1292   VisitExpr(E);
1293   SourceRange R = Record.readSourceRange();
1294   E->AtLoc = R.getBegin();
1295   E->RParen = R.getEnd();
1296   E->VersionToCheck = Record.readVersionTuple();
1297 }
1298 
1299 //===----------------------------------------------------------------------===//
1300 // C++ Expressions and Statements
1301 //===----------------------------------------------------------------------===//
1302 
1303 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
1304   VisitStmt(S);
1305   S->CatchLoc = ReadSourceLocation();
1306   S->ExceptionDecl = ReadDeclAs<VarDecl>();
1307   S->HandlerBlock = Record.readSubStmt();
1308 }
1309 
1310 void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
1311   VisitStmt(S);
1312   assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1313   Record.skipInts(1);
1314   S->TryLoc = ReadSourceLocation();
1315   S->getStmts()[0] = Record.readSubStmt();
1316   for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1317     S->getStmts()[i + 1] = Record.readSubStmt();
1318 }
1319 
1320 void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1321   VisitStmt(S);
1322   S->ForLoc = ReadSourceLocation();
1323   S->CoawaitLoc = ReadSourceLocation();
1324   S->ColonLoc = ReadSourceLocation();
1325   S->RParenLoc = ReadSourceLocation();
1326   S->setInit(Record.readSubStmt());
1327   S->setRangeStmt(Record.readSubStmt());
1328   S->setBeginStmt(Record.readSubStmt());
1329   S->setEndStmt(Record.readSubStmt());
1330   S->setCond(Record.readSubExpr());
1331   S->setInc(Record.readSubExpr());
1332   S->setLoopVarStmt(Record.readSubStmt());
1333   S->setBody(Record.readSubStmt());
1334 }
1335 
1336 void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1337   VisitStmt(S);
1338   S->KeywordLoc = ReadSourceLocation();
1339   S->IsIfExists = Record.readInt();
1340   S->QualifierLoc = Record.readNestedNameSpecifierLoc();
1341   ReadDeclarationNameInfo(S->NameInfo);
1342   S->SubStmt = Record.readSubStmt();
1343 }
1344 
1345 void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1346   VisitCallExpr(E);
1347   E->Operator = (OverloadedOperatorKind)Record.readInt();
1348   E->Range = Record.readSourceRange();
1349   E->setFPFeatures(FPOptions(Record.readInt()));
1350 }
1351 
1352 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
1353   VisitExpr(E);
1354   E->NumArgs = Record.readInt();
1355   if (E->NumArgs)
1356     E->Args = new (Record.getContext()) Stmt*[E->NumArgs];
1357   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1358     E->setArg(I, Record.readSubExpr());
1359   E->setConstructor(ReadDeclAs<CXXConstructorDecl>());
1360   E->setLocation(ReadSourceLocation());
1361   E->setElidable(Record.readInt());
1362   E->setHadMultipleCandidates(Record.readInt());
1363   E->setListInitialization(Record.readInt());
1364   E->setStdInitListInitialization(Record.readInt());
1365   E->setRequiresZeroInitialization(Record.readInt());
1366   E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record.readInt());
1367   E->ParenOrBraceRange = ReadSourceRange();
1368 }
1369 
1370 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1371   VisitExpr(E);
1372   E->Constructor = ReadDeclAs<CXXConstructorDecl>();
1373   E->Loc = ReadSourceLocation();
1374   E->ConstructsVirtualBase = Record.readInt();
1375   E->InheritedFromVirtualBase = Record.readInt();
1376 }
1377 
1378 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1379   VisitCXXConstructExpr(E);
1380   E->Type = GetTypeSourceInfo();
1381 }
1382 
1383 void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1384   VisitExpr(E);
1385   unsigned NumCaptures = Record.readInt();
1386   assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1387   E->IntroducerRange = ReadSourceRange();
1388   E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
1389   E->CaptureDefaultLoc = ReadSourceLocation();
1390   E->ExplicitParams = Record.readInt();
1391   E->ExplicitResultType = Record.readInt();
1392   E->ClosingBrace = ReadSourceLocation();
1393 
1394   // Read capture initializers.
1395   for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1396                                       CEnd = E->capture_init_end();
1397        C != CEnd; ++C)
1398     *C = Record.readSubExpr();
1399 }
1400 
1401 void
1402 ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1403   VisitExpr(E);
1404   E->SubExpr = Record.readSubExpr();
1405 }
1406 
1407 void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1408   VisitExplicitCastExpr(E);
1409   SourceRange R = ReadSourceRange();
1410   E->Loc = R.getBegin();
1411   E->RParenLoc = R.getEnd();
1412   R = ReadSourceRange();
1413   E->AngleBrackets = R;
1414 }
1415 
1416 void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1417   return VisitCXXNamedCastExpr(E);
1418 }
1419 
1420 void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1421   return VisitCXXNamedCastExpr(E);
1422 }
1423 
1424 void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1425   return VisitCXXNamedCastExpr(E);
1426 }
1427 
1428 void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1429   return VisitCXXNamedCastExpr(E);
1430 }
1431 
1432 void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1433   VisitExplicitCastExpr(E);
1434   E->setLParenLoc(ReadSourceLocation());
1435   E->setRParenLoc(ReadSourceLocation());
1436 }
1437 
1438 void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1439   VisitCallExpr(E);
1440   E->UDSuffixLoc = ReadSourceLocation();
1441 }
1442 
1443 void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1444   VisitExpr(E);
1445   E->setValue(Record.readInt());
1446   E->setLocation(ReadSourceLocation());
1447 }
1448 
1449 void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1450   VisitExpr(E);
1451   E->setLocation(ReadSourceLocation());
1452 }
1453 
1454 void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1455   VisitExpr(E);
1456   E->setSourceRange(ReadSourceRange());
1457   if (E->isTypeOperand()) { // typeid(int)
1458     E->setTypeOperandSourceInfo(
1459         GetTypeSourceInfo());
1460     return;
1461   }
1462 
1463   // typeid(42+2)
1464   E->setExprOperand(Record.readSubExpr());
1465 }
1466 
1467 void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
1468   VisitExpr(E);
1469   E->setLocation(ReadSourceLocation());
1470   E->setImplicit(Record.readInt());
1471 }
1472 
1473 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
1474   VisitExpr(E);
1475   E->CXXThrowExprBits.ThrowLoc = ReadSourceLocation();
1476   E->Operand = Record.readSubExpr();
1477   E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
1478 }
1479 
1480 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1481   VisitExpr(E);
1482   E->Param = ReadDeclAs<ParmVarDecl>();
1483   E->CXXDefaultArgExprBits.Loc = ReadSourceLocation();
1484 }
1485 
1486 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1487   VisitExpr(E);
1488   E->Field = ReadDeclAs<FieldDecl>();
1489   E->CXXDefaultInitExprBits.Loc = ReadSourceLocation();
1490 }
1491 
1492 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1493   VisitExpr(E);
1494   E->setTemporary(Record.readCXXTemporary());
1495   E->setSubExpr(Record.readSubExpr());
1496 }
1497 
1498 void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1499   VisitExpr(E);
1500   E->TypeInfo = GetTypeSourceInfo();
1501   E->RParenLoc = ReadSourceLocation();
1502 }
1503 
1504 void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
1505   VisitExpr(E);
1506   E->GlobalNew = Record.readInt();
1507   bool isArray = Record.readInt();
1508   E->PassAlignment = Record.readInt();
1509   E->UsualArrayDeleteWantsSize = Record.readInt();
1510   unsigned NumPlacementArgs = Record.readInt();
1511   E->StoredInitializationStyle = Record.readInt();
1512   E->setOperatorNew(ReadDeclAs<FunctionDecl>());
1513   E->setOperatorDelete(ReadDeclAs<FunctionDecl>());
1514   E->AllocatedTypeInfo = GetTypeSourceInfo();
1515   E->TypeIdParens = ReadSourceRange();
1516   E->Range = ReadSourceRange();
1517   E->DirectInitRange = ReadSourceRange();
1518 
1519   E->AllocateArgsArray(Record.getContext(), isArray, NumPlacementArgs,
1520                        E->StoredInitializationStyle != 0);
1521 
1522   // Install all the subexpressions.
1523   for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1524        I != e; ++I)
1525     *I = Record.readSubStmt();
1526 }
1527 
1528 void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1529   VisitExpr(E);
1530   E->GlobalDelete = Record.readInt();
1531   E->ArrayForm = Record.readInt();
1532   E->ArrayFormAsWritten = Record.readInt();
1533   E->UsualArrayDeleteWantsSize = Record.readInt();
1534   E->OperatorDelete = ReadDeclAs<FunctionDecl>();
1535   E->Argument = Record.readSubExpr();
1536   E->Loc = ReadSourceLocation();
1537 }
1538 
1539 void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1540   VisitExpr(E);
1541 
1542   E->Base = Record.readSubExpr();
1543   E->IsArrow = Record.readInt();
1544   E->OperatorLoc = ReadSourceLocation();
1545   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1546   E->ScopeType = GetTypeSourceInfo();
1547   E->ColonColonLoc = ReadSourceLocation();
1548   E->TildeLoc = ReadSourceLocation();
1549 
1550   IdentifierInfo *II = Record.getIdentifierInfo();
1551   if (II)
1552     E->setDestroyedType(II, ReadSourceLocation());
1553   else
1554     E->setDestroyedType(GetTypeSourceInfo());
1555 }
1556 
1557 void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
1558   VisitExpr(E);
1559 
1560   unsigned NumObjects = Record.readInt();
1561   assert(NumObjects == E->getNumObjects());
1562   for (unsigned i = 0; i != NumObjects; ++i)
1563     E->getTrailingObjects<BlockDecl *>()[i] =
1564         ReadDeclAs<BlockDecl>();
1565 
1566   E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
1567   E->SubExpr = Record.readSubExpr();
1568 }
1569 
1570 void
1571 ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
1572   VisitExpr(E);
1573 
1574   if (Record.readInt()) // HasTemplateKWAndArgsInfo
1575     ReadTemplateKWAndArgsInfo(
1576         *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1577         E->getTrailingObjects<TemplateArgumentLoc>(),
1578         /*NumTemplateArgs=*/Record.readInt());
1579 
1580   E->Base = Record.readSubExpr();
1581   E->BaseType = Record.readType();
1582   E->IsArrow = Record.readInt();
1583   E->OperatorLoc = ReadSourceLocation();
1584   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1585   E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>();
1586   ReadDeclarationNameInfo(E->MemberNameInfo);
1587 }
1588 
1589 void
1590 ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
1591   VisitExpr(E);
1592 
1593   if (Record.readInt()) // HasTemplateKWAndArgsInfo
1594     ReadTemplateKWAndArgsInfo(
1595         *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1596         E->getTrailingObjects<TemplateArgumentLoc>(),
1597         /*NumTemplateArgs=*/Record.readInt());
1598 
1599   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1600   ReadDeclarationNameInfo(E->NameInfo);
1601 }
1602 
1603 void
1604 ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
1605   VisitExpr(E);
1606   assert(Record.peekInt() == E->arg_size() &&
1607          "Read wrong record during creation ?");
1608   Record.skipInts(1);
1609   for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
1610     E->setArg(I, Record.readSubExpr());
1611   E->Type = GetTypeSourceInfo();
1612   E->setLParenLoc(ReadSourceLocation());
1613   E->setRParenLoc(ReadSourceLocation());
1614 }
1615 
1616 void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
1617   VisitExpr(E);
1618 
1619   if (Record.readInt()) // HasTemplateKWAndArgsInfo
1620     ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1621                               E->getTrailingTemplateArgumentLoc(),
1622                               /*NumTemplateArgs=*/Record.readInt());
1623 
1624   unsigned NumDecls = Record.readInt();
1625   UnresolvedSet<8> Decls;
1626   for (unsigned i = 0; i != NumDecls; ++i) {
1627     auto *D = ReadDeclAs<NamedDecl>();
1628     auto AS = (AccessSpecifier)Record.readInt();
1629     Decls.addDecl(D, AS);
1630   }
1631   E->initializeResults(Record.getContext(), Decls.begin(), Decls.end());
1632 
1633   ReadDeclarationNameInfo(E->NameInfo);
1634   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1635 }
1636 
1637 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
1638   VisitOverloadExpr(E);
1639   E->IsArrow = Record.readInt();
1640   E->HasUnresolvedUsing = Record.readInt();
1641   E->Base = Record.readSubExpr();
1642   E->BaseType = Record.readType();
1643   E->OperatorLoc = ReadSourceLocation();
1644 }
1645 
1646 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
1647   VisitOverloadExpr(E);
1648   E->RequiresADL = Record.readInt();
1649   E->Overloaded = Record.readInt();
1650   E->NamingClass = ReadDeclAs<CXXRecordDecl>();
1651 }
1652 
1653 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1654   VisitExpr(E);
1655   E->TypeTraitExprBits.NumArgs = Record.readInt();
1656   E->TypeTraitExprBits.Kind = Record.readInt();
1657   E->TypeTraitExprBits.Value = Record.readInt();
1658   SourceRange Range = ReadSourceRange();
1659   E->Loc = Range.getBegin();
1660   E->RParenLoc = Range.getEnd();
1661 
1662   auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
1663   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1664     Args[I] = GetTypeSourceInfo();
1665 }
1666 
1667 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1668   VisitExpr(E);
1669   E->ATT = (ArrayTypeTrait)Record.readInt();
1670   E->Value = (unsigned int)Record.readInt();
1671   SourceRange Range = ReadSourceRange();
1672   E->Loc = Range.getBegin();
1673   E->RParen = Range.getEnd();
1674   E->QueriedType = GetTypeSourceInfo();
1675   E->Dimension = Record.readSubExpr();
1676 }
1677 
1678 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1679   VisitExpr(E);
1680   E->ET = (ExpressionTrait)Record.readInt();
1681   E->Value = (bool)Record.readInt();
1682   SourceRange Range = ReadSourceRange();
1683   E->QueriedExpression = Record.readSubExpr();
1684   E->Loc = Range.getBegin();
1685   E->RParen = Range.getEnd();
1686 }
1687 
1688 void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1689   VisitExpr(E);
1690   E->Value = (bool)Record.readInt();
1691   E->Range = ReadSourceRange();
1692   E->Operand = Record.readSubExpr();
1693 }
1694 
1695 void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1696   VisitExpr(E);
1697   E->EllipsisLoc = ReadSourceLocation();
1698   E->NumExpansions = Record.readInt();
1699   E->Pattern = Record.readSubExpr();
1700 }
1701 
1702 void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1703   VisitExpr(E);
1704   unsigned NumPartialArgs = Record.readInt();
1705   E->OperatorLoc = ReadSourceLocation();
1706   E->PackLoc = ReadSourceLocation();
1707   E->RParenLoc = ReadSourceLocation();
1708   E->Pack = Record.readDeclAs<NamedDecl>();
1709   if (E->isPartiallySubstituted()) {
1710     assert(E->Length == NumPartialArgs);
1711     for (auto *I = E->getTrailingObjects<TemplateArgument>(),
1712               *E = I + NumPartialArgs;
1713          I != E; ++I)
1714       new (I) TemplateArgument(Record.readTemplateArgument());
1715   } else if (!E->isValueDependent()) {
1716     E->Length = Record.readInt();
1717   }
1718 }
1719 
1720 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1721                                               SubstNonTypeTemplateParmExpr *E) {
1722   VisitExpr(E);
1723   E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1724   E->NameLoc = ReadSourceLocation();
1725   E->Replacement = Record.readSubExpr();
1726 }
1727 
1728 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1729                                           SubstNonTypeTemplateParmPackExpr *E) {
1730   VisitExpr(E);
1731   E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1732   TemplateArgument ArgPack = Record.readTemplateArgument();
1733   if (ArgPack.getKind() != TemplateArgument::Pack)
1734     return;
1735 
1736   E->Arguments = ArgPack.pack_begin();
1737   E->NumArguments = ArgPack.pack_size();
1738   E->NameLoc = ReadSourceLocation();
1739 }
1740 
1741 void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1742   VisitExpr(E);
1743   E->NumParameters = Record.readInt();
1744   E->ParamPack = ReadDeclAs<ParmVarDecl>();
1745   E->NameLoc = ReadSourceLocation();
1746   auto **Parms = E->getTrailingObjects<ParmVarDecl *>();
1747   for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
1748     Parms[i] = ReadDeclAs<ParmVarDecl>();
1749 }
1750 
1751 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1752   VisitExpr(E);
1753   E->State = Record.readSubExpr();
1754   auto *VD = ReadDeclAs<ValueDecl>();
1755   unsigned ManglingNumber = Record.readInt();
1756   E->setExtendingDecl(VD, ManglingNumber);
1757 }
1758 
1759 void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
1760   VisitExpr(E);
1761   E->LParenLoc = ReadSourceLocation();
1762   E->EllipsisLoc = ReadSourceLocation();
1763   E->RParenLoc = ReadSourceLocation();
1764   E->SubExprs[0] = Record.readSubExpr();
1765   E->SubExprs[1] = Record.readSubExpr();
1766   E->Opcode = (BinaryOperatorKind)Record.readInt();
1767 }
1768 
1769 void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1770   VisitExpr(E);
1771   E->SourceExpr = Record.readSubExpr();
1772   E->Loc = ReadSourceLocation();
1773   E->setIsUnique(Record.readInt());
1774 }
1775 
1776 void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
1777   llvm_unreachable("Cannot read TypoExpr nodes");
1778 }
1779 
1780 //===----------------------------------------------------------------------===//
1781 // Microsoft Expressions and Statements
1782 //===----------------------------------------------------------------------===//
1783 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1784   VisitExpr(E);
1785   E->IsArrow = (Record.readInt() != 0);
1786   E->BaseExpr = Record.readSubExpr();
1787   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1788   E->MemberLoc = ReadSourceLocation();
1789   E->TheDecl = ReadDeclAs<MSPropertyDecl>();
1790 }
1791 
1792 void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
1793   VisitExpr(E);
1794   E->setBase(Record.readSubExpr());
1795   E->setIdx(Record.readSubExpr());
1796   E->setRBracketLoc(ReadSourceLocation());
1797 }
1798 
1799 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1800   VisitExpr(E);
1801   E->setSourceRange(ReadSourceRange());
1802   std::string UuidStr = ReadString();
1803   E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
1804   if (E->isTypeOperand()) { // __uuidof(ComType)
1805     E->setTypeOperandSourceInfo(
1806         GetTypeSourceInfo());
1807     return;
1808   }
1809 
1810   // __uuidof(expr)
1811   E->setExprOperand(Record.readSubExpr());
1812 }
1813 
1814 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1815   VisitStmt(S);
1816   S->setLeaveLoc(ReadSourceLocation());
1817 }
1818 
1819 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1820   VisitStmt(S);
1821   S->Loc = ReadSourceLocation();
1822   S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
1823   S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
1824 }
1825 
1826 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1827   VisitStmt(S);
1828   S->Loc = ReadSourceLocation();
1829   S->Block = Record.readSubStmt();
1830 }
1831 
1832 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1833   VisitStmt(S);
1834   S->IsCXXTry = Record.readInt();
1835   S->TryLoc = ReadSourceLocation();
1836   S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
1837   S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
1838 }
1839 
1840 //===----------------------------------------------------------------------===//
1841 // CUDA Expressions and Statements
1842 //===----------------------------------------------------------------------===//
1843 
1844 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1845   VisitCallExpr(E);
1846   E->setConfig(cast<CallExpr>(Record.readSubExpr()));
1847 }
1848 
1849 //===----------------------------------------------------------------------===//
1850 // OpenCL Expressions and Statements.
1851 //===----------------------------------------------------------------------===//
1852 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1853   VisitExpr(E);
1854   E->BuiltinLoc = ReadSourceLocation();
1855   E->RParenLoc = ReadSourceLocation();
1856   E->SrcExpr = Record.readSubExpr();
1857 }
1858 
1859 //===----------------------------------------------------------------------===//
1860 // OpenMP Directives.
1861 //===----------------------------------------------------------------------===//
1862 
1863 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
1864   E->setLocStart(ReadSourceLocation());
1865   E->setLocEnd(ReadSourceLocation());
1866   OMPClauseReader ClauseReader(Record);
1867   SmallVector<OMPClause *, 5> Clauses;
1868   for (unsigned i = 0; i < E->getNumClauses(); ++i)
1869     Clauses.push_back(ClauseReader.readClause());
1870   E->setClauses(Clauses);
1871   if (E->hasAssociatedStmt())
1872     E->setAssociatedStmt(Record.readSubStmt());
1873 }
1874 
1875 void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
1876   VisitStmt(D);
1877   // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
1878   Record.skipInts(2);
1879   VisitOMPExecutableDirective(D);
1880   D->setIterationVariable(Record.readSubExpr());
1881   D->setLastIteration(Record.readSubExpr());
1882   D->setCalcLastIteration(Record.readSubExpr());
1883   D->setPreCond(Record.readSubExpr());
1884   D->setCond(Record.readSubExpr());
1885   D->setInit(Record.readSubExpr());
1886   D->setInc(Record.readSubExpr());
1887   D->setPreInits(Record.readSubStmt());
1888   if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
1889       isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
1890       isOpenMPDistributeDirective(D->getDirectiveKind())) {
1891     D->setIsLastIterVariable(Record.readSubExpr());
1892     D->setLowerBoundVariable(Record.readSubExpr());
1893     D->setUpperBoundVariable(Record.readSubExpr());
1894     D->setStrideVariable(Record.readSubExpr());
1895     D->setEnsureUpperBound(Record.readSubExpr());
1896     D->setNextLowerBound(Record.readSubExpr());
1897     D->setNextUpperBound(Record.readSubExpr());
1898     D->setNumIterations(Record.readSubExpr());
1899   }
1900   if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
1901     D->setPrevLowerBoundVariable(Record.readSubExpr());
1902     D->setPrevUpperBoundVariable(Record.readSubExpr());
1903     D->setDistInc(Record.readSubExpr());
1904     D->setPrevEnsureUpperBound(Record.readSubExpr());
1905     D->setCombinedLowerBoundVariable(Record.readSubExpr());
1906     D->setCombinedUpperBoundVariable(Record.readSubExpr());
1907     D->setCombinedEnsureUpperBound(Record.readSubExpr());
1908     D->setCombinedInit(Record.readSubExpr());
1909     D->setCombinedCond(Record.readSubExpr());
1910     D->setCombinedNextLowerBound(Record.readSubExpr());
1911     D->setCombinedNextUpperBound(Record.readSubExpr());
1912     D->setCombinedDistCond(Record.readSubExpr());
1913     D->setCombinedParForInDistCond(Record.readSubExpr());
1914   }
1915   SmallVector<Expr *, 4> Sub;
1916   unsigned CollapsedNum = D->getCollapsedNumber();
1917   Sub.reserve(CollapsedNum);
1918   for (unsigned i = 0; i < CollapsedNum; ++i)
1919     Sub.push_back(Record.readSubExpr());
1920   D->setCounters(Sub);
1921   Sub.clear();
1922   for (unsigned i = 0; i < CollapsedNum; ++i)
1923     Sub.push_back(Record.readSubExpr());
1924   D->setPrivateCounters(Sub);
1925   Sub.clear();
1926   for (unsigned i = 0; i < CollapsedNum; ++i)
1927     Sub.push_back(Record.readSubExpr());
1928   D->setInits(Sub);
1929   Sub.clear();
1930   for (unsigned i = 0; i < CollapsedNum; ++i)
1931     Sub.push_back(Record.readSubExpr());
1932   D->setUpdates(Sub);
1933   Sub.clear();
1934   for (unsigned i = 0; i < CollapsedNum; ++i)
1935     Sub.push_back(Record.readSubExpr());
1936   D->setFinals(Sub);
1937 }
1938 
1939 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
1940   VisitStmt(D);
1941   // The NumClauses field was read in ReadStmtFromStream.
1942   Record.skipInts(1);
1943   VisitOMPExecutableDirective(D);
1944   D->setHasCancel(Record.readInt());
1945 }
1946 
1947 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
1948   VisitOMPLoopDirective(D);
1949 }
1950 
1951 void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
1952   VisitOMPLoopDirective(D);
1953   D->setHasCancel(Record.readInt());
1954 }
1955 
1956 void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
1957   VisitOMPLoopDirective(D);
1958 }
1959 
1960 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
1961   VisitStmt(D);
1962   // The NumClauses field was read in ReadStmtFromStream.
1963   Record.skipInts(1);
1964   VisitOMPExecutableDirective(D);
1965   D->setHasCancel(Record.readInt());
1966 }
1967 
1968 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
1969   VisitStmt(D);
1970   VisitOMPExecutableDirective(D);
1971   D->setHasCancel(Record.readInt());
1972 }
1973 
1974 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
1975   VisitStmt(D);
1976   // The NumClauses field was read in ReadStmtFromStream.
1977   Record.skipInts(1);
1978   VisitOMPExecutableDirective(D);
1979 }
1980 
1981 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
1982   VisitStmt(D);
1983   VisitOMPExecutableDirective(D);
1984 }
1985 
1986 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
1987   VisitStmt(D);
1988   // The NumClauses field was read in ReadStmtFromStream.
1989   Record.skipInts(1);
1990   VisitOMPExecutableDirective(D);
1991   ReadDeclarationNameInfo(D->DirName);
1992 }
1993 
1994 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
1995   VisitOMPLoopDirective(D);
1996   D->setHasCancel(Record.readInt());
1997 }
1998 
1999 void ASTStmtReader::VisitOMPParallelForSimdDirective(
2000     OMPParallelForSimdDirective *D) {
2001   VisitOMPLoopDirective(D);
2002 }
2003 
2004 void ASTStmtReader::VisitOMPParallelSectionsDirective(
2005     OMPParallelSectionsDirective *D) {
2006   VisitStmt(D);
2007   // The NumClauses field was read in ReadStmtFromStream.
2008   Record.skipInts(1);
2009   VisitOMPExecutableDirective(D);
2010   D->setHasCancel(Record.readInt());
2011 }
2012 
2013 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2014   VisitStmt(D);
2015   // The NumClauses field was read in ReadStmtFromStream.
2016   Record.skipInts(1);
2017   VisitOMPExecutableDirective(D);
2018   D->setHasCancel(Record.readInt());
2019 }
2020 
2021 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2022   VisitStmt(D);
2023   VisitOMPExecutableDirective(D);
2024 }
2025 
2026 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2027   VisitStmt(D);
2028   VisitOMPExecutableDirective(D);
2029 }
2030 
2031 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2032   VisitStmt(D);
2033   VisitOMPExecutableDirective(D);
2034 }
2035 
2036 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2037   VisitStmt(D);
2038   // The NumClauses field was read in ReadStmtFromStream.
2039   Record.skipInts(1);
2040   VisitOMPExecutableDirective(D);
2041   D->setReductionRef(Record.readSubExpr());
2042 }
2043 
2044 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2045   VisitStmt(D);
2046   // The NumClauses field was read in ReadStmtFromStream.
2047   Record.skipInts(1);
2048   VisitOMPExecutableDirective(D);
2049 }
2050 
2051 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2052   VisitStmt(D);
2053   // The NumClauses field was read in ReadStmtFromStream.
2054   Record.skipInts(1);
2055   VisitOMPExecutableDirective(D);
2056 }
2057 
2058 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2059   VisitStmt(D);
2060   // The NumClauses field was read in ReadStmtFromStream.
2061   Record.skipInts(1);
2062   VisitOMPExecutableDirective(D);
2063   D->setX(Record.readSubExpr());
2064   D->setV(Record.readSubExpr());
2065   D->setExpr(Record.readSubExpr());
2066   D->setUpdateExpr(Record.readSubExpr());
2067   D->IsXLHSInRHSPart = Record.readInt() != 0;
2068   D->IsPostfixUpdate = Record.readInt() != 0;
2069 }
2070 
2071 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2072   VisitStmt(D);
2073   // The NumClauses field was read in ReadStmtFromStream.
2074   Record.skipInts(1);
2075   VisitOMPExecutableDirective(D);
2076 }
2077 
2078 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2079   VisitStmt(D);
2080   Record.skipInts(1);
2081   VisitOMPExecutableDirective(D);
2082 }
2083 
2084 void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2085     OMPTargetEnterDataDirective *D) {
2086   VisitStmt(D);
2087   Record.skipInts(1);
2088   VisitOMPExecutableDirective(D);
2089 }
2090 
2091 void ASTStmtReader::VisitOMPTargetExitDataDirective(
2092     OMPTargetExitDataDirective *D) {
2093   VisitStmt(D);
2094   Record.skipInts(1);
2095   VisitOMPExecutableDirective(D);
2096 }
2097 
2098 void ASTStmtReader::VisitOMPTargetParallelDirective(
2099     OMPTargetParallelDirective *D) {
2100   VisitStmt(D);
2101   Record.skipInts(1);
2102   VisitOMPExecutableDirective(D);
2103 }
2104 
2105 void ASTStmtReader::VisitOMPTargetParallelForDirective(
2106     OMPTargetParallelForDirective *D) {
2107   VisitOMPLoopDirective(D);
2108   D->setHasCancel(Record.readInt());
2109 }
2110 
2111 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2112   VisitStmt(D);
2113   // The NumClauses field was read in ReadStmtFromStream.
2114   Record.skipInts(1);
2115   VisitOMPExecutableDirective(D);
2116 }
2117 
2118 void ASTStmtReader::VisitOMPCancellationPointDirective(
2119     OMPCancellationPointDirective *D) {
2120   VisitStmt(D);
2121   VisitOMPExecutableDirective(D);
2122   D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2123 }
2124 
2125 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2126   VisitStmt(D);
2127   // The NumClauses field was read in ReadStmtFromStream.
2128   Record.skipInts(1);
2129   VisitOMPExecutableDirective(D);
2130   D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2131 }
2132 
2133 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2134   VisitOMPLoopDirective(D);
2135 }
2136 
2137 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2138   VisitOMPLoopDirective(D);
2139 }
2140 
2141 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2142   VisitOMPLoopDirective(D);
2143 }
2144 
2145 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2146   VisitStmt(D);
2147   Record.skipInts(1);
2148   VisitOMPExecutableDirective(D);
2149 }
2150 
2151 void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2152     OMPDistributeParallelForDirective *D) {
2153   VisitOMPLoopDirective(D);
2154   D->setHasCancel(Record.readInt());
2155 }
2156 
2157 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2158     OMPDistributeParallelForSimdDirective *D) {
2159   VisitOMPLoopDirective(D);
2160 }
2161 
2162 void ASTStmtReader::VisitOMPDistributeSimdDirective(
2163     OMPDistributeSimdDirective *D) {
2164   VisitOMPLoopDirective(D);
2165 }
2166 
2167 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2168     OMPTargetParallelForSimdDirective *D) {
2169   VisitOMPLoopDirective(D);
2170 }
2171 
2172 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2173   VisitOMPLoopDirective(D);
2174 }
2175 
2176 void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2177     OMPTeamsDistributeDirective *D) {
2178   VisitOMPLoopDirective(D);
2179 }
2180 
2181 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2182     OMPTeamsDistributeSimdDirective *D) {
2183   VisitOMPLoopDirective(D);
2184 }
2185 
2186 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2187     OMPTeamsDistributeParallelForSimdDirective *D) {
2188   VisitOMPLoopDirective(D);
2189 }
2190 
2191 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2192     OMPTeamsDistributeParallelForDirective *D) {
2193   VisitOMPLoopDirective(D);
2194   D->setHasCancel(Record.readInt());
2195 }
2196 
2197 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2198   VisitStmt(D);
2199   // The NumClauses field was read in ReadStmtFromStream.
2200   Record.skipInts(1);
2201   VisitOMPExecutableDirective(D);
2202 }
2203 
2204 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2205     OMPTargetTeamsDistributeDirective *D) {
2206   VisitOMPLoopDirective(D);
2207 }
2208 
2209 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2210     OMPTargetTeamsDistributeParallelForDirective *D) {
2211   VisitOMPLoopDirective(D);
2212   D->setHasCancel(Record.readInt());
2213 }
2214 
2215 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2216     OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2217   VisitOMPLoopDirective(D);
2218 }
2219 
2220 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2221     OMPTargetTeamsDistributeSimdDirective *D) {
2222   VisitOMPLoopDirective(D);
2223 }
2224 
2225 //===----------------------------------------------------------------------===//
2226 // ASTReader Implementation
2227 //===----------------------------------------------------------------------===//
2228 
2229 Stmt *ASTReader::ReadStmt(ModuleFile &F) {
2230   switch (ReadingKind) {
2231   case Read_None:
2232     llvm_unreachable("should not call this when not reading anything");
2233   case Read_Decl:
2234   case Read_Type:
2235     return ReadStmtFromStream(F);
2236   case Read_Stmt:
2237     return ReadSubStmt();
2238   }
2239 
2240   llvm_unreachable("ReadingKind not set ?");
2241 }
2242 
2243 Expr *ASTReader::ReadExpr(ModuleFile &F) {
2244   return cast_or_null<Expr>(ReadStmt(F));
2245 }
2246 
2247 Expr *ASTReader::ReadSubExpr() {
2248   return cast_or_null<Expr>(ReadSubStmt());
2249 }
2250 
2251 // Within the bitstream, expressions are stored in Reverse Polish
2252 // Notation, with each of the subexpressions preceding the
2253 // expression they are stored in. Subexpressions are stored from last to first.
2254 // To evaluate expressions, we continue reading expressions and placing them on
2255 // the stack, with expressions having operands removing those operands from the
2256 // stack. Evaluation terminates when we see a STMT_STOP record, and
2257 // the single remaining expression on the stack is our result.
2258 Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
2259   ReadingKindTracker ReadingKind(Read_Stmt, *this);
2260   llvm::BitstreamCursor &Cursor = F.DeclsCursor;
2261 
2262   // Map of offset to previously deserialized stmt. The offset points
2263   // just after the stmt record.
2264   llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
2265 
2266 #ifndef NDEBUG
2267   unsigned PrevNumStmts = StmtStack.size();
2268 #endif
2269 
2270   ASTRecordReader Record(*this, F);
2271   ASTStmtReader Reader(Record, Cursor);
2272   Stmt::EmptyShell Empty;
2273 
2274   while (true) {
2275     llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
2276 
2277     switch (Entry.Kind) {
2278     case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2279     case llvm::BitstreamEntry::Error:
2280       Error("malformed block record in AST file");
2281       return nullptr;
2282     case llvm::BitstreamEntry::EndBlock:
2283       goto Done;
2284     case llvm::BitstreamEntry::Record:
2285       // The interesting case.
2286       break;
2287     }
2288 
2289     ASTContext &Context = getContext();
2290     Stmt *S = nullptr;
2291     bool Finished = false;
2292     bool IsStmtReference = false;
2293     switch ((StmtCode)Record.readRecord(Cursor, Entry.ID)) {
2294     case STMT_STOP:
2295       Finished = true;
2296       break;
2297 
2298     case STMT_REF_PTR:
2299       IsStmtReference = true;
2300       assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2301              "No stmt was recorded for this offset reference!");
2302       S = StmtEntries[Record.readInt()];
2303       break;
2304 
2305     case STMT_NULL_PTR:
2306       S = nullptr;
2307       break;
2308 
2309     case STMT_NULL:
2310       S = new (Context) NullStmt(Empty);
2311       break;
2312 
2313     case STMT_COMPOUND:
2314       S = CompoundStmt::CreateEmpty(
2315           Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
2316       break;
2317 
2318     case STMT_CASE:
2319       S = CaseStmt::CreateEmpty(
2320           Context,
2321           /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
2322       break;
2323 
2324     case STMT_DEFAULT:
2325       S = new (Context) DefaultStmt(Empty);
2326       break;
2327 
2328     case STMT_LABEL:
2329       S = new (Context) LabelStmt(Empty);
2330       break;
2331 
2332     case STMT_ATTRIBUTED:
2333       S = AttributedStmt::CreateEmpty(
2334         Context,
2335         /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
2336       break;
2337 
2338     case STMT_IF:
2339       S = IfStmt::CreateEmpty(
2340           Context,
2341           /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2342           /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2343           /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
2344       break;
2345 
2346     case STMT_SWITCH:
2347       S = SwitchStmt::CreateEmpty(
2348           Context,
2349           /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 0],
2350           /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
2351       break;
2352 
2353     case STMT_WHILE:
2354       S = WhileStmt::CreateEmpty(
2355           Context,
2356           /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 0]);
2357       break;
2358 
2359     case STMT_DO:
2360       S = new (Context) DoStmt(Empty);
2361       break;
2362 
2363     case STMT_FOR:
2364       S = new (Context) ForStmt(Empty);
2365       break;
2366 
2367     case STMT_GOTO:
2368       S = new (Context) GotoStmt(Empty);
2369       break;
2370 
2371     case STMT_INDIRECT_GOTO:
2372       S = new (Context) IndirectGotoStmt(Empty);
2373       break;
2374 
2375     case STMT_CONTINUE:
2376       S = new (Context) ContinueStmt(Empty);
2377       break;
2378 
2379     case STMT_BREAK:
2380       S = new (Context) BreakStmt(Empty);
2381       break;
2382 
2383     case STMT_RETURN:
2384       S = ReturnStmt::CreateEmpty(
2385           Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
2386       break;
2387 
2388     case STMT_DECL:
2389       S = new (Context) DeclStmt(Empty);
2390       break;
2391 
2392     case STMT_GCCASM:
2393       S = new (Context) GCCAsmStmt(Empty);
2394       break;
2395 
2396     case STMT_MSASM:
2397       S = new (Context) MSAsmStmt(Empty);
2398       break;
2399 
2400     case STMT_CAPTURED:
2401       S = CapturedStmt::CreateDeserialized(
2402           Context, Record[ASTStmtReader::NumStmtFields]);
2403       break;
2404 
2405     case EXPR_CONSTANT:
2406       S = new (Context) ConstantExpr(Empty);
2407       break;
2408 
2409     case EXPR_PREDEFINED:
2410       S = PredefinedExpr::CreateEmpty(
2411           Context,
2412           /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
2413       break;
2414 
2415     case EXPR_DECL_REF:
2416       S = DeclRefExpr::CreateEmpty(
2417         Context,
2418         /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2419         /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
2420         /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
2421         /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
2422           Record[ASTStmtReader::NumExprFields + 5] : 0);
2423       break;
2424 
2425     case EXPR_INTEGER_LITERAL:
2426       S = IntegerLiteral::Create(Context, Empty);
2427       break;
2428 
2429     case EXPR_FLOATING_LITERAL:
2430       S = FloatingLiteral::Create(Context, Empty);
2431       break;
2432 
2433     case EXPR_IMAGINARY_LITERAL:
2434       S = new (Context) ImaginaryLiteral(Empty);
2435       break;
2436 
2437     case EXPR_STRING_LITERAL:
2438       S = StringLiteral::CreateEmpty(
2439           Context,
2440           /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields + 0],
2441           /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2442           /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
2443       break;
2444 
2445     case EXPR_CHARACTER_LITERAL:
2446       S = new (Context) CharacterLiteral(Empty);
2447       break;
2448 
2449     case EXPR_PAREN:
2450       S = new (Context) ParenExpr(Empty);
2451       break;
2452 
2453     case EXPR_PAREN_LIST:
2454       S = ParenListExpr::CreateEmpty(
2455           Context,
2456           /* NumExprs=*/Record[ASTStmtReader::NumExprFields + 0]);
2457       break;
2458 
2459     case EXPR_UNARY_OPERATOR:
2460       S = new (Context) UnaryOperator(Empty);
2461       break;
2462 
2463     case EXPR_OFFSETOF:
2464       S = OffsetOfExpr::CreateEmpty(Context,
2465                                     Record[ASTStmtReader::NumExprFields],
2466                                     Record[ASTStmtReader::NumExprFields + 1]);
2467       break;
2468 
2469     case EXPR_SIZEOF_ALIGN_OF:
2470       S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
2471       break;
2472 
2473     case EXPR_ARRAY_SUBSCRIPT:
2474       S = new (Context) ArraySubscriptExpr(Empty);
2475       break;
2476 
2477     case EXPR_OMP_ARRAY_SECTION:
2478       S = new (Context) OMPArraySectionExpr(Empty);
2479       break;
2480 
2481     case EXPR_CALL:
2482       S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
2483       break;
2484 
2485     case EXPR_MEMBER: {
2486       // We load everything here and fully initialize it at creation.
2487       // That way we can use MemberExpr::Create and don't have to duplicate its
2488       // logic with a MemberExpr::CreateEmpty.
2489 
2490       assert(Record.getIdx() == 0);
2491       NestedNameSpecifierLoc QualifierLoc;
2492       if (Record.readInt()) { // HasQualifier.
2493         QualifierLoc = Record.readNestedNameSpecifierLoc();
2494       }
2495 
2496       SourceLocation TemplateKWLoc;
2497       TemplateArgumentListInfo ArgInfo;
2498       bool HasTemplateKWAndArgsInfo = Record.readInt();
2499       if (HasTemplateKWAndArgsInfo) {
2500         TemplateKWLoc = Record.readSourceLocation();
2501         unsigned NumTemplateArgs = Record.readInt();
2502         ArgInfo.setLAngleLoc(Record.readSourceLocation());
2503         ArgInfo.setRAngleLoc(Record.readSourceLocation());
2504         for (unsigned i = 0; i != NumTemplateArgs; ++i)
2505           ArgInfo.addArgument(Record.readTemplateArgumentLoc());
2506       }
2507 
2508       bool HadMultipleCandidates = Record.readInt();
2509 
2510       auto *FoundD = Record.readDeclAs<NamedDecl>();
2511       auto AS = (AccessSpecifier)Record.readInt();
2512       DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
2513 
2514       QualType T = Record.readType();
2515       auto VK = static_cast<ExprValueKind>(Record.readInt());
2516       auto OK = static_cast<ExprObjectKind>(Record.readInt());
2517       Expr *Base = ReadSubExpr();
2518       auto *MemberD = Record.readDeclAs<ValueDecl>();
2519       SourceLocation MemberLoc = Record.readSourceLocation();
2520       DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
2521       bool IsArrow = Record.readInt();
2522       SourceLocation OperatorLoc = Record.readSourceLocation();
2523 
2524       S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc,
2525                              TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
2526                              HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T,
2527                              VK, OK);
2528       Record.readDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc,
2529                                     MemberD->getDeclName());
2530       if (HadMultipleCandidates)
2531         cast<MemberExpr>(S)->setHadMultipleCandidates(true);
2532       break;
2533     }
2534 
2535     case EXPR_BINARY_OPERATOR:
2536       S = new (Context) BinaryOperator(Empty);
2537       break;
2538 
2539     case EXPR_COMPOUND_ASSIGN_OPERATOR:
2540       S = new (Context) CompoundAssignOperator(Empty);
2541       break;
2542 
2543     case EXPR_CONDITIONAL_OPERATOR:
2544       S = new (Context) ConditionalOperator(Empty);
2545       break;
2546 
2547     case EXPR_BINARY_CONDITIONAL_OPERATOR:
2548       S = new (Context) BinaryConditionalOperator(Empty);
2549       break;
2550 
2551     case EXPR_IMPLICIT_CAST:
2552       S = ImplicitCastExpr::CreateEmpty(Context,
2553                        /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2554       break;
2555 
2556     case EXPR_CSTYLE_CAST:
2557       S = CStyleCastExpr::CreateEmpty(Context,
2558                        /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2559       break;
2560 
2561     case EXPR_COMPOUND_LITERAL:
2562       S = new (Context) CompoundLiteralExpr(Empty);
2563       break;
2564 
2565     case EXPR_EXT_VECTOR_ELEMENT:
2566       S = new (Context) ExtVectorElementExpr(Empty);
2567       break;
2568 
2569     case EXPR_INIT_LIST:
2570       S = new (Context) InitListExpr(Empty);
2571       break;
2572 
2573     case EXPR_DESIGNATED_INIT:
2574       S = DesignatedInitExpr::CreateEmpty(Context,
2575                                      Record[ASTStmtReader::NumExprFields] - 1);
2576 
2577       break;
2578 
2579     case EXPR_DESIGNATED_INIT_UPDATE:
2580       S = new (Context) DesignatedInitUpdateExpr(Empty);
2581       break;
2582 
2583     case EXPR_IMPLICIT_VALUE_INIT:
2584       S = new (Context) ImplicitValueInitExpr(Empty);
2585       break;
2586 
2587     case EXPR_NO_INIT:
2588       S = new (Context) NoInitExpr(Empty);
2589       break;
2590 
2591     case EXPR_ARRAY_INIT_LOOP:
2592       S = new (Context) ArrayInitLoopExpr(Empty);
2593       break;
2594 
2595     case EXPR_ARRAY_INIT_INDEX:
2596       S = new (Context) ArrayInitIndexExpr(Empty);
2597       break;
2598 
2599     case EXPR_VA_ARG:
2600       S = new (Context) VAArgExpr(Empty);
2601       break;
2602 
2603     case EXPR_ADDR_LABEL:
2604       S = new (Context) AddrLabelExpr(Empty);
2605       break;
2606 
2607     case EXPR_STMT:
2608       S = new (Context) StmtExpr(Empty);
2609       break;
2610 
2611     case EXPR_CHOOSE:
2612       S = new (Context) ChooseExpr(Empty);
2613       break;
2614 
2615     case EXPR_GNU_NULL:
2616       S = new (Context) GNUNullExpr(Empty);
2617       break;
2618 
2619     case EXPR_SHUFFLE_VECTOR:
2620       S = new (Context) ShuffleVectorExpr(Empty);
2621       break;
2622 
2623     case EXPR_CONVERT_VECTOR:
2624       S = new (Context) ConvertVectorExpr(Empty);
2625       break;
2626 
2627     case EXPR_BLOCK:
2628       S = new (Context) BlockExpr(Empty);
2629       break;
2630 
2631     case EXPR_GENERIC_SELECTION:
2632       S = new (Context) GenericSelectionExpr(Empty);
2633       break;
2634 
2635     case EXPR_OBJC_STRING_LITERAL:
2636       S = new (Context) ObjCStringLiteral(Empty);
2637       break;
2638 
2639     case EXPR_OBJC_BOXED_EXPRESSION:
2640       S = new (Context) ObjCBoxedExpr(Empty);
2641       break;
2642 
2643     case EXPR_OBJC_ARRAY_LITERAL:
2644       S = ObjCArrayLiteral::CreateEmpty(Context,
2645                                         Record[ASTStmtReader::NumExprFields]);
2646       break;
2647 
2648     case EXPR_OBJC_DICTIONARY_LITERAL:
2649       S = ObjCDictionaryLiteral::CreateEmpty(Context,
2650             Record[ASTStmtReader::NumExprFields],
2651             Record[ASTStmtReader::NumExprFields + 1]);
2652       break;
2653 
2654     case EXPR_OBJC_ENCODE:
2655       S = new (Context) ObjCEncodeExpr(Empty);
2656       break;
2657 
2658     case EXPR_OBJC_SELECTOR_EXPR:
2659       S = new (Context) ObjCSelectorExpr(Empty);
2660       break;
2661 
2662     case EXPR_OBJC_PROTOCOL_EXPR:
2663       S = new (Context) ObjCProtocolExpr(Empty);
2664       break;
2665 
2666     case EXPR_OBJC_IVAR_REF_EXPR:
2667       S = new (Context) ObjCIvarRefExpr(Empty);
2668       break;
2669 
2670     case EXPR_OBJC_PROPERTY_REF_EXPR:
2671       S = new (Context) ObjCPropertyRefExpr(Empty);
2672       break;
2673 
2674     case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2675       S = new (Context) ObjCSubscriptRefExpr(Empty);
2676       break;
2677 
2678     case EXPR_OBJC_KVC_REF_EXPR:
2679       llvm_unreachable("mismatching AST file");
2680 
2681     case EXPR_OBJC_MESSAGE_EXPR:
2682       S = ObjCMessageExpr::CreateEmpty(Context,
2683                                      Record[ASTStmtReader::NumExprFields],
2684                                      Record[ASTStmtReader::NumExprFields + 1]);
2685       break;
2686 
2687     case EXPR_OBJC_ISA:
2688       S = new (Context) ObjCIsaExpr(Empty);
2689       break;
2690 
2691     case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2692       S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2693       break;
2694 
2695     case EXPR_OBJC_BRIDGED_CAST:
2696       S = new (Context) ObjCBridgedCastExpr(Empty);
2697       break;
2698 
2699     case STMT_OBJC_FOR_COLLECTION:
2700       S = new (Context) ObjCForCollectionStmt(Empty);
2701       break;
2702 
2703     case STMT_OBJC_CATCH:
2704       S = new (Context) ObjCAtCatchStmt(Empty);
2705       break;
2706 
2707     case STMT_OBJC_FINALLY:
2708       S = new (Context) ObjCAtFinallyStmt(Empty);
2709       break;
2710 
2711     case STMT_OBJC_AT_TRY:
2712       S = ObjCAtTryStmt::CreateEmpty(Context,
2713                                      Record[ASTStmtReader::NumStmtFields],
2714                                      Record[ASTStmtReader::NumStmtFields + 1]);
2715       break;
2716 
2717     case STMT_OBJC_AT_SYNCHRONIZED:
2718       S = new (Context) ObjCAtSynchronizedStmt(Empty);
2719       break;
2720 
2721     case STMT_OBJC_AT_THROW:
2722       S = new (Context) ObjCAtThrowStmt(Empty);
2723       break;
2724 
2725     case STMT_OBJC_AUTORELEASE_POOL:
2726       S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2727       break;
2728 
2729     case EXPR_OBJC_BOOL_LITERAL:
2730       S = new (Context) ObjCBoolLiteralExpr(Empty);
2731       break;
2732 
2733     case EXPR_OBJC_AVAILABILITY_CHECK:
2734       S = new (Context) ObjCAvailabilityCheckExpr(Empty);
2735       break;
2736 
2737     case STMT_SEH_LEAVE:
2738       S = new (Context) SEHLeaveStmt(Empty);
2739       break;
2740 
2741     case STMT_SEH_EXCEPT:
2742       S = new (Context) SEHExceptStmt(Empty);
2743       break;
2744 
2745     case STMT_SEH_FINALLY:
2746       S = new (Context) SEHFinallyStmt(Empty);
2747       break;
2748 
2749     case STMT_SEH_TRY:
2750       S = new (Context) SEHTryStmt(Empty);
2751       break;
2752 
2753     case STMT_CXX_CATCH:
2754       S = new (Context) CXXCatchStmt(Empty);
2755       break;
2756 
2757     case STMT_CXX_TRY:
2758       S = CXXTryStmt::Create(Context, Empty,
2759              /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
2760       break;
2761 
2762     case STMT_CXX_FOR_RANGE:
2763       S = new (Context) CXXForRangeStmt(Empty);
2764       break;
2765 
2766     case STMT_MS_DEPENDENT_EXISTS:
2767       S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2768                                               NestedNameSpecifierLoc(),
2769                                               DeclarationNameInfo(),
2770                                               nullptr);
2771       break;
2772 
2773     case STMT_OMP_PARALLEL_DIRECTIVE:
2774       S =
2775         OMPParallelDirective::CreateEmpty(Context,
2776                                           Record[ASTStmtReader::NumStmtFields],
2777                                           Empty);
2778       break;
2779 
2780     case STMT_OMP_SIMD_DIRECTIVE: {
2781       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2782       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2783       S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
2784                                         CollapsedNum, Empty);
2785       break;
2786     }
2787 
2788     case STMT_OMP_FOR_DIRECTIVE: {
2789       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2790       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2791       S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2792                                        Empty);
2793       break;
2794     }
2795 
2796     case STMT_OMP_FOR_SIMD_DIRECTIVE: {
2797       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2798       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2799       S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2800                                            Empty);
2801       break;
2802     }
2803 
2804     case STMT_OMP_SECTIONS_DIRECTIVE:
2805       S = OMPSectionsDirective::CreateEmpty(
2806           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2807       break;
2808 
2809     case STMT_OMP_SECTION_DIRECTIVE:
2810       S = OMPSectionDirective::CreateEmpty(Context, Empty);
2811       break;
2812 
2813     case STMT_OMP_SINGLE_DIRECTIVE:
2814       S = OMPSingleDirective::CreateEmpty(
2815           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2816       break;
2817 
2818     case STMT_OMP_MASTER_DIRECTIVE:
2819       S = OMPMasterDirective::CreateEmpty(Context, Empty);
2820       break;
2821 
2822     case STMT_OMP_CRITICAL_DIRECTIVE:
2823       S = OMPCriticalDirective::CreateEmpty(
2824           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2825       break;
2826 
2827     case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
2828       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2829       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2830       S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
2831                                                CollapsedNum, Empty);
2832       break;
2833     }
2834 
2835     case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
2836       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2837       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2838       S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2839                                                    CollapsedNum, Empty);
2840       break;
2841     }
2842 
2843     case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
2844       S = OMPParallelSectionsDirective::CreateEmpty(
2845           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2846       break;
2847 
2848     case STMT_OMP_TASK_DIRECTIVE:
2849       S = OMPTaskDirective::CreateEmpty(
2850           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2851       break;
2852 
2853     case STMT_OMP_TASKYIELD_DIRECTIVE:
2854       S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
2855       break;
2856 
2857     case STMT_OMP_BARRIER_DIRECTIVE:
2858       S = OMPBarrierDirective::CreateEmpty(Context, Empty);
2859       break;
2860 
2861     case STMT_OMP_TASKWAIT_DIRECTIVE:
2862       S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
2863       break;
2864 
2865     case STMT_OMP_TASKGROUP_DIRECTIVE:
2866       S = OMPTaskgroupDirective::CreateEmpty(
2867           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2868       break;
2869 
2870     case STMT_OMP_FLUSH_DIRECTIVE:
2871       S = OMPFlushDirective::CreateEmpty(
2872           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2873       break;
2874 
2875     case STMT_OMP_ORDERED_DIRECTIVE:
2876       S = OMPOrderedDirective::CreateEmpty(
2877           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2878       break;
2879 
2880     case STMT_OMP_ATOMIC_DIRECTIVE:
2881       S = OMPAtomicDirective::CreateEmpty(
2882           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2883       break;
2884 
2885     case STMT_OMP_TARGET_DIRECTIVE:
2886       S = OMPTargetDirective::CreateEmpty(
2887           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2888       break;
2889 
2890     case STMT_OMP_TARGET_DATA_DIRECTIVE:
2891       S = OMPTargetDataDirective::CreateEmpty(
2892           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2893       break;
2894 
2895     case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
2896       S = OMPTargetEnterDataDirective::CreateEmpty(
2897           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2898       break;
2899 
2900     case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
2901       S = OMPTargetExitDataDirective::CreateEmpty(
2902           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2903       break;
2904 
2905     case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
2906       S = OMPTargetParallelDirective::CreateEmpty(
2907           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2908       break;
2909 
2910     case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
2911       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2912       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2913       S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
2914                                                      CollapsedNum, Empty);
2915       break;
2916     }
2917 
2918     case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
2919       S = OMPTargetUpdateDirective::CreateEmpty(
2920           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2921       break;
2922 
2923     case STMT_OMP_TEAMS_DIRECTIVE:
2924       S = OMPTeamsDirective::CreateEmpty(
2925           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2926       break;
2927 
2928     case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
2929       S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
2930       break;
2931 
2932     case STMT_OMP_CANCEL_DIRECTIVE:
2933       S = OMPCancelDirective::CreateEmpty(
2934           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2935       break;
2936 
2937     case STMT_OMP_TASKLOOP_DIRECTIVE: {
2938       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2939       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2940       S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2941                                             Empty);
2942       break;
2943     }
2944 
2945     case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
2946       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2947       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2948       S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
2949                                                 CollapsedNum, Empty);
2950       break;
2951     }
2952 
2953     case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
2954       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2955       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2956       S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2957                                               Empty);
2958       break;
2959     }
2960 
2961     case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
2962       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2963       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2964       S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
2965                                                          CollapsedNum, Empty);
2966       break;
2967     }
2968 
2969     case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
2970       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2971       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2972       S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2973                                                              CollapsedNum,
2974                                                              Empty);
2975       break;
2976     }
2977 
2978     case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
2979       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2980       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2981       S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
2982                                                   CollapsedNum, Empty);
2983       break;
2984     }
2985 
2986     case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
2987       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2988       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2989       S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2990                                                          CollapsedNum, Empty);
2991       break;
2992     }
2993 
2994     case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
2995       auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2996       auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2997       S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2998                                               Empty);
2999       break;
3000     }
3001 
3002      case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
3003       auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3004       auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3005       S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3006                                                    CollapsedNum, Empty);
3007       break;
3008     }
3009 
3010     case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3011       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3012       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3013       S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3014                                                        CollapsedNum, Empty);
3015       break;
3016     }
3017 
3018     case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3019       auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3020       auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3021       S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3022           Context, NumClauses, CollapsedNum, Empty);
3023       break;
3024     }
3025 
3026     case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3027       auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3028       auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3029       S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3030           Context, NumClauses, CollapsedNum, Empty);
3031       break;
3032     }
3033 
3034     case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
3035       S = OMPTargetTeamsDirective::CreateEmpty(
3036           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3037       break;
3038 
3039     case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3040       auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3041       auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3042       S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3043                                                          CollapsedNum, Empty);
3044       break;
3045     }
3046 
3047     case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3048       auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3049       auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3050       S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3051           Context, NumClauses, CollapsedNum, Empty);
3052       break;
3053     }
3054 
3055     case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3056       auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3057       auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3058       S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3059           Context, NumClauses, CollapsedNum, Empty);
3060       break;
3061     }
3062 
3063     case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3064       auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3065       auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3066       S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3067           Context, NumClauses, CollapsedNum, Empty);
3068       break;
3069     }
3070 
3071     case EXPR_CXX_OPERATOR_CALL:
3072       S = new (Context) CXXOperatorCallExpr(Context, Empty);
3073       break;
3074 
3075     case EXPR_CXX_MEMBER_CALL:
3076       S = new (Context) CXXMemberCallExpr(Context, Empty);
3077       break;
3078 
3079     case EXPR_CXX_CONSTRUCT:
3080       S = new (Context) CXXConstructExpr(Empty);
3081       break;
3082 
3083     case EXPR_CXX_INHERITED_CTOR_INIT:
3084       S = new (Context) CXXInheritedCtorInitExpr(Empty);
3085       break;
3086 
3087     case EXPR_CXX_TEMPORARY_OBJECT:
3088       S = new (Context) CXXTemporaryObjectExpr(Empty);
3089       break;
3090 
3091     case EXPR_CXX_STATIC_CAST:
3092       S = CXXStaticCastExpr::CreateEmpty(Context,
3093                        /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3094       break;
3095 
3096     case EXPR_CXX_DYNAMIC_CAST:
3097       S = CXXDynamicCastExpr::CreateEmpty(Context,
3098                        /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3099       break;
3100 
3101     case EXPR_CXX_REINTERPRET_CAST:
3102       S = CXXReinterpretCastExpr::CreateEmpty(Context,
3103                        /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3104       break;
3105 
3106     case EXPR_CXX_CONST_CAST:
3107       S = CXXConstCastExpr::CreateEmpty(Context);
3108       break;
3109 
3110     case EXPR_CXX_FUNCTIONAL_CAST:
3111       S = CXXFunctionalCastExpr::CreateEmpty(Context,
3112                        /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3113       break;
3114 
3115     case EXPR_USER_DEFINED_LITERAL:
3116       S = new (Context) UserDefinedLiteral(Context, Empty);
3117       break;
3118 
3119     case EXPR_CXX_STD_INITIALIZER_LIST:
3120       S = new (Context) CXXStdInitializerListExpr(Empty);
3121       break;
3122 
3123     case EXPR_CXX_BOOL_LITERAL:
3124       S = new (Context) CXXBoolLiteralExpr(Empty);
3125       break;
3126 
3127     case EXPR_CXX_NULL_PTR_LITERAL:
3128       S = new (Context) CXXNullPtrLiteralExpr(Empty);
3129       break;
3130 
3131     case EXPR_CXX_TYPEID_EXPR:
3132       S = new (Context) CXXTypeidExpr(Empty, true);
3133       break;
3134 
3135     case EXPR_CXX_TYPEID_TYPE:
3136       S = new (Context) CXXTypeidExpr(Empty, false);
3137       break;
3138 
3139     case EXPR_CXX_UUIDOF_EXPR:
3140       S = new (Context) CXXUuidofExpr(Empty, true);
3141       break;
3142 
3143     case EXPR_CXX_PROPERTY_REF_EXPR:
3144       S = new (Context) MSPropertyRefExpr(Empty);
3145       break;
3146 
3147     case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3148       S = new (Context) MSPropertySubscriptExpr(Empty);
3149       break;
3150 
3151     case EXPR_CXX_UUIDOF_TYPE:
3152       S = new (Context) CXXUuidofExpr(Empty, false);
3153       break;
3154 
3155     case EXPR_CXX_THIS:
3156       S = new (Context) CXXThisExpr(Empty);
3157       break;
3158 
3159     case EXPR_CXX_THROW:
3160       S = new (Context) CXXThrowExpr(Empty);
3161       break;
3162 
3163     case EXPR_CXX_DEFAULT_ARG:
3164       S = new (Context) CXXDefaultArgExpr(Empty);
3165       break;
3166 
3167     case EXPR_CXX_DEFAULT_INIT:
3168       S = new (Context) CXXDefaultInitExpr(Empty);
3169       break;
3170 
3171     case EXPR_CXX_BIND_TEMPORARY:
3172       S = new (Context) CXXBindTemporaryExpr(Empty);
3173       break;
3174 
3175     case EXPR_CXX_SCALAR_VALUE_INIT:
3176       S = new (Context) CXXScalarValueInitExpr(Empty);
3177       break;
3178 
3179     case EXPR_CXX_NEW:
3180       S = new (Context) CXXNewExpr(Empty);
3181       break;
3182 
3183     case EXPR_CXX_DELETE:
3184       S = new (Context) CXXDeleteExpr(Empty);
3185       break;
3186 
3187     case EXPR_CXX_PSEUDO_DESTRUCTOR:
3188       S = new (Context) CXXPseudoDestructorExpr(Empty);
3189       break;
3190 
3191     case EXPR_EXPR_WITH_CLEANUPS:
3192       S = ExprWithCleanups::Create(Context, Empty,
3193                                    Record[ASTStmtReader::NumExprFields]);
3194       break;
3195 
3196     case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
3197       S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
3198          /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3199                   /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3200                                    ? Record[ASTStmtReader::NumExprFields + 1]
3201                                    : 0);
3202       break;
3203 
3204     case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
3205       S = DependentScopeDeclRefExpr::CreateEmpty(Context,
3206          /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3207                   /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3208                                    ? Record[ASTStmtReader::NumExprFields + 1]
3209                                    : 0);
3210       break;
3211 
3212     case EXPR_CXX_UNRESOLVED_CONSTRUCT:
3213       S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
3214                               /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3215       break;
3216 
3217     case EXPR_CXX_UNRESOLVED_MEMBER:
3218       S = UnresolvedMemberExpr::CreateEmpty(Context,
3219          /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3220                   /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3221                                    ? Record[ASTStmtReader::NumExprFields + 1]
3222                                    : 0);
3223       break;
3224 
3225     case EXPR_CXX_UNRESOLVED_LOOKUP:
3226       S = UnresolvedLookupExpr::CreateEmpty(Context,
3227          /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3228                   /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3229                                    ? Record[ASTStmtReader::NumExprFields + 1]
3230                                    : 0);
3231       break;
3232 
3233     case EXPR_TYPE_TRAIT:
3234       S = TypeTraitExpr::CreateDeserialized(Context,
3235             Record[ASTStmtReader::NumExprFields]);
3236       break;
3237 
3238     case EXPR_ARRAY_TYPE_TRAIT:
3239       S = new (Context) ArrayTypeTraitExpr(Empty);
3240       break;
3241 
3242     case EXPR_CXX_EXPRESSION_TRAIT:
3243       S = new (Context) ExpressionTraitExpr(Empty);
3244       break;
3245 
3246     case EXPR_CXX_NOEXCEPT:
3247       S = new (Context) CXXNoexceptExpr(Empty);
3248       break;
3249 
3250     case EXPR_PACK_EXPANSION:
3251       S = new (Context) PackExpansionExpr(Empty);
3252       break;
3253 
3254     case EXPR_SIZEOF_PACK:
3255       S = SizeOfPackExpr::CreateDeserialized(
3256               Context,
3257               /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
3258       break;
3259 
3260     case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3261       S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3262       break;
3263 
3264     case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3265       S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3266       break;
3267 
3268     case EXPR_FUNCTION_PARM_PACK:
3269       S = FunctionParmPackExpr::CreateEmpty(Context,
3270                                           Record[ASTStmtReader::NumExprFields]);
3271       break;
3272 
3273     case EXPR_MATERIALIZE_TEMPORARY:
3274       S = new (Context) MaterializeTemporaryExpr(Empty);
3275       break;
3276 
3277     case EXPR_CXX_FOLD:
3278       S = new (Context) CXXFoldExpr(Empty);
3279       break;
3280 
3281     case EXPR_OPAQUE_VALUE:
3282       S = new (Context) OpaqueValueExpr(Empty);
3283       break;
3284 
3285     case EXPR_CUDA_KERNEL_CALL:
3286       S = new (Context) CUDAKernelCallExpr(Context, Empty);
3287       break;
3288 
3289     case EXPR_ASTYPE:
3290       S = new (Context) AsTypeExpr(Empty);
3291       break;
3292 
3293     case EXPR_PSEUDO_OBJECT: {
3294       unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3295       S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3296       break;
3297     }
3298 
3299     case EXPR_ATOMIC:
3300       S = new (Context) AtomicExpr(Empty);
3301       break;
3302 
3303     case EXPR_LAMBDA: {
3304       unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
3305       S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
3306       break;
3307     }
3308 
3309     case STMT_COROUTINE_BODY: {
3310       unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3311       S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3312       break;
3313     }
3314 
3315     case STMT_CORETURN:
3316       S = new (Context) CoreturnStmt(Empty);
3317       break;
3318 
3319     case EXPR_COAWAIT:
3320       S = new (Context) CoawaitExpr(Empty);
3321       break;
3322 
3323     case EXPR_COYIELD:
3324       S = new (Context) CoyieldExpr(Empty);
3325       break;
3326 
3327     case EXPR_DEPENDENT_COAWAIT:
3328       S = new (Context) DependentCoawaitExpr(Empty);
3329       break;
3330     }
3331 
3332     // We hit a STMT_STOP, so we're done with this expression.
3333     if (Finished)
3334       break;
3335 
3336     ++NumStatementsRead;
3337 
3338     if (S && !IsStmtReference) {
3339       Reader.Visit(S);
3340       StmtEntries[Cursor.GetCurrentBitNo()] = S;
3341     }
3342 
3343     assert(Record.getIdx() == Record.size() &&
3344            "Invalid deserialization of statement");
3345     StmtStack.push_back(S);
3346   }
3347 Done:
3348   assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
3349   assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
3350   return StmtStack.pop_back_val();
3351 }
3352