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

source code of clang/lib/Serialization/ASTReaderStmt.cpp