xref: /freebsd-src/contrib/llvm-project/clang/lib/Serialization/ASTReaderStmt.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric //===- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // Statement/expression deserialization.  This implements the
100b57cec5SDimitry Andric // ASTReader::ReadStmt method.
110b57cec5SDimitry Andric //
120b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
130b57cec5SDimitry Andric 
14480093f4SDimitry Andric #include "clang/AST/ASTConcept.h"
150b57cec5SDimitry Andric #include "clang/AST/ASTContext.h"
160b57cec5SDimitry Andric #include "clang/AST/AttrIterator.h"
170b57cec5SDimitry Andric #include "clang/AST/Decl.h"
180b57cec5SDimitry Andric #include "clang/AST/DeclAccessPair.h"
190b57cec5SDimitry Andric #include "clang/AST/DeclCXX.h"
200b57cec5SDimitry Andric #include "clang/AST/DeclGroup.h"
210b57cec5SDimitry Andric #include "clang/AST/DeclObjC.h"
220b57cec5SDimitry Andric #include "clang/AST/DeclTemplate.h"
230b57cec5SDimitry Andric #include "clang/AST/DeclarationName.h"
245ffd83dbSDimitry Andric #include "clang/AST/DependenceFlags.h"
250b57cec5SDimitry Andric #include "clang/AST/Expr.h"
260b57cec5SDimitry Andric #include "clang/AST/ExprCXX.h"
270b57cec5SDimitry Andric #include "clang/AST/ExprObjC.h"
280b57cec5SDimitry Andric #include "clang/AST/ExprOpenMP.h"
290b57cec5SDimitry Andric #include "clang/AST/NestedNameSpecifier.h"
300b57cec5SDimitry Andric #include "clang/AST/OpenMPClause.h"
310b57cec5SDimitry Andric #include "clang/AST/OperationKinds.h"
320b57cec5SDimitry Andric #include "clang/AST/Stmt.h"
330b57cec5SDimitry Andric #include "clang/AST/StmtCXX.h"
340b57cec5SDimitry Andric #include "clang/AST/StmtObjC.h"
350b57cec5SDimitry Andric #include "clang/AST/StmtOpenMP.h"
360b57cec5SDimitry Andric #include "clang/AST/StmtVisitor.h"
370b57cec5SDimitry Andric #include "clang/AST/TemplateBase.h"
380b57cec5SDimitry Andric #include "clang/AST/Type.h"
390b57cec5SDimitry Andric #include "clang/AST/UnresolvedSet.h"
400b57cec5SDimitry Andric #include "clang/Basic/CapturedStmt.h"
410b57cec5SDimitry Andric #include "clang/Basic/ExpressionTraits.h"
420b57cec5SDimitry Andric #include "clang/Basic/LLVM.h"
430b57cec5SDimitry Andric #include "clang/Basic/Lambda.h"
440b57cec5SDimitry Andric #include "clang/Basic/LangOptions.h"
450b57cec5SDimitry Andric #include "clang/Basic/OpenMPKinds.h"
460b57cec5SDimitry Andric #include "clang/Basic/OperatorKinds.h"
470b57cec5SDimitry Andric #include "clang/Basic/SourceLocation.h"
480b57cec5SDimitry Andric #include "clang/Basic/Specifiers.h"
490b57cec5SDimitry Andric #include "clang/Basic/TypeTraits.h"
500b57cec5SDimitry Andric #include "clang/Lex/Token.h"
510b57cec5SDimitry Andric #include "clang/Serialization/ASTBitCodes.h"
525ffd83dbSDimitry Andric #include "clang/Serialization/ASTRecordReader.h"
535ffd83dbSDimitry Andric #include "llvm/ADT/BitmaskEnum.h"
540b57cec5SDimitry Andric #include "llvm/ADT/DenseMap.h"
550b57cec5SDimitry Andric #include "llvm/ADT/SmallString.h"
560b57cec5SDimitry Andric #include "llvm/ADT/SmallVector.h"
570b57cec5SDimitry Andric #include "llvm/ADT/StringRef.h"
580b57cec5SDimitry Andric #include "llvm/Bitstream/BitstreamReader.h"
590b57cec5SDimitry Andric #include "llvm/Support/Casting.h"
600b57cec5SDimitry Andric #include "llvm/Support/ErrorHandling.h"
610b57cec5SDimitry Andric #include <algorithm>
620b57cec5SDimitry Andric #include <cassert>
630b57cec5SDimitry Andric #include <cstdint>
64bdd1243dSDimitry Andric #include <optional>
650b57cec5SDimitry Andric #include <string>
660b57cec5SDimitry Andric 
670b57cec5SDimitry Andric using namespace clang;
680b57cec5SDimitry Andric using namespace serialization;
690b57cec5SDimitry Andric 
700b57cec5SDimitry Andric namespace clang {
710b57cec5SDimitry Andric 
720b57cec5SDimitry Andric   class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
730b57cec5SDimitry Andric     ASTRecordReader &Record;
740b57cec5SDimitry Andric     llvm::BitstreamCursor &DeclsCursor;
750b57cec5SDimitry Andric 
76cb14a3feSDimitry Andric     std::optional<BitsUnpacker> CurrentUnpackingBits;
77cb14a3feSDimitry Andric 
78480093f4SDimitry Andric     SourceLocation readSourceLocation() {
790b57cec5SDimitry Andric       return Record.readSourceLocation();
800b57cec5SDimitry Andric     }
810b57cec5SDimitry Andric 
82480093f4SDimitry Andric     SourceRange readSourceRange() {
830b57cec5SDimitry Andric       return Record.readSourceRange();
840b57cec5SDimitry Andric     }
850b57cec5SDimitry Andric 
86480093f4SDimitry Andric     std::string readString() {
870b57cec5SDimitry Andric       return Record.readString();
880b57cec5SDimitry Andric     }
890b57cec5SDimitry Andric 
90480093f4SDimitry Andric     TypeSourceInfo *readTypeSourceInfo() {
91480093f4SDimitry Andric       return Record.readTypeSourceInfo();
920b57cec5SDimitry Andric     }
930b57cec5SDimitry Andric 
94480093f4SDimitry Andric     Decl *readDecl() {
950b57cec5SDimitry Andric       return Record.readDecl();
960b57cec5SDimitry Andric     }
970b57cec5SDimitry Andric 
980b57cec5SDimitry Andric     template<typename T>
99480093f4SDimitry Andric     T *readDeclAs() {
1000b57cec5SDimitry Andric       return Record.readDeclAs<T>();
1010b57cec5SDimitry Andric     }
1020b57cec5SDimitry Andric 
1030b57cec5SDimitry Andric   public:
1040b57cec5SDimitry Andric     ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
1050b57cec5SDimitry Andric         : Record(Record), DeclsCursor(Cursor) {}
1060b57cec5SDimitry Andric 
1070b57cec5SDimitry Andric     /// The number of record fields required for the Stmt class
1080b57cec5SDimitry Andric     /// itself.
1095ffd83dbSDimitry Andric     static const unsigned NumStmtFields = 0;
1100b57cec5SDimitry Andric 
1110b57cec5SDimitry Andric     /// The number of record fields required for the Expr class
1120b57cec5SDimitry Andric     /// itself.
1135f757f3fSDimitry Andric     static const unsigned NumExprFields = NumStmtFields + 2;
1140b57cec5SDimitry Andric 
115cb14a3feSDimitry Andric     /// The number of bits required for the packing bits for the Expr class.
116cb14a3feSDimitry Andric     static const unsigned NumExprBits = 10;
117cb14a3feSDimitry Andric 
1180b57cec5SDimitry Andric     /// Read and initialize a ExplicitTemplateArgumentList structure.
1190b57cec5SDimitry Andric     void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
1200b57cec5SDimitry Andric                                    TemplateArgumentLoc *ArgsLocArray,
1210b57cec5SDimitry Andric                                    unsigned NumTemplateArgs);
1220b57cec5SDimitry Andric 
1230b57cec5SDimitry Andric     void VisitStmt(Stmt *S);
1240b57cec5SDimitry Andric #define STMT(Type, Base) \
1250b57cec5SDimitry Andric     void Visit##Type(Type *);
1260b57cec5SDimitry Andric #include "clang/AST/StmtNodes.inc"
1270b57cec5SDimitry Andric   };
1280b57cec5SDimitry Andric 
1290b57cec5SDimitry Andric } // namespace clang
1300b57cec5SDimitry Andric 
1310b57cec5SDimitry Andric void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
1320b57cec5SDimitry Andric                                               TemplateArgumentLoc *ArgsLocArray,
1330b57cec5SDimitry Andric                                               unsigned NumTemplateArgs) {
134480093f4SDimitry Andric   SourceLocation TemplateKWLoc = readSourceLocation();
1350b57cec5SDimitry Andric   TemplateArgumentListInfo ArgInfo;
136480093f4SDimitry Andric   ArgInfo.setLAngleLoc(readSourceLocation());
137480093f4SDimitry Andric   ArgInfo.setRAngleLoc(readSourceLocation());
1380b57cec5SDimitry Andric   for (unsigned i = 0; i != NumTemplateArgs; ++i)
1390b57cec5SDimitry Andric     ArgInfo.addArgument(Record.readTemplateArgumentLoc());
1400b57cec5SDimitry Andric   Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
1410b57cec5SDimitry Andric }
1420b57cec5SDimitry Andric 
1430b57cec5SDimitry Andric void ASTStmtReader::VisitStmt(Stmt *S) {
1440b57cec5SDimitry Andric   assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
1450b57cec5SDimitry Andric }
1460b57cec5SDimitry Andric 
1470b57cec5SDimitry Andric void ASTStmtReader::VisitNullStmt(NullStmt *S) {
1480b57cec5SDimitry Andric   VisitStmt(S);
149480093f4SDimitry Andric   S->setSemiLoc(readSourceLocation());
1500b57cec5SDimitry Andric   S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
1510b57cec5SDimitry Andric }
1520b57cec5SDimitry Andric 
1530b57cec5SDimitry Andric void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
1540b57cec5SDimitry Andric   VisitStmt(S);
1550b57cec5SDimitry Andric   SmallVector<Stmt *, 16> Stmts;
1560b57cec5SDimitry Andric   unsigned NumStmts = Record.readInt();
15781ad6265SDimitry Andric   unsigned HasFPFeatures = Record.readInt();
15881ad6265SDimitry Andric   assert(S->hasStoredFPFeatures() == HasFPFeatures);
1590b57cec5SDimitry Andric   while (NumStmts--)
1600b57cec5SDimitry Andric     Stmts.push_back(Record.readSubStmt());
1610b57cec5SDimitry Andric   S->setStmts(Stmts);
16281ad6265SDimitry Andric   if (HasFPFeatures)
16381ad6265SDimitry Andric     S->setStoredFPFeatures(
16481ad6265SDimitry Andric         FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
16581ad6265SDimitry Andric   S->LBraceLoc = readSourceLocation();
166480093f4SDimitry Andric   S->RBraceLoc = readSourceLocation();
1670b57cec5SDimitry Andric }
1680b57cec5SDimitry Andric 
1690b57cec5SDimitry Andric void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
1700b57cec5SDimitry Andric   VisitStmt(S);
1710b57cec5SDimitry Andric   Record.recordSwitchCaseID(S, Record.readInt());
172480093f4SDimitry Andric   S->setKeywordLoc(readSourceLocation());
173480093f4SDimitry Andric   S->setColonLoc(readSourceLocation());
1740b57cec5SDimitry Andric }
1750b57cec5SDimitry Andric 
1760b57cec5SDimitry Andric void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
1770b57cec5SDimitry Andric   VisitSwitchCase(S);
1780b57cec5SDimitry Andric   bool CaseStmtIsGNURange = Record.readInt();
1790b57cec5SDimitry Andric   S->setLHS(Record.readSubExpr());
1800b57cec5SDimitry Andric   S->setSubStmt(Record.readSubStmt());
1810b57cec5SDimitry Andric   if (CaseStmtIsGNURange) {
1820b57cec5SDimitry Andric     S->setRHS(Record.readSubExpr());
183480093f4SDimitry Andric     S->setEllipsisLoc(readSourceLocation());
1840b57cec5SDimitry Andric   }
1850b57cec5SDimitry Andric }
1860b57cec5SDimitry Andric 
1870b57cec5SDimitry Andric void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
1880b57cec5SDimitry Andric   VisitSwitchCase(S);
1890b57cec5SDimitry Andric   S->setSubStmt(Record.readSubStmt());
1900b57cec5SDimitry Andric }
1910b57cec5SDimitry Andric 
1920b57cec5SDimitry Andric void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
1930b57cec5SDimitry Andric   VisitStmt(S);
194fe6060f1SDimitry Andric   bool IsSideEntry = Record.readInt();
195480093f4SDimitry Andric   auto *LD = readDeclAs<LabelDecl>();
1960b57cec5SDimitry Andric   LD->setStmt(S);
1970b57cec5SDimitry Andric   S->setDecl(LD);
1980b57cec5SDimitry Andric   S->setSubStmt(Record.readSubStmt());
199480093f4SDimitry Andric   S->setIdentLoc(readSourceLocation());
200fe6060f1SDimitry Andric   S->setSideEntry(IsSideEntry);
2010b57cec5SDimitry Andric }
2020b57cec5SDimitry Andric 
2030b57cec5SDimitry Andric void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
2040b57cec5SDimitry Andric   VisitStmt(S);
2050b57cec5SDimitry Andric   // NumAttrs in AttributedStmt is set when creating an empty
2060b57cec5SDimitry Andric   // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
2070b57cec5SDimitry Andric   // to allocate the right amount of space for the trailing Attr *.
2080b57cec5SDimitry Andric   uint64_t NumAttrs = Record.readInt();
2090b57cec5SDimitry Andric   AttrVec Attrs;
2100b57cec5SDimitry Andric   Record.readAttributes(Attrs);
2110b57cec5SDimitry Andric   (void)NumAttrs;
2120b57cec5SDimitry Andric   assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
2130b57cec5SDimitry Andric   assert(NumAttrs == Attrs.size());
2140b57cec5SDimitry Andric   std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
2150b57cec5SDimitry Andric   S->SubStmt = Record.readSubStmt();
216480093f4SDimitry Andric   S->AttributedStmtBits.AttrLoc = readSourceLocation();
2170b57cec5SDimitry Andric }
2180b57cec5SDimitry Andric 
2190b57cec5SDimitry Andric void ASTStmtReader::VisitIfStmt(IfStmt *S) {
2200b57cec5SDimitry Andric   VisitStmt(S);
2210b57cec5SDimitry Andric 
222cb14a3feSDimitry Andric   CurrentUnpackingBits.emplace(Record.readInt());
223cb14a3feSDimitry Andric 
224cb14a3feSDimitry Andric   bool HasElse = CurrentUnpackingBits->getNextBit();
225cb14a3feSDimitry Andric   bool HasVar = CurrentUnpackingBits->getNextBit();
226cb14a3feSDimitry Andric   bool HasInit = CurrentUnpackingBits->getNextBit();
2270b57cec5SDimitry Andric 
228349cc55cSDimitry Andric   S->setStatementKind(static_cast<IfStatementKind>(Record.readInt()));
2290b57cec5SDimitry Andric   S->setCond(Record.readSubExpr());
2300b57cec5SDimitry Andric   S->setThen(Record.readSubStmt());
2310b57cec5SDimitry Andric   if (HasElse)
2320b57cec5SDimitry Andric     S->setElse(Record.readSubStmt());
2330b57cec5SDimitry Andric   if (HasVar)
23406c3fb27SDimitry Andric     S->setConditionVariableDeclStmt(cast<DeclStmt>(Record.readSubStmt()));
2350b57cec5SDimitry Andric   if (HasInit)
2360b57cec5SDimitry Andric     S->setInit(Record.readSubStmt());
2370b57cec5SDimitry Andric 
238480093f4SDimitry Andric   S->setIfLoc(readSourceLocation());
239e8d8bef9SDimitry Andric   S->setLParenLoc(readSourceLocation());
240e8d8bef9SDimitry Andric   S->setRParenLoc(readSourceLocation());
2410b57cec5SDimitry Andric   if (HasElse)
242480093f4SDimitry Andric     S->setElseLoc(readSourceLocation());
2430b57cec5SDimitry Andric }
2440b57cec5SDimitry Andric 
2450b57cec5SDimitry Andric void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
2460b57cec5SDimitry Andric   VisitStmt(S);
2470b57cec5SDimitry Andric 
2480b57cec5SDimitry Andric   bool HasInit = Record.readInt();
2490b57cec5SDimitry Andric   bool HasVar = Record.readInt();
2500b57cec5SDimitry Andric   bool AllEnumCasesCovered = Record.readInt();
2510b57cec5SDimitry Andric   if (AllEnumCasesCovered)
2520b57cec5SDimitry Andric     S->setAllEnumCasesCovered();
2530b57cec5SDimitry Andric 
2540b57cec5SDimitry Andric   S->setCond(Record.readSubExpr());
2550b57cec5SDimitry Andric   S->setBody(Record.readSubStmt());
2560b57cec5SDimitry Andric   if (HasInit)
2570b57cec5SDimitry Andric     S->setInit(Record.readSubStmt());
2580b57cec5SDimitry Andric   if (HasVar)
25906c3fb27SDimitry Andric     S->setConditionVariableDeclStmt(cast<DeclStmt>(Record.readSubStmt()));
2600b57cec5SDimitry Andric 
261480093f4SDimitry Andric   S->setSwitchLoc(readSourceLocation());
262e8d8bef9SDimitry Andric   S->setLParenLoc(readSourceLocation());
263e8d8bef9SDimitry Andric   S->setRParenLoc(readSourceLocation());
2640b57cec5SDimitry Andric 
2650b57cec5SDimitry Andric   SwitchCase *PrevSC = nullptr;
2660b57cec5SDimitry Andric   for (auto E = Record.size(); Record.getIdx() != E; ) {
2670b57cec5SDimitry Andric     SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
2680b57cec5SDimitry Andric     if (PrevSC)
2690b57cec5SDimitry Andric       PrevSC->setNextSwitchCase(SC);
2700b57cec5SDimitry Andric     else
2710b57cec5SDimitry Andric       S->setSwitchCaseList(SC);
2720b57cec5SDimitry Andric 
2730b57cec5SDimitry Andric     PrevSC = SC;
2740b57cec5SDimitry Andric   }
2750b57cec5SDimitry Andric }
2760b57cec5SDimitry Andric 
2770b57cec5SDimitry Andric void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
2780b57cec5SDimitry Andric   VisitStmt(S);
2790b57cec5SDimitry Andric 
2800b57cec5SDimitry Andric   bool HasVar = Record.readInt();
2810b57cec5SDimitry Andric 
2820b57cec5SDimitry Andric   S->setCond(Record.readSubExpr());
2830b57cec5SDimitry Andric   S->setBody(Record.readSubStmt());
2840b57cec5SDimitry Andric   if (HasVar)
28506c3fb27SDimitry Andric     S->setConditionVariableDeclStmt(cast<DeclStmt>(Record.readSubStmt()));
2860b57cec5SDimitry Andric 
287480093f4SDimitry Andric   S->setWhileLoc(readSourceLocation());
2885ffd83dbSDimitry Andric   S->setLParenLoc(readSourceLocation());
2895ffd83dbSDimitry Andric   S->setRParenLoc(readSourceLocation());
2900b57cec5SDimitry Andric }
2910b57cec5SDimitry Andric 
2920b57cec5SDimitry Andric void ASTStmtReader::VisitDoStmt(DoStmt *S) {
2930b57cec5SDimitry Andric   VisitStmt(S);
2940b57cec5SDimitry Andric   S->setCond(Record.readSubExpr());
2950b57cec5SDimitry Andric   S->setBody(Record.readSubStmt());
296480093f4SDimitry Andric   S->setDoLoc(readSourceLocation());
297480093f4SDimitry Andric   S->setWhileLoc(readSourceLocation());
298480093f4SDimitry Andric   S->setRParenLoc(readSourceLocation());
2990b57cec5SDimitry Andric }
3000b57cec5SDimitry Andric 
3010b57cec5SDimitry Andric void ASTStmtReader::VisitForStmt(ForStmt *S) {
3020b57cec5SDimitry Andric   VisitStmt(S);
3030b57cec5SDimitry Andric   S->setInit(Record.readSubStmt());
3040b57cec5SDimitry Andric   S->setCond(Record.readSubExpr());
30506c3fb27SDimitry Andric   S->setConditionVariableDeclStmt(cast_or_null<DeclStmt>(Record.readSubStmt()));
3060b57cec5SDimitry Andric   S->setInc(Record.readSubExpr());
3070b57cec5SDimitry Andric   S->setBody(Record.readSubStmt());
308480093f4SDimitry Andric   S->setForLoc(readSourceLocation());
309480093f4SDimitry Andric   S->setLParenLoc(readSourceLocation());
310480093f4SDimitry Andric   S->setRParenLoc(readSourceLocation());
3110b57cec5SDimitry Andric }
3120b57cec5SDimitry Andric 
3130b57cec5SDimitry Andric void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
3140b57cec5SDimitry Andric   VisitStmt(S);
315480093f4SDimitry Andric   S->setLabel(readDeclAs<LabelDecl>());
316480093f4SDimitry Andric   S->setGotoLoc(readSourceLocation());
317480093f4SDimitry Andric   S->setLabelLoc(readSourceLocation());
3180b57cec5SDimitry Andric }
3190b57cec5SDimitry Andric 
3200b57cec5SDimitry Andric void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
3210b57cec5SDimitry Andric   VisitStmt(S);
322480093f4SDimitry Andric   S->setGotoLoc(readSourceLocation());
323480093f4SDimitry Andric   S->setStarLoc(readSourceLocation());
3240b57cec5SDimitry Andric   S->setTarget(Record.readSubExpr());
3250b57cec5SDimitry Andric }
3260b57cec5SDimitry Andric 
3270b57cec5SDimitry Andric void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
3280b57cec5SDimitry Andric   VisitStmt(S);
329480093f4SDimitry Andric   S->setContinueLoc(readSourceLocation());
3300b57cec5SDimitry Andric }
3310b57cec5SDimitry Andric 
3320b57cec5SDimitry Andric void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
3330b57cec5SDimitry Andric   VisitStmt(S);
334480093f4SDimitry Andric   S->setBreakLoc(readSourceLocation());
3350b57cec5SDimitry Andric }
3360b57cec5SDimitry Andric 
3370b57cec5SDimitry Andric void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
3380b57cec5SDimitry Andric   VisitStmt(S);
3390b57cec5SDimitry Andric 
3400b57cec5SDimitry Andric   bool HasNRVOCandidate = Record.readInt();
3410b57cec5SDimitry Andric 
3420b57cec5SDimitry Andric   S->setRetValue(Record.readSubExpr());
3430b57cec5SDimitry Andric   if (HasNRVOCandidate)
344480093f4SDimitry Andric     S->setNRVOCandidate(readDeclAs<VarDecl>());
3450b57cec5SDimitry Andric 
346480093f4SDimitry Andric   S->setReturnLoc(readSourceLocation());
3470b57cec5SDimitry Andric }
3480b57cec5SDimitry Andric 
3490b57cec5SDimitry Andric void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
3500b57cec5SDimitry Andric   VisitStmt(S);
351480093f4SDimitry Andric   S->setStartLoc(readSourceLocation());
352480093f4SDimitry Andric   S->setEndLoc(readSourceLocation());
3530b57cec5SDimitry Andric 
3540b57cec5SDimitry Andric   if (Record.size() - Record.getIdx() == 1) {
3550b57cec5SDimitry Andric     // Single declaration
356480093f4SDimitry Andric     S->setDeclGroup(DeclGroupRef(readDecl()));
3570b57cec5SDimitry Andric   } else {
3580b57cec5SDimitry Andric     SmallVector<Decl *, 16> Decls;
3590b57cec5SDimitry Andric     int N = Record.size() - Record.getIdx();
3600b57cec5SDimitry Andric     Decls.reserve(N);
3610b57cec5SDimitry Andric     for (int I = 0; I < N; ++I)
362480093f4SDimitry Andric       Decls.push_back(readDecl());
3630b57cec5SDimitry Andric     S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
3640b57cec5SDimitry Andric                                                    Decls.data(),
3650b57cec5SDimitry Andric                                                    Decls.size())));
3660b57cec5SDimitry Andric   }
3670b57cec5SDimitry Andric }
3680b57cec5SDimitry Andric 
3690b57cec5SDimitry Andric void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
3700b57cec5SDimitry Andric   VisitStmt(S);
3710b57cec5SDimitry Andric   S->NumOutputs = Record.readInt();
3720b57cec5SDimitry Andric   S->NumInputs = Record.readInt();
3730b57cec5SDimitry Andric   S->NumClobbers = Record.readInt();
374480093f4SDimitry Andric   S->setAsmLoc(readSourceLocation());
3750b57cec5SDimitry Andric   S->setVolatile(Record.readInt());
3760b57cec5SDimitry Andric   S->setSimple(Record.readInt());
3770b57cec5SDimitry Andric }
3780b57cec5SDimitry Andric 
3790b57cec5SDimitry Andric void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
3800b57cec5SDimitry Andric   VisitAsmStmt(S);
3810b57cec5SDimitry Andric   S->NumLabels = Record.readInt();
382480093f4SDimitry Andric   S->setRParenLoc(readSourceLocation());
3830b57cec5SDimitry Andric   S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
3840b57cec5SDimitry Andric 
3850b57cec5SDimitry Andric   unsigned NumOutputs = S->getNumOutputs();
3860b57cec5SDimitry Andric   unsigned NumInputs = S->getNumInputs();
3870b57cec5SDimitry Andric   unsigned NumClobbers = S->getNumClobbers();
3880b57cec5SDimitry Andric   unsigned NumLabels = S->getNumLabels();
3890b57cec5SDimitry Andric 
3900b57cec5SDimitry Andric   // Outputs and inputs
3910b57cec5SDimitry Andric   SmallVector<IdentifierInfo *, 16> Names;
3920b57cec5SDimitry Andric   SmallVector<StringLiteral*, 16> Constraints;
3930b57cec5SDimitry Andric   SmallVector<Stmt*, 16> Exprs;
3940b57cec5SDimitry Andric   for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
395480093f4SDimitry Andric     Names.push_back(Record.readIdentifier());
3960b57cec5SDimitry Andric     Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
3970b57cec5SDimitry Andric     Exprs.push_back(Record.readSubStmt());
3980b57cec5SDimitry Andric   }
3990b57cec5SDimitry Andric 
4000b57cec5SDimitry Andric   // Constraints
4010b57cec5SDimitry Andric   SmallVector<StringLiteral*, 16> Clobbers;
4020b57cec5SDimitry Andric   for (unsigned I = 0; I != NumClobbers; ++I)
4030b57cec5SDimitry Andric     Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
4040b57cec5SDimitry Andric 
4050b57cec5SDimitry Andric   // Labels
40606c3fb27SDimitry Andric   for (unsigned I = 0, N = NumLabels; I != N; ++I) {
40706c3fb27SDimitry Andric     Names.push_back(Record.readIdentifier());
4080b57cec5SDimitry Andric     Exprs.push_back(Record.readSubStmt());
40906c3fb27SDimitry Andric   }
4100b57cec5SDimitry Andric 
4110b57cec5SDimitry Andric   S->setOutputsAndInputsAndClobbers(Record.getContext(),
4120b57cec5SDimitry Andric                                     Names.data(), Constraints.data(),
4130b57cec5SDimitry Andric                                     Exprs.data(), NumOutputs, NumInputs,
4140b57cec5SDimitry Andric                                     NumLabels,
4150b57cec5SDimitry Andric                                     Clobbers.data(), NumClobbers);
4160b57cec5SDimitry Andric }
4170b57cec5SDimitry Andric 
4180b57cec5SDimitry Andric void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
4190b57cec5SDimitry Andric   VisitAsmStmt(S);
420480093f4SDimitry Andric   S->LBraceLoc = readSourceLocation();
421480093f4SDimitry Andric   S->EndLoc = readSourceLocation();
4220b57cec5SDimitry Andric   S->NumAsmToks = Record.readInt();
423480093f4SDimitry Andric   std::string AsmStr = readString();
4240b57cec5SDimitry Andric 
4250b57cec5SDimitry Andric   // Read the tokens.
4260b57cec5SDimitry Andric   SmallVector<Token, 16> AsmToks;
4270b57cec5SDimitry Andric   AsmToks.reserve(S->NumAsmToks);
4280b57cec5SDimitry Andric   for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
4290b57cec5SDimitry Andric     AsmToks.push_back(Record.readToken());
4300b57cec5SDimitry Andric   }
4310b57cec5SDimitry Andric 
4320b57cec5SDimitry Andric   // The calls to reserve() for the FooData vectors are mandatory to
4330b57cec5SDimitry Andric   // prevent dead StringRefs in the Foo vectors.
4340b57cec5SDimitry Andric 
4350b57cec5SDimitry Andric   // Read the clobbers.
4360b57cec5SDimitry Andric   SmallVector<std::string, 16> ClobbersData;
4370b57cec5SDimitry Andric   SmallVector<StringRef, 16> Clobbers;
4380b57cec5SDimitry Andric   ClobbersData.reserve(S->NumClobbers);
4390b57cec5SDimitry Andric   Clobbers.reserve(S->NumClobbers);
4400b57cec5SDimitry Andric   for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
441480093f4SDimitry Andric     ClobbersData.push_back(readString());
4420b57cec5SDimitry Andric     Clobbers.push_back(ClobbersData.back());
4430b57cec5SDimitry Andric   }
4440b57cec5SDimitry Andric 
4450b57cec5SDimitry Andric   // Read the operands.
4460b57cec5SDimitry Andric   unsigned NumOperands = S->NumOutputs + S->NumInputs;
4470b57cec5SDimitry Andric   SmallVector<Expr*, 16> Exprs;
4480b57cec5SDimitry Andric   SmallVector<std::string, 16> ConstraintsData;
4490b57cec5SDimitry Andric   SmallVector<StringRef, 16> Constraints;
4500b57cec5SDimitry Andric   Exprs.reserve(NumOperands);
4510b57cec5SDimitry Andric   ConstraintsData.reserve(NumOperands);
4520b57cec5SDimitry Andric   Constraints.reserve(NumOperands);
4530b57cec5SDimitry Andric   for (unsigned i = 0; i != NumOperands; ++i) {
4540b57cec5SDimitry Andric     Exprs.push_back(cast<Expr>(Record.readSubStmt()));
455480093f4SDimitry Andric     ConstraintsData.push_back(readString());
4560b57cec5SDimitry Andric     Constraints.push_back(ConstraintsData.back());
4570b57cec5SDimitry Andric   }
4580b57cec5SDimitry Andric 
4590b57cec5SDimitry Andric   S->initialize(Record.getContext(), AsmStr, AsmToks,
4600b57cec5SDimitry Andric                 Constraints, Exprs, Clobbers);
4610b57cec5SDimitry Andric }
4620b57cec5SDimitry Andric 
4630b57cec5SDimitry Andric void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
4640b57cec5SDimitry Andric   VisitStmt(S);
4650b57cec5SDimitry Andric   assert(Record.peekInt() == S->NumParams);
4660b57cec5SDimitry Andric   Record.skipInts(1);
4670b57cec5SDimitry Andric   auto *StoredStmts = S->getStoredStmts();
4680b57cec5SDimitry Andric   for (unsigned i = 0;
4690b57cec5SDimitry Andric        i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
4700b57cec5SDimitry Andric     StoredStmts[i] = Record.readSubStmt();
4710b57cec5SDimitry Andric }
4720b57cec5SDimitry Andric 
4730b57cec5SDimitry Andric void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
4740b57cec5SDimitry Andric   VisitStmt(S);
4750b57cec5SDimitry Andric   S->CoreturnLoc = Record.readSourceLocation();
4760b57cec5SDimitry Andric   for (auto &SubStmt: S->SubStmts)
4770b57cec5SDimitry Andric     SubStmt = Record.readSubStmt();
4780b57cec5SDimitry Andric   S->IsImplicit = Record.readInt() != 0;
4790b57cec5SDimitry Andric }
4800b57cec5SDimitry Andric 
4810b57cec5SDimitry Andric void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
4820b57cec5SDimitry Andric   VisitExpr(E);
483480093f4SDimitry Andric   E->KeywordLoc = readSourceLocation();
4840b57cec5SDimitry Andric   for (auto &SubExpr: E->SubExprs)
4850b57cec5SDimitry Andric     SubExpr = Record.readSubStmt();
4860b57cec5SDimitry Andric   E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
4870b57cec5SDimitry Andric   E->setIsImplicit(Record.readInt() != 0);
4880b57cec5SDimitry Andric }
4890b57cec5SDimitry Andric 
4900b57cec5SDimitry Andric void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
4910b57cec5SDimitry Andric   VisitExpr(E);
492480093f4SDimitry Andric   E->KeywordLoc = readSourceLocation();
4930b57cec5SDimitry Andric   for (auto &SubExpr: E->SubExprs)
4940b57cec5SDimitry Andric     SubExpr = Record.readSubStmt();
4950b57cec5SDimitry Andric   E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
4960b57cec5SDimitry Andric }
4970b57cec5SDimitry Andric 
4980b57cec5SDimitry Andric void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
4990b57cec5SDimitry Andric   VisitExpr(E);
500480093f4SDimitry Andric   E->KeywordLoc = readSourceLocation();
5010b57cec5SDimitry Andric   for (auto &SubExpr: E->SubExprs)
5020b57cec5SDimitry Andric     SubExpr = Record.readSubStmt();
5030b57cec5SDimitry Andric }
5040b57cec5SDimitry Andric 
5050b57cec5SDimitry Andric void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
5060b57cec5SDimitry Andric   VisitStmt(S);
5070b57cec5SDimitry Andric   Record.skipInts(1);
508480093f4SDimitry Andric   S->setCapturedDecl(readDeclAs<CapturedDecl>());
5090b57cec5SDimitry Andric   S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
510480093f4SDimitry Andric   S->setCapturedRecordDecl(readDeclAs<RecordDecl>());
5110b57cec5SDimitry Andric 
5120b57cec5SDimitry Andric   // Capture inits
5130b57cec5SDimitry Andric   for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
5140b57cec5SDimitry Andric                                            E = S->capture_init_end();
5150b57cec5SDimitry Andric        I != E; ++I)
5160b57cec5SDimitry Andric     *I = Record.readSubExpr();
5170b57cec5SDimitry Andric 
5180b57cec5SDimitry Andric   // Body
5190b57cec5SDimitry Andric   S->setCapturedStmt(Record.readSubStmt());
5200b57cec5SDimitry Andric   S->getCapturedDecl()->setBody(S->getCapturedStmt());
5210b57cec5SDimitry Andric 
5220b57cec5SDimitry Andric   // Captures
5230b57cec5SDimitry Andric   for (auto &I : S->captures()) {
524480093f4SDimitry Andric     I.VarAndKind.setPointer(readDeclAs<VarDecl>());
5250b57cec5SDimitry Andric     I.VarAndKind.setInt(
5260b57cec5SDimitry Andric         static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
527480093f4SDimitry Andric     I.Loc = readSourceLocation();
5280b57cec5SDimitry Andric   }
5290b57cec5SDimitry Andric }
5300b57cec5SDimitry Andric 
5310b57cec5SDimitry Andric void ASTStmtReader::VisitExpr(Expr *E) {
5320b57cec5SDimitry Andric   VisitStmt(E);
533cb14a3feSDimitry Andric   CurrentUnpackingBits.emplace(Record.readInt());
534cb14a3feSDimitry Andric   E->setDependence(static_cast<ExprDependence>(
535cb14a3feSDimitry Andric       CurrentUnpackingBits->getNextBits(/*Width=*/5)));
536cb14a3feSDimitry Andric   E->setValueKind(static_cast<ExprValueKind>(
537cb14a3feSDimitry Andric       CurrentUnpackingBits->getNextBits(/*Width=*/2)));
538cb14a3feSDimitry Andric   E->setObjectKind(static_cast<ExprObjectKind>(
539cb14a3feSDimitry Andric       CurrentUnpackingBits->getNextBits(/*Width=*/3)));
540cb14a3feSDimitry Andric 
5410b57cec5SDimitry Andric   E->setType(Record.readType());
5420b57cec5SDimitry Andric   assert(Record.getIdx() == NumExprFields &&
5430b57cec5SDimitry Andric          "Incorrect expression field count");
5440b57cec5SDimitry Andric }
5450b57cec5SDimitry Andric 
5460b57cec5SDimitry Andric void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
5470b57cec5SDimitry Andric   VisitExpr(E);
5485ffd83dbSDimitry Andric 
5495f757f3fSDimitry Andric   auto StorageKind = static_cast<ConstantResultStorageKind>(Record.readInt());
5505f757f3fSDimitry Andric   assert(E->getResultStorageKind() == StorageKind && "Wrong ResultKind!");
5515ffd83dbSDimitry Andric 
5525ffd83dbSDimitry Andric   E->ConstantExprBits.APValueKind = Record.readInt();
5535ffd83dbSDimitry Andric   E->ConstantExprBits.IsUnsigned = Record.readInt();
5545ffd83dbSDimitry Andric   E->ConstantExprBits.BitWidth = Record.readInt();
5555ffd83dbSDimitry Andric   E->ConstantExprBits.HasCleanup = false; // Not serialized, see below.
5565ffd83dbSDimitry Andric   E->ConstantExprBits.IsImmediateInvocation = Record.readInt();
5575ffd83dbSDimitry Andric 
5585ffd83dbSDimitry Andric   switch (StorageKind) {
5595f757f3fSDimitry Andric   case ConstantResultStorageKind::None:
5600b57cec5SDimitry Andric     break;
5615ffd83dbSDimitry Andric 
5625f757f3fSDimitry Andric   case ConstantResultStorageKind::Int64:
5635ffd83dbSDimitry Andric     E->Int64Result() = Record.readInt();
5645ffd83dbSDimitry Andric     break;
5655ffd83dbSDimitry Andric 
5665f757f3fSDimitry Andric   case ConstantResultStorageKind::APValue:
5670b57cec5SDimitry Andric     E->APValueResult() = Record.readAPValue();
5685ffd83dbSDimitry Andric     if (E->APValueResult().needsCleanup()) {
5695ffd83dbSDimitry Andric       E->ConstantExprBits.HasCleanup = true;
5705ffd83dbSDimitry Andric       Record.getContext().addDestruction(&E->APValueResult());
5710b57cec5SDimitry Andric     }
5725ffd83dbSDimitry Andric     break;
5735ffd83dbSDimitry Andric   }
5745ffd83dbSDimitry Andric 
5750b57cec5SDimitry Andric   E->setSubExpr(Record.readSubExpr());
5760b57cec5SDimitry Andric }
5770b57cec5SDimitry Andric 
578fe6060f1SDimitry Andric void ASTStmtReader::VisitSYCLUniqueStableNameExpr(SYCLUniqueStableNameExpr *E) {
579fe6060f1SDimitry Andric   VisitExpr(E);
580fe6060f1SDimitry Andric 
581fe6060f1SDimitry Andric   E->setLocation(readSourceLocation());
582fe6060f1SDimitry Andric   E->setLParenLocation(readSourceLocation());
583fe6060f1SDimitry Andric   E->setRParenLocation(readSourceLocation());
584fe6060f1SDimitry Andric 
585fe6060f1SDimitry Andric   E->setTypeSourceInfo(Record.readTypeSourceInfo());
586fe6060f1SDimitry Andric }
587fe6060f1SDimitry Andric 
5880b57cec5SDimitry Andric void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
5890b57cec5SDimitry Andric   VisitExpr(E);
5900b57cec5SDimitry Andric   bool HasFunctionName = Record.readInt();
5910b57cec5SDimitry Andric   E->PredefinedExprBits.HasFunctionName = HasFunctionName;
5920b57cec5SDimitry Andric   E->PredefinedExprBits.Kind = Record.readInt();
59306c3fb27SDimitry Andric   E->PredefinedExprBits.IsTransparent = Record.readInt();
594480093f4SDimitry Andric   E->setLocation(readSourceLocation());
5950b57cec5SDimitry Andric   if (HasFunctionName)
5960b57cec5SDimitry Andric     E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
5970b57cec5SDimitry Andric }
5980b57cec5SDimitry Andric 
5990b57cec5SDimitry Andric void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
6000b57cec5SDimitry Andric   VisitExpr(E);
6010b57cec5SDimitry Andric 
602cb14a3feSDimitry Andric   CurrentUnpackingBits.emplace(Record.readInt());
603cb14a3feSDimitry Andric   E->DeclRefExprBits.HadMultipleCandidates = CurrentUnpackingBits->getNextBit();
604cb14a3feSDimitry Andric   E->DeclRefExprBits.RefersToEnclosingVariableOrCapture =
605cb14a3feSDimitry Andric       CurrentUnpackingBits->getNextBit();
606cb14a3feSDimitry Andric   E->DeclRefExprBits.NonOdrUseReason =
607cb14a3feSDimitry Andric       CurrentUnpackingBits->getNextBits(/*Width=*/2);
608cb14a3feSDimitry Andric   E->DeclRefExprBits.IsImmediateEscalating = CurrentUnpackingBits->getNextBit();
609cb14a3feSDimitry Andric   E->DeclRefExprBits.HasFoundDecl = CurrentUnpackingBits->getNextBit();
610cb14a3feSDimitry Andric   E->DeclRefExprBits.HasQualifier = CurrentUnpackingBits->getNextBit();
611cb14a3feSDimitry Andric   E->DeclRefExprBits.HasTemplateKWAndArgsInfo =
612cb14a3feSDimitry Andric       CurrentUnpackingBits->getNextBit();
6135f757f3fSDimitry Andric   E->DeclRefExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter = false;
6140b57cec5SDimitry Andric   unsigned NumTemplateArgs = 0;
6150b57cec5SDimitry Andric   if (E->hasTemplateKWAndArgsInfo())
6160b57cec5SDimitry Andric     NumTemplateArgs = Record.readInt();
6170b57cec5SDimitry Andric 
6180b57cec5SDimitry Andric   if (E->hasQualifier())
6190b57cec5SDimitry Andric     new (E->getTrailingObjects<NestedNameSpecifierLoc>())
6200b57cec5SDimitry Andric         NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
6210b57cec5SDimitry Andric 
6220b57cec5SDimitry Andric   if (E->hasFoundDecl())
623480093f4SDimitry Andric     *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
6240b57cec5SDimitry Andric 
6250b57cec5SDimitry Andric   if (E->hasTemplateKWAndArgsInfo())
6260b57cec5SDimitry Andric     ReadTemplateKWAndArgsInfo(
6270b57cec5SDimitry Andric         *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
6280b57cec5SDimitry Andric         E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
6290b57cec5SDimitry Andric 
630e8d8bef9SDimitry Andric   E->D = readDeclAs<ValueDecl>();
631480093f4SDimitry Andric   E->setLocation(readSourceLocation());
632480093f4SDimitry Andric   E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
6330b57cec5SDimitry Andric }
6340b57cec5SDimitry Andric 
6350b57cec5SDimitry Andric void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
6360b57cec5SDimitry Andric   VisitExpr(E);
637480093f4SDimitry Andric   E->setLocation(readSourceLocation());
6380b57cec5SDimitry Andric   E->setValue(Record.getContext(), Record.readAPInt());
6390b57cec5SDimitry Andric }
6400b57cec5SDimitry Andric 
6410b57cec5SDimitry Andric void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
6420b57cec5SDimitry Andric   VisitExpr(E);
643480093f4SDimitry Andric   E->setLocation(readSourceLocation());
6445ffd83dbSDimitry Andric   E->setScale(Record.readInt());
6450b57cec5SDimitry Andric   E->setValue(Record.getContext(), Record.readAPInt());
6460b57cec5SDimitry Andric }
6470b57cec5SDimitry Andric 
6480b57cec5SDimitry Andric void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
6490b57cec5SDimitry Andric   VisitExpr(E);
6500b57cec5SDimitry Andric   E->setRawSemantics(
6510b57cec5SDimitry Andric       static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
6520b57cec5SDimitry Andric   E->setExact(Record.readInt());
6530b57cec5SDimitry Andric   E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
654480093f4SDimitry Andric   E->setLocation(readSourceLocation());
6550b57cec5SDimitry Andric }
6560b57cec5SDimitry Andric 
6570b57cec5SDimitry Andric void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
6580b57cec5SDimitry Andric   VisitExpr(E);
6590b57cec5SDimitry Andric   E->setSubExpr(Record.readSubExpr());
6600b57cec5SDimitry Andric }
6610b57cec5SDimitry Andric 
6620b57cec5SDimitry Andric void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
6630b57cec5SDimitry Andric   VisitExpr(E);
6640b57cec5SDimitry Andric 
6650b57cec5SDimitry Andric   // NumConcatenated, Length and CharByteWidth are set by the empty
6660b57cec5SDimitry Andric   // ctor since they are needed to allocate storage for the trailing objects.
6670b57cec5SDimitry Andric   unsigned NumConcatenated = Record.readInt();
6680b57cec5SDimitry Andric   unsigned Length = Record.readInt();
6690b57cec5SDimitry Andric   unsigned CharByteWidth = Record.readInt();
6700b57cec5SDimitry Andric   assert((NumConcatenated == E->getNumConcatenated()) &&
6710b57cec5SDimitry Andric          "Wrong number of concatenated tokens!");
6720b57cec5SDimitry Andric   assert((Length == E->getLength()) && "Wrong Length!");
6730b57cec5SDimitry Andric   assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
6740b57cec5SDimitry Andric   E->StringLiteralBits.Kind = Record.readInt();
6750b57cec5SDimitry Andric   E->StringLiteralBits.IsPascal = Record.readInt();
6760b57cec5SDimitry Andric 
6770b57cec5SDimitry Andric   // The character width is originally computed via mapCharByteWidth.
6780b57cec5SDimitry Andric   // Check that the deserialized character width is consistant with the result
6790b57cec5SDimitry Andric   // of calling mapCharByteWidth.
6800b57cec5SDimitry Andric   assert((CharByteWidth ==
6810b57cec5SDimitry Andric           StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
6820b57cec5SDimitry Andric                                           E->getKind())) &&
6830b57cec5SDimitry Andric          "Wrong character width!");
6840b57cec5SDimitry Andric 
6850b57cec5SDimitry Andric   // Deserialize the trailing array of SourceLocation.
6860b57cec5SDimitry Andric   for (unsigned I = 0; I < NumConcatenated; ++I)
687480093f4SDimitry Andric     E->setStrTokenLoc(I, readSourceLocation());
6880b57cec5SDimitry Andric 
6890b57cec5SDimitry Andric   // Deserialize the trailing array of char holding the string data.
6900b57cec5SDimitry Andric   char *StrData = E->getStrDataAsChar();
6910b57cec5SDimitry Andric   for (unsigned I = 0; I < Length * CharByteWidth; ++I)
6920b57cec5SDimitry Andric     StrData[I] = Record.readInt();
6930b57cec5SDimitry Andric }
6940b57cec5SDimitry Andric 
6950b57cec5SDimitry Andric void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
6960b57cec5SDimitry Andric   VisitExpr(E);
6970b57cec5SDimitry Andric   E->setValue(Record.readInt());
698480093f4SDimitry Andric   E->setLocation(readSourceLocation());
6995f757f3fSDimitry Andric   E->setKind(static_cast<CharacterLiteralKind>(Record.readInt()));
7000b57cec5SDimitry Andric }
7010b57cec5SDimitry Andric 
7020b57cec5SDimitry Andric void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
7030b57cec5SDimitry Andric   VisitExpr(E);
704480093f4SDimitry Andric   E->setLParen(readSourceLocation());
705480093f4SDimitry Andric   E->setRParen(readSourceLocation());
7060b57cec5SDimitry Andric   E->setSubExpr(Record.readSubExpr());
7070b57cec5SDimitry Andric }
7080b57cec5SDimitry Andric 
7090b57cec5SDimitry Andric void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
7100b57cec5SDimitry Andric   VisitExpr(E);
7110b57cec5SDimitry Andric   unsigned NumExprs = Record.readInt();
7120b57cec5SDimitry Andric   assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
7130b57cec5SDimitry Andric   for (unsigned I = 0; I != NumExprs; ++I)
7140b57cec5SDimitry Andric     E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
715480093f4SDimitry Andric   E->LParenLoc = readSourceLocation();
716480093f4SDimitry Andric   E->RParenLoc = readSourceLocation();
7170b57cec5SDimitry Andric }
7180b57cec5SDimitry Andric 
7190b57cec5SDimitry Andric void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
7200b57cec5SDimitry Andric   VisitExpr(E);
721cb14a3feSDimitry Andric   bool hasFP_Features = CurrentUnpackingBits->getNextBit();
7225ffd83dbSDimitry Andric   assert(hasFP_Features == E->hasStoredFPFeatures());
7230b57cec5SDimitry Andric   E->setSubExpr(Record.readSubExpr());
724cb14a3feSDimitry Andric   E->setOpcode(
725cb14a3feSDimitry Andric       (UnaryOperator::Opcode)CurrentUnpackingBits->getNextBits(/*Width=*/5));
726480093f4SDimitry Andric   E->setOperatorLoc(readSourceLocation());
727cb14a3feSDimitry Andric   E->setCanOverflow(CurrentUnpackingBits->getNextBit());
7285ffd83dbSDimitry Andric   if (hasFP_Features)
729e8d8bef9SDimitry Andric     E->setStoredFPFeatures(
730e8d8bef9SDimitry Andric         FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
7310b57cec5SDimitry Andric }
7320b57cec5SDimitry Andric 
7330b57cec5SDimitry Andric void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
7340b57cec5SDimitry Andric   VisitExpr(E);
7350b57cec5SDimitry Andric   assert(E->getNumComponents() == Record.peekInt());
7360b57cec5SDimitry Andric   Record.skipInts(1);
7370b57cec5SDimitry Andric   assert(E->getNumExpressions() == Record.peekInt());
7380b57cec5SDimitry Andric   Record.skipInts(1);
739480093f4SDimitry Andric   E->setOperatorLoc(readSourceLocation());
740480093f4SDimitry Andric   E->setRParenLoc(readSourceLocation());
741480093f4SDimitry Andric   E->setTypeSourceInfo(readTypeSourceInfo());
7420b57cec5SDimitry Andric   for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
7430b57cec5SDimitry Andric     auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
744480093f4SDimitry Andric     SourceLocation Start = readSourceLocation();
745480093f4SDimitry Andric     SourceLocation End = readSourceLocation();
7460b57cec5SDimitry Andric     switch (Kind) {
7470b57cec5SDimitry Andric     case OffsetOfNode::Array:
7480b57cec5SDimitry Andric       E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
7490b57cec5SDimitry Andric       break;
7500b57cec5SDimitry Andric 
7510b57cec5SDimitry Andric     case OffsetOfNode::Field:
7520b57cec5SDimitry Andric       E->setComponent(
753480093f4SDimitry Andric           I, OffsetOfNode(Start, readDeclAs<FieldDecl>(), End));
7540b57cec5SDimitry Andric       break;
7550b57cec5SDimitry Andric 
7560b57cec5SDimitry Andric     case OffsetOfNode::Identifier:
7570b57cec5SDimitry Andric       E->setComponent(
7580b57cec5SDimitry Andric           I,
759480093f4SDimitry Andric           OffsetOfNode(Start, Record.readIdentifier(), End));
7600b57cec5SDimitry Andric       break;
7610b57cec5SDimitry Andric 
7620b57cec5SDimitry Andric     case OffsetOfNode::Base: {
7630b57cec5SDimitry Andric       auto *Base = new (Record.getContext()) CXXBaseSpecifier();
7640b57cec5SDimitry Andric       *Base = Record.readCXXBaseSpecifier();
7650b57cec5SDimitry Andric       E->setComponent(I, OffsetOfNode(Base));
7660b57cec5SDimitry Andric       break;
7670b57cec5SDimitry Andric     }
7680b57cec5SDimitry Andric     }
7690b57cec5SDimitry Andric   }
7700b57cec5SDimitry Andric 
7710b57cec5SDimitry Andric   for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
7720b57cec5SDimitry Andric     E->setIndexExpr(I, Record.readSubExpr());
7730b57cec5SDimitry Andric }
7740b57cec5SDimitry Andric 
7750b57cec5SDimitry Andric void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
7760b57cec5SDimitry Andric   VisitExpr(E);
7770b57cec5SDimitry Andric   E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
7780b57cec5SDimitry Andric   if (Record.peekInt() == 0) {
7790b57cec5SDimitry Andric     E->setArgument(Record.readSubExpr());
7800b57cec5SDimitry Andric     Record.skipInts(1);
7810b57cec5SDimitry Andric   } else {
782480093f4SDimitry Andric     E->setArgument(readTypeSourceInfo());
7830b57cec5SDimitry Andric   }
784480093f4SDimitry Andric   E->setOperatorLoc(readSourceLocation());
785480093f4SDimitry Andric   E->setRParenLoc(readSourceLocation());
7860b57cec5SDimitry Andric }
7870b57cec5SDimitry Andric 
78855e4f9d5SDimitry Andric static ConstraintSatisfaction
78955e4f9d5SDimitry Andric readConstraintSatisfaction(ASTRecordReader &Record) {
79055e4f9d5SDimitry Andric   ConstraintSatisfaction Satisfaction;
79155e4f9d5SDimitry Andric   Satisfaction.IsSatisfied = Record.readInt();
792bdd1243dSDimitry Andric   Satisfaction.ContainsErrors = Record.readInt();
793*0fca6ea1SDimitry Andric   const ASTContext &C = Record.getContext();
79455e4f9d5SDimitry Andric   if (!Satisfaction.IsSatisfied) {
79555e4f9d5SDimitry Andric     unsigned NumDetailRecords = Record.readInt();
79655e4f9d5SDimitry Andric     for (unsigned i = 0; i != NumDetailRecords; ++i) {
7975ffd83dbSDimitry Andric       if (/* IsDiagnostic */Record.readInt()) {
79855e4f9d5SDimitry Andric         SourceLocation DiagLocation = Record.readSourceLocation();
799*0fca6ea1SDimitry Andric         StringRef DiagMessage = C.backupStr(Record.readString());
800*0fca6ea1SDimitry Andric 
80155e4f9d5SDimitry Andric         Satisfaction.Details.emplace_back(
802*0fca6ea1SDimitry Andric             new (C) ConstraintSatisfaction::SubstitutionDiagnostic(
803*0fca6ea1SDimitry Andric                 DiagLocation, DiagMessage));
80455e4f9d5SDimitry Andric       } else
805*0fca6ea1SDimitry Andric         Satisfaction.Details.emplace_back(Record.readExpr());
80655e4f9d5SDimitry Andric     }
80755e4f9d5SDimitry Andric   }
80855e4f9d5SDimitry Andric   return Satisfaction;
80955e4f9d5SDimitry Andric }
81055e4f9d5SDimitry Andric 
811a7dea167SDimitry Andric void ASTStmtReader::VisitConceptSpecializationExpr(
812a7dea167SDimitry Andric         ConceptSpecializationExpr *E) {
813a7dea167SDimitry Andric   VisitExpr(E);
814bdd1243dSDimitry Andric   E->SpecDecl = Record.readDeclAs<ImplicitConceptSpecializationDecl>();
8155f757f3fSDimitry Andric   if (Record.readBool())
8165f757f3fSDimitry Andric     E->ConceptRef = Record.readConceptReference();
81755e4f9d5SDimitry Andric   E->Satisfaction = E->isValueDependent() ? nullptr :
81855e4f9d5SDimitry Andric       ASTConstraintSatisfaction::Create(Record.getContext(),
81955e4f9d5SDimitry Andric                                         readConstraintSatisfaction(Record));
82055e4f9d5SDimitry Andric }
82155e4f9d5SDimitry Andric 
82255e4f9d5SDimitry Andric static concepts::Requirement::SubstitutionDiagnostic *
82355e4f9d5SDimitry Andric readSubstitutionDiagnostic(ASTRecordReader &Record) {
824*0fca6ea1SDimitry Andric   const ASTContext &C = Record.getContext();
825*0fca6ea1SDimitry Andric   StringRef SubstitutedEntity = C.backupStr(Record.readString());
82655e4f9d5SDimitry Andric   SourceLocation DiagLoc = Record.readSourceLocation();
827*0fca6ea1SDimitry Andric   StringRef DiagMessage = C.backupStr(Record.readString());
828*0fca6ea1SDimitry Andric 
82955e4f9d5SDimitry Andric   return new (Record.getContext())
83055e4f9d5SDimitry Andric       concepts::Requirement::SubstitutionDiagnostic{SubstitutedEntity, DiagLoc,
83155e4f9d5SDimitry Andric                                                     DiagMessage};
83255e4f9d5SDimitry Andric }
83355e4f9d5SDimitry Andric 
83455e4f9d5SDimitry Andric void ASTStmtReader::VisitRequiresExpr(RequiresExpr *E) {
83555e4f9d5SDimitry Andric   VisitExpr(E);
83655e4f9d5SDimitry Andric   unsigned NumLocalParameters = Record.readInt();
83755e4f9d5SDimitry Andric   unsigned NumRequirements = Record.readInt();
83855e4f9d5SDimitry Andric   E->RequiresExprBits.RequiresKWLoc = Record.readSourceLocation();
83955e4f9d5SDimitry Andric   E->RequiresExprBits.IsSatisfied = Record.readInt();
84055e4f9d5SDimitry Andric   E->Body = Record.readDeclAs<RequiresExprBodyDecl>();
84155e4f9d5SDimitry Andric   llvm::SmallVector<ParmVarDecl *, 4> LocalParameters;
84255e4f9d5SDimitry Andric   for (unsigned i = 0; i < NumLocalParameters; ++i)
84355e4f9d5SDimitry Andric     LocalParameters.push_back(cast<ParmVarDecl>(Record.readDecl()));
84455e4f9d5SDimitry Andric   std::copy(LocalParameters.begin(), LocalParameters.end(),
84555e4f9d5SDimitry Andric             E->getTrailingObjects<ParmVarDecl *>());
84655e4f9d5SDimitry Andric   llvm::SmallVector<concepts::Requirement *, 4> Requirements;
84755e4f9d5SDimitry Andric   for (unsigned i = 0; i < NumRequirements; ++i) {
84855e4f9d5SDimitry Andric     auto RK =
84955e4f9d5SDimitry Andric         static_cast<concepts::Requirement::RequirementKind>(Record.readInt());
85055e4f9d5SDimitry Andric     concepts::Requirement *R = nullptr;
85155e4f9d5SDimitry Andric     switch (RK) {
85255e4f9d5SDimitry Andric       case concepts::Requirement::RK_Type: {
85355e4f9d5SDimitry Andric         auto Status =
85455e4f9d5SDimitry Andric             static_cast<concepts::TypeRequirement::SatisfactionStatus>(
85555e4f9d5SDimitry Andric                 Record.readInt());
85655e4f9d5SDimitry Andric         if (Status == concepts::TypeRequirement::SS_SubstitutionFailure)
85755e4f9d5SDimitry Andric           R = new (Record.getContext())
85855e4f9d5SDimitry Andric               concepts::TypeRequirement(readSubstitutionDiagnostic(Record));
85955e4f9d5SDimitry Andric         else
86055e4f9d5SDimitry Andric           R = new (Record.getContext())
86155e4f9d5SDimitry Andric               concepts::TypeRequirement(Record.readTypeSourceInfo());
86255e4f9d5SDimitry Andric       } break;
86355e4f9d5SDimitry Andric       case concepts::Requirement::RK_Simple:
86455e4f9d5SDimitry Andric       case concepts::Requirement::RK_Compound: {
86555e4f9d5SDimitry Andric         auto Status =
86655e4f9d5SDimitry Andric             static_cast<concepts::ExprRequirement::SatisfactionStatus>(
86755e4f9d5SDimitry Andric                 Record.readInt());
86855e4f9d5SDimitry Andric         llvm::PointerUnion<concepts::Requirement::SubstitutionDiagnostic *,
86955e4f9d5SDimitry Andric                            Expr *> E;
87055e4f9d5SDimitry Andric         if (Status == concepts::ExprRequirement::SS_ExprSubstitutionFailure) {
87155e4f9d5SDimitry Andric           E = readSubstitutionDiagnostic(Record);
872480093f4SDimitry Andric         } else
87355e4f9d5SDimitry Andric           E = Record.readExpr();
87455e4f9d5SDimitry Andric 
875bdd1243dSDimitry Andric         std::optional<concepts::ExprRequirement::ReturnTypeRequirement> Req;
87655e4f9d5SDimitry Andric         ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr;
87755e4f9d5SDimitry Andric         SourceLocation NoexceptLoc;
87855e4f9d5SDimitry Andric         if (RK == concepts::Requirement::RK_Simple) {
87955e4f9d5SDimitry Andric           Req.emplace();
88055e4f9d5SDimitry Andric         } else {
88155e4f9d5SDimitry Andric           NoexceptLoc = Record.readSourceLocation();
8825ffd83dbSDimitry Andric           switch (/* returnTypeRequirementKind */Record.readInt()) {
88355e4f9d5SDimitry Andric             case 0:
88455e4f9d5SDimitry Andric               // No return type requirement.
88555e4f9d5SDimitry Andric               Req.emplace();
88655e4f9d5SDimitry Andric               break;
88755e4f9d5SDimitry Andric             case 1: {
88855e4f9d5SDimitry Andric               // type-constraint
88955e4f9d5SDimitry Andric               TemplateParameterList *TPL = Record.readTemplateParameterList();
89055e4f9d5SDimitry Andric               if (Status >=
89155e4f9d5SDimitry Andric                   concepts::ExprRequirement::SS_ConstraintsNotSatisfied)
89255e4f9d5SDimitry Andric                 SubstitutedConstraintExpr =
89355e4f9d5SDimitry Andric                     cast<ConceptSpecializationExpr>(Record.readExpr());
89455e4f9d5SDimitry Andric               Req.emplace(TPL);
89555e4f9d5SDimitry Andric             } break;
89655e4f9d5SDimitry Andric             case 2:
89755e4f9d5SDimitry Andric               // Substitution failure
89855e4f9d5SDimitry Andric               Req.emplace(readSubstitutionDiagnostic(Record));
89955e4f9d5SDimitry Andric               break;
900480093f4SDimitry Andric           }
901480093f4SDimitry Andric         }
90255e4f9d5SDimitry Andric         if (Expr *Ex = E.dyn_cast<Expr *>())
90355e4f9d5SDimitry Andric           R = new (Record.getContext()) concepts::ExprRequirement(
90455e4f9d5SDimitry Andric                   Ex, RK == concepts::Requirement::RK_Simple, NoexceptLoc,
90555e4f9d5SDimitry Andric                   std::move(*Req), Status, SubstitutedConstraintExpr);
90655e4f9d5SDimitry Andric         else
90755e4f9d5SDimitry Andric           R = new (Record.getContext()) concepts::ExprRequirement(
90855e4f9d5SDimitry Andric                   E.get<concepts::Requirement::SubstitutionDiagnostic *>(),
90955e4f9d5SDimitry Andric                   RK == concepts::Requirement::RK_Simple, NoexceptLoc,
91055e4f9d5SDimitry Andric                   std::move(*Req));
91155e4f9d5SDimitry Andric       } break;
91255e4f9d5SDimitry Andric       case concepts::Requirement::RK_Nested: {
913*0fca6ea1SDimitry Andric         ASTContext &C = Record.getContext();
914bdd1243dSDimitry Andric         bool HasInvalidConstraint = Record.readInt();
915bdd1243dSDimitry Andric         if (HasInvalidConstraint) {
916*0fca6ea1SDimitry Andric           StringRef InvalidConstraint = C.backupStr(Record.readString());
917*0fca6ea1SDimitry Andric           R = new (C) concepts::NestedRequirement(
918*0fca6ea1SDimitry Andric               Record.getContext(), InvalidConstraint,
919bdd1243dSDimitry Andric               readConstraintSatisfaction(Record));
92055e4f9d5SDimitry Andric           break;
92155e4f9d5SDimitry Andric         }
92255e4f9d5SDimitry Andric         Expr *E = Record.readExpr();
92355e4f9d5SDimitry Andric         if (E->isInstantiationDependent())
924*0fca6ea1SDimitry Andric           R = new (C) concepts::NestedRequirement(E);
92555e4f9d5SDimitry Andric         else
926*0fca6ea1SDimitry Andric           R = new (C) concepts::NestedRequirement(
927*0fca6ea1SDimitry Andric               C, E, readConstraintSatisfaction(Record));
92855e4f9d5SDimitry Andric       } break;
92955e4f9d5SDimitry Andric     }
93055e4f9d5SDimitry Andric     if (!R)
93155e4f9d5SDimitry Andric       continue;
93255e4f9d5SDimitry Andric     Requirements.push_back(R);
93355e4f9d5SDimitry Andric   }
93455e4f9d5SDimitry Andric   std::copy(Requirements.begin(), Requirements.end(),
93555e4f9d5SDimitry Andric             E->getTrailingObjects<concepts::Requirement *>());
9365f757f3fSDimitry Andric   E->LParenLoc = Record.readSourceLocation();
9375f757f3fSDimitry Andric   E->RParenLoc = Record.readSourceLocation();
93855e4f9d5SDimitry Andric   E->RBraceLoc = Record.readSourceLocation();
939a7dea167SDimitry Andric }
940a7dea167SDimitry Andric 
9410b57cec5SDimitry Andric void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
9420b57cec5SDimitry Andric   VisitExpr(E);
9430b57cec5SDimitry Andric   E->setLHS(Record.readSubExpr());
9440b57cec5SDimitry Andric   E->setRHS(Record.readSubExpr());
945480093f4SDimitry Andric   E->setRBracketLoc(readSourceLocation());
9460b57cec5SDimitry Andric }
9470b57cec5SDimitry Andric 
9485ffd83dbSDimitry Andric void ASTStmtReader::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
9495ffd83dbSDimitry Andric   VisitExpr(E);
9505ffd83dbSDimitry Andric   E->setBase(Record.readSubExpr());
9515ffd83dbSDimitry Andric   E->setRowIdx(Record.readSubExpr());
9525ffd83dbSDimitry Andric   E->setColumnIdx(Record.readSubExpr());
9535ffd83dbSDimitry Andric   E->setRBracketLoc(readSourceLocation());
9545ffd83dbSDimitry Andric }
9555ffd83dbSDimitry Andric 
956*0fca6ea1SDimitry Andric void ASTStmtReader::VisitArraySectionExpr(ArraySectionExpr *E) {
9570b57cec5SDimitry Andric   VisitExpr(E);
958*0fca6ea1SDimitry Andric   E->ASType = Record.readEnum<ArraySectionExpr::ArraySectionType>();
959*0fca6ea1SDimitry Andric 
9600b57cec5SDimitry Andric   E->setBase(Record.readSubExpr());
9610b57cec5SDimitry Andric   E->setLowerBound(Record.readSubExpr());
9620b57cec5SDimitry Andric   E->setLength(Record.readSubExpr());
963*0fca6ea1SDimitry Andric 
964*0fca6ea1SDimitry Andric   if (E->isOMPArraySection())
9655ffd83dbSDimitry Andric     E->setStride(Record.readSubExpr());
966*0fca6ea1SDimitry Andric 
9675ffd83dbSDimitry Andric   E->setColonLocFirst(readSourceLocation());
968*0fca6ea1SDimitry Andric 
969*0fca6ea1SDimitry Andric   if (E->isOMPArraySection())
9705ffd83dbSDimitry Andric     E->setColonLocSecond(readSourceLocation());
971*0fca6ea1SDimitry Andric 
972480093f4SDimitry Andric   E->setRBracketLoc(readSourceLocation());
9730b57cec5SDimitry Andric }
9740b57cec5SDimitry Andric 
9755ffd83dbSDimitry Andric void ASTStmtReader::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *E) {
9765ffd83dbSDimitry Andric   VisitExpr(E);
9775ffd83dbSDimitry Andric   unsigned NumDims = Record.readInt();
9785ffd83dbSDimitry Andric   E->setBase(Record.readSubExpr());
9795ffd83dbSDimitry Andric   SmallVector<Expr *, 4> Dims(NumDims);
9805ffd83dbSDimitry Andric   for (unsigned I = 0; I < NumDims; ++I)
9815ffd83dbSDimitry Andric     Dims[I] = Record.readSubExpr();
9825ffd83dbSDimitry Andric   E->setDimensions(Dims);
9835ffd83dbSDimitry Andric   SmallVector<SourceRange, 4> SRs(NumDims);
9845ffd83dbSDimitry Andric   for (unsigned I = 0; I < NumDims; ++I)
9855ffd83dbSDimitry Andric     SRs[I] = readSourceRange();
9865ffd83dbSDimitry Andric   E->setBracketsRanges(SRs);
9875ffd83dbSDimitry Andric   E->setLParenLoc(readSourceLocation());
9885ffd83dbSDimitry Andric   E->setRParenLoc(readSourceLocation());
9895ffd83dbSDimitry Andric }
9905ffd83dbSDimitry Andric 
9915ffd83dbSDimitry Andric void ASTStmtReader::VisitOMPIteratorExpr(OMPIteratorExpr *E) {
9925ffd83dbSDimitry Andric   VisitExpr(E);
9935ffd83dbSDimitry Andric   unsigned NumIters = Record.readInt();
9945ffd83dbSDimitry Andric   E->setIteratorKwLoc(readSourceLocation());
9955ffd83dbSDimitry Andric   E->setLParenLoc(readSourceLocation());
9965ffd83dbSDimitry Andric   E->setRParenLoc(readSourceLocation());
9975ffd83dbSDimitry Andric   for (unsigned I = 0; I < NumIters; ++I) {
9985ffd83dbSDimitry Andric     E->setIteratorDeclaration(I, Record.readDeclRef());
9995ffd83dbSDimitry Andric     E->setAssignmentLoc(I, readSourceLocation());
10005ffd83dbSDimitry Andric     Expr *Begin = Record.readSubExpr();
10015ffd83dbSDimitry Andric     Expr *End = Record.readSubExpr();
10025ffd83dbSDimitry Andric     Expr *Step = Record.readSubExpr();
10035ffd83dbSDimitry Andric     SourceLocation ColonLoc = readSourceLocation();
10045ffd83dbSDimitry Andric     SourceLocation SecColonLoc;
10055ffd83dbSDimitry Andric     if (Step)
10065ffd83dbSDimitry Andric       SecColonLoc = readSourceLocation();
10075ffd83dbSDimitry Andric     E->setIteratorRange(I, Begin, ColonLoc, End, SecColonLoc, Step);
10085ffd83dbSDimitry Andric     // Deserialize helpers
10095ffd83dbSDimitry Andric     OMPIteratorHelperData HD;
10105ffd83dbSDimitry Andric     HD.CounterVD = cast_or_null<VarDecl>(Record.readDeclRef());
10115ffd83dbSDimitry Andric     HD.Upper = Record.readSubExpr();
10125ffd83dbSDimitry Andric     HD.Update = Record.readSubExpr();
10135ffd83dbSDimitry Andric     HD.CounterUpdate = Record.readSubExpr();
10145ffd83dbSDimitry Andric     E->setHelper(I, HD);
10155ffd83dbSDimitry Andric   }
10165ffd83dbSDimitry Andric }
10175ffd83dbSDimitry Andric 
10180b57cec5SDimitry Andric void ASTStmtReader::VisitCallExpr(CallExpr *E) {
10190b57cec5SDimitry Andric   VisitExpr(E);
10205f757f3fSDimitry Andric 
1021cb14a3feSDimitry Andric   unsigned NumArgs = Record.readInt();
1022cb14a3feSDimitry Andric   CurrentUnpackingBits.emplace(Record.readInt());
10235f757f3fSDimitry Andric   E->setADLCallKind(
1024cb14a3feSDimitry Andric       static_cast<CallExpr::ADLCallKind>(CurrentUnpackingBits->getNextBit()));
1025cb14a3feSDimitry Andric   bool HasFPFeatures = CurrentUnpackingBits->getNextBit();
10260b57cec5SDimitry Andric   assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1027480093f4SDimitry Andric   E->setRParenLoc(readSourceLocation());
10280b57cec5SDimitry Andric   E->setCallee(Record.readSubExpr());
10290b57cec5SDimitry Andric   for (unsigned I = 0; I != NumArgs; ++I)
10300b57cec5SDimitry Andric     E->setArg(I, Record.readSubExpr());
10315f757f3fSDimitry Andric 
1032e8d8bef9SDimitry Andric   if (HasFPFeatures)
1033e8d8bef9SDimitry Andric     E->setStoredFPFeatures(
1034e8d8bef9SDimitry Andric         FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
10350b57cec5SDimitry Andric }
10360b57cec5SDimitry Andric 
10370b57cec5SDimitry Andric void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
10380b57cec5SDimitry Andric   VisitCallExpr(E);
10390b57cec5SDimitry Andric }
10400b57cec5SDimitry Andric 
10410b57cec5SDimitry Andric void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
10420b57cec5SDimitry Andric   VisitExpr(E);
10430b57cec5SDimitry Andric 
1044cb14a3feSDimitry Andric   CurrentUnpackingBits.emplace(Record.readInt());
1045cb14a3feSDimitry Andric   bool HasQualifier = CurrentUnpackingBits->getNextBit();
1046cb14a3feSDimitry Andric   bool HasFoundDecl = CurrentUnpackingBits->getNextBit();
1047cb14a3feSDimitry Andric   bool HasTemplateInfo = CurrentUnpackingBits->getNextBit();
10480b57cec5SDimitry Andric   unsigned NumTemplateArgs = Record.readInt();
10490b57cec5SDimitry Andric 
10500b57cec5SDimitry Andric   E->Base = Record.readSubExpr();
10510b57cec5SDimitry Andric   E->MemberDecl = Record.readDeclAs<ValueDecl>();
1052480093f4SDimitry Andric   E->MemberDNLoc = Record.readDeclarationNameLoc(E->MemberDecl->getDeclName());
10530b57cec5SDimitry Andric   E->MemberLoc = Record.readSourceLocation();
1054cb14a3feSDimitry Andric   E->MemberExprBits.IsArrow = CurrentUnpackingBits->getNextBit();
1055*0fca6ea1SDimitry Andric   E->MemberExprBits.HasQualifier = HasQualifier;
1056*0fca6ea1SDimitry Andric   E->MemberExprBits.HasFoundDecl = HasFoundDecl;
10570b57cec5SDimitry Andric   E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
1058cb14a3feSDimitry Andric   E->MemberExprBits.HadMultipleCandidates = CurrentUnpackingBits->getNextBit();
1059cb14a3feSDimitry Andric   E->MemberExprBits.NonOdrUseReason =
1060cb14a3feSDimitry Andric       CurrentUnpackingBits->getNextBits(/*Width=*/2);
10610b57cec5SDimitry Andric   E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
10620b57cec5SDimitry Andric 
1063*0fca6ea1SDimitry Andric   if (HasQualifier)
1064*0fca6ea1SDimitry Andric     new (E->getTrailingObjects<NestedNameSpecifierLoc>())
1065*0fca6ea1SDimitry Andric         NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
1066*0fca6ea1SDimitry Andric 
10670b57cec5SDimitry Andric   if (HasFoundDecl) {
10680b57cec5SDimitry Andric     auto *FoundD = Record.readDeclAs<NamedDecl>();
1069cb14a3feSDimitry Andric     auto AS = (AccessSpecifier)CurrentUnpackingBits->getNextBits(/*Width=*/2);
1070*0fca6ea1SDimitry Andric     *E->getTrailingObjects<DeclAccessPair>() = DeclAccessPair::make(FoundD, AS);
10710b57cec5SDimitry Andric   }
10720b57cec5SDimitry Andric 
10730b57cec5SDimitry Andric   if (HasTemplateInfo)
10740b57cec5SDimitry Andric     ReadTemplateKWAndArgsInfo(
10750b57cec5SDimitry Andric         *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
10760b57cec5SDimitry Andric         E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
10770b57cec5SDimitry Andric }
10780b57cec5SDimitry Andric 
10790b57cec5SDimitry Andric void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
10800b57cec5SDimitry Andric   VisitExpr(E);
10810b57cec5SDimitry Andric   E->setBase(Record.readSubExpr());
1082480093f4SDimitry Andric   E->setIsaMemberLoc(readSourceLocation());
1083480093f4SDimitry Andric   E->setOpLoc(readSourceLocation());
10840b57cec5SDimitry Andric   E->setArrow(Record.readInt());
10850b57cec5SDimitry Andric }
10860b57cec5SDimitry Andric 
10870b57cec5SDimitry Andric void ASTStmtReader::
10880b57cec5SDimitry Andric VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
10890b57cec5SDimitry Andric   VisitExpr(E);
10900b57cec5SDimitry Andric   E->Operand = Record.readSubExpr();
10910b57cec5SDimitry Andric   E->setShouldCopy(Record.readInt());
10920b57cec5SDimitry Andric }
10930b57cec5SDimitry Andric 
10940b57cec5SDimitry Andric void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
10950b57cec5SDimitry Andric   VisitExplicitCastExpr(E);
1096480093f4SDimitry Andric   E->LParenLoc = readSourceLocation();
1097480093f4SDimitry Andric   E->BridgeKeywordLoc = readSourceLocation();
10980b57cec5SDimitry Andric   E->Kind = Record.readInt();
10990b57cec5SDimitry Andric }
11000b57cec5SDimitry Andric 
11010b57cec5SDimitry Andric void ASTStmtReader::VisitCastExpr(CastExpr *E) {
11020b57cec5SDimitry Andric   VisitExpr(E);
11030b57cec5SDimitry Andric   unsigned NumBaseSpecs = Record.readInt();
11040b57cec5SDimitry Andric   assert(NumBaseSpecs == E->path_size());
1105cb14a3feSDimitry Andric 
1106cb14a3feSDimitry Andric   CurrentUnpackingBits.emplace(Record.readInt());
1107cb14a3feSDimitry Andric   E->setCastKind((CastKind)CurrentUnpackingBits->getNextBits(/*Width=*/7));
1108cb14a3feSDimitry Andric   unsigned HasFPFeatures = CurrentUnpackingBits->getNextBit();
1109e8d8bef9SDimitry Andric   assert(E->hasStoredFPFeatures() == HasFPFeatures);
1110cb14a3feSDimitry Andric 
11110b57cec5SDimitry Andric   E->setSubExpr(Record.readSubExpr());
1112cb14a3feSDimitry Andric 
11130b57cec5SDimitry Andric   CastExpr::path_iterator BaseI = E->path_begin();
11140b57cec5SDimitry Andric   while (NumBaseSpecs--) {
11150b57cec5SDimitry Andric     auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
11160b57cec5SDimitry Andric     *BaseSpec = Record.readCXXBaseSpecifier();
11170b57cec5SDimitry Andric     *BaseI++ = BaseSpec;
11180b57cec5SDimitry Andric   }
1119e8d8bef9SDimitry Andric   if (HasFPFeatures)
1120e8d8bef9SDimitry Andric     *E->getTrailingFPFeatures() =
1121e8d8bef9SDimitry Andric         FPOptionsOverride::getFromOpaqueInt(Record.readInt());
11220b57cec5SDimitry Andric }
11230b57cec5SDimitry Andric 
11240b57cec5SDimitry Andric void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
11250b57cec5SDimitry Andric   VisitExpr(E);
1126cb14a3feSDimitry Andric   CurrentUnpackingBits.emplace(Record.readInt());
1127cb14a3feSDimitry Andric   E->setOpcode(
1128cb14a3feSDimitry Andric       (BinaryOperator::Opcode)CurrentUnpackingBits->getNextBits(/*Width=*/6));
1129cb14a3feSDimitry Andric   bool hasFP_Features = CurrentUnpackingBits->getNextBit();
1130cb14a3feSDimitry Andric   E->setHasStoredFPFeatures(hasFP_Features);
11310b57cec5SDimitry Andric   E->setLHS(Record.readSubExpr());
11320b57cec5SDimitry Andric   E->setRHS(Record.readSubExpr());
1133480093f4SDimitry Andric   E->setOperatorLoc(readSourceLocation());
11345ffd83dbSDimitry Andric   if (hasFP_Features)
1135e8d8bef9SDimitry Andric     E->setStoredFPFeatures(
1136e8d8bef9SDimitry Andric         FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
11370b57cec5SDimitry Andric }
11380b57cec5SDimitry Andric 
11390b57cec5SDimitry Andric void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
11400b57cec5SDimitry Andric   VisitBinaryOperator(E);
11410b57cec5SDimitry Andric   E->setComputationLHSType(Record.readType());
11420b57cec5SDimitry Andric   E->setComputationResultType(Record.readType());
11430b57cec5SDimitry Andric }
11440b57cec5SDimitry Andric 
11450b57cec5SDimitry Andric void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
11460b57cec5SDimitry Andric   VisitExpr(E);
11470b57cec5SDimitry Andric   E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
11480b57cec5SDimitry Andric   E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
11490b57cec5SDimitry Andric   E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
1150480093f4SDimitry Andric   E->QuestionLoc = readSourceLocation();
1151480093f4SDimitry Andric   E->ColonLoc = readSourceLocation();
11520b57cec5SDimitry Andric }
11530b57cec5SDimitry Andric 
11540b57cec5SDimitry Andric void
11550b57cec5SDimitry Andric ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
11560b57cec5SDimitry Andric   VisitExpr(E);
11570b57cec5SDimitry Andric   E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
11580b57cec5SDimitry Andric   E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
11590b57cec5SDimitry Andric   E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
11600b57cec5SDimitry Andric   E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
11610b57cec5SDimitry Andric   E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
1162480093f4SDimitry Andric   E->QuestionLoc = readSourceLocation();
1163480093f4SDimitry Andric   E->ColonLoc = readSourceLocation();
11640b57cec5SDimitry Andric }
11650b57cec5SDimitry Andric 
11660b57cec5SDimitry Andric void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
11670b57cec5SDimitry Andric   VisitCastExpr(E);
1168cb14a3feSDimitry Andric   E->setIsPartOfExplicitCast(CurrentUnpackingBits->getNextBit());
11690b57cec5SDimitry Andric }
11700b57cec5SDimitry Andric 
11710b57cec5SDimitry Andric void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
11720b57cec5SDimitry Andric   VisitCastExpr(E);
1173480093f4SDimitry Andric   E->setTypeInfoAsWritten(readTypeSourceInfo());
11740b57cec5SDimitry Andric }
11750b57cec5SDimitry Andric 
11760b57cec5SDimitry Andric void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
11770b57cec5SDimitry Andric   VisitExplicitCastExpr(E);
1178480093f4SDimitry Andric   E->setLParenLoc(readSourceLocation());
1179480093f4SDimitry Andric   E->setRParenLoc(readSourceLocation());
11800b57cec5SDimitry Andric }
11810b57cec5SDimitry Andric 
11820b57cec5SDimitry Andric void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
11830b57cec5SDimitry Andric   VisitExpr(E);
1184480093f4SDimitry Andric   E->setLParenLoc(readSourceLocation());
1185480093f4SDimitry Andric   E->setTypeSourceInfo(readTypeSourceInfo());
11860b57cec5SDimitry Andric   E->setInitializer(Record.readSubExpr());
11870b57cec5SDimitry Andric   E->setFileScope(Record.readInt());
11880b57cec5SDimitry Andric }
11890b57cec5SDimitry Andric 
11900b57cec5SDimitry Andric void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
11910b57cec5SDimitry Andric   VisitExpr(E);
11920b57cec5SDimitry Andric   E->setBase(Record.readSubExpr());
1193480093f4SDimitry Andric   E->setAccessor(Record.readIdentifier());
1194480093f4SDimitry Andric   E->setAccessorLoc(readSourceLocation());
11950b57cec5SDimitry Andric }
11960b57cec5SDimitry Andric 
11970b57cec5SDimitry Andric void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
11980b57cec5SDimitry Andric   VisitExpr(E);
11990b57cec5SDimitry Andric   if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
12000b57cec5SDimitry Andric     E->setSyntacticForm(SyntForm);
1201480093f4SDimitry Andric   E->setLBraceLoc(readSourceLocation());
1202480093f4SDimitry Andric   E->setRBraceLoc(readSourceLocation());
12030b57cec5SDimitry Andric   bool isArrayFiller = Record.readInt();
12040b57cec5SDimitry Andric   Expr *filler = nullptr;
12050b57cec5SDimitry Andric   if (isArrayFiller) {
12060b57cec5SDimitry Andric     filler = Record.readSubExpr();
12070b57cec5SDimitry Andric     E->ArrayFillerOrUnionFieldInit = filler;
12080b57cec5SDimitry Andric   } else
1209480093f4SDimitry Andric     E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
12100b57cec5SDimitry Andric   E->sawArrayRangeDesignator(Record.readInt());
12110b57cec5SDimitry Andric   unsigned NumInits = Record.readInt();
12120b57cec5SDimitry Andric   E->reserveInits(Record.getContext(), NumInits);
12130b57cec5SDimitry Andric   if (isArrayFiller) {
12140b57cec5SDimitry Andric     for (unsigned I = 0; I != NumInits; ++I) {
12150b57cec5SDimitry Andric       Expr *init = Record.readSubExpr();
12160b57cec5SDimitry Andric       E->updateInit(Record.getContext(), I, init ? init : filler);
12170b57cec5SDimitry Andric     }
12180b57cec5SDimitry Andric   } else {
12190b57cec5SDimitry Andric     for (unsigned I = 0; I != NumInits; ++I)
12200b57cec5SDimitry Andric       E->updateInit(Record.getContext(), I, Record.readSubExpr());
12210b57cec5SDimitry Andric   }
12220b57cec5SDimitry Andric }
12230b57cec5SDimitry Andric 
12240b57cec5SDimitry Andric void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
12250b57cec5SDimitry Andric   using Designator = DesignatedInitExpr::Designator;
12260b57cec5SDimitry Andric 
12270b57cec5SDimitry Andric   VisitExpr(E);
12280b57cec5SDimitry Andric   unsigned NumSubExprs = Record.readInt();
12290b57cec5SDimitry Andric   assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
12300b57cec5SDimitry Andric   for (unsigned I = 0; I != NumSubExprs; ++I)
12310b57cec5SDimitry Andric     E->setSubExpr(I, Record.readSubExpr());
1232480093f4SDimitry Andric   E->setEqualOrColonLoc(readSourceLocation());
12330b57cec5SDimitry Andric   E->setGNUSyntax(Record.readInt());
12340b57cec5SDimitry Andric 
12350b57cec5SDimitry Andric   SmallVector<Designator, 4> Designators;
12360b57cec5SDimitry Andric   while (Record.getIdx() < Record.size()) {
12370b57cec5SDimitry Andric     switch ((DesignatorTypes)Record.readInt()) {
12380b57cec5SDimitry Andric     case DESIG_FIELD_DECL: {
1239480093f4SDimitry Andric       auto *Field = readDeclAs<FieldDecl>();
1240480093f4SDimitry Andric       SourceLocation DotLoc = readSourceLocation();
1241480093f4SDimitry Andric       SourceLocation FieldLoc = readSourceLocation();
124206c3fb27SDimitry Andric       Designators.push_back(Designator::CreateFieldDesignator(
124306c3fb27SDimitry Andric           Field->getIdentifier(), DotLoc, FieldLoc));
124406c3fb27SDimitry Andric       Designators.back().setFieldDecl(Field);
12450b57cec5SDimitry Andric       break;
12460b57cec5SDimitry Andric     }
12470b57cec5SDimitry Andric 
12480b57cec5SDimitry Andric     case DESIG_FIELD_NAME: {
1249480093f4SDimitry Andric       const IdentifierInfo *Name = Record.readIdentifier();
1250480093f4SDimitry Andric       SourceLocation DotLoc = readSourceLocation();
1251480093f4SDimitry Andric       SourceLocation FieldLoc = readSourceLocation();
125206c3fb27SDimitry Andric       Designators.push_back(Designator::CreateFieldDesignator(Name, DotLoc,
125306c3fb27SDimitry Andric                                                               FieldLoc));
12540b57cec5SDimitry Andric       break;
12550b57cec5SDimitry Andric     }
12560b57cec5SDimitry Andric 
12570b57cec5SDimitry Andric     case DESIG_ARRAY: {
12580b57cec5SDimitry Andric       unsigned Index = Record.readInt();
1259480093f4SDimitry Andric       SourceLocation LBracketLoc = readSourceLocation();
1260480093f4SDimitry Andric       SourceLocation RBracketLoc = readSourceLocation();
126106c3fb27SDimitry Andric       Designators.push_back(Designator::CreateArrayDesignator(Index,
126206c3fb27SDimitry Andric                                                               LBracketLoc,
126306c3fb27SDimitry Andric                                                               RBracketLoc));
12640b57cec5SDimitry Andric       break;
12650b57cec5SDimitry Andric     }
12660b57cec5SDimitry Andric 
12670b57cec5SDimitry Andric     case DESIG_ARRAY_RANGE: {
12680b57cec5SDimitry Andric       unsigned Index = Record.readInt();
1269480093f4SDimitry Andric       SourceLocation LBracketLoc = readSourceLocation();
1270480093f4SDimitry Andric       SourceLocation EllipsisLoc = readSourceLocation();
1271480093f4SDimitry Andric       SourceLocation RBracketLoc = readSourceLocation();
127206c3fb27SDimitry Andric       Designators.push_back(Designator::CreateArrayRangeDesignator(
127306c3fb27SDimitry Andric           Index, LBracketLoc, EllipsisLoc, RBracketLoc));
12740b57cec5SDimitry Andric       break;
12750b57cec5SDimitry Andric     }
12760b57cec5SDimitry Andric     }
12770b57cec5SDimitry Andric   }
12780b57cec5SDimitry Andric   E->setDesignators(Record.getContext(),
12790b57cec5SDimitry Andric                     Designators.data(), Designators.size());
12800b57cec5SDimitry Andric }
12810b57cec5SDimitry Andric 
12820b57cec5SDimitry Andric void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
12830b57cec5SDimitry Andric   VisitExpr(E);
12840b57cec5SDimitry Andric   E->setBase(Record.readSubExpr());
12850b57cec5SDimitry Andric   E->setUpdater(Record.readSubExpr());
12860b57cec5SDimitry Andric }
12870b57cec5SDimitry Andric 
12880b57cec5SDimitry Andric void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
12890b57cec5SDimitry Andric   VisitExpr(E);
12900b57cec5SDimitry Andric }
12910b57cec5SDimitry Andric 
12920b57cec5SDimitry Andric void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
12930b57cec5SDimitry Andric   VisitExpr(E);
12940b57cec5SDimitry Andric   E->SubExprs[0] = Record.readSubExpr();
12950b57cec5SDimitry Andric   E->SubExprs[1] = Record.readSubExpr();
12960b57cec5SDimitry Andric }
12970b57cec5SDimitry Andric 
12980b57cec5SDimitry Andric void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
12990b57cec5SDimitry Andric   VisitExpr(E);
13000b57cec5SDimitry Andric }
13010b57cec5SDimitry Andric 
13020b57cec5SDimitry Andric void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
13030b57cec5SDimitry Andric   VisitExpr(E);
13040b57cec5SDimitry Andric }
13050b57cec5SDimitry Andric 
13060b57cec5SDimitry Andric void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
13070b57cec5SDimitry Andric   VisitExpr(E);
13080b57cec5SDimitry Andric   E->setSubExpr(Record.readSubExpr());
1309480093f4SDimitry Andric   E->setWrittenTypeInfo(readTypeSourceInfo());
1310480093f4SDimitry Andric   E->setBuiltinLoc(readSourceLocation());
1311480093f4SDimitry Andric   E->setRParenLoc(readSourceLocation());
13120b57cec5SDimitry Andric   E->setIsMicrosoftABI(Record.readInt());
13130b57cec5SDimitry Andric }
13140b57cec5SDimitry Andric 
13150b57cec5SDimitry Andric void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
13160b57cec5SDimitry Andric   VisitExpr(E);
1317480093f4SDimitry Andric   E->ParentContext = readDeclAs<DeclContext>();
1318480093f4SDimitry Andric   E->BuiltinLoc = readSourceLocation();
1319480093f4SDimitry Andric   E->RParenLoc = readSourceLocation();
13205f757f3fSDimitry Andric   E->SourceLocExprBits.Kind = Record.readInt();
13210b57cec5SDimitry Andric }
13220b57cec5SDimitry Andric 
1323*0fca6ea1SDimitry Andric void ASTStmtReader::VisitEmbedExpr(EmbedExpr *E) {
1324*0fca6ea1SDimitry Andric   VisitExpr(E);
1325*0fca6ea1SDimitry Andric   E->EmbedKeywordLoc = readSourceLocation();
1326*0fca6ea1SDimitry Andric   EmbedDataStorage *Data = new (Record.getContext()) EmbedDataStorage;
1327*0fca6ea1SDimitry Andric   Data->BinaryData = cast<StringLiteral>(Record.readSubStmt());
1328*0fca6ea1SDimitry Andric   E->Data = Data;
1329*0fca6ea1SDimitry Andric   E->Begin = Record.readInt();
1330*0fca6ea1SDimitry Andric   E->NumOfElements = Record.readInt();
1331*0fca6ea1SDimitry Andric }
1332*0fca6ea1SDimitry Andric 
13330b57cec5SDimitry Andric void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
13340b57cec5SDimitry Andric   VisitExpr(E);
1335480093f4SDimitry Andric   E->setAmpAmpLoc(readSourceLocation());
1336480093f4SDimitry Andric   E->setLabelLoc(readSourceLocation());
1337480093f4SDimitry Andric   E->setLabel(readDeclAs<LabelDecl>());
13380b57cec5SDimitry Andric }
13390b57cec5SDimitry Andric 
13400b57cec5SDimitry Andric void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
13410b57cec5SDimitry Andric   VisitExpr(E);
1342480093f4SDimitry Andric   E->setLParenLoc(readSourceLocation());
1343480093f4SDimitry Andric   E->setRParenLoc(readSourceLocation());
13440b57cec5SDimitry Andric   E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
1345cd675bb6SDimitry Andric   E->StmtExprBits.TemplateDepth = Record.readInt();
13460b57cec5SDimitry Andric }
13470b57cec5SDimitry Andric 
13480b57cec5SDimitry Andric void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
13490b57cec5SDimitry Andric   VisitExpr(E);
13500b57cec5SDimitry Andric   E->setCond(Record.readSubExpr());
13510b57cec5SDimitry Andric   E->setLHS(Record.readSubExpr());
13520b57cec5SDimitry Andric   E->setRHS(Record.readSubExpr());
1353480093f4SDimitry Andric   E->setBuiltinLoc(readSourceLocation());
1354480093f4SDimitry Andric   E->setRParenLoc(readSourceLocation());
13550b57cec5SDimitry Andric   E->setIsConditionTrue(Record.readInt());
13560b57cec5SDimitry Andric }
13570b57cec5SDimitry Andric 
13580b57cec5SDimitry Andric void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
13590b57cec5SDimitry Andric   VisitExpr(E);
1360480093f4SDimitry Andric   E->setTokenLocation(readSourceLocation());
13610b57cec5SDimitry Andric }
13620b57cec5SDimitry Andric 
13630b57cec5SDimitry Andric void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
13640b57cec5SDimitry Andric   VisitExpr(E);
13650b57cec5SDimitry Andric   SmallVector<Expr *, 16> Exprs;
13660b57cec5SDimitry Andric   unsigned NumExprs = Record.readInt();
13670b57cec5SDimitry Andric   while (NumExprs--)
13680b57cec5SDimitry Andric     Exprs.push_back(Record.readSubExpr());
13690b57cec5SDimitry Andric   E->setExprs(Record.getContext(), Exprs);
1370480093f4SDimitry Andric   E->setBuiltinLoc(readSourceLocation());
1371480093f4SDimitry Andric   E->setRParenLoc(readSourceLocation());
13720b57cec5SDimitry Andric }
13730b57cec5SDimitry Andric 
13740b57cec5SDimitry Andric void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
13750b57cec5SDimitry Andric   VisitExpr(E);
1376480093f4SDimitry Andric   E->BuiltinLoc = readSourceLocation();
1377480093f4SDimitry Andric   E->RParenLoc = readSourceLocation();
1378480093f4SDimitry Andric   E->TInfo = readTypeSourceInfo();
13790b57cec5SDimitry Andric   E->SrcExpr = Record.readSubExpr();
13800b57cec5SDimitry Andric }
13810b57cec5SDimitry Andric 
13820b57cec5SDimitry Andric void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
13830b57cec5SDimitry Andric   VisitExpr(E);
1384480093f4SDimitry Andric   E->setBlockDecl(readDeclAs<BlockDecl>());
13850b57cec5SDimitry Andric }
13860b57cec5SDimitry Andric 
13870b57cec5SDimitry Andric void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
13880b57cec5SDimitry Andric   VisitExpr(E);
13890b57cec5SDimitry Andric 
13900b57cec5SDimitry Andric   unsigned NumAssocs = Record.readInt();
13910b57cec5SDimitry Andric   assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
139206c3fb27SDimitry Andric   E->IsExprPredicate = Record.readInt();
13930b57cec5SDimitry Andric   E->ResultIndex = Record.readInt();
1394480093f4SDimitry Andric   E->GenericSelectionExprBits.GenericLoc = readSourceLocation();
1395480093f4SDimitry Andric   E->DefaultLoc = readSourceLocation();
1396480093f4SDimitry Andric   E->RParenLoc = readSourceLocation();
13970b57cec5SDimitry Andric 
13980b57cec5SDimitry Andric   Stmt **Stmts = E->getTrailingObjects<Stmt *>();
13990b57cec5SDimitry Andric   // Add 1 to account for the controlling expression which is the first
14000b57cec5SDimitry Andric   // expression in the trailing array of Stmt *. This is not needed for
14010b57cec5SDimitry Andric   // the trailing array of TypeSourceInfo *.
14020b57cec5SDimitry Andric   for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
14030b57cec5SDimitry Andric     Stmts[I] = Record.readSubExpr();
14040b57cec5SDimitry Andric 
14050b57cec5SDimitry Andric   TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
14060b57cec5SDimitry Andric   for (unsigned I = 0, N = NumAssocs; I < N; ++I)
1407480093f4SDimitry Andric     TSIs[I] = readTypeSourceInfo();
14080b57cec5SDimitry Andric }
14090b57cec5SDimitry Andric 
14100b57cec5SDimitry Andric void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
14110b57cec5SDimitry Andric   VisitExpr(E);
14120b57cec5SDimitry Andric   unsigned numSemanticExprs = Record.readInt();
14130b57cec5SDimitry Andric   assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
14140b57cec5SDimitry Andric   E->PseudoObjectExprBits.ResultIndex = Record.readInt();
14150b57cec5SDimitry Andric 
14160b57cec5SDimitry Andric   // Read the syntactic expression.
14170b57cec5SDimitry Andric   E->getSubExprsBuffer()[0] = Record.readSubExpr();
14180b57cec5SDimitry Andric 
14190b57cec5SDimitry Andric   // Read all the semantic expressions.
14200b57cec5SDimitry Andric   for (unsigned i = 0; i != numSemanticExprs; ++i) {
14210b57cec5SDimitry Andric     Expr *subExpr = Record.readSubExpr();
14220b57cec5SDimitry Andric     E->getSubExprsBuffer()[i+1] = subExpr;
14230b57cec5SDimitry Andric   }
14240b57cec5SDimitry Andric }
14250b57cec5SDimitry Andric 
14260b57cec5SDimitry Andric void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
14270b57cec5SDimitry Andric   VisitExpr(E);
14280b57cec5SDimitry Andric   E->Op = AtomicExpr::AtomicOp(Record.readInt());
14290b57cec5SDimitry Andric   E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
14300b57cec5SDimitry Andric   for (unsigned I = 0; I != E->NumSubExprs; ++I)
14310b57cec5SDimitry Andric     E->SubExprs[I] = Record.readSubExpr();
1432480093f4SDimitry Andric   E->BuiltinLoc = readSourceLocation();
1433480093f4SDimitry Andric   E->RParenLoc = readSourceLocation();
14340b57cec5SDimitry Andric }
14350b57cec5SDimitry Andric 
14360b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
14370b57cec5SDimitry Andric // Objective-C Expressions and Statements
14380b57cec5SDimitry Andric 
14390b57cec5SDimitry Andric void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
14400b57cec5SDimitry Andric   VisitExpr(E);
14410b57cec5SDimitry Andric   E->setString(cast<StringLiteral>(Record.readSubStmt()));
1442480093f4SDimitry Andric   E->setAtLoc(readSourceLocation());
14430b57cec5SDimitry Andric }
14440b57cec5SDimitry Andric 
14450b57cec5SDimitry Andric void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
14460b57cec5SDimitry Andric   VisitExpr(E);
14470b57cec5SDimitry Andric   // could be one of several IntegerLiteral, FloatLiteral, etc.
14480b57cec5SDimitry Andric   E->SubExpr = Record.readSubStmt();
1449480093f4SDimitry Andric   E->BoxingMethod = readDeclAs<ObjCMethodDecl>();
1450480093f4SDimitry Andric   E->Range = readSourceRange();
14510b57cec5SDimitry Andric }
14520b57cec5SDimitry Andric 
14530b57cec5SDimitry Andric void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
14540b57cec5SDimitry Andric   VisitExpr(E);
14550b57cec5SDimitry Andric   unsigned NumElements = Record.readInt();
14560b57cec5SDimitry Andric   assert(NumElements == E->getNumElements() && "Wrong number of elements");
14570b57cec5SDimitry Andric   Expr **Elements = E->getElements();
14580b57cec5SDimitry Andric   for (unsigned I = 0, N = NumElements; I != N; ++I)
14590b57cec5SDimitry Andric     Elements[I] = Record.readSubExpr();
1460480093f4SDimitry Andric   E->ArrayWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1461480093f4SDimitry Andric   E->Range = readSourceRange();
14620b57cec5SDimitry Andric }
14630b57cec5SDimitry Andric 
14640b57cec5SDimitry Andric void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
14650b57cec5SDimitry Andric   VisitExpr(E);
14660b57cec5SDimitry Andric   unsigned NumElements = Record.readInt();
14670b57cec5SDimitry Andric   assert(NumElements == E->getNumElements() && "Wrong number of elements");
14680b57cec5SDimitry Andric   bool HasPackExpansions = Record.readInt();
14690b57cec5SDimitry Andric   assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
14700b57cec5SDimitry Andric   auto *KeyValues =
14710b57cec5SDimitry Andric       E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
14720b57cec5SDimitry Andric   auto *Expansions =
14730b57cec5SDimitry Andric       E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
14740b57cec5SDimitry Andric   for (unsigned I = 0; I != NumElements; ++I) {
14750b57cec5SDimitry Andric     KeyValues[I].Key = Record.readSubExpr();
14760b57cec5SDimitry Andric     KeyValues[I].Value = Record.readSubExpr();
14770b57cec5SDimitry Andric     if (HasPackExpansions) {
1478480093f4SDimitry Andric       Expansions[I].EllipsisLoc = readSourceLocation();
14790b57cec5SDimitry Andric       Expansions[I].NumExpansionsPlusOne = Record.readInt();
14800b57cec5SDimitry Andric     }
14810b57cec5SDimitry Andric   }
1482480093f4SDimitry Andric   E->DictWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1483480093f4SDimitry Andric   E->Range = readSourceRange();
14840b57cec5SDimitry Andric }
14850b57cec5SDimitry Andric 
14860b57cec5SDimitry Andric void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
14870b57cec5SDimitry Andric   VisitExpr(E);
1488480093f4SDimitry Andric   E->setEncodedTypeSourceInfo(readTypeSourceInfo());
1489480093f4SDimitry Andric   E->setAtLoc(readSourceLocation());
1490480093f4SDimitry Andric   E->setRParenLoc(readSourceLocation());
14910b57cec5SDimitry Andric }
14920b57cec5SDimitry Andric 
14930b57cec5SDimitry Andric void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
14940b57cec5SDimitry Andric   VisitExpr(E);
14950b57cec5SDimitry Andric   E->setSelector(Record.readSelector());
1496480093f4SDimitry Andric   E->setAtLoc(readSourceLocation());
1497480093f4SDimitry Andric   E->setRParenLoc(readSourceLocation());
14980b57cec5SDimitry Andric }
14990b57cec5SDimitry Andric 
15000b57cec5SDimitry Andric void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
15010b57cec5SDimitry Andric   VisitExpr(E);
1502480093f4SDimitry Andric   E->setProtocol(readDeclAs<ObjCProtocolDecl>());
1503480093f4SDimitry Andric   E->setAtLoc(readSourceLocation());
1504480093f4SDimitry Andric   E->ProtoLoc = readSourceLocation();
1505480093f4SDimitry Andric   E->setRParenLoc(readSourceLocation());
15060b57cec5SDimitry Andric }
15070b57cec5SDimitry Andric 
15080b57cec5SDimitry Andric void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
15090b57cec5SDimitry Andric   VisitExpr(E);
1510480093f4SDimitry Andric   E->setDecl(readDeclAs<ObjCIvarDecl>());
1511480093f4SDimitry Andric   E->setLocation(readSourceLocation());
1512480093f4SDimitry Andric   E->setOpLoc(readSourceLocation());
15130b57cec5SDimitry Andric   E->setBase(Record.readSubExpr());
15140b57cec5SDimitry Andric   E->setIsArrow(Record.readInt());
15150b57cec5SDimitry Andric   E->setIsFreeIvar(Record.readInt());
15160b57cec5SDimitry Andric }
15170b57cec5SDimitry Andric 
15180b57cec5SDimitry Andric void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
15190b57cec5SDimitry Andric   VisitExpr(E);
15200b57cec5SDimitry Andric   unsigned MethodRefFlags = Record.readInt();
15210b57cec5SDimitry Andric   bool Implicit = Record.readInt() != 0;
15220b57cec5SDimitry Andric   if (Implicit) {
1523480093f4SDimitry Andric     auto *Getter = readDeclAs<ObjCMethodDecl>();
1524480093f4SDimitry Andric     auto *Setter = readDeclAs<ObjCMethodDecl>();
15250b57cec5SDimitry Andric     E->setImplicitProperty(Getter, Setter, MethodRefFlags);
15260b57cec5SDimitry Andric   } else {
1527480093f4SDimitry Andric     E->setExplicitProperty(readDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
15280b57cec5SDimitry Andric   }
1529480093f4SDimitry Andric   E->setLocation(readSourceLocation());
1530480093f4SDimitry Andric   E->setReceiverLocation(readSourceLocation());
15310b57cec5SDimitry Andric   switch (Record.readInt()) {
15320b57cec5SDimitry Andric   case 0:
15330b57cec5SDimitry Andric     E->setBase(Record.readSubExpr());
15340b57cec5SDimitry Andric     break;
15350b57cec5SDimitry Andric   case 1:
15360b57cec5SDimitry Andric     E->setSuperReceiver(Record.readType());
15370b57cec5SDimitry Andric     break;
15380b57cec5SDimitry Andric   case 2:
1539480093f4SDimitry Andric     E->setClassReceiver(readDeclAs<ObjCInterfaceDecl>());
15400b57cec5SDimitry Andric     break;
15410b57cec5SDimitry Andric   }
15420b57cec5SDimitry Andric }
15430b57cec5SDimitry Andric 
15440b57cec5SDimitry Andric void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
15450b57cec5SDimitry Andric   VisitExpr(E);
1546480093f4SDimitry Andric   E->setRBracket(readSourceLocation());
15470b57cec5SDimitry Andric   E->setBaseExpr(Record.readSubExpr());
15480b57cec5SDimitry Andric   E->setKeyExpr(Record.readSubExpr());
1549480093f4SDimitry Andric   E->GetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1550480093f4SDimitry Andric   E->SetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
15510b57cec5SDimitry Andric }
15520b57cec5SDimitry Andric 
15530b57cec5SDimitry Andric void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
15540b57cec5SDimitry Andric   VisitExpr(E);
15550b57cec5SDimitry Andric   assert(Record.peekInt() == E->getNumArgs());
15560b57cec5SDimitry Andric   Record.skipInts(1);
15570b57cec5SDimitry Andric   unsigned NumStoredSelLocs = Record.readInt();
15580b57cec5SDimitry Andric   E->SelLocsKind = Record.readInt();
15590b57cec5SDimitry Andric   E->setDelegateInitCall(Record.readInt());
15600b57cec5SDimitry Andric   E->IsImplicit = Record.readInt();
15610b57cec5SDimitry Andric   auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
15620b57cec5SDimitry Andric   switch (Kind) {
15630b57cec5SDimitry Andric   case ObjCMessageExpr::Instance:
15640b57cec5SDimitry Andric     E->setInstanceReceiver(Record.readSubExpr());
15650b57cec5SDimitry Andric     break;
15660b57cec5SDimitry Andric 
15670b57cec5SDimitry Andric   case ObjCMessageExpr::Class:
1568480093f4SDimitry Andric     E->setClassReceiver(readTypeSourceInfo());
15690b57cec5SDimitry Andric     break;
15700b57cec5SDimitry Andric 
15710b57cec5SDimitry Andric   case ObjCMessageExpr::SuperClass:
15720b57cec5SDimitry Andric   case ObjCMessageExpr::SuperInstance: {
15730b57cec5SDimitry Andric     QualType T = Record.readType();
1574480093f4SDimitry Andric     SourceLocation SuperLoc = readSourceLocation();
15750b57cec5SDimitry Andric     E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
15760b57cec5SDimitry Andric     break;
15770b57cec5SDimitry Andric   }
15780b57cec5SDimitry Andric   }
15790b57cec5SDimitry Andric 
15800b57cec5SDimitry Andric   assert(Kind == E->getReceiverKind());
15810b57cec5SDimitry Andric 
15820b57cec5SDimitry Andric   if (Record.readInt())
1583480093f4SDimitry Andric     E->setMethodDecl(readDeclAs<ObjCMethodDecl>());
15840b57cec5SDimitry Andric   else
15850b57cec5SDimitry Andric     E->setSelector(Record.readSelector());
15860b57cec5SDimitry Andric 
1587480093f4SDimitry Andric   E->LBracLoc = readSourceLocation();
1588480093f4SDimitry Andric   E->RBracLoc = readSourceLocation();
15890b57cec5SDimitry Andric 
15900b57cec5SDimitry Andric   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
15910b57cec5SDimitry Andric     E->setArg(I, Record.readSubExpr());
15920b57cec5SDimitry Andric 
15930b57cec5SDimitry Andric   SourceLocation *Locs = E->getStoredSelLocs();
15940b57cec5SDimitry Andric   for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1595480093f4SDimitry Andric     Locs[I] = readSourceLocation();
15960b57cec5SDimitry Andric }
15970b57cec5SDimitry Andric 
15980b57cec5SDimitry Andric void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
15990b57cec5SDimitry Andric   VisitStmt(S);
16000b57cec5SDimitry Andric   S->setElement(Record.readSubStmt());
16010b57cec5SDimitry Andric   S->setCollection(Record.readSubExpr());
16020b57cec5SDimitry Andric   S->setBody(Record.readSubStmt());
1603480093f4SDimitry Andric   S->setForLoc(readSourceLocation());
1604480093f4SDimitry Andric   S->setRParenLoc(readSourceLocation());
16050b57cec5SDimitry Andric }
16060b57cec5SDimitry Andric 
16070b57cec5SDimitry Andric void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
16080b57cec5SDimitry Andric   VisitStmt(S);
16090b57cec5SDimitry Andric   S->setCatchBody(Record.readSubStmt());
1610480093f4SDimitry Andric   S->setCatchParamDecl(readDeclAs<VarDecl>());
1611480093f4SDimitry Andric   S->setAtCatchLoc(readSourceLocation());
1612480093f4SDimitry Andric   S->setRParenLoc(readSourceLocation());
16130b57cec5SDimitry Andric }
16140b57cec5SDimitry Andric 
16150b57cec5SDimitry Andric void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
16160b57cec5SDimitry Andric   VisitStmt(S);
16170b57cec5SDimitry Andric   S->setFinallyBody(Record.readSubStmt());
1618480093f4SDimitry Andric   S->setAtFinallyLoc(readSourceLocation());
16190b57cec5SDimitry Andric }
16200b57cec5SDimitry Andric 
16210b57cec5SDimitry Andric void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
16220b57cec5SDimitry Andric   VisitStmt(S); // FIXME: no test coverage.
16230b57cec5SDimitry Andric   S->setSubStmt(Record.readSubStmt());
1624480093f4SDimitry Andric   S->setAtLoc(readSourceLocation());
16250b57cec5SDimitry Andric }
16260b57cec5SDimitry Andric 
16270b57cec5SDimitry Andric void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
16280b57cec5SDimitry Andric   VisitStmt(S);
16290b57cec5SDimitry Andric   assert(Record.peekInt() == S->getNumCatchStmts());
16300b57cec5SDimitry Andric   Record.skipInts(1);
16310b57cec5SDimitry Andric   bool HasFinally = Record.readInt();
16320b57cec5SDimitry Andric   S->setTryBody(Record.readSubStmt());
16330b57cec5SDimitry Andric   for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
16340b57cec5SDimitry Andric     S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
16350b57cec5SDimitry Andric 
16360b57cec5SDimitry Andric   if (HasFinally)
16370b57cec5SDimitry Andric     S->setFinallyStmt(Record.readSubStmt());
1638480093f4SDimitry Andric   S->setAtTryLoc(readSourceLocation());
16390b57cec5SDimitry Andric }
16400b57cec5SDimitry Andric 
16410b57cec5SDimitry Andric void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
16420b57cec5SDimitry Andric   VisitStmt(S); // FIXME: no test coverage.
16430b57cec5SDimitry Andric   S->setSynchExpr(Record.readSubStmt());
16440b57cec5SDimitry Andric   S->setSynchBody(Record.readSubStmt());
1645480093f4SDimitry Andric   S->setAtSynchronizedLoc(readSourceLocation());
16460b57cec5SDimitry Andric }
16470b57cec5SDimitry Andric 
16480b57cec5SDimitry Andric void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
16490b57cec5SDimitry Andric   VisitStmt(S); // FIXME: no test coverage.
16500b57cec5SDimitry Andric   S->setThrowExpr(Record.readSubStmt());
1651480093f4SDimitry Andric   S->setThrowLoc(readSourceLocation());
16520b57cec5SDimitry Andric }
16530b57cec5SDimitry Andric 
16540b57cec5SDimitry Andric void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
16550b57cec5SDimitry Andric   VisitExpr(E);
16560b57cec5SDimitry Andric   E->setValue(Record.readInt());
1657480093f4SDimitry Andric   E->setLocation(readSourceLocation());
16580b57cec5SDimitry Andric }
16590b57cec5SDimitry Andric 
16600b57cec5SDimitry Andric void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
16610b57cec5SDimitry Andric   VisitExpr(E);
16620b57cec5SDimitry Andric   SourceRange R = Record.readSourceRange();
16630b57cec5SDimitry Andric   E->AtLoc = R.getBegin();
16640b57cec5SDimitry Andric   E->RParen = R.getEnd();
16650b57cec5SDimitry Andric   E->VersionToCheck = Record.readVersionTuple();
16660b57cec5SDimitry Andric }
16670b57cec5SDimitry Andric 
16680b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
16690b57cec5SDimitry Andric // C++ Expressions and Statements
16700b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
16710b57cec5SDimitry Andric 
16720b57cec5SDimitry Andric void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
16730b57cec5SDimitry Andric   VisitStmt(S);
1674480093f4SDimitry Andric   S->CatchLoc = readSourceLocation();
1675480093f4SDimitry Andric   S->ExceptionDecl = readDeclAs<VarDecl>();
16760b57cec5SDimitry Andric   S->HandlerBlock = Record.readSubStmt();
16770b57cec5SDimitry Andric }
16780b57cec5SDimitry Andric 
16790b57cec5SDimitry Andric void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
16800b57cec5SDimitry Andric   VisitStmt(S);
16810b57cec5SDimitry Andric   assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
16820b57cec5SDimitry Andric   Record.skipInts(1);
1683480093f4SDimitry Andric   S->TryLoc = readSourceLocation();
16840b57cec5SDimitry Andric   S->getStmts()[0] = Record.readSubStmt();
16850b57cec5SDimitry Andric   for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
16860b57cec5SDimitry Andric     S->getStmts()[i + 1] = Record.readSubStmt();
16870b57cec5SDimitry Andric }
16880b57cec5SDimitry Andric 
16890b57cec5SDimitry Andric void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
16900b57cec5SDimitry Andric   VisitStmt(S);
1691480093f4SDimitry Andric   S->ForLoc = readSourceLocation();
1692480093f4SDimitry Andric   S->CoawaitLoc = readSourceLocation();
1693480093f4SDimitry Andric   S->ColonLoc = readSourceLocation();
1694480093f4SDimitry Andric   S->RParenLoc = readSourceLocation();
16950b57cec5SDimitry Andric   S->setInit(Record.readSubStmt());
16960b57cec5SDimitry Andric   S->setRangeStmt(Record.readSubStmt());
16970b57cec5SDimitry Andric   S->setBeginStmt(Record.readSubStmt());
16980b57cec5SDimitry Andric   S->setEndStmt(Record.readSubStmt());
16990b57cec5SDimitry Andric   S->setCond(Record.readSubExpr());
17000b57cec5SDimitry Andric   S->setInc(Record.readSubExpr());
17010b57cec5SDimitry Andric   S->setLoopVarStmt(Record.readSubStmt());
17020b57cec5SDimitry Andric   S->setBody(Record.readSubStmt());
17030b57cec5SDimitry Andric }
17040b57cec5SDimitry Andric 
17050b57cec5SDimitry Andric void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
17060b57cec5SDimitry Andric   VisitStmt(S);
1707480093f4SDimitry Andric   S->KeywordLoc = readSourceLocation();
17080b57cec5SDimitry Andric   S->IsIfExists = Record.readInt();
17090b57cec5SDimitry Andric   S->QualifierLoc = Record.readNestedNameSpecifierLoc();
1710480093f4SDimitry Andric   S->NameInfo = Record.readDeclarationNameInfo();
17110b57cec5SDimitry Andric   S->SubStmt = Record.readSubStmt();
17120b57cec5SDimitry Andric }
17130b57cec5SDimitry Andric 
17140b57cec5SDimitry Andric void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
17150b57cec5SDimitry Andric   VisitCallExpr(E);
17160b57cec5SDimitry Andric   E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
17170b57cec5SDimitry Andric   E->Range = Record.readSourceRange();
17180b57cec5SDimitry Andric }
17190b57cec5SDimitry Andric 
1720a7dea167SDimitry Andric void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1721a7dea167SDimitry Andric     CXXRewrittenBinaryOperator *E) {
1722a7dea167SDimitry Andric   VisitExpr(E);
1723a7dea167SDimitry Andric   E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1724a7dea167SDimitry Andric   E->SemanticForm = Record.readSubExpr();
1725a7dea167SDimitry Andric }
1726a7dea167SDimitry Andric 
17270b57cec5SDimitry Andric void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
17280b57cec5SDimitry Andric   VisitExpr(E);
17290b57cec5SDimitry Andric 
17300b57cec5SDimitry Andric   unsigned NumArgs = Record.readInt();
17310b57cec5SDimitry Andric   assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
17320b57cec5SDimitry Andric 
17330b57cec5SDimitry Andric   E->CXXConstructExprBits.Elidable = Record.readInt();
17340b57cec5SDimitry Andric   E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
17350b57cec5SDimitry Andric   E->CXXConstructExprBits.ListInitialization = Record.readInt();
17360b57cec5SDimitry Andric   E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
17370b57cec5SDimitry Andric   E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
17380b57cec5SDimitry Andric   E->CXXConstructExprBits.ConstructionKind = Record.readInt();
173906c3fb27SDimitry Andric   E->CXXConstructExprBits.IsImmediateEscalating = Record.readInt();
1740480093f4SDimitry Andric   E->CXXConstructExprBits.Loc = readSourceLocation();
1741480093f4SDimitry Andric   E->Constructor = readDeclAs<CXXConstructorDecl>();
1742480093f4SDimitry Andric   E->ParenOrBraceRange = readSourceRange();
17430b57cec5SDimitry Andric 
17440b57cec5SDimitry Andric   for (unsigned I = 0; I != NumArgs; ++I)
17450b57cec5SDimitry Andric     E->setArg(I, Record.readSubExpr());
17460b57cec5SDimitry Andric }
17470b57cec5SDimitry Andric 
17480b57cec5SDimitry Andric void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
17490b57cec5SDimitry Andric   VisitExpr(E);
1750480093f4SDimitry Andric   E->Constructor = readDeclAs<CXXConstructorDecl>();
1751480093f4SDimitry Andric   E->Loc = readSourceLocation();
17520b57cec5SDimitry Andric   E->ConstructsVirtualBase = Record.readInt();
17530b57cec5SDimitry Andric   E->InheritedFromVirtualBase = Record.readInt();
17540b57cec5SDimitry Andric }
17550b57cec5SDimitry Andric 
17560b57cec5SDimitry Andric void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
17570b57cec5SDimitry Andric   VisitCXXConstructExpr(E);
1758480093f4SDimitry Andric   E->TSI = readTypeSourceInfo();
17590b57cec5SDimitry Andric }
17600b57cec5SDimitry Andric 
17610b57cec5SDimitry Andric void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
17620b57cec5SDimitry Andric   VisitExpr(E);
17630b57cec5SDimitry Andric   unsigned NumCaptures = Record.readInt();
17645ffd83dbSDimitry Andric   (void)NumCaptures;
17655ffd83dbSDimitry Andric   assert(NumCaptures == E->LambdaExprBits.NumCaptures);
1766480093f4SDimitry Andric   E->IntroducerRange = readSourceRange();
17675ffd83dbSDimitry Andric   E->LambdaExprBits.CaptureDefault = Record.readInt();
1768480093f4SDimitry Andric   E->CaptureDefaultLoc = readSourceLocation();
17695ffd83dbSDimitry Andric   E->LambdaExprBits.ExplicitParams = Record.readInt();
17705ffd83dbSDimitry Andric   E->LambdaExprBits.ExplicitResultType = Record.readInt();
1771480093f4SDimitry Andric   E->ClosingBrace = readSourceLocation();
17720b57cec5SDimitry Andric 
17730b57cec5SDimitry Andric   // Read capture initializers.
17740b57cec5SDimitry Andric   for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
17750b57cec5SDimitry Andric                                          CEnd = E->capture_init_end();
17760b57cec5SDimitry Andric        C != CEnd; ++C)
17770b57cec5SDimitry Andric     *C = Record.readSubExpr();
17785ffd83dbSDimitry Andric 
17795ffd83dbSDimitry Andric   // The body will be lazily deserialized when needed from the call operator
17805ffd83dbSDimitry Andric   // declaration.
17810b57cec5SDimitry Andric }
17820b57cec5SDimitry Andric 
17830b57cec5SDimitry Andric void
17840b57cec5SDimitry Andric ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
17850b57cec5SDimitry Andric   VisitExpr(E);
17860b57cec5SDimitry Andric   E->SubExpr = Record.readSubExpr();
17870b57cec5SDimitry Andric }
17880b57cec5SDimitry Andric 
17890b57cec5SDimitry Andric void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
17900b57cec5SDimitry Andric   VisitExplicitCastExpr(E);
1791480093f4SDimitry Andric   SourceRange R = readSourceRange();
17920b57cec5SDimitry Andric   E->Loc = R.getBegin();
17930b57cec5SDimitry Andric   E->RParenLoc = R.getEnd();
1794cb14a3feSDimitry Andric   if (CurrentUnpackingBits->getNextBit())
1795cb14a3feSDimitry Andric     E->AngleBrackets = readSourceRange();
17960b57cec5SDimitry Andric }
17970b57cec5SDimitry Andric 
17980b57cec5SDimitry Andric void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
17990b57cec5SDimitry Andric   return VisitCXXNamedCastExpr(E);
18000b57cec5SDimitry Andric }
18010b57cec5SDimitry Andric 
18020b57cec5SDimitry Andric void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
18030b57cec5SDimitry Andric   return VisitCXXNamedCastExpr(E);
18040b57cec5SDimitry Andric }
18050b57cec5SDimitry Andric 
18060b57cec5SDimitry Andric void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
18070b57cec5SDimitry Andric   return VisitCXXNamedCastExpr(E);
18080b57cec5SDimitry Andric }
18090b57cec5SDimitry Andric 
18105ffd83dbSDimitry Andric void ASTStmtReader::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *E) {
18115ffd83dbSDimitry Andric   return VisitCXXNamedCastExpr(E);
18125ffd83dbSDimitry Andric }
18135ffd83dbSDimitry Andric 
18140b57cec5SDimitry Andric void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
18150b57cec5SDimitry Andric   return VisitCXXNamedCastExpr(E);
18160b57cec5SDimitry Andric }
18170b57cec5SDimitry Andric 
18180b57cec5SDimitry Andric void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
18190b57cec5SDimitry Andric   VisitExplicitCastExpr(E);
1820480093f4SDimitry Andric   E->setLParenLoc(readSourceLocation());
1821480093f4SDimitry Andric   E->setRParenLoc(readSourceLocation());
18220b57cec5SDimitry Andric }
18230b57cec5SDimitry Andric 
18240b57cec5SDimitry Andric void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
18250b57cec5SDimitry Andric   VisitExplicitCastExpr(E);
1826480093f4SDimitry Andric   E->KWLoc = readSourceLocation();
1827480093f4SDimitry Andric   E->RParenLoc = readSourceLocation();
18280b57cec5SDimitry Andric }
18290b57cec5SDimitry Andric 
18300b57cec5SDimitry Andric void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
18310b57cec5SDimitry Andric   VisitCallExpr(E);
1832480093f4SDimitry Andric   E->UDSuffixLoc = readSourceLocation();
18330b57cec5SDimitry Andric }
18340b57cec5SDimitry Andric 
18350b57cec5SDimitry Andric void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
18360b57cec5SDimitry Andric   VisitExpr(E);
18370b57cec5SDimitry Andric   E->setValue(Record.readInt());
1838480093f4SDimitry Andric   E->setLocation(readSourceLocation());
18390b57cec5SDimitry Andric }
18400b57cec5SDimitry Andric 
18410b57cec5SDimitry Andric void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
18420b57cec5SDimitry Andric   VisitExpr(E);
1843480093f4SDimitry Andric   E->setLocation(readSourceLocation());
18440b57cec5SDimitry Andric }
18450b57cec5SDimitry Andric 
18460b57cec5SDimitry Andric void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
18470b57cec5SDimitry Andric   VisitExpr(E);
1848480093f4SDimitry Andric   E->setSourceRange(readSourceRange());
18495ffd83dbSDimitry Andric   if (E->isTypeOperand())
18505ffd83dbSDimitry Andric     E->Operand = readTypeSourceInfo();
18515ffd83dbSDimitry Andric   else
18525ffd83dbSDimitry Andric     E->Operand = Record.readSubExpr();
18530b57cec5SDimitry Andric }
18540b57cec5SDimitry Andric 
18550b57cec5SDimitry Andric void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
18560b57cec5SDimitry Andric   VisitExpr(E);
1857480093f4SDimitry Andric   E->setLocation(readSourceLocation());
18580b57cec5SDimitry Andric   E->setImplicit(Record.readInt());
1859*0fca6ea1SDimitry Andric   E->setCapturedByCopyInLambdaWithExplicitObjectParameter(Record.readInt());
18600b57cec5SDimitry Andric }
18610b57cec5SDimitry Andric 
18620b57cec5SDimitry Andric void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
18630b57cec5SDimitry Andric   VisitExpr(E);
1864480093f4SDimitry Andric   E->CXXThrowExprBits.ThrowLoc = readSourceLocation();
18650b57cec5SDimitry Andric   E->Operand = Record.readSubExpr();
18660b57cec5SDimitry Andric   E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
18670b57cec5SDimitry Andric }
18680b57cec5SDimitry Andric 
18690b57cec5SDimitry Andric void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
18700b57cec5SDimitry Andric   VisitExpr(E);
1871480093f4SDimitry Andric   E->Param = readDeclAs<ParmVarDecl>();
1872480093f4SDimitry Andric   E->UsedContext = readDeclAs<DeclContext>();
1873480093f4SDimitry Andric   E->CXXDefaultArgExprBits.Loc = readSourceLocation();
1874bdd1243dSDimitry Andric   E->CXXDefaultArgExprBits.HasRewrittenInit = Record.readInt();
1875bdd1243dSDimitry Andric   if (E->CXXDefaultArgExprBits.HasRewrittenInit)
1876bdd1243dSDimitry Andric     *E->getTrailingObjects<Expr *>() = Record.readSubExpr();
18770b57cec5SDimitry Andric }
18780b57cec5SDimitry Andric 
18790b57cec5SDimitry Andric void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
18800b57cec5SDimitry Andric   VisitExpr(E);
1881bdd1243dSDimitry Andric   E->CXXDefaultInitExprBits.HasRewrittenInit = Record.readInt();
1882480093f4SDimitry Andric   E->Field = readDeclAs<FieldDecl>();
1883480093f4SDimitry Andric   E->UsedContext = readDeclAs<DeclContext>();
1884480093f4SDimitry Andric   E->CXXDefaultInitExprBits.Loc = readSourceLocation();
1885bdd1243dSDimitry Andric   if (E->CXXDefaultInitExprBits.HasRewrittenInit)
1886bdd1243dSDimitry Andric     *E->getTrailingObjects<Expr *>() = Record.readSubExpr();
18870b57cec5SDimitry Andric }
18880b57cec5SDimitry Andric 
18890b57cec5SDimitry Andric void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
18900b57cec5SDimitry Andric   VisitExpr(E);
18910b57cec5SDimitry Andric   E->setTemporary(Record.readCXXTemporary());
18920b57cec5SDimitry Andric   E->setSubExpr(Record.readSubExpr());
18930b57cec5SDimitry Andric }
18940b57cec5SDimitry Andric 
18950b57cec5SDimitry Andric void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
18960b57cec5SDimitry Andric   VisitExpr(E);
1897480093f4SDimitry Andric   E->TypeInfo = readTypeSourceInfo();
1898480093f4SDimitry Andric   E->CXXScalarValueInitExprBits.RParenLoc = readSourceLocation();
18990b57cec5SDimitry Andric }
19000b57cec5SDimitry Andric 
19010b57cec5SDimitry Andric void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
19020b57cec5SDimitry Andric   VisitExpr(E);
19030b57cec5SDimitry Andric 
19040b57cec5SDimitry Andric   bool IsArray = Record.readInt();
19050b57cec5SDimitry Andric   bool HasInit = Record.readInt();
19060b57cec5SDimitry Andric   unsigned NumPlacementArgs = Record.readInt();
19070b57cec5SDimitry Andric   bool IsParenTypeId = Record.readInt();
19080b57cec5SDimitry Andric 
19090b57cec5SDimitry Andric   E->CXXNewExprBits.IsGlobalNew = Record.readInt();
19100b57cec5SDimitry Andric   E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
19110b57cec5SDimitry Andric   E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
19127a6dacacSDimitry Andric   E->CXXNewExprBits.HasInitializer = Record.readInt();
19130b57cec5SDimitry Andric   E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
19140b57cec5SDimitry Andric 
19150b57cec5SDimitry Andric   assert((IsArray == E->isArray()) && "Wrong IsArray!");
19160b57cec5SDimitry Andric   assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
19170b57cec5SDimitry Andric   assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
19180b57cec5SDimitry Andric          "Wrong NumPlacementArgs!");
19190b57cec5SDimitry Andric   assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
19200b57cec5SDimitry Andric   (void)IsArray;
19210b57cec5SDimitry Andric   (void)HasInit;
19220b57cec5SDimitry Andric   (void)NumPlacementArgs;
19230b57cec5SDimitry Andric 
1924480093f4SDimitry Andric   E->setOperatorNew(readDeclAs<FunctionDecl>());
1925480093f4SDimitry Andric   E->setOperatorDelete(readDeclAs<FunctionDecl>());
1926480093f4SDimitry Andric   E->AllocatedTypeInfo = readTypeSourceInfo();
19270b57cec5SDimitry Andric   if (IsParenTypeId)
1928480093f4SDimitry Andric     E->getTrailingObjects<SourceRange>()[0] = readSourceRange();
1929480093f4SDimitry Andric   E->Range = readSourceRange();
1930480093f4SDimitry Andric   E->DirectInitRange = readSourceRange();
19310b57cec5SDimitry Andric 
19320b57cec5SDimitry Andric   // Install all the subexpressions.
19330b57cec5SDimitry Andric   for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
19340b57cec5SDimitry Andric                                     N = E->raw_arg_end();
19350b57cec5SDimitry Andric        I != N; ++I)
19360b57cec5SDimitry Andric     *I = Record.readSubStmt();
19370b57cec5SDimitry Andric }
19380b57cec5SDimitry Andric 
19390b57cec5SDimitry Andric void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
19400b57cec5SDimitry Andric   VisitExpr(E);
19410b57cec5SDimitry Andric   E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
19420b57cec5SDimitry Andric   E->CXXDeleteExprBits.ArrayForm = Record.readInt();
19430b57cec5SDimitry Andric   E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
19440b57cec5SDimitry Andric   E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1945480093f4SDimitry Andric   E->OperatorDelete = readDeclAs<FunctionDecl>();
19460b57cec5SDimitry Andric   E->Argument = Record.readSubExpr();
1947480093f4SDimitry Andric   E->CXXDeleteExprBits.Loc = readSourceLocation();
19480b57cec5SDimitry Andric }
19490b57cec5SDimitry Andric 
19500b57cec5SDimitry Andric void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
19510b57cec5SDimitry Andric   VisitExpr(E);
19520b57cec5SDimitry Andric 
19530b57cec5SDimitry Andric   E->Base = Record.readSubExpr();
19540b57cec5SDimitry Andric   E->IsArrow = Record.readInt();
1955480093f4SDimitry Andric   E->OperatorLoc = readSourceLocation();
19560b57cec5SDimitry Andric   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1957480093f4SDimitry Andric   E->ScopeType = readTypeSourceInfo();
1958480093f4SDimitry Andric   E->ColonColonLoc = readSourceLocation();
1959480093f4SDimitry Andric   E->TildeLoc = readSourceLocation();
19600b57cec5SDimitry Andric 
1961480093f4SDimitry Andric   IdentifierInfo *II = Record.readIdentifier();
19620b57cec5SDimitry Andric   if (II)
1963480093f4SDimitry Andric     E->setDestroyedType(II, readSourceLocation());
19640b57cec5SDimitry Andric   else
1965480093f4SDimitry Andric     E->setDestroyedType(readTypeSourceInfo());
19660b57cec5SDimitry Andric }
19670b57cec5SDimitry Andric 
19680b57cec5SDimitry Andric void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
19690b57cec5SDimitry Andric   VisitExpr(E);
19700b57cec5SDimitry Andric 
19710b57cec5SDimitry Andric   unsigned NumObjects = Record.readInt();
19720b57cec5SDimitry Andric   assert(NumObjects == E->getNumObjects());
19735ffd83dbSDimitry Andric   for (unsigned i = 0; i != NumObjects; ++i) {
19745ffd83dbSDimitry Andric     unsigned CleanupKind = Record.readInt();
19755ffd83dbSDimitry Andric     ExprWithCleanups::CleanupObject Obj;
19765ffd83dbSDimitry Andric     if (CleanupKind == COK_Block)
19775ffd83dbSDimitry Andric       Obj = readDeclAs<BlockDecl>();
19785ffd83dbSDimitry Andric     else if (CleanupKind == COK_CompoundLiteral)
19795ffd83dbSDimitry Andric       Obj = cast<CompoundLiteralExpr>(Record.readSubExpr());
19805ffd83dbSDimitry Andric     else
19815ffd83dbSDimitry Andric       llvm_unreachable("unexpected cleanup object type");
19825ffd83dbSDimitry Andric     E->getTrailingObjects<ExprWithCleanups::CleanupObject>()[i] = Obj;
19835ffd83dbSDimitry Andric   }
19840b57cec5SDimitry Andric 
19850b57cec5SDimitry Andric   E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
19860b57cec5SDimitry Andric   E->SubExpr = Record.readSubExpr();
19870b57cec5SDimitry Andric }
19880b57cec5SDimitry Andric 
19890b57cec5SDimitry Andric void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
19900b57cec5SDimitry Andric     CXXDependentScopeMemberExpr *E) {
19910b57cec5SDimitry Andric   VisitExpr(E);
19920b57cec5SDimitry Andric 
19930b57cec5SDimitry Andric   unsigned NumTemplateArgs = Record.readInt();
1994cb14a3feSDimitry Andric   CurrentUnpackingBits.emplace(Record.readInt());
1995cb14a3feSDimitry Andric   bool HasTemplateKWAndArgsInfo = CurrentUnpackingBits->getNextBit();
1996cb14a3feSDimitry Andric   bool HasFirstQualifierFoundInScope = CurrentUnpackingBits->getNextBit();
19970b57cec5SDimitry Andric 
19980b57cec5SDimitry Andric   assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
19990b57cec5SDimitry Andric          "Wrong HasTemplateKWAndArgsInfo!");
20000b57cec5SDimitry Andric   assert(
20010b57cec5SDimitry Andric       (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
20020b57cec5SDimitry Andric       "Wrong HasFirstQualifierFoundInScope!");
20030b57cec5SDimitry Andric 
20040b57cec5SDimitry Andric   if (HasTemplateKWAndArgsInfo)
20050b57cec5SDimitry Andric     ReadTemplateKWAndArgsInfo(
20060b57cec5SDimitry Andric         *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
20070b57cec5SDimitry Andric         E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
20080b57cec5SDimitry Andric 
20090b57cec5SDimitry Andric   assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
20100b57cec5SDimitry Andric          "Wrong NumTemplateArgs!");
20110b57cec5SDimitry Andric 
2012cb14a3feSDimitry Andric   E->CXXDependentScopeMemberExprBits.IsArrow =
2013cb14a3feSDimitry Andric       CurrentUnpackingBits->getNextBit();
2014cb14a3feSDimitry Andric 
20150b57cec5SDimitry Andric   E->BaseType = Record.readType();
20160b57cec5SDimitry Andric   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
2017cb14a3feSDimitry Andric   // not ImplicitAccess
2018cb14a3feSDimitry Andric   if (CurrentUnpackingBits->getNextBit())
20190b57cec5SDimitry Andric     E->Base = Record.readSubExpr();
2020cb14a3feSDimitry Andric   else
2021cb14a3feSDimitry Andric     E->Base = nullptr;
2022cb14a3feSDimitry Andric 
2023cb14a3feSDimitry Andric   E->CXXDependentScopeMemberExprBits.OperatorLoc = readSourceLocation();
20240b57cec5SDimitry Andric 
20250b57cec5SDimitry Andric   if (HasFirstQualifierFoundInScope)
2026480093f4SDimitry Andric     *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
20270b57cec5SDimitry Andric 
2028480093f4SDimitry Andric   E->MemberNameInfo = Record.readDeclarationNameInfo();
20290b57cec5SDimitry Andric }
20300b57cec5SDimitry Andric 
20310b57cec5SDimitry Andric void
20320b57cec5SDimitry Andric ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
20330b57cec5SDimitry Andric   VisitExpr(E);
20340b57cec5SDimitry Andric 
2035cb14a3feSDimitry Andric   if (CurrentUnpackingBits->getNextBit()) // HasTemplateKWAndArgsInfo
20360b57cec5SDimitry Andric     ReadTemplateKWAndArgsInfo(
20370b57cec5SDimitry Andric         *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
20380b57cec5SDimitry Andric         E->getTrailingObjects<TemplateArgumentLoc>(),
2039cb14a3feSDimitry Andric         /*NumTemplateArgs=*/CurrentUnpackingBits->getNextBits(/*Width=*/16));
20400b57cec5SDimitry Andric 
20410b57cec5SDimitry Andric   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
2042480093f4SDimitry Andric   E->NameInfo = Record.readDeclarationNameInfo();
20430b57cec5SDimitry Andric }
20440b57cec5SDimitry Andric 
20450b57cec5SDimitry Andric void
20460b57cec5SDimitry Andric ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
20470b57cec5SDimitry Andric   VisitExpr(E);
2048e8d8bef9SDimitry Andric   assert(Record.peekInt() == E->getNumArgs() &&
20490b57cec5SDimitry Andric          "Read wrong record during creation ?");
20500b57cec5SDimitry Andric   Record.skipInts(1);
2051e8d8bef9SDimitry Andric   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
20520b57cec5SDimitry Andric     E->setArg(I, Record.readSubExpr());
205306c3fb27SDimitry Andric   E->TypeAndInitForm.setPointer(readTypeSourceInfo());
2054480093f4SDimitry Andric   E->setLParenLoc(readSourceLocation());
2055480093f4SDimitry Andric   E->setRParenLoc(readSourceLocation());
205606c3fb27SDimitry Andric   E->TypeAndInitForm.setInt(Record.readInt());
20570b57cec5SDimitry Andric }
20580b57cec5SDimitry Andric 
20590b57cec5SDimitry Andric void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
20600b57cec5SDimitry Andric   VisitExpr(E);
20610b57cec5SDimitry Andric 
2062cb14a3feSDimitry Andric   unsigned NumResults = Record.readInt();
2063cb14a3feSDimitry Andric   CurrentUnpackingBits.emplace(Record.readInt());
2064cb14a3feSDimitry Andric   bool HasTemplateKWAndArgsInfo = CurrentUnpackingBits->getNextBit();
20650b57cec5SDimitry Andric   assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
20660b57cec5SDimitry Andric   assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
20670b57cec5SDimitry Andric          "Wrong HasTemplateKWAndArgsInfo!");
20680b57cec5SDimitry Andric 
20690b57cec5SDimitry Andric   if (HasTemplateKWAndArgsInfo) {
2070cb14a3feSDimitry Andric     unsigned NumTemplateArgs = Record.readInt();
20710b57cec5SDimitry Andric     ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
20720b57cec5SDimitry Andric                               E->getTrailingTemplateArgumentLoc(),
20730b57cec5SDimitry Andric                               NumTemplateArgs);
20740b57cec5SDimitry Andric     assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
20750b57cec5SDimitry Andric            "Wrong NumTemplateArgs!");
20760b57cec5SDimitry Andric   }
20770b57cec5SDimitry Andric 
20780b57cec5SDimitry Andric   UnresolvedSet<8> Decls;
20790b57cec5SDimitry Andric   for (unsigned I = 0; I != NumResults; ++I) {
2080480093f4SDimitry Andric     auto *D = readDeclAs<NamedDecl>();
20810b57cec5SDimitry Andric     auto AS = (AccessSpecifier)Record.readInt();
20820b57cec5SDimitry Andric     Decls.addDecl(D, AS);
20830b57cec5SDimitry Andric   }
20840b57cec5SDimitry Andric 
20850b57cec5SDimitry Andric   DeclAccessPair *Results = E->getTrailingResults();
20860b57cec5SDimitry Andric   UnresolvedSetIterator Iter = Decls.begin();
20870b57cec5SDimitry Andric   for (unsigned I = 0; I != NumResults; ++I) {
20880b57cec5SDimitry Andric     Results[I] = (Iter + I).getPair();
20890b57cec5SDimitry Andric   }
20900b57cec5SDimitry Andric 
2091480093f4SDimitry Andric   E->NameInfo = Record.readDeclarationNameInfo();
20920b57cec5SDimitry Andric   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
20930b57cec5SDimitry Andric }
20940b57cec5SDimitry Andric 
20950b57cec5SDimitry Andric void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
20960b57cec5SDimitry Andric   VisitOverloadExpr(E);
2097cb14a3feSDimitry Andric   E->UnresolvedMemberExprBits.IsArrow = CurrentUnpackingBits->getNextBit();
2098cb14a3feSDimitry Andric   E->UnresolvedMemberExprBits.HasUnresolvedUsing =
2099cb14a3feSDimitry Andric       CurrentUnpackingBits->getNextBit();
2100cb14a3feSDimitry Andric 
2101cb14a3feSDimitry Andric   if (/*!isImplicitAccess=*/CurrentUnpackingBits->getNextBit())
21020b57cec5SDimitry Andric     E->Base = Record.readSubExpr();
2103cb14a3feSDimitry Andric   else
2104cb14a3feSDimitry Andric     E->Base = nullptr;
2105cb14a3feSDimitry Andric 
2106480093f4SDimitry Andric   E->OperatorLoc = readSourceLocation();
2107cb14a3feSDimitry Andric 
2108cb14a3feSDimitry Andric   E->BaseType = Record.readType();
21090b57cec5SDimitry Andric }
21100b57cec5SDimitry Andric 
21110b57cec5SDimitry Andric void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
21120b57cec5SDimitry Andric   VisitOverloadExpr(E);
2113cb14a3feSDimitry Andric   E->UnresolvedLookupExprBits.RequiresADL = CurrentUnpackingBits->getNextBit();
2114480093f4SDimitry Andric   E->NamingClass = readDeclAs<CXXRecordDecl>();
21150b57cec5SDimitry Andric }
21160b57cec5SDimitry Andric 
21170b57cec5SDimitry Andric void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
21180b57cec5SDimitry Andric   VisitExpr(E);
21190b57cec5SDimitry Andric   E->TypeTraitExprBits.NumArgs = Record.readInt();
21200b57cec5SDimitry Andric   E->TypeTraitExprBits.Kind = Record.readInt();
21210b57cec5SDimitry Andric   E->TypeTraitExprBits.Value = Record.readInt();
2122480093f4SDimitry Andric   SourceRange Range = readSourceRange();
21230b57cec5SDimitry Andric   E->Loc = Range.getBegin();
21240b57cec5SDimitry Andric   E->RParenLoc = Range.getEnd();
21250b57cec5SDimitry Andric 
21260b57cec5SDimitry Andric   auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
21270b57cec5SDimitry Andric   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
2128480093f4SDimitry Andric     Args[I] = readTypeSourceInfo();
21290b57cec5SDimitry Andric }
21300b57cec5SDimitry Andric 
21310b57cec5SDimitry Andric void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
21320b57cec5SDimitry Andric   VisitExpr(E);
21330b57cec5SDimitry Andric   E->ATT = (ArrayTypeTrait)Record.readInt();
21340b57cec5SDimitry Andric   E->Value = (unsigned int)Record.readInt();
2135480093f4SDimitry Andric   SourceRange Range = readSourceRange();
21360b57cec5SDimitry Andric   E->Loc = Range.getBegin();
21370b57cec5SDimitry Andric   E->RParen = Range.getEnd();
2138480093f4SDimitry Andric   E->QueriedType = readTypeSourceInfo();
21390b57cec5SDimitry Andric   E->Dimension = Record.readSubExpr();
21400b57cec5SDimitry Andric }
21410b57cec5SDimitry Andric 
21420b57cec5SDimitry Andric void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
21430b57cec5SDimitry Andric   VisitExpr(E);
21440b57cec5SDimitry Andric   E->ET = (ExpressionTrait)Record.readInt();
21450b57cec5SDimitry Andric   E->Value = (bool)Record.readInt();
2146480093f4SDimitry Andric   SourceRange Range = readSourceRange();
21470b57cec5SDimitry Andric   E->QueriedExpression = Record.readSubExpr();
21480b57cec5SDimitry Andric   E->Loc = Range.getBegin();
21490b57cec5SDimitry Andric   E->RParen = Range.getEnd();
21500b57cec5SDimitry Andric }
21510b57cec5SDimitry Andric 
21520b57cec5SDimitry Andric void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
21530b57cec5SDimitry Andric   VisitExpr(E);
21540b57cec5SDimitry Andric   E->CXXNoexceptExprBits.Value = Record.readInt();
2155480093f4SDimitry Andric   E->Range = readSourceRange();
21560b57cec5SDimitry Andric   E->Operand = Record.readSubExpr();
21570b57cec5SDimitry Andric }
21580b57cec5SDimitry Andric 
21590b57cec5SDimitry Andric void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
21600b57cec5SDimitry Andric   VisitExpr(E);
2161480093f4SDimitry Andric   E->EllipsisLoc = readSourceLocation();
21620b57cec5SDimitry Andric   E->NumExpansions = Record.readInt();
21630b57cec5SDimitry Andric   E->Pattern = Record.readSubExpr();
21640b57cec5SDimitry Andric }
21650b57cec5SDimitry Andric 
21660b57cec5SDimitry Andric void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
21670b57cec5SDimitry Andric   VisitExpr(E);
21680b57cec5SDimitry Andric   unsigned NumPartialArgs = Record.readInt();
2169480093f4SDimitry Andric   E->OperatorLoc = readSourceLocation();
2170480093f4SDimitry Andric   E->PackLoc = readSourceLocation();
2171480093f4SDimitry Andric   E->RParenLoc = readSourceLocation();
21720b57cec5SDimitry Andric   E->Pack = Record.readDeclAs<NamedDecl>();
21730b57cec5SDimitry Andric   if (E->isPartiallySubstituted()) {
21740b57cec5SDimitry Andric     assert(E->Length == NumPartialArgs);
21750b57cec5SDimitry Andric     for (auto *I = E->getTrailingObjects<TemplateArgument>(),
21760b57cec5SDimitry Andric               *E = I + NumPartialArgs;
21770b57cec5SDimitry Andric          I != E; ++I)
21780b57cec5SDimitry Andric       new (I) TemplateArgument(Record.readTemplateArgument());
21790b57cec5SDimitry Andric   } else if (!E->isValueDependent()) {
21800b57cec5SDimitry Andric     E->Length = Record.readInt();
21810b57cec5SDimitry Andric   }
21820b57cec5SDimitry Andric }
21830b57cec5SDimitry Andric 
2184*0fca6ea1SDimitry Andric void ASTStmtReader::VisitPackIndexingExpr(PackIndexingExpr *E) {
2185*0fca6ea1SDimitry Andric   VisitExpr(E);
2186*0fca6ea1SDimitry Andric   E->TransformedExpressions = Record.readInt();
2187*0fca6ea1SDimitry Andric   E->ExpandedToEmptyPack = Record.readInt();
2188*0fca6ea1SDimitry Andric   E->EllipsisLoc = readSourceLocation();
2189*0fca6ea1SDimitry Andric   E->RSquareLoc = readSourceLocation();
2190*0fca6ea1SDimitry Andric   E->SubExprs[0] = Record.readStmt();
2191*0fca6ea1SDimitry Andric   E->SubExprs[1] = Record.readStmt();
2192*0fca6ea1SDimitry Andric   auto **Exprs = E->getTrailingObjects<Expr *>();
2193*0fca6ea1SDimitry Andric   for (unsigned I = 0; I < E->TransformedExpressions; ++I)
2194*0fca6ea1SDimitry Andric     Exprs[I] = Record.readExpr();
2195*0fca6ea1SDimitry Andric }
2196*0fca6ea1SDimitry Andric 
21970b57cec5SDimitry Andric void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
21980b57cec5SDimitry Andric                                               SubstNonTypeTemplateParmExpr *E) {
21990b57cec5SDimitry Andric   VisitExpr(E);
2200bdd1243dSDimitry Andric   E->AssociatedDeclAndRef.setPointer(readDeclAs<Decl>());
2201cb14a3feSDimitry Andric   E->AssociatedDeclAndRef.setInt(CurrentUnpackingBits->getNextBit());
2202cb14a3feSDimitry Andric   E->Index = CurrentUnpackingBits->getNextBits(/*Width=*/12);
2203cb14a3feSDimitry Andric   if (CurrentUnpackingBits->getNextBit())
2204bdd1243dSDimitry Andric     E->PackIndex = Record.readInt();
2205cb14a3feSDimitry Andric   else
2206cb14a3feSDimitry Andric     E->PackIndex = 0;
2207480093f4SDimitry Andric   E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
22080b57cec5SDimitry Andric   E->Replacement = Record.readSubExpr();
22090b57cec5SDimitry Andric }
22100b57cec5SDimitry Andric 
22110b57cec5SDimitry Andric void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
22120b57cec5SDimitry Andric                                           SubstNonTypeTemplateParmPackExpr *E) {
22130b57cec5SDimitry Andric   VisitExpr(E);
2214bdd1243dSDimitry Andric   E->AssociatedDecl = readDeclAs<Decl>();
2215bdd1243dSDimitry Andric   E->Index = Record.readInt();
22160b57cec5SDimitry Andric   TemplateArgument ArgPack = Record.readTemplateArgument();
22170b57cec5SDimitry Andric   if (ArgPack.getKind() != TemplateArgument::Pack)
22180b57cec5SDimitry Andric     return;
22190b57cec5SDimitry Andric 
22200b57cec5SDimitry Andric   E->Arguments = ArgPack.pack_begin();
22210b57cec5SDimitry Andric   E->NumArguments = ArgPack.pack_size();
2222480093f4SDimitry Andric   E->NameLoc = readSourceLocation();
22230b57cec5SDimitry Andric }
22240b57cec5SDimitry Andric 
22250b57cec5SDimitry Andric void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
22260b57cec5SDimitry Andric   VisitExpr(E);
22270b57cec5SDimitry Andric   E->NumParameters = Record.readInt();
2228480093f4SDimitry Andric   E->ParamPack = readDeclAs<ParmVarDecl>();
2229480093f4SDimitry Andric   E->NameLoc = readSourceLocation();
22300b57cec5SDimitry Andric   auto **Parms = E->getTrailingObjects<VarDecl *>();
22310b57cec5SDimitry Andric   for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
2232480093f4SDimitry Andric     Parms[i] = readDeclAs<VarDecl>();
22330b57cec5SDimitry Andric }
22340b57cec5SDimitry Andric 
22350b57cec5SDimitry Andric void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
22360b57cec5SDimitry Andric   VisitExpr(E);
2237480093f4SDimitry Andric   bool HasMaterialzedDecl = Record.readInt();
2238480093f4SDimitry Andric   if (HasMaterialzedDecl)
2239480093f4SDimitry Andric     E->State = cast<LifetimeExtendedTemporaryDecl>(Record.readDecl());
2240480093f4SDimitry Andric   else
22410b57cec5SDimitry Andric     E->State = Record.readSubExpr();
22420b57cec5SDimitry Andric }
22430b57cec5SDimitry Andric 
22440b57cec5SDimitry Andric void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
22450b57cec5SDimitry Andric   VisitExpr(E);
2246480093f4SDimitry Andric   E->LParenLoc = readSourceLocation();
2247480093f4SDimitry Andric   E->EllipsisLoc = readSourceLocation();
2248480093f4SDimitry Andric   E->RParenLoc = readSourceLocation();
22490b57cec5SDimitry Andric   E->NumExpansions = Record.readInt();
22500b57cec5SDimitry Andric   E->SubExprs[0] = Record.readSubExpr();
22510b57cec5SDimitry Andric   E->SubExprs[1] = Record.readSubExpr();
2252e8d8bef9SDimitry Andric   E->SubExprs[2] = Record.readSubExpr();
22530b57cec5SDimitry Andric   E->Opcode = (BinaryOperatorKind)Record.readInt();
22540b57cec5SDimitry Andric }
22550b57cec5SDimitry Andric 
2256bdd1243dSDimitry Andric void ASTStmtReader::VisitCXXParenListInitExpr(CXXParenListInitExpr *E) {
2257bdd1243dSDimitry Andric   VisitExpr(E);
2258bdd1243dSDimitry Andric   unsigned ExpectedNumExprs = Record.readInt();
2259bdd1243dSDimitry Andric   assert(E->NumExprs == ExpectedNumExprs &&
2260bdd1243dSDimitry Andric          "expected number of expressions does not equal the actual number of "
2261bdd1243dSDimitry Andric          "serialized expressions.");
2262bdd1243dSDimitry Andric   E->NumUserSpecifiedExprs = Record.readInt();
2263bdd1243dSDimitry Andric   E->InitLoc = readSourceLocation();
2264bdd1243dSDimitry Andric   E->LParenLoc = readSourceLocation();
2265bdd1243dSDimitry Andric   E->RParenLoc = readSourceLocation();
2266bdd1243dSDimitry Andric   for (unsigned I = 0; I < ExpectedNumExprs; I++)
2267bdd1243dSDimitry Andric     E->getTrailingObjects<Expr *>()[I] = Record.readSubExpr();
2268bdd1243dSDimitry Andric 
2269bdd1243dSDimitry Andric   bool HasArrayFillerOrUnionDecl = Record.readBool();
2270bdd1243dSDimitry Andric   if (HasArrayFillerOrUnionDecl) {
2271bdd1243dSDimitry Andric     bool HasArrayFiller = Record.readBool();
2272bdd1243dSDimitry Andric     if (HasArrayFiller) {
2273bdd1243dSDimitry Andric       E->setArrayFiller(Record.readSubExpr());
2274bdd1243dSDimitry Andric     } else {
2275bdd1243dSDimitry Andric       E->setInitializedFieldInUnion(readDeclAs<FieldDecl>());
2276bdd1243dSDimitry Andric     }
2277bdd1243dSDimitry Andric   }
2278bdd1243dSDimitry Andric   E->updateDependence();
2279bdd1243dSDimitry Andric }
2280bdd1243dSDimitry Andric 
22810b57cec5SDimitry Andric void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
22820b57cec5SDimitry Andric   VisitExpr(E);
22830b57cec5SDimitry Andric   E->SourceExpr = Record.readSubExpr();
2284480093f4SDimitry Andric   E->OpaqueValueExprBits.Loc = readSourceLocation();
22850b57cec5SDimitry Andric   E->setIsUnique(Record.readInt());
22860b57cec5SDimitry Andric }
22870b57cec5SDimitry Andric 
22880b57cec5SDimitry Andric void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
22890b57cec5SDimitry Andric   llvm_unreachable("Cannot read TypoExpr nodes");
22900b57cec5SDimitry Andric }
22910b57cec5SDimitry Andric 
22925ffd83dbSDimitry Andric void ASTStmtReader::VisitRecoveryExpr(RecoveryExpr *E) {
22935ffd83dbSDimitry Andric   VisitExpr(E);
22945ffd83dbSDimitry Andric   unsigned NumArgs = Record.readInt();
22955ffd83dbSDimitry Andric   E->BeginLoc = readSourceLocation();
22965ffd83dbSDimitry Andric   E->EndLoc = readSourceLocation();
2297e8d8bef9SDimitry Andric   assert((NumArgs + 0LL ==
2298e8d8bef9SDimitry Andric           std::distance(E->children().begin(), E->children().end())) &&
22995ffd83dbSDimitry Andric          "Wrong NumArgs!");
23005ffd83dbSDimitry Andric   (void)NumArgs;
23015ffd83dbSDimitry Andric   for (Stmt *&Child : E->children())
23025ffd83dbSDimitry Andric     Child = Record.readSubStmt();
23035ffd83dbSDimitry Andric }
23045ffd83dbSDimitry Andric 
23050b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
23060b57cec5SDimitry Andric // Microsoft Expressions and Statements
23070b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
23080b57cec5SDimitry Andric void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
23090b57cec5SDimitry Andric   VisitExpr(E);
23100b57cec5SDimitry Andric   E->IsArrow = (Record.readInt() != 0);
23110b57cec5SDimitry Andric   E->BaseExpr = Record.readSubExpr();
23120b57cec5SDimitry Andric   E->QualifierLoc = Record.readNestedNameSpecifierLoc();
2313480093f4SDimitry Andric   E->MemberLoc = readSourceLocation();
2314480093f4SDimitry Andric   E->TheDecl = readDeclAs<MSPropertyDecl>();
23150b57cec5SDimitry Andric }
23160b57cec5SDimitry Andric 
23170b57cec5SDimitry Andric void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
23180b57cec5SDimitry Andric   VisitExpr(E);
23190b57cec5SDimitry Andric   E->setBase(Record.readSubExpr());
23200b57cec5SDimitry Andric   E->setIdx(Record.readSubExpr());
2321480093f4SDimitry Andric   E->setRBracketLoc(readSourceLocation());
23220b57cec5SDimitry Andric }
23230b57cec5SDimitry Andric 
23240b57cec5SDimitry Andric void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
23250b57cec5SDimitry Andric   VisitExpr(E);
2326480093f4SDimitry Andric   E->setSourceRange(readSourceRange());
23275ffd83dbSDimitry Andric   E->Guid = readDeclAs<MSGuidDecl>();
23285ffd83dbSDimitry Andric   if (E->isTypeOperand())
23295ffd83dbSDimitry Andric     E->Operand = readTypeSourceInfo();
23305ffd83dbSDimitry Andric   else
23315ffd83dbSDimitry Andric     E->Operand = Record.readSubExpr();
23320b57cec5SDimitry Andric }
23330b57cec5SDimitry Andric 
23340b57cec5SDimitry Andric void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
23350b57cec5SDimitry Andric   VisitStmt(S);
2336480093f4SDimitry Andric   S->setLeaveLoc(readSourceLocation());
23370b57cec5SDimitry Andric }
23380b57cec5SDimitry Andric 
23390b57cec5SDimitry Andric void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
23400b57cec5SDimitry Andric   VisitStmt(S);
2341480093f4SDimitry Andric   S->Loc = readSourceLocation();
23420b57cec5SDimitry Andric   S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
23430b57cec5SDimitry Andric   S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
23440b57cec5SDimitry Andric }
23450b57cec5SDimitry Andric 
23460b57cec5SDimitry Andric void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
23470b57cec5SDimitry Andric   VisitStmt(S);
2348480093f4SDimitry Andric   S->Loc = readSourceLocation();
23490b57cec5SDimitry Andric   S->Block = Record.readSubStmt();
23500b57cec5SDimitry Andric }
23510b57cec5SDimitry Andric 
23520b57cec5SDimitry Andric void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
23530b57cec5SDimitry Andric   VisitStmt(S);
23540b57cec5SDimitry Andric   S->IsCXXTry = Record.readInt();
2355480093f4SDimitry Andric   S->TryLoc = readSourceLocation();
23560b57cec5SDimitry Andric   S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
23570b57cec5SDimitry Andric   S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
23580b57cec5SDimitry Andric }
23590b57cec5SDimitry Andric 
23600b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
23610b57cec5SDimitry Andric // CUDA Expressions and Statements
23620b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
23630b57cec5SDimitry Andric 
23640b57cec5SDimitry Andric void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
23650b57cec5SDimitry Andric   VisitCallExpr(E);
23660b57cec5SDimitry Andric   E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
23670b57cec5SDimitry Andric }
23680b57cec5SDimitry Andric 
23690b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
23700b57cec5SDimitry Andric // OpenCL Expressions and Statements.
23710b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
23720b57cec5SDimitry Andric void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
23730b57cec5SDimitry Andric   VisitExpr(E);
2374480093f4SDimitry Andric   E->BuiltinLoc = readSourceLocation();
2375480093f4SDimitry Andric   E->RParenLoc = readSourceLocation();
23760b57cec5SDimitry Andric   E->SrcExpr = Record.readSubExpr();
23770b57cec5SDimitry Andric }
23780b57cec5SDimitry Andric 
23790b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
23800b57cec5SDimitry Andric // OpenMP Directives.
23810b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
23820b57cec5SDimitry Andric 
2383fe6060f1SDimitry Andric void ASTStmtReader::VisitOMPCanonicalLoop(OMPCanonicalLoop *S) {
2384fe6060f1SDimitry Andric   VisitStmt(S);
2385fe6060f1SDimitry Andric   for (Stmt *&SubStmt : S->SubStmts)
2386fe6060f1SDimitry Andric     SubStmt = Record.readSubStmt();
2387fe6060f1SDimitry Andric }
2388fe6060f1SDimitry Andric 
23890b57cec5SDimitry Andric void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
2390e8d8bef9SDimitry Andric   Record.readOMPChildren(E->Data);
2391480093f4SDimitry Andric   E->setLocStart(readSourceLocation());
2392480093f4SDimitry Andric   E->setLocEnd(readSourceLocation());
23935f757f3fSDimitry Andric   E->setMappedDirective(Record.readEnum<OpenMPDirectiveKind>());
23940b57cec5SDimitry Andric }
23950b57cec5SDimitry Andric 
2396fe6060f1SDimitry Andric void ASTStmtReader::VisitOMPLoopBasedDirective(OMPLoopBasedDirective *D) {
23970b57cec5SDimitry Andric   VisitStmt(D);
2398e8d8bef9SDimitry Andric   // Field CollapsedNum was read in ReadStmtFromStream.
2399e8d8bef9SDimitry Andric   Record.skipInts(1);
24000b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
24010b57cec5SDimitry Andric }
24020b57cec5SDimitry Andric 
2403fe6060f1SDimitry Andric void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2404fe6060f1SDimitry Andric   VisitOMPLoopBasedDirective(D);
2405fe6060f1SDimitry Andric }
2406fe6060f1SDimitry Andric 
2407349cc55cSDimitry Andric void ASTStmtReader::VisitOMPMetaDirective(OMPMetaDirective *D) {
2408349cc55cSDimitry Andric   VisitStmt(D);
2409349cc55cSDimitry Andric   // The NumClauses field was read in ReadStmtFromStream.
2410349cc55cSDimitry Andric   Record.skipInts(1);
2411349cc55cSDimitry Andric   VisitOMPExecutableDirective(D);
2412349cc55cSDimitry Andric }
2413349cc55cSDimitry Andric 
24140b57cec5SDimitry Andric void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
24150b57cec5SDimitry Andric   VisitStmt(D);
24160b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
2417e8d8bef9SDimitry Andric   D->setHasCancel(Record.readBool());
24180b57cec5SDimitry Andric }
24190b57cec5SDimitry Andric 
24200b57cec5SDimitry Andric void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
24210b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
24220b57cec5SDimitry Andric }
24230b57cec5SDimitry Andric 
2424349cc55cSDimitry Andric void ASTStmtReader::VisitOMPLoopTransformationDirective(
2425349cc55cSDimitry Andric     OMPLoopTransformationDirective *D) {
2426fe6060f1SDimitry Andric   VisitOMPLoopBasedDirective(D);
2427349cc55cSDimitry Andric   D->setNumGeneratedLoops(Record.readUInt32());
2428349cc55cSDimitry Andric }
2429349cc55cSDimitry Andric 
2430349cc55cSDimitry Andric void ASTStmtReader::VisitOMPTileDirective(OMPTileDirective *D) {
2431349cc55cSDimitry Andric   VisitOMPLoopTransformationDirective(D);
2432fe6060f1SDimitry Andric }
2433fe6060f1SDimitry Andric 
2434fe6060f1SDimitry Andric void ASTStmtReader::VisitOMPUnrollDirective(OMPUnrollDirective *D) {
2435349cc55cSDimitry Andric   VisitOMPLoopTransformationDirective(D);
2436fe6060f1SDimitry Andric }
2437fe6060f1SDimitry Andric 
2438*0fca6ea1SDimitry Andric void ASTStmtReader::VisitOMPReverseDirective(OMPReverseDirective *D) {
2439*0fca6ea1SDimitry Andric   VisitOMPLoopTransformationDirective(D);
2440*0fca6ea1SDimitry Andric }
2441*0fca6ea1SDimitry Andric 
2442*0fca6ea1SDimitry Andric void ASTStmtReader::VisitOMPInterchangeDirective(OMPInterchangeDirective *D) {
2443*0fca6ea1SDimitry Andric   VisitOMPLoopTransformationDirective(D);
2444*0fca6ea1SDimitry Andric }
2445*0fca6ea1SDimitry Andric 
24460b57cec5SDimitry Andric void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
24470b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
2448e8d8bef9SDimitry Andric   D->setHasCancel(Record.readBool());
24490b57cec5SDimitry Andric }
24500b57cec5SDimitry Andric 
24510b57cec5SDimitry Andric void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
24520b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
24530b57cec5SDimitry Andric }
24540b57cec5SDimitry Andric 
24550b57cec5SDimitry Andric void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
24560b57cec5SDimitry Andric   VisitStmt(D);
24570b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
2458e8d8bef9SDimitry Andric   D->setHasCancel(Record.readBool());
24590b57cec5SDimitry Andric }
24600b57cec5SDimitry Andric 
24610b57cec5SDimitry Andric void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
24620b57cec5SDimitry Andric   VisitStmt(D);
24630b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
2464e8d8bef9SDimitry Andric   D->setHasCancel(Record.readBool());
24650b57cec5SDimitry Andric }
24660b57cec5SDimitry Andric 
24675f757f3fSDimitry Andric void ASTStmtReader::VisitOMPScopeDirective(OMPScopeDirective *D) {
24685f757f3fSDimitry Andric   VisitStmt(D);
24695f757f3fSDimitry Andric   VisitOMPExecutableDirective(D);
24705f757f3fSDimitry Andric }
24715f757f3fSDimitry Andric 
24720b57cec5SDimitry Andric void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
24730b57cec5SDimitry Andric   VisitStmt(D);
24740b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
24750b57cec5SDimitry Andric }
24760b57cec5SDimitry Andric 
24770b57cec5SDimitry Andric void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
24780b57cec5SDimitry Andric   VisitStmt(D);
24790b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
24800b57cec5SDimitry Andric }
24810b57cec5SDimitry Andric 
24820b57cec5SDimitry Andric void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
24830b57cec5SDimitry Andric   VisitStmt(D);
24840b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
2485480093f4SDimitry Andric   D->DirName = Record.readDeclarationNameInfo();
24860b57cec5SDimitry Andric }
24870b57cec5SDimitry Andric 
24880b57cec5SDimitry Andric void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
24890b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
2490e8d8bef9SDimitry Andric   D->setHasCancel(Record.readBool());
24910b57cec5SDimitry Andric }
24920b57cec5SDimitry Andric 
24930b57cec5SDimitry Andric void ASTStmtReader::VisitOMPParallelForSimdDirective(
24940b57cec5SDimitry Andric     OMPParallelForSimdDirective *D) {
24950b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
24960b57cec5SDimitry Andric }
24970b57cec5SDimitry Andric 
2498480093f4SDimitry Andric void ASTStmtReader::VisitOMPParallelMasterDirective(
2499480093f4SDimitry Andric     OMPParallelMasterDirective *D) {
2500480093f4SDimitry Andric   VisitStmt(D);
2501480093f4SDimitry Andric   VisitOMPExecutableDirective(D);
2502480093f4SDimitry Andric }
2503480093f4SDimitry Andric 
250481ad6265SDimitry Andric void ASTStmtReader::VisitOMPParallelMaskedDirective(
250581ad6265SDimitry Andric     OMPParallelMaskedDirective *D) {
250681ad6265SDimitry Andric   VisitStmt(D);
250781ad6265SDimitry Andric   VisitOMPExecutableDirective(D);
250881ad6265SDimitry Andric }
250981ad6265SDimitry Andric 
25100b57cec5SDimitry Andric void ASTStmtReader::VisitOMPParallelSectionsDirective(
25110b57cec5SDimitry Andric     OMPParallelSectionsDirective *D) {
25120b57cec5SDimitry Andric   VisitStmt(D);
25130b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
2514e8d8bef9SDimitry Andric   D->setHasCancel(Record.readBool());
25150b57cec5SDimitry Andric }
25160b57cec5SDimitry Andric 
25170b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
25180b57cec5SDimitry Andric   VisitStmt(D);
25190b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
2520e8d8bef9SDimitry Andric   D->setHasCancel(Record.readBool());
25210b57cec5SDimitry Andric }
25220b57cec5SDimitry Andric 
25230b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
25240b57cec5SDimitry Andric   VisitStmt(D);
25250b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
25260b57cec5SDimitry Andric }
25270b57cec5SDimitry Andric 
25280b57cec5SDimitry Andric void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
25290b57cec5SDimitry Andric   VisitStmt(D);
25300b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
25310b57cec5SDimitry Andric }
25320b57cec5SDimitry Andric 
25330b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
25340b57cec5SDimitry Andric   VisitStmt(D);
2535349cc55cSDimitry Andric   // The NumClauses field was read in ReadStmtFromStream.
2536349cc55cSDimitry Andric   Record.skipInts(1);
25370b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
25380b57cec5SDimitry Andric }
25390b57cec5SDimitry Andric 
2540bdd1243dSDimitry Andric void ASTStmtReader::VisitOMPErrorDirective(OMPErrorDirective *D) {
2541bdd1243dSDimitry Andric   VisitStmt(D);
2542bdd1243dSDimitry Andric   // The NumClauses field was read in ReadStmtFromStream.
2543bdd1243dSDimitry Andric   Record.skipInts(1);
2544bdd1243dSDimitry Andric   VisitOMPExecutableDirective(D);
2545bdd1243dSDimitry Andric }
2546bdd1243dSDimitry Andric 
25470b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
25480b57cec5SDimitry Andric   VisitStmt(D);
25490b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
25500b57cec5SDimitry Andric }
25510b57cec5SDimitry Andric 
25520b57cec5SDimitry Andric void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
25530b57cec5SDimitry Andric   VisitStmt(D);
25540b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
25550b57cec5SDimitry Andric }
25560b57cec5SDimitry Andric 
25575ffd83dbSDimitry Andric void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective *D) {
25585ffd83dbSDimitry Andric   VisitStmt(D);
25595ffd83dbSDimitry Andric   VisitOMPExecutableDirective(D);
25605ffd83dbSDimitry Andric }
25615ffd83dbSDimitry Andric 
25625ffd83dbSDimitry Andric void ASTStmtReader::VisitOMPScanDirective(OMPScanDirective *D) {
25635ffd83dbSDimitry Andric   VisitStmt(D);
25645ffd83dbSDimitry Andric   VisitOMPExecutableDirective(D);
25655ffd83dbSDimitry Andric }
25665ffd83dbSDimitry Andric 
25670b57cec5SDimitry Andric void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
25680b57cec5SDimitry Andric   VisitStmt(D);
25690b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
25700b57cec5SDimitry Andric }
25710b57cec5SDimitry Andric 
25720b57cec5SDimitry Andric void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
25730b57cec5SDimitry Andric   VisitStmt(D);
25740b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
257581ad6265SDimitry Andric   D->Flags.IsXLHSInRHSPart = Record.readBool() ? 1 : 0;
257681ad6265SDimitry Andric   D->Flags.IsPostfixUpdate = Record.readBool() ? 1 : 0;
257781ad6265SDimitry Andric   D->Flags.IsFailOnly = Record.readBool() ? 1 : 0;
25780b57cec5SDimitry Andric }
25790b57cec5SDimitry Andric 
25800b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
25810b57cec5SDimitry Andric   VisitStmt(D);
25820b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
25830b57cec5SDimitry Andric }
25840b57cec5SDimitry Andric 
25850b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
25860b57cec5SDimitry Andric   VisitStmt(D);
25870b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
25880b57cec5SDimitry Andric }
25890b57cec5SDimitry Andric 
25900b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTargetEnterDataDirective(
25910b57cec5SDimitry Andric     OMPTargetEnterDataDirective *D) {
25920b57cec5SDimitry Andric   VisitStmt(D);
25930b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
25940b57cec5SDimitry Andric }
25950b57cec5SDimitry Andric 
25960b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTargetExitDataDirective(
25970b57cec5SDimitry Andric     OMPTargetExitDataDirective *D) {
25980b57cec5SDimitry Andric   VisitStmt(D);
25990b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
26000b57cec5SDimitry Andric }
26010b57cec5SDimitry Andric 
26020b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTargetParallelDirective(
26030b57cec5SDimitry Andric     OMPTargetParallelDirective *D) {
26040b57cec5SDimitry Andric   VisitStmt(D);
26050b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
26065ffd83dbSDimitry Andric   D->setHasCancel(Record.readBool());
26070b57cec5SDimitry Andric }
26080b57cec5SDimitry Andric 
26090b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTargetParallelForDirective(
26100b57cec5SDimitry Andric     OMPTargetParallelForDirective *D) {
26110b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
2612e8d8bef9SDimitry Andric   D->setHasCancel(Record.readBool());
26130b57cec5SDimitry Andric }
26140b57cec5SDimitry Andric 
26150b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
26160b57cec5SDimitry Andric   VisitStmt(D);
26170b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
26180b57cec5SDimitry Andric }
26190b57cec5SDimitry Andric 
26200b57cec5SDimitry Andric void ASTStmtReader::VisitOMPCancellationPointDirective(
26210b57cec5SDimitry Andric     OMPCancellationPointDirective *D) {
26220b57cec5SDimitry Andric   VisitStmt(D);
26230b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
2624e8d8bef9SDimitry Andric   D->setCancelRegion(Record.readEnum<OpenMPDirectiveKind>());
26250b57cec5SDimitry Andric }
26260b57cec5SDimitry Andric 
26270b57cec5SDimitry Andric void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
26280b57cec5SDimitry Andric   VisitStmt(D);
26290b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
2630e8d8bef9SDimitry Andric   D->setCancelRegion(Record.readEnum<OpenMPDirectiveKind>());
26310b57cec5SDimitry Andric }
26320b57cec5SDimitry Andric 
26330b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
26340b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
2635e8d8bef9SDimitry Andric   D->setHasCancel(Record.readBool());
26360b57cec5SDimitry Andric }
26370b57cec5SDimitry Andric 
26380b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
26390b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
26400b57cec5SDimitry Andric }
26410b57cec5SDimitry Andric 
2642a7dea167SDimitry Andric void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2643a7dea167SDimitry Andric     OMPMasterTaskLoopDirective *D) {
2644a7dea167SDimitry Andric   VisitOMPLoopDirective(D);
2645e8d8bef9SDimitry Andric   D->setHasCancel(Record.readBool());
2646a7dea167SDimitry Andric }
2647a7dea167SDimitry Andric 
264881ad6265SDimitry Andric void ASTStmtReader::VisitOMPMaskedTaskLoopDirective(
264981ad6265SDimitry Andric     OMPMaskedTaskLoopDirective *D) {
265081ad6265SDimitry Andric   VisitOMPLoopDirective(D);
265181ad6265SDimitry Andric   D->setHasCancel(Record.readBool());
265281ad6265SDimitry Andric }
265381ad6265SDimitry Andric 
2654a7dea167SDimitry Andric void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2655a7dea167SDimitry Andric     OMPMasterTaskLoopSimdDirective *D) {
2656a7dea167SDimitry Andric   VisitOMPLoopDirective(D);
2657a7dea167SDimitry Andric }
2658a7dea167SDimitry Andric 
265981ad6265SDimitry Andric void ASTStmtReader::VisitOMPMaskedTaskLoopSimdDirective(
266081ad6265SDimitry Andric     OMPMaskedTaskLoopSimdDirective *D) {
266181ad6265SDimitry Andric   VisitOMPLoopDirective(D);
266281ad6265SDimitry Andric }
266381ad6265SDimitry Andric 
2664a7dea167SDimitry Andric void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2665a7dea167SDimitry Andric     OMPParallelMasterTaskLoopDirective *D) {
2666a7dea167SDimitry Andric   VisitOMPLoopDirective(D);
2667e8d8bef9SDimitry Andric   D->setHasCancel(Record.readBool());
2668a7dea167SDimitry Andric }
2669a7dea167SDimitry Andric 
267081ad6265SDimitry Andric void ASTStmtReader::VisitOMPParallelMaskedTaskLoopDirective(
267181ad6265SDimitry Andric     OMPParallelMaskedTaskLoopDirective *D) {
267281ad6265SDimitry Andric   VisitOMPLoopDirective(D);
267381ad6265SDimitry Andric   D->setHasCancel(Record.readBool());
267481ad6265SDimitry Andric }
267581ad6265SDimitry Andric 
2676480093f4SDimitry Andric void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2677480093f4SDimitry Andric     OMPParallelMasterTaskLoopSimdDirective *D) {
2678480093f4SDimitry Andric   VisitOMPLoopDirective(D);
2679480093f4SDimitry Andric }
2680480093f4SDimitry Andric 
268181ad6265SDimitry Andric void ASTStmtReader::VisitOMPParallelMaskedTaskLoopSimdDirective(
268281ad6265SDimitry Andric     OMPParallelMaskedTaskLoopSimdDirective *D) {
268381ad6265SDimitry Andric   VisitOMPLoopDirective(D);
268481ad6265SDimitry Andric }
268581ad6265SDimitry Andric 
26860b57cec5SDimitry Andric void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
26870b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
26880b57cec5SDimitry Andric }
26890b57cec5SDimitry Andric 
26900b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
26910b57cec5SDimitry Andric   VisitStmt(D);
26920b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
26930b57cec5SDimitry Andric }
26940b57cec5SDimitry Andric 
26950b57cec5SDimitry Andric void ASTStmtReader::VisitOMPDistributeParallelForDirective(
26960b57cec5SDimitry Andric     OMPDistributeParallelForDirective *D) {
26970b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
2698e8d8bef9SDimitry Andric   D->setHasCancel(Record.readBool());
26990b57cec5SDimitry Andric }
27000b57cec5SDimitry Andric 
27010b57cec5SDimitry Andric void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
27020b57cec5SDimitry Andric     OMPDistributeParallelForSimdDirective *D) {
27030b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
27040b57cec5SDimitry Andric }
27050b57cec5SDimitry Andric 
27060b57cec5SDimitry Andric void ASTStmtReader::VisitOMPDistributeSimdDirective(
27070b57cec5SDimitry Andric     OMPDistributeSimdDirective *D) {
27080b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
27090b57cec5SDimitry Andric }
27100b57cec5SDimitry Andric 
27110b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
27120b57cec5SDimitry Andric     OMPTargetParallelForSimdDirective *D) {
27130b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
27140b57cec5SDimitry Andric }
27150b57cec5SDimitry Andric 
27160b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
27170b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
27180b57cec5SDimitry Andric }
27190b57cec5SDimitry Andric 
27200b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTeamsDistributeDirective(
27210b57cec5SDimitry Andric     OMPTeamsDistributeDirective *D) {
27220b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
27230b57cec5SDimitry Andric }
27240b57cec5SDimitry Andric 
27250b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
27260b57cec5SDimitry Andric     OMPTeamsDistributeSimdDirective *D) {
27270b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
27280b57cec5SDimitry Andric }
27290b57cec5SDimitry Andric 
27300b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
27310b57cec5SDimitry Andric     OMPTeamsDistributeParallelForSimdDirective *D) {
27320b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
27330b57cec5SDimitry Andric }
27340b57cec5SDimitry Andric 
27350b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
27360b57cec5SDimitry Andric     OMPTeamsDistributeParallelForDirective *D) {
27370b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
2738e8d8bef9SDimitry Andric   D->setHasCancel(Record.readBool());
27390b57cec5SDimitry Andric }
27400b57cec5SDimitry Andric 
27410b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
27420b57cec5SDimitry Andric   VisitStmt(D);
27430b57cec5SDimitry Andric   VisitOMPExecutableDirective(D);
27440b57cec5SDimitry Andric }
27450b57cec5SDimitry Andric 
27460b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
27470b57cec5SDimitry Andric     OMPTargetTeamsDistributeDirective *D) {
27480b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
27490b57cec5SDimitry Andric }
27500b57cec5SDimitry Andric 
27510b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
27520b57cec5SDimitry Andric     OMPTargetTeamsDistributeParallelForDirective *D) {
27530b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
2754e8d8bef9SDimitry Andric   D->setHasCancel(Record.readBool());
27550b57cec5SDimitry Andric }
27560b57cec5SDimitry Andric 
27570b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
27580b57cec5SDimitry Andric     OMPTargetTeamsDistributeParallelForSimdDirective *D) {
27590b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
27600b57cec5SDimitry Andric }
27610b57cec5SDimitry Andric 
27620b57cec5SDimitry Andric void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
27630b57cec5SDimitry Andric     OMPTargetTeamsDistributeSimdDirective *D) {
27640b57cec5SDimitry Andric   VisitOMPLoopDirective(D);
27650b57cec5SDimitry Andric }
27660b57cec5SDimitry Andric 
2767fe6060f1SDimitry Andric void ASTStmtReader::VisitOMPInteropDirective(OMPInteropDirective *D) {
2768fe6060f1SDimitry Andric   VisitStmt(D);
2769fe6060f1SDimitry Andric   VisitOMPExecutableDirective(D);
2770fe6060f1SDimitry Andric }
2771fe6060f1SDimitry Andric 
2772fe6060f1SDimitry Andric void ASTStmtReader::VisitOMPDispatchDirective(OMPDispatchDirective *D) {
2773fe6060f1SDimitry Andric   VisitStmt(D);
2774fe6060f1SDimitry Andric   VisitOMPExecutableDirective(D);
2775fe6060f1SDimitry Andric   D->setTargetCallLoc(Record.readSourceLocation());
2776fe6060f1SDimitry Andric }
2777fe6060f1SDimitry Andric 
2778fe6060f1SDimitry Andric void ASTStmtReader::VisitOMPMaskedDirective(OMPMaskedDirective *D) {
2779fe6060f1SDimitry Andric   VisitStmt(D);
2780fe6060f1SDimitry Andric   VisitOMPExecutableDirective(D);
2781fe6060f1SDimitry Andric }
2782fe6060f1SDimitry Andric 
2783349cc55cSDimitry Andric void ASTStmtReader::VisitOMPGenericLoopDirective(OMPGenericLoopDirective *D) {
2784349cc55cSDimitry Andric   VisitOMPLoopDirective(D);
2785349cc55cSDimitry Andric }
2786349cc55cSDimitry Andric 
278781ad6265SDimitry Andric void ASTStmtReader::VisitOMPTeamsGenericLoopDirective(
278881ad6265SDimitry Andric     OMPTeamsGenericLoopDirective *D) {
278981ad6265SDimitry Andric   VisitOMPLoopDirective(D);
279081ad6265SDimitry Andric }
279181ad6265SDimitry Andric 
279281ad6265SDimitry Andric void ASTStmtReader::VisitOMPTargetTeamsGenericLoopDirective(
279381ad6265SDimitry Andric     OMPTargetTeamsGenericLoopDirective *D) {
279481ad6265SDimitry Andric   VisitOMPLoopDirective(D);
2795*0fca6ea1SDimitry Andric   D->setCanBeParallelFor(Record.readBool());
279681ad6265SDimitry Andric }
279781ad6265SDimitry Andric 
279881ad6265SDimitry Andric void ASTStmtReader::VisitOMPParallelGenericLoopDirective(
279981ad6265SDimitry Andric     OMPParallelGenericLoopDirective *D) {
280081ad6265SDimitry Andric   VisitOMPLoopDirective(D);
280181ad6265SDimitry Andric }
280281ad6265SDimitry Andric 
280381ad6265SDimitry Andric void ASTStmtReader::VisitOMPTargetParallelGenericLoopDirective(
280481ad6265SDimitry Andric     OMPTargetParallelGenericLoopDirective *D) {
280581ad6265SDimitry Andric   VisitOMPLoopDirective(D);
280681ad6265SDimitry Andric }
280781ad6265SDimitry Andric 
28080b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
2809*0fca6ea1SDimitry Andric // OpenACC Constructs/Directives.
2810*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===//
2811*0fca6ea1SDimitry Andric void ASTStmtReader::VisitOpenACCConstructStmt(OpenACCConstructStmt *S) {
2812*0fca6ea1SDimitry Andric   (void)Record.readInt();
2813*0fca6ea1SDimitry Andric   S->Kind = Record.readEnum<OpenACCDirectiveKind>();
2814*0fca6ea1SDimitry Andric   S->Range = Record.readSourceRange();
2815*0fca6ea1SDimitry Andric   S->DirectiveLoc = Record.readSourceLocation();
2816*0fca6ea1SDimitry Andric   Record.readOpenACCClauseList(S->Clauses);
2817*0fca6ea1SDimitry Andric }
2818*0fca6ea1SDimitry Andric 
2819*0fca6ea1SDimitry Andric void ASTStmtReader::VisitOpenACCAssociatedStmtConstruct(
2820*0fca6ea1SDimitry Andric     OpenACCAssociatedStmtConstruct *S) {
2821*0fca6ea1SDimitry Andric   VisitOpenACCConstructStmt(S);
2822*0fca6ea1SDimitry Andric   S->setAssociatedStmt(Record.readSubStmt());
2823*0fca6ea1SDimitry Andric }
2824*0fca6ea1SDimitry Andric 
2825*0fca6ea1SDimitry Andric void ASTStmtReader::VisitOpenACCComputeConstruct(OpenACCComputeConstruct *S) {
2826*0fca6ea1SDimitry Andric   VisitStmt(S);
2827*0fca6ea1SDimitry Andric   VisitOpenACCAssociatedStmtConstruct(S);
2828*0fca6ea1SDimitry Andric   S->findAndSetChildLoops();
2829*0fca6ea1SDimitry Andric }
2830*0fca6ea1SDimitry Andric 
2831*0fca6ea1SDimitry Andric void ASTStmtReader::VisitOpenACCLoopConstruct(OpenACCLoopConstruct *S) {
2832*0fca6ea1SDimitry Andric   VisitStmt(S);
2833*0fca6ea1SDimitry Andric   VisitOpenACCAssociatedStmtConstruct(S);
2834*0fca6ea1SDimitry Andric }
2835*0fca6ea1SDimitry Andric 
2836*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===//
28370b57cec5SDimitry Andric // ASTReader Implementation
28380b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
28390b57cec5SDimitry Andric 
28400b57cec5SDimitry Andric Stmt *ASTReader::ReadStmt(ModuleFile &F) {
28410b57cec5SDimitry Andric   switch (ReadingKind) {
28420b57cec5SDimitry Andric   case Read_None:
28430b57cec5SDimitry Andric     llvm_unreachable("should not call this when not reading anything");
28440b57cec5SDimitry Andric   case Read_Decl:
28450b57cec5SDimitry Andric   case Read_Type:
28460b57cec5SDimitry Andric     return ReadStmtFromStream(F);
28470b57cec5SDimitry Andric   case Read_Stmt:
28480b57cec5SDimitry Andric     return ReadSubStmt();
28490b57cec5SDimitry Andric   }
28500b57cec5SDimitry Andric 
28510b57cec5SDimitry Andric   llvm_unreachable("ReadingKind not set ?");
28520b57cec5SDimitry Andric }
28530b57cec5SDimitry Andric 
28540b57cec5SDimitry Andric Expr *ASTReader::ReadExpr(ModuleFile &F) {
28550b57cec5SDimitry Andric   return cast_or_null<Expr>(ReadStmt(F));
28560b57cec5SDimitry Andric }
28570b57cec5SDimitry Andric 
28580b57cec5SDimitry Andric Expr *ASTReader::ReadSubExpr() {
28590b57cec5SDimitry Andric   return cast_or_null<Expr>(ReadSubStmt());
28600b57cec5SDimitry Andric }
28610b57cec5SDimitry Andric 
28620b57cec5SDimitry Andric // Within the bitstream, expressions are stored in Reverse Polish
28630b57cec5SDimitry Andric // Notation, with each of the subexpressions preceding the
28640b57cec5SDimitry Andric // expression they are stored in. Subexpressions are stored from last to first.
28650b57cec5SDimitry Andric // To evaluate expressions, we continue reading expressions and placing them on
28660b57cec5SDimitry Andric // the stack, with expressions having operands removing those operands from the
28670b57cec5SDimitry Andric // stack. Evaluation terminates when we see a STMT_STOP record, and
28680b57cec5SDimitry Andric // the single remaining expression on the stack is our result.
28690b57cec5SDimitry Andric Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
28700b57cec5SDimitry Andric   ReadingKindTracker ReadingKind(Read_Stmt, *this);
28710b57cec5SDimitry Andric   llvm::BitstreamCursor &Cursor = F.DeclsCursor;
28720b57cec5SDimitry Andric 
28730b57cec5SDimitry Andric   // Map of offset to previously deserialized stmt. The offset points
28740b57cec5SDimitry Andric   // just after the stmt record.
28750b57cec5SDimitry Andric   llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
28760b57cec5SDimitry Andric 
28770b57cec5SDimitry Andric #ifndef NDEBUG
28780b57cec5SDimitry Andric   unsigned PrevNumStmts = StmtStack.size();
28790b57cec5SDimitry Andric #endif
28800b57cec5SDimitry Andric 
28810b57cec5SDimitry Andric   ASTRecordReader Record(*this, F);
28820b57cec5SDimitry Andric   ASTStmtReader Reader(Record, Cursor);
28830b57cec5SDimitry Andric   Stmt::EmptyShell Empty;
28840b57cec5SDimitry Andric 
28850b57cec5SDimitry Andric   while (true) {
28860b57cec5SDimitry Andric     llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
28870b57cec5SDimitry Andric         Cursor.advanceSkippingSubblocks();
28880b57cec5SDimitry Andric     if (!MaybeEntry) {
28890b57cec5SDimitry Andric       Error(toString(MaybeEntry.takeError()));
28900b57cec5SDimitry Andric       return nullptr;
28910b57cec5SDimitry Andric     }
28920b57cec5SDimitry Andric     llvm::BitstreamEntry Entry = MaybeEntry.get();
28930b57cec5SDimitry Andric 
28940b57cec5SDimitry Andric     switch (Entry.Kind) {
28950b57cec5SDimitry Andric     case llvm::BitstreamEntry::SubBlock: // Handled for us already.
28960b57cec5SDimitry Andric     case llvm::BitstreamEntry::Error:
28970b57cec5SDimitry Andric       Error("malformed block record in AST file");
28980b57cec5SDimitry Andric       return nullptr;
28990b57cec5SDimitry Andric     case llvm::BitstreamEntry::EndBlock:
29000b57cec5SDimitry Andric       goto Done;
29010b57cec5SDimitry Andric     case llvm::BitstreamEntry::Record:
29020b57cec5SDimitry Andric       // The interesting case.
29030b57cec5SDimitry Andric       break;
29040b57cec5SDimitry Andric     }
29050b57cec5SDimitry Andric 
29060b57cec5SDimitry Andric     ASTContext &Context = getContext();
29070b57cec5SDimitry Andric     Stmt *S = nullptr;
29080b57cec5SDimitry Andric     bool Finished = false;
29090b57cec5SDimitry Andric     bool IsStmtReference = false;
29100b57cec5SDimitry Andric     Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
29110b57cec5SDimitry Andric     if (!MaybeStmtCode) {
29120b57cec5SDimitry Andric       Error(toString(MaybeStmtCode.takeError()));
29130b57cec5SDimitry Andric       return nullptr;
29140b57cec5SDimitry Andric     }
29150b57cec5SDimitry Andric     switch ((StmtCode)MaybeStmtCode.get()) {
29160b57cec5SDimitry Andric     case STMT_STOP:
29170b57cec5SDimitry Andric       Finished = true;
29180b57cec5SDimitry Andric       break;
29190b57cec5SDimitry Andric 
29200b57cec5SDimitry Andric     case STMT_REF_PTR:
29210b57cec5SDimitry Andric       IsStmtReference = true;
292206c3fb27SDimitry Andric       assert(StmtEntries.contains(Record[0]) &&
29230b57cec5SDimitry Andric              "No stmt was recorded for this offset reference!");
29240b57cec5SDimitry Andric       S = StmtEntries[Record.readInt()];
29250b57cec5SDimitry Andric       break;
29260b57cec5SDimitry Andric 
29270b57cec5SDimitry Andric     case STMT_NULL_PTR:
29280b57cec5SDimitry Andric       S = nullptr;
29290b57cec5SDimitry Andric       break;
29300b57cec5SDimitry Andric 
29310b57cec5SDimitry Andric     case STMT_NULL:
29320b57cec5SDimitry Andric       S = new (Context) NullStmt(Empty);
29330b57cec5SDimitry Andric       break;
29340b57cec5SDimitry Andric 
2935cb14a3feSDimitry Andric     case STMT_COMPOUND: {
2936cb14a3feSDimitry Andric       unsigned NumStmts = Record[ASTStmtReader::NumStmtFields];
2937cb14a3feSDimitry Andric       bool HasFPFeatures = Record[ASTStmtReader::NumStmtFields + 1];
2938cb14a3feSDimitry Andric       S = CompoundStmt::CreateEmpty(Context, NumStmts, HasFPFeatures);
29390b57cec5SDimitry Andric       break;
2940cb14a3feSDimitry Andric     }
29410b57cec5SDimitry Andric 
29420b57cec5SDimitry Andric     case STMT_CASE:
29430b57cec5SDimitry Andric       S = CaseStmt::CreateEmpty(
29440b57cec5SDimitry Andric           Context,
29450b57cec5SDimitry Andric           /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
29460b57cec5SDimitry Andric       break;
29470b57cec5SDimitry Andric 
29480b57cec5SDimitry Andric     case STMT_DEFAULT:
29490b57cec5SDimitry Andric       S = new (Context) DefaultStmt(Empty);
29500b57cec5SDimitry Andric       break;
29510b57cec5SDimitry Andric 
29520b57cec5SDimitry Andric     case STMT_LABEL:
29530b57cec5SDimitry Andric       S = new (Context) LabelStmt(Empty);
29540b57cec5SDimitry Andric       break;
29550b57cec5SDimitry Andric 
29560b57cec5SDimitry Andric     case STMT_ATTRIBUTED:
29570b57cec5SDimitry Andric       S = AttributedStmt::CreateEmpty(
29580b57cec5SDimitry Andric         Context,
29590b57cec5SDimitry Andric         /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
29600b57cec5SDimitry Andric       break;
29610b57cec5SDimitry Andric 
2962cb14a3feSDimitry Andric     case STMT_IF: {
2963cb14a3feSDimitry Andric       BitsUnpacker IfStmtBits(Record[ASTStmtReader::NumStmtFields]);
2964cb14a3feSDimitry Andric       bool HasElse = IfStmtBits.getNextBit();
2965cb14a3feSDimitry Andric       bool HasVar = IfStmtBits.getNextBit();
2966cb14a3feSDimitry Andric       bool HasInit = IfStmtBits.getNextBit();
2967cb14a3feSDimitry Andric       S = IfStmt::CreateEmpty(Context, HasElse, HasVar, HasInit);
29680b57cec5SDimitry Andric       break;
2969cb14a3feSDimitry Andric     }
29700b57cec5SDimitry Andric 
29710b57cec5SDimitry Andric     case STMT_SWITCH:
29720b57cec5SDimitry Andric       S = SwitchStmt::CreateEmpty(
29730b57cec5SDimitry Andric           Context,
29740b57cec5SDimitry Andric           /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
29750b57cec5SDimitry Andric           /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
29760b57cec5SDimitry Andric       break;
29770b57cec5SDimitry Andric 
29780b57cec5SDimitry Andric     case STMT_WHILE:
29790b57cec5SDimitry Andric       S = WhileStmt::CreateEmpty(
29800b57cec5SDimitry Andric           Context,
29810b57cec5SDimitry Andric           /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
29820b57cec5SDimitry Andric       break;
29830b57cec5SDimitry Andric 
29840b57cec5SDimitry Andric     case STMT_DO:
29850b57cec5SDimitry Andric       S = new (Context) DoStmt(Empty);
29860b57cec5SDimitry Andric       break;
29870b57cec5SDimitry Andric 
29880b57cec5SDimitry Andric     case STMT_FOR:
29890b57cec5SDimitry Andric       S = new (Context) ForStmt(Empty);
29900b57cec5SDimitry Andric       break;
29910b57cec5SDimitry Andric 
29920b57cec5SDimitry Andric     case STMT_GOTO:
29930b57cec5SDimitry Andric       S = new (Context) GotoStmt(Empty);
29940b57cec5SDimitry Andric       break;
29950b57cec5SDimitry Andric 
29960b57cec5SDimitry Andric     case STMT_INDIRECT_GOTO:
29970b57cec5SDimitry Andric       S = new (Context) IndirectGotoStmt(Empty);
29980b57cec5SDimitry Andric       break;
29990b57cec5SDimitry Andric 
30000b57cec5SDimitry Andric     case STMT_CONTINUE:
30010b57cec5SDimitry Andric       S = new (Context) ContinueStmt(Empty);
30020b57cec5SDimitry Andric       break;
30030b57cec5SDimitry Andric 
30040b57cec5SDimitry Andric     case STMT_BREAK:
30050b57cec5SDimitry Andric       S = new (Context) BreakStmt(Empty);
30060b57cec5SDimitry Andric       break;
30070b57cec5SDimitry Andric 
30080b57cec5SDimitry Andric     case STMT_RETURN:
30090b57cec5SDimitry Andric       S = ReturnStmt::CreateEmpty(
30100b57cec5SDimitry Andric           Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
30110b57cec5SDimitry Andric       break;
30120b57cec5SDimitry Andric 
30130b57cec5SDimitry Andric     case STMT_DECL:
30140b57cec5SDimitry Andric       S = new (Context) DeclStmt(Empty);
30150b57cec5SDimitry Andric       break;
30160b57cec5SDimitry Andric 
30170b57cec5SDimitry Andric     case STMT_GCCASM:
30180b57cec5SDimitry Andric       S = new (Context) GCCAsmStmt(Empty);
30190b57cec5SDimitry Andric       break;
30200b57cec5SDimitry Andric 
30210b57cec5SDimitry Andric     case STMT_MSASM:
30220b57cec5SDimitry Andric       S = new (Context) MSAsmStmt(Empty);
30230b57cec5SDimitry Andric       break;
30240b57cec5SDimitry Andric 
30250b57cec5SDimitry Andric     case STMT_CAPTURED:
30260b57cec5SDimitry Andric       S = CapturedStmt::CreateDeserialized(
30270b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields]);
30280b57cec5SDimitry Andric       break;
30290b57cec5SDimitry Andric 
30300b57cec5SDimitry Andric     case EXPR_CONSTANT:
30310b57cec5SDimitry Andric       S = ConstantExpr::CreateEmpty(
30325f757f3fSDimitry Andric           Context, static_cast<ConstantResultStorageKind>(
30335ffd83dbSDimitry Andric                        /*StorageKind=*/Record[ASTStmtReader::NumExprFields]));
30340b57cec5SDimitry Andric       break;
30350b57cec5SDimitry Andric 
3036fe6060f1SDimitry Andric     case EXPR_SYCL_UNIQUE_STABLE_NAME:
3037fe6060f1SDimitry Andric       S = SYCLUniqueStableNameExpr::CreateEmpty(Context);
3038fe6060f1SDimitry Andric       break;
3039fe6060f1SDimitry Andric 
30400b57cec5SDimitry Andric     case EXPR_PREDEFINED:
30410b57cec5SDimitry Andric       S = PredefinedExpr::CreateEmpty(
30420b57cec5SDimitry Andric           Context,
30430b57cec5SDimitry Andric           /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
30440b57cec5SDimitry Andric       break;
30450b57cec5SDimitry Andric 
3046cb14a3feSDimitry Andric     case EXPR_DECL_REF: {
3047cb14a3feSDimitry Andric       BitsUnpacker DeclRefExprBits(Record[ASTStmtReader::NumExprFields]);
3048cb14a3feSDimitry Andric       DeclRefExprBits.advance(5);
3049cb14a3feSDimitry Andric       bool HasFoundDecl = DeclRefExprBits.getNextBit();
3050cb14a3feSDimitry Andric       bool HasQualifier = DeclRefExprBits.getNextBit();
3051cb14a3feSDimitry Andric       bool HasTemplateKWAndArgsInfo = DeclRefExprBits.getNextBit();
3052cb14a3feSDimitry Andric       unsigned NumTemplateArgs = HasTemplateKWAndArgsInfo
3053cb14a3feSDimitry Andric                                      ? Record[ASTStmtReader::NumExprFields + 1]
3054cb14a3feSDimitry Andric                                      : 0;
3055cb14a3feSDimitry Andric       S = DeclRefExpr::CreateEmpty(Context, HasQualifier, HasFoundDecl,
3056cb14a3feSDimitry Andric                                    HasTemplateKWAndArgsInfo, NumTemplateArgs);
30570b57cec5SDimitry Andric       break;
3058cb14a3feSDimitry Andric     }
30590b57cec5SDimitry Andric 
30600b57cec5SDimitry Andric     case EXPR_INTEGER_LITERAL:
30610b57cec5SDimitry Andric       S = IntegerLiteral::Create(Context, Empty);
30620b57cec5SDimitry Andric       break;
30630b57cec5SDimitry Andric 
30645ffd83dbSDimitry Andric     case EXPR_FIXEDPOINT_LITERAL:
30655ffd83dbSDimitry Andric       S = FixedPointLiteral::Create(Context, Empty);
30665ffd83dbSDimitry Andric       break;
30675ffd83dbSDimitry Andric 
30680b57cec5SDimitry Andric     case EXPR_FLOATING_LITERAL:
30690b57cec5SDimitry Andric       S = FloatingLiteral::Create(Context, Empty);
30700b57cec5SDimitry Andric       break;
30710b57cec5SDimitry Andric 
30720b57cec5SDimitry Andric     case EXPR_IMAGINARY_LITERAL:
30730b57cec5SDimitry Andric       S = new (Context) ImaginaryLiteral(Empty);
30740b57cec5SDimitry Andric       break;
30750b57cec5SDimitry Andric 
30760b57cec5SDimitry Andric     case EXPR_STRING_LITERAL:
30770b57cec5SDimitry Andric       S = StringLiteral::CreateEmpty(
30780b57cec5SDimitry Andric           Context,
30790b57cec5SDimitry Andric           /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
30800b57cec5SDimitry Andric           /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
30810b57cec5SDimitry Andric           /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
30820b57cec5SDimitry Andric       break;
30830b57cec5SDimitry Andric 
30840b57cec5SDimitry Andric     case EXPR_CHARACTER_LITERAL:
30850b57cec5SDimitry Andric       S = new (Context) CharacterLiteral(Empty);
30860b57cec5SDimitry Andric       break;
30870b57cec5SDimitry Andric 
30880b57cec5SDimitry Andric     case EXPR_PAREN:
30890b57cec5SDimitry Andric       S = new (Context) ParenExpr(Empty);
30900b57cec5SDimitry Andric       break;
30910b57cec5SDimitry Andric 
30920b57cec5SDimitry Andric     case EXPR_PAREN_LIST:
30930b57cec5SDimitry Andric       S = ParenListExpr::CreateEmpty(
30940b57cec5SDimitry Andric           Context,
30950b57cec5SDimitry Andric           /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
30960b57cec5SDimitry Andric       break;
30970b57cec5SDimitry Andric 
3098cb14a3feSDimitry Andric     case EXPR_UNARY_OPERATOR: {
3099cb14a3feSDimitry Andric       BitsUnpacker UnaryOperatorBits(Record[ASTStmtReader::NumStmtFields]);
3100cb14a3feSDimitry Andric       UnaryOperatorBits.advance(ASTStmtReader::NumExprBits);
3101cb14a3feSDimitry Andric       bool HasFPFeatures = UnaryOperatorBits.getNextBit();
3102cb14a3feSDimitry Andric       S = UnaryOperator::CreateEmpty(Context, HasFPFeatures);
31030b57cec5SDimitry Andric       break;
3104cb14a3feSDimitry Andric     }
31050b57cec5SDimitry Andric 
31060b57cec5SDimitry Andric     case EXPR_OFFSETOF:
31070b57cec5SDimitry Andric       S = OffsetOfExpr::CreateEmpty(Context,
31080b57cec5SDimitry Andric                                     Record[ASTStmtReader::NumExprFields],
31090b57cec5SDimitry Andric                                     Record[ASTStmtReader::NumExprFields + 1]);
31100b57cec5SDimitry Andric       break;
31110b57cec5SDimitry Andric 
31120b57cec5SDimitry Andric     case EXPR_SIZEOF_ALIGN_OF:
31130b57cec5SDimitry Andric       S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
31140b57cec5SDimitry Andric       break;
31150b57cec5SDimitry Andric 
31160b57cec5SDimitry Andric     case EXPR_ARRAY_SUBSCRIPT:
31170b57cec5SDimitry Andric       S = new (Context) ArraySubscriptExpr(Empty);
31180b57cec5SDimitry Andric       break;
31190b57cec5SDimitry Andric 
31205ffd83dbSDimitry Andric     case EXPR_MATRIX_SUBSCRIPT:
31215ffd83dbSDimitry Andric       S = new (Context) MatrixSubscriptExpr(Empty);
31225ffd83dbSDimitry Andric       break;
31235ffd83dbSDimitry Andric 
3124*0fca6ea1SDimitry Andric     case EXPR_ARRAY_SECTION:
3125*0fca6ea1SDimitry Andric       S = new (Context) ArraySectionExpr(Empty);
31260b57cec5SDimitry Andric       break;
31270b57cec5SDimitry Andric 
31285ffd83dbSDimitry Andric     case EXPR_OMP_ARRAY_SHAPING:
31295ffd83dbSDimitry Andric       S = OMPArrayShapingExpr::CreateEmpty(
31305ffd83dbSDimitry Andric           Context, Record[ASTStmtReader::NumExprFields]);
31315ffd83dbSDimitry Andric       break;
31325ffd83dbSDimitry Andric 
31335ffd83dbSDimitry Andric     case EXPR_OMP_ITERATOR:
31345ffd83dbSDimitry Andric       S = OMPIteratorExpr::CreateEmpty(Context,
31355ffd83dbSDimitry Andric                                        Record[ASTStmtReader::NumExprFields]);
31365ffd83dbSDimitry Andric       break;
31375ffd83dbSDimitry Andric 
31385f757f3fSDimitry Andric     case EXPR_CALL: {
3139cb14a3feSDimitry Andric       auto NumArgs = Record[ASTStmtReader::NumExprFields];
3140cb14a3feSDimitry Andric       BitsUnpacker CallExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3141cb14a3feSDimitry Andric       CallExprBits.advance(1);
31425f757f3fSDimitry Andric       auto HasFPFeatures = CallExprBits.getNextBit();
31435f757f3fSDimitry Andric       S = CallExpr::CreateEmpty(Context, NumArgs, HasFPFeatures, Empty);
31440b57cec5SDimitry Andric       break;
31455f757f3fSDimitry Andric     }
31460b57cec5SDimitry Andric 
31475ffd83dbSDimitry Andric     case EXPR_RECOVERY:
31485ffd83dbSDimitry Andric       S = RecoveryExpr::CreateEmpty(
31495ffd83dbSDimitry Andric           Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
31505ffd83dbSDimitry Andric       break;
31515ffd83dbSDimitry Andric 
3152cb14a3feSDimitry Andric     case EXPR_MEMBER: {
3153cb14a3feSDimitry Andric       BitsUnpacker ExprMemberBits(Record[ASTStmtReader::NumExprFields]);
3154cb14a3feSDimitry Andric       bool HasQualifier = ExprMemberBits.getNextBit();
3155cb14a3feSDimitry Andric       bool HasFoundDecl = ExprMemberBits.getNextBit();
3156cb14a3feSDimitry Andric       bool HasTemplateInfo = ExprMemberBits.getNextBit();
3157cb14a3feSDimitry Andric       unsigned NumTemplateArgs = Record[ASTStmtReader::NumExprFields + 1];
3158cb14a3feSDimitry Andric       S = MemberExpr::CreateEmpty(Context, HasQualifier, HasFoundDecl,
3159cb14a3feSDimitry Andric                                   HasTemplateInfo, NumTemplateArgs);
31600b57cec5SDimitry Andric       break;
3161cb14a3feSDimitry Andric     }
31620b57cec5SDimitry Andric 
3163cb14a3feSDimitry Andric     case EXPR_BINARY_OPERATOR: {
3164cb14a3feSDimitry Andric       BitsUnpacker BinaryOperatorBits(Record[ASTStmtReader::NumExprFields]);
3165cb14a3feSDimitry Andric       BinaryOperatorBits.advance(/*Size of opcode*/ 6);
3166cb14a3feSDimitry Andric       bool HasFPFeatures = BinaryOperatorBits.getNextBit();
3167cb14a3feSDimitry Andric       S = BinaryOperator::CreateEmpty(Context, HasFPFeatures);
31680b57cec5SDimitry Andric       break;
3169cb14a3feSDimitry Andric     }
31700b57cec5SDimitry Andric 
3171cb14a3feSDimitry Andric     case EXPR_COMPOUND_ASSIGN_OPERATOR: {
3172cb14a3feSDimitry Andric       BitsUnpacker BinaryOperatorBits(Record[ASTStmtReader::NumExprFields]);
3173cb14a3feSDimitry Andric       BinaryOperatorBits.advance(/*Size of opcode*/ 6);
3174cb14a3feSDimitry Andric       bool HasFPFeatures = BinaryOperatorBits.getNextBit();
3175cb14a3feSDimitry Andric       S = CompoundAssignOperator::CreateEmpty(Context, HasFPFeatures);
31760b57cec5SDimitry Andric       break;
3177cb14a3feSDimitry Andric     }
31780b57cec5SDimitry Andric 
31790b57cec5SDimitry Andric     case EXPR_CONDITIONAL_OPERATOR:
31800b57cec5SDimitry Andric       S = new (Context) ConditionalOperator(Empty);
31810b57cec5SDimitry Andric       break;
31820b57cec5SDimitry Andric 
31830b57cec5SDimitry Andric     case EXPR_BINARY_CONDITIONAL_OPERATOR:
31840b57cec5SDimitry Andric       S = new (Context) BinaryConditionalOperator(Empty);
31850b57cec5SDimitry Andric       break;
31860b57cec5SDimitry Andric 
3187cb14a3feSDimitry Andric     case EXPR_IMPLICIT_CAST: {
3188cb14a3feSDimitry Andric       unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3189cb14a3feSDimitry Andric       BitsUnpacker CastExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3190cb14a3feSDimitry Andric       CastExprBits.advance(7);
3191cb14a3feSDimitry Andric       bool HasFPFeatures = CastExprBits.getNextBit();
3192cb14a3feSDimitry Andric       S = ImplicitCastExpr::CreateEmpty(Context, PathSize, HasFPFeatures);
31930b57cec5SDimitry Andric       break;
3194cb14a3feSDimitry Andric     }
31950b57cec5SDimitry Andric 
3196cb14a3feSDimitry Andric     case EXPR_CSTYLE_CAST: {
3197cb14a3feSDimitry Andric       unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3198cb14a3feSDimitry Andric       BitsUnpacker CastExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3199cb14a3feSDimitry Andric       CastExprBits.advance(7);
3200cb14a3feSDimitry Andric       bool HasFPFeatures = CastExprBits.getNextBit();
3201cb14a3feSDimitry Andric       S = CStyleCastExpr::CreateEmpty(Context, PathSize, HasFPFeatures);
32020b57cec5SDimitry Andric       break;
3203cb14a3feSDimitry Andric     }
32040b57cec5SDimitry Andric 
32050b57cec5SDimitry Andric     case EXPR_COMPOUND_LITERAL:
32060b57cec5SDimitry Andric       S = new (Context) CompoundLiteralExpr(Empty);
32070b57cec5SDimitry Andric       break;
32080b57cec5SDimitry Andric 
32090b57cec5SDimitry Andric     case EXPR_EXT_VECTOR_ELEMENT:
32100b57cec5SDimitry Andric       S = new (Context) ExtVectorElementExpr(Empty);
32110b57cec5SDimitry Andric       break;
32120b57cec5SDimitry Andric 
32130b57cec5SDimitry Andric     case EXPR_INIT_LIST:
32140b57cec5SDimitry Andric       S = new (Context) InitListExpr(Empty);
32150b57cec5SDimitry Andric       break;
32160b57cec5SDimitry Andric 
32170b57cec5SDimitry Andric     case EXPR_DESIGNATED_INIT:
32180b57cec5SDimitry Andric       S = DesignatedInitExpr::CreateEmpty(Context,
32190b57cec5SDimitry Andric                                      Record[ASTStmtReader::NumExprFields] - 1);
32200b57cec5SDimitry Andric 
32210b57cec5SDimitry Andric       break;
32220b57cec5SDimitry Andric 
32230b57cec5SDimitry Andric     case EXPR_DESIGNATED_INIT_UPDATE:
32240b57cec5SDimitry Andric       S = new (Context) DesignatedInitUpdateExpr(Empty);
32250b57cec5SDimitry Andric       break;
32260b57cec5SDimitry Andric 
32270b57cec5SDimitry Andric     case EXPR_IMPLICIT_VALUE_INIT:
32280b57cec5SDimitry Andric       S = new (Context) ImplicitValueInitExpr(Empty);
32290b57cec5SDimitry Andric       break;
32300b57cec5SDimitry Andric 
32310b57cec5SDimitry Andric     case EXPR_NO_INIT:
32320b57cec5SDimitry Andric       S = new (Context) NoInitExpr(Empty);
32330b57cec5SDimitry Andric       break;
32340b57cec5SDimitry Andric 
32350b57cec5SDimitry Andric     case EXPR_ARRAY_INIT_LOOP:
32360b57cec5SDimitry Andric       S = new (Context) ArrayInitLoopExpr(Empty);
32370b57cec5SDimitry Andric       break;
32380b57cec5SDimitry Andric 
32390b57cec5SDimitry Andric     case EXPR_ARRAY_INIT_INDEX:
32400b57cec5SDimitry Andric       S = new (Context) ArrayInitIndexExpr(Empty);
32410b57cec5SDimitry Andric       break;
32420b57cec5SDimitry Andric 
32430b57cec5SDimitry Andric     case EXPR_VA_ARG:
32440b57cec5SDimitry Andric       S = new (Context) VAArgExpr(Empty);
32450b57cec5SDimitry Andric       break;
32460b57cec5SDimitry Andric 
32470b57cec5SDimitry Andric     case EXPR_SOURCE_LOC:
32480b57cec5SDimitry Andric       S = new (Context) SourceLocExpr(Empty);
32490b57cec5SDimitry Andric       break;
32500b57cec5SDimitry Andric 
3251*0fca6ea1SDimitry Andric     case EXPR_BUILTIN_PP_EMBED:
3252*0fca6ea1SDimitry Andric       S = new (Context) EmbedExpr(Empty);
3253*0fca6ea1SDimitry Andric       break;
3254*0fca6ea1SDimitry Andric 
32550b57cec5SDimitry Andric     case EXPR_ADDR_LABEL:
32560b57cec5SDimitry Andric       S = new (Context) AddrLabelExpr(Empty);
32570b57cec5SDimitry Andric       break;
32580b57cec5SDimitry Andric 
32590b57cec5SDimitry Andric     case EXPR_STMT:
32600b57cec5SDimitry Andric       S = new (Context) StmtExpr(Empty);
32610b57cec5SDimitry Andric       break;
32620b57cec5SDimitry Andric 
32630b57cec5SDimitry Andric     case EXPR_CHOOSE:
32640b57cec5SDimitry Andric       S = new (Context) ChooseExpr(Empty);
32650b57cec5SDimitry Andric       break;
32660b57cec5SDimitry Andric 
32670b57cec5SDimitry Andric     case EXPR_GNU_NULL:
32680b57cec5SDimitry Andric       S = new (Context) GNUNullExpr(Empty);
32690b57cec5SDimitry Andric       break;
32700b57cec5SDimitry Andric 
32710b57cec5SDimitry Andric     case EXPR_SHUFFLE_VECTOR:
32720b57cec5SDimitry Andric       S = new (Context) ShuffleVectorExpr(Empty);
32730b57cec5SDimitry Andric       break;
32740b57cec5SDimitry Andric 
32750b57cec5SDimitry Andric     case EXPR_CONVERT_VECTOR:
32760b57cec5SDimitry Andric       S = new (Context) ConvertVectorExpr(Empty);
32770b57cec5SDimitry Andric       break;
32780b57cec5SDimitry Andric 
32790b57cec5SDimitry Andric     case EXPR_BLOCK:
32800b57cec5SDimitry Andric       S = new (Context) BlockExpr(Empty);
32810b57cec5SDimitry Andric       break;
32820b57cec5SDimitry Andric 
32830b57cec5SDimitry Andric     case EXPR_GENERIC_SELECTION:
32840b57cec5SDimitry Andric       S = GenericSelectionExpr::CreateEmpty(
32850b57cec5SDimitry Andric           Context,
32860b57cec5SDimitry Andric           /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
32870b57cec5SDimitry Andric       break;
32880b57cec5SDimitry Andric 
32890b57cec5SDimitry Andric     case EXPR_OBJC_STRING_LITERAL:
32900b57cec5SDimitry Andric       S = new (Context) ObjCStringLiteral(Empty);
32910b57cec5SDimitry Andric       break;
32920b57cec5SDimitry Andric 
32930b57cec5SDimitry Andric     case EXPR_OBJC_BOXED_EXPRESSION:
32940b57cec5SDimitry Andric       S = new (Context) ObjCBoxedExpr(Empty);
32950b57cec5SDimitry Andric       break;
32960b57cec5SDimitry Andric 
32970b57cec5SDimitry Andric     case EXPR_OBJC_ARRAY_LITERAL:
32980b57cec5SDimitry Andric       S = ObjCArrayLiteral::CreateEmpty(Context,
32990b57cec5SDimitry Andric                                         Record[ASTStmtReader::NumExprFields]);
33000b57cec5SDimitry Andric       break;
33010b57cec5SDimitry Andric 
33020b57cec5SDimitry Andric     case EXPR_OBJC_DICTIONARY_LITERAL:
33030b57cec5SDimitry Andric       S = ObjCDictionaryLiteral::CreateEmpty(Context,
33040b57cec5SDimitry Andric             Record[ASTStmtReader::NumExprFields],
33050b57cec5SDimitry Andric             Record[ASTStmtReader::NumExprFields + 1]);
33060b57cec5SDimitry Andric       break;
33070b57cec5SDimitry Andric 
33080b57cec5SDimitry Andric     case EXPR_OBJC_ENCODE:
33090b57cec5SDimitry Andric       S = new (Context) ObjCEncodeExpr(Empty);
33100b57cec5SDimitry Andric       break;
33110b57cec5SDimitry Andric 
33120b57cec5SDimitry Andric     case EXPR_OBJC_SELECTOR_EXPR:
33130b57cec5SDimitry Andric       S = new (Context) ObjCSelectorExpr(Empty);
33140b57cec5SDimitry Andric       break;
33150b57cec5SDimitry Andric 
33160b57cec5SDimitry Andric     case EXPR_OBJC_PROTOCOL_EXPR:
33170b57cec5SDimitry Andric       S = new (Context) ObjCProtocolExpr(Empty);
33180b57cec5SDimitry Andric       break;
33190b57cec5SDimitry Andric 
33200b57cec5SDimitry Andric     case EXPR_OBJC_IVAR_REF_EXPR:
33210b57cec5SDimitry Andric       S = new (Context) ObjCIvarRefExpr(Empty);
33220b57cec5SDimitry Andric       break;
33230b57cec5SDimitry Andric 
33240b57cec5SDimitry Andric     case EXPR_OBJC_PROPERTY_REF_EXPR:
33250b57cec5SDimitry Andric       S = new (Context) ObjCPropertyRefExpr(Empty);
33260b57cec5SDimitry Andric       break;
33270b57cec5SDimitry Andric 
33280b57cec5SDimitry Andric     case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
33290b57cec5SDimitry Andric       S = new (Context) ObjCSubscriptRefExpr(Empty);
33300b57cec5SDimitry Andric       break;
33310b57cec5SDimitry Andric 
33320b57cec5SDimitry Andric     case EXPR_OBJC_KVC_REF_EXPR:
33330b57cec5SDimitry Andric       llvm_unreachable("mismatching AST file");
33340b57cec5SDimitry Andric 
33350b57cec5SDimitry Andric     case EXPR_OBJC_MESSAGE_EXPR:
33360b57cec5SDimitry Andric       S = ObjCMessageExpr::CreateEmpty(Context,
33370b57cec5SDimitry Andric                                      Record[ASTStmtReader::NumExprFields],
33380b57cec5SDimitry Andric                                      Record[ASTStmtReader::NumExprFields + 1]);
33390b57cec5SDimitry Andric       break;
33400b57cec5SDimitry Andric 
33410b57cec5SDimitry Andric     case EXPR_OBJC_ISA:
33420b57cec5SDimitry Andric       S = new (Context) ObjCIsaExpr(Empty);
33430b57cec5SDimitry Andric       break;
33440b57cec5SDimitry Andric 
33450b57cec5SDimitry Andric     case EXPR_OBJC_INDIRECT_COPY_RESTORE:
33460b57cec5SDimitry Andric       S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
33470b57cec5SDimitry Andric       break;
33480b57cec5SDimitry Andric 
33490b57cec5SDimitry Andric     case EXPR_OBJC_BRIDGED_CAST:
33500b57cec5SDimitry Andric       S = new (Context) ObjCBridgedCastExpr(Empty);
33510b57cec5SDimitry Andric       break;
33520b57cec5SDimitry Andric 
33530b57cec5SDimitry Andric     case STMT_OBJC_FOR_COLLECTION:
33540b57cec5SDimitry Andric       S = new (Context) ObjCForCollectionStmt(Empty);
33550b57cec5SDimitry Andric       break;
33560b57cec5SDimitry Andric 
33570b57cec5SDimitry Andric     case STMT_OBJC_CATCH:
33580b57cec5SDimitry Andric       S = new (Context) ObjCAtCatchStmt(Empty);
33590b57cec5SDimitry Andric       break;
33600b57cec5SDimitry Andric 
33610b57cec5SDimitry Andric     case STMT_OBJC_FINALLY:
33620b57cec5SDimitry Andric       S = new (Context) ObjCAtFinallyStmt(Empty);
33630b57cec5SDimitry Andric       break;
33640b57cec5SDimitry Andric 
33650b57cec5SDimitry Andric     case STMT_OBJC_AT_TRY:
33660b57cec5SDimitry Andric       S = ObjCAtTryStmt::CreateEmpty(Context,
33670b57cec5SDimitry Andric                                      Record[ASTStmtReader::NumStmtFields],
33680b57cec5SDimitry Andric                                      Record[ASTStmtReader::NumStmtFields + 1]);
33690b57cec5SDimitry Andric       break;
33700b57cec5SDimitry Andric 
33710b57cec5SDimitry Andric     case STMT_OBJC_AT_SYNCHRONIZED:
33720b57cec5SDimitry Andric       S = new (Context) ObjCAtSynchronizedStmt(Empty);
33730b57cec5SDimitry Andric       break;
33740b57cec5SDimitry Andric 
33750b57cec5SDimitry Andric     case STMT_OBJC_AT_THROW:
33760b57cec5SDimitry Andric       S = new (Context) ObjCAtThrowStmt(Empty);
33770b57cec5SDimitry Andric       break;
33780b57cec5SDimitry Andric 
33790b57cec5SDimitry Andric     case STMT_OBJC_AUTORELEASE_POOL:
33800b57cec5SDimitry Andric       S = new (Context) ObjCAutoreleasePoolStmt(Empty);
33810b57cec5SDimitry Andric       break;
33820b57cec5SDimitry Andric 
33830b57cec5SDimitry Andric     case EXPR_OBJC_BOOL_LITERAL:
33840b57cec5SDimitry Andric       S = new (Context) ObjCBoolLiteralExpr(Empty);
33850b57cec5SDimitry Andric       break;
33860b57cec5SDimitry Andric 
33870b57cec5SDimitry Andric     case EXPR_OBJC_AVAILABILITY_CHECK:
33880b57cec5SDimitry Andric       S = new (Context) ObjCAvailabilityCheckExpr(Empty);
33890b57cec5SDimitry Andric       break;
33900b57cec5SDimitry Andric 
33910b57cec5SDimitry Andric     case STMT_SEH_LEAVE:
33920b57cec5SDimitry Andric       S = new (Context) SEHLeaveStmt(Empty);
33930b57cec5SDimitry Andric       break;
33940b57cec5SDimitry Andric 
33950b57cec5SDimitry Andric     case STMT_SEH_EXCEPT:
33960b57cec5SDimitry Andric       S = new (Context) SEHExceptStmt(Empty);
33970b57cec5SDimitry Andric       break;
33980b57cec5SDimitry Andric 
33990b57cec5SDimitry Andric     case STMT_SEH_FINALLY:
34000b57cec5SDimitry Andric       S = new (Context) SEHFinallyStmt(Empty);
34010b57cec5SDimitry Andric       break;
34020b57cec5SDimitry Andric 
34030b57cec5SDimitry Andric     case STMT_SEH_TRY:
34040b57cec5SDimitry Andric       S = new (Context) SEHTryStmt(Empty);
34050b57cec5SDimitry Andric       break;
34060b57cec5SDimitry Andric 
34070b57cec5SDimitry Andric     case STMT_CXX_CATCH:
34080b57cec5SDimitry Andric       S = new (Context) CXXCatchStmt(Empty);
34090b57cec5SDimitry Andric       break;
34100b57cec5SDimitry Andric 
34110b57cec5SDimitry Andric     case STMT_CXX_TRY:
34120b57cec5SDimitry Andric       S = CXXTryStmt::Create(Context, Empty,
34130b57cec5SDimitry Andric              /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
34140b57cec5SDimitry Andric       break;
34150b57cec5SDimitry Andric 
34160b57cec5SDimitry Andric     case STMT_CXX_FOR_RANGE:
34170b57cec5SDimitry Andric       S = new (Context) CXXForRangeStmt(Empty);
34180b57cec5SDimitry Andric       break;
34190b57cec5SDimitry Andric 
34200b57cec5SDimitry Andric     case STMT_MS_DEPENDENT_EXISTS:
34210b57cec5SDimitry Andric       S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
34220b57cec5SDimitry Andric                                               NestedNameSpecifierLoc(),
34230b57cec5SDimitry Andric                                               DeclarationNameInfo(),
34240b57cec5SDimitry Andric                                               nullptr);
34250b57cec5SDimitry Andric       break;
34260b57cec5SDimitry Andric 
3427fe6060f1SDimitry Andric     case STMT_OMP_CANONICAL_LOOP:
3428fe6060f1SDimitry Andric       S = OMPCanonicalLoop::createEmpty(Context);
3429fe6060f1SDimitry Andric       break;
3430fe6060f1SDimitry Andric 
3431349cc55cSDimitry Andric     case STMT_OMP_META_DIRECTIVE:
3432349cc55cSDimitry Andric       S = OMPMetaDirective::CreateEmpty(
3433349cc55cSDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3434349cc55cSDimitry Andric       break;
3435349cc55cSDimitry Andric 
34360b57cec5SDimitry Andric     case STMT_OMP_PARALLEL_DIRECTIVE:
34370b57cec5SDimitry Andric       S =
34380b57cec5SDimitry Andric         OMPParallelDirective::CreateEmpty(Context,
34390b57cec5SDimitry Andric                                           Record[ASTStmtReader::NumStmtFields],
34400b57cec5SDimitry Andric                                           Empty);
34410b57cec5SDimitry Andric       break;
34420b57cec5SDimitry Andric 
34430b57cec5SDimitry Andric     case STMT_OMP_SIMD_DIRECTIVE: {
3444e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3445e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
34460b57cec5SDimitry Andric       S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
34470b57cec5SDimitry Andric                                         CollapsedNum, Empty);
34480b57cec5SDimitry Andric       break;
34490b57cec5SDimitry Andric     }
34500b57cec5SDimitry Andric 
3451fe6060f1SDimitry Andric     case STMT_OMP_TILE_DIRECTIVE: {
3452fe6060f1SDimitry Andric       unsigned NumLoops = Record[ASTStmtReader::NumStmtFields];
3453fe6060f1SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3454fe6060f1SDimitry Andric       S = OMPTileDirective::CreateEmpty(Context, NumClauses, NumLoops);
3455fe6060f1SDimitry Andric       break;
3456fe6060f1SDimitry Andric     }
3457fe6060f1SDimitry Andric 
3458fe6060f1SDimitry Andric     case STMT_OMP_UNROLL_DIRECTIVE: {
3459fe6060f1SDimitry Andric       assert(Record[ASTStmtReader::NumStmtFields] == 1 && "Unroll directive accepts only a single loop");
3460fe6060f1SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3461fe6060f1SDimitry Andric       S = OMPUnrollDirective::CreateEmpty(Context, NumClauses);
3462fe6060f1SDimitry Andric       break;
3463fe6060f1SDimitry Andric     }
3464fe6060f1SDimitry Andric 
3465*0fca6ea1SDimitry Andric     case STMT_OMP_REVERSE_DIRECTIVE: {
3466*0fca6ea1SDimitry Andric       assert(Record[ASTStmtReader::NumStmtFields] == 1 &&
3467*0fca6ea1SDimitry Andric              "Reverse directive accepts only a single loop");
3468*0fca6ea1SDimitry Andric       assert(Record[ASTStmtReader::NumStmtFields + 1] == 0 &&
3469*0fca6ea1SDimitry Andric              "Reverse directive has no clauses");
3470*0fca6ea1SDimitry Andric       S = OMPReverseDirective::CreateEmpty(Context);
3471*0fca6ea1SDimitry Andric       break;
3472*0fca6ea1SDimitry Andric     }
3473*0fca6ea1SDimitry Andric 
3474*0fca6ea1SDimitry Andric     case STMT_OMP_INTERCHANGE_DIRECTIVE: {
3475*0fca6ea1SDimitry Andric       unsigned NumLoops = Record[ASTStmtReader::NumStmtFields];
3476*0fca6ea1SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3477*0fca6ea1SDimitry Andric       S = OMPInterchangeDirective::CreateEmpty(Context, NumClauses, NumLoops);
3478*0fca6ea1SDimitry Andric       break;
3479*0fca6ea1SDimitry Andric     }
3480*0fca6ea1SDimitry Andric 
34810b57cec5SDimitry Andric     case STMT_OMP_FOR_DIRECTIVE: {
3482e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3483e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
34840b57cec5SDimitry Andric       S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
34850b57cec5SDimitry Andric                                        Empty);
34860b57cec5SDimitry Andric       break;
34870b57cec5SDimitry Andric     }
34880b57cec5SDimitry Andric 
34890b57cec5SDimitry Andric     case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3490e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3491e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
34920b57cec5SDimitry Andric       S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
34930b57cec5SDimitry Andric                                            Empty);
34940b57cec5SDimitry Andric       break;
34950b57cec5SDimitry Andric     }
34960b57cec5SDimitry Andric 
34970b57cec5SDimitry Andric     case STMT_OMP_SECTIONS_DIRECTIVE:
34980b57cec5SDimitry Andric       S = OMPSectionsDirective::CreateEmpty(
34990b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
35000b57cec5SDimitry Andric       break;
35010b57cec5SDimitry Andric 
35020b57cec5SDimitry Andric     case STMT_OMP_SECTION_DIRECTIVE:
35030b57cec5SDimitry Andric       S = OMPSectionDirective::CreateEmpty(Context, Empty);
35040b57cec5SDimitry Andric       break;
35050b57cec5SDimitry Andric 
35065f757f3fSDimitry Andric     case STMT_OMP_SCOPE_DIRECTIVE:
35075f757f3fSDimitry Andric       S = OMPScopeDirective::CreateEmpty(
35085f757f3fSDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
35095f757f3fSDimitry Andric       break;
35105f757f3fSDimitry Andric 
35110b57cec5SDimitry Andric     case STMT_OMP_SINGLE_DIRECTIVE:
35120b57cec5SDimitry Andric       S = OMPSingleDirective::CreateEmpty(
35130b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
35140b57cec5SDimitry Andric       break;
35150b57cec5SDimitry Andric 
35160b57cec5SDimitry Andric     case STMT_OMP_MASTER_DIRECTIVE:
35170b57cec5SDimitry Andric       S = OMPMasterDirective::CreateEmpty(Context, Empty);
35180b57cec5SDimitry Andric       break;
35190b57cec5SDimitry Andric 
35200b57cec5SDimitry Andric     case STMT_OMP_CRITICAL_DIRECTIVE:
35210b57cec5SDimitry Andric       S = OMPCriticalDirective::CreateEmpty(
35220b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
35230b57cec5SDimitry Andric       break;
35240b57cec5SDimitry Andric 
35250b57cec5SDimitry Andric     case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3526e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3527e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
35280b57cec5SDimitry Andric       S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
35290b57cec5SDimitry Andric                                                CollapsedNum, Empty);
35300b57cec5SDimitry Andric       break;
35310b57cec5SDimitry Andric     }
35320b57cec5SDimitry Andric 
35330b57cec5SDimitry Andric     case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3534e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3535e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
35360b57cec5SDimitry Andric       S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
35370b57cec5SDimitry Andric                                                    CollapsedNum, Empty);
35380b57cec5SDimitry Andric       break;
35390b57cec5SDimitry Andric     }
35400b57cec5SDimitry Andric 
3541480093f4SDimitry Andric     case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3542480093f4SDimitry Andric       S = OMPParallelMasterDirective::CreateEmpty(
3543480093f4SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3544480093f4SDimitry Andric       break;
3545480093f4SDimitry Andric 
354681ad6265SDimitry Andric     case STMT_OMP_PARALLEL_MASKED_DIRECTIVE:
354781ad6265SDimitry Andric       S = OMPParallelMaskedDirective::CreateEmpty(
354881ad6265SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
354981ad6265SDimitry Andric       break;
355081ad6265SDimitry Andric 
35510b57cec5SDimitry Andric     case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
35520b57cec5SDimitry Andric       S = OMPParallelSectionsDirective::CreateEmpty(
35530b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
35540b57cec5SDimitry Andric       break;
35550b57cec5SDimitry Andric 
35560b57cec5SDimitry Andric     case STMT_OMP_TASK_DIRECTIVE:
35570b57cec5SDimitry Andric       S = OMPTaskDirective::CreateEmpty(
35580b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
35590b57cec5SDimitry Andric       break;
35600b57cec5SDimitry Andric 
35610b57cec5SDimitry Andric     case STMT_OMP_TASKYIELD_DIRECTIVE:
35620b57cec5SDimitry Andric       S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
35630b57cec5SDimitry Andric       break;
35640b57cec5SDimitry Andric 
35650b57cec5SDimitry Andric     case STMT_OMP_BARRIER_DIRECTIVE:
35660b57cec5SDimitry Andric       S = OMPBarrierDirective::CreateEmpty(Context, Empty);
35670b57cec5SDimitry Andric       break;
35680b57cec5SDimitry Andric 
35690b57cec5SDimitry Andric     case STMT_OMP_TASKWAIT_DIRECTIVE:
3570349cc55cSDimitry Andric       S = OMPTaskwaitDirective::CreateEmpty(
3571349cc55cSDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
35720b57cec5SDimitry Andric       break;
35730b57cec5SDimitry Andric 
3574bdd1243dSDimitry Andric     case STMT_OMP_ERROR_DIRECTIVE:
3575bdd1243dSDimitry Andric       S = OMPErrorDirective::CreateEmpty(
3576bdd1243dSDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3577bdd1243dSDimitry Andric       break;
3578bdd1243dSDimitry Andric 
35790b57cec5SDimitry Andric     case STMT_OMP_TASKGROUP_DIRECTIVE:
35800b57cec5SDimitry Andric       S = OMPTaskgroupDirective::CreateEmpty(
35810b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
35820b57cec5SDimitry Andric       break;
35830b57cec5SDimitry Andric 
35840b57cec5SDimitry Andric     case STMT_OMP_FLUSH_DIRECTIVE:
35850b57cec5SDimitry Andric       S = OMPFlushDirective::CreateEmpty(
35860b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
35870b57cec5SDimitry Andric       break;
35880b57cec5SDimitry Andric 
35895ffd83dbSDimitry Andric     case STMT_OMP_DEPOBJ_DIRECTIVE:
35905ffd83dbSDimitry Andric       S = OMPDepobjDirective::CreateEmpty(
35915ffd83dbSDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
35925ffd83dbSDimitry Andric       break;
35935ffd83dbSDimitry Andric 
35945ffd83dbSDimitry Andric     case STMT_OMP_SCAN_DIRECTIVE:
35955ffd83dbSDimitry Andric       S = OMPScanDirective::CreateEmpty(
35965ffd83dbSDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
35975ffd83dbSDimitry Andric       break;
35985ffd83dbSDimitry Andric 
3599e8d8bef9SDimitry Andric     case STMT_OMP_ORDERED_DIRECTIVE: {
3600e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3601e8d8bef9SDimitry Andric       bool HasAssociatedStmt = Record[ASTStmtReader::NumStmtFields + 2];
3602e8d8bef9SDimitry Andric       S = OMPOrderedDirective::CreateEmpty(Context, NumClauses,
3603e8d8bef9SDimitry Andric                                            !HasAssociatedStmt, Empty);
36040b57cec5SDimitry Andric       break;
3605e8d8bef9SDimitry Andric     }
36060b57cec5SDimitry Andric 
36070b57cec5SDimitry Andric     case STMT_OMP_ATOMIC_DIRECTIVE:
36080b57cec5SDimitry Andric       S = OMPAtomicDirective::CreateEmpty(
36090b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
36100b57cec5SDimitry Andric       break;
36110b57cec5SDimitry Andric 
36120b57cec5SDimitry Andric     case STMT_OMP_TARGET_DIRECTIVE:
36130b57cec5SDimitry Andric       S = OMPTargetDirective::CreateEmpty(
36140b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
36150b57cec5SDimitry Andric       break;
36160b57cec5SDimitry Andric 
36170b57cec5SDimitry Andric     case STMT_OMP_TARGET_DATA_DIRECTIVE:
36180b57cec5SDimitry Andric       S = OMPTargetDataDirective::CreateEmpty(
36190b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
36200b57cec5SDimitry Andric       break;
36210b57cec5SDimitry Andric 
36220b57cec5SDimitry Andric     case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
36230b57cec5SDimitry Andric       S = OMPTargetEnterDataDirective::CreateEmpty(
36240b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
36250b57cec5SDimitry Andric       break;
36260b57cec5SDimitry Andric 
36270b57cec5SDimitry Andric     case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
36280b57cec5SDimitry Andric       S = OMPTargetExitDataDirective::CreateEmpty(
36290b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
36300b57cec5SDimitry Andric       break;
36310b57cec5SDimitry Andric 
36320b57cec5SDimitry Andric     case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
36330b57cec5SDimitry Andric       S = OMPTargetParallelDirective::CreateEmpty(
36340b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
36350b57cec5SDimitry Andric       break;
36360b57cec5SDimitry Andric 
36370b57cec5SDimitry Andric     case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3638e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3639e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
36400b57cec5SDimitry Andric       S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
36410b57cec5SDimitry Andric                                                      CollapsedNum, Empty);
36420b57cec5SDimitry Andric       break;
36430b57cec5SDimitry Andric     }
36440b57cec5SDimitry Andric 
36450b57cec5SDimitry Andric     case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
36460b57cec5SDimitry Andric       S = OMPTargetUpdateDirective::CreateEmpty(
36470b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
36480b57cec5SDimitry Andric       break;
36490b57cec5SDimitry Andric 
36500b57cec5SDimitry Andric     case STMT_OMP_TEAMS_DIRECTIVE:
36510b57cec5SDimitry Andric       S = OMPTeamsDirective::CreateEmpty(
36520b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
36530b57cec5SDimitry Andric       break;
36540b57cec5SDimitry Andric 
36550b57cec5SDimitry Andric     case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
36560b57cec5SDimitry Andric       S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
36570b57cec5SDimitry Andric       break;
36580b57cec5SDimitry Andric 
36590b57cec5SDimitry Andric     case STMT_OMP_CANCEL_DIRECTIVE:
36600b57cec5SDimitry Andric       S = OMPCancelDirective::CreateEmpty(
36610b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
36620b57cec5SDimitry Andric       break;
36630b57cec5SDimitry Andric 
36640b57cec5SDimitry Andric     case STMT_OMP_TASKLOOP_DIRECTIVE: {
3665e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3666e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
36670b57cec5SDimitry Andric       S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
36680b57cec5SDimitry Andric                                             Empty);
36690b57cec5SDimitry Andric       break;
36700b57cec5SDimitry Andric     }
36710b57cec5SDimitry Andric 
36720b57cec5SDimitry Andric     case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3673e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3674e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
36750b57cec5SDimitry Andric       S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
36760b57cec5SDimitry Andric                                                 CollapsedNum, Empty);
36770b57cec5SDimitry Andric       break;
36780b57cec5SDimitry Andric     }
36790b57cec5SDimitry Andric 
3680a7dea167SDimitry Andric     case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3681e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3682e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3683a7dea167SDimitry Andric       S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3684a7dea167SDimitry Andric                                                   CollapsedNum, Empty);
3685a7dea167SDimitry Andric       break;
3686a7dea167SDimitry Andric     }
3687a7dea167SDimitry Andric 
368881ad6265SDimitry Andric     case STMT_OMP_MASKED_TASKLOOP_DIRECTIVE: {
368981ad6265SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
369081ad6265SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
369181ad6265SDimitry Andric       S = OMPMaskedTaskLoopDirective::CreateEmpty(Context, NumClauses,
369281ad6265SDimitry Andric                                                   CollapsedNum, Empty);
369381ad6265SDimitry Andric       break;
369481ad6265SDimitry Andric     }
369581ad6265SDimitry Andric 
3696a7dea167SDimitry Andric     case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3697e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3698e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3699a7dea167SDimitry Andric       S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3700a7dea167SDimitry Andric                                                       CollapsedNum, Empty);
3701a7dea167SDimitry Andric       break;
3702a7dea167SDimitry Andric     }
3703a7dea167SDimitry Andric 
370481ad6265SDimitry Andric     case STMT_OMP_MASKED_TASKLOOP_SIMD_DIRECTIVE: {
370581ad6265SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
370681ad6265SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
370781ad6265SDimitry Andric       S = OMPMaskedTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
370881ad6265SDimitry Andric                                                       CollapsedNum, Empty);
370981ad6265SDimitry Andric       break;
371081ad6265SDimitry Andric     }
371181ad6265SDimitry Andric 
3712a7dea167SDimitry Andric     case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3713e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3714e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3715a7dea167SDimitry Andric       S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3716a7dea167SDimitry Andric                                                           CollapsedNum, Empty);
3717a7dea167SDimitry Andric       break;
3718a7dea167SDimitry Andric     }
3719a7dea167SDimitry Andric 
372081ad6265SDimitry Andric     case STMT_OMP_PARALLEL_MASKED_TASKLOOP_DIRECTIVE: {
372181ad6265SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
372281ad6265SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
372381ad6265SDimitry Andric       S = OMPParallelMaskedTaskLoopDirective::CreateEmpty(Context, NumClauses,
372481ad6265SDimitry Andric                                                           CollapsedNum, Empty);
372581ad6265SDimitry Andric       break;
372681ad6265SDimitry Andric     }
372781ad6265SDimitry Andric 
3728480093f4SDimitry Andric     case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3729e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3730e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3731480093f4SDimitry Andric       S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3732480093f4SDimitry Andric           Context, NumClauses, CollapsedNum, Empty);
3733480093f4SDimitry Andric       break;
3734480093f4SDimitry Andric     }
3735480093f4SDimitry Andric 
373681ad6265SDimitry Andric     case STMT_OMP_PARALLEL_MASKED_TASKLOOP_SIMD_DIRECTIVE: {
373781ad6265SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
373881ad6265SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
373981ad6265SDimitry Andric       S = OMPParallelMaskedTaskLoopSimdDirective::CreateEmpty(
374081ad6265SDimitry Andric           Context, NumClauses, CollapsedNum, Empty);
374181ad6265SDimitry Andric       break;
374281ad6265SDimitry Andric     }
374381ad6265SDimitry Andric 
37440b57cec5SDimitry Andric     case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3745e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3746e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
37470b57cec5SDimitry Andric       S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
37480b57cec5SDimitry Andric                                               Empty);
37490b57cec5SDimitry Andric       break;
37500b57cec5SDimitry Andric     }
37510b57cec5SDimitry Andric 
37520b57cec5SDimitry Andric     case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3753e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3754e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
37550b57cec5SDimitry Andric       S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
37560b57cec5SDimitry Andric                                                          CollapsedNum, Empty);
37570b57cec5SDimitry Andric       break;
37580b57cec5SDimitry Andric     }
37590b57cec5SDimitry Andric 
37600b57cec5SDimitry Andric     case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3761e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3762e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
37630b57cec5SDimitry Andric       S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
37640b57cec5SDimitry Andric                                                              CollapsedNum,
37650b57cec5SDimitry Andric                                                              Empty);
37660b57cec5SDimitry Andric       break;
37670b57cec5SDimitry Andric     }
37680b57cec5SDimitry Andric 
37690b57cec5SDimitry Andric     case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3770e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3771e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
37720b57cec5SDimitry Andric       S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
37730b57cec5SDimitry Andric                                                   CollapsedNum, Empty);
37740b57cec5SDimitry Andric       break;
37750b57cec5SDimitry Andric     }
37760b57cec5SDimitry Andric 
37770b57cec5SDimitry Andric     case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3778e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3779e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
37800b57cec5SDimitry Andric       S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
37810b57cec5SDimitry Andric                                                          CollapsedNum, Empty);
37820b57cec5SDimitry Andric       break;
37830b57cec5SDimitry Andric     }
37840b57cec5SDimitry Andric 
37850b57cec5SDimitry Andric     case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3786e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3787e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
37880b57cec5SDimitry Andric       S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
37890b57cec5SDimitry Andric                                               Empty);
37900b57cec5SDimitry Andric       break;
37910b57cec5SDimitry Andric     }
37920b57cec5SDimitry Andric 
37930b57cec5SDimitry Andric      case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
3794e8d8bef9SDimitry Andric        unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3795e8d8bef9SDimitry Andric        unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
37960b57cec5SDimitry Andric        S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
37970b57cec5SDimitry Andric                                                     CollapsedNum, Empty);
37980b57cec5SDimitry Andric        break;
37990b57cec5SDimitry Andric     }
38000b57cec5SDimitry Andric 
38010b57cec5SDimitry Andric     case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3802e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3803e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
38040b57cec5SDimitry Andric       S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
38050b57cec5SDimitry Andric                                                        CollapsedNum, Empty);
38060b57cec5SDimitry Andric       break;
38070b57cec5SDimitry Andric     }
38080b57cec5SDimitry Andric 
38090b57cec5SDimitry Andric     case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3810e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3811e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
38120b57cec5SDimitry Andric       S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
38130b57cec5SDimitry Andric           Context, NumClauses, CollapsedNum, Empty);
38140b57cec5SDimitry Andric       break;
38150b57cec5SDimitry Andric     }
38160b57cec5SDimitry Andric 
38170b57cec5SDimitry Andric     case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3818e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3819e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
38200b57cec5SDimitry Andric       S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
38210b57cec5SDimitry Andric           Context, NumClauses, CollapsedNum, Empty);
38220b57cec5SDimitry Andric       break;
38230b57cec5SDimitry Andric     }
38240b57cec5SDimitry Andric 
38250b57cec5SDimitry Andric     case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
38260b57cec5SDimitry Andric       S = OMPTargetTeamsDirective::CreateEmpty(
38270b57cec5SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
38280b57cec5SDimitry Andric       break;
38290b57cec5SDimitry Andric 
38300b57cec5SDimitry Andric     case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3831e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3832e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
38330b57cec5SDimitry Andric       S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
38340b57cec5SDimitry Andric                                                          CollapsedNum, Empty);
38350b57cec5SDimitry Andric       break;
38360b57cec5SDimitry Andric     }
38370b57cec5SDimitry Andric 
38380b57cec5SDimitry Andric     case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3839e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3840e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
38410b57cec5SDimitry Andric       S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
38420b57cec5SDimitry Andric           Context, NumClauses, CollapsedNum, Empty);
38430b57cec5SDimitry Andric       break;
38440b57cec5SDimitry Andric     }
38450b57cec5SDimitry Andric 
38460b57cec5SDimitry Andric     case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3847e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3848e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
38490b57cec5SDimitry Andric       S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
38500b57cec5SDimitry Andric           Context, NumClauses, CollapsedNum, Empty);
38510b57cec5SDimitry Andric       break;
38520b57cec5SDimitry Andric     }
38530b57cec5SDimitry Andric 
38540b57cec5SDimitry Andric     case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3855e8d8bef9SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3856e8d8bef9SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
38570b57cec5SDimitry Andric       S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
38580b57cec5SDimitry Andric           Context, NumClauses, CollapsedNum, Empty);
38590b57cec5SDimitry Andric       break;
38600b57cec5SDimitry Andric     }
38610b57cec5SDimitry Andric 
3862fe6060f1SDimitry Andric     case STMT_OMP_INTEROP_DIRECTIVE:
3863fe6060f1SDimitry Andric       S = OMPInteropDirective::CreateEmpty(
3864fe6060f1SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3865fe6060f1SDimitry Andric       break;
3866fe6060f1SDimitry Andric 
3867fe6060f1SDimitry Andric     case STMT_OMP_DISPATCH_DIRECTIVE:
3868fe6060f1SDimitry Andric       S = OMPDispatchDirective::CreateEmpty(
3869fe6060f1SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3870fe6060f1SDimitry Andric       break;
3871fe6060f1SDimitry Andric 
3872fe6060f1SDimitry Andric     case STMT_OMP_MASKED_DIRECTIVE:
3873fe6060f1SDimitry Andric       S = OMPMaskedDirective::CreateEmpty(
3874fe6060f1SDimitry Andric           Context, Record[ASTStmtReader::NumStmtFields], Empty);
3875fe6060f1SDimitry Andric       break;
3876fe6060f1SDimitry Andric 
3877349cc55cSDimitry Andric     case STMT_OMP_GENERIC_LOOP_DIRECTIVE: {
3878349cc55cSDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3879349cc55cSDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3880349cc55cSDimitry Andric       S = OMPGenericLoopDirective::CreateEmpty(Context, NumClauses,
3881349cc55cSDimitry Andric                                                CollapsedNum, Empty);
3882349cc55cSDimitry Andric       break;
3883349cc55cSDimitry Andric     }
3884349cc55cSDimitry Andric 
388581ad6265SDimitry Andric     case STMT_OMP_TEAMS_GENERIC_LOOP_DIRECTIVE: {
388681ad6265SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
388781ad6265SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
388881ad6265SDimitry Andric       S = OMPTeamsGenericLoopDirective::CreateEmpty(Context, NumClauses,
388981ad6265SDimitry Andric                                                     CollapsedNum, Empty);
389081ad6265SDimitry Andric       break;
389181ad6265SDimitry Andric     }
389281ad6265SDimitry Andric 
389381ad6265SDimitry Andric     case STMT_OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVE: {
389481ad6265SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
389581ad6265SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
389681ad6265SDimitry Andric       S = OMPTargetTeamsGenericLoopDirective::CreateEmpty(Context, NumClauses,
389781ad6265SDimitry Andric                                                           CollapsedNum, Empty);
389881ad6265SDimitry Andric       break;
389981ad6265SDimitry Andric     }
390081ad6265SDimitry Andric 
390181ad6265SDimitry Andric     case STMT_OMP_PARALLEL_GENERIC_LOOP_DIRECTIVE: {
390281ad6265SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
390381ad6265SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
390481ad6265SDimitry Andric       S = OMPParallelGenericLoopDirective::CreateEmpty(Context, NumClauses,
390581ad6265SDimitry Andric                                                        CollapsedNum, Empty);
390681ad6265SDimitry Andric       break;
390781ad6265SDimitry Andric     }
390881ad6265SDimitry Andric 
390981ad6265SDimitry Andric     case STMT_OMP_TARGET_PARALLEL_GENERIC_LOOP_DIRECTIVE: {
391081ad6265SDimitry Andric       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
391181ad6265SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
391281ad6265SDimitry Andric       S = OMPTargetParallelGenericLoopDirective::CreateEmpty(
391381ad6265SDimitry Andric           Context, NumClauses, CollapsedNum, Empty);
391481ad6265SDimitry Andric       break;
391581ad6265SDimitry Andric     }
391681ad6265SDimitry Andric 
39175f757f3fSDimitry Andric     case EXPR_CXX_OPERATOR_CALL: {
3918cb14a3feSDimitry Andric       auto NumArgs = Record[ASTStmtReader::NumExprFields];
3919cb14a3feSDimitry Andric       BitsUnpacker CallExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3920cb14a3feSDimitry Andric       CallExprBits.advance(1);
39215f757f3fSDimitry Andric       auto HasFPFeatures = CallExprBits.getNextBit();
39225f757f3fSDimitry Andric       S = CXXOperatorCallExpr::CreateEmpty(Context, NumArgs, HasFPFeatures,
39235f757f3fSDimitry Andric                                            Empty);
39240b57cec5SDimitry Andric       break;
39255f757f3fSDimitry Andric     }
39260b57cec5SDimitry Andric 
39275f757f3fSDimitry Andric     case EXPR_CXX_MEMBER_CALL: {
3928cb14a3feSDimitry Andric       auto NumArgs = Record[ASTStmtReader::NumExprFields];
3929cb14a3feSDimitry Andric       BitsUnpacker CallExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3930cb14a3feSDimitry Andric       CallExprBits.advance(1);
39315f757f3fSDimitry Andric       auto HasFPFeatures = CallExprBits.getNextBit();
39325f757f3fSDimitry Andric       S = CXXMemberCallExpr::CreateEmpty(Context, NumArgs, HasFPFeatures,
39335f757f3fSDimitry Andric                                          Empty);
39340b57cec5SDimitry Andric       break;
39355f757f3fSDimitry Andric     }
39360b57cec5SDimitry Andric 
3937a7dea167SDimitry Andric     case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3938a7dea167SDimitry Andric       S = new (Context) CXXRewrittenBinaryOperator(Empty);
3939a7dea167SDimitry Andric       break;
3940a7dea167SDimitry Andric 
39410b57cec5SDimitry Andric     case EXPR_CXX_CONSTRUCT:
39420b57cec5SDimitry Andric       S = CXXConstructExpr::CreateEmpty(
39430b57cec5SDimitry Andric           Context,
39440b57cec5SDimitry Andric           /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
39450b57cec5SDimitry Andric       break;
39460b57cec5SDimitry Andric 
39470b57cec5SDimitry Andric     case EXPR_CXX_INHERITED_CTOR_INIT:
39480b57cec5SDimitry Andric       S = new (Context) CXXInheritedCtorInitExpr(Empty);
39490b57cec5SDimitry Andric       break;
39500b57cec5SDimitry Andric 
39510b57cec5SDimitry Andric     case EXPR_CXX_TEMPORARY_OBJECT:
39520b57cec5SDimitry Andric       S = CXXTemporaryObjectExpr::CreateEmpty(
39530b57cec5SDimitry Andric           Context,
39540b57cec5SDimitry Andric           /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
39550b57cec5SDimitry Andric       break;
39560b57cec5SDimitry Andric 
3957cb14a3feSDimitry Andric     case EXPR_CXX_STATIC_CAST: {
3958cb14a3feSDimitry Andric       unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3959cb14a3feSDimitry Andric       BitsUnpacker CastExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3960cb14a3feSDimitry Andric       CastExprBits.advance(7);
3961cb14a3feSDimitry Andric       bool HasFPFeatures = CastExprBits.getNextBit();
3962cb14a3feSDimitry Andric       S = CXXStaticCastExpr::CreateEmpty(Context, PathSize, HasFPFeatures);
39630b57cec5SDimitry Andric       break;
3964cb14a3feSDimitry Andric     }
39650b57cec5SDimitry Andric 
3966cb14a3feSDimitry Andric     case EXPR_CXX_DYNAMIC_CAST: {
3967cb14a3feSDimitry Andric       unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3968cb14a3feSDimitry Andric       S = CXXDynamicCastExpr::CreateEmpty(Context, PathSize);
39690b57cec5SDimitry Andric       break;
3970cb14a3feSDimitry Andric     }
39710b57cec5SDimitry Andric 
3972cb14a3feSDimitry Andric     case EXPR_CXX_REINTERPRET_CAST: {
3973cb14a3feSDimitry Andric       unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3974cb14a3feSDimitry Andric       S = CXXReinterpretCastExpr::CreateEmpty(Context, PathSize);
39750b57cec5SDimitry Andric       break;
3976cb14a3feSDimitry Andric     }
39770b57cec5SDimitry Andric 
39780b57cec5SDimitry Andric     case EXPR_CXX_CONST_CAST:
39790b57cec5SDimitry Andric       S = CXXConstCastExpr::CreateEmpty(Context);
39800b57cec5SDimitry Andric       break;
39810b57cec5SDimitry Andric 
39825ffd83dbSDimitry Andric     case EXPR_CXX_ADDRSPACE_CAST:
39835ffd83dbSDimitry Andric       S = CXXAddrspaceCastExpr::CreateEmpty(Context);
39845ffd83dbSDimitry Andric       break;
39855ffd83dbSDimitry Andric 
3986cb14a3feSDimitry Andric     case EXPR_CXX_FUNCTIONAL_CAST: {
3987cb14a3feSDimitry Andric       unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3988cb14a3feSDimitry Andric       BitsUnpacker CastExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3989cb14a3feSDimitry Andric       CastExprBits.advance(7);
3990cb14a3feSDimitry Andric       bool HasFPFeatures = CastExprBits.getNextBit();
3991cb14a3feSDimitry Andric       S = CXXFunctionalCastExpr::CreateEmpty(Context, PathSize, HasFPFeatures);
39920b57cec5SDimitry Andric       break;
3993cb14a3feSDimitry Andric     }
39940b57cec5SDimitry Andric 
3995cb14a3feSDimitry Andric     case EXPR_BUILTIN_BIT_CAST: {
3996cb14a3feSDimitry Andric #ifndef NDEBUG
3997cb14a3feSDimitry Andric       unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3998cb14a3feSDimitry Andric       assert(PathSize == 0 && "Wrong PathSize!");
3999cb14a3feSDimitry Andric #endif
40005ffd83dbSDimitry Andric       S = new (Context) BuiltinBitCastExpr(Empty);
40015ffd83dbSDimitry Andric       break;
4002cb14a3feSDimitry Andric     }
40035ffd83dbSDimitry Andric 
40045f757f3fSDimitry Andric     case EXPR_USER_DEFINED_LITERAL: {
4005cb14a3feSDimitry Andric       auto NumArgs = Record[ASTStmtReader::NumExprFields];
4006cb14a3feSDimitry Andric       BitsUnpacker CallExprBits(Record[ASTStmtReader::NumExprFields + 1]);
4007cb14a3feSDimitry Andric       CallExprBits.advance(1);
40085f757f3fSDimitry Andric       auto HasFPFeatures = CallExprBits.getNextBit();
40095f757f3fSDimitry Andric       S = UserDefinedLiteral::CreateEmpty(Context, NumArgs, HasFPFeatures,
40105f757f3fSDimitry Andric                                           Empty);
40110b57cec5SDimitry Andric       break;
40125f757f3fSDimitry Andric     }
40130b57cec5SDimitry Andric 
40140b57cec5SDimitry Andric     case EXPR_CXX_STD_INITIALIZER_LIST:
40150b57cec5SDimitry Andric       S = new (Context) CXXStdInitializerListExpr(Empty);
40160b57cec5SDimitry Andric       break;
40170b57cec5SDimitry Andric 
40180b57cec5SDimitry Andric     case EXPR_CXX_BOOL_LITERAL:
40190b57cec5SDimitry Andric       S = new (Context) CXXBoolLiteralExpr(Empty);
40200b57cec5SDimitry Andric       break;
40210b57cec5SDimitry Andric 
40220b57cec5SDimitry Andric     case EXPR_CXX_NULL_PTR_LITERAL:
40230b57cec5SDimitry Andric       S = new (Context) CXXNullPtrLiteralExpr(Empty);
40240b57cec5SDimitry Andric       break;
40250b57cec5SDimitry Andric 
40260b57cec5SDimitry Andric     case EXPR_CXX_TYPEID_EXPR:
40270b57cec5SDimitry Andric       S = new (Context) CXXTypeidExpr(Empty, true);
40280b57cec5SDimitry Andric       break;
40290b57cec5SDimitry Andric 
40300b57cec5SDimitry Andric     case EXPR_CXX_TYPEID_TYPE:
40310b57cec5SDimitry Andric       S = new (Context) CXXTypeidExpr(Empty, false);
40320b57cec5SDimitry Andric       break;
40330b57cec5SDimitry Andric 
40340b57cec5SDimitry Andric     case EXPR_CXX_UUIDOF_EXPR:
40350b57cec5SDimitry Andric       S = new (Context) CXXUuidofExpr(Empty, true);
40360b57cec5SDimitry Andric       break;
40370b57cec5SDimitry Andric 
40380b57cec5SDimitry Andric     case EXPR_CXX_PROPERTY_REF_EXPR:
40390b57cec5SDimitry Andric       S = new (Context) MSPropertyRefExpr(Empty);
40400b57cec5SDimitry Andric       break;
40410b57cec5SDimitry Andric 
40420b57cec5SDimitry Andric     case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
40430b57cec5SDimitry Andric       S = new (Context) MSPropertySubscriptExpr(Empty);
40440b57cec5SDimitry Andric       break;
40450b57cec5SDimitry Andric 
40460b57cec5SDimitry Andric     case EXPR_CXX_UUIDOF_TYPE:
40470b57cec5SDimitry Andric       S = new (Context) CXXUuidofExpr(Empty, false);
40480b57cec5SDimitry Andric       break;
40490b57cec5SDimitry Andric 
40500b57cec5SDimitry Andric     case EXPR_CXX_THIS:
40515f757f3fSDimitry Andric       S = CXXThisExpr::CreateEmpty(Context);
40520b57cec5SDimitry Andric       break;
40530b57cec5SDimitry Andric 
40540b57cec5SDimitry Andric     case EXPR_CXX_THROW:
40550b57cec5SDimitry Andric       S = new (Context) CXXThrowExpr(Empty);
40560b57cec5SDimitry Andric       break;
40570b57cec5SDimitry Andric 
40580b57cec5SDimitry Andric     case EXPR_CXX_DEFAULT_ARG:
4059bdd1243dSDimitry Andric       S = CXXDefaultArgExpr::CreateEmpty(
4060bdd1243dSDimitry Andric           Context, /*HasRewrittenInit=*/Record[ASTStmtReader::NumExprFields]);
40610b57cec5SDimitry Andric       break;
40620b57cec5SDimitry Andric 
40630b57cec5SDimitry Andric     case EXPR_CXX_DEFAULT_INIT:
4064bdd1243dSDimitry Andric       S = CXXDefaultInitExpr::CreateEmpty(
4065bdd1243dSDimitry Andric           Context, /*HasRewrittenInit=*/Record[ASTStmtReader::NumExprFields]);
40660b57cec5SDimitry Andric       break;
40670b57cec5SDimitry Andric 
40680b57cec5SDimitry Andric     case EXPR_CXX_BIND_TEMPORARY:
40690b57cec5SDimitry Andric       S = new (Context) CXXBindTemporaryExpr(Empty);
40700b57cec5SDimitry Andric       break;
40710b57cec5SDimitry Andric 
40720b57cec5SDimitry Andric     case EXPR_CXX_SCALAR_VALUE_INIT:
40730b57cec5SDimitry Andric       S = new (Context) CXXScalarValueInitExpr(Empty);
40740b57cec5SDimitry Andric       break;
40750b57cec5SDimitry Andric 
40760b57cec5SDimitry Andric     case EXPR_CXX_NEW:
40770b57cec5SDimitry Andric       S = CXXNewExpr::CreateEmpty(
40780b57cec5SDimitry Andric           Context,
40790b57cec5SDimitry Andric           /*IsArray=*/Record[ASTStmtReader::NumExprFields],
40800b57cec5SDimitry Andric           /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
40810b57cec5SDimitry Andric           /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
40820b57cec5SDimitry Andric           /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
40830b57cec5SDimitry Andric       break;
40840b57cec5SDimitry Andric 
40850b57cec5SDimitry Andric     case EXPR_CXX_DELETE:
40860b57cec5SDimitry Andric       S = new (Context) CXXDeleteExpr(Empty);
40870b57cec5SDimitry Andric       break;
40880b57cec5SDimitry Andric 
40890b57cec5SDimitry Andric     case EXPR_CXX_PSEUDO_DESTRUCTOR:
40900b57cec5SDimitry Andric       S = new (Context) CXXPseudoDestructorExpr(Empty);
40910b57cec5SDimitry Andric       break;
40920b57cec5SDimitry Andric 
40930b57cec5SDimitry Andric     case EXPR_EXPR_WITH_CLEANUPS:
40940b57cec5SDimitry Andric       S = ExprWithCleanups::Create(Context, Empty,
40950b57cec5SDimitry Andric                                    Record[ASTStmtReader::NumExprFields]);
40960b57cec5SDimitry Andric       break;
40970b57cec5SDimitry Andric 
4098cb14a3feSDimitry Andric     case EXPR_CXX_DEPENDENT_SCOPE_MEMBER: {
4099cb14a3feSDimitry Andric       unsigned NumTemplateArgs = Record[ASTStmtReader::NumExprFields];
4100cb14a3feSDimitry Andric       BitsUnpacker DependentScopeMemberBits(
4101cb14a3feSDimitry Andric           Record[ASTStmtReader::NumExprFields + 1]);
4102cb14a3feSDimitry Andric       bool HasTemplateKWAndArgsInfo = DependentScopeMemberBits.getNextBit();
41030b57cec5SDimitry Andric 
4104cb14a3feSDimitry Andric       bool HasFirstQualifierFoundInScope =
4105cb14a3feSDimitry Andric           DependentScopeMemberBits.getNextBit();
4106cb14a3feSDimitry Andric       S = CXXDependentScopeMemberExpr::CreateEmpty(
4107cb14a3feSDimitry Andric           Context, HasTemplateKWAndArgsInfo, NumTemplateArgs,
4108cb14a3feSDimitry Andric           HasFirstQualifierFoundInScope);
41090b57cec5SDimitry Andric       break;
4110cb14a3feSDimitry Andric     }
4111cb14a3feSDimitry Andric 
4112cb14a3feSDimitry Andric     case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF: {
4113cb14a3feSDimitry Andric       BitsUnpacker DependentScopeDeclRefBits(
4114cb14a3feSDimitry Andric           Record[ASTStmtReader::NumStmtFields]);
4115cb14a3feSDimitry Andric       DependentScopeDeclRefBits.advance(ASTStmtReader::NumExprBits);
4116cb14a3feSDimitry Andric       bool HasTemplateKWAndArgsInfo = DependentScopeDeclRefBits.getNextBit();
4117cb14a3feSDimitry Andric       unsigned NumTemplateArgs =
4118cb14a3feSDimitry Andric           HasTemplateKWAndArgsInfo
4119cb14a3feSDimitry Andric               ? DependentScopeDeclRefBits.getNextBits(/*Width=*/16)
4120cb14a3feSDimitry Andric               : 0;
4121cb14a3feSDimitry Andric       S = DependentScopeDeclRefExpr::CreateEmpty(
4122cb14a3feSDimitry Andric           Context, HasTemplateKWAndArgsInfo, NumTemplateArgs);
4123cb14a3feSDimitry Andric       break;
4124cb14a3feSDimitry Andric     }
41250b57cec5SDimitry Andric 
41260b57cec5SDimitry Andric     case EXPR_CXX_UNRESOLVED_CONSTRUCT:
41270b57cec5SDimitry Andric       S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
41280b57cec5SDimitry Andric                               /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
41290b57cec5SDimitry Andric       break;
41300b57cec5SDimitry Andric 
4131cb14a3feSDimitry Andric     case EXPR_CXX_UNRESOLVED_MEMBER: {
4132cb14a3feSDimitry Andric       auto NumResults = Record[ASTStmtReader::NumExprFields];
4133cb14a3feSDimitry Andric       BitsUnpacker OverloadExprBits(Record[ASTStmtReader::NumExprFields + 1]);
4134cb14a3feSDimitry Andric       auto HasTemplateKWAndArgsInfo = OverloadExprBits.getNextBit();
4135cb14a3feSDimitry Andric       auto NumTemplateArgs = HasTemplateKWAndArgsInfo
4136cb14a3feSDimitry Andric                                  ? Record[ASTStmtReader::NumExprFields + 2]
4137cb14a3feSDimitry Andric                                  : 0;
41380b57cec5SDimitry Andric       S = UnresolvedMemberExpr::CreateEmpty(
4139cb14a3feSDimitry Andric           Context, NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
41400b57cec5SDimitry Andric       break;
4141cb14a3feSDimitry Andric     }
41420b57cec5SDimitry Andric 
4143cb14a3feSDimitry Andric     case EXPR_CXX_UNRESOLVED_LOOKUP: {
4144cb14a3feSDimitry Andric       auto NumResults = Record[ASTStmtReader::NumExprFields];
4145cb14a3feSDimitry Andric       BitsUnpacker OverloadExprBits(Record[ASTStmtReader::NumExprFields + 1]);
4146cb14a3feSDimitry Andric       auto HasTemplateKWAndArgsInfo = OverloadExprBits.getNextBit();
4147cb14a3feSDimitry Andric       auto NumTemplateArgs = HasTemplateKWAndArgsInfo
4148cb14a3feSDimitry Andric                                  ? Record[ASTStmtReader::NumExprFields + 2]
4149cb14a3feSDimitry Andric                                  : 0;
41500b57cec5SDimitry Andric       S = UnresolvedLookupExpr::CreateEmpty(
4151cb14a3feSDimitry Andric           Context, NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
41520b57cec5SDimitry Andric       break;
4153cb14a3feSDimitry Andric     }
41540b57cec5SDimitry Andric 
41550b57cec5SDimitry Andric     case EXPR_TYPE_TRAIT:
41560b57cec5SDimitry Andric       S = TypeTraitExpr::CreateDeserialized(Context,
41570b57cec5SDimitry Andric             Record[ASTStmtReader::NumExprFields]);
41580b57cec5SDimitry Andric       break;
41590b57cec5SDimitry Andric 
41600b57cec5SDimitry Andric     case EXPR_ARRAY_TYPE_TRAIT:
41610b57cec5SDimitry Andric       S = new (Context) ArrayTypeTraitExpr(Empty);
41620b57cec5SDimitry Andric       break;
41630b57cec5SDimitry Andric 
41640b57cec5SDimitry Andric     case EXPR_CXX_EXPRESSION_TRAIT:
41650b57cec5SDimitry Andric       S = new (Context) ExpressionTraitExpr(Empty);
41660b57cec5SDimitry Andric       break;
41670b57cec5SDimitry Andric 
41680b57cec5SDimitry Andric     case EXPR_CXX_NOEXCEPT:
41690b57cec5SDimitry Andric       S = new (Context) CXXNoexceptExpr(Empty);
41700b57cec5SDimitry Andric       break;
41710b57cec5SDimitry Andric 
41720b57cec5SDimitry Andric     case EXPR_PACK_EXPANSION:
41730b57cec5SDimitry Andric       S = new (Context) PackExpansionExpr(Empty);
41740b57cec5SDimitry Andric       break;
41750b57cec5SDimitry Andric 
41760b57cec5SDimitry Andric     case EXPR_SIZEOF_PACK:
41770b57cec5SDimitry Andric       S = SizeOfPackExpr::CreateDeserialized(
41780b57cec5SDimitry Andric               Context,
41790b57cec5SDimitry Andric               /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
41800b57cec5SDimitry Andric       break;
41810b57cec5SDimitry Andric 
4182*0fca6ea1SDimitry Andric     case EXPR_PACK_INDEXING:
4183*0fca6ea1SDimitry Andric       S = PackIndexingExpr::CreateDeserialized(
4184*0fca6ea1SDimitry Andric           Context,
4185*0fca6ea1SDimitry Andric           /*TransformedExprs=*/Record[ASTStmtReader::NumExprFields]);
4186*0fca6ea1SDimitry Andric       break;
4187*0fca6ea1SDimitry Andric 
41880b57cec5SDimitry Andric     case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
41890b57cec5SDimitry Andric       S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
41900b57cec5SDimitry Andric       break;
41910b57cec5SDimitry Andric 
41920b57cec5SDimitry Andric     case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
41930b57cec5SDimitry Andric       S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
41940b57cec5SDimitry Andric       break;
41950b57cec5SDimitry Andric 
41960b57cec5SDimitry Andric     case EXPR_FUNCTION_PARM_PACK:
41970b57cec5SDimitry Andric       S = FunctionParmPackExpr::CreateEmpty(Context,
41980b57cec5SDimitry Andric                                           Record[ASTStmtReader::NumExprFields]);
41990b57cec5SDimitry Andric       break;
42000b57cec5SDimitry Andric 
42010b57cec5SDimitry Andric     case EXPR_MATERIALIZE_TEMPORARY:
42020b57cec5SDimitry Andric       S = new (Context) MaterializeTemporaryExpr(Empty);
42030b57cec5SDimitry Andric       break;
42040b57cec5SDimitry Andric 
42050b57cec5SDimitry Andric     case EXPR_CXX_FOLD:
42060b57cec5SDimitry Andric       S = new (Context) CXXFoldExpr(Empty);
42070b57cec5SDimitry Andric       break;
42080b57cec5SDimitry Andric 
4209bdd1243dSDimitry Andric     case EXPR_CXX_PAREN_LIST_INIT:
4210bdd1243dSDimitry Andric       S = CXXParenListInitExpr::CreateEmpty(
4211bdd1243dSDimitry Andric           Context, /*numExprs=*/Record[ASTStmtReader::NumExprFields], Empty);
4212bdd1243dSDimitry Andric       break;
4213bdd1243dSDimitry Andric 
42140b57cec5SDimitry Andric     case EXPR_OPAQUE_VALUE:
42150b57cec5SDimitry Andric       S = new (Context) OpaqueValueExpr(Empty);
42160b57cec5SDimitry Andric       break;
42170b57cec5SDimitry Andric 
42185f757f3fSDimitry Andric     case EXPR_CUDA_KERNEL_CALL: {
4219cb14a3feSDimitry Andric       auto NumArgs = Record[ASTStmtReader::NumExprFields];
4220cb14a3feSDimitry Andric       BitsUnpacker CallExprBits(Record[ASTStmtReader::NumExprFields + 1]);
4221cb14a3feSDimitry Andric       CallExprBits.advance(1);
42225f757f3fSDimitry Andric       auto HasFPFeatures = CallExprBits.getNextBit();
42235f757f3fSDimitry Andric       S = CUDAKernelCallExpr::CreateEmpty(Context, NumArgs, HasFPFeatures,
42245f757f3fSDimitry Andric                                           Empty);
42250b57cec5SDimitry Andric       break;
42265f757f3fSDimitry Andric     }
42270b57cec5SDimitry Andric 
42280b57cec5SDimitry Andric     case EXPR_ASTYPE:
42290b57cec5SDimitry Andric       S = new (Context) AsTypeExpr(Empty);
42300b57cec5SDimitry Andric       break;
42310b57cec5SDimitry Andric 
42320b57cec5SDimitry Andric     case EXPR_PSEUDO_OBJECT: {
42330b57cec5SDimitry Andric       unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
42340b57cec5SDimitry Andric       S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
42350b57cec5SDimitry Andric       break;
42360b57cec5SDimitry Andric     }
42370b57cec5SDimitry Andric 
42380b57cec5SDimitry Andric     case EXPR_ATOMIC:
42390b57cec5SDimitry Andric       S = new (Context) AtomicExpr(Empty);
42400b57cec5SDimitry Andric       break;
42410b57cec5SDimitry Andric 
42420b57cec5SDimitry Andric     case EXPR_LAMBDA: {
42430b57cec5SDimitry Andric       unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
42440b57cec5SDimitry Andric       S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
42450b57cec5SDimitry Andric       break;
42460b57cec5SDimitry Andric     }
42470b57cec5SDimitry Andric 
42480b57cec5SDimitry Andric     case STMT_COROUTINE_BODY: {
42490b57cec5SDimitry Andric       unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
42500b57cec5SDimitry Andric       S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
42510b57cec5SDimitry Andric       break;
42520b57cec5SDimitry Andric     }
42530b57cec5SDimitry Andric 
42540b57cec5SDimitry Andric     case STMT_CORETURN:
42550b57cec5SDimitry Andric       S = new (Context) CoreturnStmt(Empty);
42560b57cec5SDimitry Andric       break;
42570b57cec5SDimitry Andric 
42580b57cec5SDimitry Andric     case EXPR_COAWAIT:
42590b57cec5SDimitry Andric       S = new (Context) CoawaitExpr(Empty);
42600b57cec5SDimitry Andric       break;
42610b57cec5SDimitry Andric 
42620b57cec5SDimitry Andric     case EXPR_COYIELD:
42630b57cec5SDimitry Andric       S = new (Context) CoyieldExpr(Empty);
42640b57cec5SDimitry Andric       break;
42650b57cec5SDimitry Andric 
42660b57cec5SDimitry Andric     case EXPR_DEPENDENT_COAWAIT:
42670b57cec5SDimitry Andric       S = new (Context) DependentCoawaitExpr(Empty);
42680b57cec5SDimitry Andric       break;
4269a7dea167SDimitry Andric 
427055e4f9d5SDimitry Andric     case EXPR_CONCEPT_SPECIALIZATION: {
4271bdd1243dSDimitry Andric       S = new (Context) ConceptSpecializationExpr(Empty);
4272a7dea167SDimitry Andric       break;
427355e4f9d5SDimitry Andric     }
4274*0fca6ea1SDimitry Andric     case STMT_OPENACC_COMPUTE_CONSTRUCT: {
4275*0fca6ea1SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
4276*0fca6ea1SDimitry Andric       S = OpenACCComputeConstruct::CreateEmpty(Context, NumClauses);
4277*0fca6ea1SDimitry Andric       break;
4278*0fca6ea1SDimitry Andric     }
4279*0fca6ea1SDimitry Andric     case STMT_OPENACC_LOOP_CONSTRUCT: {
4280*0fca6ea1SDimitry Andric       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
4281*0fca6ea1SDimitry Andric       S = OpenACCLoopConstruct::CreateEmpty(Context, NumClauses);
4282*0fca6ea1SDimitry Andric       break;
4283*0fca6ea1SDimitry Andric     }
428455e4f9d5SDimitry Andric     case EXPR_REQUIRES:
428555e4f9d5SDimitry Andric       unsigned numLocalParameters = Record[ASTStmtReader::NumExprFields];
428655e4f9d5SDimitry Andric       unsigned numRequirement = Record[ASTStmtReader::NumExprFields + 1];
428755e4f9d5SDimitry Andric       S = RequiresExpr::Create(Context, Empty, numLocalParameters,
428855e4f9d5SDimitry Andric                                numRequirement);
428955e4f9d5SDimitry Andric       break;
42900b57cec5SDimitry Andric     }
42910b57cec5SDimitry Andric 
42920b57cec5SDimitry Andric     // We hit a STMT_STOP, so we're done with this expression.
42930b57cec5SDimitry Andric     if (Finished)
42940b57cec5SDimitry Andric       break;
42950b57cec5SDimitry Andric 
42960b57cec5SDimitry Andric     ++NumStatementsRead;
42970b57cec5SDimitry Andric 
42980b57cec5SDimitry Andric     if (S && !IsStmtReference) {
42990b57cec5SDimitry Andric       Reader.Visit(S);
43000b57cec5SDimitry Andric       StmtEntries[Cursor.GetCurrentBitNo()] = S;
43010b57cec5SDimitry Andric     }
43020b57cec5SDimitry Andric 
43030b57cec5SDimitry Andric     assert(Record.getIdx() == Record.size() &&
43040b57cec5SDimitry Andric            "Invalid deserialization of statement");
43050b57cec5SDimitry Andric     StmtStack.push_back(S);
43060b57cec5SDimitry Andric   }
43070b57cec5SDimitry Andric Done:
43080b57cec5SDimitry Andric   assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
43090b57cec5SDimitry Andric   assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
43100b57cec5SDimitry Andric   return StmtStack.pop_back_val();
43110b57cec5SDimitry Andric }
4312