[AMDGPU][AsmParser][NFC] Get rid of custom default operand handlers.
[llvm-project.git] / clang / lib / Serialization / ASTReaderStmt.cpp
blobc241a963918a64563d607804738db83d5da982be
1 //===- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Statement/expression deserialization. This implements the
10 // ASTReader::ReadStmt method.
12 //===----------------------------------------------------------------------===//
14 #include "clang/AST/ASTConcept.h"
15 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/AttrIterator.h"
17 #include "clang/AST/Decl.h"
18 #include "clang/AST/DeclAccessPair.h"
19 #include "clang/AST/DeclCXX.h"
20 #include "clang/AST/DeclGroup.h"
21 #include "clang/AST/DeclObjC.h"
22 #include "clang/AST/DeclTemplate.h"
23 #include "clang/AST/DeclarationName.h"
24 #include "clang/AST/DependenceFlags.h"
25 #include "clang/AST/Expr.h"
26 #include "clang/AST/ExprCXX.h"
27 #include "clang/AST/ExprObjC.h"
28 #include "clang/AST/ExprOpenMP.h"
29 #include "clang/AST/NestedNameSpecifier.h"
30 #include "clang/AST/OpenMPClause.h"
31 #include "clang/AST/OperationKinds.h"
32 #include "clang/AST/Stmt.h"
33 #include "clang/AST/StmtCXX.h"
34 #include "clang/AST/StmtObjC.h"
35 #include "clang/AST/StmtOpenMP.h"
36 #include "clang/AST/StmtVisitor.h"
37 #include "clang/AST/TemplateBase.h"
38 #include "clang/AST/Type.h"
39 #include "clang/AST/UnresolvedSet.h"
40 #include "clang/Basic/CapturedStmt.h"
41 #include "clang/Basic/ExpressionTraits.h"
42 #include "clang/Basic/LLVM.h"
43 #include "clang/Basic/Lambda.h"
44 #include "clang/Basic/LangOptions.h"
45 #include "clang/Basic/OpenMPKinds.h"
46 #include "clang/Basic/OperatorKinds.h"
47 #include "clang/Basic/SourceLocation.h"
48 #include "clang/Basic/Specifiers.h"
49 #include "clang/Basic/TypeTraits.h"
50 #include "clang/Lex/Token.h"
51 #include "clang/Serialization/ASTBitCodes.h"
52 #include "clang/Serialization/ASTRecordReader.h"
53 #include "llvm/ADT/BitmaskEnum.h"
54 #include "llvm/ADT/DenseMap.h"
55 #include "llvm/ADT/SmallString.h"
56 #include "llvm/ADT/SmallVector.h"
57 #include "llvm/ADT/StringRef.h"
58 #include "llvm/Bitstream/BitstreamReader.h"
59 #include "llvm/Support/Casting.h"
60 #include "llvm/Support/ErrorHandling.h"
61 #include <algorithm>
62 #include <cassert>
63 #include <cstdint>
64 #include <optional>
65 #include <string>
67 using namespace clang;
68 using namespace serialization;
70 namespace clang {
72 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
73 ASTRecordReader &Record;
74 llvm::BitstreamCursor &DeclsCursor;
76 SourceLocation readSourceLocation() {
77 return Record.readSourceLocation();
80 SourceRange readSourceRange() {
81 return Record.readSourceRange();
84 std::string readString() {
85 return Record.readString();
88 TypeSourceInfo *readTypeSourceInfo() {
89 return Record.readTypeSourceInfo();
92 Decl *readDecl() {
93 return Record.readDecl();
96 template<typename T>
97 T *readDeclAs() {
98 return Record.readDeclAs<T>();
101 public:
102 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
103 : Record(Record), DeclsCursor(Cursor) {}
105 /// The number of record fields required for the Stmt class
106 /// itself.
107 static const unsigned NumStmtFields = 0;
109 /// The number of record fields required for the Expr class
110 /// itself.
111 static const unsigned NumExprFields = NumStmtFields + 4;
113 /// Read and initialize a ExplicitTemplateArgumentList structure.
114 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
115 TemplateArgumentLoc *ArgsLocArray,
116 unsigned NumTemplateArgs);
118 void VisitStmt(Stmt *S);
119 #define STMT(Type, Base) \
120 void Visit##Type(Type *);
121 #include "clang/AST/StmtNodes.inc"
124 } // namespace clang
126 void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
127 TemplateArgumentLoc *ArgsLocArray,
128 unsigned NumTemplateArgs) {
129 SourceLocation TemplateKWLoc = readSourceLocation();
130 TemplateArgumentListInfo ArgInfo;
131 ArgInfo.setLAngleLoc(readSourceLocation());
132 ArgInfo.setRAngleLoc(readSourceLocation());
133 for (unsigned i = 0; i != NumTemplateArgs; ++i)
134 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
135 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
138 void ASTStmtReader::VisitStmt(Stmt *S) {
139 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
142 void ASTStmtReader::VisitNullStmt(NullStmt *S) {
143 VisitStmt(S);
144 S->setSemiLoc(readSourceLocation());
145 S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
148 void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
149 VisitStmt(S);
150 SmallVector<Stmt *, 16> Stmts;
151 unsigned NumStmts = Record.readInt();
152 unsigned HasFPFeatures = Record.readInt();
153 assert(S->hasStoredFPFeatures() == HasFPFeatures);
154 while (NumStmts--)
155 Stmts.push_back(Record.readSubStmt());
156 S->setStmts(Stmts);
157 if (HasFPFeatures)
158 S->setStoredFPFeatures(
159 FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
160 S->LBraceLoc = readSourceLocation();
161 S->RBraceLoc = readSourceLocation();
164 void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
165 VisitStmt(S);
166 Record.recordSwitchCaseID(S, Record.readInt());
167 S->setKeywordLoc(readSourceLocation());
168 S->setColonLoc(readSourceLocation());
171 void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
172 VisitSwitchCase(S);
173 bool CaseStmtIsGNURange = Record.readInt();
174 S->setLHS(Record.readSubExpr());
175 S->setSubStmt(Record.readSubStmt());
176 if (CaseStmtIsGNURange) {
177 S->setRHS(Record.readSubExpr());
178 S->setEllipsisLoc(readSourceLocation());
182 void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
183 VisitSwitchCase(S);
184 S->setSubStmt(Record.readSubStmt());
187 void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
188 VisitStmt(S);
189 bool IsSideEntry = Record.readInt();
190 auto *LD = readDeclAs<LabelDecl>();
191 LD->setStmt(S);
192 S->setDecl(LD);
193 S->setSubStmt(Record.readSubStmt());
194 S->setIdentLoc(readSourceLocation());
195 S->setSideEntry(IsSideEntry);
198 void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
199 VisitStmt(S);
200 // NumAttrs in AttributedStmt is set when creating an empty
201 // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
202 // to allocate the right amount of space for the trailing Attr *.
203 uint64_t NumAttrs = Record.readInt();
204 AttrVec Attrs;
205 Record.readAttributes(Attrs);
206 (void)NumAttrs;
207 assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
208 assert(NumAttrs == Attrs.size());
209 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
210 S->SubStmt = Record.readSubStmt();
211 S->AttributedStmtBits.AttrLoc = readSourceLocation();
214 void ASTStmtReader::VisitIfStmt(IfStmt *S) {
215 VisitStmt(S);
217 bool HasElse = Record.readInt();
218 bool HasVar = Record.readInt();
219 bool HasInit = Record.readInt();
221 S->setStatementKind(static_cast<IfStatementKind>(Record.readInt()));
222 S->setCond(Record.readSubExpr());
223 S->setThen(Record.readSubStmt());
224 if (HasElse)
225 S->setElse(Record.readSubStmt());
226 if (HasVar)
227 S->setConditionVariableDeclStmt(cast<DeclStmt>(Record.readSubStmt()));
228 if (HasInit)
229 S->setInit(Record.readSubStmt());
231 S->setIfLoc(readSourceLocation());
232 S->setLParenLoc(readSourceLocation());
233 S->setRParenLoc(readSourceLocation());
234 if (HasElse)
235 S->setElseLoc(readSourceLocation());
238 void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
239 VisitStmt(S);
241 bool HasInit = Record.readInt();
242 bool HasVar = Record.readInt();
243 bool AllEnumCasesCovered = Record.readInt();
244 if (AllEnumCasesCovered)
245 S->setAllEnumCasesCovered();
247 S->setCond(Record.readSubExpr());
248 S->setBody(Record.readSubStmt());
249 if (HasInit)
250 S->setInit(Record.readSubStmt());
251 if (HasVar)
252 S->setConditionVariableDeclStmt(cast<DeclStmt>(Record.readSubStmt()));
254 S->setSwitchLoc(readSourceLocation());
255 S->setLParenLoc(readSourceLocation());
256 S->setRParenLoc(readSourceLocation());
258 SwitchCase *PrevSC = nullptr;
259 for (auto E = Record.size(); Record.getIdx() != E; ) {
260 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
261 if (PrevSC)
262 PrevSC->setNextSwitchCase(SC);
263 else
264 S->setSwitchCaseList(SC);
266 PrevSC = SC;
270 void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
271 VisitStmt(S);
273 bool HasVar = Record.readInt();
275 S->setCond(Record.readSubExpr());
276 S->setBody(Record.readSubStmt());
277 if (HasVar)
278 S->setConditionVariableDeclStmt(cast<DeclStmt>(Record.readSubStmt()));
280 S->setWhileLoc(readSourceLocation());
281 S->setLParenLoc(readSourceLocation());
282 S->setRParenLoc(readSourceLocation());
285 void ASTStmtReader::VisitDoStmt(DoStmt *S) {
286 VisitStmt(S);
287 S->setCond(Record.readSubExpr());
288 S->setBody(Record.readSubStmt());
289 S->setDoLoc(readSourceLocation());
290 S->setWhileLoc(readSourceLocation());
291 S->setRParenLoc(readSourceLocation());
294 void ASTStmtReader::VisitForStmt(ForStmt *S) {
295 VisitStmt(S);
296 S->setInit(Record.readSubStmt());
297 S->setCond(Record.readSubExpr());
298 S->setConditionVariableDeclStmt(cast_or_null<DeclStmt>(Record.readSubStmt()));
299 S->setInc(Record.readSubExpr());
300 S->setBody(Record.readSubStmt());
301 S->setForLoc(readSourceLocation());
302 S->setLParenLoc(readSourceLocation());
303 S->setRParenLoc(readSourceLocation());
306 void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
307 VisitStmt(S);
308 S->setLabel(readDeclAs<LabelDecl>());
309 S->setGotoLoc(readSourceLocation());
310 S->setLabelLoc(readSourceLocation());
313 void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
314 VisitStmt(S);
315 S->setGotoLoc(readSourceLocation());
316 S->setStarLoc(readSourceLocation());
317 S->setTarget(Record.readSubExpr());
320 void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
321 VisitStmt(S);
322 S->setContinueLoc(readSourceLocation());
325 void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
326 VisitStmt(S);
327 S->setBreakLoc(readSourceLocation());
330 void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
331 VisitStmt(S);
333 bool HasNRVOCandidate = Record.readInt();
335 S->setRetValue(Record.readSubExpr());
336 if (HasNRVOCandidate)
337 S->setNRVOCandidate(readDeclAs<VarDecl>());
339 S->setReturnLoc(readSourceLocation());
342 void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
343 VisitStmt(S);
344 S->setStartLoc(readSourceLocation());
345 S->setEndLoc(readSourceLocation());
347 if (Record.size() - Record.getIdx() == 1) {
348 // Single declaration
349 S->setDeclGroup(DeclGroupRef(readDecl()));
350 } else {
351 SmallVector<Decl *, 16> Decls;
352 int N = Record.size() - Record.getIdx();
353 Decls.reserve(N);
354 for (int I = 0; I < N; ++I)
355 Decls.push_back(readDecl());
356 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
357 Decls.data(),
358 Decls.size())));
362 void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
363 VisitStmt(S);
364 S->NumOutputs = Record.readInt();
365 S->NumInputs = Record.readInt();
366 S->NumClobbers = Record.readInt();
367 S->setAsmLoc(readSourceLocation());
368 S->setVolatile(Record.readInt());
369 S->setSimple(Record.readInt());
372 void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
373 VisitAsmStmt(S);
374 S->NumLabels = Record.readInt();
375 S->setRParenLoc(readSourceLocation());
376 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
378 unsigned NumOutputs = S->getNumOutputs();
379 unsigned NumInputs = S->getNumInputs();
380 unsigned NumClobbers = S->getNumClobbers();
381 unsigned NumLabels = S->getNumLabels();
383 // Outputs and inputs
384 SmallVector<IdentifierInfo *, 16> Names;
385 SmallVector<StringLiteral*, 16> Constraints;
386 SmallVector<Stmt*, 16> Exprs;
387 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
388 Names.push_back(Record.readIdentifier());
389 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
390 Exprs.push_back(Record.readSubStmt());
393 // Constraints
394 SmallVector<StringLiteral*, 16> Clobbers;
395 for (unsigned I = 0; I != NumClobbers; ++I)
396 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
398 // Labels
399 for (unsigned I = 0, N = NumLabels; I != N; ++I) {
400 Names.push_back(Record.readIdentifier());
401 Exprs.push_back(Record.readSubStmt());
404 S->setOutputsAndInputsAndClobbers(Record.getContext(),
405 Names.data(), Constraints.data(),
406 Exprs.data(), NumOutputs, NumInputs,
407 NumLabels,
408 Clobbers.data(), NumClobbers);
411 void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
412 VisitAsmStmt(S);
413 S->LBraceLoc = readSourceLocation();
414 S->EndLoc = readSourceLocation();
415 S->NumAsmToks = Record.readInt();
416 std::string AsmStr = readString();
418 // Read the tokens.
419 SmallVector<Token, 16> AsmToks;
420 AsmToks.reserve(S->NumAsmToks);
421 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
422 AsmToks.push_back(Record.readToken());
425 // The calls to reserve() for the FooData vectors are mandatory to
426 // prevent dead StringRefs in the Foo vectors.
428 // Read the clobbers.
429 SmallVector<std::string, 16> ClobbersData;
430 SmallVector<StringRef, 16> Clobbers;
431 ClobbersData.reserve(S->NumClobbers);
432 Clobbers.reserve(S->NumClobbers);
433 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
434 ClobbersData.push_back(readString());
435 Clobbers.push_back(ClobbersData.back());
438 // Read the operands.
439 unsigned NumOperands = S->NumOutputs + S->NumInputs;
440 SmallVector<Expr*, 16> Exprs;
441 SmallVector<std::string, 16> ConstraintsData;
442 SmallVector<StringRef, 16> Constraints;
443 Exprs.reserve(NumOperands);
444 ConstraintsData.reserve(NumOperands);
445 Constraints.reserve(NumOperands);
446 for (unsigned i = 0; i != NumOperands; ++i) {
447 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
448 ConstraintsData.push_back(readString());
449 Constraints.push_back(ConstraintsData.back());
452 S->initialize(Record.getContext(), AsmStr, AsmToks,
453 Constraints, Exprs, Clobbers);
456 void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
457 VisitStmt(S);
458 assert(Record.peekInt() == S->NumParams);
459 Record.skipInts(1);
460 auto *StoredStmts = S->getStoredStmts();
461 for (unsigned i = 0;
462 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
463 StoredStmts[i] = Record.readSubStmt();
466 void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
467 VisitStmt(S);
468 S->CoreturnLoc = Record.readSourceLocation();
469 for (auto &SubStmt: S->SubStmts)
470 SubStmt = Record.readSubStmt();
471 S->IsImplicit = Record.readInt() != 0;
474 void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
475 VisitExpr(E);
476 E->KeywordLoc = readSourceLocation();
477 for (auto &SubExpr: E->SubExprs)
478 SubExpr = Record.readSubStmt();
479 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
480 E->setIsImplicit(Record.readInt() != 0);
483 void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
484 VisitExpr(E);
485 E->KeywordLoc = readSourceLocation();
486 for (auto &SubExpr: E->SubExprs)
487 SubExpr = Record.readSubStmt();
488 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
491 void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
492 VisitExpr(E);
493 E->KeywordLoc = readSourceLocation();
494 for (auto &SubExpr: E->SubExprs)
495 SubExpr = Record.readSubStmt();
498 void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
499 VisitStmt(S);
500 Record.skipInts(1);
501 S->setCapturedDecl(readDeclAs<CapturedDecl>());
502 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
503 S->setCapturedRecordDecl(readDeclAs<RecordDecl>());
505 // Capture inits
506 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
507 E = S->capture_init_end();
508 I != E; ++I)
509 *I = Record.readSubExpr();
511 // Body
512 S->setCapturedStmt(Record.readSubStmt());
513 S->getCapturedDecl()->setBody(S->getCapturedStmt());
515 // Captures
516 for (auto &I : S->captures()) {
517 I.VarAndKind.setPointer(readDeclAs<VarDecl>());
518 I.VarAndKind.setInt(
519 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
520 I.Loc = readSourceLocation();
524 void ASTStmtReader::VisitExpr(Expr *E) {
525 VisitStmt(E);
526 E->setType(Record.readType());
527 E->setDependence(static_cast<ExprDependence>(Record.readInt()));
528 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
529 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
530 assert(Record.getIdx() == NumExprFields &&
531 "Incorrect expression field count");
534 void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
535 VisitExpr(E);
537 auto StorageKind = Record.readInt();
538 assert(E->ConstantExprBits.ResultKind == StorageKind && "Wrong ResultKind!");
540 E->ConstantExprBits.APValueKind = Record.readInt();
541 E->ConstantExprBits.IsUnsigned = Record.readInt();
542 E->ConstantExprBits.BitWidth = Record.readInt();
543 E->ConstantExprBits.HasCleanup = false; // Not serialized, see below.
544 E->ConstantExprBits.IsImmediateInvocation = Record.readInt();
546 switch (StorageKind) {
547 case ConstantExpr::RSK_None:
548 break;
550 case ConstantExpr::RSK_Int64:
551 E->Int64Result() = Record.readInt();
552 break;
554 case ConstantExpr::RSK_APValue:
555 E->APValueResult() = Record.readAPValue();
556 if (E->APValueResult().needsCleanup()) {
557 E->ConstantExprBits.HasCleanup = true;
558 Record.getContext().addDestruction(&E->APValueResult());
560 break;
561 default:
562 llvm_unreachable("unexpected ResultKind!");
565 E->setSubExpr(Record.readSubExpr());
568 void ASTStmtReader::VisitSYCLUniqueStableNameExpr(SYCLUniqueStableNameExpr *E) {
569 VisitExpr(E);
571 E->setLocation(readSourceLocation());
572 E->setLParenLocation(readSourceLocation());
573 E->setRParenLocation(readSourceLocation());
575 E->setTypeSourceInfo(Record.readTypeSourceInfo());
578 void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
579 VisitExpr(E);
580 bool HasFunctionName = Record.readInt();
581 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
582 E->PredefinedExprBits.Kind = Record.readInt();
583 E->PredefinedExprBits.IsTransparent = Record.readInt();
584 E->setLocation(readSourceLocation());
585 if (HasFunctionName)
586 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
589 void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
590 VisitExpr(E);
592 E->DeclRefExprBits.HasQualifier = Record.readInt();
593 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
594 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
595 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
596 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
597 E->DeclRefExprBits.NonOdrUseReason = Record.readInt();
598 E->DeclRefExprBits.IsImmediateEscalating = Record.readInt();
599 unsigned NumTemplateArgs = 0;
600 if (E->hasTemplateKWAndArgsInfo())
601 NumTemplateArgs = Record.readInt();
603 if (E->hasQualifier())
604 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
605 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
607 if (E->hasFoundDecl())
608 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
610 if (E->hasTemplateKWAndArgsInfo())
611 ReadTemplateKWAndArgsInfo(
612 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
613 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
615 E->D = readDeclAs<ValueDecl>();
616 E->setLocation(readSourceLocation());
617 E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
620 void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
621 VisitExpr(E);
622 E->setLocation(readSourceLocation());
623 E->setValue(Record.getContext(), Record.readAPInt());
626 void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
627 VisitExpr(E);
628 E->setLocation(readSourceLocation());
629 E->setScale(Record.readInt());
630 E->setValue(Record.getContext(), Record.readAPInt());
633 void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
634 VisitExpr(E);
635 E->setRawSemantics(
636 static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
637 E->setExact(Record.readInt());
638 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
639 E->setLocation(readSourceLocation());
642 void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
643 VisitExpr(E);
644 E->setSubExpr(Record.readSubExpr());
647 void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
648 VisitExpr(E);
650 // NumConcatenated, Length and CharByteWidth are set by the empty
651 // ctor since they are needed to allocate storage for the trailing objects.
652 unsigned NumConcatenated = Record.readInt();
653 unsigned Length = Record.readInt();
654 unsigned CharByteWidth = Record.readInt();
655 assert((NumConcatenated == E->getNumConcatenated()) &&
656 "Wrong number of concatenated tokens!");
657 assert((Length == E->getLength()) && "Wrong Length!");
658 assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
659 E->StringLiteralBits.Kind = Record.readInt();
660 E->StringLiteralBits.IsPascal = Record.readInt();
662 // The character width is originally computed via mapCharByteWidth.
663 // Check that the deserialized character width is consistant with the result
664 // of calling mapCharByteWidth.
665 assert((CharByteWidth ==
666 StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
667 E->getKind())) &&
668 "Wrong character width!");
670 // Deserialize the trailing array of SourceLocation.
671 for (unsigned I = 0; I < NumConcatenated; ++I)
672 E->setStrTokenLoc(I, readSourceLocation());
674 // Deserialize the trailing array of char holding the string data.
675 char *StrData = E->getStrDataAsChar();
676 for (unsigned I = 0; I < Length * CharByteWidth; ++I)
677 StrData[I] = Record.readInt();
680 void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
681 VisitExpr(E);
682 E->setValue(Record.readInt());
683 E->setLocation(readSourceLocation());
684 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
687 void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
688 VisitExpr(E);
689 E->setLParen(readSourceLocation());
690 E->setRParen(readSourceLocation());
691 E->setSubExpr(Record.readSubExpr());
694 void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
695 VisitExpr(E);
696 unsigned NumExprs = Record.readInt();
697 assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
698 for (unsigned I = 0; I != NumExprs; ++I)
699 E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
700 E->LParenLoc = readSourceLocation();
701 E->RParenLoc = readSourceLocation();
704 void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
705 VisitExpr(E);
706 bool hasFP_Features = Record.readInt();
707 assert(hasFP_Features == E->hasStoredFPFeatures());
708 E->setSubExpr(Record.readSubExpr());
709 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
710 E->setOperatorLoc(readSourceLocation());
711 E->setCanOverflow(Record.readInt());
712 if (hasFP_Features)
713 E->setStoredFPFeatures(
714 FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
717 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
718 VisitExpr(E);
719 assert(E->getNumComponents() == Record.peekInt());
720 Record.skipInts(1);
721 assert(E->getNumExpressions() == Record.peekInt());
722 Record.skipInts(1);
723 E->setOperatorLoc(readSourceLocation());
724 E->setRParenLoc(readSourceLocation());
725 E->setTypeSourceInfo(readTypeSourceInfo());
726 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
727 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
728 SourceLocation Start = readSourceLocation();
729 SourceLocation End = readSourceLocation();
730 switch (Kind) {
731 case OffsetOfNode::Array:
732 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
733 break;
735 case OffsetOfNode::Field:
736 E->setComponent(
737 I, OffsetOfNode(Start, readDeclAs<FieldDecl>(), End));
738 break;
740 case OffsetOfNode::Identifier:
741 E->setComponent(
743 OffsetOfNode(Start, Record.readIdentifier(), End));
744 break;
746 case OffsetOfNode::Base: {
747 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
748 *Base = Record.readCXXBaseSpecifier();
749 E->setComponent(I, OffsetOfNode(Base));
750 break;
755 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
756 E->setIndexExpr(I, Record.readSubExpr());
759 void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
760 VisitExpr(E);
761 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
762 if (Record.peekInt() == 0) {
763 E->setArgument(Record.readSubExpr());
764 Record.skipInts(1);
765 } else {
766 E->setArgument(readTypeSourceInfo());
768 E->setOperatorLoc(readSourceLocation());
769 E->setRParenLoc(readSourceLocation());
772 static ConstraintSatisfaction
773 readConstraintSatisfaction(ASTRecordReader &Record) {
774 ConstraintSatisfaction Satisfaction;
775 Satisfaction.IsSatisfied = Record.readInt();
776 Satisfaction.ContainsErrors = Record.readInt();
777 if (!Satisfaction.IsSatisfied) {
778 unsigned NumDetailRecords = Record.readInt();
779 for (unsigned i = 0; i != NumDetailRecords; ++i) {
780 Expr *ConstraintExpr = Record.readExpr();
781 if (/* IsDiagnostic */Record.readInt()) {
782 SourceLocation DiagLocation = Record.readSourceLocation();
783 std::string DiagMessage = Record.readString();
784 Satisfaction.Details.emplace_back(
785 ConstraintExpr, new (Record.getContext())
786 ConstraintSatisfaction::SubstitutionDiagnostic{
787 DiagLocation, DiagMessage});
788 } else
789 Satisfaction.Details.emplace_back(ConstraintExpr, Record.readExpr());
792 return Satisfaction;
795 void ASTStmtReader::VisitConceptSpecializationExpr(
796 ConceptSpecializationExpr *E) {
797 VisitExpr(E);
798 E->NestedNameSpec = Record.readNestedNameSpecifierLoc();
799 E->TemplateKWLoc = Record.readSourceLocation();
800 E->ConceptName = Record.readDeclarationNameInfo();
801 E->NamedConcept = readDeclAs<ConceptDecl>();
802 E->FoundDecl = Record.readDeclAs<NamedDecl>();
803 E->SpecDecl = Record.readDeclAs<ImplicitConceptSpecializationDecl>();
804 E->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
805 E->Satisfaction = E->isValueDependent() ? nullptr :
806 ASTConstraintSatisfaction::Create(Record.getContext(),
807 readConstraintSatisfaction(Record));
810 static concepts::Requirement::SubstitutionDiagnostic *
811 readSubstitutionDiagnostic(ASTRecordReader &Record) {
812 std::string SubstitutedEntity = Record.readString();
813 SourceLocation DiagLoc = Record.readSourceLocation();
814 std::string DiagMessage = Record.readString();
815 return new (Record.getContext())
816 concepts::Requirement::SubstitutionDiagnostic{SubstitutedEntity, DiagLoc,
817 DiagMessage};
820 void ASTStmtReader::VisitRequiresExpr(RequiresExpr *E) {
821 VisitExpr(E);
822 unsigned NumLocalParameters = Record.readInt();
823 unsigned NumRequirements = Record.readInt();
824 E->RequiresExprBits.RequiresKWLoc = Record.readSourceLocation();
825 E->RequiresExprBits.IsSatisfied = Record.readInt();
826 E->Body = Record.readDeclAs<RequiresExprBodyDecl>();
827 llvm::SmallVector<ParmVarDecl *, 4> LocalParameters;
828 for (unsigned i = 0; i < NumLocalParameters; ++i)
829 LocalParameters.push_back(cast<ParmVarDecl>(Record.readDecl()));
830 std::copy(LocalParameters.begin(), LocalParameters.end(),
831 E->getTrailingObjects<ParmVarDecl *>());
832 llvm::SmallVector<concepts::Requirement *, 4> Requirements;
833 for (unsigned i = 0; i < NumRequirements; ++i) {
834 auto RK =
835 static_cast<concepts::Requirement::RequirementKind>(Record.readInt());
836 concepts::Requirement *R = nullptr;
837 switch (RK) {
838 case concepts::Requirement::RK_Type: {
839 auto Status =
840 static_cast<concepts::TypeRequirement::SatisfactionStatus>(
841 Record.readInt());
842 if (Status == concepts::TypeRequirement::SS_SubstitutionFailure)
843 R = new (Record.getContext())
844 concepts::TypeRequirement(readSubstitutionDiagnostic(Record));
845 else
846 R = new (Record.getContext())
847 concepts::TypeRequirement(Record.readTypeSourceInfo());
848 } break;
849 case concepts::Requirement::RK_Simple:
850 case concepts::Requirement::RK_Compound: {
851 auto Status =
852 static_cast<concepts::ExprRequirement::SatisfactionStatus>(
853 Record.readInt());
854 llvm::PointerUnion<concepts::Requirement::SubstitutionDiagnostic *,
855 Expr *> E;
856 if (Status == concepts::ExprRequirement::SS_ExprSubstitutionFailure) {
857 E = readSubstitutionDiagnostic(Record);
858 } else
859 E = Record.readExpr();
861 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> Req;
862 ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr;
863 SourceLocation NoexceptLoc;
864 if (RK == concepts::Requirement::RK_Simple) {
865 Req.emplace();
866 } else {
867 NoexceptLoc = Record.readSourceLocation();
868 switch (/* returnTypeRequirementKind */Record.readInt()) {
869 case 0:
870 // No return type requirement.
871 Req.emplace();
872 break;
873 case 1: {
874 // type-constraint
875 TemplateParameterList *TPL = Record.readTemplateParameterList();
876 if (Status >=
877 concepts::ExprRequirement::SS_ConstraintsNotSatisfied)
878 SubstitutedConstraintExpr =
879 cast<ConceptSpecializationExpr>(Record.readExpr());
880 Req.emplace(TPL);
881 } break;
882 case 2:
883 // Substitution failure
884 Req.emplace(readSubstitutionDiagnostic(Record));
885 break;
888 if (Expr *Ex = E.dyn_cast<Expr *>())
889 R = new (Record.getContext()) concepts::ExprRequirement(
890 Ex, RK == concepts::Requirement::RK_Simple, NoexceptLoc,
891 std::move(*Req), Status, SubstitutedConstraintExpr);
892 else
893 R = new (Record.getContext()) concepts::ExprRequirement(
894 E.get<concepts::Requirement::SubstitutionDiagnostic *>(),
895 RK == concepts::Requirement::RK_Simple, NoexceptLoc,
896 std::move(*Req));
897 } break;
898 case concepts::Requirement::RK_Nested: {
899 bool HasInvalidConstraint = Record.readInt();
900 if (HasInvalidConstraint) {
901 std::string InvalidConstraint = Record.readString();
902 char *InvalidConstraintBuf =
903 new (Record.getContext()) char[InvalidConstraint.size()];
904 std::copy(InvalidConstraint.begin(), InvalidConstraint.end(),
905 InvalidConstraintBuf);
906 R = new (Record.getContext()) concepts::NestedRequirement(
907 Record.getContext(),
908 StringRef(InvalidConstraintBuf, InvalidConstraint.size()),
909 readConstraintSatisfaction(Record));
910 break;
912 Expr *E = Record.readExpr();
913 if (E->isInstantiationDependent())
914 R = new (Record.getContext()) concepts::NestedRequirement(E);
915 else
916 R = new (Record.getContext())
917 concepts::NestedRequirement(Record.getContext(), E,
918 readConstraintSatisfaction(Record));
919 } break;
921 if (!R)
922 continue;
923 Requirements.push_back(R);
925 std::copy(Requirements.begin(), Requirements.end(),
926 E->getTrailingObjects<concepts::Requirement *>());
927 E->RBraceLoc = Record.readSourceLocation();
930 void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
931 VisitExpr(E);
932 E->setLHS(Record.readSubExpr());
933 E->setRHS(Record.readSubExpr());
934 E->setRBracketLoc(readSourceLocation());
937 void ASTStmtReader::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
938 VisitExpr(E);
939 E->setBase(Record.readSubExpr());
940 E->setRowIdx(Record.readSubExpr());
941 E->setColumnIdx(Record.readSubExpr());
942 E->setRBracketLoc(readSourceLocation());
945 void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
946 VisitExpr(E);
947 E->setBase(Record.readSubExpr());
948 E->setLowerBound(Record.readSubExpr());
949 E->setLength(Record.readSubExpr());
950 E->setStride(Record.readSubExpr());
951 E->setColonLocFirst(readSourceLocation());
952 E->setColonLocSecond(readSourceLocation());
953 E->setRBracketLoc(readSourceLocation());
956 void ASTStmtReader::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *E) {
957 VisitExpr(E);
958 unsigned NumDims = Record.readInt();
959 E->setBase(Record.readSubExpr());
960 SmallVector<Expr *, 4> Dims(NumDims);
961 for (unsigned I = 0; I < NumDims; ++I)
962 Dims[I] = Record.readSubExpr();
963 E->setDimensions(Dims);
964 SmallVector<SourceRange, 4> SRs(NumDims);
965 for (unsigned I = 0; I < NumDims; ++I)
966 SRs[I] = readSourceRange();
967 E->setBracketsRanges(SRs);
968 E->setLParenLoc(readSourceLocation());
969 E->setRParenLoc(readSourceLocation());
972 void ASTStmtReader::VisitOMPIteratorExpr(OMPIteratorExpr *E) {
973 VisitExpr(E);
974 unsigned NumIters = Record.readInt();
975 E->setIteratorKwLoc(readSourceLocation());
976 E->setLParenLoc(readSourceLocation());
977 E->setRParenLoc(readSourceLocation());
978 for (unsigned I = 0; I < NumIters; ++I) {
979 E->setIteratorDeclaration(I, Record.readDeclRef());
980 E->setAssignmentLoc(I, readSourceLocation());
981 Expr *Begin = Record.readSubExpr();
982 Expr *End = Record.readSubExpr();
983 Expr *Step = Record.readSubExpr();
984 SourceLocation ColonLoc = readSourceLocation();
985 SourceLocation SecColonLoc;
986 if (Step)
987 SecColonLoc = readSourceLocation();
988 E->setIteratorRange(I, Begin, ColonLoc, End, SecColonLoc, Step);
989 // Deserialize helpers
990 OMPIteratorHelperData HD;
991 HD.CounterVD = cast_or_null<VarDecl>(Record.readDeclRef());
992 HD.Upper = Record.readSubExpr();
993 HD.Update = Record.readSubExpr();
994 HD.CounterUpdate = Record.readSubExpr();
995 E->setHelper(I, HD);
999 void ASTStmtReader::VisitCallExpr(CallExpr *E) {
1000 VisitExpr(E);
1001 unsigned NumArgs = Record.readInt();
1002 bool HasFPFeatures = Record.readInt();
1003 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1004 E->setRParenLoc(readSourceLocation());
1005 E->setCallee(Record.readSubExpr());
1006 for (unsigned I = 0; I != NumArgs; ++I)
1007 E->setArg(I, Record.readSubExpr());
1008 E->setADLCallKind(static_cast<CallExpr::ADLCallKind>(Record.readInt()));
1009 if (HasFPFeatures)
1010 E->setStoredFPFeatures(
1011 FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
1014 void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
1015 VisitCallExpr(E);
1018 void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
1019 VisitExpr(E);
1021 bool HasQualifier = Record.readInt();
1022 bool HasFoundDecl = Record.readInt();
1023 bool HasTemplateInfo = Record.readInt();
1024 unsigned NumTemplateArgs = Record.readInt();
1026 E->Base = Record.readSubExpr();
1027 E->MemberDecl = Record.readDeclAs<ValueDecl>();
1028 E->MemberDNLoc = Record.readDeclarationNameLoc(E->MemberDecl->getDeclName());
1029 E->MemberLoc = Record.readSourceLocation();
1030 E->MemberExprBits.IsArrow = Record.readInt();
1031 E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
1032 E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
1033 E->MemberExprBits.HadMultipleCandidates = Record.readInt();
1034 E->MemberExprBits.NonOdrUseReason = Record.readInt();
1035 E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
1037 if (HasQualifier || HasFoundDecl) {
1038 DeclAccessPair FoundDecl;
1039 if (HasFoundDecl) {
1040 auto *FoundD = Record.readDeclAs<NamedDecl>();
1041 auto AS = (AccessSpecifier)Record.readInt();
1042 FoundDecl = DeclAccessPair::make(FoundD, AS);
1043 } else {
1044 FoundDecl = DeclAccessPair::make(E->MemberDecl,
1045 E->MemberDecl->getAccess());
1047 E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
1049 NestedNameSpecifierLoc QualifierLoc;
1050 if (HasQualifier)
1051 QualifierLoc = Record.readNestedNameSpecifierLoc();
1052 E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
1053 QualifierLoc;
1056 if (HasTemplateInfo)
1057 ReadTemplateKWAndArgsInfo(
1058 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1059 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
1062 void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
1063 VisitExpr(E);
1064 E->setBase(Record.readSubExpr());
1065 E->setIsaMemberLoc(readSourceLocation());
1066 E->setOpLoc(readSourceLocation());
1067 E->setArrow(Record.readInt());
1070 void ASTStmtReader::
1071 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
1072 VisitExpr(E);
1073 E->Operand = Record.readSubExpr();
1074 E->setShouldCopy(Record.readInt());
1077 void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
1078 VisitExplicitCastExpr(E);
1079 E->LParenLoc = readSourceLocation();
1080 E->BridgeKeywordLoc = readSourceLocation();
1081 E->Kind = Record.readInt();
1084 void ASTStmtReader::VisitCastExpr(CastExpr *E) {
1085 VisitExpr(E);
1086 unsigned NumBaseSpecs = Record.readInt();
1087 assert(NumBaseSpecs == E->path_size());
1088 unsigned HasFPFeatures = Record.readInt();
1089 assert(E->hasStoredFPFeatures() == HasFPFeatures);
1090 E->setSubExpr(Record.readSubExpr());
1091 E->setCastKind((CastKind)Record.readInt());
1092 CastExpr::path_iterator BaseI = E->path_begin();
1093 while (NumBaseSpecs--) {
1094 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
1095 *BaseSpec = Record.readCXXBaseSpecifier();
1096 *BaseI++ = BaseSpec;
1098 if (HasFPFeatures)
1099 *E->getTrailingFPFeatures() =
1100 FPOptionsOverride::getFromOpaqueInt(Record.readInt());
1103 void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
1104 bool hasFP_Features;
1105 VisitExpr(E);
1106 E->setHasStoredFPFeatures(hasFP_Features = Record.readInt());
1107 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
1108 E->setLHS(Record.readSubExpr());
1109 E->setRHS(Record.readSubExpr());
1110 E->setOperatorLoc(readSourceLocation());
1111 if (hasFP_Features)
1112 E->setStoredFPFeatures(
1113 FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
1116 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
1117 VisitBinaryOperator(E);
1118 E->setComputationLHSType(Record.readType());
1119 E->setComputationResultType(Record.readType());
1122 void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
1123 VisitExpr(E);
1124 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
1125 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
1126 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
1127 E->QuestionLoc = readSourceLocation();
1128 E->ColonLoc = readSourceLocation();
1131 void
1132 ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
1133 VisitExpr(E);
1134 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
1135 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
1136 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
1137 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
1138 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
1139 E->QuestionLoc = readSourceLocation();
1140 E->ColonLoc = readSourceLocation();
1143 void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
1144 VisitCastExpr(E);
1145 E->setIsPartOfExplicitCast(Record.readInt());
1148 void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
1149 VisitCastExpr(E);
1150 E->setTypeInfoAsWritten(readTypeSourceInfo());
1153 void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
1154 VisitExplicitCastExpr(E);
1155 E->setLParenLoc(readSourceLocation());
1156 E->setRParenLoc(readSourceLocation());
1159 void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
1160 VisitExpr(E);
1161 E->setLParenLoc(readSourceLocation());
1162 E->setTypeSourceInfo(readTypeSourceInfo());
1163 E->setInitializer(Record.readSubExpr());
1164 E->setFileScope(Record.readInt());
1167 void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
1168 VisitExpr(E);
1169 E->setBase(Record.readSubExpr());
1170 E->setAccessor(Record.readIdentifier());
1171 E->setAccessorLoc(readSourceLocation());
1174 void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
1175 VisitExpr(E);
1176 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
1177 E->setSyntacticForm(SyntForm);
1178 E->setLBraceLoc(readSourceLocation());
1179 E->setRBraceLoc(readSourceLocation());
1180 bool isArrayFiller = Record.readInt();
1181 Expr *filler = nullptr;
1182 if (isArrayFiller) {
1183 filler = Record.readSubExpr();
1184 E->ArrayFillerOrUnionFieldInit = filler;
1185 } else
1186 E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
1187 E->sawArrayRangeDesignator(Record.readInt());
1188 unsigned NumInits = Record.readInt();
1189 E->reserveInits(Record.getContext(), NumInits);
1190 if (isArrayFiller) {
1191 for (unsigned I = 0; I != NumInits; ++I) {
1192 Expr *init = Record.readSubExpr();
1193 E->updateInit(Record.getContext(), I, init ? init : filler);
1195 } else {
1196 for (unsigned I = 0; I != NumInits; ++I)
1197 E->updateInit(Record.getContext(), I, Record.readSubExpr());
1201 void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
1202 using Designator = DesignatedInitExpr::Designator;
1204 VisitExpr(E);
1205 unsigned NumSubExprs = Record.readInt();
1206 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
1207 for (unsigned I = 0; I != NumSubExprs; ++I)
1208 E->setSubExpr(I, Record.readSubExpr());
1209 E->setEqualOrColonLoc(readSourceLocation());
1210 E->setGNUSyntax(Record.readInt());
1212 SmallVector<Designator, 4> Designators;
1213 while (Record.getIdx() < Record.size()) {
1214 switch ((DesignatorTypes)Record.readInt()) {
1215 case DESIG_FIELD_DECL: {
1216 auto *Field = readDeclAs<FieldDecl>();
1217 SourceLocation DotLoc = readSourceLocation();
1218 SourceLocation FieldLoc = readSourceLocation();
1219 Designators.push_back(Designator::CreateFieldDesignator(
1220 Field->getIdentifier(), DotLoc, FieldLoc));
1221 Designators.back().setFieldDecl(Field);
1222 break;
1225 case DESIG_FIELD_NAME: {
1226 const IdentifierInfo *Name = Record.readIdentifier();
1227 SourceLocation DotLoc = readSourceLocation();
1228 SourceLocation FieldLoc = readSourceLocation();
1229 Designators.push_back(Designator::CreateFieldDesignator(Name, DotLoc,
1230 FieldLoc));
1231 break;
1234 case DESIG_ARRAY: {
1235 unsigned Index = Record.readInt();
1236 SourceLocation LBracketLoc = readSourceLocation();
1237 SourceLocation RBracketLoc = readSourceLocation();
1238 Designators.push_back(Designator::CreateArrayDesignator(Index,
1239 LBracketLoc,
1240 RBracketLoc));
1241 break;
1244 case DESIG_ARRAY_RANGE: {
1245 unsigned Index = Record.readInt();
1246 SourceLocation LBracketLoc = readSourceLocation();
1247 SourceLocation EllipsisLoc = readSourceLocation();
1248 SourceLocation RBracketLoc = readSourceLocation();
1249 Designators.push_back(Designator::CreateArrayRangeDesignator(
1250 Index, LBracketLoc, EllipsisLoc, RBracketLoc));
1251 break;
1255 E->setDesignators(Record.getContext(),
1256 Designators.data(), Designators.size());
1259 void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1260 VisitExpr(E);
1261 E->setBase(Record.readSubExpr());
1262 E->setUpdater(Record.readSubExpr());
1265 void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1266 VisitExpr(E);
1269 void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1270 VisitExpr(E);
1271 E->SubExprs[0] = Record.readSubExpr();
1272 E->SubExprs[1] = Record.readSubExpr();
1275 void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1276 VisitExpr(E);
1279 void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
1280 VisitExpr(E);
1283 void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
1284 VisitExpr(E);
1285 E->setSubExpr(Record.readSubExpr());
1286 E->setWrittenTypeInfo(readTypeSourceInfo());
1287 E->setBuiltinLoc(readSourceLocation());
1288 E->setRParenLoc(readSourceLocation());
1289 E->setIsMicrosoftABI(Record.readInt());
1292 void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1293 VisitExpr(E);
1294 E->ParentContext = readDeclAs<DeclContext>();
1295 E->BuiltinLoc = readSourceLocation();
1296 E->RParenLoc = readSourceLocation();
1297 E->SourceLocExprBits.Kind =
1298 static_cast<SourceLocExpr::IdentKind>(Record.readInt());
1301 void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
1302 VisitExpr(E);
1303 E->setAmpAmpLoc(readSourceLocation());
1304 E->setLabelLoc(readSourceLocation());
1305 E->setLabel(readDeclAs<LabelDecl>());
1308 void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
1309 VisitExpr(E);
1310 E->setLParenLoc(readSourceLocation());
1311 E->setRParenLoc(readSourceLocation());
1312 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
1313 E->StmtExprBits.TemplateDepth = Record.readInt();
1316 void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
1317 VisitExpr(E);
1318 E->setCond(Record.readSubExpr());
1319 E->setLHS(Record.readSubExpr());
1320 E->setRHS(Record.readSubExpr());
1321 E->setBuiltinLoc(readSourceLocation());
1322 E->setRParenLoc(readSourceLocation());
1323 E->setIsConditionTrue(Record.readInt());
1326 void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
1327 VisitExpr(E);
1328 E->setTokenLocation(readSourceLocation());
1331 void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
1332 VisitExpr(E);
1333 SmallVector<Expr *, 16> Exprs;
1334 unsigned NumExprs = Record.readInt();
1335 while (NumExprs--)
1336 Exprs.push_back(Record.readSubExpr());
1337 E->setExprs(Record.getContext(), Exprs);
1338 E->setBuiltinLoc(readSourceLocation());
1339 E->setRParenLoc(readSourceLocation());
1342 void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1343 VisitExpr(E);
1344 E->BuiltinLoc = readSourceLocation();
1345 E->RParenLoc = readSourceLocation();
1346 E->TInfo = readTypeSourceInfo();
1347 E->SrcExpr = Record.readSubExpr();
1350 void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
1351 VisitExpr(E);
1352 E->setBlockDecl(readDeclAs<BlockDecl>());
1355 void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1356 VisitExpr(E);
1358 unsigned NumAssocs = Record.readInt();
1359 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
1360 E->IsExprPredicate = Record.readInt();
1361 E->ResultIndex = Record.readInt();
1362 E->GenericSelectionExprBits.GenericLoc = readSourceLocation();
1363 E->DefaultLoc = readSourceLocation();
1364 E->RParenLoc = readSourceLocation();
1366 Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1367 // Add 1 to account for the controlling expression which is the first
1368 // expression in the trailing array of Stmt *. This is not needed for
1369 // the trailing array of TypeSourceInfo *.
1370 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1371 Stmts[I] = Record.readSubExpr();
1373 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1374 for (unsigned I = 0, N = NumAssocs; I < N; ++I)
1375 TSIs[I] = readTypeSourceInfo();
1378 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1379 VisitExpr(E);
1380 unsigned numSemanticExprs = Record.readInt();
1381 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
1382 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
1384 // Read the syntactic expression.
1385 E->getSubExprsBuffer()[0] = Record.readSubExpr();
1387 // Read all the semantic expressions.
1388 for (unsigned i = 0; i != numSemanticExprs; ++i) {
1389 Expr *subExpr = Record.readSubExpr();
1390 E->getSubExprsBuffer()[i+1] = subExpr;
1394 void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1395 VisitExpr(E);
1396 E->Op = AtomicExpr::AtomicOp(Record.readInt());
1397 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1398 for (unsigned I = 0; I != E->NumSubExprs; ++I)
1399 E->SubExprs[I] = Record.readSubExpr();
1400 E->BuiltinLoc = readSourceLocation();
1401 E->RParenLoc = readSourceLocation();
1404 //===----------------------------------------------------------------------===//
1405 // Objective-C Expressions and Statements
1407 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
1408 VisitExpr(E);
1409 E->setString(cast<StringLiteral>(Record.readSubStmt()));
1410 E->setAtLoc(readSourceLocation());
1413 void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
1414 VisitExpr(E);
1415 // could be one of several IntegerLiteral, FloatLiteral, etc.
1416 E->SubExpr = Record.readSubStmt();
1417 E->BoxingMethod = readDeclAs<ObjCMethodDecl>();
1418 E->Range = readSourceRange();
1421 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1422 VisitExpr(E);
1423 unsigned NumElements = Record.readInt();
1424 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1425 Expr **Elements = E->getElements();
1426 for (unsigned I = 0, N = NumElements; I != N; ++I)
1427 Elements[I] = Record.readSubExpr();
1428 E->ArrayWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1429 E->Range = readSourceRange();
1432 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1433 VisitExpr(E);
1434 unsigned NumElements = Record.readInt();
1435 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1436 bool HasPackExpansions = Record.readInt();
1437 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
1438 auto *KeyValues =
1439 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
1440 auto *Expansions =
1441 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
1442 for (unsigned I = 0; I != NumElements; ++I) {
1443 KeyValues[I].Key = Record.readSubExpr();
1444 KeyValues[I].Value = Record.readSubExpr();
1445 if (HasPackExpansions) {
1446 Expansions[I].EllipsisLoc = readSourceLocation();
1447 Expansions[I].NumExpansionsPlusOne = Record.readInt();
1450 E->DictWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1451 E->Range = readSourceRange();
1454 void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
1455 VisitExpr(E);
1456 E->setEncodedTypeSourceInfo(readTypeSourceInfo());
1457 E->setAtLoc(readSourceLocation());
1458 E->setRParenLoc(readSourceLocation());
1461 void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
1462 VisitExpr(E);
1463 E->setSelector(Record.readSelector());
1464 E->setAtLoc(readSourceLocation());
1465 E->setRParenLoc(readSourceLocation());
1468 void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
1469 VisitExpr(E);
1470 E->setProtocol(readDeclAs<ObjCProtocolDecl>());
1471 E->setAtLoc(readSourceLocation());
1472 E->ProtoLoc = readSourceLocation();
1473 E->setRParenLoc(readSourceLocation());
1476 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
1477 VisitExpr(E);
1478 E->setDecl(readDeclAs<ObjCIvarDecl>());
1479 E->setLocation(readSourceLocation());
1480 E->setOpLoc(readSourceLocation());
1481 E->setBase(Record.readSubExpr());
1482 E->setIsArrow(Record.readInt());
1483 E->setIsFreeIvar(Record.readInt());
1486 void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
1487 VisitExpr(E);
1488 unsigned MethodRefFlags = Record.readInt();
1489 bool Implicit = Record.readInt() != 0;
1490 if (Implicit) {
1491 auto *Getter = readDeclAs<ObjCMethodDecl>();
1492 auto *Setter = readDeclAs<ObjCMethodDecl>();
1493 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
1494 } else {
1495 E->setExplicitProperty(readDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
1497 E->setLocation(readSourceLocation());
1498 E->setReceiverLocation(readSourceLocation());
1499 switch (Record.readInt()) {
1500 case 0:
1501 E->setBase(Record.readSubExpr());
1502 break;
1503 case 1:
1504 E->setSuperReceiver(Record.readType());
1505 break;
1506 case 2:
1507 E->setClassReceiver(readDeclAs<ObjCInterfaceDecl>());
1508 break;
1512 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1513 VisitExpr(E);
1514 E->setRBracket(readSourceLocation());
1515 E->setBaseExpr(Record.readSubExpr());
1516 E->setKeyExpr(Record.readSubExpr());
1517 E->GetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1518 E->SetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1521 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1522 VisitExpr(E);
1523 assert(Record.peekInt() == E->getNumArgs());
1524 Record.skipInts(1);
1525 unsigned NumStoredSelLocs = Record.readInt();
1526 E->SelLocsKind = Record.readInt();
1527 E->setDelegateInitCall(Record.readInt());
1528 E->IsImplicit = Record.readInt();
1529 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
1530 switch (Kind) {
1531 case ObjCMessageExpr::Instance:
1532 E->setInstanceReceiver(Record.readSubExpr());
1533 break;
1535 case ObjCMessageExpr::Class:
1536 E->setClassReceiver(readTypeSourceInfo());
1537 break;
1539 case ObjCMessageExpr::SuperClass:
1540 case ObjCMessageExpr::SuperInstance: {
1541 QualType T = Record.readType();
1542 SourceLocation SuperLoc = readSourceLocation();
1543 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1544 break;
1548 assert(Kind == E->getReceiverKind());
1550 if (Record.readInt())
1551 E->setMethodDecl(readDeclAs<ObjCMethodDecl>());
1552 else
1553 E->setSelector(Record.readSelector());
1555 E->LBracLoc = readSourceLocation();
1556 E->RBracLoc = readSourceLocation();
1558 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1559 E->setArg(I, Record.readSubExpr());
1561 SourceLocation *Locs = E->getStoredSelLocs();
1562 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1563 Locs[I] = readSourceLocation();
1566 void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1567 VisitStmt(S);
1568 S->setElement(Record.readSubStmt());
1569 S->setCollection(Record.readSubExpr());
1570 S->setBody(Record.readSubStmt());
1571 S->setForLoc(readSourceLocation());
1572 S->setRParenLoc(readSourceLocation());
1575 void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1576 VisitStmt(S);
1577 S->setCatchBody(Record.readSubStmt());
1578 S->setCatchParamDecl(readDeclAs<VarDecl>());
1579 S->setAtCatchLoc(readSourceLocation());
1580 S->setRParenLoc(readSourceLocation());
1583 void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1584 VisitStmt(S);
1585 S->setFinallyBody(Record.readSubStmt());
1586 S->setAtFinallyLoc(readSourceLocation());
1589 void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1590 VisitStmt(S); // FIXME: no test coverage.
1591 S->setSubStmt(Record.readSubStmt());
1592 S->setAtLoc(readSourceLocation());
1595 void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1596 VisitStmt(S);
1597 assert(Record.peekInt() == S->getNumCatchStmts());
1598 Record.skipInts(1);
1599 bool HasFinally = Record.readInt();
1600 S->setTryBody(Record.readSubStmt());
1601 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
1602 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
1604 if (HasFinally)
1605 S->setFinallyStmt(Record.readSubStmt());
1606 S->setAtTryLoc(readSourceLocation());
1609 void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1610 VisitStmt(S); // FIXME: no test coverage.
1611 S->setSynchExpr(Record.readSubStmt());
1612 S->setSynchBody(Record.readSubStmt());
1613 S->setAtSynchronizedLoc(readSourceLocation());
1616 void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1617 VisitStmt(S); // FIXME: no test coverage.
1618 S->setThrowExpr(Record.readSubStmt());
1619 S->setThrowLoc(readSourceLocation());
1622 void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1623 VisitExpr(E);
1624 E->setValue(Record.readInt());
1625 E->setLocation(readSourceLocation());
1628 void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1629 VisitExpr(E);
1630 SourceRange R = Record.readSourceRange();
1631 E->AtLoc = R.getBegin();
1632 E->RParen = R.getEnd();
1633 E->VersionToCheck = Record.readVersionTuple();
1636 //===----------------------------------------------------------------------===//
1637 // C++ Expressions and Statements
1638 //===----------------------------------------------------------------------===//
1640 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
1641 VisitStmt(S);
1642 S->CatchLoc = readSourceLocation();
1643 S->ExceptionDecl = readDeclAs<VarDecl>();
1644 S->HandlerBlock = Record.readSubStmt();
1647 void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
1648 VisitStmt(S);
1649 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1650 Record.skipInts(1);
1651 S->TryLoc = readSourceLocation();
1652 S->getStmts()[0] = Record.readSubStmt();
1653 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1654 S->getStmts()[i + 1] = Record.readSubStmt();
1657 void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1658 VisitStmt(S);
1659 S->ForLoc = readSourceLocation();
1660 S->CoawaitLoc = readSourceLocation();
1661 S->ColonLoc = readSourceLocation();
1662 S->RParenLoc = readSourceLocation();
1663 S->setInit(Record.readSubStmt());
1664 S->setRangeStmt(Record.readSubStmt());
1665 S->setBeginStmt(Record.readSubStmt());
1666 S->setEndStmt(Record.readSubStmt());
1667 S->setCond(Record.readSubExpr());
1668 S->setInc(Record.readSubExpr());
1669 S->setLoopVarStmt(Record.readSubStmt());
1670 S->setBody(Record.readSubStmt());
1673 void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1674 VisitStmt(S);
1675 S->KeywordLoc = readSourceLocation();
1676 S->IsIfExists = Record.readInt();
1677 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
1678 S->NameInfo = Record.readDeclarationNameInfo();
1679 S->SubStmt = Record.readSubStmt();
1682 void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1683 VisitCallExpr(E);
1684 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1685 E->Range = Record.readSourceRange();
1688 void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1689 CXXRewrittenBinaryOperator *E) {
1690 VisitExpr(E);
1691 E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1692 E->SemanticForm = Record.readSubExpr();
1695 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
1696 VisitExpr(E);
1698 unsigned NumArgs = Record.readInt();
1699 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1701 E->CXXConstructExprBits.Elidable = Record.readInt();
1702 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1703 E->CXXConstructExprBits.ListInitialization = Record.readInt();
1704 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1705 E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1706 E->CXXConstructExprBits.ConstructionKind = Record.readInt();
1707 E->CXXConstructExprBits.IsImmediateEscalating = Record.readInt();
1708 E->CXXConstructExprBits.Loc = readSourceLocation();
1709 E->Constructor = readDeclAs<CXXConstructorDecl>();
1710 E->ParenOrBraceRange = readSourceRange();
1712 for (unsigned I = 0; I != NumArgs; ++I)
1713 E->setArg(I, Record.readSubExpr());
1716 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1717 VisitExpr(E);
1718 E->Constructor = readDeclAs<CXXConstructorDecl>();
1719 E->Loc = readSourceLocation();
1720 E->ConstructsVirtualBase = Record.readInt();
1721 E->InheritedFromVirtualBase = Record.readInt();
1724 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1725 VisitCXXConstructExpr(E);
1726 E->TSI = readTypeSourceInfo();
1729 void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1730 VisitExpr(E);
1731 unsigned NumCaptures = Record.readInt();
1732 (void)NumCaptures;
1733 assert(NumCaptures == E->LambdaExprBits.NumCaptures);
1734 E->IntroducerRange = readSourceRange();
1735 E->LambdaExprBits.CaptureDefault = Record.readInt();
1736 E->CaptureDefaultLoc = readSourceLocation();
1737 E->LambdaExprBits.ExplicitParams = Record.readInt();
1738 E->LambdaExprBits.ExplicitResultType = Record.readInt();
1739 E->ClosingBrace = readSourceLocation();
1741 // Read capture initializers.
1742 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1743 CEnd = E->capture_init_end();
1744 C != CEnd; ++C)
1745 *C = Record.readSubExpr();
1747 // The body will be lazily deserialized when needed from the call operator
1748 // declaration.
1751 void
1752 ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1753 VisitExpr(E);
1754 E->SubExpr = Record.readSubExpr();
1757 void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1758 VisitExplicitCastExpr(E);
1759 SourceRange R = readSourceRange();
1760 E->Loc = R.getBegin();
1761 E->RParenLoc = R.getEnd();
1762 R = readSourceRange();
1763 E->AngleBrackets = R;
1766 void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1767 return VisitCXXNamedCastExpr(E);
1770 void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1771 return VisitCXXNamedCastExpr(E);
1774 void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1775 return VisitCXXNamedCastExpr(E);
1778 void ASTStmtReader::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *E) {
1779 return VisitCXXNamedCastExpr(E);
1782 void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1783 return VisitCXXNamedCastExpr(E);
1786 void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1787 VisitExplicitCastExpr(E);
1788 E->setLParenLoc(readSourceLocation());
1789 E->setRParenLoc(readSourceLocation());
1792 void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1793 VisitExplicitCastExpr(E);
1794 E->KWLoc = readSourceLocation();
1795 E->RParenLoc = readSourceLocation();
1798 void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1799 VisitCallExpr(E);
1800 E->UDSuffixLoc = readSourceLocation();
1803 void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1804 VisitExpr(E);
1805 E->setValue(Record.readInt());
1806 E->setLocation(readSourceLocation());
1809 void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1810 VisitExpr(E);
1811 E->setLocation(readSourceLocation());
1814 void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1815 VisitExpr(E);
1816 E->setSourceRange(readSourceRange());
1817 if (E->isTypeOperand())
1818 E->Operand = readTypeSourceInfo();
1819 else
1820 E->Operand = Record.readSubExpr();
1823 void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
1824 VisitExpr(E);
1825 E->setLocation(readSourceLocation());
1826 E->setImplicit(Record.readInt());
1829 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
1830 VisitExpr(E);
1831 E->CXXThrowExprBits.ThrowLoc = readSourceLocation();
1832 E->Operand = Record.readSubExpr();
1833 E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
1836 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1837 VisitExpr(E);
1838 E->Param = readDeclAs<ParmVarDecl>();
1839 E->UsedContext = readDeclAs<DeclContext>();
1840 E->CXXDefaultArgExprBits.Loc = readSourceLocation();
1841 E->CXXDefaultArgExprBits.HasRewrittenInit = Record.readInt();
1842 if (E->CXXDefaultArgExprBits.HasRewrittenInit)
1843 *E->getTrailingObjects<Expr *>() = Record.readSubExpr();
1846 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1847 VisitExpr(E);
1848 E->CXXDefaultInitExprBits.HasRewrittenInit = Record.readInt();
1849 E->Field = readDeclAs<FieldDecl>();
1850 E->UsedContext = readDeclAs<DeclContext>();
1851 E->CXXDefaultInitExprBits.Loc = readSourceLocation();
1852 if (E->CXXDefaultInitExprBits.HasRewrittenInit)
1853 *E->getTrailingObjects<Expr *>() = Record.readSubExpr();
1856 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1857 VisitExpr(E);
1858 E->setTemporary(Record.readCXXTemporary());
1859 E->setSubExpr(Record.readSubExpr());
1862 void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1863 VisitExpr(E);
1864 E->TypeInfo = readTypeSourceInfo();
1865 E->CXXScalarValueInitExprBits.RParenLoc = readSourceLocation();
1868 void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
1869 VisitExpr(E);
1871 bool IsArray = Record.readInt();
1872 bool HasInit = Record.readInt();
1873 unsigned NumPlacementArgs = Record.readInt();
1874 bool IsParenTypeId = Record.readInt();
1876 E->CXXNewExprBits.IsGlobalNew = Record.readInt();
1877 E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
1878 E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1879 E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
1881 assert((IsArray == E->isArray()) && "Wrong IsArray!");
1882 assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
1883 assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
1884 "Wrong NumPlacementArgs!");
1885 assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
1886 (void)IsArray;
1887 (void)HasInit;
1888 (void)NumPlacementArgs;
1890 E->setOperatorNew(readDeclAs<FunctionDecl>());
1891 E->setOperatorDelete(readDeclAs<FunctionDecl>());
1892 E->AllocatedTypeInfo = readTypeSourceInfo();
1893 if (IsParenTypeId)
1894 E->getTrailingObjects<SourceRange>()[0] = readSourceRange();
1895 E->Range = readSourceRange();
1896 E->DirectInitRange = readSourceRange();
1898 // Install all the subexpressions.
1899 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
1900 N = E->raw_arg_end();
1901 I != N; ++I)
1902 *I = Record.readSubStmt();
1905 void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1906 VisitExpr(E);
1907 E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
1908 E->CXXDeleteExprBits.ArrayForm = Record.readInt();
1909 E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
1910 E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1911 E->OperatorDelete = readDeclAs<FunctionDecl>();
1912 E->Argument = Record.readSubExpr();
1913 E->CXXDeleteExprBits.Loc = readSourceLocation();
1916 void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1917 VisitExpr(E);
1919 E->Base = Record.readSubExpr();
1920 E->IsArrow = Record.readInt();
1921 E->OperatorLoc = readSourceLocation();
1922 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1923 E->ScopeType = readTypeSourceInfo();
1924 E->ColonColonLoc = readSourceLocation();
1925 E->TildeLoc = readSourceLocation();
1927 IdentifierInfo *II = Record.readIdentifier();
1928 if (II)
1929 E->setDestroyedType(II, readSourceLocation());
1930 else
1931 E->setDestroyedType(readTypeSourceInfo());
1934 void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
1935 VisitExpr(E);
1937 unsigned NumObjects = Record.readInt();
1938 assert(NumObjects == E->getNumObjects());
1939 for (unsigned i = 0; i != NumObjects; ++i) {
1940 unsigned CleanupKind = Record.readInt();
1941 ExprWithCleanups::CleanupObject Obj;
1942 if (CleanupKind == COK_Block)
1943 Obj = readDeclAs<BlockDecl>();
1944 else if (CleanupKind == COK_CompoundLiteral)
1945 Obj = cast<CompoundLiteralExpr>(Record.readSubExpr());
1946 else
1947 llvm_unreachable("unexpected cleanup object type");
1948 E->getTrailingObjects<ExprWithCleanups::CleanupObject>()[i] = Obj;
1951 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
1952 E->SubExpr = Record.readSubExpr();
1955 void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1956 CXXDependentScopeMemberExpr *E) {
1957 VisitExpr(E);
1959 bool HasTemplateKWAndArgsInfo = Record.readInt();
1960 unsigned NumTemplateArgs = Record.readInt();
1961 bool HasFirstQualifierFoundInScope = Record.readInt();
1963 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
1964 "Wrong HasTemplateKWAndArgsInfo!");
1965 assert(
1966 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
1967 "Wrong HasFirstQualifierFoundInScope!");
1969 if (HasTemplateKWAndArgsInfo)
1970 ReadTemplateKWAndArgsInfo(
1971 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1972 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
1974 assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
1975 "Wrong NumTemplateArgs!");
1977 E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
1978 E->CXXDependentScopeMemberExprBits.OperatorLoc = readSourceLocation();
1979 E->BaseType = Record.readType();
1980 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1981 E->Base = Record.readSubExpr();
1983 if (HasFirstQualifierFoundInScope)
1984 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
1986 E->MemberNameInfo = Record.readDeclarationNameInfo();
1989 void
1990 ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
1991 VisitExpr(E);
1993 if (Record.readInt()) // HasTemplateKWAndArgsInfo
1994 ReadTemplateKWAndArgsInfo(
1995 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1996 E->getTrailingObjects<TemplateArgumentLoc>(),
1997 /*NumTemplateArgs=*/Record.readInt());
1999 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
2000 E->NameInfo = Record.readDeclarationNameInfo();
2003 void
2004 ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
2005 VisitExpr(E);
2006 assert(Record.peekInt() == E->getNumArgs() &&
2007 "Read wrong record during creation ?");
2008 Record.skipInts(1);
2009 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
2010 E->setArg(I, Record.readSubExpr());
2011 E->TypeAndInitForm.setPointer(readTypeSourceInfo());
2012 E->setLParenLoc(readSourceLocation());
2013 E->setRParenLoc(readSourceLocation());
2014 E->TypeAndInitForm.setInt(Record.readInt());
2017 void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
2018 VisitExpr(E);
2020 unsigned NumResults = Record.readInt();
2021 bool HasTemplateKWAndArgsInfo = Record.readInt();
2022 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
2023 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
2024 "Wrong HasTemplateKWAndArgsInfo!");
2026 if (HasTemplateKWAndArgsInfo) {
2027 unsigned NumTemplateArgs = Record.readInt();
2028 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
2029 E->getTrailingTemplateArgumentLoc(),
2030 NumTemplateArgs);
2031 assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
2032 "Wrong NumTemplateArgs!");
2035 UnresolvedSet<8> Decls;
2036 for (unsigned I = 0; I != NumResults; ++I) {
2037 auto *D = readDeclAs<NamedDecl>();
2038 auto AS = (AccessSpecifier)Record.readInt();
2039 Decls.addDecl(D, AS);
2042 DeclAccessPair *Results = E->getTrailingResults();
2043 UnresolvedSetIterator Iter = Decls.begin();
2044 for (unsigned I = 0; I != NumResults; ++I) {
2045 Results[I] = (Iter + I).getPair();
2048 E->NameInfo = Record.readDeclarationNameInfo();
2049 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
2052 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
2053 VisitOverloadExpr(E);
2054 E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
2055 E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
2056 E->Base = Record.readSubExpr();
2057 E->BaseType = Record.readType();
2058 E->OperatorLoc = readSourceLocation();
2061 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
2062 VisitOverloadExpr(E);
2063 E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
2064 E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
2065 E->NamingClass = readDeclAs<CXXRecordDecl>();
2068 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
2069 VisitExpr(E);
2070 E->TypeTraitExprBits.NumArgs = Record.readInt();
2071 E->TypeTraitExprBits.Kind = Record.readInt();
2072 E->TypeTraitExprBits.Value = Record.readInt();
2073 SourceRange Range = readSourceRange();
2074 E->Loc = Range.getBegin();
2075 E->RParenLoc = Range.getEnd();
2077 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
2078 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
2079 Args[I] = readTypeSourceInfo();
2082 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
2083 VisitExpr(E);
2084 E->ATT = (ArrayTypeTrait)Record.readInt();
2085 E->Value = (unsigned int)Record.readInt();
2086 SourceRange Range = readSourceRange();
2087 E->Loc = Range.getBegin();
2088 E->RParen = Range.getEnd();
2089 E->QueriedType = readTypeSourceInfo();
2090 E->Dimension = Record.readSubExpr();
2093 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
2094 VisitExpr(E);
2095 E->ET = (ExpressionTrait)Record.readInt();
2096 E->Value = (bool)Record.readInt();
2097 SourceRange Range = readSourceRange();
2098 E->QueriedExpression = Record.readSubExpr();
2099 E->Loc = Range.getBegin();
2100 E->RParen = Range.getEnd();
2103 void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
2104 VisitExpr(E);
2105 E->CXXNoexceptExprBits.Value = Record.readInt();
2106 E->Range = readSourceRange();
2107 E->Operand = Record.readSubExpr();
2110 void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
2111 VisitExpr(E);
2112 E->EllipsisLoc = readSourceLocation();
2113 E->NumExpansions = Record.readInt();
2114 E->Pattern = Record.readSubExpr();
2117 void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2118 VisitExpr(E);
2119 unsigned NumPartialArgs = Record.readInt();
2120 E->OperatorLoc = readSourceLocation();
2121 E->PackLoc = readSourceLocation();
2122 E->RParenLoc = readSourceLocation();
2123 E->Pack = Record.readDeclAs<NamedDecl>();
2124 if (E->isPartiallySubstituted()) {
2125 assert(E->Length == NumPartialArgs);
2126 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
2127 *E = I + NumPartialArgs;
2128 I != E; ++I)
2129 new (I) TemplateArgument(Record.readTemplateArgument());
2130 } else if (!E->isValueDependent()) {
2131 E->Length = Record.readInt();
2135 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
2136 SubstNonTypeTemplateParmExpr *E) {
2137 VisitExpr(E);
2138 E->AssociatedDeclAndRef.setPointer(readDeclAs<Decl>());
2139 E->AssociatedDeclAndRef.setInt(Record.readInt());
2140 E->Index = Record.readInt();
2141 E->PackIndex = Record.readInt();
2142 E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
2143 E->Replacement = Record.readSubExpr();
2146 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
2147 SubstNonTypeTemplateParmPackExpr *E) {
2148 VisitExpr(E);
2149 E->AssociatedDecl = readDeclAs<Decl>();
2150 E->Index = Record.readInt();
2151 TemplateArgument ArgPack = Record.readTemplateArgument();
2152 if (ArgPack.getKind() != TemplateArgument::Pack)
2153 return;
2155 E->Arguments = ArgPack.pack_begin();
2156 E->NumArguments = ArgPack.pack_size();
2157 E->NameLoc = readSourceLocation();
2160 void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2161 VisitExpr(E);
2162 E->NumParameters = Record.readInt();
2163 E->ParamPack = readDeclAs<ParmVarDecl>();
2164 E->NameLoc = readSourceLocation();
2165 auto **Parms = E->getTrailingObjects<VarDecl *>();
2166 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
2167 Parms[i] = readDeclAs<VarDecl>();
2170 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
2171 VisitExpr(E);
2172 bool HasMaterialzedDecl = Record.readInt();
2173 if (HasMaterialzedDecl)
2174 E->State = cast<LifetimeExtendedTemporaryDecl>(Record.readDecl());
2175 else
2176 E->State = Record.readSubExpr();
2179 void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
2180 VisitExpr(E);
2181 E->LParenLoc = readSourceLocation();
2182 E->EllipsisLoc = readSourceLocation();
2183 E->RParenLoc = readSourceLocation();
2184 E->NumExpansions = Record.readInt();
2185 E->SubExprs[0] = Record.readSubExpr();
2186 E->SubExprs[1] = Record.readSubExpr();
2187 E->SubExprs[2] = Record.readSubExpr();
2188 E->Opcode = (BinaryOperatorKind)Record.readInt();
2191 void ASTStmtReader::VisitCXXParenListInitExpr(CXXParenListInitExpr *E) {
2192 VisitExpr(E);
2193 unsigned ExpectedNumExprs = Record.readInt();
2194 assert(E->NumExprs == ExpectedNumExprs &&
2195 "expected number of expressions does not equal the actual number of "
2196 "serialized expressions.");
2197 E->NumUserSpecifiedExprs = Record.readInt();
2198 E->InitLoc = readSourceLocation();
2199 E->LParenLoc = readSourceLocation();
2200 E->RParenLoc = readSourceLocation();
2201 for (unsigned I = 0; I < ExpectedNumExprs; I++)
2202 E->getTrailingObjects<Expr *>()[I] = Record.readSubExpr();
2204 bool HasArrayFillerOrUnionDecl = Record.readBool();
2205 if (HasArrayFillerOrUnionDecl) {
2206 bool HasArrayFiller = Record.readBool();
2207 if (HasArrayFiller) {
2208 E->setArrayFiller(Record.readSubExpr());
2209 } else {
2210 E->setInitializedFieldInUnion(readDeclAs<FieldDecl>());
2213 E->updateDependence();
2216 void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
2217 VisitExpr(E);
2218 E->SourceExpr = Record.readSubExpr();
2219 E->OpaqueValueExprBits.Loc = readSourceLocation();
2220 E->setIsUnique(Record.readInt());
2223 void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
2224 llvm_unreachable("Cannot read TypoExpr nodes");
2227 void ASTStmtReader::VisitRecoveryExpr(RecoveryExpr *E) {
2228 VisitExpr(E);
2229 unsigned NumArgs = Record.readInt();
2230 E->BeginLoc = readSourceLocation();
2231 E->EndLoc = readSourceLocation();
2232 assert((NumArgs + 0LL ==
2233 std::distance(E->children().begin(), E->children().end())) &&
2234 "Wrong NumArgs!");
2235 (void)NumArgs;
2236 for (Stmt *&Child : E->children())
2237 Child = Record.readSubStmt();
2240 //===----------------------------------------------------------------------===//
2241 // Microsoft Expressions and Statements
2242 //===----------------------------------------------------------------------===//
2243 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
2244 VisitExpr(E);
2245 E->IsArrow = (Record.readInt() != 0);
2246 E->BaseExpr = Record.readSubExpr();
2247 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
2248 E->MemberLoc = readSourceLocation();
2249 E->TheDecl = readDeclAs<MSPropertyDecl>();
2252 void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
2253 VisitExpr(E);
2254 E->setBase(Record.readSubExpr());
2255 E->setIdx(Record.readSubExpr());
2256 E->setRBracketLoc(readSourceLocation());
2259 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
2260 VisitExpr(E);
2261 E->setSourceRange(readSourceRange());
2262 E->Guid = readDeclAs<MSGuidDecl>();
2263 if (E->isTypeOperand())
2264 E->Operand = readTypeSourceInfo();
2265 else
2266 E->Operand = Record.readSubExpr();
2269 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
2270 VisitStmt(S);
2271 S->setLeaveLoc(readSourceLocation());
2274 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
2275 VisitStmt(S);
2276 S->Loc = readSourceLocation();
2277 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
2278 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
2281 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
2282 VisitStmt(S);
2283 S->Loc = readSourceLocation();
2284 S->Block = Record.readSubStmt();
2287 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
2288 VisitStmt(S);
2289 S->IsCXXTry = Record.readInt();
2290 S->TryLoc = readSourceLocation();
2291 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
2292 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
2295 //===----------------------------------------------------------------------===//
2296 // CUDA Expressions and Statements
2297 //===----------------------------------------------------------------------===//
2299 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2300 VisitCallExpr(E);
2301 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
2304 //===----------------------------------------------------------------------===//
2305 // OpenCL Expressions and Statements.
2306 //===----------------------------------------------------------------------===//
2307 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2308 VisitExpr(E);
2309 E->BuiltinLoc = readSourceLocation();
2310 E->RParenLoc = readSourceLocation();
2311 E->SrcExpr = Record.readSubExpr();
2314 //===----------------------------------------------------------------------===//
2315 // OpenMP Directives.
2316 //===----------------------------------------------------------------------===//
2318 void ASTStmtReader::VisitOMPCanonicalLoop(OMPCanonicalLoop *S) {
2319 VisitStmt(S);
2320 for (Stmt *&SubStmt : S->SubStmts)
2321 SubStmt = Record.readSubStmt();
2324 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
2325 Record.readOMPChildren(E->Data);
2326 E->setLocStart(readSourceLocation());
2327 E->setLocEnd(readSourceLocation());
2330 void ASTStmtReader::VisitOMPLoopBasedDirective(OMPLoopBasedDirective *D) {
2331 VisitStmt(D);
2332 // Field CollapsedNum was read in ReadStmtFromStream.
2333 Record.skipInts(1);
2334 VisitOMPExecutableDirective(D);
2337 void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2338 VisitOMPLoopBasedDirective(D);
2341 void ASTStmtReader::VisitOMPMetaDirective(OMPMetaDirective *D) {
2342 VisitStmt(D);
2343 // The NumClauses field was read in ReadStmtFromStream.
2344 Record.skipInts(1);
2345 VisitOMPExecutableDirective(D);
2348 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
2349 VisitStmt(D);
2350 VisitOMPExecutableDirective(D);
2351 D->setHasCancel(Record.readBool());
2354 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
2355 VisitOMPLoopDirective(D);
2358 void ASTStmtReader::VisitOMPLoopTransformationDirective(
2359 OMPLoopTransformationDirective *D) {
2360 VisitOMPLoopBasedDirective(D);
2361 D->setNumGeneratedLoops(Record.readUInt32());
2364 void ASTStmtReader::VisitOMPTileDirective(OMPTileDirective *D) {
2365 VisitOMPLoopTransformationDirective(D);
2368 void ASTStmtReader::VisitOMPUnrollDirective(OMPUnrollDirective *D) {
2369 VisitOMPLoopTransformationDirective(D);
2372 void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
2373 VisitOMPLoopDirective(D);
2374 D->setHasCancel(Record.readBool());
2377 void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2378 VisitOMPLoopDirective(D);
2381 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2382 VisitStmt(D);
2383 VisitOMPExecutableDirective(D);
2384 D->setHasCancel(Record.readBool());
2387 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2388 VisitStmt(D);
2389 VisitOMPExecutableDirective(D);
2390 D->setHasCancel(Record.readBool());
2393 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2394 VisitStmt(D);
2395 VisitOMPExecutableDirective(D);
2398 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2399 VisitStmt(D);
2400 VisitOMPExecutableDirective(D);
2403 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2404 VisitStmt(D);
2405 VisitOMPExecutableDirective(D);
2406 D->DirName = Record.readDeclarationNameInfo();
2409 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
2410 VisitOMPLoopDirective(D);
2411 D->setHasCancel(Record.readBool());
2414 void ASTStmtReader::VisitOMPParallelForSimdDirective(
2415 OMPParallelForSimdDirective *D) {
2416 VisitOMPLoopDirective(D);
2419 void ASTStmtReader::VisitOMPParallelMasterDirective(
2420 OMPParallelMasterDirective *D) {
2421 VisitStmt(D);
2422 VisitOMPExecutableDirective(D);
2425 void ASTStmtReader::VisitOMPParallelMaskedDirective(
2426 OMPParallelMaskedDirective *D) {
2427 VisitStmt(D);
2428 VisitOMPExecutableDirective(D);
2431 void ASTStmtReader::VisitOMPParallelSectionsDirective(
2432 OMPParallelSectionsDirective *D) {
2433 VisitStmt(D);
2434 VisitOMPExecutableDirective(D);
2435 D->setHasCancel(Record.readBool());
2438 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2439 VisitStmt(D);
2440 VisitOMPExecutableDirective(D);
2441 D->setHasCancel(Record.readBool());
2444 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2445 VisitStmt(D);
2446 VisitOMPExecutableDirective(D);
2449 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2450 VisitStmt(D);
2451 VisitOMPExecutableDirective(D);
2454 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2455 VisitStmt(D);
2456 // The NumClauses field was read in ReadStmtFromStream.
2457 Record.skipInts(1);
2458 VisitOMPExecutableDirective(D);
2461 void ASTStmtReader::VisitOMPErrorDirective(OMPErrorDirective *D) {
2462 VisitStmt(D);
2463 // The NumClauses field was read in ReadStmtFromStream.
2464 Record.skipInts(1);
2465 VisitOMPExecutableDirective(D);
2468 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2469 VisitStmt(D);
2470 VisitOMPExecutableDirective(D);
2473 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2474 VisitStmt(D);
2475 VisitOMPExecutableDirective(D);
2478 void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective *D) {
2479 VisitStmt(D);
2480 VisitOMPExecutableDirective(D);
2483 void ASTStmtReader::VisitOMPScanDirective(OMPScanDirective *D) {
2484 VisitStmt(D);
2485 VisitOMPExecutableDirective(D);
2488 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2489 VisitStmt(D);
2490 VisitOMPExecutableDirective(D);
2493 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2494 VisitStmt(D);
2495 VisitOMPExecutableDirective(D);
2496 D->Flags.IsXLHSInRHSPart = Record.readBool() ? 1 : 0;
2497 D->Flags.IsPostfixUpdate = Record.readBool() ? 1 : 0;
2498 D->Flags.IsFailOnly = Record.readBool() ? 1 : 0;
2501 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2502 VisitStmt(D);
2503 VisitOMPExecutableDirective(D);
2506 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2507 VisitStmt(D);
2508 VisitOMPExecutableDirective(D);
2511 void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2512 OMPTargetEnterDataDirective *D) {
2513 VisitStmt(D);
2514 VisitOMPExecutableDirective(D);
2517 void ASTStmtReader::VisitOMPTargetExitDataDirective(
2518 OMPTargetExitDataDirective *D) {
2519 VisitStmt(D);
2520 VisitOMPExecutableDirective(D);
2523 void ASTStmtReader::VisitOMPTargetParallelDirective(
2524 OMPTargetParallelDirective *D) {
2525 VisitStmt(D);
2526 VisitOMPExecutableDirective(D);
2527 D->setHasCancel(Record.readBool());
2530 void ASTStmtReader::VisitOMPTargetParallelForDirective(
2531 OMPTargetParallelForDirective *D) {
2532 VisitOMPLoopDirective(D);
2533 D->setHasCancel(Record.readBool());
2536 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2537 VisitStmt(D);
2538 VisitOMPExecutableDirective(D);
2541 void ASTStmtReader::VisitOMPCancellationPointDirective(
2542 OMPCancellationPointDirective *D) {
2543 VisitStmt(D);
2544 VisitOMPExecutableDirective(D);
2545 D->setCancelRegion(Record.readEnum<OpenMPDirectiveKind>());
2548 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2549 VisitStmt(D);
2550 VisitOMPExecutableDirective(D);
2551 D->setCancelRegion(Record.readEnum<OpenMPDirectiveKind>());
2554 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2555 VisitOMPLoopDirective(D);
2556 D->setHasCancel(Record.readBool());
2559 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2560 VisitOMPLoopDirective(D);
2563 void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2564 OMPMasterTaskLoopDirective *D) {
2565 VisitOMPLoopDirective(D);
2566 D->setHasCancel(Record.readBool());
2569 void ASTStmtReader::VisitOMPMaskedTaskLoopDirective(
2570 OMPMaskedTaskLoopDirective *D) {
2571 VisitOMPLoopDirective(D);
2572 D->setHasCancel(Record.readBool());
2575 void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2576 OMPMasterTaskLoopSimdDirective *D) {
2577 VisitOMPLoopDirective(D);
2580 void ASTStmtReader::VisitOMPMaskedTaskLoopSimdDirective(
2581 OMPMaskedTaskLoopSimdDirective *D) {
2582 VisitOMPLoopDirective(D);
2585 void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2586 OMPParallelMasterTaskLoopDirective *D) {
2587 VisitOMPLoopDirective(D);
2588 D->setHasCancel(Record.readBool());
2591 void ASTStmtReader::VisitOMPParallelMaskedTaskLoopDirective(
2592 OMPParallelMaskedTaskLoopDirective *D) {
2593 VisitOMPLoopDirective(D);
2594 D->setHasCancel(Record.readBool());
2597 void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2598 OMPParallelMasterTaskLoopSimdDirective *D) {
2599 VisitOMPLoopDirective(D);
2602 void ASTStmtReader::VisitOMPParallelMaskedTaskLoopSimdDirective(
2603 OMPParallelMaskedTaskLoopSimdDirective *D) {
2604 VisitOMPLoopDirective(D);
2607 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2608 VisitOMPLoopDirective(D);
2611 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2612 VisitStmt(D);
2613 VisitOMPExecutableDirective(D);
2616 void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2617 OMPDistributeParallelForDirective *D) {
2618 VisitOMPLoopDirective(D);
2619 D->setHasCancel(Record.readBool());
2622 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2623 OMPDistributeParallelForSimdDirective *D) {
2624 VisitOMPLoopDirective(D);
2627 void ASTStmtReader::VisitOMPDistributeSimdDirective(
2628 OMPDistributeSimdDirective *D) {
2629 VisitOMPLoopDirective(D);
2632 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2633 OMPTargetParallelForSimdDirective *D) {
2634 VisitOMPLoopDirective(D);
2637 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2638 VisitOMPLoopDirective(D);
2641 void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2642 OMPTeamsDistributeDirective *D) {
2643 VisitOMPLoopDirective(D);
2646 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2647 OMPTeamsDistributeSimdDirective *D) {
2648 VisitOMPLoopDirective(D);
2651 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2652 OMPTeamsDistributeParallelForSimdDirective *D) {
2653 VisitOMPLoopDirective(D);
2656 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2657 OMPTeamsDistributeParallelForDirective *D) {
2658 VisitOMPLoopDirective(D);
2659 D->setHasCancel(Record.readBool());
2662 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2663 VisitStmt(D);
2664 VisitOMPExecutableDirective(D);
2667 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2668 OMPTargetTeamsDistributeDirective *D) {
2669 VisitOMPLoopDirective(D);
2672 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2673 OMPTargetTeamsDistributeParallelForDirective *D) {
2674 VisitOMPLoopDirective(D);
2675 D->setHasCancel(Record.readBool());
2678 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2679 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2680 VisitOMPLoopDirective(D);
2683 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2684 OMPTargetTeamsDistributeSimdDirective *D) {
2685 VisitOMPLoopDirective(D);
2688 void ASTStmtReader::VisitOMPInteropDirective(OMPInteropDirective *D) {
2689 VisitStmt(D);
2690 VisitOMPExecutableDirective(D);
2693 void ASTStmtReader::VisitOMPDispatchDirective(OMPDispatchDirective *D) {
2694 VisitStmt(D);
2695 VisitOMPExecutableDirective(D);
2696 D->setTargetCallLoc(Record.readSourceLocation());
2699 void ASTStmtReader::VisitOMPMaskedDirective(OMPMaskedDirective *D) {
2700 VisitStmt(D);
2701 VisitOMPExecutableDirective(D);
2704 void ASTStmtReader::VisitOMPGenericLoopDirective(OMPGenericLoopDirective *D) {
2705 VisitOMPLoopDirective(D);
2708 void ASTStmtReader::VisitOMPTeamsGenericLoopDirective(
2709 OMPTeamsGenericLoopDirective *D) {
2710 VisitOMPLoopDirective(D);
2713 void ASTStmtReader::VisitOMPTargetTeamsGenericLoopDirective(
2714 OMPTargetTeamsGenericLoopDirective *D) {
2715 VisitOMPLoopDirective(D);
2718 void ASTStmtReader::VisitOMPParallelGenericLoopDirective(
2719 OMPParallelGenericLoopDirective *D) {
2720 VisitOMPLoopDirective(D);
2723 void ASTStmtReader::VisitOMPTargetParallelGenericLoopDirective(
2724 OMPTargetParallelGenericLoopDirective *D) {
2725 VisitOMPLoopDirective(D);
2728 //===----------------------------------------------------------------------===//
2729 // ASTReader Implementation
2730 //===----------------------------------------------------------------------===//
2732 Stmt *ASTReader::ReadStmt(ModuleFile &F) {
2733 switch (ReadingKind) {
2734 case Read_None:
2735 llvm_unreachable("should not call this when not reading anything");
2736 case Read_Decl:
2737 case Read_Type:
2738 return ReadStmtFromStream(F);
2739 case Read_Stmt:
2740 return ReadSubStmt();
2743 llvm_unreachable("ReadingKind not set ?");
2746 Expr *ASTReader::ReadExpr(ModuleFile &F) {
2747 return cast_or_null<Expr>(ReadStmt(F));
2750 Expr *ASTReader::ReadSubExpr() {
2751 return cast_or_null<Expr>(ReadSubStmt());
2754 // Within the bitstream, expressions are stored in Reverse Polish
2755 // Notation, with each of the subexpressions preceding the
2756 // expression they are stored in. Subexpressions are stored from last to first.
2757 // To evaluate expressions, we continue reading expressions and placing them on
2758 // the stack, with expressions having operands removing those operands from the
2759 // stack. Evaluation terminates when we see a STMT_STOP record, and
2760 // the single remaining expression on the stack is our result.
2761 Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
2762 ReadingKindTracker ReadingKind(Read_Stmt, *this);
2763 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
2765 // Map of offset to previously deserialized stmt. The offset points
2766 // just after the stmt record.
2767 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
2769 #ifndef NDEBUG
2770 unsigned PrevNumStmts = StmtStack.size();
2771 #endif
2773 ASTRecordReader Record(*this, F);
2774 ASTStmtReader Reader(Record, Cursor);
2775 Stmt::EmptyShell Empty;
2777 while (true) {
2778 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2779 Cursor.advanceSkippingSubblocks();
2780 if (!MaybeEntry) {
2781 Error(toString(MaybeEntry.takeError()));
2782 return nullptr;
2784 llvm::BitstreamEntry Entry = MaybeEntry.get();
2786 switch (Entry.Kind) {
2787 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2788 case llvm::BitstreamEntry::Error:
2789 Error("malformed block record in AST file");
2790 return nullptr;
2791 case llvm::BitstreamEntry::EndBlock:
2792 goto Done;
2793 case llvm::BitstreamEntry::Record:
2794 // The interesting case.
2795 break;
2798 ASTContext &Context = getContext();
2799 Stmt *S = nullptr;
2800 bool Finished = false;
2801 bool IsStmtReference = false;
2802 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2803 if (!MaybeStmtCode) {
2804 Error(toString(MaybeStmtCode.takeError()));
2805 return nullptr;
2807 switch ((StmtCode)MaybeStmtCode.get()) {
2808 case STMT_STOP:
2809 Finished = true;
2810 break;
2812 case STMT_REF_PTR:
2813 IsStmtReference = true;
2814 assert(StmtEntries.contains(Record[0]) &&
2815 "No stmt was recorded for this offset reference!");
2816 S = StmtEntries[Record.readInt()];
2817 break;
2819 case STMT_NULL_PTR:
2820 S = nullptr;
2821 break;
2823 case STMT_NULL:
2824 S = new (Context) NullStmt(Empty);
2825 break;
2827 case STMT_COMPOUND:
2828 S = CompoundStmt::CreateEmpty(
2829 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields],
2830 /*HasFPFeatures=*/Record[ASTStmtReader::NumStmtFields + 1]);
2831 break;
2833 case STMT_CASE:
2834 S = CaseStmt::CreateEmpty(
2835 Context,
2836 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
2837 break;
2839 case STMT_DEFAULT:
2840 S = new (Context) DefaultStmt(Empty);
2841 break;
2843 case STMT_LABEL:
2844 S = new (Context) LabelStmt(Empty);
2845 break;
2847 case STMT_ATTRIBUTED:
2848 S = AttributedStmt::CreateEmpty(
2849 Context,
2850 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
2851 break;
2853 case STMT_IF:
2854 S = IfStmt::CreateEmpty(
2855 Context,
2856 /* HasElse=*/Record[ASTStmtReader::NumStmtFields],
2857 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1],
2858 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 2]);
2859 break;
2861 case STMT_SWITCH:
2862 S = SwitchStmt::CreateEmpty(
2863 Context,
2864 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
2865 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
2866 break;
2868 case STMT_WHILE:
2869 S = WhileStmt::CreateEmpty(
2870 Context,
2871 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
2872 break;
2874 case STMT_DO:
2875 S = new (Context) DoStmt(Empty);
2876 break;
2878 case STMT_FOR:
2879 S = new (Context) ForStmt(Empty);
2880 break;
2882 case STMT_GOTO:
2883 S = new (Context) GotoStmt(Empty);
2884 break;
2886 case STMT_INDIRECT_GOTO:
2887 S = new (Context) IndirectGotoStmt(Empty);
2888 break;
2890 case STMT_CONTINUE:
2891 S = new (Context) ContinueStmt(Empty);
2892 break;
2894 case STMT_BREAK:
2895 S = new (Context) BreakStmt(Empty);
2896 break;
2898 case STMT_RETURN:
2899 S = ReturnStmt::CreateEmpty(
2900 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
2901 break;
2903 case STMT_DECL:
2904 S = new (Context) DeclStmt(Empty);
2905 break;
2907 case STMT_GCCASM:
2908 S = new (Context) GCCAsmStmt(Empty);
2909 break;
2911 case STMT_MSASM:
2912 S = new (Context) MSAsmStmt(Empty);
2913 break;
2915 case STMT_CAPTURED:
2916 S = CapturedStmt::CreateDeserialized(
2917 Context, Record[ASTStmtReader::NumStmtFields]);
2918 break;
2920 case EXPR_CONSTANT:
2921 S = ConstantExpr::CreateEmpty(
2922 Context, static_cast<ConstantExpr::ResultStorageKind>(
2923 /*StorageKind=*/Record[ASTStmtReader::NumExprFields]));
2924 break;
2926 case EXPR_SYCL_UNIQUE_STABLE_NAME:
2927 S = SYCLUniqueStableNameExpr::CreateEmpty(Context);
2928 break;
2930 case EXPR_PREDEFINED:
2931 S = PredefinedExpr::CreateEmpty(
2932 Context,
2933 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
2934 break;
2936 case EXPR_DECL_REF:
2937 S = DeclRefExpr::CreateEmpty(
2938 Context,
2939 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2940 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
2941 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
2942 /*NumTemplateArgs=*/
2943 Record[ASTStmtReader::NumExprFields + 2]
2944 ? Record[ASTStmtReader::NumExprFields + 7]
2945 : 0);
2946 break;
2948 case EXPR_INTEGER_LITERAL:
2949 S = IntegerLiteral::Create(Context, Empty);
2950 break;
2952 case EXPR_FIXEDPOINT_LITERAL:
2953 S = FixedPointLiteral::Create(Context, Empty);
2954 break;
2956 case EXPR_FLOATING_LITERAL:
2957 S = FloatingLiteral::Create(Context, Empty);
2958 break;
2960 case EXPR_IMAGINARY_LITERAL:
2961 S = new (Context) ImaginaryLiteral(Empty);
2962 break;
2964 case EXPR_STRING_LITERAL:
2965 S = StringLiteral::CreateEmpty(
2966 Context,
2967 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
2968 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2969 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
2970 break;
2972 case EXPR_CHARACTER_LITERAL:
2973 S = new (Context) CharacterLiteral(Empty);
2974 break;
2976 case EXPR_PAREN:
2977 S = new (Context) ParenExpr(Empty);
2978 break;
2980 case EXPR_PAREN_LIST:
2981 S = ParenListExpr::CreateEmpty(
2982 Context,
2983 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
2984 break;
2986 case EXPR_UNARY_OPERATOR:
2987 S = UnaryOperator::CreateEmpty(Context,
2988 Record[ASTStmtReader::NumExprFields]);
2989 break;
2991 case EXPR_OFFSETOF:
2992 S = OffsetOfExpr::CreateEmpty(Context,
2993 Record[ASTStmtReader::NumExprFields],
2994 Record[ASTStmtReader::NumExprFields + 1]);
2995 break;
2997 case EXPR_SIZEOF_ALIGN_OF:
2998 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
2999 break;
3001 case EXPR_ARRAY_SUBSCRIPT:
3002 S = new (Context) ArraySubscriptExpr(Empty);
3003 break;
3005 case EXPR_MATRIX_SUBSCRIPT:
3006 S = new (Context) MatrixSubscriptExpr(Empty);
3007 break;
3009 case EXPR_OMP_ARRAY_SECTION:
3010 S = new (Context) OMPArraySectionExpr(Empty);
3011 break;
3013 case EXPR_OMP_ARRAY_SHAPING:
3014 S = OMPArrayShapingExpr::CreateEmpty(
3015 Context, Record[ASTStmtReader::NumExprFields]);
3016 break;
3018 case EXPR_OMP_ITERATOR:
3019 S = OMPIteratorExpr::CreateEmpty(Context,
3020 Record[ASTStmtReader::NumExprFields]);
3021 break;
3023 case EXPR_CALL:
3024 S = CallExpr::CreateEmpty(
3025 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields],
3026 /*HasFPFeatures=*/Record[ASTStmtReader::NumExprFields + 1], Empty);
3027 break;
3029 case EXPR_RECOVERY:
3030 S = RecoveryExpr::CreateEmpty(
3031 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3032 break;
3034 case EXPR_MEMBER:
3035 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
3036 Record[ASTStmtReader::NumExprFields + 1],
3037 Record[ASTStmtReader::NumExprFields + 2],
3038 Record[ASTStmtReader::NumExprFields + 3]);
3039 break;
3041 case EXPR_BINARY_OPERATOR:
3042 S = BinaryOperator::CreateEmpty(Context,
3043 Record[ASTStmtReader::NumExprFields]);
3044 break;
3046 case EXPR_COMPOUND_ASSIGN_OPERATOR:
3047 S = CompoundAssignOperator::CreateEmpty(
3048 Context, Record[ASTStmtReader::NumExprFields]);
3049 break;
3051 case EXPR_CONDITIONAL_OPERATOR:
3052 S = new (Context) ConditionalOperator(Empty);
3053 break;
3055 case EXPR_BINARY_CONDITIONAL_OPERATOR:
3056 S = new (Context) BinaryConditionalOperator(Empty);
3057 break;
3059 case EXPR_IMPLICIT_CAST:
3060 S = ImplicitCastExpr::CreateEmpty(
3061 Context,
3062 /*PathSize*/ Record[ASTStmtReader::NumExprFields],
3063 /*HasFPFeatures*/ Record[ASTStmtReader::NumExprFields + 1]);
3064 break;
3066 case EXPR_CSTYLE_CAST:
3067 S = CStyleCastExpr::CreateEmpty(
3068 Context,
3069 /*PathSize*/ Record[ASTStmtReader::NumExprFields],
3070 /*HasFPFeatures*/ Record[ASTStmtReader::NumExprFields + 1]);
3071 break;
3073 case EXPR_COMPOUND_LITERAL:
3074 S = new (Context) CompoundLiteralExpr(Empty);
3075 break;
3077 case EXPR_EXT_VECTOR_ELEMENT:
3078 S = new (Context) ExtVectorElementExpr(Empty);
3079 break;
3081 case EXPR_INIT_LIST:
3082 S = new (Context) InitListExpr(Empty);
3083 break;
3085 case EXPR_DESIGNATED_INIT:
3086 S = DesignatedInitExpr::CreateEmpty(Context,
3087 Record[ASTStmtReader::NumExprFields] - 1);
3089 break;
3091 case EXPR_DESIGNATED_INIT_UPDATE:
3092 S = new (Context) DesignatedInitUpdateExpr(Empty);
3093 break;
3095 case EXPR_IMPLICIT_VALUE_INIT:
3096 S = new (Context) ImplicitValueInitExpr(Empty);
3097 break;
3099 case EXPR_NO_INIT:
3100 S = new (Context) NoInitExpr(Empty);
3101 break;
3103 case EXPR_ARRAY_INIT_LOOP:
3104 S = new (Context) ArrayInitLoopExpr(Empty);
3105 break;
3107 case EXPR_ARRAY_INIT_INDEX:
3108 S = new (Context) ArrayInitIndexExpr(Empty);
3109 break;
3111 case EXPR_VA_ARG:
3112 S = new (Context) VAArgExpr(Empty);
3113 break;
3115 case EXPR_SOURCE_LOC:
3116 S = new (Context) SourceLocExpr(Empty);
3117 break;
3119 case EXPR_ADDR_LABEL:
3120 S = new (Context) AddrLabelExpr(Empty);
3121 break;
3123 case EXPR_STMT:
3124 S = new (Context) StmtExpr(Empty);
3125 break;
3127 case EXPR_CHOOSE:
3128 S = new (Context) ChooseExpr(Empty);
3129 break;
3131 case EXPR_GNU_NULL:
3132 S = new (Context) GNUNullExpr(Empty);
3133 break;
3135 case EXPR_SHUFFLE_VECTOR:
3136 S = new (Context) ShuffleVectorExpr(Empty);
3137 break;
3139 case EXPR_CONVERT_VECTOR:
3140 S = new (Context) ConvertVectorExpr(Empty);
3141 break;
3143 case EXPR_BLOCK:
3144 S = new (Context) BlockExpr(Empty);
3145 break;
3147 case EXPR_GENERIC_SELECTION:
3148 S = GenericSelectionExpr::CreateEmpty(
3149 Context,
3150 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
3151 break;
3153 case EXPR_OBJC_STRING_LITERAL:
3154 S = new (Context) ObjCStringLiteral(Empty);
3155 break;
3157 case EXPR_OBJC_BOXED_EXPRESSION:
3158 S = new (Context) ObjCBoxedExpr(Empty);
3159 break;
3161 case EXPR_OBJC_ARRAY_LITERAL:
3162 S = ObjCArrayLiteral::CreateEmpty(Context,
3163 Record[ASTStmtReader::NumExprFields]);
3164 break;
3166 case EXPR_OBJC_DICTIONARY_LITERAL:
3167 S = ObjCDictionaryLiteral::CreateEmpty(Context,
3168 Record[ASTStmtReader::NumExprFields],
3169 Record[ASTStmtReader::NumExprFields + 1]);
3170 break;
3172 case EXPR_OBJC_ENCODE:
3173 S = new (Context) ObjCEncodeExpr(Empty);
3174 break;
3176 case EXPR_OBJC_SELECTOR_EXPR:
3177 S = new (Context) ObjCSelectorExpr(Empty);
3178 break;
3180 case EXPR_OBJC_PROTOCOL_EXPR:
3181 S = new (Context) ObjCProtocolExpr(Empty);
3182 break;
3184 case EXPR_OBJC_IVAR_REF_EXPR:
3185 S = new (Context) ObjCIvarRefExpr(Empty);
3186 break;
3188 case EXPR_OBJC_PROPERTY_REF_EXPR:
3189 S = new (Context) ObjCPropertyRefExpr(Empty);
3190 break;
3192 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
3193 S = new (Context) ObjCSubscriptRefExpr(Empty);
3194 break;
3196 case EXPR_OBJC_KVC_REF_EXPR:
3197 llvm_unreachable("mismatching AST file");
3199 case EXPR_OBJC_MESSAGE_EXPR:
3200 S = ObjCMessageExpr::CreateEmpty(Context,
3201 Record[ASTStmtReader::NumExprFields],
3202 Record[ASTStmtReader::NumExprFields + 1]);
3203 break;
3205 case EXPR_OBJC_ISA:
3206 S = new (Context) ObjCIsaExpr(Empty);
3207 break;
3209 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
3210 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
3211 break;
3213 case EXPR_OBJC_BRIDGED_CAST:
3214 S = new (Context) ObjCBridgedCastExpr(Empty);
3215 break;
3217 case STMT_OBJC_FOR_COLLECTION:
3218 S = new (Context) ObjCForCollectionStmt(Empty);
3219 break;
3221 case STMT_OBJC_CATCH:
3222 S = new (Context) ObjCAtCatchStmt(Empty);
3223 break;
3225 case STMT_OBJC_FINALLY:
3226 S = new (Context) ObjCAtFinallyStmt(Empty);
3227 break;
3229 case STMT_OBJC_AT_TRY:
3230 S = ObjCAtTryStmt::CreateEmpty(Context,
3231 Record[ASTStmtReader::NumStmtFields],
3232 Record[ASTStmtReader::NumStmtFields + 1]);
3233 break;
3235 case STMT_OBJC_AT_SYNCHRONIZED:
3236 S = new (Context) ObjCAtSynchronizedStmt(Empty);
3237 break;
3239 case STMT_OBJC_AT_THROW:
3240 S = new (Context) ObjCAtThrowStmt(Empty);
3241 break;
3243 case STMT_OBJC_AUTORELEASE_POOL:
3244 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3245 break;
3247 case EXPR_OBJC_BOOL_LITERAL:
3248 S = new (Context) ObjCBoolLiteralExpr(Empty);
3249 break;
3251 case EXPR_OBJC_AVAILABILITY_CHECK:
3252 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3253 break;
3255 case STMT_SEH_LEAVE:
3256 S = new (Context) SEHLeaveStmt(Empty);
3257 break;
3259 case STMT_SEH_EXCEPT:
3260 S = new (Context) SEHExceptStmt(Empty);
3261 break;
3263 case STMT_SEH_FINALLY:
3264 S = new (Context) SEHFinallyStmt(Empty);
3265 break;
3267 case STMT_SEH_TRY:
3268 S = new (Context) SEHTryStmt(Empty);
3269 break;
3271 case STMT_CXX_CATCH:
3272 S = new (Context) CXXCatchStmt(Empty);
3273 break;
3275 case STMT_CXX_TRY:
3276 S = CXXTryStmt::Create(Context, Empty,
3277 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
3278 break;
3280 case STMT_CXX_FOR_RANGE:
3281 S = new (Context) CXXForRangeStmt(Empty);
3282 break;
3284 case STMT_MS_DEPENDENT_EXISTS:
3285 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3286 NestedNameSpecifierLoc(),
3287 DeclarationNameInfo(),
3288 nullptr);
3289 break;
3291 case STMT_OMP_CANONICAL_LOOP:
3292 S = OMPCanonicalLoop::createEmpty(Context);
3293 break;
3295 case STMT_OMP_META_DIRECTIVE:
3296 S = OMPMetaDirective::CreateEmpty(
3297 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3298 break;
3300 case STMT_OMP_PARALLEL_DIRECTIVE:
3302 OMPParallelDirective::CreateEmpty(Context,
3303 Record[ASTStmtReader::NumStmtFields],
3304 Empty);
3305 break;
3307 case STMT_OMP_SIMD_DIRECTIVE: {
3308 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3309 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3310 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3311 CollapsedNum, Empty);
3312 break;
3315 case STMT_OMP_TILE_DIRECTIVE: {
3316 unsigned NumLoops = Record[ASTStmtReader::NumStmtFields];
3317 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3318 S = OMPTileDirective::CreateEmpty(Context, NumClauses, NumLoops);
3319 break;
3322 case STMT_OMP_UNROLL_DIRECTIVE: {
3323 assert(Record[ASTStmtReader::NumStmtFields] == 1 && "Unroll directive accepts only a single loop");
3324 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3325 S = OMPUnrollDirective::CreateEmpty(Context, NumClauses);
3326 break;
3329 case STMT_OMP_FOR_DIRECTIVE: {
3330 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3331 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3332 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3333 Empty);
3334 break;
3337 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3338 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3339 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3340 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3341 Empty);
3342 break;
3345 case STMT_OMP_SECTIONS_DIRECTIVE:
3346 S = OMPSectionsDirective::CreateEmpty(
3347 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3348 break;
3350 case STMT_OMP_SECTION_DIRECTIVE:
3351 S = OMPSectionDirective::CreateEmpty(Context, Empty);
3352 break;
3354 case STMT_OMP_SINGLE_DIRECTIVE:
3355 S = OMPSingleDirective::CreateEmpty(
3356 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3357 break;
3359 case STMT_OMP_MASTER_DIRECTIVE:
3360 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3361 break;
3363 case STMT_OMP_CRITICAL_DIRECTIVE:
3364 S = OMPCriticalDirective::CreateEmpty(
3365 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3366 break;
3368 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3369 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3370 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3371 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3372 CollapsedNum, Empty);
3373 break;
3376 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3377 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3378 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3379 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3380 CollapsedNum, Empty);
3381 break;
3384 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3385 S = OMPParallelMasterDirective::CreateEmpty(
3386 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3387 break;
3389 case STMT_OMP_PARALLEL_MASKED_DIRECTIVE:
3390 S = OMPParallelMaskedDirective::CreateEmpty(
3391 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3392 break;
3394 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3395 S = OMPParallelSectionsDirective::CreateEmpty(
3396 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3397 break;
3399 case STMT_OMP_TASK_DIRECTIVE:
3400 S = OMPTaskDirective::CreateEmpty(
3401 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3402 break;
3404 case STMT_OMP_TASKYIELD_DIRECTIVE:
3405 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3406 break;
3408 case STMT_OMP_BARRIER_DIRECTIVE:
3409 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3410 break;
3412 case STMT_OMP_TASKWAIT_DIRECTIVE:
3413 S = OMPTaskwaitDirective::CreateEmpty(
3414 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3415 break;
3417 case STMT_OMP_ERROR_DIRECTIVE:
3418 S = OMPErrorDirective::CreateEmpty(
3419 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3420 break;
3422 case STMT_OMP_TASKGROUP_DIRECTIVE:
3423 S = OMPTaskgroupDirective::CreateEmpty(
3424 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3425 break;
3427 case STMT_OMP_FLUSH_DIRECTIVE:
3428 S = OMPFlushDirective::CreateEmpty(
3429 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3430 break;
3432 case STMT_OMP_DEPOBJ_DIRECTIVE:
3433 S = OMPDepobjDirective::CreateEmpty(
3434 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3435 break;
3437 case STMT_OMP_SCAN_DIRECTIVE:
3438 S = OMPScanDirective::CreateEmpty(
3439 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3440 break;
3442 case STMT_OMP_ORDERED_DIRECTIVE: {
3443 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3444 bool HasAssociatedStmt = Record[ASTStmtReader::NumStmtFields + 2];
3445 S = OMPOrderedDirective::CreateEmpty(Context, NumClauses,
3446 !HasAssociatedStmt, Empty);
3447 break;
3450 case STMT_OMP_ATOMIC_DIRECTIVE:
3451 S = OMPAtomicDirective::CreateEmpty(
3452 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3453 break;
3455 case STMT_OMP_TARGET_DIRECTIVE:
3456 S = OMPTargetDirective::CreateEmpty(
3457 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3458 break;
3460 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3461 S = OMPTargetDataDirective::CreateEmpty(
3462 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3463 break;
3465 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3466 S = OMPTargetEnterDataDirective::CreateEmpty(
3467 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3468 break;
3470 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3471 S = OMPTargetExitDataDirective::CreateEmpty(
3472 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3473 break;
3475 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3476 S = OMPTargetParallelDirective::CreateEmpty(
3477 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3478 break;
3480 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3481 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3482 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3483 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3484 CollapsedNum, Empty);
3485 break;
3488 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3489 S = OMPTargetUpdateDirective::CreateEmpty(
3490 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3491 break;
3493 case STMT_OMP_TEAMS_DIRECTIVE:
3494 S = OMPTeamsDirective::CreateEmpty(
3495 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3496 break;
3498 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3499 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3500 break;
3502 case STMT_OMP_CANCEL_DIRECTIVE:
3503 S = OMPCancelDirective::CreateEmpty(
3504 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3505 break;
3507 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3508 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3509 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3510 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3511 Empty);
3512 break;
3515 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3516 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3517 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3518 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3519 CollapsedNum, Empty);
3520 break;
3523 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3524 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3525 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3526 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3527 CollapsedNum, Empty);
3528 break;
3531 case STMT_OMP_MASKED_TASKLOOP_DIRECTIVE: {
3532 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3533 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3534 S = OMPMaskedTaskLoopDirective::CreateEmpty(Context, NumClauses,
3535 CollapsedNum, Empty);
3536 break;
3539 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3540 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3541 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3542 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3543 CollapsedNum, Empty);
3544 break;
3547 case STMT_OMP_MASKED_TASKLOOP_SIMD_DIRECTIVE: {
3548 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3549 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3550 S = OMPMaskedTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3551 CollapsedNum, Empty);
3552 break;
3555 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3556 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3557 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3558 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3559 CollapsedNum, Empty);
3560 break;
3563 case STMT_OMP_PARALLEL_MASKED_TASKLOOP_DIRECTIVE: {
3564 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3565 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3566 S = OMPParallelMaskedTaskLoopDirective::CreateEmpty(Context, NumClauses,
3567 CollapsedNum, Empty);
3568 break;
3571 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3572 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3573 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3574 S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3575 Context, NumClauses, CollapsedNum, Empty);
3576 break;
3579 case STMT_OMP_PARALLEL_MASKED_TASKLOOP_SIMD_DIRECTIVE: {
3580 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3581 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3582 S = OMPParallelMaskedTaskLoopSimdDirective::CreateEmpty(
3583 Context, NumClauses, CollapsedNum, Empty);
3584 break;
3587 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3588 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3589 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3590 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3591 Empty);
3592 break;
3595 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3596 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3597 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3598 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3599 CollapsedNum, Empty);
3600 break;
3603 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3604 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3605 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3606 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3607 CollapsedNum,
3608 Empty);
3609 break;
3612 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3613 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3614 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3615 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3616 CollapsedNum, Empty);
3617 break;
3620 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3621 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3622 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3623 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3624 CollapsedNum, Empty);
3625 break;
3628 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3629 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3630 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3631 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3632 Empty);
3633 break;
3636 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
3637 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3638 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3639 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3640 CollapsedNum, Empty);
3641 break;
3644 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3645 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3646 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3647 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3648 CollapsedNum, Empty);
3649 break;
3652 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3653 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3654 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3655 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3656 Context, NumClauses, CollapsedNum, Empty);
3657 break;
3660 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3661 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3662 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3663 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3664 Context, NumClauses, CollapsedNum, Empty);
3665 break;
3668 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
3669 S = OMPTargetTeamsDirective::CreateEmpty(
3670 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3671 break;
3673 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3674 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3675 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3676 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3677 CollapsedNum, Empty);
3678 break;
3681 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3682 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3683 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3684 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3685 Context, NumClauses, CollapsedNum, Empty);
3686 break;
3689 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3690 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3691 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3692 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3693 Context, NumClauses, CollapsedNum, Empty);
3694 break;
3697 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3698 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3699 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3700 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3701 Context, NumClauses, CollapsedNum, Empty);
3702 break;
3705 case STMT_OMP_INTEROP_DIRECTIVE:
3706 S = OMPInteropDirective::CreateEmpty(
3707 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3708 break;
3710 case STMT_OMP_DISPATCH_DIRECTIVE:
3711 S = OMPDispatchDirective::CreateEmpty(
3712 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3713 break;
3715 case STMT_OMP_MASKED_DIRECTIVE:
3716 S = OMPMaskedDirective::CreateEmpty(
3717 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3718 break;
3720 case STMT_OMP_GENERIC_LOOP_DIRECTIVE: {
3721 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3722 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3723 S = OMPGenericLoopDirective::CreateEmpty(Context, NumClauses,
3724 CollapsedNum, Empty);
3725 break;
3728 case STMT_OMP_TEAMS_GENERIC_LOOP_DIRECTIVE: {
3729 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3730 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3731 S = OMPTeamsGenericLoopDirective::CreateEmpty(Context, NumClauses,
3732 CollapsedNum, Empty);
3733 break;
3736 case STMT_OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVE: {
3737 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3738 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3739 S = OMPTargetTeamsGenericLoopDirective::CreateEmpty(Context, NumClauses,
3740 CollapsedNum, Empty);
3741 break;
3744 case STMT_OMP_PARALLEL_GENERIC_LOOP_DIRECTIVE: {
3745 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3746 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3747 S = OMPParallelGenericLoopDirective::CreateEmpty(Context, NumClauses,
3748 CollapsedNum, Empty);
3749 break;
3752 case STMT_OMP_TARGET_PARALLEL_GENERIC_LOOP_DIRECTIVE: {
3753 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3754 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3755 S = OMPTargetParallelGenericLoopDirective::CreateEmpty(
3756 Context, NumClauses, CollapsedNum, Empty);
3757 break;
3760 case EXPR_CXX_OPERATOR_CALL:
3761 S = CXXOperatorCallExpr::CreateEmpty(
3762 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields],
3763 /*HasFPFeatures=*/Record[ASTStmtReader::NumExprFields + 1], Empty);
3764 break;
3766 case EXPR_CXX_MEMBER_CALL:
3767 S = CXXMemberCallExpr::CreateEmpty(
3768 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields],
3769 /*HasFPFeatures=*/Record[ASTStmtReader::NumExprFields + 1], Empty);
3770 break;
3772 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3773 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3774 break;
3776 case EXPR_CXX_CONSTRUCT:
3777 S = CXXConstructExpr::CreateEmpty(
3778 Context,
3779 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3780 break;
3782 case EXPR_CXX_INHERITED_CTOR_INIT:
3783 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3784 break;
3786 case EXPR_CXX_TEMPORARY_OBJECT:
3787 S = CXXTemporaryObjectExpr::CreateEmpty(
3788 Context,
3789 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3790 break;
3792 case EXPR_CXX_STATIC_CAST:
3793 S = CXXStaticCastExpr::CreateEmpty(
3794 Context,
3795 /*PathSize*/ Record[ASTStmtReader::NumExprFields],
3796 /*HasFPFeatures*/ Record[ASTStmtReader::NumExprFields + 1]);
3797 break;
3799 case EXPR_CXX_DYNAMIC_CAST:
3800 S = CXXDynamicCastExpr::CreateEmpty(Context,
3801 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3802 break;
3804 case EXPR_CXX_REINTERPRET_CAST:
3805 S = CXXReinterpretCastExpr::CreateEmpty(Context,
3806 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3807 break;
3809 case EXPR_CXX_CONST_CAST:
3810 S = CXXConstCastExpr::CreateEmpty(Context);
3811 break;
3813 case EXPR_CXX_ADDRSPACE_CAST:
3814 S = CXXAddrspaceCastExpr::CreateEmpty(Context);
3815 break;
3817 case EXPR_CXX_FUNCTIONAL_CAST:
3818 S = CXXFunctionalCastExpr::CreateEmpty(
3819 Context,
3820 /*PathSize*/ Record[ASTStmtReader::NumExprFields],
3821 /*HasFPFeatures*/ Record[ASTStmtReader::NumExprFields + 1]);
3822 break;
3824 case EXPR_BUILTIN_BIT_CAST:
3825 assert(Record[ASTStmtReader::NumExprFields] == 0 && "Wrong PathSize!");
3826 S = new (Context) BuiltinBitCastExpr(Empty);
3827 break;
3829 case EXPR_USER_DEFINED_LITERAL:
3830 S = UserDefinedLiteral::CreateEmpty(
3831 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields],
3832 /*HasFPFeatures=*/Record[ASTStmtReader::NumExprFields + 1], Empty);
3833 break;
3835 case EXPR_CXX_STD_INITIALIZER_LIST:
3836 S = new (Context) CXXStdInitializerListExpr(Empty);
3837 break;
3839 case EXPR_CXX_BOOL_LITERAL:
3840 S = new (Context) CXXBoolLiteralExpr(Empty);
3841 break;
3843 case EXPR_CXX_NULL_PTR_LITERAL:
3844 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3845 break;
3847 case EXPR_CXX_TYPEID_EXPR:
3848 S = new (Context) CXXTypeidExpr(Empty, true);
3849 break;
3851 case EXPR_CXX_TYPEID_TYPE:
3852 S = new (Context) CXXTypeidExpr(Empty, false);
3853 break;
3855 case EXPR_CXX_UUIDOF_EXPR:
3856 S = new (Context) CXXUuidofExpr(Empty, true);
3857 break;
3859 case EXPR_CXX_PROPERTY_REF_EXPR:
3860 S = new (Context) MSPropertyRefExpr(Empty);
3861 break;
3863 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3864 S = new (Context) MSPropertySubscriptExpr(Empty);
3865 break;
3867 case EXPR_CXX_UUIDOF_TYPE:
3868 S = new (Context) CXXUuidofExpr(Empty, false);
3869 break;
3871 case EXPR_CXX_THIS:
3872 S = new (Context) CXXThisExpr(Empty);
3873 break;
3875 case EXPR_CXX_THROW:
3876 S = new (Context) CXXThrowExpr(Empty);
3877 break;
3879 case EXPR_CXX_DEFAULT_ARG:
3880 S = CXXDefaultArgExpr::CreateEmpty(
3881 Context, /*HasRewrittenInit=*/Record[ASTStmtReader::NumExprFields]);
3882 break;
3884 case EXPR_CXX_DEFAULT_INIT:
3885 S = CXXDefaultInitExpr::CreateEmpty(
3886 Context, /*HasRewrittenInit=*/Record[ASTStmtReader::NumExprFields]);
3887 break;
3889 case EXPR_CXX_BIND_TEMPORARY:
3890 S = new (Context) CXXBindTemporaryExpr(Empty);
3891 break;
3893 case EXPR_CXX_SCALAR_VALUE_INIT:
3894 S = new (Context) CXXScalarValueInitExpr(Empty);
3895 break;
3897 case EXPR_CXX_NEW:
3898 S = CXXNewExpr::CreateEmpty(
3899 Context,
3900 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3901 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3902 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3903 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
3904 break;
3906 case EXPR_CXX_DELETE:
3907 S = new (Context) CXXDeleteExpr(Empty);
3908 break;
3910 case EXPR_CXX_PSEUDO_DESTRUCTOR:
3911 S = new (Context) CXXPseudoDestructorExpr(Empty);
3912 break;
3914 case EXPR_EXPR_WITH_CLEANUPS:
3915 S = ExprWithCleanups::Create(Context, Empty,
3916 Record[ASTStmtReader::NumExprFields]);
3917 break;
3919 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
3920 S = CXXDependentScopeMemberExpr::CreateEmpty(
3921 Context,
3922 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3923 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3924 /*HasFirstQualifierFoundInScope=*/
3925 Record[ASTStmtReader::NumExprFields + 2]);
3926 break;
3928 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
3929 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
3930 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3931 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3932 ? Record[ASTStmtReader::NumExprFields + 1]
3933 : 0);
3934 break;
3936 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
3937 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
3938 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3939 break;
3941 case EXPR_CXX_UNRESOLVED_MEMBER:
3942 S = UnresolvedMemberExpr::CreateEmpty(
3943 Context,
3944 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3945 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3946 /*NumTemplateArgs=*/
3947 Record[ASTStmtReader::NumExprFields + 1]
3948 ? Record[ASTStmtReader::NumExprFields + 2]
3949 : 0);
3950 break;
3952 case EXPR_CXX_UNRESOLVED_LOOKUP:
3953 S = UnresolvedLookupExpr::CreateEmpty(
3954 Context,
3955 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3956 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3957 /*NumTemplateArgs=*/
3958 Record[ASTStmtReader::NumExprFields + 1]
3959 ? Record[ASTStmtReader::NumExprFields + 2]
3960 : 0);
3961 break;
3963 case EXPR_TYPE_TRAIT:
3964 S = TypeTraitExpr::CreateDeserialized(Context,
3965 Record[ASTStmtReader::NumExprFields]);
3966 break;
3968 case EXPR_ARRAY_TYPE_TRAIT:
3969 S = new (Context) ArrayTypeTraitExpr(Empty);
3970 break;
3972 case EXPR_CXX_EXPRESSION_TRAIT:
3973 S = new (Context) ExpressionTraitExpr(Empty);
3974 break;
3976 case EXPR_CXX_NOEXCEPT:
3977 S = new (Context) CXXNoexceptExpr(Empty);
3978 break;
3980 case EXPR_PACK_EXPANSION:
3981 S = new (Context) PackExpansionExpr(Empty);
3982 break;
3984 case EXPR_SIZEOF_PACK:
3985 S = SizeOfPackExpr::CreateDeserialized(
3986 Context,
3987 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
3988 break;
3990 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3991 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3992 break;
3994 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3995 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3996 break;
3998 case EXPR_FUNCTION_PARM_PACK:
3999 S = FunctionParmPackExpr::CreateEmpty(Context,
4000 Record[ASTStmtReader::NumExprFields]);
4001 break;
4003 case EXPR_MATERIALIZE_TEMPORARY:
4004 S = new (Context) MaterializeTemporaryExpr(Empty);
4005 break;
4007 case EXPR_CXX_FOLD:
4008 S = new (Context) CXXFoldExpr(Empty);
4009 break;
4011 case EXPR_CXX_PAREN_LIST_INIT:
4012 S = CXXParenListInitExpr::CreateEmpty(
4013 Context, /*numExprs=*/Record[ASTStmtReader::NumExprFields], Empty);
4014 break;
4016 case EXPR_OPAQUE_VALUE:
4017 S = new (Context) OpaqueValueExpr(Empty);
4018 break;
4020 case EXPR_CUDA_KERNEL_CALL:
4021 S = CUDAKernelCallExpr::CreateEmpty(
4022 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields],
4023 /*HasFPFeatures=*/Record[ASTStmtReader::NumExprFields + 1], Empty);
4024 break;
4026 case EXPR_ASTYPE:
4027 S = new (Context) AsTypeExpr(Empty);
4028 break;
4030 case EXPR_PSEUDO_OBJECT: {
4031 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
4032 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
4033 break;
4036 case EXPR_ATOMIC:
4037 S = new (Context) AtomicExpr(Empty);
4038 break;
4040 case EXPR_LAMBDA: {
4041 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
4042 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
4043 break;
4046 case STMT_COROUTINE_BODY: {
4047 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
4048 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
4049 break;
4052 case STMT_CORETURN:
4053 S = new (Context) CoreturnStmt(Empty);
4054 break;
4056 case EXPR_COAWAIT:
4057 S = new (Context) CoawaitExpr(Empty);
4058 break;
4060 case EXPR_COYIELD:
4061 S = new (Context) CoyieldExpr(Empty);
4062 break;
4064 case EXPR_DEPENDENT_COAWAIT:
4065 S = new (Context) DependentCoawaitExpr(Empty);
4066 break;
4068 case EXPR_CONCEPT_SPECIALIZATION: {
4069 S = new (Context) ConceptSpecializationExpr(Empty);
4070 break;
4073 case EXPR_REQUIRES:
4074 unsigned numLocalParameters = Record[ASTStmtReader::NumExprFields];
4075 unsigned numRequirement = Record[ASTStmtReader::NumExprFields + 1];
4076 S = RequiresExpr::Create(Context, Empty, numLocalParameters,
4077 numRequirement);
4078 break;
4081 // We hit a STMT_STOP, so we're done with this expression.
4082 if (Finished)
4083 break;
4085 ++NumStatementsRead;
4087 if (S && !IsStmtReference) {
4088 Reader.Visit(S);
4089 StmtEntries[Cursor.GetCurrentBitNo()] = S;
4092 assert(Record.getIdx() == Record.size() &&
4093 "Invalid deserialization of statement");
4094 StmtStack.push_back(S);
4096 Done:
4097 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
4098 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
4099 return StmtStack.pop_back_val();