[Flang] remove whole-archive option for AIX linker (#76039)
[llvm-project.git] / clang / lib / Serialization / ASTReaderStmt.cpp
blobcf37ffe4c38b5d2aa6373eab7bd32beff29fe2d9
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 std::optional<BitsUnpacker> CurrentUnpackingBits;
78 SourceLocation readSourceLocation() {
79 return Record.readSourceLocation();
82 SourceRange readSourceRange() {
83 return Record.readSourceRange();
86 std::string readString() {
87 return Record.readString();
90 TypeSourceInfo *readTypeSourceInfo() {
91 return Record.readTypeSourceInfo();
94 Decl *readDecl() {
95 return Record.readDecl();
98 template<typename T>
99 T *readDeclAs() {
100 return Record.readDeclAs<T>();
103 public:
104 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
105 : Record(Record), DeclsCursor(Cursor) {}
107 /// The number of record fields required for the Stmt class
108 /// itself.
109 static const unsigned NumStmtFields = 0;
111 /// The number of record fields required for the Expr class
112 /// itself.
113 static const unsigned NumExprFields = NumStmtFields + 2;
115 /// The number of bits required for the packing bits for the Expr class.
116 static const unsigned NumExprBits = 10;
118 /// Read and initialize a ExplicitTemplateArgumentList structure.
119 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
120 TemplateArgumentLoc *ArgsLocArray,
121 unsigned NumTemplateArgs);
123 void VisitStmt(Stmt *S);
124 #define STMT(Type, Base) \
125 void Visit##Type(Type *);
126 #include "clang/AST/StmtNodes.inc"
129 } // namespace clang
131 void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
132 TemplateArgumentLoc *ArgsLocArray,
133 unsigned NumTemplateArgs) {
134 SourceLocation TemplateKWLoc = readSourceLocation();
135 TemplateArgumentListInfo ArgInfo;
136 ArgInfo.setLAngleLoc(readSourceLocation());
137 ArgInfo.setRAngleLoc(readSourceLocation());
138 for (unsigned i = 0; i != NumTemplateArgs; ++i)
139 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
140 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
143 void ASTStmtReader::VisitStmt(Stmt *S) {
144 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
147 void ASTStmtReader::VisitNullStmt(NullStmt *S) {
148 VisitStmt(S);
149 S->setSemiLoc(readSourceLocation());
150 S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
153 void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
154 VisitStmt(S);
155 SmallVector<Stmt *, 16> Stmts;
156 unsigned NumStmts = Record.readInt();
157 unsigned HasFPFeatures = Record.readInt();
158 assert(S->hasStoredFPFeatures() == HasFPFeatures);
159 while (NumStmts--)
160 Stmts.push_back(Record.readSubStmt());
161 S->setStmts(Stmts);
162 if (HasFPFeatures)
163 S->setStoredFPFeatures(
164 FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
165 S->LBraceLoc = readSourceLocation();
166 S->RBraceLoc = readSourceLocation();
169 void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
170 VisitStmt(S);
171 Record.recordSwitchCaseID(S, Record.readInt());
172 S->setKeywordLoc(readSourceLocation());
173 S->setColonLoc(readSourceLocation());
176 void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
177 VisitSwitchCase(S);
178 bool CaseStmtIsGNURange = Record.readInt();
179 S->setLHS(Record.readSubExpr());
180 S->setSubStmt(Record.readSubStmt());
181 if (CaseStmtIsGNURange) {
182 S->setRHS(Record.readSubExpr());
183 S->setEllipsisLoc(readSourceLocation());
187 void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
188 VisitSwitchCase(S);
189 S->setSubStmt(Record.readSubStmt());
192 void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
193 VisitStmt(S);
194 bool IsSideEntry = Record.readInt();
195 auto *LD = readDeclAs<LabelDecl>();
196 LD->setStmt(S);
197 S->setDecl(LD);
198 S->setSubStmt(Record.readSubStmt());
199 S->setIdentLoc(readSourceLocation());
200 S->setSideEntry(IsSideEntry);
203 void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
204 VisitStmt(S);
205 // NumAttrs in AttributedStmt is set when creating an empty
206 // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
207 // to allocate the right amount of space for the trailing Attr *.
208 uint64_t NumAttrs = Record.readInt();
209 AttrVec Attrs;
210 Record.readAttributes(Attrs);
211 (void)NumAttrs;
212 assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
213 assert(NumAttrs == Attrs.size());
214 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
215 S->SubStmt = Record.readSubStmt();
216 S->AttributedStmtBits.AttrLoc = readSourceLocation();
219 void ASTStmtReader::VisitIfStmt(IfStmt *S) {
220 VisitStmt(S);
222 CurrentUnpackingBits.emplace(Record.readInt());
224 bool HasElse = CurrentUnpackingBits->getNextBit();
225 bool HasVar = CurrentUnpackingBits->getNextBit();
226 bool HasInit = CurrentUnpackingBits->getNextBit();
228 S->setStatementKind(static_cast<IfStatementKind>(Record.readInt()));
229 S->setCond(Record.readSubExpr());
230 S->setThen(Record.readSubStmt());
231 if (HasElse)
232 S->setElse(Record.readSubStmt());
233 if (HasVar)
234 S->setConditionVariableDeclStmt(cast<DeclStmt>(Record.readSubStmt()));
235 if (HasInit)
236 S->setInit(Record.readSubStmt());
238 S->setIfLoc(readSourceLocation());
239 S->setLParenLoc(readSourceLocation());
240 S->setRParenLoc(readSourceLocation());
241 if (HasElse)
242 S->setElseLoc(readSourceLocation());
245 void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
246 VisitStmt(S);
248 bool HasInit = Record.readInt();
249 bool HasVar = Record.readInt();
250 bool AllEnumCasesCovered = Record.readInt();
251 if (AllEnumCasesCovered)
252 S->setAllEnumCasesCovered();
254 S->setCond(Record.readSubExpr());
255 S->setBody(Record.readSubStmt());
256 if (HasInit)
257 S->setInit(Record.readSubStmt());
258 if (HasVar)
259 S->setConditionVariableDeclStmt(cast<DeclStmt>(Record.readSubStmt()));
261 S->setSwitchLoc(readSourceLocation());
262 S->setLParenLoc(readSourceLocation());
263 S->setRParenLoc(readSourceLocation());
265 SwitchCase *PrevSC = nullptr;
266 for (auto E = Record.size(); Record.getIdx() != E; ) {
267 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
268 if (PrevSC)
269 PrevSC->setNextSwitchCase(SC);
270 else
271 S->setSwitchCaseList(SC);
273 PrevSC = SC;
277 void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
278 VisitStmt(S);
280 bool HasVar = Record.readInt();
282 S->setCond(Record.readSubExpr());
283 S->setBody(Record.readSubStmt());
284 if (HasVar)
285 S->setConditionVariableDeclStmt(cast<DeclStmt>(Record.readSubStmt()));
287 S->setWhileLoc(readSourceLocation());
288 S->setLParenLoc(readSourceLocation());
289 S->setRParenLoc(readSourceLocation());
292 void ASTStmtReader::VisitDoStmt(DoStmt *S) {
293 VisitStmt(S);
294 S->setCond(Record.readSubExpr());
295 S->setBody(Record.readSubStmt());
296 S->setDoLoc(readSourceLocation());
297 S->setWhileLoc(readSourceLocation());
298 S->setRParenLoc(readSourceLocation());
301 void ASTStmtReader::VisitForStmt(ForStmt *S) {
302 VisitStmt(S);
303 S->setInit(Record.readSubStmt());
304 S->setCond(Record.readSubExpr());
305 S->setConditionVariableDeclStmt(cast_or_null<DeclStmt>(Record.readSubStmt()));
306 S->setInc(Record.readSubExpr());
307 S->setBody(Record.readSubStmt());
308 S->setForLoc(readSourceLocation());
309 S->setLParenLoc(readSourceLocation());
310 S->setRParenLoc(readSourceLocation());
313 void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
314 VisitStmt(S);
315 S->setLabel(readDeclAs<LabelDecl>());
316 S->setGotoLoc(readSourceLocation());
317 S->setLabelLoc(readSourceLocation());
320 void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
321 VisitStmt(S);
322 S->setGotoLoc(readSourceLocation());
323 S->setStarLoc(readSourceLocation());
324 S->setTarget(Record.readSubExpr());
327 void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
328 VisitStmt(S);
329 S->setContinueLoc(readSourceLocation());
332 void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
333 VisitStmt(S);
334 S->setBreakLoc(readSourceLocation());
337 void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
338 VisitStmt(S);
340 bool HasNRVOCandidate = Record.readInt();
342 S->setRetValue(Record.readSubExpr());
343 if (HasNRVOCandidate)
344 S->setNRVOCandidate(readDeclAs<VarDecl>());
346 S->setReturnLoc(readSourceLocation());
349 void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
350 VisitStmt(S);
351 S->setStartLoc(readSourceLocation());
352 S->setEndLoc(readSourceLocation());
354 if (Record.size() - Record.getIdx() == 1) {
355 // Single declaration
356 S->setDeclGroup(DeclGroupRef(readDecl()));
357 } else {
358 SmallVector<Decl *, 16> Decls;
359 int N = Record.size() - Record.getIdx();
360 Decls.reserve(N);
361 for (int I = 0; I < N; ++I)
362 Decls.push_back(readDecl());
363 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
364 Decls.data(),
365 Decls.size())));
369 void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
370 VisitStmt(S);
371 S->NumOutputs = Record.readInt();
372 S->NumInputs = Record.readInt();
373 S->NumClobbers = Record.readInt();
374 S->setAsmLoc(readSourceLocation());
375 S->setVolatile(Record.readInt());
376 S->setSimple(Record.readInt());
379 void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
380 VisitAsmStmt(S);
381 S->NumLabels = Record.readInt();
382 S->setRParenLoc(readSourceLocation());
383 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
385 unsigned NumOutputs = S->getNumOutputs();
386 unsigned NumInputs = S->getNumInputs();
387 unsigned NumClobbers = S->getNumClobbers();
388 unsigned NumLabels = S->getNumLabels();
390 // Outputs and inputs
391 SmallVector<IdentifierInfo *, 16> Names;
392 SmallVector<StringLiteral*, 16> Constraints;
393 SmallVector<Stmt*, 16> Exprs;
394 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
395 Names.push_back(Record.readIdentifier());
396 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
397 Exprs.push_back(Record.readSubStmt());
400 // Constraints
401 SmallVector<StringLiteral*, 16> Clobbers;
402 for (unsigned I = 0; I != NumClobbers; ++I)
403 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
405 // Labels
406 for (unsigned I = 0, N = NumLabels; I != N; ++I) {
407 Names.push_back(Record.readIdentifier());
408 Exprs.push_back(Record.readSubStmt());
411 S->setOutputsAndInputsAndClobbers(Record.getContext(),
412 Names.data(), Constraints.data(),
413 Exprs.data(), NumOutputs, NumInputs,
414 NumLabels,
415 Clobbers.data(), NumClobbers);
418 void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
419 VisitAsmStmt(S);
420 S->LBraceLoc = readSourceLocation();
421 S->EndLoc = readSourceLocation();
422 S->NumAsmToks = Record.readInt();
423 std::string AsmStr = readString();
425 // Read the tokens.
426 SmallVector<Token, 16> AsmToks;
427 AsmToks.reserve(S->NumAsmToks);
428 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
429 AsmToks.push_back(Record.readToken());
432 // The calls to reserve() for the FooData vectors are mandatory to
433 // prevent dead StringRefs in the Foo vectors.
435 // Read the clobbers.
436 SmallVector<std::string, 16> ClobbersData;
437 SmallVector<StringRef, 16> Clobbers;
438 ClobbersData.reserve(S->NumClobbers);
439 Clobbers.reserve(S->NumClobbers);
440 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
441 ClobbersData.push_back(readString());
442 Clobbers.push_back(ClobbersData.back());
445 // Read the operands.
446 unsigned NumOperands = S->NumOutputs + S->NumInputs;
447 SmallVector<Expr*, 16> Exprs;
448 SmallVector<std::string, 16> ConstraintsData;
449 SmallVector<StringRef, 16> Constraints;
450 Exprs.reserve(NumOperands);
451 ConstraintsData.reserve(NumOperands);
452 Constraints.reserve(NumOperands);
453 for (unsigned i = 0; i != NumOperands; ++i) {
454 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
455 ConstraintsData.push_back(readString());
456 Constraints.push_back(ConstraintsData.back());
459 S->initialize(Record.getContext(), AsmStr, AsmToks,
460 Constraints, Exprs, Clobbers);
463 void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
464 VisitStmt(S);
465 assert(Record.peekInt() == S->NumParams);
466 Record.skipInts(1);
467 auto *StoredStmts = S->getStoredStmts();
468 for (unsigned i = 0;
469 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
470 StoredStmts[i] = Record.readSubStmt();
473 void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
474 VisitStmt(S);
475 S->CoreturnLoc = Record.readSourceLocation();
476 for (auto &SubStmt: S->SubStmts)
477 SubStmt = Record.readSubStmt();
478 S->IsImplicit = Record.readInt() != 0;
481 void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
482 VisitExpr(E);
483 E->KeywordLoc = readSourceLocation();
484 for (auto &SubExpr: E->SubExprs)
485 SubExpr = Record.readSubStmt();
486 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
487 E->setIsImplicit(Record.readInt() != 0);
490 void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
491 VisitExpr(E);
492 E->KeywordLoc = readSourceLocation();
493 for (auto &SubExpr: E->SubExprs)
494 SubExpr = Record.readSubStmt();
495 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
498 void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
499 VisitExpr(E);
500 E->KeywordLoc = readSourceLocation();
501 for (auto &SubExpr: E->SubExprs)
502 SubExpr = Record.readSubStmt();
505 void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
506 VisitStmt(S);
507 Record.skipInts(1);
508 S->setCapturedDecl(readDeclAs<CapturedDecl>());
509 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
510 S->setCapturedRecordDecl(readDeclAs<RecordDecl>());
512 // Capture inits
513 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
514 E = S->capture_init_end();
515 I != E; ++I)
516 *I = Record.readSubExpr();
518 // Body
519 S->setCapturedStmt(Record.readSubStmt());
520 S->getCapturedDecl()->setBody(S->getCapturedStmt());
522 // Captures
523 for (auto &I : S->captures()) {
524 I.VarAndKind.setPointer(readDeclAs<VarDecl>());
525 I.VarAndKind.setInt(
526 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
527 I.Loc = readSourceLocation();
531 void ASTStmtReader::VisitExpr(Expr *E) {
532 VisitStmt(E);
533 CurrentUnpackingBits.emplace(Record.readInt());
534 E->setDependence(static_cast<ExprDependence>(
535 CurrentUnpackingBits->getNextBits(/*Width=*/5)));
536 E->setValueKind(static_cast<ExprValueKind>(
537 CurrentUnpackingBits->getNextBits(/*Width=*/2)));
538 E->setObjectKind(static_cast<ExprObjectKind>(
539 CurrentUnpackingBits->getNextBits(/*Width=*/3)));
541 E->setType(Record.readType());
542 assert(Record.getIdx() == NumExprFields &&
543 "Incorrect expression field count");
546 void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
547 VisitExpr(E);
549 auto StorageKind = static_cast<ConstantResultStorageKind>(Record.readInt());
550 assert(E->getResultStorageKind() == StorageKind && "Wrong ResultKind!");
552 E->ConstantExprBits.APValueKind = Record.readInt();
553 E->ConstantExprBits.IsUnsigned = Record.readInt();
554 E->ConstantExprBits.BitWidth = Record.readInt();
555 E->ConstantExprBits.HasCleanup = false; // Not serialized, see below.
556 E->ConstantExprBits.IsImmediateInvocation = Record.readInt();
558 switch (StorageKind) {
559 case ConstantResultStorageKind::None:
560 break;
562 case ConstantResultStorageKind::Int64:
563 E->Int64Result() = Record.readInt();
564 break;
566 case ConstantResultStorageKind::APValue:
567 E->APValueResult() = Record.readAPValue();
568 if (E->APValueResult().needsCleanup()) {
569 E->ConstantExprBits.HasCleanup = true;
570 Record.getContext().addDestruction(&E->APValueResult());
572 break;
575 E->setSubExpr(Record.readSubExpr());
578 void ASTStmtReader::VisitSYCLUniqueStableNameExpr(SYCLUniqueStableNameExpr *E) {
579 VisitExpr(E);
581 E->setLocation(readSourceLocation());
582 E->setLParenLocation(readSourceLocation());
583 E->setRParenLocation(readSourceLocation());
585 E->setTypeSourceInfo(Record.readTypeSourceInfo());
588 void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
589 VisitExpr(E);
590 bool HasFunctionName = Record.readInt();
591 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
592 E->PredefinedExprBits.Kind = Record.readInt();
593 E->PredefinedExprBits.IsTransparent = Record.readInt();
594 E->setLocation(readSourceLocation());
595 if (HasFunctionName)
596 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
599 void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
600 VisitExpr(E);
602 CurrentUnpackingBits.emplace(Record.readInt());
603 E->DeclRefExprBits.HadMultipleCandidates = CurrentUnpackingBits->getNextBit();
604 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture =
605 CurrentUnpackingBits->getNextBit();
606 E->DeclRefExprBits.NonOdrUseReason =
607 CurrentUnpackingBits->getNextBits(/*Width=*/2);
608 E->DeclRefExprBits.IsImmediateEscalating = CurrentUnpackingBits->getNextBit();
609 E->DeclRefExprBits.HasFoundDecl = CurrentUnpackingBits->getNextBit();
610 E->DeclRefExprBits.HasQualifier = CurrentUnpackingBits->getNextBit();
611 E->DeclRefExprBits.HasTemplateKWAndArgsInfo =
612 CurrentUnpackingBits->getNextBit();
613 E->DeclRefExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter = false;
614 unsigned NumTemplateArgs = 0;
615 if (E->hasTemplateKWAndArgsInfo())
616 NumTemplateArgs = Record.readInt();
618 if (E->hasQualifier())
619 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
620 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
622 if (E->hasFoundDecl())
623 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
625 if (E->hasTemplateKWAndArgsInfo())
626 ReadTemplateKWAndArgsInfo(
627 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
628 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
630 E->D = readDeclAs<ValueDecl>();
631 E->setLocation(readSourceLocation());
632 E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
635 void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
636 VisitExpr(E);
637 E->setLocation(readSourceLocation());
638 E->setValue(Record.getContext(), Record.readAPInt());
641 void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
642 VisitExpr(E);
643 E->setLocation(readSourceLocation());
644 E->setScale(Record.readInt());
645 E->setValue(Record.getContext(), Record.readAPInt());
648 void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
649 VisitExpr(E);
650 E->setRawSemantics(
651 static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
652 E->setExact(Record.readInt());
653 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
654 E->setLocation(readSourceLocation());
657 void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
658 VisitExpr(E);
659 E->setSubExpr(Record.readSubExpr());
662 void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
663 VisitExpr(E);
665 // NumConcatenated, Length and CharByteWidth are set by the empty
666 // ctor since they are needed to allocate storage for the trailing objects.
667 unsigned NumConcatenated = Record.readInt();
668 unsigned Length = Record.readInt();
669 unsigned CharByteWidth = Record.readInt();
670 assert((NumConcatenated == E->getNumConcatenated()) &&
671 "Wrong number of concatenated tokens!");
672 assert((Length == E->getLength()) && "Wrong Length!");
673 assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
674 E->StringLiteralBits.Kind = Record.readInt();
675 E->StringLiteralBits.IsPascal = Record.readInt();
677 // The character width is originally computed via mapCharByteWidth.
678 // Check that the deserialized character width is consistant with the result
679 // of calling mapCharByteWidth.
680 assert((CharByteWidth ==
681 StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
682 E->getKind())) &&
683 "Wrong character width!");
685 // Deserialize the trailing array of SourceLocation.
686 for (unsigned I = 0; I < NumConcatenated; ++I)
687 E->setStrTokenLoc(I, readSourceLocation());
689 // Deserialize the trailing array of char holding the string data.
690 char *StrData = E->getStrDataAsChar();
691 for (unsigned I = 0; I < Length * CharByteWidth; ++I)
692 StrData[I] = Record.readInt();
695 void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
696 VisitExpr(E);
697 E->setValue(Record.readInt());
698 E->setLocation(readSourceLocation());
699 E->setKind(static_cast<CharacterLiteralKind>(Record.readInt()));
702 void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
703 VisitExpr(E);
704 E->setLParen(readSourceLocation());
705 E->setRParen(readSourceLocation());
706 E->setSubExpr(Record.readSubExpr());
709 void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
710 VisitExpr(E);
711 unsigned NumExprs = Record.readInt();
712 assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
713 for (unsigned I = 0; I != NumExprs; ++I)
714 E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
715 E->LParenLoc = readSourceLocation();
716 E->RParenLoc = readSourceLocation();
719 void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
720 VisitExpr(E);
721 bool hasFP_Features = CurrentUnpackingBits->getNextBit();
722 assert(hasFP_Features == E->hasStoredFPFeatures());
723 E->setSubExpr(Record.readSubExpr());
724 E->setOpcode(
725 (UnaryOperator::Opcode)CurrentUnpackingBits->getNextBits(/*Width=*/5));
726 E->setOperatorLoc(readSourceLocation());
727 E->setCanOverflow(CurrentUnpackingBits->getNextBit());
728 if (hasFP_Features)
729 E->setStoredFPFeatures(
730 FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
733 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
734 VisitExpr(E);
735 assert(E->getNumComponents() == Record.peekInt());
736 Record.skipInts(1);
737 assert(E->getNumExpressions() == Record.peekInt());
738 Record.skipInts(1);
739 E->setOperatorLoc(readSourceLocation());
740 E->setRParenLoc(readSourceLocation());
741 E->setTypeSourceInfo(readTypeSourceInfo());
742 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
743 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
744 SourceLocation Start = readSourceLocation();
745 SourceLocation End = readSourceLocation();
746 switch (Kind) {
747 case OffsetOfNode::Array:
748 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
749 break;
751 case OffsetOfNode::Field:
752 E->setComponent(
753 I, OffsetOfNode(Start, readDeclAs<FieldDecl>(), End));
754 break;
756 case OffsetOfNode::Identifier:
757 E->setComponent(
759 OffsetOfNode(Start, Record.readIdentifier(), End));
760 break;
762 case OffsetOfNode::Base: {
763 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
764 *Base = Record.readCXXBaseSpecifier();
765 E->setComponent(I, OffsetOfNode(Base));
766 break;
771 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
772 E->setIndexExpr(I, Record.readSubExpr());
775 void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
776 VisitExpr(E);
777 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
778 if (Record.peekInt() == 0) {
779 E->setArgument(Record.readSubExpr());
780 Record.skipInts(1);
781 } else {
782 E->setArgument(readTypeSourceInfo());
784 E->setOperatorLoc(readSourceLocation());
785 E->setRParenLoc(readSourceLocation());
788 static ConstraintSatisfaction
789 readConstraintSatisfaction(ASTRecordReader &Record) {
790 ConstraintSatisfaction Satisfaction;
791 Satisfaction.IsSatisfied = Record.readInt();
792 Satisfaction.ContainsErrors = Record.readInt();
793 if (!Satisfaction.IsSatisfied) {
794 unsigned NumDetailRecords = Record.readInt();
795 for (unsigned i = 0; i != NumDetailRecords; ++i) {
796 Expr *ConstraintExpr = Record.readExpr();
797 if (/* IsDiagnostic */Record.readInt()) {
798 SourceLocation DiagLocation = Record.readSourceLocation();
799 std::string DiagMessage = Record.readString();
800 Satisfaction.Details.emplace_back(
801 ConstraintExpr, new (Record.getContext())
802 ConstraintSatisfaction::SubstitutionDiagnostic{
803 DiagLocation, DiagMessage});
804 } else
805 Satisfaction.Details.emplace_back(ConstraintExpr, Record.readExpr());
808 return Satisfaction;
811 void ASTStmtReader::VisitConceptSpecializationExpr(
812 ConceptSpecializationExpr *E) {
813 VisitExpr(E);
814 E->SpecDecl = Record.readDeclAs<ImplicitConceptSpecializationDecl>();
815 if (Record.readBool())
816 E->ConceptRef = Record.readConceptReference();
817 E->Satisfaction = E->isValueDependent() ? nullptr :
818 ASTConstraintSatisfaction::Create(Record.getContext(),
819 readConstraintSatisfaction(Record));
822 static concepts::Requirement::SubstitutionDiagnostic *
823 readSubstitutionDiagnostic(ASTRecordReader &Record) {
824 std::string SubstitutedEntity = Record.readString();
825 SourceLocation DiagLoc = Record.readSourceLocation();
826 std::string DiagMessage = Record.readString();
827 return new (Record.getContext())
828 concepts::Requirement::SubstitutionDiagnostic{SubstitutedEntity, DiagLoc,
829 DiagMessage};
832 void ASTStmtReader::VisitRequiresExpr(RequiresExpr *E) {
833 VisitExpr(E);
834 unsigned NumLocalParameters = Record.readInt();
835 unsigned NumRequirements = Record.readInt();
836 E->RequiresExprBits.RequiresKWLoc = Record.readSourceLocation();
837 E->RequiresExprBits.IsSatisfied = Record.readInt();
838 E->Body = Record.readDeclAs<RequiresExprBodyDecl>();
839 llvm::SmallVector<ParmVarDecl *, 4> LocalParameters;
840 for (unsigned i = 0; i < NumLocalParameters; ++i)
841 LocalParameters.push_back(cast<ParmVarDecl>(Record.readDecl()));
842 std::copy(LocalParameters.begin(), LocalParameters.end(),
843 E->getTrailingObjects<ParmVarDecl *>());
844 llvm::SmallVector<concepts::Requirement *, 4> Requirements;
845 for (unsigned i = 0; i < NumRequirements; ++i) {
846 auto RK =
847 static_cast<concepts::Requirement::RequirementKind>(Record.readInt());
848 concepts::Requirement *R = nullptr;
849 switch (RK) {
850 case concepts::Requirement::RK_Type: {
851 auto Status =
852 static_cast<concepts::TypeRequirement::SatisfactionStatus>(
853 Record.readInt());
854 if (Status == concepts::TypeRequirement::SS_SubstitutionFailure)
855 R = new (Record.getContext())
856 concepts::TypeRequirement(readSubstitutionDiagnostic(Record));
857 else
858 R = new (Record.getContext())
859 concepts::TypeRequirement(Record.readTypeSourceInfo());
860 } break;
861 case concepts::Requirement::RK_Simple:
862 case concepts::Requirement::RK_Compound: {
863 auto Status =
864 static_cast<concepts::ExprRequirement::SatisfactionStatus>(
865 Record.readInt());
866 llvm::PointerUnion<concepts::Requirement::SubstitutionDiagnostic *,
867 Expr *> E;
868 if (Status == concepts::ExprRequirement::SS_ExprSubstitutionFailure) {
869 E = readSubstitutionDiagnostic(Record);
870 } else
871 E = Record.readExpr();
873 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> Req;
874 ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr;
875 SourceLocation NoexceptLoc;
876 if (RK == concepts::Requirement::RK_Simple) {
877 Req.emplace();
878 } else {
879 NoexceptLoc = Record.readSourceLocation();
880 switch (/* returnTypeRequirementKind */Record.readInt()) {
881 case 0:
882 // No return type requirement.
883 Req.emplace();
884 break;
885 case 1: {
886 // type-constraint
887 TemplateParameterList *TPL = Record.readTemplateParameterList();
888 if (Status >=
889 concepts::ExprRequirement::SS_ConstraintsNotSatisfied)
890 SubstitutedConstraintExpr =
891 cast<ConceptSpecializationExpr>(Record.readExpr());
892 Req.emplace(TPL);
893 } break;
894 case 2:
895 // Substitution failure
896 Req.emplace(readSubstitutionDiagnostic(Record));
897 break;
900 if (Expr *Ex = E.dyn_cast<Expr *>())
901 R = new (Record.getContext()) concepts::ExprRequirement(
902 Ex, RK == concepts::Requirement::RK_Simple, NoexceptLoc,
903 std::move(*Req), Status, SubstitutedConstraintExpr);
904 else
905 R = new (Record.getContext()) concepts::ExprRequirement(
906 E.get<concepts::Requirement::SubstitutionDiagnostic *>(),
907 RK == concepts::Requirement::RK_Simple, NoexceptLoc,
908 std::move(*Req));
909 } break;
910 case concepts::Requirement::RK_Nested: {
911 bool HasInvalidConstraint = Record.readInt();
912 if (HasInvalidConstraint) {
913 std::string InvalidConstraint = Record.readString();
914 char *InvalidConstraintBuf =
915 new (Record.getContext()) char[InvalidConstraint.size()];
916 std::copy(InvalidConstraint.begin(), InvalidConstraint.end(),
917 InvalidConstraintBuf);
918 R = new (Record.getContext()) concepts::NestedRequirement(
919 Record.getContext(),
920 StringRef(InvalidConstraintBuf, InvalidConstraint.size()),
921 readConstraintSatisfaction(Record));
922 break;
924 Expr *E = Record.readExpr();
925 if (E->isInstantiationDependent())
926 R = new (Record.getContext()) concepts::NestedRequirement(E);
927 else
928 R = new (Record.getContext())
929 concepts::NestedRequirement(Record.getContext(), E,
930 readConstraintSatisfaction(Record));
931 } break;
933 if (!R)
934 continue;
935 Requirements.push_back(R);
937 std::copy(Requirements.begin(), Requirements.end(),
938 E->getTrailingObjects<concepts::Requirement *>());
939 E->LParenLoc = Record.readSourceLocation();
940 E->RParenLoc = Record.readSourceLocation();
941 E->RBraceLoc = Record.readSourceLocation();
944 void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
945 VisitExpr(E);
946 E->setLHS(Record.readSubExpr());
947 E->setRHS(Record.readSubExpr());
948 E->setRBracketLoc(readSourceLocation());
951 void ASTStmtReader::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
952 VisitExpr(E);
953 E->setBase(Record.readSubExpr());
954 E->setRowIdx(Record.readSubExpr());
955 E->setColumnIdx(Record.readSubExpr());
956 E->setRBracketLoc(readSourceLocation());
959 void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
960 VisitExpr(E);
961 E->setBase(Record.readSubExpr());
962 E->setLowerBound(Record.readSubExpr());
963 E->setLength(Record.readSubExpr());
964 E->setStride(Record.readSubExpr());
965 E->setColonLocFirst(readSourceLocation());
966 E->setColonLocSecond(readSourceLocation());
967 E->setRBracketLoc(readSourceLocation());
970 void ASTStmtReader::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *E) {
971 VisitExpr(E);
972 unsigned NumDims = Record.readInt();
973 E->setBase(Record.readSubExpr());
974 SmallVector<Expr *, 4> Dims(NumDims);
975 for (unsigned I = 0; I < NumDims; ++I)
976 Dims[I] = Record.readSubExpr();
977 E->setDimensions(Dims);
978 SmallVector<SourceRange, 4> SRs(NumDims);
979 for (unsigned I = 0; I < NumDims; ++I)
980 SRs[I] = readSourceRange();
981 E->setBracketsRanges(SRs);
982 E->setLParenLoc(readSourceLocation());
983 E->setRParenLoc(readSourceLocation());
986 void ASTStmtReader::VisitOMPIteratorExpr(OMPIteratorExpr *E) {
987 VisitExpr(E);
988 unsigned NumIters = Record.readInt();
989 E->setIteratorKwLoc(readSourceLocation());
990 E->setLParenLoc(readSourceLocation());
991 E->setRParenLoc(readSourceLocation());
992 for (unsigned I = 0; I < NumIters; ++I) {
993 E->setIteratorDeclaration(I, Record.readDeclRef());
994 E->setAssignmentLoc(I, readSourceLocation());
995 Expr *Begin = Record.readSubExpr();
996 Expr *End = Record.readSubExpr();
997 Expr *Step = Record.readSubExpr();
998 SourceLocation ColonLoc = readSourceLocation();
999 SourceLocation SecColonLoc;
1000 if (Step)
1001 SecColonLoc = readSourceLocation();
1002 E->setIteratorRange(I, Begin, ColonLoc, End, SecColonLoc, Step);
1003 // Deserialize helpers
1004 OMPIteratorHelperData HD;
1005 HD.CounterVD = cast_or_null<VarDecl>(Record.readDeclRef());
1006 HD.Upper = Record.readSubExpr();
1007 HD.Update = Record.readSubExpr();
1008 HD.CounterUpdate = Record.readSubExpr();
1009 E->setHelper(I, HD);
1013 void ASTStmtReader::VisitCallExpr(CallExpr *E) {
1014 VisitExpr(E);
1016 unsigned NumArgs = Record.readInt();
1017 CurrentUnpackingBits.emplace(Record.readInt());
1018 E->setADLCallKind(
1019 static_cast<CallExpr::ADLCallKind>(CurrentUnpackingBits->getNextBit()));
1020 bool HasFPFeatures = CurrentUnpackingBits->getNextBit();
1021 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1022 E->setRParenLoc(readSourceLocation());
1023 E->setCallee(Record.readSubExpr());
1024 for (unsigned I = 0; I != NumArgs; ++I)
1025 E->setArg(I, Record.readSubExpr());
1027 if (HasFPFeatures)
1028 E->setStoredFPFeatures(
1029 FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
1032 void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
1033 VisitCallExpr(E);
1036 void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
1037 VisitExpr(E);
1039 CurrentUnpackingBits.emplace(Record.readInt());
1040 bool HasQualifier = CurrentUnpackingBits->getNextBit();
1041 bool HasFoundDecl = CurrentUnpackingBits->getNextBit();
1042 bool HasTemplateInfo = CurrentUnpackingBits->getNextBit();
1043 unsigned NumTemplateArgs = Record.readInt();
1045 E->Base = Record.readSubExpr();
1046 E->MemberDecl = Record.readDeclAs<ValueDecl>();
1047 E->MemberDNLoc = Record.readDeclarationNameLoc(E->MemberDecl->getDeclName());
1048 E->MemberLoc = Record.readSourceLocation();
1049 E->MemberExprBits.IsArrow = CurrentUnpackingBits->getNextBit();
1050 E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
1051 E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
1052 E->MemberExprBits.HadMultipleCandidates = CurrentUnpackingBits->getNextBit();
1053 E->MemberExprBits.NonOdrUseReason =
1054 CurrentUnpackingBits->getNextBits(/*Width=*/2);
1055 E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
1057 if (HasQualifier || HasFoundDecl) {
1058 DeclAccessPair FoundDecl;
1059 if (HasFoundDecl) {
1060 auto *FoundD = Record.readDeclAs<NamedDecl>();
1061 auto AS = (AccessSpecifier)CurrentUnpackingBits->getNextBits(/*Width=*/2);
1062 FoundDecl = DeclAccessPair::make(FoundD, AS);
1063 } else {
1064 FoundDecl = DeclAccessPair::make(E->MemberDecl,
1065 E->MemberDecl->getAccess());
1067 E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
1069 NestedNameSpecifierLoc QualifierLoc;
1070 if (HasQualifier)
1071 QualifierLoc = Record.readNestedNameSpecifierLoc();
1072 E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
1073 QualifierLoc;
1076 if (HasTemplateInfo)
1077 ReadTemplateKWAndArgsInfo(
1078 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1079 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
1082 void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
1083 VisitExpr(E);
1084 E->setBase(Record.readSubExpr());
1085 E->setIsaMemberLoc(readSourceLocation());
1086 E->setOpLoc(readSourceLocation());
1087 E->setArrow(Record.readInt());
1090 void ASTStmtReader::
1091 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
1092 VisitExpr(E);
1093 E->Operand = Record.readSubExpr();
1094 E->setShouldCopy(Record.readInt());
1097 void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
1098 VisitExplicitCastExpr(E);
1099 E->LParenLoc = readSourceLocation();
1100 E->BridgeKeywordLoc = readSourceLocation();
1101 E->Kind = Record.readInt();
1104 void ASTStmtReader::VisitCastExpr(CastExpr *E) {
1105 VisitExpr(E);
1106 unsigned NumBaseSpecs = Record.readInt();
1107 assert(NumBaseSpecs == E->path_size());
1109 CurrentUnpackingBits.emplace(Record.readInt());
1110 E->setCastKind((CastKind)CurrentUnpackingBits->getNextBits(/*Width=*/7));
1111 unsigned HasFPFeatures = CurrentUnpackingBits->getNextBit();
1112 assert(E->hasStoredFPFeatures() == HasFPFeatures);
1114 E->setSubExpr(Record.readSubExpr());
1116 CastExpr::path_iterator BaseI = E->path_begin();
1117 while (NumBaseSpecs--) {
1118 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
1119 *BaseSpec = Record.readCXXBaseSpecifier();
1120 *BaseI++ = BaseSpec;
1122 if (HasFPFeatures)
1123 *E->getTrailingFPFeatures() =
1124 FPOptionsOverride::getFromOpaqueInt(Record.readInt());
1127 void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
1128 VisitExpr(E);
1129 CurrentUnpackingBits.emplace(Record.readInt());
1130 E->setOpcode(
1131 (BinaryOperator::Opcode)CurrentUnpackingBits->getNextBits(/*Width=*/6));
1132 bool hasFP_Features = CurrentUnpackingBits->getNextBit();
1133 E->setHasStoredFPFeatures(hasFP_Features);
1134 E->setLHS(Record.readSubExpr());
1135 E->setRHS(Record.readSubExpr());
1136 E->setOperatorLoc(readSourceLocation());
1137 if (hasFP_Features)
1138 E->setStoredFPFeatures(
1139 FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
1142 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
1143 VisitBinaryOperator(E);
1144 E->setComputationLHSType(Record.readType());
1145 E->setComputationResultType(Record.readType());
1148 void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
1149 VisitExpr(E);
1150 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
1151 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
1152 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
1153 E->QuestionLoc = readSourceLocation();
1154 E->ColonLoc = readSourceLocation();
1157 void
1158 ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
1159 VisitExpr(E);
1160 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
1161 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
1162 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
1163 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
1164 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
1165 E->QuestionLoc = readSourceLocation();
1166 E->ColonLoc = readSourceLocation();
1169 void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
1170 VisitCastExpr(E);
1171 E->setIsPartOfExplicitCast(CurrentUnpackingBits->getNextBit());
1174 void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
1175 VisitCastExpr(E);
1176 E->setTypeInfoAsWritten(readTypeSourceInfo());
1179 void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
1180 VisitExplicitCastExpr(E);
1181 E->setLParenLoc(readSourceLocation());
1182 E->setRParenLoc(readSourceLocation());
1185 void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
1186 VisitExpr(E);
1187 E->setLParenLoc(readSourceLocation());
1188 E->setTypeSourceInfo(readTypeSourceInfo());
1189 E->setInitializer(Record.readSubExpr());
1190 E->setFileScope(Record.readInt());
1193 void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
1194 VisitExpr(E);
1195 E->setBase(Record.readSubExpr());
1196 E->setAccessor(Record.readIdentifier());
1197 E->setAccessorLoc(readSourceLocation());
1200 void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
1201 VisitExpr(E);
1202 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
1203 E->setSyntacticForm(SyntForm);
1204 E->setLBraceLoc(readSourceLocation());
1205 E->setRBraceLoc(readSourceLocation());
1206 bool isArrayFiller = Record.readInt();
1207 Expr *filler = nullptr;
1208 if (isArrayFiller) {
1209 filler = Record.readSubExpr();
1210 E->ArrayFillerOrUnionFieldInit = filler;
1211 } else
1212 E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
1213 E->sawArrayRangeDesignator(Record.readInt());
1214 unsigned NumInits = Record.readInt();
1215 E->reserveInits(Record.getContext(), NumInits);
1216 if (isArrayFiller) {
1217 for (unsigned I = 0; I != NumInits; ++I) {
1218 Expr *init = Record.readSubExpr();
1219 E->updateInit(Record.getContext(), I, init ? init : filler);
1221 } else {
1222 for (unsigned I = 0; I != NumInits; ++I)
1223 E->updateInit(Record.getContext(), I, Record.readSubExpr());
1227 void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
1228 using Designator = DesignatedInitExpr::Designator;
1230 VisitExpr(E);
1231 unsigned NumSubExprs = Record.readInt();
1232 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
1233 for (unsigned I = 0; I != NumSubExprs; ++I)
1234 E->setSubExpr(I, Record.readSubExpr());
1235 E->setEqualOrColonLoc(readSourceLocation());
1236 E->setGNUSyntax(Record.readInt());
1238 SmallVector<Designator, 4> Designators;
1239 while (Record.getIdx() < Record.size()) {
1240 switch ((DesignatorTypes)Record.readInt()) {
1241 case DESIG_FIELD_DECL: {
1242 auto *Field = readDeclAs<FieldDecl>();
1243 SourceLocation DotLoc = readSourceLocation();
1244 SourceLocation FieldLoc = readSourceLocation();
1245 Designators.push_back(Designator::CreateFieldDesignator(
1246 Field->getIdentifier(), DotLoc, FieldLoc));
1247 Designators.back().setFieldDecl(Field);
1248 break;
1251 case DESIG_FIELD_NAME: {
1252 const IdentifierInfo *Name = Record.readIdentifier();
1253 SourceLocation DotLoc = readSourceLocation();
1254 SourceLocation FieldLoc = readSourceLocation();
1255 Designators.push_back(Designator::CreateFieldDesignator(Name, DotLoc,
1256 FieldLoc));
1257 break;
1260 case DESIG_ARRAY: {
1261 unsigned Index = Record.readInt();
1262 SourceLocation LBracketLoc = readSourceLocation();
1263 SourceLocation RBracketLoc = readSourceLocation();
1264 Designators.push_back(Designator::CreateArrayDesignator(Index,
1265 LBracketLoc,
1266 RBracketLoc));
1267 break;
1270 case DESIG_ARRAY_RANGE: {
1271 unsigned Index = Record.readInt();
1272 SourceLocation LBracketLoc = readSourceLocation();
1273 SourceLocation EllipsisLoc = readSourceLocation();
1274 SourceLocation RBracketLoc = readSourceLocation();
1275 Designators.push_back(Designator::CreateArrayRangeDesignator(
1276 Index, LBracketLoc, EllipsisLoc, RBracketLoc));
1277 break;
1281 E->setDesignators(Record.getContext(),
1282 Designators.data(), Designators.size());
1285 void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1286 VisitExpr(E);
1287 E->setBase(Record.readSubExpr());
1288 E->setUpdater(Record.readSubExpr());
1291 void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1292 VisitExpr(E);
1295 void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1296 VisitExpr(E);
1297 E->SubExprs[0] = Record.readSubExpr();
1298 E->SubExprs[1] = Record.readSubExpr();
1301 void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1302 VisitExpr(E);
1305 void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
1306 VisitExpr(E);
1309 void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
1310 VisitExpr(E);
1311 E->setSubExpr(Record.readSubExpr());
1312 E->setWrittenTypeInfo(readTypeSourceInfo());
1313 E->setBuiltinLoc(readSourceLocation());
1314 E->setRParenLoc(readSourceLocation());
1315 E->setIsMicrosoftABI(Record.readInt());
1318 void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1319 VisitExpr(E);
1320 E->ParentContext = readDeclAs<DeclContext>();
1321 E->BuiltinLoc = readSourceLocation();
1322 E->RParenLoc = readSourceLocation();
1323 E->SourceLocExprBits.Kind = Record.readInt();
1326 void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
1327 VisitExpr(E);
1328 E->setAmpAmpLoc(readSourceLocation());
1329 E->setLabelLoc(readSourceLocation());
1330 E->setLabel(readDeclAs<LabelDecl>());
1333 void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
1334 VisitExpr(E);
1335 E->setLParenLoc(readSourceLocation());
1336 E->setRParenLoc(readSourceLocation());
1337 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
1338 E->StmtExprBits.TemplateDepth = Record.readInt();
1341 void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
1342 VisitExpr(E);
1343 E->setCond(Record.readSubExpr());
1344 E->setLHS(Record.readSubExpr());
1345 E->setRHS(Record.readSubExpr());
1346 E->setBuiltinLoc(readSourceLocation());
1347 E->setRParenLoc(readSourceLocation());
1348 E->setIsConditionTrue(Record.readInt());
1351 void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
1352 VisitExpr(E);
1353 E->setTokenLocation(readSourceLocation());
1356 void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
1357 VisitExpr(E);
1358 SmallVector<Expr *, 16> Exprs;
1359 unsigned NumExprs = Record.readInt();
1360 while (NumExprs--)
1361 Exprs.push_back(Record.readSubExpr());
1362 E->setExprs(Record.getContext(), Exprs);
1363 E->setBuiltinLoc(readSourceLocation());
1364 E->setRParenLoc(readSourceLocation());
1367 void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1368 VisitExpr(E);
1369 E->BuiltinLoc = readSourceLocation();
1370 E->RParenLoc = readSourceLocation();
1371 E->TInfo = readTypeSourceInfo();
1372 E->SrcExpr = Record.readSubExpr();
1375 void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
1376 VisitExpr(E);
1377 E->setBlockDecl(readDeclAs<BlockDecl>());
1380 void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1381 VisitExpr(E);
1383 unsigned NumAssocs = Record.readInt();
1384 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
1385 E->IsExprPredicate = Record.readInt();
1386 E->ResultIndex = Record.readInt();
1387 E->GenericSelectionExprBits.GenericLoc = readSourceLocation();
1388 E->DefaultLoc = readSourceLocation();
1389 E->RParenLoc = readSourceLocation();
1391 Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1392 // Add 1 to account for the controlling expression which is the first
1393 // expression in the trailing array of Stmt *. This is not needed for
1394 // the trailing array of TypeSourceInfo *.
1395 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1396 Stmts[I] = Record.readSubExpr();
1398 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1399 for (unsigned I = 0, N = NumAssocs; I < N; ++I)
1400 TSIs[I] = readTypeSourceInfo();
1403 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1404 VisitExpr(E);
1405 unsigned numSemanticExprs = Record.readInt();
1406 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
1407 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
1409 // Read the syntactic expression.
1410 E->getSubExprsBuffer()[0] = Record.readSubExpr();
1412 // Read all the semantic expressions.
1413 for (unsigned i = 0; i != numSemanticExprs; ++i) {
1414 Expr *subExpr = Record.readSubExpr();
1415 E->getSubExprsBuffer()[i+1] = subExpr;
1419 void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1420 VisitExpr(E);
1421 E->Op = AtomicExpr::AtomicOp(Record.readInt());
1422 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1423 for (unsigned I = 0; I != E->NumSubExprs; ++I)
1424 E->SubExprs[I] = Record.readSubExpr();
1425 E->BuiltinLoc = readSourceLocation();
1426 E->RParenLoc = readSourceLocation();
1429 //===----------------------------------------------------------------------===//
1430 // Objective-C Expressions and Statements
1432 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
1433 VisitExpr(E);
1434 E->setString(cast<StringLiteral>(Record.readSubStmt()));
1435 E->setAtLoc(readSourceLocation());
1438 void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
1439 VisitExpr(E);
1440 // could be one of several IntegerLiteral, FloatLiteral, etc.
1441 E->SubExpr = Record.readSubStmt();
1442 E->BoxingMethod = readDeclAs<ObjCMethodDecl>();
1443 E->Range = readSourceRange();
1446 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1447 VisitExpr(E);
1448 unsigned NumElements = Record.readInt();
1449 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1450 Expr **Elements = E->getElements();
1451 for (unsigned I = 0, N = NumElements; I != N; ++I)
1452 Elements[I] = Record.readSubExpr();
1453 E->ArrayWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1454 E->Range = readSourceRange();
1457 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1458 VisitExpr(E);
1459 unsigned NumElements = Record.readInt();
1460 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1461 bool HasPackExpansions = Record.readInt();
1462 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
1463 auto *KeyValues =
1464 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
1465 auto *Expansions =
1466 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
1467 for (unsigned I = 0; I != NumElements; ++I) {
1468 KeyValues[I].Key = Record.readSubExpr();
1469 KeyValues[I].Value = Record.readSubExpr();
1470 if (HasPackExpansions) {
1471 Expansions[I].EllipsisLoc = readSourceLocation();
1472 Expansions[I].NumExpansionsPlusOne = Record.readInt();
1475 E->DictWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1476 E->Range = readSourceRange();
1479 void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
1480 VisitExpr(E);
1481 E->setEncodedTypeSourceInfo(readTypeSourceInfo());
1482 E->setAtLoc(readSourceLocation());
1483 E->setRParenLoc(readSourceLocation());
1486 void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
1487 VisitExpr(E);
1488 E->setSelector(Record.readSelector());
1489 E->setAtLoc(readSourceLocation());
1490 E->setRParenLoc(readSourceLocation());
1493 void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
1494 VisitExpr(E);
1495 E->setProtocol(readDeclAs<ObjCProtocolDecl>());
1496 E->setAtLoc(readSourceLocation());
1497 E->ProtoLoc = readSourceLocation();
1498 E->setRParenLoc(readSourceLocation());
1501 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
1502 VisitExpr(E);
1503 E->setDecl(readDeclAs<ObjCIvarDecl>());
1504 E->setLocation(readSourceLocation());
1505 E->setOpLoc(readSourceLocation());
1506 E->setBase(Record.readSubExpr());
1507 E->setIsArrow(Record.readInt());
1508 E->setIsFreeIvar(Record.readInt());
1511 void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
1512 VisitExpr(E);
1513 unsigned MethodRefFlags = Record.readInt();
1514 bool Implicit = Record.readInt() != 0;
1515 if (Implicit) {
1516 auto *Getter = readDeclAs<ObjCMethodDecl>();
1517 auto *Setter = readDeclAs<ObjCMethodDecl>();
1518 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
1519 } else {
1520 E->setExplicitProperty(readDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
1522 E->setLocation(readSourceLocation());
1523 E->setReceiverLocation(readSourceLocation());
1524 switch (Record.readInt()) {
1525 case 0:
1526 E->setBase(Record.readSubExpr());
1527 break;
1528 case 1:
1529 E->setSuperReceiver(Record.readType());
1530 break;
1531 case 2:
1532 E->setClassReceiver(readDeclAs<ObjCInterfaceDecl>());
1533 break;
1537 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1538 VisitExpr(E);
1539 E->setRBracket(readSourceLocation());
1540 E->setBaseExpr(Record.readSubExpr());
1541 E->setKeyExpr(Record.readSubExpr());
1542 E->GetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1543 E->SetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1546 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1547 VisitExpr(E);
1548 assert(Record.peekInt() == E->getNumArgs());
1549 Record.skipInts(1);
1550 unsigned NumStoredSelLocs = Record.readInt();
1551 E->SelLocsKind = Record.readInt();
1552 E->setDelegateInitCall(Record.readInt());
1553 E->IsImplicit = Record.readInt();
1554 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
1555 switch (Kind) {
1556 case ObjCMessageExpr::Instance:
1557 E->setInstanceReceiver(Record.readSubExpr());
1558 break;
1560 case ObjCMessageExpr::Class:
1561 E->setClassReceiver(readTypeSourceInfo());
1562 break;
1564 case ObjCMessageExpr::SuperClass:
1565 case ObjCMessageExpr::SuperInstance: {
1566 QualType T = Record.readType();
1567 SourceLocation SuperLoc = readSourceLocation();
1568 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1569 break;
1573 assert(Kind == E->getReceiverKind());
1575 if (Record.readInt())
1576 E->setMethodDecl(readDeclAs<ObjCMethodDecl>());
1577 else
1578 E->setSelector(Record.readSelector());
1580 E->LBracLoc = readSourceLocation();
1581 E->RBracLoc = readSourceLocation();
1583 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1584 E->setArg(I, Record.readSubExpr());
1586 SourceLocation *Locs = E->getStoredSelLocs();
1587 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1588 Locs[I] = readSourceLocation();
1591 void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1592 VisitStmt(S);
1593 S->setElement(Record.readSubStmt());
1594 S->setCollection(Record.readSubExpr());
1595 S->setBody(Record.readSubStmt());
1596 S->setForLoc(readSourceLocation());
1597 S->setRParenLoc(readSourceLocation());
1600 void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1601 VisitStmt(S);
1602 S->setCatchBody(Record.readSubStmt());
1603 S->setCatchParamDecl(readDeclAs<VarDecl>());
1604 S->setAtCatchLoc(readSourceLocation());
1605 S->setRParenLoc(readSourceLocation());
1608 void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1609 VisitStmt(S);
1610 S->setFinallyBody(Record.readSubStmt());
1611 S->setAtFinallyLoc(readSourceLocation());
1614 void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1615 VisitStmt(S); // FIXME: no test coverage.
1616 S->setSubStmt(Record.readSubStmt());
1617 S->setAtLoc(readSourceLocation());
1620 void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1621 VisitStmt(S);
1622 assert(Record.peekInt() == S->getNumCatchStmts());
1623 Record.skipInts(1);
1624 bool HasFinally = Record.readInt();
1625 S->setTryBody(Record.readSubStmt());
1626 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
1627 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
1629 if (HasFinally)
1630 S->setFinallyStmt(Record.readSubStmt());
1631 S->setAtTryLoc(readSourceLocation());
1634 void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1635 VisitStmt(S); // FIXME: no test coverage.
1636 S->setSynchExpr(Record.readSubStmt());
1637 S->setSynchBody(Record.readSubStmt());
1638 S->setAtSynchronizedLoc(readSourceLocation());
1641 void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1642 VisitStmt(S); // FIXME: no test coverage.
1643 S->setThrowExpr(Record.readSubStmt());
1644 S->setThrowLoc(readSourceLocation());
1647 void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1648 VisitExpr(E);
1649 E->setValue(Record.readInt());
1650 E->setLocation(readSourceLocation());
1653 void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1654 VisitExpr(E);
1655 SourceRange R = Record.readSourceRange();
1656 E->AtLoc = R.getBegin();
1657 E->RParen = R.getEnd();
1658 E->VersionToCheck = Record.readVersionTuple();
1661 //===----------------------------------------------------------------------===//
1662 // C++ Expressions and Statements
1663 //===----------------------------------------------------------------------===//
1665 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
1666 VisitStmt(S);
1667 S->CatchLoc = readSourceLocation();
1668 S->ExceptionDecl = readDeclAs<VarDecl>();
1669 S->HandlerBlock = Record.readSubStmt();
1672 void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
1673 VisitStmt(S);
1674 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1675 Record.skipInts(1);
1676 S->TryLoc = readSourceLocation();
1677 S->getStmts()[0] = Record.readSubStmt();
1678 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1679 S->getStmts()[i + 1] = Record.readSubStmt();
1682 void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1683 VisitStmt(S);
1684 S->ForLoc = readSourceLocation();
1685 S->CoawaitLoc = readSourceLocation();
1686 S->ColonLoc = readSourceLocation();
1687 S->RParenLoc = readSourceLocation();
1688 S->setInit(Record.readSubStmt());
1689 S->setRangeStmt(Record.readSubStmt());
1690 S->setBeginStmt(Record.readSubStmt());
1691 S->setEndStmt(Record.readSubStmt());
1692 S->setCond(Record.readSubExpr());
1693 S->setInc(Record.readSubExpr());
1694 S->setLoopVarStmt(Record.readSubStmt());
1695 S->setBody(Record.readSubStmt());
1698 void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1699 VisitStmt(S);
1700 S->KeywordLoc = readSourceLocation();
1701 S->IsIfExists = Record.readInt();
1702 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
1703 S->NameInfo = Record.readDeclarationNameInfo();
1704 S->SubStmt = Record.readSubStmt();
1707 void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1708 VisitCallExpr(E);
1709 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1710 E->Range = Record.readSourceRange();
1713 void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1714 CXXRewrittenBinaryOperator *E) {
1715 VisitExpr(E);
1716 E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1717 E->SemanticForm = Record.readSubExpr();
1720 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
1721 VisitExpr(E);
1723 unsigned NumArgs = Record.readInt();
1724 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1726 E->CXXConstructExprBits.Elidable = Record.readInt();
1727 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1728 E->CXXConstructExprBits.ListInitialization = Record.readInt();
1729 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1730 E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1731 E->CXXConstructExprBits.ConstructionKind = Record.readInt();
1732 E->CXXConstructExprBits.IsImmediateEscalating = Record.readInt();
1733 E->CXXConstructExprBits.Loc = readSourceLocation();
1734 E->Constructor = readDeclAs<CXXConstructorDecl>();
1735 E->ParenOrBraceRange = readSourceRange();
1737 for (unsigned I = 0; I != NumArgs; ++I)
1738 E->setArg(I, Record.readSubExpr());
1741 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1742 VisitExpr(E);
1743 E->Constructor = readDeclAs<CXXConstructorDecl>();
1744 E->Loc = readSourceLocation();
1745 E->ConstructsVirtualBase = Record.readInt();
1746 E->InheritedFromVirtualBase = Record.readInt();
1749 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1750 VisitCXXConstructExpr(E);
1751 E->TSI = readTypeSourceInfo();
1754 void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1755 VisitExpr(E);
1756 unsigned NumCaptures = Record.readInt();
1757 (void)NumCaptures;
1758 assert(NumCaptures == E->LambdaExprBits.NumCaptures);
1759 E->IntroducerRange = readSourceRange();
1760 E->LambdaExprBits.CaptureDefault = Record.readInt();
1761 E->CaptureDefaultLoc = readSourceLocation();
1762 E->LambdaExprBits.ExplicitParams = Record.readInt();
1763 E->LambdaExprBits.ExplicitResultType = Record.readInt();
1764 E->ClosingBrace = readSourceLocation();
1766 // Read capture initializers.
1767 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1768 CEnd = E->capture_init_end();
1769 C != CEnd; ++C)
1770 *C = Record.readSubExpr();
1772 // The body will be lazily deserialized when needed from the call operator
1773 // declaration.
1776 void
1777 ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1778 VisitExpr(E);
1779 E->SubExpr = Record.readSubExpr();
1782 void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1783 VisitExplicitCastExpr(E);
1784 SourceRange R = readSourceRange();
1785 E->Loc = R.getBegin();
1786 E->RParenLoc = R.getEnd();
1787 if (CurrentUnpackingBits->getNextBit())
1788 E->AngleBrackets = readSourceRange();
1791 void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1792 return VisitCXXNamedCastExpr(E);
1795 void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1796 return VisitCXXNamedCastExpr(E);
1799 void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1800 return VisitCXXNamedCastExpr(E);
1803 void ASTStmtReader::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *E) {
1804 return VisitCXXNamedCastExpr(E);
1807 void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1808 return VisitCXXNamedCastExpr(E);
1811 void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1812 VisitExplicitCastExpr(E);
1813 E->setLParenLoc(readSourceLocation());
1814 E->setRParenLoc(readSourceLocation());
1817 void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1818 VisitExplicitCastExpr(E);
1819 E->KWLoc = readSourceLocation();
1820 E->RParenLoc = readSourceLocation();
1823 void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1824 VisitCallExpr(E);
1825 E->UDSuffixLoc = readSourceLocation();
1828 void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1829 VisitExpr(E);
1830 E->setValue(Record.readInt());
1831 E->setLocation(readSourceLocation());
1834 void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1835 VisitExpr(E);
1836 E->setLocation(readSourceLocation());
1839 void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1840 VisitExpr(E);
1841 E->setSourceRange(readSourceRange());
1842 if (E->isTypeOperand())
1843 E->Operand = readTypeSourceInfo();
1844 else
1845 E->Operand = Record.readSubExpr();
1848 void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
1849 VisitExpr(E);
1850 E->setLocation(readSourceLocation());
1851 E->setImplicit(Record.readInt());
1854 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
1855 VisitExpr(E);
1856 E->CXXThrowExprBits.ThrowLoc = readSourceLocation();
1857 E->Operand = Record.readSubExpr();
1858 E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
1861 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1862 VisitExpr(E);
1863 E->Param = readDeclAs<ParmVarDecl>();
1864 E->UsedContext = readDeclAs<DeclContext>();
1865 E->CXXDefaultArgExprBits.Loc = readSourceLocation();
1866 E->CXXDefaultArgExprBits.HasRewrittenInit = Record.readInt();
1867 if (E->CXXDefaultArgExprBits.HasRewrittenInit)
1868 *E->getTrailingObjects<Expr *>() = Record.readSubExpr();
1871 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1872 VisitExpr(E);
1873 E->CXXDefaultInitExprBits.HasRewrittenInit = Record.readInt();
1874 E->Field = readDeclAs<FieldDecl>();
1875 E->UsedContext = readDeclAs<DeclContext>();
1876 E->CXXDefaultInitExprBits.Loc = readSourceLocation();
1877 if (E->CXXDefaultInitExprBits.HasRewrittenInit)
1878 *E->getTrailingObjects<Expr *>() = Record.readSubExpr();
1881 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1882 VisitExpr(E);
1883 E->setTemporary(Record.readCXXTemporary());
1884 E->setSubExpr(Record.readSubExpr());
1887 void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1888 VisitExpr(E);
1889 E->TypeInfo = readTypeSourceInfo();
1890 E->CXXScalarValueInitExprBits.RParenLoc = readSourceLocation();
1893 void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
1894 VisitExpr(E);
1896 bool IsArray = Record.readInt();
1897 bool HasInit = Record.readInt();
1898 unsigned NumPlacementArgs = Record.readInt();
1899 bool IsParenTypeId = Record.readInt();
1901 E->CXXNewExprBits.IsGlobalNew = Record.readInt();
1902 E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
1903 E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1904 E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
1906 assert((IsArray == E->isArray()) && "Wrong IsArray!");
1907 assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
1908 assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
1909 "Wrong NumPlacementArgs!");
1910 assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
1911 (void)IsArray;
1912 (void)HasInit;
1913 (void)NumPlacementArgs;
1915 E->setOperatorNew(readDeclAs<FunctionDecl>());
1916 E->setOperatorDelete(readDeclAs<FunctionDecl>());
1917 E->AllocatedTypeInfo = readTypeSourceInfo();
1918 if (IsParenTypeId)
1919 E->getTrailingObjects<SourceRange>()[0] = readSourceRange();
1920 E->Range = readSourceRange();
1921 E->DirectInitRange = readSourceRange();
1923 // Install all the subexpressions.
1924 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
1925 N = E->raw_arg_end();
1926 I != N; ++I)
1927 *I = Record.readSubStmt();
1930 void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1931 VisitExpr(E);
1932 E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
1933 E->CXXDeleteExprBits.ArrayForm = Record.readInt();
1934 E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
1935 E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1936 E->OperatorDelete = readDeclAs<FunctionDecl>();
1937 E->Argument = Record.readSubExpr();
1938 E->CXXDeleteExprBits.Loc = readSourceLocation();
1941 void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1942 VisitExpr(E);
1944 E->Base = Record.readSubExpr();
1945 E->IsArrow = Record.readInt();
1946 E->OperatorLoc = readSourceLocation();
1947 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1948 E->ScopeType = readTypeSourceInfo();
1949 E->ColonColonLoc = readSourceLocation();
1950 E->TildeLoc = readSourceLocation();
1952 IdentifierInfo *II = Record.readIdentifier();
1953 if (II)
1954 E->setDestroyedType(II, readSourceLocation());
1955 else
1956 E->setDestroyedType(readTypeSourceInfo());
1959 void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
1960 VisitExpr(E);
1962 unsigned NumObjects = Record.readInt();
1963 assert(NumObjects == E->getNumObjects());
1964 for (unsigned i = 0; i != NumObjects; ++i) {
1965 unsigned CleanupKind = Record.readInt();
1966 ExprWithCleanups::CleanupObject Obj;
1967 if (CleanupKind == COK_Block)
1968 Obj = readDeclAs<BlockDecl>();
1969 else if (CleanupKind == COK_CompoundLiteral)
1970 Obj = cast<CompoundLiteralExpr>(Record.readSubExpr());
1971 else
1972 llvm_unreachable("unexpected cleanup object type");
1973 E->getTrailingObjects<ExprWithCleanups::CleanupObject>()[i] = Obj;
1976 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
1977 E->SubExpr = Record.readSubExpr();
1980 void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1981 CXXDependentScopeMemberExpr *E) {
1982 VisitExpr(E);
1984 unsigned NumTemplateArgs = Record.readInt();
1985 CurrentUnpackingBits.emplace(Record.readInt());
1986 bool HasTemplateKWAndArgsInfo = CurrentUnpackingBits->getNextBit();
1987 bool HasFirstQualifierFoundInScope = CurrentUnpackingBits->getNextBit();
1989 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
1990 "Wrong HasTemplateKWAndArgsInfo!");
1991 assert(
1992 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
1993 "Wrong HasFirstQualifierFoundInScope!");
1995 if (HasTemplateKWAndArgsInfo)
1996 ReadTemplateKWAndArgsInfo(
1997 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1998 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
2000 assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
2001 "Wrong NumTemplateArgs!");
2003 E->CXXDependentScopeMemberExprBits.IsArrow =
2004 CurrentUnpackingBits->getNextBit();
2006 E->BaseType = Record.readType();
2007 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
2008 // not ImplicitAccess
2009 if (CurrentUnpackingBits->getNextBit())
2010 E->Base = Record.readSubExpr();
2011 else
2012 E->Base = nullptr;
2014 E->CXXDependentScopeMemberExprBits.OperatorLoc = readSourceLocation();
2016 if (HasFirstQualifierFoundInScope)
2017 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
2019 E->MemberNameInfo = Record.readDeclarationNameInfo();
2022 void
2023 ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
2024 VisitExpr(E);
2026 if (CurrentUnpackingBits->getNextBit()) // HasTemplateKWAndArgsInfo
2027 ReadTemplateKWAndArgsInfo(
2028 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
2029 E->getTrailingObjects<TemplateArgumentLoc>(),
2030 /*NumTemplateArgs=*/CurrentUnpackingBits->getNextBits(/*Width=*/16));
2032 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
2033 E->NameInfo = Record.readDeclarationNameInfo();
2036 void
2037 ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
2038 VisitExpr(E);
2039 assert(Record.peekInt() == E->getNumArgs() &&
2040 "Read wrong record during creation ?");
2041 Record.skipInts(1);
2042 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
2043 E->setArg(I, Record.readSubExpr());
2044 E->TypeAndInitForm.setPointer(readTypeSourceInfo());
2045 E->setLParenLoc(readSourceLocation());
2046 E->setRParenLoc(readSourceLocation());
2047 E->TypeAndInitForm.setInt(Record.readInt());
2050 void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
2051 VisitExpr(E);
2053 unsigned NumResults = Record.readInt();
2054 CurrentUnpackingBits.emplace(Record.readInt());
2055 bool HasTemplateKWAndArgsInfo = CurrentUnpackingBits->getNextBit();
2056 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
2057 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
2058 "Wrong HasTemplateKWAndArgsInfo!");
2060 if (HasTemplateKWAndArgsInfo) {
2061 unsigned NumTemplateArgs = Record.readInt();
2062 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
2063 E->getTrailingTemplateArgumentLoc(),
2064 NumTemplateArgs);
2065 assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
2066 "Wrong NumTemplateArgs!");
2069 UnresolvedSet<8> Decls;
2070 for (unsigned I = 0; I != NumResults; ++I) {
2071 auto *D = readDeclAs<NamedDecl>();
2072 auto AS = (AccessSpecifier)Record.readInt();
2073 Decls.addDecl(D, AS);
2076 DeclAccessPair *Results = E->getTrailingResults();
2077 UnresolvedSetIterator Iter = Decls.begin();
2078 for (unsigned I = 0; I != NumResults; ++I) {
2079 Results[I] = (Iter + I).getPair();
2082 E->NameInfo = Record.readDeclarationNameInfo();
2083 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
2086 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
2087 VisitOverloadExpr(E);
2088 E->UnresolvedMemberExprBits.IsArrow = CurrentUnpackingBits->getNextBit();
2089 E->UnresolvedMemberExprBits.HasUnresolvedUsing =
2090 CurrentUnpackingBits->getNextBit();
2092 if (/*!isImplicitAccess=*/CurrentUnpackingBits->getNextBit())
2093 E->Base = Record.readSubExpr();
2094 else
2095 E->Base = nullptr;
2097 E->OperatorLoc = readSourceLocation();
2099 E->BaseType = Record.readType();
2102 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
2103 VisitOverloadExpr(E);
2104 E->UnresolvedLookupExprBits.RequiresADL = CurrentUnpackingBits->getNextBit();
2105 E->UnresolvedLookupExprBits.Overloaded = CurrentUnpackingBits->getNextBit();
2106 E->NamingClass = readDeclAs<CXXRecordDecl>();
2109 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
2110 VisitExpr(E);
2111 E->TypeTraitExprBits.NumArgs = Record.readInt();
2112 E->TypeTraitExprBits.Kind = Record.readInt();
2113 E->TypeTraitExprBits.Value = Record.readInt();
2114 SourceRange Range = readSourceRange();
2115 E->Loc = Range.getBegin();
2116 E->RParenLoc = Range.getEnd();
2118 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
2119 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
2120 Args[I] = readTypeSourceInfo();
2123 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
2124 VisitExpr(E);
2125 E->ATT = (ArrayTypeTrait)Record.readInt();
2126 E->Value = (unsigned int)Record.readInt();
2127 SourceRange Range = readSourceRange();
2128 E->Loc = Range.getBegin();
2129 E->RParen = Range.getEnd();
2130 E->QueriedType = readTypeSourceInfo();
2131 E->Dimension = Record.readSubExpr();
2134 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
2135 VisitExpr(E);
2136 E->ET = (ExpressionTrait)Record.readInt();
2137 E->Value = (bool)Record.readInt();
2138 SourceRange Range = readSourceRange();
2139 E->QueriedExpression = Record.readSubExpr();
2140 E->Loc = Range.getBegin();
2141 E->RParen = Range.getEnd();
2144 void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
2145 VisitExpr(E);
2146 E->CXXNoexceptExprBits.Value = Record.readInt();
2147 E->Range = readSourceRange();
2148 E->Operand = Record.readSubExpr();
2151 void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
2152 VisitExpr(E);
2153 E->EllipsisLoc = readSourceLocation();
2154 E->NumExpansions = Record.readInt();
2155 E->Pattern = Record.readSubExpr();
2158 void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2159 VisitExpr(E);
2160 unsigned NumPartialArgs = Record.readInt();
2161 E->OperatorLoc = readSourceLocation();
2162 E->PackLoc = readSourceLocation();
2163 E->RParenLoc = readSourceLocation();
2164 E->Pack = Record.readDeclAs<NamedDecl>();
2165 if (E->isPartiallySubstituted()) {
2166 assert(E->Length == NumPartialArgs);
2167 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
2168 *E = I + NumPartialArgs;
2169 I != E; ++I)
2170 new (I) TemplateArgument(Record.readTemplateArgument());
2171 } else if (!E->isValueDependent()) {
2172 E->Length = Record.readInt();
2176 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
2177 SubstNonTypeTemplateParmExpr *E) {
2178 VisitExpr(E);
2179 E->AssociatedDeclAndRef.setPointer(readDeclAs<Decl>());
2180 E->AssociatedDeclAndRef.setInt(CurrentUnpackingBits->getNextBit());
2181 E->Index = CurrentUnpackingBits->getNextBits(/*Width=*/12);
2182 if (CurrentUnpackingBits->getNextBit())
2183 E->PackIndex = Record.readInt();
2184 else
2185 E->PackIndex = 0;
2186 E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
2187 E->Replacement = Record.readSubExpr();
2190 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
2191 SubstNonTypeTemplateParmPackExpr *E) {
2192 VisitExpr(E);
2193 E->AssociatedDecl = readDeclAs<Decl>();
2194 E->Index = Record.readInt();
2195 TemplateArgument ArgPack = Record.readTemplateArgument();
2196 if (ArgPack.getKind() != TemplateArgument::Pack)
2197 return;
2199 E->Arguments = ArgPack.pack_begin();
2200 E->NumArguments = ArgPack.pack_size();
2201 E->NameLoc = readSourceLocation();
2204 void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2205 VisitExpr(E);
2206 E->NumParameters = Record.readInt();
2207 E->ParamPack = readDeclAs<ParmVarDecl>();
2208 E->NameLoc = readSourceLocation();
2209 auto **Parms = E->getTrailingObjects<VarDecl *>();
2210 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
2211 Parms[i] = readDeclAs<VarDecl>();
2214 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
2215 VisitExpr(E);
2216 bool HasMaterialzedDecl = Record.readInt();
2217 if (HasMaterialzedDecl)
2218 E->State = cast<LifetimeExtendedTemporaryDecl>(Record.readDecl());
2219 else
2220 E->State = Record.readSubExpr();
2223 void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
2224 VisitExpr(E);
2225 E->LParenLoc = readSourceLocation();
2226 E->EllipsisLoc = readSourceLocation();
2227 E->RParenLoc = readSourceLocation();
2228 E->NumExpansions = Record.readInt();
2229 E->SubExprs[0] = Record.readSubExpr();
2230 E->SubExprs[1] = Record.readSubExpr();
2231 E->SubExprs[2] = Record.readSubExpr();
2232 E->Opcode = (BinaryOperatorKind)Record.readInt();
2235 void ASTStmtReader::VisitCXXParenListInitExpr(CXXParenListInitExpr *E) {
2236 VisitExpr(E);
2237 unsigned ExpectedNumExprs = Record.readInt();
2238 assert(E->NumExprs == ExpectedNumExprs &&
2239 "expected number of expressions does not equal the actual number of "
2240 "serialized expressions.");
2241 E->NumUserSpecifiedExprs = Record.readInt();
2242 E->InitLoc = readSourceLocation();
2243 E->LParenLoc = readSourceLocation();
2244 E->RParenLoc = readSourceLocation();
2245 for (unsigned I = 0; I < ExpectedNumExprs; I++)
2246 E->getTrailingObjects<Expr *>()[I] = Record.readSubExpr();
2248 bool HasArrayFillerOrUnionDecl = Record.readBool();
2249 if (HasArrayFillerOrUnionDecl) {
2250 bool HasArrayFiller = Record.readBool();
2251 if (HasArrayFiller) {
2252 E->setArrayFiller(Record.readSubExpr());
2253 } else {
2254 E->setInitializedFieldInUnion(readDeclAs<FieldDecl>());
2257 E->updateDependence();
2260 void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
2261 VisitExpr(E);
2262 E->SourceExpr = Record.readSubExpr();
2263 E->OpaqueValueExprBits.Loc = readSourceLocation();
2264 E->setIsUnique(Record.readInt());
2267 void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
2268 llvm_unreachable("Cannot read TypoExpr nodes");
2271 void ASTStmtReader::VisitRecoveryExpr(RecoveryExpr *E) {
2272 VisitExpr(E);
2273 unsigned NumArgs = Record.readInt();
2274 E->BeginLoc = readSourceLocation();
2275 E->EndLoc = readSourceLocation();
2276 assert((NumArgs + 0LL ==
2277 std::distance(E->children().begin(), E->children().end())) &&
2278 "Wrong NumArgs!");
2279 (void)NumArgs;
2280 for (Stmt *&Child : E->children())
2281 Child = Record.readSubStmt();
2284 //===----------------------------------------------------------------------===//
2285 // Microsoft Expressions and Statements
2286 //===----------------------------------------------------------------------===//
2287 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
2288 VisitExpr(E);
2289 E->IsArrow = (Record.readInt() != 0);
2290 E->BaseExpr = Record.readSubExpr();
2291 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
2292 E->MemberLoc = readSourceLocation();
2293 E->TheDecl = readDeclAs<MSPropertyDecl>();
2296 void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
2297 VisitExpr(E);
2298 E->setBase(Record.readSubExpr());
2299 E->setIdx(Record.readSubExpr());
2300 E->setRBracketLoc(readSourceLocation());
2303 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
2304 VisitExpr(E);
2305 E->setSourceRange(readSourceRange());
2306 E->Guid = readDeclAs<MSGuidDecl>();
2307 if (E->isTypeOperand())
2308 E->Operand = readTypeSourceInfo();
2309 else
2310 E->Operand = Record.readSubExpr();
2313 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
2314 VisitStmt(S);
2315 S->setLeaveLoc(readSourceLocation());
2318 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
2319 VisitStmt(S);
2320 S->Loc = readSourceLocation();
2321 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
2322 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
2325 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
2326 VisitStmt(S);
2327 S->Loc = readSourceLocation();
2328 S->Block = Record.readSubStmt();
2331 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
2332 VisitStmt(S);
2333 S->IsCXXTry = Record.readInt();
2334 S->TryLoc = readSourceLocation();
2335 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
2336 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
2339 //===----------------------------------------------------------------------===//
2340 // CUDA Expressions and Statements
2341 //===----------------------------------------------------------------------===//
2343 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2344 VisitCallExpr(E);
2345 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
2348 //===----------------------------------------------------------------------===//
2349 // OpenCL Expressions and Statements.
2350 //===----------------------------------------------------------------------===//
2351 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2352 VisitExpr(E);
2353 E->BuiltinLoc = readSourceLocation();
2354 E->RParenLoc = readSourceLocation();
2355 E->SrcExpr = Record.readSubExpr();
2358 //===----------------------------------------------------------------------===//
2359 // OpenMP Directives.
2360 //===----------------------------------------------------------------------===//
2362 void ASTStmtReader::VisitOMPCanonicalLoop(OMPCanonicalLoop *S) {
2363 VisitStmt(S);
2364 for (Stmt *&SubStmt : S->SubStmts)
2365 SubStmt = Record.readSubStmt();
2368 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
2369 Record.readOMPChildren(E->Data);
2370 E->setLocStart(readSourceLocation());
2371 E->setLocEnd(readSourceLocation());
2372 E->setMappedDirective(Record.readEnum<OpenMPDirectiveKind>());
2375 void ASTStmtReader::VisitOMPLoopBasedDirective(OMPLoopBasedDirective *D) {
2376 VisitStmt(D);
2377 // Field CollapsedNum was read in ReadStmtFromStream.
2378 Record.skipInts(1);
2379 VisitOMPExecutableDirective(D);
2382 void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2383 VisitOMPLoopBasedDirective(D);
2386 void ASTStmtReader::VisitOMPMetaDirective(OMPMetaDirective *D) {
2387 VisitStmt(D);
2388 // The NumClauses field was read in ReadStmtFromStream.
2389 Record.skipInts(1);
2390 VisitOMPExecutableDirective(D);
2393 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
2394 VisitStmt(D);
2395 VisitOMPExecutableDirective(D);
2396 D->setHasCancel(Record.readBool());
2399 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
2400 VisitOMPLoopDirective(D);
2403 void ASTStmtReader::VisitOMPLoopTransformationDirective(
2404 OMPLoopTransformationDirective *D) {
2405 VisitOMPLoopBasedDirective(D);
2406 D->setNumGeneratedLoops(Record.readUInt32());
2409 void ASTStmtReader::VisitOMPTileDirective(OMPTileDirective *D) {
2410 VisitOMPLoopTransformationDirective(D);
2413 void ASTStmtReader::VisitOMPUnrollDirective(OMPUnrollDirective *D) {
2414 VisitOMPLoopTransformationDirective(D);
2417 void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
2418 VisitOMPLoopDirective(D);
2419 D->setHasCancel(Record.readBool());
2422 void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2423 VisitOMPLoopDirective(D);
2426 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2427 VisitStmt(D);
2428 VisitOMPExecutableDirective(D);
2429 D->setHasCancel(Record.readBool());
2432 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2433 VisitStmt(D);
2434 VisitOMPExecutableDirective(D);
2435 D->setHasCancel(Record.readBool());
2438 void ASTStmtReader::VisitOMPScopeDirective(OMPScopeDirective *D) {
2439 VisitStmt(D);
2440 VisitOMPExecutableDirective(D);
2443 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2444 VisitStmt(D);
2445 VisitOMPExecutableDirective(D);
2448 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2449 VisitStmt(D);
2450 VisitOMPExecutableDirective(D);
2453 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2454 VisitStmt(D);
2455 VisitOMPExecutableDirective(D);
2456 D->DirName = Record.readDeclarationNameInfo();
2459 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
2460 VisitOMPLoopDirective(D);
2461 D->setHasCancel(Record.readBool());
2464 void ASTStmtReader::VisitOMPParallelForSimdDirective(
2465 OMPParallelForSimdDirective *D) {
2466 VisitOMPLoopDirective(D);
2469 void ASTStmtReader::VisitOMPParallelMasterDirective(
2470 OMPParallelMasterDirective *D) {
2471 VisitStmt(D);
2472 VisitOMPExecutableDirective(D);
2475 void ASTStmtReader::VisitOMPParallelMaskedDirective(
2476 OMPParallelMaskedDirective *D) {
2477 VisitStmt(D);
2478 VisitOMPExecutableDirective(D);
2481 void ASTStmtReader::VisitOMPParallelSectionsDirective(
2482 OMPParallelSectionsDirective *D) {
2483 VisitStmt(D);
2484 VisitOMPExecutableDirective(D);
2485 D->setHasCancel(Record.readBool());
2488 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2489 VisitStmt(D);
2490 VisitOMPExecutableDirective(D);
2491 D->setHasCancel(Record.readBool());
2494 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2495 VisitStmt(D);
2496 VisitOMPExecutableDirective(D);
2499 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2500 VisitStmt(D);
2501 VisitOMPExecutableDirective(D);
2504 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2505 VisitStmt(D);
2506 // The NumClauses field was read in ReadStmtFromStream.
2507 Record.skipInts(1);
2508 VisitOMPExecutableDirective(D);
2511 void ASTStmtReader::VisitOMPErrorDirective(OMPErrorDirective *D) {
2512 VisitStmt(D);
2513 // The NumClauses field was read in ReadStmtFromStream.
2514 Record.skipInts(1);
2515 VisitOMPExecutableDirective(D);
2518 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2519 VisitStmt(D);
2520 VisitOMPExecutableDirective(D);
2523 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2524 VisitStmt(D);
2525 VisitOMPExecutableDirective(D);
2528 void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective *D) {
2529 VisitStmt(D);
2530 VisitOMPExecutableDirective(D);
2533 void ASTStmtReader::VisitOMPScanDirective(OMPScanDirective *D) {
2534 VisitStmt(D);
2535 VisitOMPExecutableDirective(D);
2538 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2539 VisitStmt(D);
2540 VisitOMPExecutableDirective(D);
2543 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2544 VisitStmt(D);
2545 VisitOMPExecutableDirective(D);
2546 D->Flags.IsXLHSInRHSPart = Record.readBool() ? 1 : 0;
2547 D->Flags.IsPostfixUpdate = Record.readBool() ? 1 : 0;
2548 D->Flags.IsFailOnly = Record.readBool() ? 1 : 0;
2551 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2552 VisitStmt(D);
2553 VisitOMPExecutableDirective(D);
2556 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2557 VisitStmt(D);
2558 VisitOMPExecutableDirective(D);
2561 void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2562 OMPTargetEnterDataDirective *D) {
2563 VisitStmt(D);
2564 VisitOMPExecutableDirective(D);
2567 void ASTStmtReader::VisitOMPTargetExitDataDirective(
2568 OMPTargetExitDataDirective *D) {
2569 VisitStmt(D);
2570 VisitOMPExecutableDirective(D);
2573 void ASTStmtReader::VisitOMPTargetParallelDirective(
2574 OMPTargetParallelDirective *D) {
2575 VisitStmt(D);
2576 VisitOMPExecutableDirective(D);
2577 D->setHasCancel(Record.readBool());
2580 void ASTStmtReader::VisitOMPTargetParallelForDirective(
2581 OMPTargetParallelForDirective *D) {
2582 VisitOMPLoopDirective(D);
2583 D->setHasCancel(Record.readBool());
2586 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2587 VisitStmt(D);
2588 VisitOMPExecutableDirective(D);
2591 void ASTStmtReader::VisitOMPCancellationPointDirective(
2592 OMPCancellationPointDirective *D) {
2593 VisitStmt(D);
2594 VisitOMPExecutableDirective(D);
2595 D->setCancelRegion(Record.readEnum<OpenMPDirectiveKind>());
2598 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2599 VisitStmt(D);
2600 VisitOMPExecutableDirective(D);
2601 D->setCancelRegion(Record.readEnum<OpenMPDirectiveKind>());
2604 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2605 VisitOMPLoopDirective(D);
2606 D->setHasCancel(Record.readBool());
2609 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2610 VisitOMPLoopDirective(D);
2613 void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2614 OMPMasterTaskLoopDirective *D) {
2615 VisitOMPLoopDirective(D);
2616 D->setHasCancel(Record.readBool());
2619 void ASTStmtReader::VisitOMPMaskedTaskLoopDirective(
2620 OMPMaskedTaskLoopDirective *D) {
2621 VisitOMPLoopDirective(D);
2622 D->setHasCancel(Record.readBool());
2625 void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2626 OMPMasterTaskLoopSimdDirective *D) {
2627 VisitOMPLoopDirective(D);
2630 void ASTStmtReader::VisitOMPMaskedTaskLoopSimdDirective(
2631 OMPMaskedTaskLoopSimdDirective *D) {
2632 VisitOMPLoopDirective(D);
2635 void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2636 OMPParallelMasterTaskLoopDirective *D) {
2637 VisitOMPLoopDirective(D);
2638 D->setHasCancel(Record.readBool());
2641 void ASTStmtReader::VisitOMPParallelMaskedTaskLoopDirective(
2642 OMPParallelMaskedTaskLoopDirective *D) {
2643 VisitOMPLoopDirective(D);
2644 D->setHasCancel(Record.readBool());
2647 void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2648 OMPParallelMasterTaskLoopSimdDirective *D) {
2649 VisitOMPLoopDirective(D);
2652 void ASTStmtReader::VisitOMPParallelMaskedTaskLoopSimdDirective(
2653 OMPParallelMaskedTaskLoopSimdDirective *D) {
2654 VisitOMPLoopDirective(D);
2657 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2658 VisitOMPLoopDirective(D);
2661 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2662 VisitStmt(D);
2663 VisitOMPExecutableDirective(D);
2666 void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2667 OMPDistributeParallelForDirective *D) {
2668 VisitOMPLoopDirective(D);
2669 D->setHasCancel(Record.readBool());
2672 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2673 OMPDistributeParallelForSimdDirective *D) {
2674 VisitOMPLoopDirective(D);
2677 void ASTStmtReader::VisitOMPDistributeSimdDirective(
2678 OMPDistributeSimdDirective *D) {
2679 VisitOMPLoopDirective(D);
2682 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2683 OMPTargetParallelForSimdDirective *D) {
2684 VisitOMPLoopDirective(D);
2687 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2688 VisitOMPLoopDirective(D);
2691 void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2692 OMPTeamsDistributeDirective *D) {
2693 VisitOMPLoopDirective(D);
2696 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2697 OMPTeamsDistributeSimdDirective *D) {
2698 VisitOMPLoopDirective(D);
2701 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2702 OMPTeamsDistributeParallelForSimdDirective *D) {
2703 VisitOMPLoopDirective(D);
2706 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2707 OMPTeamsDistributeParallelForDirective *D) {
2708 VisitOMPLoopDirective(D);
2709 D->setHasCancel(Record.readBool());
2712 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2713 VisitStmt(D);
2714 VisitOMPExecutableDirective(D);
2717 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2718 OMPTargetTeamsDistributeDirective *D) {
2719 VisitOMPLoopDirective(D);
2722 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2723 OMPTargetTeamsDistributeParallelForDirective *D) {
2724 VisitOMPLoopDirective(D);
2725 D->setHasCancel(Record.readBool());
2728 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2729 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2730 VisitOMPLoopDirective(D);
2733 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2734 OMPTargetTeamsDistributeSimdDirective *D) {
2735 VisitOMPLoopDirective(D);
2738 void ASTStmtReader::VisitOMPInteropDirective(OMPInteropDirective *D) {
2739 VisitStmt(D);
2740 VisitOMPExecutableDirective(D);
2743 void ASTStmtReader::VisitOMPDispatchDirective(OMPDispatchDirective *D) {
2744 VisitStmt(D);
2745 VisitOMPExecutableDirective(D);
2746 D->setTargetCallLoc(Record.readSourceLocation());
2749 void ASTStmtReader::VisitOMPMaskedDirective(OMPMaskedDirective *D) {
2750 VisitStmt(D);
2751 VisitOMPExecutableDirective(D);
2754 void ASTStmtReader::VisitOMPGenericLoopDirective(OMPGenericLoopDirective *D) {
2755 VisitOMPLoopDirective(D);
2758 void ASTStmtReader::VisitOMPTeamsGenericLoopDirective(
2759 OMPTeamsGenericLoopDirective *D) {
2760 VisitOMPLoopDirective(D);
2763 void ASTStmtReader::VisitOMPTargetTeamsGenericLoopDirective(
2764 OMPTargetTeamsGenericLoopDirective *D) {
2765 VisitOMPLoopDirective(D);
2768 void ASTStmtReader::VisitOMPParallelGenericLoopDirective(
2769 OMPParallelGenericLoopDirective *D) {
2770 VisitOMPLoopDirective(D);
2773 void ASTStmtReader::VisitOMPTargetParallelGenericLoopDirective(
2774 OMPTargetParallelGenericLoopDirective *D) {
2775 VisitOMPLoopDirective(D);
2778 //===----------------------------------------------------------------------===//
2779 // ASTReader Implementation
2780 //===----------------------------------------------------------------------===//
2782 Stmt *ASTReader::ReadStmt(ModuleFile &F) {
2783 switch (ReadingKind) {
2784 case Read_None:
2785 llvm_unreachable("should not call this when not reading anything");
2786 case Read_Decl:
2787 case Read_Type:
2788 return ReadStmtFromStream(F);
2789 case Read_Stmt:
2790 return ReadSubStmt();
2793 llvm_unreachable("ReadingKind not set ?");
2796 Expr *ASTReader::ReadExpr(ModuleFile &F) {
2797 return cast_or_null<Expr>(ReadStmt(F));
2800 Expr *ASTReader::ReadSubExpr() {
2801 return cast_or_null<Expr>(ReadSubStmt());
2804 // Within the bitstream, expressions are stored in Reverse Polish
2805 // Notation, with each of the subexpressions preceding the
2806 // expression they are stored in. Subexpressions are stored from last to first.
2807 // To evaluate expressions, we continue reading expressions and placing them on
2808 // the stack, with expressions having operands removing those operands from the
2809 // stack. Evaluation terminates when we see a STMT_STOP record, and
2810 // the single remaining expression on the stack is our result.
2811 Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
2812 ReadingKindTracker ReadingKind(Read_Stmt, *this);
2813 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
2815 // Map of offset to previously deserialized stmt. The offset points
2816 // just after the stmt record.
2817 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
2819 #ifndef NDEBUG
2820 unsigned PrevNumStmts = StmtStack.size();
2821 #endif
2823 ASTRecordReader Record(*this, F);
2824 ASTStmtReader Reader(Record, Cursor);
2825 Stmt::EmptyShell Empty;
2827 while (true) {
2828 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2829 Cursor.advanceSkippingSubblocks();
2830 if (!MaybeEntry) {
2831 Error(toString(MaybeEntry.takeError()));
2832 return nullptr;
2834 llvm::BitstreamEntry Entry = MaybeEntry.get();
2836 switch (Entry.Kind) {
2837 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2838 case llvm::BitstreamEntry::Error:
2839 Error("malformed block record in AST file");
2840 return nullptr;
2841 case llvm::BitstreamEntry::EndBlock:
2842 goto Done;
2843 case llvm::BitstreamEntry::Record:
2844 // The interesting case.
2845 break;
2848 ASTContext &Context = getContext();
2849 Stmt *S = nullptr;
2850 bool Finished = false;
2851 bool IsStmtReference = false;
2852 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2853 if (!MaybeStmtCode) {
2854 Error(toString(MaybeStmtCode.takeError()));
2855 return nullptr;
2857 switch ((StmtCode)MaybeStmtCode.get()) {
2858 case STMT_STOP:
2859 Finished = true;
2860 break;
2862 case STMT_REF_PTR:
2863 IsStmtReference = true;
2864 assert(StmtEntries.contains(Record[0]) &&
2865 "No stmt was recorded for this offset reference!");
2866 S = StmtEntries[Record.readInt()];
2867 break;
2869 case STMT_NULL_PTR:
2870 S = nullptr;
2871 break;
2873 case STMT_NULL:
2874 S = new (Context) NullStmt(Empty);
2875 break;
2877 case STMT_COMPOUND: {
2878 unsigned NumStmts = Record[ASTStmtReader::NumStmtFields];
2879 bool HasFPFeatures = Record[ASTStmtReader::NumStmtFields + 1];
2880 S = CompoundStmt::CreateEmpty(Context, NumStmts, HasFPFeatures);
2881 break;
2884 case STMT_CASE:
2885 S = CaseStmt::CreateEmpty(
2886 Context,
2887 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
2888 break;
2890 case STMT_DEFAULT:
2891 S = new (Context) DefaultStmt(Empty);
2892 break;
2894 case STMT_LABEL:
2895 S = new (Context) LabelStmt(Empty);
2896 break;
2898 case STMT_ATTRIBUTED:
2899 S = AttributedStmt::CreateEmpty(
2900 Context,
2901 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
2902 break;
2904 case STMT_IF: {
2905 BitsUnpacker IfStmtBits(Record[ASTStmtReader::NumStmtFields]);
2906 bool HasElse = IfStmtBits.getNextBit();
2907 bool HasVar = IfStmtBits.getNextBit();
2908 bool HasInit = IfStmtBits.getNextBit();
2909 S = IfStmt::CreateEmpty(Context, HasElse, HasVar, HasInit);
2910 break;
2913 case STMT_SWITCH:
2914 S = SwitchStmt::CreateEmpty(
2915 Context,
2916 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
2917 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
2918 break;
2920 case STMT_WHILE:
2921 S = WhileStmt::CreateEmpty(
2922 Context,
2923 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
2924 break;
2926 case STMT_DO:
2927 S = new (Context) DoStmt(Empty);
2928 break;
2930 case STMT_FOR:
2931 S = new (Context) ForStmt(Empty);
2932 break;
2934 case STMT_GOTO:
2935 S = new (Context) GotoStmt(Empty);
2936 break;
2938 case STMT_INDIRECT_GOTO:
2939 S = new (Context) IndirectGotoStmt(Empty);
2940 break;
2942 case STMT_CONTINUE:
2943 S = new (Context) ContinueStmt(Empty);
2944 break;
2946 case STMT_BREAK:
2947 S = new (Context) BreakStmt(Empty);
2948 break;
2950 case STMT_RETURN:
2951 S = ReturnStmt::CreateEmpty(
2952 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
2953 break;
2955 case STMT_DECL:
2956 S = new (Context) DeclStmt(Empty);
2957 break;
2959 case STMT_GCCASM:
2960 S = new (Context) GCCAsmStmt(Empty);
2961 break;
2963 case STMT_MSASM:
2964 S = new (Context) MSAsmStmt(Empty);
2965 break;
2967 case STMT_CAPTURED:
2968 S = CapturedStmt::CreateDeserialized(
2969 Context, Record[ASTStmtReader::NumStmtFields]);
2970 break;
2972 case EXPR_CONSTANT:
2973 S = ConstantExpr::CreateEmpty(
2974 Context, static_cast<ConstantResultStorageKind>(
2975 /*StorageKind=*/Record[ASTStmtReader::NumExprFields]));
2976 break;
2978 case EXPR_SYCL_UNIQUE_STABLE_NAME:
2979 S = SYCLUniqueStableNameExpr::CreateEmpty(Context);
2980 break;
2982 case EXPR_PREDEFINED:
2983 S = PredefinedExpr::CreateEmpty(
2984 Context,
2985 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
2986 break;
2988 case EXPR_DECL_REF: {
2989 BitsUnpacker DeclRefExprBits(Record[ASTStmtReader::NumExprFields]);
2990 DeclRefExprBits.advance(5);
2991 bool HasFoundDecl = DeclRefExprBits.getNextBit();
2992 bool HasQualifier = DeclRefExprBits.getNextBit();
2993 bool HasTemplateKWAndArgsInfo = DeclRefExprBits.getNextBit();
2994 unsigned NumTemplateArgs = HasTemplateKWAndArgsInfo
2995 ? Record[ASTStmtReader::NumExprFields + 1]
2996 : 0;
2997 S = DeclRefExpr::CreateEmpty(Context, HasQualifier, HasFoundDecl,
2998 HasTemplateKWAndArgsInfo, NumTemplateArgs);
2999 break;
3002 case EXPR_INTEGER_LITERAL:
3003 S = IntegerLiteral::Create(Context, Empty);
3004 break;
3006 case EXPR_FIXEDPOINT_LITERAL:
3007 S = FixedPointLiteral::Create(Context, Empty);
3008 break;
3010 case EXPR_FLOATING_LITERAL:
3011 S = FloatingLiteral::Create(Context, Empty);
3012 break;
3014 case EXPR_IMAGINARY_LITERAL:
3015 S = new (Context) ImaginaryLiteral(Empty);
3016 break;
3018 case EXPR_STRING_LITERAL:
3019 S = StringLiteral::CreateEmpty(
3020 Context,
3021 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
3022 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
3023 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
3024 break;
3026 case EXPR_CHARACTER_LITERAL:
3027 S = new (Context) CharacterLiteral(Empty);
3028 break;
3030 case EXPR_PAREN:
3031 S = new (Context) ParenExpr(Empty);
3032 break;
3034 case EXPR_PAREN_LIST:
3035 S = ParenListExpr::CreateEmpty(
3036 Context,
3037 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
3038 break;
3040 case EXPR_UNARY_OPERATOR: {
3041 BitsUnpacker UnaryOperatorBits(Record[ASTStmtReader::NumStmtFields]);
3042 UnaryOperatorBits.advance(ASTStmtReader::NumExprBits);
3043 bool HasFPFeatures = UnaryOperatorBits.getNextBit();
3044 S = UnaryOperator::CreateEmpty(Context, HasFPFeatures);
3045 break;
3048 case EXPR_OFFSETOF:
3049 S = OffsetOfExpr::CreateEmpty(Context,
3050 Record[ASTStmtReader::NumExprFields],
3051 Record[ASTStmtReader::NumExprFields + 1]);
3052 break;
3054 case EXPR_SIZEOF_ALIGN_OF:
3055 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
3056 break;
3058 case EXPR_ARRAY_SUBSCRIPT:
3059 S = new (Context) ArraySubscriptExpr(Empty);
3060 break;
3062 case EXPR_MATRIX_SUBSCRIPT:
3063 S = new (Context) MatrixSubscriptExpr(Empty);
3064 break;
3066 case EXPR_OMP_ARRAY_SECTION:
3067 S = new (Context) OMPArraySectionExpr(Empty);
3068 break;
3070 case EXPR_OMP_ARRAY_SHAPING:
3071 S = OMPArrayShapingExpr::CreateEmpty(
3072 Context, Record[ASTStmtReader::NumExprFields]);
3073 break;
3075 case EXPR_OMP_ITERATOR:
3076 S = OMPIteratorExpr::CreateEmpty(Context,
3077 Record[ASTStmtReader::NumExprFields]);
3078 break;
3080 case EXPR_CALL: {
3081 auto NumArgs = Record[ASTStmtReader::NumExprFields];
3082 BitsUnpacker CallExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3083 CallExprBits.advance(1);
3084 auto HasFPFeatures = CallExprBits.getNextBit();
3085 S = CallExpr::CreateEmpty(Context, NumArgs, HasFPFeatures, Empty);
3086 break;
3089 case EXPR_RECOVERY:
3090 S = RecoveryExpr::CreateEmpty(
3091 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3092 break;
3094 case EXPR_MEMBER: {
3095 BitsUnpacker ExprMemberBits(Record[ASTStmtReader::NumExprFields]);
3096 bool HasQualifier = ExprMemberBits.getNextBit();
3097 bool HasFoundDecl = ExprMemberBits.getNextBit();
3098 bool HasTemplateInfo = ExprMemberBits.getNextBit();
3099 unsigned NumTemplateArgs = Record[ASTStmtReader::NumExprFields + 1];
3100 S = MemberExpr::CreateEmpty(Context, HasQualifier, HasFoundDecl,
3101 HasTemplateInfo, NumTemplateArgs);
3102 break;
3105 case EXPR_BINARY_OPERATOR: {
3106 BitsUnpacker BinaryOperatorBits(Record[ASTStmtReader::NumExprFields]);
3107 BinaryOperatorBits.advance(/*Size of opcode*/ 6);
3108 bool HasFPFeatures = BinaryOperatorBits.getNextBit();
3109 S = BinaryOperator::CreateEmpty(Context, HasFPFeatures);
3110 break;
3113 case EXPR_COMPOUND_ASSIGN_OPERATOR: {
3114 BitsUnpacker BinaryOperatorBits(Record[ASTStmtReader::NumExprFields]);
3115 BinaryOperatorBits.advance(/*Size of opcode*/ 6);
3116 bool HasFPFeatures = BinaryOperatorBits.getNextBit();
3117 S = CompoundAssignOperator::CreateEmpty(Context, HasFPFeatures);
3118 break;
3121 case EXPR_CONDITIONAL_OPERATOR:
3122 S = new (Context) ConditionalOperator(Empty);
3123 break;
3125 case EXPR_BINARY_CONDITIONAL_OPERATOR:
3126 S = new (Context) BinaryConditionalOperator(Empty);
3127 break;
3129 case EXPR_IMPLICIT_CAST: {
3130 unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3131 BitsUnpacker CastExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3132 CastExprBits.advance(7);
3133 bool HasFPFeatures = CastExprBits.getNextBit();
3134 S = ImplicitCastExpr::CreateEmpty(Context, PathSize, HasFPFeatures);
3135 break;
3138 case EXPR_CSTYLE_CAST: {
3139 unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3140 BitsUnpacker CastExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3141 CastExprBits.advance(7);
3142 bool HasFPFeatures = CastExprBits.getNextBit();
3143 S = CStyleCastExpr::CreateEmpty(Context, PathSize, HasFPFeatures);
3144 break;
3147 case EXPR_COMPOUND_LITERAL:
3148 S = new (Context) CompoundLiteralExpr(Empty);
3149 break;
3151 case EXPR_EXT_VECTOR_ELEMENT:
3152 S = new (Context) ExtVectorElementExpr(Empty);
3153 break;
3155 case EXPR_INIT_LIST:
3156 S = new (Context) InitListExpr(Empty);
3157 break;
3159 case EXPR_DESIGNATED_INIT:
3160 S = DesignatedInitExpr::CreateEmpty(Context,
3161 Record[ASTStmtReader::NumExprFields] - 1);
3163 break;
3165 case EXPR_DESIGNATED_INIT_UPDATE:
3166 S = new (Context) DesignatedInitUpdateExpr(Empty);
3167 break;
3169 case EXPR_IMPLICIT_VALUE_INIT:
3170 S = new (Context) ImplicitValueInitExpr(Empty);
3171 break;
3173 case EXPR_NO_INIT:
3174 S = new (Context) NoInitExpr(Empty);
3175 break;
3177 case EXPR_ARRAY_INIT_LOOP:
3178 S = new (Context) ArrayInitLoopExpr(Empty);
3179 break;
3181 case EXPR_ARRAY_INIT_INDEX:
3182 S = new (Context) ArrayInitIndexExpr(Empty);
3183 break;
3185 case EXPR_VA_ARG:
3186 S = new (Context) VAArgExpr(Empty);
3187 break;
3189 case EXPR_SOURCE_LOC:
3190 S = new (Context) SourceLocExpr(Empty);
3191 break;
3193 case EXPR_ADDR_LABEL:
3194 S = new (Context) AddrLabelExpr(Empty);
3195 break;
3197 case EXPR_STMT:
3198 S = new (Context) StmtExpr(Empty);
3199 break;
3201 case EXPR_CHOOSE:
3202 S = new (Context) ChooseExpr(Empty);
3203 break;
3205 case EXPR_GNU_NULL:
3206 S = new (Context) GNUNullExpr(Empty);
3207 break;
3209 case EXPR_SHUFFLE_VECTOR:
3210 S = new (Context) ShuffleVectorExpr(Empty);
3211 break;
3213 case EXPR_CONVERT_VECTOR:
3214 S = new (Context) ConvertVectorExpr(Empty);
3215 break;
3217 case EXPR_BLOCK:
3218 S = new (Context) BlockExpr(Empty);
3219 break;
3221 case EXPR_GENERIC_SELECTION:
3222 S = GenericSelectionExpr::CreateEmpty(
3223 Context,
3224 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
3225 break;
3227 case EXPR_OBJC_STRING_LITERAL:
3228 S = new (Context) ObjCStringLiteral(Empty);
3229 break;
3231 case EXPR_OBJC_BOXED_EXPRESSION:
3232 S = new (Context) ObjCBoxedExpr(Empty);
3233 break;
3235 case EXPR_OBJC_ARRAY_LITERAL:
3236 S = ObjCArrayLiteral::CreateEmpty(Context,
3237 Record[ASTStmtReader::NumExprFields]);
3238 break;
3240 case EXPR_OBJC_DICTIONARY_LITERAL:
3241 S = ObjCDictionaryLiteral::CreateEmpty(Context,
3242 Record[ASTStmtReader::NumExprFields],
3243 Record[ASTStmtReader::NumExprFields + 1]);
3244 break;
3246 case EXPR_OBJC_ENCODE:
3247 S = new (Context) ObjCEncodeExpr(Empty);
3248 break;
3250 case EXPR_OBJC_SELECTOR_EXPR:
3251 S = new (Context) ObjCSelectorExpr(Empty);
3252 break;
3254 case EXPR_OBJC_PROTOCOL_EXPR:
3255 S = new (Context) ObjCProtocolExpr(Empty);
3256 break;
3258 case EXPR_OBJC_IVAR_REF_EXPR:
3259 S = new (Context) ObjCIvarRefExpr(Empty);
3260 break;
3262 case EXPR_OBJC_PROPERTY_REF_EXPR:
3263 S = new (Context) ObjCPropertyRefExpr(Empty);
3264 break;
3266 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
3267 S = new (Context) ObjCSubscriptRefExpr(Empty);
3268 break;
3270 case EXPR_OBJC_KVC_REF_EXPR:
3271 llvm_unreachable("mismatching AST file");
3273 case EXPR_OBJC_MESSAGE_EXPR:
3274 S = ObjCMessageExpr::CreateEmpty(Context,
3275 Record[ASTStmtReader::NumExprFields],
3276 Record[ASTStmtReader::NumExprFields + 1]);
3277 break;
3279 case EXPR_OBJC_ISA:
3280 S = new (Context) ObjCIsaExpr(Empty);
3281 break;
3283 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
3284 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
3285 break;
3287 case EXPR_OBJC_BRIDGED_CAST:
3288 S = new (Context) ObjCBridgedCastExpr(Empty);
3289 break;
3291 case STMT_OBJC_FOR_COLLECTION:
3292 S = new (Context) ObjCForCollectionStmt(Empty);
3293 break;
3295 case STMT_OBJC_CATCH:
3296 S = new (Context) ObjCAtCatchStmt(Empty);
3297 break;
3299 case STMT_OBJC_FINALLY:
3300 S = new (Context) ObjCAtFinallyStmt(Empty);
3301 break;
3303 case STMT_OBJC_AT_TRY:
3304 S = ObjCAtTryStmt::CreateEmpty(Context,
3305 Record[ASTStmtReader::NumStmtFields],
3306 Record[ASTStmtReader::NumStmtFields + 1]);
3307 break;
3309 case STMT_OBJC_AT_SYNCHRONIZED:
3310 S = new (Context) ObjCAtSynchronizedStmt(Empty);
3311 break;
3313 case STMT_OBJC_AT_THROW:
3314 S = new (Context) ObjCAtThrowStmt(Empty);
3315 break;
3317 case STMT_OBJC_AUTORELEASE_POOL:
3318 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3319 break;
3321 case EXPR_OBJC_BOOL_LITERAL:
3322 S = new (Context) ObjCBoolLiteralExpr(Empty);
3323 break;
3325 case EXPR_OBJC_AVAILABILITY_CHECK:
3326 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3327 break;
3329 case STMT_SEH_LEAVE:
3330 S = new (Context) SEHLeaveStmt(Empty);
3331 break;
3333 case STMT_SEH_EXCEPT:
3334 S = new (Context) SEHExceptStmt(Empty);
3335 break;
3337 case STMT_SEH_FINALLY:
3338 S = new (Context) SEHFinallyStmt(Empty);
3339 break;
3341 case STMT_SEH_TRY:
3342 S = new (Context) SEHTryStmt(Empty);
3343 break;
3345 case STMT_CXX_CATCH:
3346 S = new (Context) CXXCatchStmt(Empty);
3347 break;
3349 case STMT_CXX_TRY:
3350 S = CXXTryStmt::Create(Context, Empty,
3351 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
3352 break;
3354 case STMT_CXX_FOR_RANGE:
3355 S = new (Context) CXXForRangeStmt(Empty);
3356 break;
3358 case STMT_MS_DEPENDENT_EXISTS:
3359 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3360 NestedNameSpecifierLoc(),
3361 DeclarationNameInfo(),
3362 nullptr);
3363 break;
3365 case STMT_OMP_CANONICAL_LOOP:
3366 S = OMPCanonicalLoop::createEmpty(Context);
3367 break;
3369 case STMT_OMP_META_DIRECTIVE:
3370 S = OMPMetaDirective::CreateEmpty(
3371 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3372 break;
3374 case STMT_OMP_PARALLEL_DIRECTIVE:
3376 OMPParallelDirective::CreateEmpty(Context,
3377 Record[ASTStmtReader::NumStmtFields],
3378 Empty);
3379 break;
3381 case STMT_OMP_SIMD_DIRECTIVE: {
3382 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3383 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3384 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3385 CollapsedNum, Empty);
3386 break;
3389 case STMT_OMP_TILE_DIRECTIVE: {
3390 unsigned NumLoops = Record[ASTStmtReader::NumStmtFields];
3391 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3392 S = OMPTileDirective::CreateEmpty(Context, NumClauses, NumLoops);
3393 break;
3396 case STMT_OMP_UNROLL_DIRECTIVE: {
3397 assert(Record[ASTStmtReader::NumStmtFields] == 1 && "Unroll directive accepts only a single loop");
3398 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3399 S = OMPUnrollDirective::CreateEmpty(Context, NumClauses);
3400 break;
3403 case STMT_OMP_FOR_DIRECTIVE: {
3404 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3405 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3406 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3407 Empty);
3408 break;
3411 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3412 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3413 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3414 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3415 Empty);
3416 break;
3419 case STMT_OMP_SECTIONS_DIRECTIVE:
3420 S = OMPSectionsDirective::CreateEmpty(
3421 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3422 break;
3424 case STMT_OMP_SECTION_DIRECTIVE:
3425 S = OMPSectionDirective::CreateEmpty(Context, Empty);
3426 break;
3428 case STMT_OMP_SCOPE_DIRECTIVE:
3429 S = OMPScopeDirective::CreateEmpty(
3430 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3431 break;
3433 case STMT_OMP_SINGLE_DIRECTIVE:
3434 S = OMPSingleDirective::CreateEmpty(
3435 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3436 break;
3438 case STMT_OMP_MASTER_DIRECTIVE:
3439 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3440 break;
3442 case STMT_OMP_CRITICAL_DIRECTIVE:
3443 S = OMPCriticalDirective::CreateEmpty(
3444 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3445 break;
3447 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3448 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3449 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3450 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3451 CollapsedNum, Empty);
3452 break;
3455 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3456 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3457 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3458 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3459 CollapsedNum, Empty);
3460 break;
3463 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3464 S = OMPParallelMasterDirective::CreateEmpty(
3465 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3466 break;
3468 case STMT_OMP_PARALLEL_MASKED_DIRECTIVE:
3469 S = OMPParallelMaskedDirective::CreateEmpty(
3470 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3471 break;
3473 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3474 S = OMPParallelSectionsDirective::CreateEmpty(
3475 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3476 break;
3478 case STMT_OMP_TASK_DIRECTIVE:
3479 S = OMPTaskDirective::CreateEmpty(
3480 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3481 break;
3483 case STMT_OMP_TASKYIELD_DIRECTIVE:
3484 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3485 break;
3487 case STMT_OMP_BARRIER_DIRECTIVE:
3488 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3489 break;
3491 case STMT_OMP_TASKWAIT_DIRECTIVE:
3492 S = OMPTaskwaitDirective::CreateEmpty(
3493 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3494 break;
3496 case STMT_OMP_ERROR_DIRECTIVE:
3497 S = OMPErrorDirective::CreateEmpty(
3498 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3499 break;
3501 case STMT_OMP_TASKGROUP_DIRECTIVE:
3502 S = OMPTaskgroupDirective::CreateEmpty(
3503 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3504 break;
3506 case STMT_OMP_FLUSH_DIRECTIVE:
3507 S = OMPFlushDirective::CreateEmpty(
3508 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3509 break;
3511 case STMT_OMP_DEPOBJ_DIRECTIVE:
3512 S = OMPDepobjDirective::CreateEmpty(
3513 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3514 break;
3516 case STMT_OMP_SCAN_DIRECTIVE:
3517 S = OMPScanDirective::CreateEmpty(
3518 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3519 break;
3521 case STMT_OMP_ORDERED_DIRECTIVE: {
3522 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3523 bool HasAssociatedStmt = Record[ASTStmtReader::NumStmtFields + 2];
3524 S = OMPOrderedDirective::CreateEmpty(Context, NumClauses,
3525 !HasAssociatedStmt, Empty);
3526 break;
3529 case STMT_OMP_ATOMIC_DIRECTIVE:
3530 S = OMPAtomicDirective::CreateEmpty(
3531 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3532 break;
3534 case STMT_OMP_TARGET_DIRECTIVE:
3535 S = OMPTargetDirective::CreateEmpty(
3536 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3537 break;
3539 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3540 S = OMPTargetDataDirective::CreateEmpty(
3541 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3542 break;
3544 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3545 S = OMPTargetEnterDataDirective::CreateEmpty(
3546 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3547 break;
3549 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3550 S = OMPTargetExitDataDirective::CreateEmpty(
3551 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3552 break;
3554 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3555 S = OMPTargetParallelDirective::CreateEmpty(
3556 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3557 break;
3559 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3560 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3561 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3562 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3563 CollapsedNum, Empty);
3564 break;
3567 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3568 S = OMPTargetUpdateDirective::CreateEmpty(
3569 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3570 break;
3572 case STMT_OMP_TEAMS_DIRECTIVE:
3573 S = OMPTeamsDirective::CreateEmpty(
3574 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3575 break;
3577 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3578 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3579 break;
3581 case STMT_OMP_CANCEL_DIRECTIVE:
3582 S = OMPCancelDirective::CreateEmpty(
3583 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3584 break;
3586 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3587 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3588 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3589 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3590 Empty);
3591 break;
3594 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3595 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3596 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3597 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3598 CollapsedNum, Empty);
3599 break;
3602 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3603 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3604 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3605 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3606 CollapsedNum, Empty);
3607 break;
3610 case STMT_OMP_MASKED_TASKLOOP_DIRECTIVE: {
3611 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3612 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3613 S = OMPMaskedTaskLoopDirective::CreateEmpty(Context, NumClauses,
3614 CollapsedNum, Empty);
3615 break;
3618 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3619 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3620 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3621 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3622 CollapsedNum, Empty);
3623 break;
3626 case STMT_OMP_MASKED_TASKLOOP_SIMD_DIRECTIVE: {
3627 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3628 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3629 S = OMPMaskedTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3630 CollapsedNum, Empty);
3631 break;
3634 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3635 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3636 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3637 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3638 CollapsedNum, Empty);
3639 break;
3642 case STMT_OMP_PARALLEL_MASKED_TASKLOOP_DIRECTIVE: {
3643 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3644 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3645 S = OMPParallelMaskedTaskLoopDirective::CreateEmpty(Context, NumClauses,
3646 CollapsedNum, Empty);
3647 break;
3650 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3651 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3652 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3653 S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3654 Context, NumClauses, CollapsedNum, Empty);
3655 break;
3658 case STMT_OMP_PARALLEL_MASKED_TASKLOOP_SIMD_DIRECTIVE: {
3659 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3660 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3661 S = OMPParallelMaskedTaskLoopSimdDirective::CreateEmpty(
3662 Context, NumClauses, CollapsedNum, Empty);
3663 break;
3666 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3667 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3668 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3669 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3670 Empty);
3671 break;
3674 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3675 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3676 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3677 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3678 CollapsedNum, Empty);
3679 break;
3682 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3683 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3684 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3685 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3686 CollapsedNum,
3687 Empty);
3688 break;
3691 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3692 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3693 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3694 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3695 CollapsedNum, Empty);
3696 break;
3699 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3700 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3701 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3702 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3703 CollapsedNum, Empty);
3704 break;
3707 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3708 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3709 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3710 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3711 Empty);
3712 break;
3715 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
3716 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3717 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3718 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3719 CollapsedNum, Empty);
3720 break;
3723 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3724 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3725 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3726 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3727 CollapsedNum, Empty);
3728 break;
3731 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3732 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3733 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3734 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3735 Context, NumClauses, CollapsedNum, Empty);
3736 break;
3739 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3740 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3741 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3742 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3743 Context, NumClauses, CollapsedNum, Empty);
3744 break;
3747 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
3748 S = OMPTargetTeamsDirective::CreateEmpty(
3749 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3750 break;
3752 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3753 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3754 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3755 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3756 CollapsedNum, Empty);
3757 break;
3760 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3761 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3762 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3763 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3764 Context, NumClauses, CollapsedNum, Empty);
3765 break;
3768 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3769 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3770 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3771 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3772 Context, NumClauses, CollapsedNum, Empty);
3773 break;
3776 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3777 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3778 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3779 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3780 Context, NumClauses, CollapsedNum, Empty);
3781 break;
3784 case STMT_OMP_INTEROP_DIRECTIVE:
3785 S = OMPInteropDirective::CreateEmpty(
3786 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3787 break;
3789 case STMT_OMP_DISPATCH_DIRECTIVE:
3790 S = OMPDispatchDirective::CreateEmpty(
3791 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3792 break;
3794 case STMT_OMP_MASKED_DIRECTIVE:
3795 S = OMPMaskedDirective::CreateEmpty(
3796 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3797 break;
3799 case STMT_OMP_GENERIC_LOOP_DIRECTIVE: {
3800 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3801 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3802 S = OMPGenericLoopDirective::CreateEmpty(Context, NumClauses,
3803 CollapsedNum, Empty);
3804 break;
3807 case STMT_OMP_TEAMS_GENERIC_LOOP_DIRECTIVE: {
3808 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3809 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3810 S = OMPTeamsGenericLoopDirective::CreateEmpty(Context, NumClauses,
3811 CollapsedNum, Empty);
3812 break;
3815 case STMT_OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVE: {
3816 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3817 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3818 S = OMPTargetTeamsGenericLoopDirective::CreateEmpty(Context, NumClauses,
3819 CollapsedNum, Empty);
3820 break;
3823 case STMT_OMP_PARALLEL_GENERIC_LOOP_DIRECTIVE: {
3824 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3825 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3826 S = OMPParallelGenericLoopDirective::CreateEmpty(Context, NumClauses,
3827 CollapsedNum, Empty);
3828 break;
3831 case STMT_OMP_TARGET_PARALLEL_GENERIC_LOOP_DIRECTIVE: {
3832 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
3833 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
3834 S = OMPTargetParallelGenericLoopDirective::CreateEmpty(
3835 Context, NumClauses, CollapsedNum, Empty);
3836 break;
3839 case EXPR_CXX_OPERATOR_CALL: {
3840 auto NumArgs = Record[ASTStmtReader::NumExprFields];
3841 BitsUnpacker CallExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3842 CallExprBits.advance(1);
3843 auto HasFPFeatures = CallExprBits.getNextBit();
3844 S = CXXOperatorCallExpr::CreateEmpty(Context, NumArgs, HasFPFeatures,
3845 Empty);
3846 break;
3849 case EXPR_CXX_MEMBER_CALL: {
3850 auto NumArgs = Record[ASTStmtReader::NumExprFields];
3851 BitsUnpacker CallExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3852 CallExprBits.advance(1);
3853 auto HasFPFeatures = CallExprBits.getNextBit();
3854 S = CXXMemberCallExpr::CreateEmpty(Context, NumArgs, HasFPFeatures,
3855 Empty);
3856 break;
3859 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3860 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3861 break;
3863 case EXPR_CXX_CONSTRUCT:
3864 S = CXXConstructExpr::CreateEmpty(
3865 Context,
3866 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3867 break;
3869 case EXPR_CXX_INHERITED_CTOR_INIT:
3870 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3871 break;
3873 case EXPR_CXX_TEMPORARY_OBJECT:
3874 S = CXXTemporaryObjectExpr::CreateEmpty(
3875 Context,
3876 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3877 break;
3879 case EXPR_CXX_STATIC_CAST: {
3880 unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3881 BitsUnpacker CastExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3882 CastExprBits.advance(7);
3883 bool HasFPFeatures = CastExprBits.getNextBit();
3884 S = CXXStaticCastExpr::CreateEmpty(Context, PathSize, HasFPFeatures);
3885 break;
3888 case EXPR_CXX_DYNAMIC_CAST: {
3889 unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3890 S = CXXDynamicCastExpr::CreateEmpty(Context, PathSize);
3891 break;
3894 case EXPR_CXX_REINTERPRET_CAST: {
3895 unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3896 S = CXXReinterpretCastExpr::CreateEmpty(Context, PathSize);
3897 break;
3900 case EXPR_CXX_CONST_CAST:
3901 S = CXXConstCastExpr::CreateEmpty(Context);
3902 break;
3904 case EXPR_CXX_ADDRSPACE_CAST:
3905 S = CXXAddrspaceCastExpr::CreateEmpty(Context);
3906 break;
3908 case EXPR_CXX_FUNCTIONAL_CAST: {
3909 unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3910 BitsUnpacker CastExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3911 CastExprBits.advance(7);
3912 bool HasFPFeatures = CastExprBits.getNextBit();
3913 S = CXXFunctionalCastExpr::CreateEmpty(Context, PathSize, HasFPFeatures);
3914 break;
3917 case EXPR_BUILTIN_BIT_CAST: {
3918 #ifndef NDEBUG
3919 unsigned PathSize = Record[ASTStmtReader::NumExprFields];
3920 assert(PathSize == 0 && "Wrong PathSize!");
3921 #endif
3922 S = new (Context) BuiltinBitCastExpr(Empty);
3923 break;
3926 case EXPR_USER_DEFINED_LITERAL: {
3927 auto NumArgs = Record[ASTStmtReader::NumExprFields];
3928 BitsUnpacker CallExprBits(Record[ASTStmtReader::NumExprFields + 1]);
3929 CallExprBits.advance(1);
3930 auto HasFPFeatures = CallExprBits.getNextBit();
3931 S = UserDefinedLiteral::CreateEmpty(Context, NumArgs, HasFPFeatures,
3932 Empty);
3933 break;
3936 case EXPR_CXX_STD_INITIALIZER_LIST:
3937 S = new (Context) CXXStdInitializerListExpr(Empty);
3938 break;
3940 case EXPR_CXX_BOOL_LITERAL:
3941 S = new (Context) CXXBoolLiteralExpr(Empty);
3942 break;
3944 case EXPR_CXX_NULL_PTR_LITERAL:
3945 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3946 break;
3948 case EXPR_CXX_TYPEID_EXPR:
3949 S = new (Context) CXXTypeidExpr(Empty, true);
3950 break;
3952 case EXPR_CXX_TYPEID_TYPE:
3953 S = new (Context) CXXTypeidExpr(Empty, false);
3954 break;
3956 case EXPR_CXX_UUIDOF_EXPR:
3957 S = new (Context) CXXUuidofExpr(Empty, true);
3958 break;
3960 case EXPR_CXX_PROPERTY_REF_EXPR:
3961 S = new (Context) MSPropertyRefExpr(Empty);
3962 break;
3964 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3965 S = new (Context) MSPropertySubscriptExpr(Empty);
3966 break;
3968 case EXPR_CXX_UUIDOF_TYPE:
3969 S = new (Context) CXXUuidofExpr(Empty, false);
3970 break;
3972 case EXPR_CXX_THIS:
3973 S = CXXThisExpr::CreateEmpty(Context);
3974 break;
3976 case EXPR_CXX_THROW:
3977 S = new (Context) CXXThrowExpr(Empty);
3978 break;
3980 case EXPR_CXX_DEFAULT_ARG:
3981 S = CXXDefaultArgExpr::CreateEmpty(
3982 Context, /*HasRewrittenInit=*/Record[ASTStmtReader::NumExprFields]);
3983 break;
3985 case EXPR_CXX_DEFAULT_INIT:
3986 S = CXXDefaultInitExpr::CreateEmpty(
3987 Context, /*HasRewrittenInit=*/Record[ASTStmtReader::NumExprFields]);
3988 break;
3990 case EXPR_CXX_BIND_TEMPORARY:
3991 S = new (Context) CXXBindTemporaryExpr(Empty);
3992 break;
3994 case EXPR_CXX_SCALAR_VALUE_INIT:
3995 S = new (Context) CXXScalarValueInitExpr(Empty);
3996 break;
3998 case EXPR_CXX_NEW:
3999 S = CXXNewExpr::CreateEmpty(
4000 Context,
4001 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
4002 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
4003 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
4004 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
4005 break;
4007 case EXPR_CXX_DELETE:
4008 S = new (Context) CXXDeleteExpr(Empty);
4009 break;
4011 case EXPR_CXX_PSEUDO_DESTRUCTOR:
4012 S = new (Context) CXXPseudoDestructorExpr(Empty);
4013 break;
4015 case EXPR_EXPR_WITH_CLEANUPS:
4016 S = ExprWithCleanups::Create(Context, Empty,
4017 Record[ASTStmtReader::NumExprFields]);
4018 break;
4020 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER: {
4021 unsigned NumTemplateArgs = Record[ASTStmtReader::NumExprFields];
4022 BitsUnpacker DependentScopeMemberBits(
4023 Record[ASTStmtReader::NumExprFields + 1]);
4024 bool HasTemplateKWAndArgsInfo = DependentScopeMemberBits.getNextBit();
4026 bool HasFirstQualifierFoundInScope =
4027 DependentScopeMemberBits.getNextBit();
4028 S = CXXDependentScopeMemberExpr::CreateEmpty(
4029 Context, HasTemplateKWAndArgsInfo, NumTemplateArgs,
4030 HasFirstQualifierFoundInScope);
4031 break;
4034 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF: {
4035 BitsUnpacker DependentScopeDeclRefBits(
4036 Record[ASTStmtReader::NumStmtFields]);
4037 DependentScopeDeclRefBits.advance(ASTStmtReader::NumExprBits);
4038 bool HasTemplateKWAndArgsInfo = DependentScopeDeclRefBits.getNextBit();
4039 unsigned NumTemplateArgs =
4040 HasTemplateKWAndArgsInfo
4041 ? DependentScopeDeclRefBits.getNextBits(/*Width=*/16)
4042 : 0;
4043 S = DependentScopeDeclRefExpr::CreateEmpty(
4044 Context, HasTemplateKWAndArgsInfo, NumTemplateArgs);
4045 break;
4048 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
4049 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
4050 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
4051 break;
4053 case EXPR_CXX_UNRESOLVED_MEMBER: {
4054 auto NumResults = Record[ASTStmtReader::NumExprFields];
4055 BitsUnpacker OverloadExprBits(Record[ASTStmtReader::NumExprFields + 1]);
4056 auto HasTemplateKWAndArgsInfo = OverloadExprBits.getNextBit();
4057 auto NumTemplateArgs = HasTemplateKWAndArgsInfo
4058 ? Record[ASTStmtReader::NumExprFields + 2]
4059 : 0;
4060 S = UnresolvedMemberExpr::CreateEmpty(
4061 Context, NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
4062 break;
4065 case EXPR_CXX_UNRESOLVED_LOOKUP: {
4066 auto NumResults = Record[ASTStmtReader::NumExprFields];
4067 BitsUnpacker OverloadExprBits(Record[ASTStmtReader::NumExprFields + 1]);
4068 auto HasTemplateKWAndArgsInfo = OverloadExprBits.getNextBit();
4069 auto NumTemplateArgs = HasTemplateKWAndArgsInfo
4070 ? Record[ASTStmtReader::NumExprFields + 2]
4071 : 0;
4072 S = UnresolvedLookupExpr::CreateEmpty(
4073 Context, NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
4074 break;
4077 case EXPR_TYPE_TRAIT:
4078 S = TypeTraitExpr::CreateDeserialized(Context,
4079 Record[ASTStmtReader::NumExprFields]);
4080 break;
4082 case EXPR_ARRAY_TYPE_TRAIT:
4083 S = new (Context) ArrayTypeTraitExpr(Empty);
4084 break;
4086 case EXPR_CXX_EXPRESSION_TRAIT:
4087 S = new (Context) ExpressionTraitExpr(Empty);
4088 break;
4090 case EXPR_CXX_NOEXCEPT:
4091 S = new (Context) CXXNoexceptExpr(Empty);
4092 break;
4094 case EXPR_PACK_EXPANSION:
4095 S = new (Context) PackExpansionExpr(Empty);
4096 break;
4098 case EXPR_SIZEOF_PACK:
4099 S = SizeOfPackExpr::CreateDeserialized(
4100 Context,
4101 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
4102 break;
4104 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
4105 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
4106 break;
4108 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
4109 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
4110 break;
4112 case EXPR_FUNCTION_PARM_PACK:
4113 S = FunctionParmPackExpr::CreateEmpty(Context,
4114 Record[ASTStmtReader::NumExprFields]);
4115 break;
4117 case EXPR_MATERIALIZE_TEMPORARY:
4118 S = new (Context) MaterializeTemporaryExpr(Empty);
4119 break;
4121 case EXPR_CXX_FOLD:
4122 S = new (Context) CXXFoldExpr(Empty);
4123 break;
4125 case EXPR_CXX_PAREN_LIST_INIT:
4126 S = CXXParenListInitExpr::CreateEmpty(
4127 Context, /*numExprs=*/Record[ASTStmtReader::NumExprFields], Empty);
4128 break;
4130 case EXPR_OPAQUE_VALUE:
4131 S = new (Context) OpaqueValueExpr(Empty);
4132 break;
4134 case EXPR_CUDA_KERNEL_CALL: {
4135 auto NumArgs = Record[ASTStmtReader::NumExprFields];
4136 BitsUnpacker CallExprBits(Record[ASTStmtReader::NumExprFields + 1]);
4137 CallExprBits.advance(1);
4138 auto HasFPFeatures = CallExprBits.getNextBit();
4139 S = CUDAKernelCallExpr::CreateEmpty(Context, NumArgs, HasFPFeatures,
4140 Empty);
4141 break;
4144 case EXPR_ASTYPE:
4145 S = new (Context) AsTypeExpr(Empty);
4146 break;
4148 case EXPR_PSEUDO_OBJECT: {
4149 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
4150 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
4151 break;
4154 case EXPR_ATOMIC:
4155 S = new (Context) AtomicExpr(Empty);
4156 break;
4158 case EXPR_LAMBDA: {
4159 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
4160 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
4161 break;
4164 case STMT_COROUTINE_BODY: {
4165 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
4166 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
4167 break;
4170 case STMT_CORETURN:
4171 S = new (Context) CoreturnStmt(Empty);
4172 break;
4174 case EXPR_COAWAIT:
4175 S = new (Context) CoawaitExpr(Empty);
4176 break;
4178 case EXPR_COYIELD:
4179 S = new (Context) CoyieldExpr(Empty);
4180 break;
4182 case EXPR_DEPENDENT_COAWAIT:
4183 S = new (Context) DependentCoawaitExpr(Empty);
4184 break;
4186 case EXPR_CONCEPT_SPECIALIZATION: {
4187 S = new (Context) ConceptSpecializationExpr(Empty);
4188 break;
4191 case EXPR_REQUIRES:
4192 unsigned numLocalParameters = Record[ASTStmtReader::NumExprFields];
4193 unsigned numRequirement = Record[ASTStmtReader::NumExprFields + 1];
4194 S = RequiresExpr::Create(Context, Empty, numLocalParameters,
4195 numRequirement);
4196 break;
4199 // We hit a STMT_STOP, so we're done with this expression.
4200 if (Finished)
4201 break;
4203 ++NumStatementsRead;
4205 if (S && !IsStmtReference) {
4206 Reader.Visit(S);
4207 StmtEntries[Cursor.GetCurrentBitNo()] = S;
4210 assert(Record.getIdx() == Record.size() &&
4211 "Invalid deserialization of statement");
4212 StmtStack.push_back(S);
4214 Done:
4215 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
4216 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
4217 return StmtStack.pop_back_val();