xref: /llvm-project/clang/lib/Serialization/ASTReaderStmt.cpp (revision abc8812df02599fc413d9ed77b992f8236ed2af9)
1 //===- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Statement/expression deserialization.  This implements the
10 // ASTReader::ReadStmt method.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/AST/ASTConcept.h"
15 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/AttrIterator.h"
17 #include "clang/AST/Decl.h"
18 #include "clang/AST/DeclAccessPair.h"
19 #include "clang/AST/DeclCXX.h"
20 #include "clang/AST/DeclGroup.h"
21 #include "clang/AST/DeclObjC.h"
22 #include "clang/AST/DeclTemplate.h"
23 #include "clang/AST/DeclarationName.h"
24 #include "clang/AST/DependenceFlags.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/StmtSYCL.h"
37 #include "clang/AST/StmtVisitor.h"
38 #include "clang/AST/TemplateBase.h"
39 #include "clang/AST/Type.h"
40 #include "clang/AST/UnresolvedSet.h"
41 #include "clang/Basic/CapturedStmt.h"
42 #include "clang/Basic/ExpressionTraits.h"
43 #include "clang/Basic/LLVM.h"
44 #include "clang/Basic/Lambda.h"
45 #include "clang/Basic/LangOptions.h"
46 #include "clang/Basic/OpenMPKinds.h"
47 #include "clang/Basic/OperatorKinds.h"
48 #include "clang/Basic/SourceLocation.h"
49 #include "clang/Basic/Specifiers.h"
50 #include "clang/Basic/TypeTraits.h"
51 #include "clang/Lex/Token.h"
52 #include "clang/Serialization/ASTBitCodes.h"
53 #include "clang/Serialization/ASTRecordReader.h"
54 #include "llvm/ADT/BitmaskEnum.h"
55 #include "llvm/ADT/DenseMap.h"
56 #include "llvm/ADT/SmallString.h"
57 #include "llvm/ADT/SmallVector.h"
58 #include "llvm/ADT/StringRef.h"
59 #include "llvm/Bitstream/BitstreamReader.h"
60 #include "llvm/Support/Casting.h"
61 #include "llvm/Support/ErrorHandling.h"
62 #include <algorithm>
63 #include <cassert>
64 #include <cstdint>
65 #include <optional>
66 #include <string>
67 
68 using namespace clang;
69 using namespace serialization;
70 
71 namespace clang {
72 
73   class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
74     ASTRecordReader &Record;
75     llvm::BitstreamCursor &DeclsCursor;
76 
77     std::optional<BitsUnpacker> CurrentUnpackingBits;
78 
79     SourceLocation readSourceLocation() {
80       return Record.readSourceLocation();
81     }
82 
83     SourceRange readSourceRange() {
84       return Record.readSourceRange();
85     }
86 
87     std::string readString() {
88       return Record.readString();
89     }
90 
91     TypeSourceInfo *readTypeSourceInfo() {
92       return Record.readTypeSourceInfo();
93     }
94 
95     Decl *readDecl() {
96       return Record.readDecl();
97     }
98 
99     template<typename T>
100     T *readDeclAs() {
101       return Record.readDeclAs<T>();
102     }
103 
104   public:
105     ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
106         : Record(Record), DeclsCursor(Cursor) {}
107 
108     /// The number of record fields required for the Stmt class
109     /// itself.
110     static const unsigned NumStmtFields = 0;
111 
112     /// The number of record fields required for the Expr class
113     /// itself.
114     static const unsigned NumExprFields = NumStmtFields + 2;
115 
116     /// The number of bits required for the packing bits for the Expr class.
117     static const unsigned NumExprBits = 10;
118 
119     /// Read and initialize a ExplicitTemplateArgumentList structure.
120     void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
121                                    TemplateArgumentLoc *ArgsLocArray,
122                                    unsigned NumTemplateArgs);
123 
124     void VisitStmt(Stmt *S);
125 #define STMT(Type, Base) \
126     void Visit##Type(Type *);
127 #include "clang/AST/StmtNodes.inc"
128   };
129 
130 } // namespace clang
131 
132 void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
133                                               TemplateArgumentLoc *ArgsLocArray,
134                                               unsigned NumTemplateArgs) {
135   SourceLocation TemplateKWLoc = readSourceLocation();
136   TemplateArgumentListInfo ArgInfo;
137   ArgInfo.setLAngleLoc(readSourceLocation());
138   ArgInfo.setRAngleLoc(readSourceLocation());
139   for (unsigned i = 0; i != NumTemplateArgs; ++i)
140     ArgInfo.addArgument(Record.readTemplateArgumentLoc());
141   Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
142 }
143 
144 void ASTStmtReader::VisitStmt(Stmt *S) {
145   assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
146 }
147 
148 void ASTStmtReader::VisitNullStmt(NullStmt *S) {
149   VisitStmt(S);
150   S->setSemiLoc(readSourceLocation());
151   S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
152 }
153 
154 void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
155   VisitStmt(S);
156   SmallVector<Stmt *, 16> Stmts;
157   unsigned NumStmts = Record.readInt();
158   unsigned HasFPFeatures = Record.readInt();
159   assert(S->hasStoredFPFeatures() == HasFPFeatures);
160   while (NumStmts--)
161     Stmts.push_back(Record.readSubStmt());
162   S->setStmts(Stmts);
163   if (HasFPFeatures)
164     S->setStoredFPFeatures(
165         FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
166   S->LBraceLoc = readSourceLocation();
167   S->RBraceLoc = readSourceLocation();
168 }
169 
170 void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
171   VisitStmt(S);
172   Record.recordSwitchCaseID(S, Record.readInt());
173   S->setKeywordLoc(readSourceLocation());
174   S->setColonLoc(readSourceLocation());
175 }
176 
177 void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
178   VisitSwitchCase(S);
179   bool CaseStmtIsGNURange = Record.readInt();
180   S->setLHS(Record.readSubExpr());
181   S->setSubStmt(Record.readSubStmt());
182   if (CaseStmtIsGNURange) {
183     S->setRHS(Record.readSubExpr());
184     S->setEllipsisLoc(readSourceLocation());
185   }
186 }
187 
188 void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
189   VisitSwitchCase(S);
190   S->setSubStmt(Record.readSubStmt());
191 }
192 
193 void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
194   VisitStmt(S);
195   bool IsSideEntry = Record.readInt();
196   auto *LD = readDeclAs<LabelDecl>();
197   LD->setStmt(S);
198   S->setDecl(LD);
199   S->setSubStmt(Record.readSubStmt());
200   S->setIdentLoc(readSourceLocation());
201   S->setSideEntry(IsSideEntry);
202 }
203 
204 void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
205   VisitStmt(S);
206   // NumAttrs in AttributedStmt is set when creating an empty
207   // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
208   // to allocate the right amount of space for the trailing Attr *.
209   uint64_t NumAttrs = Record.readInt();
210   AttrVec Attrs;
211   Record.readAttributes(Attrs);
212   (void)NumAttrs;
213   assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
214   assert(NumAttrs == Attrs.size());
215   std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
216   S->SubStmt = Record.readSubStmt();
217   S->AttributedStmtBits.AttrLoc = readSourceLocation();
218 }
219 
220 void ASTStmtReader::VisitIfStmt(IfStmt *S) {
221   VisitStmt(S);
222 
223   CurrentUnpackingBits.emplace(Record.readInt());
224 
225   bool HasElse = CurrentUnpackingBits->getNextBit();
226   bool HasVar = CurrentUnpackingBits->getNextBit();
227   bool HasInit = CurrentUnpackingBits->getNextBit();
228 
229   S->setStatementKind(static_cast<IfStatementKind>(Record.readInt()));
230   S->setCond(Record.readSubExpr());
231   S->setThen(Record.readSubStmt());
232   if (HasElse)
233     S->setElse(Record.readSubStmt());
234   if (HasVar)
235     S->setConditionVariableDeclStmt(cast<DeclStmt>(Record.readSubStmt()));
236   if (HasInit)
237     S->setInit(Record.readSubStmt());
238 
239   S->setIfLoc(readSourceLocation());
240   S->setLParenLoc(readSourceLocation());
241   S->setRParenLoc(readSourceLocation());
242   if (HasElse)
243     S->setElseLoc(readSourceLocation());
244 }
245 
246 void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
247   VisitStmt(S);
248 
249   bool HasInit = Record.readInt();
250   bool HasVar = Record.readInt();
251   bool AllEnumCasesCovered = Record.readInt();
252   if (AllEnumCasesCovered)
253     S->setAllEnumCasesCovered();
254 
255   S->setCond(Record.readSubExpr());
256   S->setBody(Record.readSubStmt());
257   if (HasInit)
258     S->setInit(Record.readSubStmt());
259   if (HasVar)
260     S->setConditionVariableDeclStmt(cast<DeclStmt>(Record.readSubStmt()));
261 
262   S->setSwitchLoc(readSourceLocation());
263   S->setLParenLoc(readSourceLocation());
264   S->setRParenLoc(readSourceLocation());
265 
266   SwitchCase *PrevSC = nullptr;
267   for (auto E = Record.size(); Record.getIdx() != E; ) {
268     SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
269     if (PrevSC)
270       PrevSC->setNextSwitchCase(SC);
271     else
272       S->setSwitchCaseList(SC);
273 
274     PrevSC = SC;
275   }
276 }
277 
278 void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
279   VisitStmt(S);
280 
281   bool HasVar = Record.readInt();
282 
283   S->setCond(Record.readSubExpr());
284   S->setBody(Record.readSubStmt());
285   if (HasVar)
286     S->setConditionVariableDeclStmt(cast<DeclStmt>(Record.readSubStmt()));
287 
288   S->setWhileLoc(readSourceLocation());
289   S->setLParenLoc(readSourceLocation());
290   S->setRParenLoc(readSourceLocation());
291 }
292 
293 void ASTStmtReader::VisitDoStmt(DoStmt *S) {
294   VisitStmt(S);
295   S->setCond(Record.readSubExpr());
296   S->setBody(Record.readSubStmt());
297   S->setDoLoc(readSourceLocation());
298   S->setWhileLoc(readSourceLocation());
299   S->setRParenLoc(readSourceLocation());
300 }
301 
302 void ASTStmtReader::VisitForStmt(ForStmt *S) {
303   VisitStmt(S);
304   S->setInit(Record.readSubStmt());
305   S->setCond(Record.readSubExpr());
306   S->setConditionVariableDeclStmt(cast_or_null<DeclStmt>(Record.readSubStmt()));
307   S->setInc(Record.readSubExpr());
308   S->setBody(Record.readSubStmt());
309   S->setForLoc(readSourceLocation());
310   S->setLParenLoc(readSourceLocation());
311   S->setRParenLoc(readSourceLocation());
312 }
313 
314 void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
315   VisitStmt(S);
316   S->setLabel(readDeclAs<LabelDecl>());
317   S->setGotoLoc(readSourceLocation());
318   S->setLabelLoc(readSourceLocation());
319 }
320 
321 void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
322   VisitStmt(S);
323   S->setGotoLoc(readSourceLocation());
324   S->setStarLoc(readSourceLocation());
325   S->setTarget(Record.readSubExpr());
326 }
327 
328 void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
329   VisitStmt(S);
330   S->setContinueLoc(readSourceLocation());
331 }
332 
333 void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
334   VisitStmt(S);
335   S->setBreakLoc(readSourceLocation());
336 }
337 
338 void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
339   VisitStmt(S);
340 
341   bool HasNRVOCandidate = Record.readInt();
342 
343   S->setRetValue(Record.readSubExpr());
344   if (HasNRVOCandidate)
345     S->setNRVOCandidate(readDeclAs<VarDecl>());
346 
347   S->setReturnLoc(readSourceLocation());
348 }
349 
350 void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
351   VisitStmt(S);
352   S->setStartLoc(readSourceLocation());
353   S->setEndLoc(readSourceLocation());
354 
355   if (Record.size() - Record.getIdx() == 1) {
356     // Single declaration
357     S->setDeclGroup(DeclGroupRef(readDecl()));
358   } else {
359     SmallVector<Decl *, 16> Decls;
360     int N = Record.size() - Record.getIdx();
361     Decls.reserve(N);
362     for (int I = 0; I < N; ++I)
363       Decls.push_back(readDecl());
364     S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
365                                                    Decls.data(),
366                                                    Decls.size())));
367   }
368 }
369 
370 void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
371   VisitStmt(S);
372   S->NumOutputs = Record.readInt();
373   S->NumInputs = Record.readInt();
374   S->NumClobbers = Record.readInt();
375   S->setAsmLoc(readSourceLocation());
376   S->setVolatile(Record.readInt());
377   S->setSimple(Record.readInt());
378 }
379 
380 void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
381   VisitAsmStmt(S);
382   S->NumLabels = Record.readInt();
383   S->setRParenLoc(readSourceLocation());
384   S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
385 
386   unsigned NumOutputs = S->getNumOutputs();
387   unsigned NumInputs = S->getNumInputs();
388   unsigned NumClobbers = S->getNumClobbers();
389   unsigned NumLabels = S->getNumLabels();
390 
391   // Outputs and inputs
392   SmallVector<IdentifierInfo *, 16> Names;
393   SmallVector<StringLiteral*, 16> Constraints;
394   SmallVector<Stmt*, 16> Exprs;
395   for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
396     Names.push_back(Record.readIdentifier());
397     Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
398     Exprs.push_back(Record.readSubStmt());
399   }
400 
401   // Constraints
402   SmallVector<StringLiteral*, 16> Clobbers;
403   for (unsigned I = 0; I != NumClobbers; ++I)
404     Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
405 
406   // Labels
407   for (unsigned I = 0, N = NumLabels; I != N; ++I) {
408     Names.push_back(Record.readIdentifier());
409     Exprs.push_back(Record.readSubStmt());
410   }
411 
412   S->setOutputsAndInputsAndClobbers(Record.getContext(),
413                                     Names.data(), Constraints.data(),
414                                     Exprs.data(), NumOutputs, NumInputs,
415                                     NumLabels,
416                                     Clobbers.data(), NumClobbers);
417 }
418 
419 void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
420   VisitAsmStmt(S);
421   S->LBraceLoc = readSourceLocation();
422   S->EndLoc = readSourceLocation();
423   S->NumAsmToks = Record.readInt();
424   std::string AsmStr = readString();
425 
426   // Read the tokens.
427   SmallVector<Token, 16> AsmToks;
428   AsmToks.reserve(S->NumAsmToks);
429   for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
430     AsmToks.push_back(Record.readToken());
431   }
432 
433   // The calls to reserve() for the FooData vectors are mandatory to
434   // prevent dead StringRefs in the Foo vectors.
435 
436   // Read the clobbers.
437   SmallVector<std::string, 16> ClobbersData;
438   SmallVector<StringRef, 16> Clobbers;
439   ClobbersData.reserve(S->NumClobbers);
440   Clobbers.reserve(S->NumClobbers);
441   for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
442     ClobbersData.push_back(readString());
443     Clobbers.push_back(ClobbersData.back());
444   }
445 
446   // Read the operands.
447   unsigned NumOperands = S->NumOutputs + S->NumInputs;
448   SmallVector<Expr*, 16> Exprs;
449   SmallVector<std::string, 16> ConstraintsData;
450   SmallVector<StringRef, 16> Constraints;
451   Exprs.reserve(NumOperands);
452   ConstraintsData.reserve(NumOperands);
453   Constraints.reserve(NumOperands);
454   for (unsigned i = 0; i != NumOperands; ++i) {
455     Exprs.push_back(cast<Expr>(Record.readSubStmt()));
456     ConstraintsData.push_back(readString());
457     Constraints.push_back(ConstraintsData.back());
458   }
459 
460   S->initialize(Record.getContext(), AsmStr, AsmToks,
461                 Constraints, Exprs, Clobbers);
462 }
463 
464 void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
465   VisitStmt(S);
466   assert(Record.peekInt() == S->NumParams);
467   Record.skipInts(1);
468   auto *StoredStmts = S->getStoredStmts();
469   for (unsigned i = 0;
470        i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
471     StoredStmts[i] = Record.readSubStmt();
472 }
473 
474 void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
475   VisitStmt(S);
476   S->CoreturnLoc = Record.readSourceLocation();
477   for (auto &SubStmt: S->SubStmts)
478     SubStmt = Record.readSubStmt();
479   S->IsImplicit = Record.readInt() != 0;
480 }
481 
482 void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
483   VisitExpr(E);
484   E->KeywordLoc = readSourceLocation();
485   for (auto &SubExpr: E->SubExprs)
486     SubExpr = Record.readSubStmt();
487   E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
488   E->setIsImplicit(Record.readInt() != 0);
489 }
490 
491 void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
492   VisitExpr(E);
493   E->KeywordLoc = readSourceLocation();
494   for (auto &SubExpr: E->SubExprs)
495     SubExpr = Record.readSubStmt();
496   E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
497 }
498 
499 void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
500   VisitExpr(E);
501   E->KeywordLoc = readSourceLocation();
502   for (auto &SubExpr: E->SubExprs)
503     SubExpr = Record.readSubStmt();
504 }
505 
506 void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
507   VisitStmt(S);
508   Record.skipInts(1);
509   S->setCapturedDecl(readDeclAs<CapturedDecl>());
510   S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
511   S->setCapturedRecordDecl(readDeclAs<RecordDecl>());
512 
513   // Capture inits
514   for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
515                                            E = S->capture_init_end();
516        I != E; ++I)
517     *I = Record.readSubExpr();
518 
519   // Body
520   S->setCapturedStmt(Record.readSubStmt());
521   S->getCapturedDecl()->setBody(S->getCapturedStmt());
522 
523   // Captures
524   for (auto &I : S->captures()) {
525     I.VarAndKind.setPointer(readDeclAs<VarDecl>());
526     I.VarAndKind.setInt(
527         static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
528     I.Loc = readSourceLocation();
529   }
530 }
531 
532 void ASTStmtReader::VisitSYCLKernelCallStmt(SYCLKernelCallStmt *S) {
533   VisitStmt(S);
534   S->setOriginalStmt(cast<CompoundStmt>(Record.readSubStmt()));
535   S->setOutlinedFunctionDecl(readDeclAs<OutlinedFunctionDecl>());
536 }
537 
538 void ASTStmtReader::VisitExpr(Expr *E) {
539   VisitStmt(E);
540   CurrentUnpackingBits.emplace(Record.readInt());
541   E->setDependence(static_cast<ExprDependence>(
542       CurrentUnpackingBits->getNextBits(/*Width=*/5)));
543   E->setValueKind(static_cast<ExprValueKind>(
544       CurrentUnpackingBits->getNextBits(/*Width=*/2)));
545   E->setObjectKind(static_cast<ExprObjectKind>(
546       CurrentUnpackingBits->getNextBits(/*Width=*/3)));
547 
548   E->setType(Record.readType());
549   assert(Record.getIdx() == NumExprFields &&
550          "Incorrect expression field count");
551 }
552 
553 void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
554   VisitExpr(E);
555 
556   auto StorageKind = static_cast<ConstantResultStorageKind>(Record.readInt());
557   assert(E->getResultStorageKind() == StorageKind && "Wrong ResultKind!");
558 
559   E->ConstantExprBits.APValueKind = Record.readInt();
560   E->ConstantExprBits.IsUnsigned = Record.readInt();
561   E->ConstantExprBits.BitWidth = Record.readInt();
562   E->ConstantExprBits.HasCleanup = false; // Not serialized, see below.
563   E->ConstantExprBits.IsImmediateInvocation = Record.readInt();
564 
565   switch (StorageKind) {
566   case ConstantResultStorageKind::None:
567     break;
568 
569   case ConstantResultStorageKind::Int64:
570     E->Int64Result() = Record.readInt();
571     break;
572 
573   case ConstantResultStorageKind::APValue:
574     E->APValueResult() = Record.readAPValue();
575     if (E->APValueResult().needsCleanup()) {
576       E->ConstantExprBits.HasCleanup = true;
577       Record.getContext().addDestruction(&E->APValueResult());
578     }
579     break;
580   }
581 
582   E->setSubExpr(Record.readSubExpr());
583 }
584 
585 void ASTStmtReader::VisitOpenACCAsteriskSizeExpr(OpenACCAsteriskSizeExpr *E) {
586   VisitExpr(E);
587   E->setAsteriskLocation(readSourceLocation());
588 }
589 
590 void ASTStmtReader::VisitSYCLUniqueStableNameExpr(SYCLUniqueStableNameExpr *E) {
591   VisitExpr(E);
592 
593   E->setLocation(readSourceLocation());
594   E->setLParenLocation(readSourceLocation());
595   E->setRParenLocation(readSourceLocation());
596 
597   E->setTypeSourceInfo(Record.readTypeSourceInfo());
598 }
599 
600 void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
601   VisitExpr(E);
602   bool HasFunctionName = Record.readInt();
603   E->PredefinedExprBits.HasFunctionName = HasFunctionName;
604   E->PredefinedExprBits.Kind = Record.readInt();
605   E->PredefinedExprBits.IsTransparent = Record.readInt();
606   E->setLocation(readSourceLocation());
607   if (HasFunctionName)
608     E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
609 }
610 
611 void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
612   VisitExpr(E);
613 
614   CurrentUnpackingBits.emplace(Record.readInt());
615   E->DeclRefExprBits.HadMultipleCandidates = CurrentUnpackingBits->getNextBit();
616   E->DeclRefExprBits.RefersToEnclosingVariableOrCapture =
617       CurrentUnpackingBits->getNextBit();
618   E->DeclRefExprBits.NonOdrUseReason =
619       CurrentUnpackingBits->getNextBits(/*Width=*/2);
620   E->DeclRefExprBits.IsImmediateEscalating = CurrentUnpackingBits->getNextBit();
621   E->DeclRefExprBits.HasFoundDecl = CurrentUnpackingBits->getNextBit();
622   E->DeclRefExprBits.HasQualifier = CurrentUnpackingBits->getNextBit();
623   E->DeclRefExprBits.HasTemplateKWAndArgsInfo =
624       CurrentUnpackingBits->getNextBit();
625   E->DeclRefExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter = false;
626   unsigned NumTemplateArgs = 0;
627   if (E->hasTemplateKWAndArgsInfo())
628     NumTemplateArgs = Record.readInt();
629 
630   if (E->hasQualifier())
631     new (E->getTrailingObjects<NestedNameSpecifierLoc>())
632         NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
633 
634   if (E->hasFoundDecl())
635     *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
636 
637   if (E->hasTemplateKWAndArgsInfo())
638     ReadTemplateKWAndArgsInfo(
639         *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
640         E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
641 
642   E->D = readDeclAs<ValueDecl>();
643   E->setLocation(readSourceLocation());
644   E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
645 }
646 
647 void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
648   VisitExpr(E);
649   E->setLocation(readSourceLocation());
650   E->setValue(Record.getContext(), Record.readAPInt());
651 }
652 
653 void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
654   VisitExpr(E);
655   E->setLocation(readSourceLocation());
656   E->setScale(Record.readInt());
657   E->setValue(Record.getContext(), Record.readAPInt());
658 }
659 
660 void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
661   VisitExpr(E);
662   E->setRawSemantics(
663       static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
664   E->setExact(Record.readInt());
665   E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
666   E->setLocation(readSourceLocation());
667 }
668 
669 void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
670   VisitExpr(E);
671   E->setSubExpr(Record.readSubExpr());
672 }
673 
674 void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
675   VisitExpr(E);
676 
677   // NumConcatenated, Length and CharByteWidth are set by the empty
678   // ctor since they are needed to allocate storage for the trailing objects.
679   unsigned NumConcatenated = Record.readInt();
680   unsigned Length = Record.readInt();
681   unsigned CharByteWidth = Record.readInt();
682   assert((NumConcatenated == E->getNumConcatenated()) &&
683          "Wrong number of concatenated tokens!");
684   assert((Length == E->getLength()) && "Wrong Length!");
685   assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
686   E->StringLiteralBits.Kind = Record.readInt();
687   E->StringLiteralBits.IsPascal = Record.readInt();
688 
689   // The character width is originally computed via mapCharByteWidth.
690   // Check that the deserialized character width is consistant with the result
691   // of calling mapCharByteWidth.
692   assert((CharByteWidth ==
693           StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
694                                           E->getKind())) &&
695          "Wrong character width!");
696 
697   // Deserialize the trailing array of SourceLocation.
698   for (unsigned I = 0; I < NumConcatenated; ++I)
699     E->setStrTokenLoc(I, readSourceLocation());
700 
701   // Deserialize the trailing array of char holding the string data.
702   char *StrData = E->getStrDataAsChar();
703   for (unsigned I = 0; I < Length * CharByteWidth; ++I)
704     StrData[I] = Record.readInt();
705 }
706 
707 void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
708   VisitExpr(E);
709   E->setValue(Record.readInt());
710   E->setLocation(readSourceLocation());
711   E->setKind(static_cast<CharacterLiteralKind>(Record.readInt()));
712 }
713 
714 void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
715   VisitExpr(E);
716   E->setIsProducedByFoldExpansion(Record.readInt());
717   E->setLParen(readSourceLocation());
718   E->setRParen(readSourceLocation());
719   E->setSubExpr(Record.readSubExpr());
720 }
721 
722 void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
723   VisitExpr(E);
724   unsigned NumExprs = Record.readInt();
725   assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
726   for (unsigned I = 0; I != NumExprs; ++I)
727     E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
728   E->LParenLoc = readSourceLocation();
729   E->RParenLoc = readSourceLocation();
730 }
731 
732 void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
733   VisitExpr(E);
734   bool hasFP_Features = CurrentUnpackingBits->getNextBit();
735   assert(hasFP_Features == E->hasStoredFPFeatures());
736   E->setSubExpr(Record.readSubExpr());
737   E->setOpcode(
738       (UnaryOperator::Opcode)CurrentUnpackingBits->getNextBits(/*Width=*/5));
739   E->setOperatorLoc(readSourceLocation());
740   E->setCanOverflow(CurrentUnpackingBits->getNextBit());
741   if (hasFP_Features)
742     E->setStoredFPFeatures(
743         FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
744 }
745 
746 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
747   VisitExpr(E);
748   assert(E->getNumComponents() == Record.peekInt());
749   Record.skipInts(1);
750   assert(E->getNumExpressions() == Record.peekInt());
751   Record.skipInts(1);
752   E->setOperatorLoc(readSourceLocation());
753   E->setRParenLoc(readSourceLocation());
754   E->setTypeSourceInfo(readTypeSourceInfo());
755   for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
756     auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
757     SourceLocation Start = readSourceLocation();
758     SourceLocation End = readSourceLocation();
759     switch (Kind) {
760     case OffsetOfNode::Array:
761       E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
762       break;
763 
764     case OffsetOfNode::Field:
765       E->setComponent(
766           I, OffsetOfNode(Start, readDeclAs<FieldDecl>(), End));
767       break;
768 
769     case OffsetOfNode::Identifier:
770       E->setComponent(
771           I,
772           OffsetOfNode(Start, Record.readIdentifier(), End));
773       break;
774 
775     case OffsetOfNode::Base: {
776       auto *Base = new (Record.getContext()) CXXBaseSpecifier();
777       *Base = Record.readCXXBaseSpecifier();
778       E->setComponent(I, OffsetOfNode(Base));
779       break;
780     }
781     }
782   }
783 
784   for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
785     E->setIndexExpr(I, Record.readSubExpr());
786 }
787 
788 void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
789   VisitExpr(E);
790   E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
791   if (Record.peekInt() == 0) {
792     E->setArgument(Record.readSubExpr());
793     Record.skipInts(1);
794   } else {
795     E->setArgument(readTypeSourceInfo());
796   }
797   E->setOperatorLoc(readSourceLocation());
798   E->setRParenLoc(readSourceLocation());
799 }
800 
801 static ConstraintSatisfaction
802 readConstraintSatisfaction(ASTRecordReader &Record) {
803   ConstraintSatisfaction Satisfaction;
804   Satisfaction.IsSatisfied = Record.readInt();
805   Satisfaction.ContainsErrors = Record.readInt();
806   const ASTContext &C = Record.getContext();
807   if (!Satisfaction.IsSatisfied) {
808     unsigned NumDetailRecords = Record.readInt();
809     for (unsigned i = 0; i != NumDetailRecords; ++i) {
810       if (/* IsDiagnostic */Record.readInt()) {
811         SourceLocation DiagLocation = Record.readSourceLocation();
812         StringRef DiagMessage = C.backupStr(Record.readString());
813 
814         Satisfaction.Details.emplace_back(
815             new (C) ConstraintSatisfaction::SubstitutionDiagnostic(
816                 DiagLocation, DiagMessage));
817       } else
818         Satisfaction.Details.emplace_back(Record.readExpr());
819     }
820   }
821   return Satisfaction;
822 }
823 
824 void ASTStmtReader::VisitConceptSpecializationExpr(
825         ConceptSpecializationExpr *E) {
826   VisitExpr(E);
827   E->SpecDecl = Record.readDeclAs<ImplicitConceptSpecializationDecl>();
828   if (Record.readBool())
829     E->ConceptRef = Record.readConceptReference();
830   E->Satisfaction = E->isValueDependent() ? nullptr :
831       ASTConstraintSatisfaction::Create(Record.getContext(),
832                                         readConstraintSatisfaction(Record));
833 }
834 
835 static concepts::Requirement::SubstitutionDiagnostic *
836 readSubstitutionDiagnostic(ASTRecordReader &Record) {
837   const ASTContext &C = Record.getContext();
838   StringRef SubstitutedEntity = C.backupStr(Record.readString());
839   SourceLocation DiagLoc = Record.readSourceLocation();
840   StringRef DiagMessage = C.backupStr(Record.readString());
841 
842   return new (Record.getContext())
843       concepts::Requirement::SubstitutionDiagnostic{SubstitutedEntity, DiagLoc,
844                                                     DiagMessage};
845 }
846 
847 void ASTStmtReader::VisitRequiresExpr(RequiresExpr *E) {
848   VisitExpr(E);
849   unsigned NumLocalParameters = Record.readInt();
850   unsigned NumRequirements = Record.readInt();
851   E->RequiresExprBits.RequiresKWLoc = Record.readSourceLocation();
852   E->RequiresExprBits.IsSatisfied = Record.readInt();
853   E->Body = Record.readDeclAs<RequiresExprBodyDecl>();
854   llvm::SmallVector<ParmVarDecl *, 4> LocalParameters;
855   for (unsigned i = 0; i < NumLocalParameters; ++i)
856     LocalParameters.push_back(cast<ParmVarDecl>(Record.readDecl()));
857   std::copy(LocalParameters.begin(), LocalParameters.end(),
858             E->getTrailingObjects<ParmVarDecl *>());
859   llvm::SmallVector<concepts::Requirement *, 4> Requirements;
860   for (unsigned i = 0; i < NumRequirements; ++i) {
861     auto RK =
862         static_cast<concepts::Requirement::RequirementKind>(Record.readInt());
863     concepts::Requirement *R = nullptr;
864     switch (RK) {
865       case concepts::Requirement::RK_Type: {
866         auto Status =
867             static_cast<concepts::TypeRequirement::SatisfactionStatus>(
868                 Record.readInt());
869         if (Status == concepts::TypeRequirement::SS_SubstitutionFailure)
870           R = new (Record.getContext())
871               concepts::TypeRequirement(readSubstitutionDiagnostic(Record));
872         else
873           R = new (Record.getContext())
874               concepts::TypeRequirement(Record.readTypeSourceInfo());
875       } break;
876       case concepts::Requirement::RK_Simple:
877       case concepts::Requirement::RK_Compound: {
878         auto Status =
879             static_cast<concepts::ExprRequirement::SatisfactionStatus>(
880                 Record.readInt());
881         llvm::PointerUnion<concepts::Requirement::SubstitutionDiagnostic *,
882                            Expr *> E;
883         if (Status == concepts::ExprRequirement::SS_ExprSubstitutionFailure) {
884           E = readSubstitutionDiagnostic(Record);
885         } else
886           E = Record.readExpr();
887 
888         std::optional<concepts::ExprRequirement::ReturnTypeRequirement> Req;
889         ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr;
890         SourceLocation NoexceptLoc;
891         if (RK == concepts::Requirement::RK_Simple) {
892           Req.emplace();
893         } else {
894           NoexceptLoc = Record.readSourceLocation();
895           switch (/* returnTypeRequirementKind */Record.readInt()) {
896             case 0:
897               // No return type requirement.
898               Req.emplace();
899               break;
900             case 1: {
901               // type-constraint
902               TemplateParameterList *TPL = Record.readTemplateParameterList();
903               if (Status >=
904                   concepts::ExprRequirement::SS_ConstraintsNotSatisfied)
905                 SubstitutedConstraintExpr =
906                     cast<ConceptSpecializationExpr>(Record.readExpr());
907               Req.emplace(TPL);
908             } break;
909             case 2:
910               // Substitution failure
911               Req.emplace(readSubstitutionDiagnostic(Record));
912               break;
913           }
914         }
915         if (Expr *Ex = E.dyn_cast<Expr *>())
916           R = new (Record.getContext()) concepts::ExprRequirement(
917                   Ex, RK == concepts::Requirement::RK_Simple, NoexceptLoc,
918                   std::move(*Req), Status, SubstitutedConstraintExpr);
919         else
920           R = new (Record.getContext()) concepts::ExprRequirement(
921               cast<concepts::Requirement::SubstitutionDiagnostic *>(E),
922               RK == concepts::Requirement::RK_Simple, NoexceptLoc,
923               std::move(*Req));
924       } break;
925       case concepts::Requirement::RK_Nested: {
926         ASTContext &C = Record.getContext();
927         bool HasInvalidConstraint = Record.readInt();
928         if (HasInvalidConstraint) {
929           StringRef InvalidConstraint = C.backupStr(Record.readString());
930           R = new (C) concepts::NestedRequirement(
931               Record.getContext(), InvalidConstraint,
932               readConstraintSatisfaction(Record));
933           break;
934         }
935         Expr *E = Record.readExpr();
936         if (E->isInstantiationDependent())
937           R = new (C) concepts::NestedRequirement(E);
938         else
939           R = new (C) concepts::NestedRequirement(
940               C, E, readConstraintSatisfaction(Record));
941       } break;
942     }
943     if (!R)
944       continue;
945     Requirements.push_back(R);
946   }
947   std::copy(Requirements.begin(), Requirements.end(),
948             E->getTrailingObjects<concepts::Requirement *>());
949   E->LParenLoc = Record.readSourceLocation();
950   E->RParenLoc = Record.readSourceLocation();
951   E->RBraceLoc = Record.readSourceLocation();
952 }
953 
954 void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
955   VisitExpr(E);
956   E->setLHS(Record.readSubExpr());
957   E->setRHS(Record.readSubExpr());
958   E->setRBracketLoc(readSourceLocation());
959 }
960 
961 void ASTStmtReader::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
962   VisitExpr(E);
963   E->setBase(Record.readSubExpr());
964   E->setRowIdx(Record.readSubExpr());
965   E->setColumnIdx(Record.readSubExpr());
966   E->setRBracketLoc(readSourceLocation());
967 }
968 
969 void ASTStmtReader::VisitArraySectionExpr(ArraySectionExpr *E) {
970   VisitExpr(E);
971   E->ASType = Record.readEnum<ArraySectionExpr::ArraySectionType>();
972 
973   E->setBase(Record.readSubExpr());
974   E->setLowerBound(Record.readSubExpr());
975   E->setLength(Record.readSubExpr());
976 
977   if (E->isOMPArraySection())
978     E->setStride(Record.readSubExpr());
979 
980   E->setColonLocFirst(readSourceLocation());
981 
982   if (E->isOMPArraySection())
983     E->setColonLocSecond(readSourceLocation());
984 
985   E->setRBracketLoc(readSourceLocation());
986 }
987 
988 void ASTStmtReader::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *E) {
989   VisitExpr(E);
990   unsigned NumDims = Record.readInt();
991   E->setBase(Record.readSubExpr());
992   SmallVector<Expr *, 4> Dims(NumDims);
993   for (unsigned I = 0; I < NumDims; ++I)
994     Dims[I] = Record.readSubExpr();
995   E->setDimensions(Dims);
996   SmallVector<SourceRange, 4> SRs(NumDims);
997   for (unsigned I = 0; I < NumDims; ++I)
998     SRs[I] = readSourceRange();
999   E->setBracketsRanges(SRs);
1000   E->setLParenLoc(readSourceLocation());
1001   E->setRParenLoc(readSourceLocation());
1002 }
1003 
1004 void ASTStmtReader::VisitOMPIteratorExpr(OMPIteratorExpr *E) {
1005   VisitExpr(E);
1006   unsigned NumIters = Record.readInt();
1007   E->setIteratorKwLoc(readSourceLocation());
1008   E->setLParenLoc(readSourceLocation());
1009   E->setRParenLoc(readSourceLocation());
1010   for (unsigned I = 0; I < NumIters; ++I) {
1011     E->setIteratorDeclaration(I, Record.readDeclRef());
1012     E->setAssignmentLoc(I, readSourceLocation());
1013     Expr *Begin = Record.readSubExpr();
1014     Expr *End = Record.readSubExpr();
1015     Expr *Step = Record.readSubExpr();
1016     SourceLocation ColonLoc = readSourceLocation();
1017     SourceLocation SecColonLoc;
1018     if (Step)
1019       SecColonLoc = readSourceLocation();
1020     E->setIteratorRange(I, Begin, ColonLoc, End, SecColonLoc, Step);
1021     // Deserialize helpers
1022     OMPIteratorHelperData HD;
1023     HD.CounterVD = cast_or_null<VarDecl>(Record.readDeclRef());
1024     HD.Upper = Record.readSubExpr();
1025     HD.Update = Record.readSubExpr();
1026     HD.CounterUpdate = Record.readSubExpr();
1027     E->setHelper(I, HD);
1028   }
1029 }
1030 
1031 void ASTStmtReader::VisitCallExpr(CallExpr *E) {
1032   VisitExpr(E);
1033 
1034   unsigned NumArgs = Record.readInt();
1035   CurrentUnpackingBits.emplace(Record.readInt());
1036   E->setADLCallKind(
1037       static_cast<CallExpr::ADLCallKind>(CurrentUnpackingBits->getNextBit()));
1038   bool HasFPFeatures = CurrentUnpackingBits->getNextBit();
1039   assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1040   E->setRParenLoc(readSourceLocation());
1041   E->setCallee(Record.readSubExpr());
1042   for (unsigned I = 0; I != NumArgs; ++I)
1043     E->setArg(I, Record.readSubExpr());
1044 
1045   if (HasFPFeatures)
1046     E->setStoredFPFeatures(
1047         FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
1048 }
1049 
1050 void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
1051   VisitCallExpr(E);
1052 }
1053 
1054 void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
1055   VisitExpr(E);
1056 
1057   CurrentUnpackingBits.emplace(Record.readInt());
1058   bool HasQualifier = CurrentUnpackingBits->getNextBit();
1059   bool HasFoundDecl = CurrentUnpackingBits->getNextBit();
1060   bool HasTemplateInfo = CurrentUnpackingBits->getNextBit();
1061   unsigned NumTemplateArgs = Record.readInt();
1062 
1063   E->Base = Record.readSubExpr();
1064   E->MemberDecl = Record.readDeclAs<ValueDecl>();
1065   E->MemberDNLoc = Record.readDeclarationNameLoc(E->MemberDecl->getDeclName());
1066   E->MemberLoc = Record.readSourceLocation();
1067   E->MemberExprBits.IsArrow = CurrentUnpackingBits->getNextBit();
1068   E->MemberExprBits.HasQualifier = HasQualifier;
1069   E->MemberExprBits.HasFoundDecl = HasFoundDecl;
1070   E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
1071   E->MemberExprBits.HadMultipleCandidates = CurrentUnpackingBits->getNextBit();
1072   E->MemberExprBits.NonOdrUseReason =
1073       CurrentUnpackingBits->getNextBits(/*Width=*/2);
1074   E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
1075 
1076   if (HasQualifier)
1077     new (E->getTrailingObjects<NestedNameSpecifierLoc>())
1078         NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
1079 
1080   if (HasFoundDecl) {
1081     auto *FoundD = Record.readDeclAs<NamedDecl>();
1082     auto AS = (AccessSpecifier)CurrentUnpackingBits->getNextBits(/*Width=*/2);
1083     *E->getTrailingObjects<DeclAccessPair>() = DeclAccessPair::make(FoundD, AS);
1084   }
1085 
1086   if (HasTemplateInfo)
1087     ReadTemplateKWAndArgsInfo(
1088         *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1089         E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
1090 }
1091 
1092 void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
1093   VisitExpr(E);
1094   E->setBase(Record.readSubExpr());
1095   E->setIsaMemberLoc(readSourceLocation());
1096   E->setOpLoc(readSourceLocation());
1097   E->setArrow(Record.readInt());
1098 }
1099 
1100 void ASTStmtReader::
1101 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
1102   VisitExpr(E);
1103   E->Operand = Record.readSubExpr();
1104   E->setShouldCopy(Record.readInt());
1105 }
1106 
1107 void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
1108   VisitExplicitCastExpr(E);
1109   E->LParenLoc = readSourceLocation();
1110   E->BridgeKeywordLoc = readSourceLocation();
1111   E->Kind = Record.readInt();
1112 }
1113 
1114 void ASTStmtReader::VisitCastExpr(CastExpr *E) {
1115   VisitExpr(E);
1116   unsigned NumBaseSpecs = Record.readInt();
1117   assert(NumBaseSpecs == E->path_size());
1118 
1119   CurrentUnpackingBits.emplace(Record.readInt());
1120   E->setCastKind((CastKind)CurrentUnpackingBits->getNextBits(/*Width=*/7));
1121   unsigned HasFPFeatures = CurrentUnpackingBits->getNextBit();
1122   assert(E->hasStoredFPFeatures() == HasFPFeatures);
1123 
1124   E->setSubExpr(Record.readSubExpr());
1125 
1126   CastExpr::path_iterator BaseI = E->path_begin();
1127   while (NumBaseSpecs--) {
1128     auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
1129     *BaseSpec = Record.readCXXBaseSpecifier();
1130     *BaseI++ = BaseSpec;
1131   }
1132   if (HasFPFeatures)
1133     *E->getTrailingFPFeatures() =
1134         FPOptionsOverride::getFromOpaqueInt(Record.readInt());
1135 }
1136 
1137 void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
1138   VisitExpr(E);
1139   CurrentUnpackingBits.emplace(Record.readInt());
1140   E->setOpcode(
1141       (BinaryOperator::Opcode)CurrentUnpackingBits->getNextBits(/*Width=*/6));
1142   bool hasFP_Features = CurrentUnpackingBits->getNextBit();
1143   E->setHasStoredFPFeatures(hasFP_Features);
1144   E->setExcludedOverflowPattern(CurrentUnpackingBits->getNextBit());
1145   E->setLHS(Record.readSubExpr());
1146   E->setRHS(Record.readSubExpr());
1147   E->setOperatorLoc(readSourceLocation());
1148   if (hasFP_Features)
1149     E->setStoredFPFeatures(
1150         FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
1151 }
1152 
1153 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
1154   VisitBinaryOperator(E);
1155   E->setComputationLHSType(Record.readType());
1156   E->setComputationResultType(Record.readType());
1157 }
1158 
1159 void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
1160   VisitExpr(E);
1161   E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
1162   E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
1163   E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
1164   E->QuestionLoc = readSourceLocation();
1165   E->ColonLoc = readSourceLocation();
1166 }
1167 
1168 void
1169 ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
1170   VisitExpr(E);
1171   E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
1172   E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
1173   E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
1174   E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
1175   E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
1176   E->QuestionLoc = readSourceLocation();
1177   E->ColonLoc = readSourceLocation();
1178 }
1179 
1180 void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
1181   VisitCastExpr(E);
1182   E->setIsPartOfExplicitCast(CurrentUnpackingBits->getNextBit());
1183 }
1184 
1185 void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
1186   VisitCastExpr(E);
1187   E->setTypeInfoAsWritten(readTypeSourceInfo());
1188 }
1189 
1190 void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
1191   VisitExplicitCastExpr(E);
1192   E->setLParenLoc(readSourceLocation());
1193   E->setRParenLoc(readSourceLocation());
1194 }
1195 
1196 void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
1197   VisitExpr(E);
1198   E->setLParenLoc(readSourceLocation());
1199   E->setTypeSourceInfo(readTypeSourceInfo());
1200   E->setInitializer(Record.readSubExpr());
1201   E->setFileScope(Record.readInt());
1202 }
1203 
1204 void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
1205   VisitExpr(E);
1206   E->setBase(Record.readSubExpr());
1207   E->setAccessor(Record.readIdentifier());
1208   E->setAccessorLoc(readSourceLocation());
1209 }
1210 
1211 void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
1212   VisitExpr(E);
1213   if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
1214     E->setSyntacticForm(SyntForm);
1215   E->setLBraceLoc(readSourceLocation());
1216   E->setRBraceLoc(readSourceLocation());
1217   bool isArrayFiller = Record.readInt();
1218   Expr *filler = nullptr;
1219   if (isArrayFiller) {
1220     filler = Record.readSubExpr();
1221     E->ArrayFillerOrUnionFieldInit = filler;
1222   } else
1223     E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
1224   E->sawArrayRangeDesignator(Record.readInt());
1225   unsigned NumInits = Record.readInt();
1226   E->reserveInits(Record.getContext(), NumInits);
1227   if (isArrayFiller) {
1228     for (unsigned I = 0; I != NumInits; ++I) {
1229       Expr *init = Record.readSubExpr();
1230       E->updateInit(Record.getContext(), I, init ? init : filler);
1231     }
1232   } else {
1233     for (unsigned I = 0; I != NumInits; ++I)
1234       E->updateInit(Record.getContext(), I, Record.readSubExpr());
1235   }
1236 }
1237 
1238 void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
1239   using Designator = DesignatedInitExpr::Designator;
1240 
1241   VisitExpr(E);
1242   unsigned NumSubExprs = Record.readInt();
1243   assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
1244   for (unsigned I = 0; I != NumSubExprs; ++I)
1245     E->setSubExpr(I, Record.readSubExpr());
1246   E->setEqualOrColonLoc(readSourceLocation());
1247   E->setGNUSyntax(Record.readInt());
1248 
1249   SmallVector<Designator, 4> Designators;
1250   while (Record.getIdx() < Record.size()) {
1251     switch ((DesignatorTypes)Record.readInt()) {
1252     case DESIG_FIELD_DECL: {
1253       auto *Field = readDeclAs<FieldDecl>();
1254       SourceLocation DotLoc = readSourceLocation();
1255       SourceLocation FieldLoc = readSourceLocation();
1256       Designators.push_back(Designator::CreateFieldDesignator(
1257           Field->getIdentifier(), DotLoc, FieldLoc));
1258       Designators.back().setFieldDecl(Field);
1259       break;
1260     }
1261 
1262     case DESIG_FIELD_NAME: {
1263       const IdentifierInfo *Name = Record.readIdentifier();
1264       SourceLocation DotLoc = readSourceLocation();
1265       SourceLocation FieldLoc = readSourceLocation();
1266       Designators.push_back(Designator::CreateFieldDesignator(Name, DotLoc,
1267                                                               FieldLoc));
1268       break;
1269     }
1270 
1271     case DESIG_ARRAY: {
1272       unsigned Index = Record.readInt();
1273       SourceLocation LBracketLoc = readSourceLocation();
1274       SourceLocation RBracketLoc = readSourceLocation();
1275       Designators.push_back(Designator::CreateArrayDesignator(Index,
1276                                                               LBracketLoc,
1277                                                               RBracketLoc));
1278       break;
1279     }
1280 
1281     case DESIG_ARRAY_RANGE: {
1282       unsigned Index = Record.readInt();
1283       SourceLocation LBracketLoc = readSourceLocation();
1284       SourceLocation EllipsisLoc = readSourceLocation();
1285       SourceLocation RBracketLoc = readSourceLocation();
1286       Designators.push_back(Designator::CreateArrayRangeDesignator(
1287           Index, LBracketLoc, EllipsisLoc, RBracketLoc));
1288       break;
1289     }
1290     }
1291   }
1292   E->setDesignators(Record.getContext(),
1293                     Designators.data(), Designators.size());
1294 }
1295 
1296 void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1297   VisitExpr(E);
1298   E->setBase(Record.readSubExpr());
1299   E->setUpdater(Record.readSubExpr());
1300 }
1301 
1302 void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1303   VisitExpr(E);
1304 }
1305 
1306 void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1307   VisitExpr(E);
1308   E->SubExprs[0] = Record.readSubExpr();
1309   E->SubExprs[1] = Record.readSubExpr();
1310 }
1311 
1312 void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1313   VisitExpr(E);
1314 }
1315 
1316 void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
1317   VisitExpr(E);
1318 }
1319 
1320 void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
1321   VisitExpr(E);
1322   E->setSubExpr(Record.readSubExpr());
1323   E->setWrittenTypeInfo(readTypeSourceInfo());
1324   E->setBuiltinLoc(readSourceLocation());
1325   E->setRParenLoc(readSourceLocation());
1326   E->setIsMicrosoftABI(Record.readInt());
1327 }
1328 
1329 void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1330   VisitExpr(E);
1331   E->ParentContext = readDeclAs<DeclContext>();
1332   E->BuiltinLoc = readSourceLocation();
1333   E->RParenLoc = readSourceLocation();
1334   E->SourceLocExprBits.Kind = Record.readInt();
1335 }
1336 
1337 void ASTStmtReader::VisitEmbedExpr(EmbedExpr *E) {
1338   VisitExpr(E);
1339   E->EmbedKeywordLoc = readSourceLocation();
1340   EmbedDataStorage *Data = new (Record.getContext()) EmbedDataStorage;
1341   Data->BinaryData = cast<StringLiteral>(Record.readSubStmt());
1342   E->Data = Data;
1343   E->Begin = Record.readInt();
1344   E->NumOfElements = Record.readInt();
1345 }
1346 
1347 void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
1348   VisitExpr(E);
1349   E->setAmpAmpLoc(readSourceLocation());
1350   E->setLabelLoc(readSourceLocation());
1351   E->setLabel(readDeclAs<LabelDecl>());
1352 }
1353 
1354 void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
1355   VisitExpr(E);
1356   E->setLParenLoc(readSourceLocation());
1357   E->setRParenLoc(readSourceLocation());
1358   E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
1359   E->StmtExprBits.TemplateDepth = Record.readInt();
1360 }
1361 
1362 void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
1363   VisitExpr(E);
1364   E->setCond(Record.readSubExpr());
1365   E->setLHS(Record.readSubExpr());
1366   E->setRHS(Record.readSubExpr());
1367   E->setBuiltinLoc(readSourceLocation());
1368   E->setRParenLoc(readSourceLocation());
1369   E->setIsConditionTrue(Record.readInt());
1370 }
1371 
1372 void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
1373   VisitExpr(E);
1374   E->setTokenLocation(readSourceLocation());
1375 }
1376 
1377 void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
1378   VisitExpr(E);
1379   SmallVector<Expr *, 16> Exprs;
1380   unsigned NumExprs = Record.readInt();
1381   while (NumExprs--)
1382     Exprs.push_back(Record.readSubExpr());
1383   E->setExprs(Record.getContext(), Exprs);
1384   E->setBuiltinLoc(readSourceLocation());
1385   E->setRParenLoc(readSourceLocation());
1386 }
1387 
1388 void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1389   VisitExpr(E);
1390   E->BuiltinLoc = readSourceLocation();
1391   E->RParenLoc = readSourceLocation();
1392   E->TInfo = readTypeSourceInfo();
1393   E->SrcExpr = Record.readSubExpr();
1394 }
1395 
1396 void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
1397   VisitExpr(E);
1398   E->setBlockDecl(readDeclAs<BlockDecl>());
1399 }
1400 
1401 void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1402   VisitExpr(E);
1403 
1404   unsigned NumAssocs = Record.readInt();
1405   assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
1406   E->IsExprPredicate = Record.readInt();
1407   E->ResultIndex = Record.readInt();
1408   E->GenericSelectionExprBits.GenericLoc = readSourceLocation();
1409   E->DefaultLoc = readSourceLocation();
1410   E->RParenLoc = readSourceLocation();
1411 
1412   Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1413   // Add 1 to account for the controlling expression which is the first
1414   // expression in the trailing array of Stmt *. This is not needed for
1415   // the trailing array of TypeSourceInfo *.
1416   for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1417     Stmts[I] = Record.readSubExpr();
1418 
1419   TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1420   for (unsigned I = 0, N = NumAssocs; I < N; ++I)
1421     TSIs[I] = readTypeSourceInfo();
1422 }
1423 
1424 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1425   VisitExpr(E);
1426   unsigned numSemanticExprs = Record.readInt();
1427   assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
1428   E->PseudoObjectExprBits.ResultIndex = Record.readInt();
1429 
1430   // Read the syntactic expression.
1431   E->getSubExprsBuffer()[0] = Record.readSubExpr();
1432 
1433   // Read all the semantic expressions.
1434   for (unsigned i = 0; i != numSemanticExprs; ++i) {
1435     Expr *subExpr = Record.readSubExpr();
1436     E->getSubExprsBuffer()[i+1] = subExpr;
1437   }
1438 }
1439 
1440 void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1441   VisitExpr(E);
1442   E->Op = AtomicExpr::AtomicOp(Record.readInt());
1443   E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1444   for (unsigned I = 0; I != E->NumSubExprs; ++I)
1445     E->SubExprs[I] = Record.readSubExpr();
1446   E->BuiltinLoc = readSourceLocation();
1447   E->RParenLoc = readSourceLocation();
1448 }
1449 
1450 //===----------------------------------------------------------------------===//
1451 // Objective-C Expressions and Statements
1452 
1453 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
1454   VisitExpr(E);
1455   E->setString(cast<StringLiteral>(Record.readSubStmt()));
1456   E->setAtLoc(readSourceLocation());
1457 }
1458 
1459 void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
1460   VisitExpr(E);
1461   // could be one of several IntegerLiteral, FloatLiteral, etc.
1462   E->SubExpr = Record.readSubStmt();
1463   E->BoxingMethod = readDeclAs<ObjCMethodDecl>();
1464   E->Range = readSourceRange();
1465 }
1466 
1467 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1468   VisitExpr(E);
1469   unsigned NumElements = Record.readInt();
1470   assert(NumElements == E->getNumElements() && "Wrong number of elements");
1471   Expr **Elements = E->getElements();
1472   for (unsigned I = 0, N = NumElements; I != N; ++I)
1473     Elements[I] = Record.readSubExpr();
1474   E->ArrayWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1475   E->Range = readSourceRange();
1476 }
1477 
1478 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1479   VisitExpr(E);
1480   unsigned NumElements = Record.readInt();
1481   assert(NumElements == E->getNumElements() && "Wrong number of elements");
1482   bool HasPackExpansions = Record.readInt();
1483   assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
1484   auto *KeyValues =
1485       E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
1486   auto *Expansions =
1487       E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
1488   for (unsigned I = 0; I != NumElements; ++I) {
1489     KeyValues[I].Key = Record.readSubExpr();
1490     KeyValues[I].Value = Record.readSubExpr();
1491     if (HasPackExpansions) {
1492       Expansions[I].EllipsisLoc = readSourceLocation();
1493       Expansions[I].NumExpansionsPlusOne = Record.readInt();
1494     }
1495   }
1496   E->DictWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1497   E->Range = readSourceRange();
1498 }
1499 
1500 void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
1501   VisitExpr(E);
1502   E->setEncodedTypeSourceInfo(readTypeSourceInfo());
1503   E->setAtLoc(readSourceLocation());
1504   E->setRParenLoc(readSourceLocation());
1505 }
1506 
1507 void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
1508   VisitExpr(E);
1509   E->setSelector(Record.readSelector());
1510   E->setAtLoc(readSourceLocation());
1511   E->setRParenLoc(readSourceLocation());
1512 }
1513 
1514 void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
1515   VisitExpr(E);
1516   E->setProtocol(readDeclAs<ObjCProtocolDecl>());
1517   E->setAtLoc(readSourceLocation());
1518   E->ProtoLoc = readSourceLocation();
1519   E->setRParenLoc(readSourceLocation());
1520 }
1521 
1522 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
1523   VisitExpr(E);
1524   E->setDecl(readDeclAs<ObjCIvarDecl>());
1525   E->setLocation(readSourceLocation());
1526   E->setOpLoc(readSourceLocation());
1527   E->setBase(Record.readSubExpr());
1528   E->setIsArrow(Record.readInt());
1529   E->setIsFreeIvar(Record.readInt());
1530 }
1531 
1532 void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
1533   VisitExpr(E);
1534   unsigned MethodRefFlags = Record.readInt();
1535   bool Implicit = Record.readInt() != 0;
1536   if (Implicit) {
1537     auto *Getter = readDeclAs<ObjCMethodDecl>();
1538     auto *Setter = readDeclAs<ObjCMethodDecl>();
1539     E->setImplicitProperty(Getter, Setter, MethodRefFlags);
1540   } else {
1541     E->setExplicitProperty(readDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
1542   }
1543   E->setLocation(readSourceLocation());
1544   E->setReceiverLocation(readSourceLocation());
1545   switch (Record.readInt()) {
1546   case 0:
1547     E->setBase(Record.readSubExpr());
1548     break;
1549   case 1:
1550     E->setSuperReceiver(Record.readType());
1551     break;
1552   case 2:
1553     E->setClassReceiver(readDeclAs<ObjCInterfaceDecl>());
1554     break;
1555   }
1556 }
1557 
1558 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1559   VisitExpr(E);
1560   E->setRBracket(readSourceLocation());
1561   E->setBaseExpr(Record.readSubExpr());
1562   E->setKeyExpr(Record.readSubExpr());
1563   E->GetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1564   E->SetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1565 }
1566 
1567 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1568   VisitExpr(E);
1569   assert(Record.peekInt() == E->getNumArgs());
1570   Record.skipInts(1);
1571   unsigned NumStoredSelLocs = Record.readInt();
1572   E->SelLocsKind = Record.readInt();
1573   E->setDelegateInitCall(Record.readInt());
1574   E->IsImplicit = Record.readInt();
1575   auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
1576   switch (Kind) {
1577   case ObjCMessageExpr::Instance:
1578     E->setInstanceReceiver(Record.readSubExpr());
1579     break;
1580 
1581   case ObjCMessageExpr::Class:
1582     E->setClassReceiver(readTypeSourceInfo());
1583     break;
1584 
1585   case ObjCMessageExpr::SuperClass:
1586   case ObjCMessageExpr::SuperInstance: {
1587     QualType T = Record.readType();
1588     SourceLocation SuperLoc = readSourceLocation();
1589     E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1590     break;
1591   }
1592   }
1593 
1594   assert(Kind == E->getReceiverKind());
1595 
1596   if (Record.readInt())
1597     E->setMethodDecl(readDeclAs<ObjCMethodDecl>());
1598   else
1599     E->setSelector(Record.readSelector());
1600 
1601   E->LBracLoc = readSourceLocation();
1602   E->RBracLoc = readSourceLocation();
1603 
1604   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1605     E->setArg(I, Record.readSubExpr());
1606 
1607   SourceLocation *Locs = E->getStoredSelLocs();
1608   for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1609     Locs[I] = readSourceLocation();
1610 }
1611 
1612 void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1613   VisitStmt(S);
1614   S->setElement(Record.readSubStmt());
1615   S->setCollection(Record.readSubExpr());
1616   S->setBody(Record.readSubStmt());
1617   S->setForLoc(readSourceLocation());
1618   S->setRParenLoc(readSourceLocation());
1619 }
1620 
1621 void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1622   VisitStmt(S);
1623   S->setCatchBody(Record.readSubStmt());
1624   S->setCatchParamDecl(readDeclAs<VarDecl>());
1625   S->setAtCatchLoc(readSourceLocation());
1626   S->setRParenLoc(readSourceLocation());
1627 }
1628 
1629 void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1630   VisitStmt(S);
1631   S->setFinallyBody(Record.readSubStmt());
1632   S->setAtFinallyLoc(readSourceLocation());
1633 }
1634 
1635 void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1636   VisitStmt(S); // FIXME: no test coverage.
1637   S->setSubStmt(Record.readSubStmt());
1638   S->setAtLoc(readSourceLocation());
1639 }
1640 
1641 void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1642   VisitStmt(S);
1643   assert(Record.peekInt() == S->getNumCatchStmts());
1644   Record.skipInts(1);
1645   bool HasFinally = Record.readInt();
1646   S->setTryBody(Record.readSubStmt());
1647   for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
1648     S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
1649 
1650   if (HasFinally)
1651     S->setFinallyStmt(Record.readSubStmt());
1652   S->setAtTryLoc(readSourceLocation());
1653 }
1654 
1655 void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1656   VisitStmt(S); // FIXME: no test coverage.
1657   S->setSynchExpr(Record.readSubStmt());
1658   S->setSynchBody(Record.readSubStmt());
1659   S->setAtSynchronizedLoc(readSourceLocation());
1660 }
1661 
1662 void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1663   VisitStmt(S); // FIXME: no test coverage.
1664   S->setThrowExpr(Record.readSubStmt());
1665   S->setThrowLoc(readSourceLocation());
1666 }
1667 
1668 void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1669   VisitExpr(E);
1670   E->setValue(Record.readInt());
1671   E->setLocation(readSourceLocation());
1672 }
1673 
1674 void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1675   VisitExpr(E);
1676   SourceRange R = Record.readSourceRange();
1677   E->AtLoc = R.getBegin();
1678   E->RParen = R.getEnd();
1679   E->VersionToCheck = Record.readVersionTuple();
1680 }
1681 
1682 //===----------------------------------------------------------------------===//
1683 // C++ Expressions and Statements
1684 //===----------------------------------------------------------------------===//
1685 
1686 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
1687   VisitStmt(S);
1688   S->CatchLoc = readSourceLocation();
1689   S->ExceptionDecl = readDeclAs<VarDecl>();
1690   S->HandlerBlock = Record.readSubStmt();
1691 }
1692 
1693 void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
1694   VisitStmt(S);
1695   assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1696   Record.skipInts(1);
1697   S->TryLoc = readSourceLocation();
1698   S->getStmts()[0] = Record.readSubStmt();
1699   for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1700     S->getStmts()[i + 1] = Record.readSubStmt();
1701 }
1702 
1703 void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1704   VisitStmt(S);
1705   S->ForLoc = readSourceLocation();
1706   S->CoawaitLoc = readSourceLocation();
1707   S->ColonLoc = readSourceLocation();
1708   S->RParenLoc = readSourceLocation();
1709   S->setInit(Record.readSubStmt());
1710   S->setRangeStmt(Record.readSubStmt());
1711   S->setBeginStmt(Record.readSubStmt());
1712   S->setEndStmt(Record.readSubStmt());
1713   S->setCond(Record.readSubExpr());
1714   S->setInc(Record.readSubExpr());
1715   S->setLoopVarStmt(Record.readSubStmt());
1716   S->setBody(Record.readSubStmt());
1717 }
1718 
1719 void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1720   VisitStmt(S);
1721   S->KeywordLoc = readSourceLocation();
1722   S->IsIfExists = Record.readInt();
1723   S->QualifierLoc = Record.readNestedNameSpecifierLoc();
1724   S->NameInfo = Record.readDeclarationNameInfo();
1725   S->SubStmt = Record.readSubStmt();
1726 }
1727 
1728 void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1729   VisitCallExpr(E);
1730   E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1731   E->Range = Record.readSourceRange();
1732 }
1733 
1734 void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1735     CXXRewrittenBinaryOperator *E) {
1736   VisitExpr(E);
1737   E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1738   E->SemanticForm = Record.readSubExpr();
1739 }
1740 
1741 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
1742   VisitExpr(E);
1743 
1744   unsigned NumArgs = Record.readInt();
1745   assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1746 
1747   E->CXXConstructExprBits.Elidable = Record.readInt();
1748   E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1749   E->CXXConstructExprBits.ListInitialization = Record.readInt();
1750   E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1751   E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1752   E->CXXConstructExprBits.ConstructionKind = Record.readInt();
1753   E->CXXConstructExprBits.IsImmediateEscalating = Record.readInt();
1754   E->CXXConstructExprBits.Loc = readSourceLocation();
1755   E->Constructor = readDeclAs<CXXConstructorDecl>();
1756   E->ParenOrBraceRange = readSourceRange();
1757 
1758   for (unsigned I = 0; I != NumArgs; ++I)
1759     E->setArg(I, Record.readSubExpr());
1760 }
1761 
1762 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1763   VisitExpr(E);
1764   E->Constructor = readDeclAs<CXXConstructorDecl>();
1765   E->Loc = readSourceLocation();
1766   E->ConstructsVirtualBase = Record.readInt();
1767   E->InheritedFromVirtualBase = Record.readInt();
1768 }
1769 
1770 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1771   VisitCXXConstructExpr(E);
1772   E->TSI = readTypeSourceInfo();
1773 }
1774 
1775 void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1776   VisitExpr(E);
1777   unsigned NumCaptures = Record.readInt();
1778   (void)NumCaptures;
1779   assert(NumCaptures == E->LambdaExprBits.NumCaptures);
1780   E->IntroducerRange = readSourceRange();
1781   E->LambdaExprBits.CaptureDefault = Record.readInt();
1782   E->CaptureDefaultLoc = readSourceLocation();
1783   E->LambdaExprBits.ExplicitParams = Record.readInt();
1784   E->LambdaExprBits.ExplicitResultType = Record.readInt();
1785   E->ClosingBrace = readSourceLocation();
1786 
1787   // Read capture initializers.
1788   for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1789                                          CEnd = E->capture_init_end();
1790        C != CEnd; ++C)
1791     *C = Record.readSubExpr();
1792 
1793   // The body will be lazily deserialized when needed from the call operator
1794   // declaration.
1795 }
1796 
1797 void
1798 ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1799   VisitExpr(E);
1800   E->SubExpr = Record.readSubExpr();
1801 }
1802 
1803 void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1804   VisitExplicitCastExpr(E);
1805   SourceRange R = readSourceRange();
1806   E->Loc = R.getBegin();
1807   E->RParenLoc = R.getEnd();
1808   if (CurrentUnpackingBits->getNextBit())
1809     E->AngleBrackets = readSourceRange();
1810 }
1811 
1812 void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1813   return VisitCXXNamedCastExpr(E);
1814 }
1815 
1816 void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1817   return VisitCXXNamedCastExpr(E);
1818 }
1819 
1820 void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1821   return VisitCXXNamedCastExpr(E);
1822 }
1823 
1824 void ASTStmtReader::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *E) {
1825   return VisitCXXNamedCastExpr(E);
1826 }
1827 
1828 void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1829   return VisitCXXNamedCastExpr(E);
1830 }
1831 
1832 void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1833   VisitExplicitCastExpr(E);
1834   E->setLParenLoc(readSourceLocation());
1835   E->setRParenLoc(readSourceLocation());
1836 }
1837 
1838 void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1839   VisitExplicitCastExpr(E);
1840   E->KWLoc = readSourceLocation();
1841   E->RParenLoc = readSourceLocation();
1842 }
1843 
1844 void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1845   VisitCallExpr(E);
1846   E->UDSuffixLoc = readSourceLocation();
1847 }
1848 
1849 void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1850   VisitExpr(E);
1851   E->setValue(Record.readInt());
1852   E->setLocation(readSourceLocation());
1853 }
1854 
1855 void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1856   VisitExpr(E);
1857   E->setLocation(readSourceLocation());
1858 }
1859 
1860 void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1861   VisitExpr(E);
1862   E->setSourceRange(readSourceRange());
1863   if (E->isTypeOperand())
1864     E->Operand = readTypeSourceInfo();
1865   else
1866     E->Operand = Record.readSubExpr();
1867 }
1868 
1869 void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
1870   VisitExpr(E);
1871   E->setLocation(readSourceLocation());
1872   E->setImplicit(Record.readInt());
1873   E->setCapturedByCopyInLambdaWithExplicitObjectParameter(Record.readInt());
1874 }
1875 
1876 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
1877   VisitExpr(E);
1878   E->CXXThrowExprBits.ThrowLoc = readSourceLocation();
1879   E->Operand = Record.readSubExpr();
1880   E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
1881 }
1882 
1883 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1884   VisitExpr(E);
1885   E->Param = readDeclAs<ParmVarDecl>();
1886   E->UsedContext = readDeclAs<DeclContext>();
1887   E->CXXDefaultArgExprBits.Loc = readSourceLocation();
1888   E->CXXDefaultArgExprBits.HasRewrittenInit = Record.readInt();
1889   if (E->CXXDefaultArgExprBits.HasRewrittenInit)
1890     *E->getTrailingObjects<Expr *>() = Record.readSubExpr();
1891 }
1892 
1893 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1894   VisitExpr(E);
1895   E->CXXDefaultInitExprBits.HasRewrittenInit = Record.readInt();
1896   E->Field = readDeclAs<FieldDecl>();
1897   E->UsedContext = readDeclAs<DeclContext>();
1898   E->CXXDefaultInitExprBits.Loc = readSourceLocation();
1899   if (E->CXXDefaultInitExprBits.HasRewrittenInit)
1900     *E->getTrailingObjects<Expr *>() = Record.readSubExpr();
1901 }
1902 
1903 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1904   VisitExpr(E);
1905   E->setTemporary(Record.readCXXTemporary());
1906   E->setSubExpr(Record.readSubExpr());
1907 }
1908 
1909 void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1910   VisitExpr(E);
1911   E->TypeInfo = readTypeSourceInfo();
1912   E->CXXScalarValueInitExprBits.RParenLoc = readSourceLocation();
1913 }
1914 
1915 void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
1916   VisitExpr(E);
1917 
1918   bool IsArray = Record.readInt();
1919   bool HasInit = Record.readInt();
1920   unsigned NumPlacementArgs = Record.readInt();
1921   bool IsParenTypeId = Record.readInt();
1922 
1923   E->CXXNewExprBits.IsGlobalNew = Record.readInt();
1924   E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
1925   E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1926   E->CXXNewExprBits.HasInitializer = Record.readInt();
1927   E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
1928 
1929   assert((IsArray == E->isArray()) && "Wrong IsArray!");
1930   assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
1931   assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
1932          "Wrong NumPlacementArgs!");
1933   assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
1934   (void)IsArray;
1935   (void)HasInit;
1936   (void)NumPlacementArgs;
1937 
1938   E->setOperatorNew(readDeclAs<FunctionDecl>());
1939   E->setOperatorDelete(readDeclAs<FunctionDecl>());
1940   E->AllocatedTypeInfo = readTypeSourceInfo();
1941   if (IsParenTypeId)
1942     E->getTrailingObjects<SourceRange>()[0] = readSourceRange();
1943   E->Range = readSourceRange();
1944   E->DirectInitRange = readSourceRange();
1945 
1946   // Install all the subexpressions.
1947   for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
1948                                     N = E->raw_arg_end();
1949        I != N; ++I)
1950     *I = Record.readSubStmt();
1951 }
1952 
1953 void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1954   VisitExpr(E);
1955   E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
1956   E->CXXDeleteExprBits.ArrayForm = Record.readInt();
1957   E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
1958   E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1959   E->OperatorDelete = readDeclAs<FunctionDecl>();
1960   E->Argument = Record.readSubExpr();
1961   E->CXXDeleteExprBits.Loc = readSourceLocation();
1962 }
1963 
1964 void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1965   VisitExpr(E);
1966 
1967   E->Base = Record.readSubExpr();
1968   E->IsArrow = Record.readInt();
1969   E->OperatorLoc = readSourceLocation();
1970   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1971   E->ScopeType = readTypeSourceInfo();
1972   E->ColonColonLoc = readSourceLocation();
1973   E->TildeLoc = readSourceLocation();
1974 
1975   IdentifierInfo *II = Record.readIdentifier();
1976   if (II)
1977     E->setDestroyedType(II, readSourceLocation());
1978   else
1979     E->setDestroyedType(readTypeSourceInfo());
1980 }
1981 
1982 void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
1983   VisitExpr(E);
1984 
1985   unsigned NumObjects = Record.readInt();
1986   assert(NumObjects == E->getNumObjects());
1987   for (unsigned i = 0; i != NumObjects; ++i) {
1988     unsigned CleanupKind = Record.readInt();
1989     ExprWithCleanups::CleanupObject Obj;
1990     if (CleanupKind == COK_Block)
1991       Obj = readDeclAs<BlockDecl>();
1992     else if (CleanupKind == COK_CompoundLiteral)
1993       Obj = cast<CompoundLiteralExpr>(Record.readSubExpr());
1994     else
1995       llvm_unreachable("unexpected cleanup object type");
1996     E->getTrailingObjects<ExprWithCleanups::CleanupObject>()[i] = Obj;
1997   }
1998 
1999   E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
2000   E->SubExpr = Record.readSubExpr();
2001 }
2002 
2003 void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
2004     CXXDependentScopeMemberExpr *E) {
2005   VisitExpr(E);
2006 
2007   unsigned NumTemplateArgs = Record.readInt();
2008   CurrentUnpackingBits.emplace(Record.readInt());
2009   bool HasTemplateKWAndArgsInfo = CurrentUnpackingBits->getNextBit();
2010   bool HasFirstQualifierFoundInScope = CurrentUnpackingBits->getNextBit();
2011 
2012   assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
2013          "Wrong HasTemplateKWAndArgsInfo!");
2014   assert(
2015       (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
2016       "Wrong HasFirstQualifierFoundInScope!");
2017 
2018   if (HasTemplateKWAndArgsInfo)
2019     ReadTemplateKWAndArgsInfo(
2020         *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
2021         E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
2022 
2023   assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
2024          "Wrong NumTemplateArgs!");
2025 
2026   E->CXXDependentScopeMemberExprBits.IsArrow =
2027       CurrentUnpackingBits->getNextBit();
2028 
2029   E->BaseType = Record.readType();
2030   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
2031   // not ImplicitAccess
2032   if (CurrentUnpackingBits->getNextBit())
2033     E->Base = Record.readSubExpr();
2034   else
2035     E->Base = nullptr;
2036 
2037   E->CXXDependentScopeMemberExprBits.OperatorLoc = readSourceLocation();
2038 
2039   if (HasFirstQualifierFoundInScope)
2040     *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
2041 
2042   E->MemberNameInfo = Record.readDeclarationNameInfo();
2043 }
2044 
2045 void
2046 ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
2047   VisitExpr(E);
2048 
2049   if (CurrentUnpackingBits->getNextBit()) // HasTemplateKWAndArgsInfo
2050     ReadTemplateKWAndArgsInfo(
2051         *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
2052         E->getTrailingObjects<TemplateArgumentLoc>(),
2053         /*NumTemplateArgs=*/CurrentUnpackingBits->getNextBits(/*Width=*/16));
2054 
2055   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
2056   E->NameInfo = Record.readDeclarationNameInfo();
2057 }
2058 
2059 void
2060 ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
2061   VisitExpr(E);
2062   assert(Record.peekInt() == E->getNumArgs() &&
2063          "Read wrong record during creation ?");
2064   Record.skipInts(1);
2065   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
2066     E->setArg(I, Record.readSubExpr());
2067   E->TypeAndInitForm.setPointer(readTypeSourceInfo());
2068   E->setLParenLoc(readSourceLocation());
2069   E->setRParenLoc(readSourceLocation());
2070   E->TypeAndInitForm.setInt(Record.readInt());
2071 }
2072 
2073 void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
2074   VisitExpr(E);
2075 
2076   unsigned NumResults = Record.readInt();
2077   CurrentUnpackingBits.emplace(Record.readInt());
2078   bool HasTemplateKWAndArgsInfo = CurrentUnpackingBits->getNextBit();
2079   assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
2080   assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
2081          "Wrong HasTemplateKWAndArgsInfo!");
2082 
2083   if (HasTemplateKWAndArgsInfo) {
2084     unsigned NumTemplateArgs = Record.readInt();
2085     ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
2086                               E->getTrailingTemplateArgumentLoc(),
2087                               NumTemplateArgs);
2088     assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
2089            "Wrong NumTemplateArgs!");
2090   }
2091 
2092   UnresolvedSet<8> Decls;
2093   for (unsigned I = 0; I != NumResults; ++I) {
2094     auto *D = readDeclAs<NamedDecl>();
2095     auto AS = (AccessSpecifier)Record.readInt();
2096     Decls.addDecl(D, AS);
2097   }
2098 
2099   DeclAccessPair *Results = E->getTrailingResults();
2100   UnresolvedSetIterator Iter = Decls.begin();
2101   for (unsigned I = 0; I != NumResults; ++I) {
2102     Results[I] = (Iter + I).getPair();
2103   }
2104 
2105   E->NameInfo = Record.readDeclarationNameInfo();
2106   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
2107 }
2108 
2109 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
2110   VisitOverloadExpr(E);
2111   E->UnresolvedMemberExprBits.IsArrow = CurrentUnpackingBits->getNextBit();
2112   E->UnresolvedMemberExprBits.HasUnresolvedUsing =
2113       CurrentUnpackingBits->getNextBit();
2114 
2115   if (/*!isImplicitAccess=*/CurrentUnpackingBits->getNextBit())
2116     E->Base = Record.readSubExpr();
2117   else
2118     E->Base = nullptr;
2119 
2120   E->OperatorLoc = readSourceLocation();
2121 
2122   E->BaseType = Record.readType();
2123 }
2124 
2125 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
2126   VisitOverloadExpr(E);
2127   E->UnresolvedLookupExprBits.RequiresADL = CurrentUnpackingBits->getNextBit();
2128   E->NamingClass = readDeclAs<CXXRecordDecl>();
2129 }
2130 
2131 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
2132   VisitExpr(E);
2133   E->TypeTraitExprBits.NumArgs = Record.readInt();
2134   E->TypeTraitExprBits.Kind = Record.readInt();
2135   E->TypeTraitExprBits.Value = Record.readInt();
2136   SourceRange Range = readSourceRange();
2137   E->Loc = Range.getBegin();
2138   E->RParenLoc = Range.getEnd();
2139 
2140   auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
2141   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
2142     Args[I] = readTypeSourceInfo();
2143 }
2144 
2145 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
2146   VisitExpr(E);
2147   E->ATT = (ArrayTypeTrait)Record.readInt();
2148   E->Value = (unsigned int)Record.readInt();
2149   SourceRange Range = readSourceRange();
2150   E->Loc = Range.getBegin();
2151   E->RParen = Range.getEnd();
2152   E->QueriedType = readTypeSourceInfo();
2153   E->Dimension = Record.readSubExpr();
2154 }
2155 
2156 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
2157   VisitExpr(E);
2158   E->ET = (ExpressionTrait)Record.readInt();
2159   E->Value = (bool)Record.readInt();
2160   SourceRange Range = readSourceRange();
2161   E->QueriedExpression = Record.readSubExpr();
2162   E->Loc = Range.getBegin();
2163   E->RParen = Range.getEnd();
2164 }
2165 
2166 void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
2167   VisitExpr(E);
2168   E->CXXNoexceptExprBits.Value = Record.readInt();
2169   E->Range = readSourceRange();
2170   E->Operand = Record.readSubExpr();
2171 }
2172 
2173 void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
2174   VisitExpr(E);
2175   E->EllipsisLoc = readSourceLocation();
2176   E->NumExpansions = Record.readInt();
2177   E->Pattern = Record.readSubExpr();
2178 }
2179 
2180 void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2181   VisitExpr(E);
2182   unsigned NumPartialArgs = Record.readInt();
2183   E->OperatorLoc = readSourceLocation();
2184   E->PackLoc = readSourceLocation();
2185   E->RParenLoc = readSourceLocation();
2186   E->Pack = Record.readDeclAs<NamedDecl>();
2187   if (E->isPartiallySubstituted()) {
2188     assert(E->Length == NumPartialArgs);
2189     for (auto *I = E->getTrailingObjects<TemplateArgument>(),
2190               *E = I + NumPartialArgs;
2191          I != E; ++I)
2192       new (I) TemplateArgument(Record.readTemplateArgument());
2193   } else if (!E->isValueDependent()) {
2194     E->Length = Record.readInt();
2195   }
2196 }
2197 
2198 void ASTStmtReader::VisitPackIndexingExpr(PackIndexingExpr *E) {
2199   VisitExpr(E);
2200   E->TransformedExpressions = Record.readInt();
2201   E->FullySubstituted = Record.readInt();
2202   E->EllipsisLoc = readSourceLocation();
2203   E->RSquareLoc = readSourceLocation();
2204   E->SubExprs[0] = Record.readStmt();
2205   E->SubExprs[1] = Record.readStmt();
2206   auto **Exprs = E->getTrailingObjects<Expr *>();
2207   for (unsigned I = 0; I < E->TransformedExpressions; ++I)
2208     Exprs[I] = Record.readExpr();
2209 }
2210 
2211 void ASTStmtReader::VisitResolvedUnexpandedPackExpr(
2212     ResolvedUnexpandedPackExpr *E) {
2213   VisitExpr(E);
2214   E->NumExprs = Record.readInt();
2215   E->BeginLoc = readSourceLocation();
2216   auto **Exprs = E->getTrailingObjects<Expr *>();
2217   for (unsigned I = 0; I < E->NumExprs; ++I)
2218     Exprs[I] = Record.readExpr();
2219 }
2220 
2221 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
2222                                               SubstNonTypeTemplateParmExpr *E) {
2223   VisitExpr(E);
2224   E->AssociatedDeclAndRef.setPointer(readDeclAs<Decl>());
2225   E->AssociatedDeclAndRef.setInt(CurrentUnpackingBits->getNextBit());
2226   E->Index = CurrentUnpackingBits->getNextBits(/*Width=*/12);
2227   if (CurrentUnpackingBits->getNextBit())
2228     E->PackIndex = Record.readInt();
2229   else
2230     E->PackIndex = 0;
2231   E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
2232   E->Replacement = Record.readSubExpr();
2233 }
2234 
2235 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
2236                                           SubstNonTypeTemplateParmPackExpr *E) {
2237   VisitExpr(E);
2238   E->AssociatedDecl = readDeclAs<Decl>();
2239   E->Index = Record.readInt();
2240   TemplateArgument ArgPack = Record.readTemplateArgument();
2241   if (ArgPack.getKind() != TemplateArgument::Pack)
2242     return;
2243 
2244   E->Arguments = ArgPack.pack_begin();
2245   E->NumArguments = ArgPack.pack_size();
2246   E->NameLoc = readSourceLocation();
2247 }
2248 
2249 void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2250   VisitExpr(E);
2251   E->NumParameters = Record.readInt();
2252   E->ParamPack = readDeclAs<ParmVarDecl>();
2253   E->NameLoc = readSourceLocation();
2254   auto **Parms = E->getTrailingObjects<VarDecl *>();
2255   for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
2256     Parms[i] = readDeclAs<VarDecl>();
2257 }
2258 
2259 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
2260   VisitExpr(E);
2261   bool HasMaterialzedDecl = Record.readInt();
2262   if (HasMaterialzedDecl)
2263     E->State = cast<LifetimeExtendedTemporaryDecl>(Record.readDecl());
2264   else
2265     E->State = Record.readSubExpr();
2266 }
2267 
2268 void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
2269   VisitExpr(E);
2270   E->LParenLoc = readSourceLocation();
2271   E->EllipsisLoc = readSourceLocation();
2272   E->RParenLoc = readSourceLocation();
2273   E->NumExpansions = Record.readInt();
2274   E->SubExprs[0] = Record.readSubExpr();
2275   E->SubExprs[1] = Record.readSubExpr();
2276   E->SubExprs[2] = Record.readSubExpr();
2277   E->Opcode = (BinaryOperatorKind)Record.readInt();
2278 }
2279 
2280 void ASTStmtReader::VisitCXXParenListInitExpr(CXXParenListInitExpr *E) {
2281   VisitExpr(E);
2282   unsigned ExpectedNumExprs = Record.readInt();
2283   assert(E->NumExprs == ExpectedNumExprs &&
2284          "expected number of expressions does not equal the actual number of "
2285          "serialized expressions.");
2286   E->NumUserSpecifiedExprs = Record.readInt();
2287   E->InitLoc = readSourceLocation();
2288   E->LParenLoc = readSourceLocation();
2289   E->RParenLoc = readSourceLocation();
2290   for (unsigned I = 0; I < ExpectedNumExprs; I++)
2291     E->getTrailingObjects<Expr *>()[I] = Record.readSubExpr();
2292 
2293   bool HasArrayFillerOrUnionDecl = Record.readBool();
2294   if (HasArrayFillerOrUnionDecl) {
2295     bool HasArrayFiller = Record.readBool();
2296     if (HasArrayFiller) {
2297       E->setArrayFiller(Record.readSubExpr());
2298     } else {
2299       E->setInitializedFieldInUnion(readDeclAs<FieldDecl>());
2300     }
2301   }
2302   E->updateDependence();
2303 }
2304 
2305 void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
2306   VisitExpr(E);
2307   E->SourceExpr = Record.readSubExpr();
2308   E->OpaqueValueExprBits.Loc = readSourceLocation();
2309   E->setIsUnique(Record.readInt());
2310 }
2311 
2312 void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
2313   llvm_unreachable("Cannot read TypoExpr nodes");
2314 }
2315 
2316 void ASTStmtReader::VisitRecoveryExpr(RecoveryExpr *E) {
2317   VisitExpr(E);
2318   unsigned NumArgs = Record.readInt();
2319   E->BeginLoc = readSourceLocation();
2320   E->EndLoc = readSourceLocation();
2321   assert((NumArgs + 0LL ==
2322           std::distance(E->children().begin(), E->children().end())) &&
2323          "Wrong NumArgs!");
2324   (void)NumArgs;
2325   for (Stmt *&Child : E->children())
2326     Child = Record.readSubStmt();
2327 }
2328 
2329 //===----------------------------------------------------------------------===//
2330 // Microsoft Expressions and Statements
2331 //===----------------------------------------------------------------------===//
2332 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
2333   VisitExpr(E);
2334   E->IsArrow = (Record.readInt() != 0);
2335   E->BaseExpr = Record.readSubExpr();
2336   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
2337   E->MemberLoc = readSourceLocation();
2338   E->TheDecl = readDeclAs<MSPropertyDecl>();
2339 }
2340 
2341 void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
2342   VisitExpr(E);
2343   E->setBase(Record.readSubExpr());
2344   E->setIdx(Record.readSubExpr());
2345   E->setRBracketLoc(readSourceLocation());
2346 }
2347 
2348 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
2349   VisitExpr(E);
2350   E->setSourceRange(readSourceRange());
2351   E->Guid = readDeclAs<MSGuidDecl>();
2352   if (E->isTypeOperand())
2353     E->Operand = readTypeSourceInfo();
2354   else
2355     E->Operand = Record.readSubExpr();
2356 }
2357 
2358 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
2359   VisitStmt(S);
2360   S->setLeaveLoc(readSourceLocation());
2361 }
2362 
2363 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
2364   VisitStmt(S);
2365   S->Loc = readSourceLocation();
2366   S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
2367   S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
2368 }
2369 
2370 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
2371   VisitStmt(S);
2372   S->Loc = readSourceLocation();
2373   S->Block = Record.readSubStmt();
2374 }
2375 
2376 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
2377   VisitStmt(S);
2378   S->IsCXXTry = Record.readInt();
2379   S->TryLoc = readSourceLocation();
2380   S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
2381   S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
2382 }
2383 
2384 //===----------------------------------------------------------------------===//
2385 // CUDA Expressions and Statements
2386 //===----------------------------------------------------------------------===//
2387 
2388 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2389   VisitCallExpr(E);
2390   E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
2391 }
2392 
2393 //===----------------------------------------------------------------------===//
2394 // OpenCL Expressions and Statements.
2395 //===----------------------------------------------------------------------===//
2396 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2397   VisitExpr(E);
2398   E->BuiltinLoc = readSourceLocation();
2399   E->RParenLoc = readSourceLocation();
2400   E->SrcExpr = Record.readSubExpr();
2401 }
2402 
2403 //===----------------------------------------------------------------------===//
2404 // OpenMP Directives.
2405 //===----------------------------------------------------------------------===//
2406 
2407 void ASTStmtReader::VisitOMPCanonicalLoop(OMPCanonicalLoop *S) {
2408   VisitStmt(S);
2409   for (Stmt *&SubStmt : S->SubStmts)
2410     SubStmt = Record.readSubStmt();
2411 }
2412 
2413 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
2414   Record.readOMPChildren(E->Data);
2415   E->setLocStart(readSourceLocation());
2416   E->setLocEnd(readSourceLocation());
2417 }
2418 
2419 void ASTStmtReader::VisitOMPLoopBasedDirective(OMPLoopBasedDirective *D) {
2420   VisitStmt(D);
2421   // Field CollapsedNum was read in ReadStmtFromStream.
2422   Record.skipInts(1);
2423   VisitOMPExecutableDirective(D);
2424 }
2425 
2426 void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2427   VisitOMPLoopBasedDirective(D);
2428 }
2429 
2430 void ASTStmtReader::VisitOMPMetaDirective(OMPMetaDirective *D) {
2431   VisitStmt(D);
2432   // The NumClauses field was read in ReadStmtFromStream.
2433   Record.skipInts(1);
2434   VisitOMPExecutableDirective(D);
2435 }
2436 
2437 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
2438   VisitStmt(D);
2439   VisitOMPExecutableDirective(D);
2440   D->setHasCancel(Record.readBool());
2441 }
2442 
2443 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
2444   VisitOMPLoopDirective(D);
2445 }
2446 
2447 void ASTStmtReader::VisitOMPLoopTransformationDirective(
2448     OMPLoopTransformationDirective *D) {
2449   VisitOMPLoopBasedDirective(D);
2450   D->setNumGeneratedLoops(Record.readUInt32());
2451 }
2452 
2453 void ASTStmtReader::VisitOMPTileDirective(OMPTileDirective *D) {
2454   VisitOMPLoopTransformationDirective(D);
2455 }
2456 
2457 void ASTStmtReader::VisitOMPUnrollDirective(OMPUnrollDirective *D) {
2458   VisitOMPLoopTransformationDirective(D);
2459 }
2460 
2461 void ASTStmtReader::VisitOMPReverseDirective(OMPReverseDirective *D) {
2462   VisitOMPLoopTransformationDirective(D);
2463 }
2464 
2465 void ASTStmtReader::VisitOMPInterchangeDirective(OMPInterchangeDirective *D) {
2466   VisitOMPLoopTransformationDirective(D);
2467 }
2468 
2469 void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
2470   VisitOMPLoopDirective(D);
2471   D->setHasCancel(Record.readBool());
2472 }
2473 
2474 void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2475   VisitOMPLoopDirective(D);
2476 }
2477 
2478 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2479   VisitStmt(D);
2480   VisitOMPExecutableDirective(D);
2481   D->setHasCancel(Record.readBool());
2482 }
2483 
2484 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2485   VisitStmt(D);
2486   VisitOMPExecutableDirective(D);
2487   D->setHasCancel(Record.readBool());
2488 }
2489 
2490 void ASTStmtReader::VisitOMPScopeDirective(OMPScopeDirective *D) {
2491   VisitStmt(D);
2492   VisitOMPExecutableDirective(D);
2493 }
2494 
2495 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2496   VisitStmt(D);
2497   VisitOMPExecutableDirective(D);
2498 }
2499 
2500 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2501   VisitStmt(D);
2502   VisitOMPExecutableDirective(D);
2503 }
2504 
2505 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2506   VisitStmt(D);
2507   VisitOMPExecutableDirective(D);
2508   D->DirName = Record.readDeclarationNameInfo();
2509 }
2510 
2511 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
2512   VisitOMPLoopDirective(D);
2513   D->setHasCancel(Record.readBool());
2514 }
2515 
2516 void ASTStmtReader::VisitOMPParallelForSimdDirective(
2517     OMPParallelForSimdDirective *D) {
2518   VisitOMPLoopDirective(D);
2519 }
2520 
2521 void ASTStmtReader::VisitOMPParallelMasterDirective(
2522     OMPParallelMasterDirective *D) {
2523   VisitStmt(D);
2524   VisitOMPExecutableDirective(D);
2525 }
2526 
2527 void ASTStmtReader::VisitOMPParallelMaskedDirective(
2528     OMPParallelMaskedDirective *D) {
2529   VisitStmt(D);
2530   VisitOMPExecutableDirective(D);
2531 }
2532 
2533 void ASTStmtReader::VisitOMPParallelSectionsDirective(
2534     OMPParallelSectionsDirective *D) {
2535   VisitStmt(D);
2536   VisitOMPExecutableDirective(D);
2537   D->setHasCancel(Record.readBool());
2538 }
2539 
2540 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2541   VisitStmt(D);
2542   VisitOMPExecutableDirective(D);
2543   D->setHasCancel(Record.readBool());
2544 }
2545 
2546 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2547   VisitStmt(D);
2548   VisitOMPExecutableDirective(D);
2549 }
2550 
2551 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2552   VisitStmt(D);
2553   VisitOMPExecutableDirective(D);
2554 }
2555 
2556 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2557   VisitStmt(D);
2558   // The NumClauses field was read in ReadStmtFromStream.
2559   Record.skipInts(1);
2560   VisitOMPExecutableDirective(D);
2561 }
2562 
2563 void ASTStmtReader::VisitOMPAssumeDirective(OMPAssumeDirective *D) {
2564   VisitStmt(D);
2565   VisitOMPExecutableDirective(D);
2566 }
2567 
2568 void ASTStmtReader::VisitOMPErrorDirective(OMPErrorDirective *D) {
2569   VisitStmt(D);
2570   // The NumClauses field was read in ReadStmtFromStream.
2571   Record.skipInts(1);
2572   VisitOMPExecutableDirective(D);
2573 }
2574 
2575 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2576   VisitStmt(D);
2577   VisitOMPExecutableDirective(D);
2578 }
2579 
2580 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2581   VisitStmt(D);
2582   VisitOMPExecutableDirective(D);
2583 }
2584 
2585 void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective *D) {
2586   VisitStmt(D);
2587   VisitOMPExecutableDirective(D);
2588 }
2589 
2590 void ASTStmtReader::VisitOMPScanDirective(OMPScanDirective *D) {
2591   VisitStmt(D);
2592   VisitOMPExecutableDirective(D);
2593 }
2594 
2595 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2596   VisitStmt(D);
2597   VisitOMPExecutableDirective(D);
2598 }
2599 
2600 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2601   VisitStmt(D);
2602   VisitOMPExecutableDirective(D);
2603   D->Flags.IsXLHSInRHSPart = Record.readBool() ? 1 : 0;
2604   D->Flags.IsPostfixUpdate = Record.readBool() ? 1 : 0;
2605   D->Flags.IsFailOnly = Record.readBool() ? 1 : 0;
2606 }
2607 
2608 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2609   VisitStmt(D);
2610   VisitOMPExecutableDirective(D);
2611 }
2612 
2613 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2614   VisitStmt(D);
2615   VisitOMPExecutableDirective(D);
2616 }
2617 
2618 void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2619     OMPTargetEnterDataDirective *D) {
2620   VisitStmt(D);
2621   VisitOMPExecutableDirective(D);
2622 }
2623 
2624 void ASTStmtReader::VisitOMPTargetExitDataDirective(
2625     OMPTargetExitDataDirective *D) {
2626   VisitStmt(D);
2627   VisitOMPExecutableDirective(D);
2628 }
2629 
2630 void ASTStmtReader::VisitOMPTargetParallelDirective(
2631     OMPTargetParallelDirective *D) {
2632   VisitStmt(D);
2633   VisitOMPExecutableDirective(D);
2634   D->setHasCancel(Record.readBool());
2635 }
2636 
2637 void ASTStmtReader::VisitOMPTargetParallelForDirective(
2638     OMPTargetParallelForDirective *D) {
2639   VisitOMPLoopDirective(D);
2640   D->setHasCancel(Record.readBool());
2641 }
2642 
2643 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2644   VisitStmt(D);
2645   VisitOMPExecutableDirective(D);
2646 }
2647 
2648 void ASTStmtReader::VisitOMPCancellationPointDirective(
2649     OMPCancellationPointDirective *D) {
2650   VisitStmt(D);
2651   VisitOMPExecutableDirective(D);
2652   D->setCancelRegion(Record.readEnum<OpenMPDirectiveKind>());
2653 }
2654 
2655 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2656   VisitStmt(D);
2657   VisitOMPExecutableDirective(D);
2658   D->setCancelRegion(Record.readEnum<OpenMPDirectiveKind>());
2659 }
2660 
2661 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2662   VisitOMPLoopDirective(D);
2663   D->setHasCancel(Record.readBool());
2664 }
2665 
2666 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2667   VisitOMPLoopDirective(D);
2668 }
2669 
2670 void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2671     OMPMasterTaskLoopDirective *D) {
2672   VisitOMPLoopDirective(D);
2673   D->setHasCancel(Record.readBool());
2674 }
2675 
2676 void ASTStmtReader::VisitOMPMaskedTaskLoopDirective(
2677     OMPMaskedTaskLoopDirective *D) {
2678   VisitOMPLoopDirective(D);
2679   D->setHasCancel(Record.readBool());
2680 }
2681 
2682 void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2683     OMPMasterTaskLoopSimdDirective *D) {
2684   VisitOMPLoopDirective(D);
2685 }
2686 
2687 void ASTStmtReader::VisitOMPMaskedTaskLoopSimdDirective(
2688     OMPMaskedTaskLoopSimdDirective *D) {
2689   VisitOMPLoopDirective(D);
2690 }
2691 
2692 void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2693     OMPParallelMasterTaskLoopDirective *D) {
2694   VisitOMPLoopDirective(D);
2695   D->setHasCancel(Record.readBool());
2696 }
2697 
2698 void ASTStmtReader::VisitOMPParallelMaskedTaskLoopDirective(
2699     OMPParallelMaskedTaskLoopDirective *D) {
2700   VisitOMPLoopDirective(D);
2701   D->setHasCancel(Record.readBool());
2702 }
2703 
2704 void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2705     OMPParallelMasterTaskLoopSimdDirective *D) {
2706   VisitOMPLoopDirective(D);
2707 }
2708 
2709 void ASTStmtReader::VisitOMPParallelMaskedTaskLoopSimdDirective(
2710     OMPParallelMaskedTaskLoopSimdDirective *D) {
2711   VisitOMPLoopDirective(D);
2712 }
2713 
2714 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2715   VisitOMPLoopDirective(D);
2716 }
2717 
2718 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2719   VisitStmt(D);
2720   VisitOMPExecutableDirective(D);
2721 }
2722 
2723 void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2724     OMPDistributeParallelForDirective *D) {
2725   VisitOMPLoopDirective(D);
2726   D->setHasCancel(Record.readBool());
2727 }
2728 
2729 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2730     OMPDistributeParallelForSimdDirective *D) {
2731   VisitOMPLoopDirective(D);
2732 }
2733 
2734 void ASTStmtReader::VisitOMPDistributeSimdDirective(
2735     OMPDistributeSimdDirective *D) {
2736   VisitOMPLoopDirective(D);
2737 }
2738 
2739 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2740     OMPTargetParallelForSimdDirective *D) {
2741   VisitOMPLoopDirective(D);
2742 }
2743 
2744 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2745   VisitOMPLoopDirective(D);
2746 }
2747 
2748 void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2749     OMPTeamsDistributeDirective *D) {
2750   VisitOMPLoopDirective(D);
2751 }
2752 
2753 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2754     OMPTeamsDistributeSimdDirective *D) {
2755   VisitOMPLoopDirective(D);
2756 }
2757 
2758 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2759     OMPTeamsDistributeParallelForSimdDirective *D) {
2760   VisitOMPLoopDirective(D);
2761 }
2762 
2763 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2764     OMPTeamsDistributeParallelForDirective *D) {
2765   VisitOMPLoopDirective(D);
2766   D->setHasCancel(Record.readBool());
2767 }
2768 
2769 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2770   VisitStmt(D);
2771   VisitOMPExecutableDirective(D);
2772 }
2773 
2774 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2775     OMPTargetTeamsDistributeDirective *D) {
2776   VisitOMPLoopDirective(D);
2777 }
2778 
2779 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2780     OMPTargetTeamsDistributeParallelForDirective *D) {
2781   VisitOMPLoopDirective(D);
2782   D->setHasCancel(Record.readBool());
2783 }
2784 
2785 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2786     OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2787   VisitOMPLoopDirective(D);
2788 }
2789 
2790 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2791     OMPTargetTeamsDistributeSimdDirective *D) {
2792   VisitOMPLoopDirective(D);
2793 }
2794 
2795 void ASTStmtReader::VisitOMPInteropDirective(OMPInteropDirective *D) {
2796   VisitStmt(D);
2797   VisitOMPExecutableDirective(D);
2798 }
2799 
2800 void ASTStmtReader::VisitOMPDispatchDirective(OMPDispatchDirective *D) {
2801   VisitStmt(D);
2802   VisitOMPExecutableDirective(D);
2803   D->setTargetCallLoc(Record.readSourceLocation());
2804 }
2805 
2806 void ASTStmtReader::VisitOMPMaskedDirective(OMPMaskedDirective *D) {
2807   VisitStmt(D);
2808   VisitOMPExecutableDirective(D);
2809 }
2810 
2811 void ASTStmtReader::VisitOMPGenericLoopDirective(OMPGenericLoopDirective *D) {
2812   VisitOMPLoopDirective(D);
2813 }
2814 
2815 void ASTStmtReader::VisitOMPTeamsGenericLoopDirective(
2816     OMPTeamsGenericLoopDirective *D) {
2817   VisitOMPLoopDirective(D);
2818 }
2819 
2820 void ASTStmtReader::VisitOMPTargetTeamsGenericLoopDirective(
2821     OMPTargetTeamsGenericLoopDirective *D) {
2822   VisitOMPLoopDirective(D);
2823   D->setCanBeParallelFor(Record.readBool());
2824 }
2825 
2826 void ASTStmtReader::VisitOMPParallelGenericLoopDirective(
2827     OMPParallelGenericLoopDirective *D) {
2828   VisitOMPLoopDirective(D);
2829 }
2830 
2831 void ASTStmtReader::VisitOMPTargetParallelGenericLoopDirective(
2832     OMPTargetParallelGenericLoopDirective *D) {
2833   VisitOMPLoopDirective(D);
2834 }
2835 
2836 //===----------------------------------------------------------------------===//
2837 // OpenACC Constructs/Directives.
2838 //===----------------------------------------------------------------------===//
2839 void ASTStmtReader::VisitOpenACCConstructStmt(OpenACCConstructStmt *S) {
2840   (void)Record.readInt();
2841   S->Kind = Record.readEnum<OpenACCDirectiveKind>();
2842   S->Range = Record.readSourceRange();
2843   S->DirectiveLoc = Record.readSourceLocation();
2844   Record.readOpenACCClauseList(S->Clauses);
2845 }
2846 
2847 void ASTStmtReader::VisitOpenACCAssociatedStmtConstruct(
2848     OpenACCAssociatedStmtConstruct *S) {
2849   VisitOpenACCConstructStmt(S);
2850   S->setAssociatedStmt(Record.readSubStmt());
2851 }
2852 
2853 void ASTStmtReader::VisitOpenACCComputeConstruct(OpenACCComputeConstruct *S) {
2854   VisitStmt(S);
2855   VisitOpenACCAssociatedStmtConstruct(S);
2856 }
2857 
2858 void ASTStmtReader::VisitOpenACCLoopConstruct(OpenACCLoopConstruct *S) {
2859   VisitStmt(S);
2860   VisitOpenACCAssociatedStmtConstruct(S);
2861   S->ParentComputeConstructKind = Record.readEnum<OpenACCDirectiveKind>();
2862 }
2863 
2864 void ASTStmtReader::VisitOpenACCCombinedConstruct(OpenACCCombinedConstruct *S) {
2865   VisitStmt(S);
2866   VisitOpenACCAssociatedStmtConstruct(S);
2867 }
2868 
2869 void ASTStmtReader::VisitOpenACCDataConstruct(OpenACCDataConstruct *S) {
2870   VisitStmt(S);
2871   VisitOpenACCAssociatedStmtConstruct(S);
2872 }
2873 
2874 void ASTStmtReader::VisitOpenACCEnterDataConstruct(
2875     OpenACCEnterDataConstruct *S) {
2876   VisitStmt(S);
2877   VisitOpenACCConstructStmt(S);
2878 }
2879 
2880 void ASTStmtReader::VisitOpenACCExitDataConstruct(OpenACCExitDataConstruct *S) {
2881   VisitStmt(S);
2882   VisitOpenACCConstructStmt(S);
2883 }
2884 
2885 void ASTStmtReader::VisitOpenACCInitConstruct(OpenACCInitConstruct *S) {
2886   VisitStmt(S);
2887   VisitOpenACCConstructStmt(S);
2888 }
2889 
2890 void ASTStmtReader::VisitOpenACCShutdownConstruct(OpenACCShutdownConstruct *S) {
2891   VisitStmt(S);
2892   VisitOpenACCConstructStmt(S);
2893 }
2894 
2895 void ASTStmtReader::VisitOpenACCSetConstruct(OpenACCSetConstruct *S) {
2896   VisitStmt(S);
2897   VisitOpenACCConstructStmt(S);
2898 }
2899 
2900 void ASTStmtReader::VisitOpenACCUpdateConstruct(OpenACCUpdateConstruct *S) {
2901   VisitStmt(S);
2902   VisitOpenACCConstructStmt(S);
2903 }
2904 
2905 void ASTStmtReader::VisitOpenACCHostDataConstruct(OpenACCHostDataConstruct *S) {
2906   VisitStmt(S);
2907   VisitOpenACCAssociatedStmtConstruct(S);
2908 }
2909 
2910 void ASTStmtReader::VisitOpenACCWaitConstruct(OpenACCWaitConstruct *S) {
2911   VisitStmt(S);
2912   // Consume the count of Expressions.
2913   (void)Record.readInt();
2914   VisitOpenACCConstructStmt(S);
2915   S->LParenLoc = Record.readSourceLocation();
2916   S->RParenLoc = Record.readSourceLocation();
2917   S->QueuesLoc = Record.readSourceLocation();
2918 
2919   for (unsigned I = 0; I < S->NumExprs; ++I) {
2920     S->getExprPtr()[I] = cast_if_present<Expr>(Record.readSubStmt());
2921     assert((I == 0 || S->getExprPtr()[I] != nullptr) &&
2922            "Only first expression should be null");
2923   }
2924 }
2925 
2926 //===----------------------------------------------------------------------===//
2927 // HLSL Constructs/Directives.
2928 //===----------------------------------------------------------------------===//
2929 
2930 void ASTStmtReader::VisitHLSLOutArgExpr(HLSLOutArgExpr *S) {
2931   VisitExpr(S);
2932   S->SubExprs[HLSLOutArgExpr::BaseLValue] = Record.readSubExpr();
2933   S->SubExprs[HLSLOutArgExpr::CastedTemporary] = Record.readSubExpr();
2934   S->SubExprs[HLSLOutArgExpr::WritebackCast] = Record.readSubExpr();
2935   S->IsInOut = Record.readBool();
2936 }
2937 
2938 //===----------------------------------------------------------------------===//
2939 // ASTReader Implementation
2940 //===----------------------------------------------------------------------===//
2941 
2942 Stmt *ASTReader::ReadStmt(ModuleFile &F) {
2943   switch (ReadingKind) {
2944   case Read_None:
2945     llvm_unreachable("should not call this when not reading anything");
2946   case Read_Decl:
2947   case Read_Type:
2948     return ReadStmtFromStream(F);
2949   case Read_Stmt:
2950     return ReadSubStmt();
2951   }
2952 
2953   llvm_unreachable("ReadingKind not set ?");
2954 }
2955 
2956 Expr *ASTReader::ReadExpr(ModuleFile &F) {
2957   return cast_or_null<Expr>(ReadStmt(F));
2958 }
2959 
2960 Expr *ASTReader::ReadSubExpr() {
2961   return cast_or_null<Expr>(ReadSubStmt());
2962 }
2963 
2964 // Within the bitstream, expressions are stored in Reverse Polish
2965 // Notation, with each of the subexpressions preceding the
2966 // expression they are stored in. Subexpressions are stored from last to first.
2967 // To evaluate expressions, we continue reading expressions and placing them on
2968 // the stack, with expressions having operands removing those operands from the
2969 // stack. Evaluation terminates when we see a STMT_STOP record, and
2970 // the single remaining expression on the stack is our result.
2971 Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
2972   ReadingKindTracker ReadingKind(Read_Stmt, *this);
2973   llvm::BitstreamCursor &Cursor = F.DeclsCursor;
2974 
2975   // Map of offset to previously deserialized stmt. The offset points
2976   // just after the stmt record.
2977   llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
2978 
2979 #ifndef NDEBUG
2980   unsigned PrevNumStmts = StmtStack.size();
2981 #endif
2982 
2983   ASTRecordReader Record(*this, F);
2984   ASTStmtReader Reader(Record, Cursor);
2985   Stmt::EmptyShell Empty;
2986 
2987   while (true) {
2988     llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2989         Cursor.advanceSkippingSubblocks();
2990     if (!MaybeEntry) {
2991       Error(toString(MaybeEntry.takeError()));
2992       return nullptr;
2993     }
2994     llvm::BitstreamEntry Entry = MaybeEntry.get();
2995 
2996     switch (Entry.Kind) {
2997     case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2998     case llvm::BitstreamEntry::Error:
2999       Error("malformed block record in AST file");
3000       return nullptr;
3001     case llvm::BitstreamEntry::EndBlock:
3002       goto Done;
3003     case llvm::BitstreamEntry::Record:
3004       // The interesting case.
3005       break;
3006     }
3007 
3008     ASTContext &Context = getContext();
3009     Stmt *S = nullptr;
3010     bool Finished = false;
3011     bool IsStmtReference = false;
3012     Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
3013     if (!MaybeStmtCode) {
3014       Error(toString(MaybeStmtCode.takeError()));
3015       return nullptr;
3016     }
3017     switch ((StmtCode)MaybeStmtCode.get()) {
3018     case STMT_STOP:
3019       Finished = true;
3020       break;
3021 
3022     case STMT_REF_PTR:
3023       IsStmtReference = true;
3024       assert(StmtEntries.contains(Record[0]) &&
3025              "No stmt was recorded for this offset reference!");
3026       S = StmtEntries[Record.readInt()];
3027       break;
3028 
3029     case STMT_NULL_PTR:
3030       S = nullptr;
3031       break;
3032 
3033     case STMT_NULL:
3034       S = new (Context) NullStmt(Empty);
3035       break;
3036 
3037     case STMT_COMPOUND: {
3038       unsigned NumStmts = Record[ASTStmtReader::NumStmtFields];
3039       bool HasFPFeatures = Record[ASTStmtReader::NumStmtFields + 1];
3040       S = CompoundStmt::CreateEmpty(Context, NumStmts, HasFPFeatures);
3041       break;
3042     }
3043 
3044     case STMT_CASE:
3045       S = CaseStmt::CreateEmpty(
3046           Context,
3047           /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
3048       break;
3049 
3050     case STMT_DEFAULT:
3051       S = new (Context) DefaultStmt(Empty);
3052       break;
3053 
3054     case STMT_LABEL:
3055       S = new (Context) LabelStmt(Empty);
3056       break;
3057 
3058     case STMT_ATTRIBUTED:
3059       S = AttributedStmt::CreateEmpty(
3060         Context,
3061         /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
3062       break;
3063 
3064     case STMT_IF: {
3065       BitsUnpacker IfStmtBits(Record[ASTStmtReader::NumStmtFields]);
3066       bool HasElse = IfStmtBits.getNextBit();
3067       bool HasVar = IfStmtBits.getNextBit();
3068       bool HasInit = IfStmtBits.getNextBit();
3069       S = IfStmt::CreateEmpty(Context, HasElse, HasVar, HasInit);
3070       break;
3071     }
3072 
3073     case STMT_SWITCH:
3074       S = SwitchStmt::CreateEmpty(
3075           Context,
3076           /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
3077           /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
3078       break;
3079 
3080     case STMT_WHILE:
3081       S = WhileStmt::CreateEmpty(
3082           Context,
3083           /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
3084       break;
3085 
3086     case STMT_DO:
3087       S = new (Context) DoStmt(Empty);
3088       break;
3089 
3090     case STMT_FOR:
3091       S = new (Context) ForStmt(Empty);
3092       break;
3093 
3094     case STMT_GOTO:
3095       S = new (Context) GotoStmt(Empty);
3096       break;
3097 
3098     case STMT_INDIRECT_GOTO:
3099       S = new (Context) IndirectGotoStmt(Empty);
3100       break;
3101 
3102     case STMT_CONTINUE:
3103       S = new (Context) ContinueStmt(Empty);
3104       break;
3105 
3106     case STMT_BREAK:
3107       S = new (Context) BreakStmt(Empty);
3108       break;
3109 
3110     case STMT_RETURN:
3111       S = ReturnStmt::CreateEmpty(
3112           Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
3113       break;
3114 
3115     case STMT_DECL:
3116       S = new (Context) DeclStmt(Empty);
3117       break;
3118 
3119     case STMT_GCCASM:
3120       S = new (Context) GCCAsmStmt(Empty);
3121       break;
3122 
3123     case STMT_MSASM:
3124       S = new (Context) MSAsmStmt(Empty);
3125       break;
3126 
3127     case STMT_CAPTURED:
3128       S = CapturedStmt::CreateDeserialized(
3129           Context, Record[ASTStmtReader::NumStmtFields]);
3130       break;
3131 
3132     case STMT_SYCLKERNELCALL:
3133       S = new (Context) SYCLKernelCallStmt(Empty);
3134       break;
3135 
3136     case EXPR_CONSTANT:
3137       S = ConstantExpr::CreateEmpty(
3138           Context, static_cast<ConstantResultStorageKind>(
3139                        /*StorageKind=*/Record[ASTStmtReader::NumExprFields]));
3140       break;
3141 
3142     case EXPR_SYCL_UNIQUE_STABLE_NAME:
3143       S = SYCLUniqueStableNameExpr::CreateEmpty(Context);
3144       break;
3145 
3146     case EXPR_OPENACC_ASTERISK_SIZE:
3147       S = OpenACCAsteriskSizeExpr::CreateEmpty(Context);
3148       break;
3149 
3150     case EXPR_PREDEFINED:
3151       S = PredefinedExpr::CreateEmpty(
3152           Context,
3153           /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
3154       break;
3155 
3156     case EXPR_DECL_REF: {
3157       BitsUnpacker DeclRefExprBits(Record[ASTStmtReader::NumExprFields]);
3158       DeclRefExprBits.advance(5);
3159       bool HasFoundDecl = DeclRefExprBits.getNextBit();
3160       bool HasQualifier = DeclRefExprBits.getNextBit();
3161       bool HasTemplateKWAndArgsInfo = DeclRefExprBits.getNextBit();
3162       unsigned NumTemplateArgs = HasTemplateKWAndArgsInfo
3163                                      ? Record[ASTStmtReader::NumExprFields + 1]
3164                                      : 0;
3165       S = DeclRefExpr::CreateEmpty(Context, HasQualifier, HasFoundDecl,
3166                                    HasTemplateKWAndArgsInfo, NumTemplateArgs);
3167       break;
3168     }
3169 
3170     case EXPR_INTEGER_LITERAL:
3171       S = IntegerLiteral::Create(Context, Empty);
3172       break;
3173 
3174     case EXPR_FIXEDPOINT_LITERAL:
3175       S = FixedPointLiteral::Create(Context, Empty);
3176       break;
3177 
3178     case EXPR_FLOATING_LITERAL:
3179       S = FloatingLiteral::Create(Context, Empty);
3180       break;
3181 
3182     case EXPR_IMAGINARY_LITERAL:
3183       S = new (Context) ImaginaryLiteral(Empty);
3184       break;
3185 
3186     case EXPR_STRING_LITERAL:
3187       S = StringLiteral::CreateEmpty(
3188           Context,
3189           /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
3190           /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
3191           /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
3192       break;
3193 
3194     case EXPR_CHARACTER_LITERAL:
3195       S = new (Context) CharacterLiteral(Empty);
3196       break;
3197 
3198     case EXPR_PAREN:
3199       S = new (Context) ParenExpr(Empty);
3200       break;
3201 
3202     case EXPR_PAREN_LIST:
3203       S = ParenListExpr::CreateEmpty(
3204           Context,
3205           /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
3206       break;
3207 
3208     case EXPR_UNARY_OPERATOR: {
3209       BitsUnpacker UnaryOperatorBits(Record[ASTStmtReader::NumStmtFields]);
3210       UnaryOperatorBits.advance(ASTStmtReader::NumExprBits);
3211       bool HasFPFeatures = UnaryOperatorBits.getNextBit();
3212       S = UnaryOperator::CreateEmpty(Context, HasFPFeatures);
3213       break;
3214     }
3215 
3216     case EXPR_OFFSETOF:
3217       S = OffsetOfExpr::CreateEmpty(Context,
3218                                     Record[ASTStmtReader::NumExprFields],
3219                                     Record[ASTStmtReader::NumExprFields + 1]);
3220       break;
3221 
3222     case EXPR_SIZEOF_ALIGN_OF:
3223       S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
3224       break;
3225 
3226     case EXPR_ARRAY_SUBSCRIPT:
3227       S = new (Context) ArraySubscriptExpr(Empty);
3228       break;
3229 
3230     case EXPR_MATRIX_SUBSCRIPT:
3231       S = new (Context) MatrixSubscriptExpr(Empty);
3232       break;
3233 
3234     case EXPR_ARRAY_SECTION:
3235       S = new (Context) ArraySectionExpr(Empty);
3236       break;
3237 
3238     case EXPR_OMP_ARRAY_SHAPING:
3239       S = OMPArrayShapingExpr::CreateEmpty(
3240           Context, Record[ASTStmtReader::NumExprFields]);
3241       break;
3242 
3243     case EXPR_OMP_ITERATOR:
3244       S = OMPIteratorExpr::CreateEmpty(Context,
3245                                        Record[ASTStmtReader::NumExprFields]);
3246       break;
3247 
3248     case EXPR_CALL: {
3249       auto NumArgs = Record[ASTStmtReader::NumExprFields];
3250       BitsUnpacker CallExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3251       CallExprBits.advance(1);
3252       auto HasFPFeatures = CallExprBits.getNextBit();
3253       S = CallExpr::CreateEmpty(Context, NumArgs, HasFPFeatures, Empty);
3254       break;
3255     }
3256 
3257     case EXPR_RECOVERY:
3258       S = RecoveryExpr::CreateEmpty(
3259           Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3260       break;
3261 
3262     case EXPR_MEMBER: {
3263       BitsUnpacker ExprMemberBits(Record[ASTStmtReader::NumExprFields]);
3264       bool HasQualifier = ExprMemberBits.getNextBit();
3265       bool HasFoundDecl = ExprMemberBits.getNextBit();
3266       bool HasTemplateInfo = ExprMemberBits.getNextBit();
3267       unsigned NumTemplateArgs = Record[ASTStmtReader::NumExprFields + 1];
3268       S = MemberExpr::CreateEmpty(Context, HasQualifier, HasFoundDecl,
3269                                   HasTemplateInfo, NumTemplateArgs);
3270       break;
3271     }
3272 
3273     case EXPR_BINARY_OPERATOR: {
3274       BitsUnpacker BinaryOperatorBits(Record[ASTStmtReader::NumExprFields]);
3275       BinaryOperatorBits.advance(/*Size of opcode*/ 6);
3276       bool HasFPFeatures = BinaryOperatorBits.getNextBit();
3277       S = BinaryOperator::CreateEmpty(Context, HasFPFeatures);
3278       break;
3279     }
3280 
3281     case EXPR_COMPOUND_ASSIGN_OPERATOR: {
3282       BitsUnpacker BinaryOperatorBits(Record[ASTStmtReader::NumExprFields]);
3283       BinaryOperatorBits.advance(/*Size of opcode*/ 6);
3284       bool HasFPFeatures = BinaryOperatorBits.getNextBit();
3285       S = CompoundAssignOperator::CreateEmpty(Context, HasFPFeatures);
3286       break;
3287     }
3288 
3289     case EXPR_CONDITIONAL_OPERATOR:
3290       S = new (Context) ConditionalOperator(Empty);
3291       break;
3292 
3293     case EXPR_BINARY_CONDITIONAL_OPERATOR:
3294       S = new (Context) BinaryConditionalOperator(Empty);
3295       break;
3296 
3297     case EXPR_IMPLICIT_CAST: {
3298       unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3299       BitsUnpacker CastExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3300       CastExprBits.advance(7);
3301       bool HasFPFeatures = CastExprBits.getNextBit();
3302       S = ImplicitCastExpr::CreateEmpty(Context, PathSize, HasFPFeatures);
3303       break;
3304     }
3305 
3306     case EXPR_CSTYLE_CAST: {
3307       unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3308       BitsUnpacker CastExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3309       CastExprBits.advance(7);
3310       bool HasFPFeatures = CastExprBits.getNextBit();
3311       S = CStyleCastExpr::CreateEmpty(Context, PathSize, HasFPFeatures);
3312       break;
3313     }
3314 
3315     case EXPR_COMPOUND_LITERAL:
3316       S = new (Context) CompoundLiteralExpr(Empty);
3317       break;
3318 
3319     case EXPR_EXT_VECTOR_ELEMENT:
3320       S = new (Context) ExtVectorElementExpr(Empty);
3321       break;
3322 
3323     case EXPR_INIT_LIST:
3324       S = new (Context) InitListExpr(Empty);
3325       break;
3326 
3327     case EXPR_DESIGNATED_INIT:
3328       S = DesignatedInitExpr::CreateEmpty(Context,
3329                                      Record[ASTStmtReader::NumExprFields] - 1);
3330 
3331       break;
3332 
3333     case EXPR_DESIGNATED_INIT_UPDATE:
3334       S = new (Context) DesignatedInitUpdateExpr(Empty);
3335       break;
3336 
3337     case EXPR_IMPLICIT_VALUE_INIT:
3338       S = new (Context) ImplicitValueInitExpr(Empty);
3339       break;
3340 
3341     case EXPR_NO_INIT:
3342       S = new (Context) NoInitExpr(Empty);
3343       break;
3344 
3345     case EXPR_ARRAY_INIT_LOOP:
3346       S = new (Context) ArrayInitLoopExpr(Empty);
3347       break;
3348 
3349     case EXPR_ARRAY_INIT_INDEX:
3350       S = new (Context) ArrayInitIndexExpr(Empty);
3351       break;
3352 
3353     case EXPR_VA_ARG:
3354       S = new (Context) VAArgExpr(Empty);
3355       break;
3356 
3357     case EXPR_SOURCE_LOC:
3358       S = new (Context) SourceLocExpr(Empty);
3359       break;
3360 
3361     case EXPR_BUILTIN_PP_EMBED:
3362       S = new (Context) EmbedExpr(Empty);
3363       break;
3364 
3365     case EXPR_ADDR_LABEL:
3366       S = new (Context) AddrLabelExpr(Empty);
3367       break;
3368 
3369     case EXPR_STMT:
3370       S = new (Context) StmtExpr(Empty);
3371       break;
3372 
3373     case EXPR_CHOOSE:
3374       S = new (Context) ChooseExpr(Empty);
3375       break;
3376 
3377     case EXPR_GNU_NULL:
3378       S = new (Context) GNUNullExpr(Empty);
3379       break;
3380 
3381     case EXPR_SHUFFLE_VECTOR:
3382       S = new (Context) ShuffleVectorExpr(Empty);
3383       break;
3384 
3385     case EXPR_CONVERT_VECTOR:
3386       S = new (Context) ConvertVectorExpr(Empty);
3387       break;
3388 
3389     case EXPR_BLOCK:
3390       S = new (Context) BlockExpr(Empty);
3391       break;
3392 
3393     case EXPR_GENERIC_SELECTION:
3394       S = GenericSelectionExpr::CreateEmpty(
3395           Context,
3396           /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
3397       break;
3398 
3399     case EXPR_OBJC_STRING_LITERAL:
3400       S = new (Context) ObjCStringLiteral(Empty);
3401       break;
3402 
3403     case EXPR_OBJC_BOXED_EXPRESSION:
3404       S = new (Context) ObjCBoxedExpr(Empty);
3405       break;
3406 
3407     case EXPR_OBJC_ARRAY_LITERAL:
3408       S = ObjCArrayLiteral::CreateEmpty(Context,
3409                                         Record[ASTStmtReader::NumExprFields]);
3410       break;
3411 
3412     case EXPR_OBJC_DICTIONARY_LITERAL:
3413       S = ObjCDictionaryLiteral::CreateEmpty(Context,
3414             Record[ASTStmtReader::NumExprFields],
3415             Record[ASTStmtReader::NumExprFields + 1]);
3416       break;
3417 
3418     case EXPR_OBJC_ENCODE:
3419       S = new (Context) ObjCEncodeExpr(Empty);
3420       break;
3421 
3422     case EXPR_OBJC_SELECTOR_EXPR:
3423       S = new (Context) ObjCSelectorExpr(Empty);
3424       break;
3425 
3426     case EXPR_OBJC_PROTOCOL_EXPR:
3427       S = new (Context) ObjCProtocolExpr(Empty);
3428       break;
3429 
3430     case EXPR_OBJC_IVAR_REF_EXPR:
3431       S = new (Context) ObjCIvarRefExpr(Empty);
3432       break;
3433 
3434     case EXPR_OBJC_PROPERTY_REF_EXPR:
3435       S = new (Context) ObjCPropertyRefExpr(Empty);
3436       break;
3437 
3438     case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
3439       S = new (Context) ObjCSubscriptRefExpr(Empty);
3440       break;
3441 
3442     case EXPR_OBJC_KVC_REF_EXPR:
3443       llvm_unreachable("mismatching AST file");
3444 
3445     case EXPR_OBJC_MESSAGE_EXPR:
3446       S = ObjCMessageExpr::CreateEmpty(Context,
3447                                      Record[ASTStmtReader::NumExprFields],
3448                                      Record[ASTStmtReader::NumExprFields + 1]);
3449       break;
3450 
3451     case EXPR_OBJC_ISA:
3452       S = new (Context) ObjCIsaExpr(Empty);
3453       break;
3454 
3455     case EXPR_OBJC_INDIRECT_COPY_RESTORE:
3456       S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
3457       break;
3458 
3459     case EXPR_OBJC_BRIDGED_CAST:
3460       S = new (Context) ObjCBridgedCastExpr(Empty);
3461       break;
3462 
3463     case STMT_OBJC_FOR_COLLECTION:
3464       S = new (Context) ObjCForCollectionStmt(Empty);
3465       break;
3466 
3467     case STMT_OBJC_CATCH:
3468       S = new (Context) ObjCAtCatchStmt(Empty);
3469       break;
3470 
3471     case STMT_OBJC_FINALLY:
3472       S = new (Context) ObjCAtFinallyStmt(Empty);
3473       break;
3474 
3475     case STMT_OBJC_AT_TRY:
3476       S = ObjCAtTryStmt::CreateEmpty(Context,
3477                                      Record[ASTStmtReader::NumStmtFields],
3478                                      Record[ASTStmtReader::NumStmtFields + 1]);
3479       break;
3480 
3481     case STMT_OBJC_AT_SYNCHRONIZED:
3482       S = new (Context) ObjCAtSynchronizedStmt(Empty);
3483       break;
3484 
3485     case STMT_OBJC_AT_THROW:
3486       S = new (Context) ObjCAtThrowStmt(Empty);
3487       break;
3488 
3489     case STMT_OBJC_AUTORELEASE_POOL:
3490       S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3491       break;
3492 
3493     case EXPR_OBJC_BOOL_LITERAL:
3494       S = new (Context) ObjCBoolLiteralExpr(Empty);
3495       break;
3496 
3497     case EXPR_OBJC_AVAILABILITY_CHECK:
3498       S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3499       break;
3500 
3501     case STMT_SEH_LEAVE:
3502       S = new (Context) SEHLeaveStmt(Empty);
3503       break;
3504 
3505     case STMT_SEH_EXCEPT:
3506       S = new (Context) SEHExceptStmt(Empty);
3507       break;
3508 
3509     case STMT_SEH_FINALLY:
3510       S = new (Context) SEHFinallyStmt(Empty);
3511       break;
3512 
3513     case STMT_SEH_TRY:
3514       S = new (Context) SEHTryStmt(Empty);
3515       break;
3516 
3517     case STMT_CXX_CATCH:
3518       S = new (Context) CXXCatchStmt(Empty);
3519       break;
3520 
3521     case STMT_CXX_TRY:
3522       S = CXXTryStmt::Create(Context, Empty,
3523              /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
3524       break;
3525 
3526     case STMT_CXX_FOR_RANGE:
3527       S = new (Context) CXXForRangeStmt(Empty);
3528       break;
3529 
3530     case STMT_MS_DEPENDENT_EXISTS:
3531       S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3532                                               NestedNameSpecifierLoc(),
3533                                               DeclarationNameInfo(),
3534                                               nullptr);
3535       break;
3536 
3537     case STMT_OMP_CANONICAL_LOOP:
3538       S = OMPCanonicalLoop::createEmpty(Context);
3539       break;
3540 
3541     case STMT_OMP_META_DIRECTIVE:
3542       S = OMPMetaDirective::CreateEmpty(
3543           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3544       break;
3545 
3546     case STMT_OMP_PARALLEL_DIRECTIVE:
3547       S =
3548         OMPParallelDirective::CreateEmpty(Context,
3549                                           Record[ASTStmtReader::NumStmtFields],
3550                                           Empty);
3551       break;
3552 
3553     case STMT_OMP_SIMD_DIRECTIVE: {
3554       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3555       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3556       S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3557                                         CollapsedNum, Empty);
3558       break;
3559     }
3560 
3561     case STMT_OMP_TILE_DIRECTIVE: {
3562       unsigned NumLoops = Record[ASTStmtReader::NumStmtFields];
3563       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3564       S = OMPTileDirective::CreateEmpty(Context, NumClauses, NumLoops);
3565       break;
3566     }
3567 
3568     case STMT_OMP_UNROLL_DIRECTIVE: {
3569       assert(Record[ASTStmtReader::NumStmtFields] == 1 && "Unroll directive accepts only a single loop");
3570       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3571       S = OMPUnrollDirective::CreateEmpty(Context, NumClauses);
3572       break;
3573     }
3574 
3575     case STMT_OMP_REVERSE_DIRECTIVE: {
3576       assert(Record[ASTStmtReader::NumStmtFields] == 1 &&
3577              "Reverse directive accepts only a single loop");
3578       assert(Record[ASTStmtReader::NumStmtFields + 1] == 0 &&
3579              "Reverse directive has no clauses");
3580       S = OMPReverseDirective::CreateEmpty(Context);
3581       break;
3582     }
3583 
3584     case STMT_OMP_INTERCHANGE_DIRECTIVE: {
3585       unsigned NumLoops = Record[ASTStmtReader::NumStmtFields];
3586       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3587       S = OMPInterchangeDirective::CreateEmpty(Context, NumClauses, NumLoops);
3588       break;
3589     }
3590 
3591     case STMT_OMP_FOR_DIRECTIVE: {
3592       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3593       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3594       S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3595                                        Empty);
3596       break;
3597     }
3598 
3599     case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3600       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3601       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3602       S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3603                                            Empty);
3604       break;
3605     }
3606 
3607     case STMT_OMP_SECTIONS_DIRECTIVE:
3608       S = OMPSectionsDirective::CreateEmpty(
3609           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3610       break;
3611 
3612     case STMT_OMP_SECTION_DIRECTIVE:
3613       S = OMPSectionDirective::CreateEmpty(Context, Empty);
3614       break;
3615 
3616     case STMT_OMP_SCOPE_DIRECTIVE:
3617       S = OMPScopeDirective::CreateEmpty(
3618           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3619       break;
3620 
3621     case STMT_OMP_SINGLE_DIRECTIVE:
3622       S = OMPSingleDirective::CreateEmpty(
3623           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3624       break;
3625 
3626     case STMT_OMP_MASTER_DIRECTIVE:
3627       S = OMPMasterDirective::CreateEmpty(Context, Empty);
3628       break;
3629 
3630     case STMT_OMP_CRITICAL_DIRECTIVE:
3631       S = OMPCriticalDirective::CreateEmpty(
3632           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3633       break;
3634 
3635     case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3636       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3637       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3638       S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3639                                                CollapsedNum, Empty);
3640       break;
3641     }
3642 
3643     case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3644       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3645       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3646       S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3647                                                    CollapsedNum, Empty);
3648       break;
3649     }
3650 
3651     case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3652       S = OMPParallelMasterDirective::CreateEmpty(
3653           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3654       break;
3655 
3656     case STMT_OMP_PARALLEL_MASKED_DIRECTIVE:
3657       S = OMPParallelMaskedDirective::CreateEmpty(
3658           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3659       break;
3660 
3661     case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3662       S = OMPParallelSectionsDirective::CreateEmpty(
3663           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3664       break;
3665 
3666     case STMT_OMP_TASK_DIRECTIVE:
3667       S = OMPTaskDirective::CreateEmpty(
3668           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3669       break;
3670 
3671     case STMT_OMP_TASKYIELD_DIRECTIVE:
3672       S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3673       break;
3674 
3675     case STMT_OMP_BARRIER_DIRECTIVE:
3676       S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3677       break;
3678 
3679     case STMT_OMP_TASKWAIT_DIRECTIVE:
3680       S = OMPTaskwaitDirective::CreateEmpty(
3681           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3682       break;
3683 
3684     case STMT_OMP_ERROR_DIRECTIVE:
3685       S = OMPErrorDirective::CreateEmpty(
3686           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3687       break;
3688 
3689     case STMT_OMP_TASKGROUP_DIRECTIVE:
3690       S = OMPTaskgroupDirective::CreateEmpty(
3691           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3692       break;
3693 
3694     case STMT_OMP_FLUSH_DIRECTIVE:
3695       S = OMPFlushDirective::CreateEmpty(
3696           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3697       break;
3698 
3699     case STMT_OMP_DEPOBJ_DIRECTIVE:
3700       S = OMPDepobjDirective::CreateEmpty(
3701           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3702       break;
3703 
3704     case STMT_OMP_SCAN_DIRECTIVE:
3705       S = OMPScanDirective::CreateEmpty(
3706           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3707       break;
3708 
3709     case STMT_OMP_ORDERED_DIRECTIVE: {
3710       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3711       bool HasAssociatedStmt = Record[ASTStmtReader::NumStmtFields + 2];
3712       S = OMPOrderedDirective::CreateEmpty(Context, NumClauses,
3713                                            !HasAssociatedStmt, Empty);
3714       break;
3715     }
3716 
3717     case STMT_OMP_ATOMIC_DIRECTIVE:
3718       S = OMPAtomicDirective::CreateEmpty(
3719           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3720       break;
3721 
3722     case STMT_OMP_TARGET_DIRECTIVE:
3723       S = OMPTargetDirective::CreateEmpty(
3724           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3725       break;
3726 
3727     case STMT_OMP_TARGET_DATA_DIRECTIVE:
3728       S = OMPTargetDataDirective::CreateEmpty(
3729           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3730       break;
3731 
3732     case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3733       S = OMPTargetEnterDataDirective::CreateEmpty(
3734           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3735       break;
3736 
3737     case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3738       S = OMPTargetExitDataDirective::CreateEmpty(
3739           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3740       break;
3741 
3742     case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3743       S = OMPTargetParallelDirective::CreateEmpty(
3744           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3745       break;
3746 
3747     case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3748       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3749       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3750       S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3751                                                      CollapsedNum, Empty);
3752       break;
3753     }
3754 
3755     case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3756       S = OMPTargetUpdateDirective::CreateEmpty(
3757           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3758       break;
3759 
3760     case STMT_OMP_TEAMS_DIRECTIVE:
3761       S = OMPTeamsDirective::CreateEmpty(
3762           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3763       break;
3764 
3765     case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3766       S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3767       break;
3768 
3769     case STMT_OMP_CANCEL_DIRECTIVE:
3770       S = OMPCancelDirective::CreateEmpty(
3771           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3772       break;
3773 
3774     case STMT_OMP_TASKLOOP_DIRECTIVE: {
3775       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3776       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3777       S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3778                                             Empty);
3779       break;
3780     }
3781 
3782     case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3783       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3784       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3785       S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3786                                                 CollapsedNum, Empty);
3787       break;
3788     }
3789 
3790     case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3791       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3792       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3793       S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3794                                                   CollapsedNum, Empty);
3795       break;
3796     }
3797 
3798     case STMT_OMP_MASKED_TASKLOOP_DIRECTIVE: {
3799       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3800       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3801       S = OMPMaskedTaskLoopDirective::CreateEmpty(Context, NumClauses,
3802                                                   CollapsedNum, Empty);
3803       break;
3804     }
3805 
3806     case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3807       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3808       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3809       S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3810                                                       CollapsedNum, Empty);
3811       break;
3812     }
3813 
3814     case STMT_OMP_MASKED_TASKLOOP_SIMD_DIRECTIVE: {
3815       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3816       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3817       S = OMPMaskedTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3818                                                       CollapsedNum, Empty);
3819       break;
3820     }
3821 
3822     case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3823       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3824       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3825       S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3826                                                           CollapsedNum, Empty);
3827       break;
3828     }
3829 
3830     case STMT_OMP_PARALLEL_MASKED_TASKLOOP_DIRECTIVE: {
3831       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3832       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3833       S = OMPParallelMaskedTaskLoopDirective::CreateEmpty(Context, NumClauses,
3834                                                           CollapsedNum, Empty);
3835       break;
3836     }
3837 
3838     case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3839       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3840       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3841       S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3842           Context, NumClauses, CollapsedNum, Empty);
3843       break;
3844     }
3845 
3846     case STMT_OMP_PARALLEL_MASKED_TASKLOOP_SIMD_DIRECTIVE: {
3847       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3848       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3849       S = OMPParallelMaskedTaskLoopSimdDirective::CreateEmpty(
3850           Context, NumClauses, CollapsedNum, Empty);
3851       break;
3852     }
3853 
3854     case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3855       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3856       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3857       S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3858                                               Empty);
3859       break;
3860     }
3861 
3862     case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3863       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3864       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3865       S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3866                                                          CollapsedNum, Empty);
3867       break;
3868     }
3869 
3870     case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3871       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3872       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3873       S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3874                                                              CollapsedNum,
3875                                                              Empty);
3876       break;
3877     }
3878 
3879     case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3880       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3881       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3882       S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3883                                                   CollapsedNum, Empty);
3884       break;
3885     }
3886 
3887     case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3888       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3889       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3890       S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3891                                                          CollapsedNum, Empty);
3892       break;
3893     }
3894 
3895     case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3896       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3897       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3898       S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3899                                               Empty);
3900       break;
3901     }
3902 
3903      case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
3904        unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3905        unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3906        S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3907                                                     CollapsedNum, Empty);
3908        break;
3909     }
3910 
3911     case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3912       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3913       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3914       S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3915                                                        CollapsedNum, Empty);
3916       break;
3917     }
3918 
3919     case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3920       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3921       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3922       S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3923           Context, NumClauses, CollapsedNum, Empty);
3924       break;
3925     }
3926 
3927     case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3928       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3929       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3930       S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3931           Context, NumClauses, CollapsedNum, Empty);
3932       break;
3933     }
3934 
3935     case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
3936       S = OMPTargetTeamsDirective::CreateEmpty(
3937           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3938       break;
3939 
3940     case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3941       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3942       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3943       S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3944                                                          CollapsedNum, Empty);
3945       break;
3946     }
3947 
3948     case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3949       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3950       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3951       S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3952           Context, NumClauses, CollapsedNum, Empty);
3953       break;
3954     }
3955 
3956     case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3957       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3958       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3959       S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3960           Context, NumClauses, CollapsedNum, Empty);
3961       break;
3962     }
3963 
3964     case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3965       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3966       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3967       S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3968           Context, NumClauses, CollapsedNum, Empty);
3969       break;
3970     }
3971 
3972     case STMT_OMP_INTEROP_DIRECTIVE:
3973       S = OMPInteropDirective::CreateEmpty(
3974           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3975       break;
3976 
3977     case STMT_OMP_DISPATCH_DIRECTIVE:
3978       S = OMPDispatchDirective::CreateEmpty(
3979           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3980       break;
3981 
3982     case STMT_OMP_MASKED_DIRECTIVE:
3983       S = OMPMaskedDirective::CreateEmpty(
3984           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3985       break;
3986 
3987     case STMT_OMP_GENERIC_LOOP_DIRECTIVE: {
3988       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3989       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3990       S = OMPGenericLoopDirective::CreateEmpty(Context, NumClauses,
3991                                                CollapsedNum, Empty);
3992       break;
3993     }
3994 
3995     case STMT_OMP_TEAMS_GENERIC_LOOP_DIRECTIVE: {
3996       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3997       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3998       S = OMPTeamsGenericLoopDirective::CreateEmpty(Context, NumClauses,
3999                                                     CollapsedNum, Empty);
4000       break;
4001     }
4002 
4003     case STMT_OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVE: {
4004       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
4005       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
4006       S = OMPTargetTeamsGenericLoopDirective::CreateEmpty(Context, NumClauses,
4007                                                           CollapsedNum, Empty);
4008       break;
4009     }
4010 
4011     case STMT_OMP_PARALLEL_GENERIC_LOOP_DIRECTIVE: {
4012       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
4013       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
4014       S = OMPParallelGenericLoopDirective::CreateEmpty(Context, NumClauses,
4015                                                        CollapsedNum, Empty);
4016       break;
4017     }
4018 
4019     case STMT_OMP_TARGET_PARALLEL_GENERIC_LOOP_DIRECTIVE: {
4020       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
4021       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
4022       S = OMPTargetParallelGenericLoopDirective::CreateEmpty(
4023           Context, NumClauses, CollapsedNum, Empty);
4024       break;
4025     }
4026 
4027     case STMT_OMP_ASSUME_DIRECTIVE: {
4028       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
4029       S = OMPAssumeDirective::CreateEmpty(Context, NumClauses, Empty);
4030       break;
4031     }
4032 
4033     case EXPR_CXX_OPERATOR_CALL: {
4034       auto NumArgs = Record[ASTStmtReader::NumExprFields];
4035       BitsUnpacker CallExprBits(Record[ASTStmtReader::NumExprFields + 1]);
4036       CallExprBits.advance(1);
4037       auto HasFPFeatures = CallExprBits.getNextBit();
4038       S = CXXOperatorCallExpr::CreateEmpty(Context, NumArgs, HasFPFeatures,
4039                                            Empty);
4040       break;
4041     }
4042 
4043     case EXPR_CXX_MEMBER_CALL: {
4044       auto NumArgs = Record[ASTStmtReader::NumExprFields];
4045       BitsUnpacker CallExprBits(Record[ASTStmtReader::NumExprFields + 1]);
4046       CallExprBits.advance(1);
4047       auto HasFPFeatures = CallExprBits.getNextBit();
4048       S = CXXMemberCallExpr::CreateEmpty(Context, NumArgs, HasFPFeatures,
4049                                          Empty);
4050       break;
4051     }
4052 
4053     case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
4054       S = new (Context) CXXRewrittenBinaryOperator(Empty);
4055       break;
4056 
4057     case EXPR_CXX_CONSTRUCT:
4058       S = CXXConstructExpr::CreateEmpty(
4059           Context,
4060           /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
4061       break;
4062 
4063     case EXPR_CXX_INHERITED_CTOR_INIT:
4064       S = new (Context) CXXInheritedCtorInitExpr(Empty);
4065       break;
4066 
4067     case EXPR_CXX_TEMPORARY_OBJECT:
4068       S = CXXTemporaryObjectExpr::CreateEmpty(
4069           Context,
4070           /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
4071       break;
4072 
4073     case EXPR_CXX_STATIC_CAST: {
4074       unsigned PathSize = Record[ASTStmtReader::NumExprFields];
4075       BitsUnpacker CastExprBits(Record[ASTStmtReader::NumExprFields + 1]);
4076       CastExprBits.advance(7);
4077       bool HasFPFeatures = CastExprBits.getNextBit();
4078       S = CXXStaticCastExpr::CreateEmpty(Context, PathSize, HasFPFeatures);
4079       break;
4080     }
4081 
4082     case EXPR_CXX_DYNAMIC_CAST: {
4083       unsigned PathSize = Record[ASTStmtReader::NumExprFields];
4084       S = CXXDynamicCastExpr::CreateEmpty(Context, PathSize);
4085       break;
4086     }
4087 
4088     case EXPR_CXX_REINTERPRET_CAST: {
4089       unsigned PathSize = Record[ASTStmtReader::NumExprFields];
4090       S = CXXReinterpretCastExpr::CreateEmpty(Context, PathSize);
4091       break;
4092     }
4093 
4094     case EXPR_CXX_CONST_CAST:
4095       S = CXXConstCastExpr::CreateEmpty(Context);
4096       break;
4097 
4098     case EXPR_CXX_ADDRSPACE_CAST:
4099       S = CXXAddrspaceCastExpr::CreateEmpty(Context);
4100       break;
4101 
4102     case EXPR_CXX_FUNCTIONAL_CAST: {
4103       unsigned PathSize = Record[ASTStmtReader::NumExprFields];
4104       BitsUnpacker CastExprBits(Record[ASTStmtReader::NumExprFields + 1]);
4105       CastExprBits.advance(7);
4106       bool HasFPFeatures = CastExprBits.getNextBit();
4107       S = CXXFunctionalCastExpr::CreateEmpty(Context, PathSize, HasFPFeatures);
4108       break;
4109     }
4110 
4111     case EXPR_BUILTIN_BIT_CAST: {
4112 #ifndef NDEBUG
4113       unsigned PathSize = Record[ASTStmtReader::NumExprFields];
4114       assert(PathSize == 0 && "Wrong PathSize!");
4115 #endif
4116       S = new (Context) BuiltinBitCastExpr(Empty);
4117       break;
4118     }
4119 
4120     case EXPR_USER_DEFINED_LITERAL: {
4121       auto NumArgs = Record[ASTStmtReader::NumExprFields];
4122       BitsUnpacker CallExprBits(Record[ASTStmtReader::NumExprFields + 1]);
4123       CallExprBits.advance(1);
4124       auto HasFPFeatures = CallExprBits.getNextBit();
4125       S = UserDefinedLiteral::CreateEmpty(Context, NumArgs, HasFPFeatures,
4126                                           Empty);
4127       break;
4128     }
4129 
4130     case EXPR_CXX_STD_INITIALIZER_LIST:
4131       S = new (Context) CXXStdInitializerListExpr(Empty);
4132       break;
4133 
4134     case EXPR_CXX_BOOL_LITERAL:
4135       S = new (Context) CXXBoolLiteralExpr(Empty);
4136       break;
4137 
4138     case EXPR_CXX_NULL_PTR_LITERAL:
4139       S = new (Context) CXXNullPtrLiteralExpr(Empty);
4140       break;
4141 
4142     case EXPR_CXX_TYPEID_EXPR:
4143       S = new (Context) CXXTypeidExpr(Empty, true);
4144       break;
4145 
4146     case EXPR_CXX_TYPEID_TYPE:
4147       S = new (Context) CXXTypeidExpr(Empty, false);
4148       break;
4149 
4150     case EXPR_CXX_UUIDOF_EXPR:
4151       S = new (Context) CXXUuidofExpr(Empty, true);
4152       break;
4153 
4154     case EXPR_CXX_PROPERTY_REF_EXPR:
4155       S = new (Context) MSPropertyRefExpr(Empty);
4156       break;
4157 
4158     case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
4159       S = new (Context) MSPropertySubscriptExpr(Empty);
4160       break;
4161 
4162     case EXPR_CXX_UUIDOF_TYPE:
4163       S = new (Context) CXXUuidofExpr(Empty, false);
4164       break;
4165 
4166     case EXPR_CXX_THIS:
4167       S = CXXThisExpr::CreateEmpty(Context);
4168       break;
4169 
4170     case EXPR_CXX_THROW:
4171       S = new (Context) CXXThrowExpr(Empty);
4172       break;
4173 
4174     case EXPR_CXX_DEFAULT_ARG:
4175       S = CXXDefaultArgExpr::CreateEmpty(
4176           Context, /*HasRewrittenInit=*/Record[ASTStmtReader::NumExprFields]);
4177       break;
4178 
4179     case EXPR_CXX_DEFAULT_INIT:
4180       S = CXXDefaultInitExpr::CreateEmpty(
4181           Context, /*HasRewrittenInit=*/Record[ASTStmtReader::NumExprFields]);
4182       break;
4183 
4184     case EXPR_CXX_BIND_TEMPORARY:
4185       S = new (Context) CXXBindTemporaryExpr(Empty);
4186       break;
4187 
4188     case EXPR_CXX_SCALAR_VALUE_INIT:
4189       S = new (Context) CXXScalarValueInitExpr(Empty);
4190       break;
4191 
4192     case EXPR_CXX_NEW:
4193       S = CXXNewExpr::CreateEmpty(
4194           Context,
4195           /*IsArray=*/Record[ASTStmtReader::NumExprFields],
4196           /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
4197           /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
4198           /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
4199       break;
4200 
4201     case EXPR_CXX_DELETE:
4202       S = new (Context) CXXDeleteExpr(Empty);
4203       break;
4204 
4205     case EXPR_CXX_PSEUDO_DESTRUCTOR:
4206       S = new (Context) CXXPseudoDestructorExpr(Empty);
4207       break;
4208 
4209     case EXPR_EXPR_WITH_CLEANUPS:
4210       S = ExprWithCleanups::Create(Context, Empty,
4211                                    Record[ASTStmtReader::NumExprFields]);
4212       break;
4213 
4214     case EXPR_CXX_DEPENDENT_SCOPE_MEMBER: {
4215       unsigned NumTemplateArgs = Record[ASTStmtReader::NumExprFields];
4216       BitsUnpacker DependentScopeMemberBits(
4217           Record[ASTStmtReader::NumExprFields + 1]);
4218       bool HasTemplateKWAndArgsInfo = DependentScopeMemberBits.getNextBit();
4219 
4220       bool HasFirstQualifierFoundInScope =
4221           DependentScopeMemberBits.getNextBit();
4222       S = CXXDependentScopeMemberExpr::CreateEmpty(
4223           Context, HasTemplateKWAndArgsInfo, NumTemplateArgs,
4224           HasFirstQualifierFoundInScope);
4225       break;
4226     }
4227 
4228     case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF: {
4229       BitsUnpacker DependentScopeDeclRefBits(
4230           Record[ASTStmtReader::NumStmtFields]);
4231       DependentScopeDeclRefBits.advance(ASTStmtReader::NumExprBits);
4232       bool HasTemplateKWAndArgsInfo = DependentScopeDeclRefBits.getNextBit();
4233       unsigned NumTemplateArgs =
4234           HasTemplateKWAndArgsInfo
4235               ? DependentScopeDeclRefBits.getNextBits(/*Width=*/16)
4236               : 0;
4237       S = DependentScopeDeclRefExpr::CreateEmpty(
4238           Context, HasTemplateKWAndArgsInfo, NumTemplateArgs);
4239       break;
4240     }
4241 
4242     case EXPR_CXX_UNRESOLVED_CONSTRUCT:
4243       S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
4244                               /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
4245       break;
4246 
4247     case EXPR_CXX_UNRESOLVED_MEMBER: {
4248       auto NumResults = Record[ASTStmtReader::NumExprFields];
4249       BitsUnpacker OverloadExprBits(Record[ASTStmtReader::NumExprFields + 1]);
4250       auto HasTemplateKWAndArgsInfo = OverloadExprBits.getNextBit();
4251       auto NumTemplateArgs = HasTemplateKWAndArgsInfo
4252                                  ? Record[ASTStmtReader::NumExprFields + 2]
4253                                  : 0;
4254       S = UnresolvedMemberExpr::CreateEmpty(
4255           Context, NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
4256       break;
4257     }
4258 
4259     case EXPR_CXX_UNRESOLVED_LOOKUP: {
4260       auto NumResults = Record[ASTStmtReader::NumExprFields];
4261       BitsUnpacker OverloadExprBits(Record[ASTStmtReader::NumExprFields + 1]);
4262       auto HasTemplateKWAndArgsInfo = OverloadExprBits.getNextBit();
4263       auto NumTemplateArgs = HasTemplateKWAndArgsInfo
4264                                  ? Record[ASTStmtReader::NumExprFields + 2]
4265                                  : 0;
4266       S = UnresolvedLookupExpr::CreateEmpty(
4267           Context, NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
4268       break;
4269     }
4270 
4271     case EXPR_TYPE_TRAIT:
4272       S = TypeTraitExpr::CreateDeserialized(Context,
4273             Record[ASTStmtReader::NumExprFields]);
4274       break;
4275 
4276     case EXPR_ARRAY_TYPE_TRAIT:
4277       S = new (Context) ArrayTypeTraitExpr(Empty);
4278       break;
4279 
4280     case EXPR_CXX_EXPRESSION_TRAIT:
4281       S = new (Context) ExpressionTraitExpr(Empty);
4282       break;
4283 
4284     case EXPR_CXX_NOEXCEPT:
4285       S = new (Context) CXXNoexceptExpr(Empty);
4286       break;
4287 
4288     case EXPR_PACK_EXPANSION:
4289       S = new (Context) PackExpansionExpr(Empty);
4290       break;
4291 
4292     case EXPR_SIZEOF_PACK:
4293       S = SizeOfPackExpr::CreateDeserialized(
4294               Context,
4295               /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
4296       break;
4297 
4298     case EXPR_PACK_INDEXING:
4299       S = PackIndexingExpr::CreateDeserialized(
4300           Context,
4301           /*TransformedExprs=*/Record[ASTStmtReader::NumExprFields]);
4302       break;
4303 
4304     case EXPR_RESOLVED_UNEXPANDED_PACK:
4305       S = ResolvedUnexpandedPackExpr::CreateDeserialized(
4306           Context,
4307           /*NumExprs=*/Record[ASTStmtReader::NumExprFields]);
4308       break;
4309 
4310     case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
4311       S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
4312       break;
4313 
4314     case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
4315       S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
4316       break;
4317 
4318     case EXPR_FUNCTION_PARM_PACK:
4319       S = FunctionParmPackExpr::CreateEmpty(Context,
4320                                           Record[ASTStmtReader::NumExprFields]);
4321       break;
4322 
4323     case EXPR_MATERIALIZE_TEMPORARY:
4324       S = new (Context) MaterializeTemporaryExpr(Empty);
4325       break;
4326 
4327     case EXPR_CXX_FOLD:
4328       S = new (Context) CXXFoldExpr(Empty);
4329       break;
4330 
4331     case EXPR_CXX_PAREN_LIST_INIT:
4332       S = CXXParenListInitExpr::CreateEmpty(
4333           Context, /*numExprs=*/Record[ASTStmtReader::NumExprFields], Empty);
4334       break;
4335 
4336     case EXPR_OPAQUE_VALUE:
4337       S = new (Context) OpaqueValueExpr(Empty);
4338       break;
4339 
4340     case EXPR_CUDA_KERNEL_CALL: {
4341       auto NumArgs = Record[ASTStmtReader::NumExprFields];
4342       BitsUnpacker CallExprBits(Record[ASTStmtReader::NumExprFields + 1]);
4343       CallExprBits.advance(1);
4344       auto HasFPFeatures = CallExprBits.getNextBit();
4345       S = CUDAKernelCallExpr::CreateEmpty(Context, NumArgs, HasFPFeatures,
4346                                           Empty);
4347       break;
4348     }
4349 
4350     case EXPR_ASTYPE:
4351       S = new (Context) AsTypeExpr(Empty);
4352       break;
4353 
4354     case EXPR_PSEUDO_OBJECT: {
4355       unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
4356       S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
4357       break;
4358     }
4359 
4360     case EXPR_ATOMIC:
4361       S = new (Context) AtomicExpr(Empty);
4362       break;
4363 
4364     case EXPR_LAMBDA: {
4365       unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
4366       S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
4367       break;
4368     }
4369 
4370     case STMT_COROUTINE_BODY: {
4371       unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
4372       S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
4373       break;
4374     }
4375 
4376     case STMT_CORETURN:
4377       S = new (Context) CoreturnStmt(Empty);
4378       break;
4379 
4380     case EXPR_COAWAIT:
4381       S = new (Context) CoawaitExpr(Empty);
4382       break;
4383 
4384     case EXPR_COYIELD:
4385       S = new (Context) CoyieldExpr(Empty);
4386       break;
4387 
4388     case EXPR_DEPENDENT_COAWAIT:
4389       S = new (Context) DependentCoawaitExpr(Empty);
4390       break;
4391 
4392     case EXPR_CONCEPT_SPECIALIZATION: {
4393       S = new (Context) ConceptSpecializationExpr(Empty);
4394       break;
4395     }
4396     case STMT_OPENACC_COMPUTE_CONSTRUCT: {
4397       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
4398       S = OpenACCComputeConstruct::CreateEmpty(Context, NumClauses);
4399       break;
4400     }
4401     case STMT_OPENACC_LOOP_CONSTRUCT: {
4402       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
4403       S = OpenACCLoopConstruct::CreateEmpty(Context, NumClauses);
4404       break;
4405     }
4406     case STMT_OPENACC_COMBINED_CONSTRUCT: {
4407       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
4408       S = OpenACCCombinedConstruct::CreateEmpty(Context, NumClauses);
4409       break;
4410     }
4411     case STMT_OPENACC_DATA_CONSTRUCT: {
4412       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
4413       S = OpenACCDataConstruct::CreateEmpty(Context, NumClauses);
4414       break;
4415     }
4416     case STMT_OPENACC_ENTER_DATA_CONSTRUCT: {
4417       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
4418       S = OpenACCEnterDataConstruct::CreateEmpty(Context, NumClauses);
4419       break;
4420     }
4421     case STMT_OPENACC_EXIT_DATA_CONSTRUCT: {
4422       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
4423       S = OpenACCExitDataConstruct::CreateEmpty(Context, NumClauses);
4424       break;
4425     }
4426     case STMT_OPENACC_HOST_DATA_CONSTRUCT: {
4427       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
4428       S = OpenACCHostDataConstruct::CreateEmpty(Context, NumClauses);
4429       break;
4430     }
4431     case STMT_OPENACC_WAIT_CONSTRUCT: {
4432       unsigned NumExprs = Record[ASTStmtReader::NumStmtFields];
4433       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
4434       S = OpenACCWaitConstruct::CreateEmpty(Context, NumExprs, NumClauses);
4435       break;
4436     }
4437     case STMT_OPENACC_INIT_CONSTRUCT: {
4438       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
4439       S = OpenACCInitConstruct::CreateEmpty(Context, NumClauses);
4440       break;
4441     }
4442     case STMT_OPENACC_SHUTDOWN_CONSTRUCT: {
4443       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
4444       S = OpenACCShutdownConstruct::CreateEmpty(Context, NumClauses);
4445       break;
4446     }
4447     case STMT_OPENACC_SET_CONSTRUCT: {
4448       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
4449       S = OpenACCSetConstruct::CreateEmpty(Context, NumClauses);
4450       break;
4451     }
4452     case STMT_OPENACC_UPDATE_CONSTRUCT: {
4453       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
4454       S = OpenACCUpdateConstruct::CreateEmpty(Context, NumClauses);
4455       break;
4456     }
4457     case EXPR_REQUIRES: {
4458       unsigned numLocalParameters = Record[ASTStmtReader::NumExprFields];
4459       unsigned numRequirement = Record[ASTStmtReader::NumExprFields + 1];
4460       S = RequiresExpr::Create(Context, Empty, numLocalParameters,
4461                                numRequirement);
4462       break;
4463     }
4464     case EXPR_HLSL_OUT_ARG:
4465       S = HLSLOutArgExpr::CreateEmpty(Context);
4466       break;
4467     }
4468 
4469     // We hit a STMT_STOP, so we're done with this expression.
4470     if (Finished)
4471       break;
4472 
4473     ++NumStatementsRead;
4474 
4475     if (S && !IsStmtReference) {
4476       Reader.Visit(S);
4477       StmtEntries[Cursor.GetCurrentBitNo()] = S;
4478     }
4479 
4480     assert(Record.getIdx() == Record.size() &&
4481            "Invalid deserialization of statement");
4482     StmtStack.push_back(S);
4483   }
4484 Done:
4485   assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
4486   assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
4487   return StmtStack.pop_back_val();
4488 }
4489