Bug Summary

File:llvm/include/llvm/Bitstream/BitstreamReader.h
Warning:line 220, column 39
The result of the right shift is undefined due to shifting by '64', which is greater or equal to the width of type 'llvm::SimpleBitstreamCursor::word_t'

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name ASTReaderStmt.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=none -relaxed-aliasing -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -D CLANG_VENDOR="Debian " -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/build-llvm/tools/clang/lib/Serialization -I /build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization -I /build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/include -I /build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/build-llvm/tools/clang/include -I /build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/build-llvm/include -I /build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/llvm/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-10/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -std=c++14 -fdeprecated-macro -fdebug-compilation-dir /build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/build-llvm/tools/clang/lib/Serialization -fdebug-prefix-map=/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809=. -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fno-common -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -o /tmp/scan-build-2019-12-09-002921-48462-1 -x c++ /build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp

/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp

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/Serialization/ASTReader.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/Expr.h"
25#include "clang/AST/ExprCXX.h"
26#include "clang/AST/ExprObjC.h"
27#include "clang/AST/ExprOpenMP.h"
28#include "clang/AST/NestedNameSpecifier.h"
29#include "clang/AST/OpenMPClause.h"
30#include "clang/AST/OperationKinds.h"
31#include "clang/AST/Stmt.h"
32#include "clang/AST/StmtCXX.h"
33#include "clang/AST/StmtObjC.h"
34#include "clang/AST/StmtOpenMP.h"
35#include "clang/AST/StmtVisitor.h"
36#include "clang/AST/TemplateBase.h"
37#include "clang/AST/Type.h"
38#include "clang/AST/UnresolvedSet.h"
39#include "clang/Basic/CapturedStmt.h"
40#include "clang/Basic/ExpressionTraits.h"
41#include "clang/Basic/LLVM.h"
42#include "clang/Basic/Lambda.h"
43#include "clang/Basic/LangOptions.h"
44#include "clang/Basic/OpenMPKinds.h"
45#include "clang/Basic/OperatorKinds.h"
46#include "clang/Basic/SourceLocation.h"
47#include "clang/Basic/Specifiers.h"
48#include "clang/Basic/TypeTraits.h"
49#include "clang/Lex/Token.h"
50#include "clang/Serialization/ASTBitCodes.h"
51#include "llvm/ADT/DenseMap.h"
52#include "llvm/ADT/SmallString.h"
53#include "llvm/ADT/SmallVector.h"
54#include "llvm/ADT/StringRef.h"
55#include "llvm/Bitstream/BitstreamReader.h"
56#include "llvm/Support/Casting.h"
57#include "llvm/Support/ErrorHandling.h"
58#include <algorithm>
59#include <cassert>
60#include <cstdint>
61#include <string>
62
63using namespace clang;
64using namespace serialization;
65
66namespace clang {
67
68 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
69 friend class OMPClauseReader;
70
71 ASTRecordReader &Record;
72 llvm::BitstreamCursor &DeclsCursor;
73
74 SourceLocation ReadSourceLocation() {
75 return Record.readSourceLocation();
76 }
77
78 SourceRange ReadSourceRange() {
79 return Record.readSourceRange();
80 }
81
82 std::string ReadString() {
83 return Record.readString();
84 }
85
86 TypeSourceInfo *GetTypeSourceInfo() {
87 return Record.getTypeSourceInfo();
88 }
89
90 Decl *ReadDecl() {
91 return Record.readDecl();
92 }
93
94 template<typename T>
95 T *ReadDeclAs() {
96 return Record.readDeclAs<T>();
97 }
98
99 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc,
100 DeclarationName Name) {
101 Record.readDeclarationNameLoc(DNLoc, Name);
102 }
103
104 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo) {
105 Record.readDeclarationNameInfo(NameInfo);
106 }
107
108 public:
109 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
110 : Record(Record), DeclsCursor(Cursor) {}
111
112 /// The number of record fields required for the Stmt class
113 /// itself.
114 static const unsigned NumStmtFields = 1;
115
116 /// The number of record fields required for the Expr class
117 /// itself.
118 static const unsigned NumExprFields = NumStmtFields + 7;
119
120 /// Read and initialize a ExplicitTemplateArgumentList structure.
121 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
122 TemplateArgumentLoc *ArgsLocArray,
123 unsigned NumTemplateArgs);
124
125 /// Read and initialize a ExplicitTemplateArgumentList structure.
126 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
127 unsigned NumTemplateArgs);
128
129 void VisitStmt(Stmt *S);
130#define STMT(Type, Base) \
131 void Visit##Type(Type *);
132#include "clang/AST/StmtNodes.inc"
133 };
134
135} // namespace clang
136
137void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
138 TemplateArgumentLoc *ArgsLocArray,
139 unsigned NumTemplateArgs) {
140 SourceLocation TemplateKWLoc = ReadSourceLocation();
141 TemplateArgumentListInfo ArgInfo;
142 ArgInfo.setLAngleLoc(ReadSourceLocation());
143 ArgInfo.setRAngleLoc(ReadSourceLocation());
144 for (unsigned i = 0; i != NumTemplateArgs; ++i)
145 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
146 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
147}
148
149void ASTStmtReader::VisitStmt(Stmt *S) {
150 S->setIsOMPStructuredBlock(Record.readInt());
151 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count")((Record.getIdx() == NumStmtFields && "Incorrect statement field count"
) ? static_cast<void> (0) : __assert_fail ("Record.getIdx() == NumStmtFields && \"Incorrect statement field count\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 151, __PRETTY_FUNCTION__))
;
152}
153
154void ASTStmtReader::VisitNullStmt(NullStmt *S) {
155 VisitStmt(S);
156 S->setSemiLoc(ReadSourceLocation());
157 S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
158}
159
160void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
161 VisitStmt(S);
162 SmallVector<Stmt *, 16> Stmts;
163 unsigned NumStmts = Record.readInt();
164 while (NumStmts--)
165 Stmts.push_back(Record.readSubStmt());
166 S->setStmts(Stmts);
167 S->CompoundStmtBits.LBraceLoc = ReadSourceLocation();
168 S->RBraceLoc = ReadSourceLocation();
169}
170
171void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
172 VisitStmt(S);
173 Record.recordSwitchCaseID(S, Record.readInt());
174 S->setKeywordLoc(ReadSourceLocation());
175 S->setColonLoc(ReadSourceLocation());
176}
177
178void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
179 VisitSwitchCase(S);
180 bool CaseStmtIsGNURange = Record.readInt();
181 S->setLHS(Record.readSubExpr());
182 S->setSubStmt(Record.readSubStmt());
183 if (CaseStmtIsGNURange) {
184 S->setRHS(Record.readSubExpr());
185 S->setEllipsisLoc(ReadSourceLocation());
186 }
187}
188
189void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
190 VisitSwitchCase(S);
191 S->setSubStmt(Record.readSubStmt());
192}
193
194void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
195 VisitStmt(S);
196 auto *LD = ReadDeclAs<LabelDecl>();
197 LD->setStmt(S);
198 S->setDecl(LD);
199 S->setSubStmt(Record.readSubStmt());
200 S->setIdentLoc(ReadSourceLocation());
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)((NumAttrs == S->AttributedStmtBits.NumAttrs) ? static_cast
<void> (0) : __assert_fail ("NumAttrs == S->AttributedStmtBits.NumAttrs"
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 212, __PRETTY_FUNCTION__))
;
213 assert(NumAttrs == Attrs.size())((NumAttrs == Attrs.size()) ? static_cast<void> (0) : __assert_fail
("NumAttrs == Attrs.size()", "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 213, __PRETTY_FUNCTION__))
;
214 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
215 S->SubStmt = Record.readSubStmt();
216 S->AttributedStmtBits.AttrLoc = ReadSourceLocation();
217}
218
219void ASTStmtReader::VisitIfStmt(IfStmt *S) {
220 VisitStmt(S);
221
222 S->setConstexpr(Record.readInt());
223 bool HasElse = Record.readInt();
224 bool HasVar = Record.readInt();
225 bool HasInit = Record.readInt();
226
227 S->setCond(Record.readSubExpr());
228 S->setThen(Record.readSubStmt());
229 if (HasElse)
230 S->setElse(Record.readSubStmt());
231 if (HasVar)
232 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
233 if (HasInit)
234 S->setInit(Record.readSubStmt());
235
236 S->setIfLoc(ReadSourceLocation());
237 if (HasElse)
238 S->setElseLoc(ReadSourceLocation());
239}
240
241void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
242 VisitStmt(S);
243
244 bool HasInit = Record.readInt();
245 bool HasVar = Record.readInt();
246 bool AllEnumCasesCovered = Record.readInt();
247 if (AllEnumCasesCovered)
248 S->setAllEnumCasesCovered();
249
250 S->setCond(Record.readSubExpr());
251 S->setBody(Record.readSubStmt());
252 if (HasInit)
253 S->setInit(Record.readSubStmt());
254 if (HasVar)
255 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
256
257 S->setSwitchLoc(ReadSourceLocation());
258
259 SwitchCase *PrevSC = nullptr;
260 for (auto E = Record.size(); Record.getIdx() != E; ) {
261 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
262 if (PrevSC)
263 PrevSC->setNextSwitchCase(SC);
264 else
265 S->setSwitchCaseList(SC);
266
267 PrevSC = SC;
268 }
269}
270
271void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
272 VisitStmt(S);
273
274 bool HasVar = Record.readInt();
275
276 S->setCond(Record.readSubExpr());
277 S->setBody(Record.readSubStmt());
278 if (HasVar)
279 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
280
281 S->setWhileLoc(ReadSourceLocation());
282}
283
284void ASTStmtReader::VisitDoStmt(DoStmt *S) {
285 VisitStmt(S);
286 S->setCond(Record.readSubExpr());
287 S->setBody(Record.readSubStmt());
288 S->setDoLoc(ReadSourceLocation());
289 S->setWhileLoc(ReadSourceLocation());
290 S->setRParenLoc(ReadSourceLocation());
291}
292
293void ASTStmtReader::VisitForStmt(ForStmt *S) {
294 VisitStmt(S);
295 S->setInit(Record.readSubStmt());
296 S->setCond(Record.readSubExpr());
297 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
298 S->setInc(Record.readSubExpr());
299 S->setBody(Record.readSubStmt());
300 S->setForLoc(ReadSourceLocation());
301 S->setLParenLoc(ReadSourceLocation());
302 S->setRParenLoc(ReadSourceLocation());
303}
304
305void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
306 VisitStmt(S);
307 S->setLabel(ReadDeclAs<LabelDecl>());
308 S->setGotoLoc(ReadSourceLocation());
309 S->setLabelLoc(ReadSourceLocation());
310}
311
312void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
313 VisitStmt(S);
314 S->setGotoLoc(ReadSourceLocation());
315 S->setStarLoc(ReadSourceLocation());
316 S->setTarget(Record.readSubExpr());
317}
318
319void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
320 VisitStmt(S);
321 S->setContinueLoc(ReadSourceLocation());
322}
323
324void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
325 VisitStmt(S);
326 S->setBreakLoc(ReadSourceLocation());
327}
328
329void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
330 VisitStmt(S);
331
332 bool HasNRVOCandidate = Record.readInt();
333
334 S->setRetValue(Record.readSubExpr());
335 if (HasNRVOCandidate)
336 S->setNRVOCandidate(ReadDeclAs<VarDecl>());
337
338 S->setReturnLoc(ReadSourceLocation());
339}
340
341void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
342 VisitStmt(S);
343 S->setStartLoc(ReadSourceLocation());
344 S->setEndLoc(ReadSourceLocation());
345
346 if (Record.size() - Record.getIdx() == 1) {
347 // Single declaration
348 S->setDeclGroup(DeclGroupRef(ReadDecl()));
349 } else {
350 SmallVector<Decl *, 16> Decls;
351 int N = Record.size() - Record.getIdx();
352 Decls.reserve(N);
353 for (int I = 0; I < N; ++I)
354 Decls.push_back(ReadDecl());
355 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
356 Decls.data(),
357 Decls.size())));
358 }
359}
360
361void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
362 VisitStmt(S);
363 S->NumOutputs = Record.readInt();
364 S->NumInputs = Record.readInt();
365 S->NumClobbers = Record.readInt();
366 S->setAsmLoc(ReadSourceLocation());
367 S->setVolatile(Record.readInt());
368 S->setSimple(Record.readInt());
369}
370
371void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
372 VisitAsmStmt(S);
373 S->NumLabels = Record.readInt();
374 S->setRParenLoc(ReadSourceLocation());
375 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
376
377 unsigned NumOutputs = S->getNumOutputs();
378 unsigned NumInputs = S->getNumInputs();
379 unsigned NumClobbers = S->getNumClobbers();
380 unsigned NumLabels = S->getNumLabels();
381
382 // Outputs and inputs
383 SmallVector<IdentifierInfo *, 16> Names;
384 SmallVector<StringLiteral*, 16> Constraints;
385 SmallVector<Stmt*, 16> Exprs;
386 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
387 Names.push_back(Record.getIdentifierInfo());
388 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
389 Exprs.push_back(Record.readSubStmt());
390 }
391
392 // Constraints
393 SmallVector<StringLiteral*, 16> Clobbers;
394 for (unsigned I = 0; I != NumClobbers; ++I)
395 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
396
397 // Labels
398 for (unsigned I = 0, N = NumLabels; I != N; ++I)
399 Exprs.push_back(Record.readSubStmt());
400
401 S->setOutputsAndInputsAndClobbers(Record.getContext(),
402 Names.data(), Constraints.data(),
403 Exprs.data(), NumOutputs, NumInputs,
404 NumLabels,
405 Clobbers.data(), NumClobbers);
406}
407
408void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
409 VisitAsmStmt(S);
410 S->LBraceLoc = ReadSourceLocation();
411 S->EndLoc = ReadSourceLocation();
412 S->NumAsmToks = Record.readInt();
413 std::string AsmStr = ReadString();
414
415 // Read the tokens.
416 SmallVector<Token, 16> AsmToks;
417 AsmToks.reserve(S->NumAsmToks);
418 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
419 AsmToks.push_back(Record.readToken());
420 }
421
422 // The calls to reserve() for the FooData vectors are mandatory to
423 // prevent dead StringRefs in the Foo vectors.
424
425 // Read the clobbers.
426 SmallVector<std::string, 16> ClobbersData;
427 SmallVector<StringRef, 16> Clobbers;
428 ClobbersData.reserve(S->NumClobbers);
429 Clobbers.reserve(S->NumClobbers);
430 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
431 ClobbersData.push_back(ReadString());
432 Clobbers.push_back(ClobbersData.back());
433 }
434
435 // Read the operands.
436 unsigned NumOperands = S->NumOutputs + S->NumInputs;
437 SmallVector<Expr*, 16> Exprs;
438 SmallVector<std::string, 16> ConstraintsData;
439 SmallVector<StringRef, 16> Constraints;
440 Exprs.reserve(NumOperands);
441 ConstraintsData.reserve(NumOperands);
442 Constraints.reserve(NumOperands);
443 for (unsigned i = 0; i != NumOperands; ++i) {
444 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
445 ConstraintsData.push_back(ReadString());
446 Constraints.push_back(ConstraintsData.back());
447 }
448
449 S->initialize(Record.getContext(), AsmStr, AsmToks,
450 Constraints, Exprs, Clobbers);
451}
452
453void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
454 VisitStmt(S);
455 assert(Record.peekInt() == S->NumParams)((Record.peekInt() == S->NumParams) ? static_cast<void>
(0) : __assert_fail ("Record.peekInt() == S->NumParams", "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 455, __PRETTY_FUNCTION__))
;
456 Record.skipInts(1);
457 auto *StoredStmts = S->getStoredStmts();
458 for (unsigned i = 0;
459 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
460 StoredStmts[i] = Record.readSubStmt();
461}
462
463void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
464 VisitStmt(S);
465 S->CoreturnLoc = Record.readSourceLocation();
466 for (auto &SubStmt: S->SubStmts)
467 SubStmt = Record.readSubStmt();
468 S->IsImplicit = Record.readInt() != 0;
469}
470
471void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
472 VisitExpr(E);
473 E->KeywordLoc = ReadSourceLocation();
474 for (auto &SubExpr: E->SubExprs)
475 SubExpr = Record.readSubStmt();
476 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
477 E->setIsImplicit(Record.readInt() != 0);
478}
479
480void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
481 VisitExpr(E);
482 E->KeywordLoc = ReadSourceLocation();
483 for (auto &SubExpr: E->SubExprs)
484 SubExpr = Record.readSubStmt();
485 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
486}
487
488void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
489 VisitExpr(E);
490 E->KeywordLoc = ReadSourceLocation();
491 for (auto &SubExpr: E->SubExprs)
492 SubExpr = Record.readSubStmt();
493}
494
495void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
496 VisitStmt(S);
497 Record.skipInts(1);
498 S->setCapturedDecl(ReadDeclAs<CapturedDecl>());
499 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
500 S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>());
501
502 // Capture inits
503 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
504 E = S->capture_init_end();
505 I != E; ++I)
506 *I = Record.readSubExpr();
507
508 // Body
509 S->setCapturedStmt(Record.readSubStmt());
510 S->getCapturedDecl()->setBody(S->getCapturedStmt());
511
512 // Captures
513 for (auto &I : S->captures()) {
514 I.VarAndKind.setPointer(ReadDeclAs<VarDecl>());
515 I.VarAndKind.setInt(
516 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
517 I.Loc = ReadSourceLocation();
518 }
519}
520
521void ASTStmtReader::VisitExpr(Expr *E) {
522 VisitStmt(E);
523 E->setType(Record.readType());
524 E->setTypeDependent(Record.readInt());
525 E->setValueDependent(Record.readInt());
526 E->setInstantiationDependent(Record.readInt());
527 E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
528 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
529 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
530 assert(Record.getIdx() == NumExprFields &&((Record.getIdx() == NumExprFields && "Incorrect expression field count"
) ? static_cast<void> (0) : __assert_fail ("Record.getIdx() == NumExprFields && \"Incorrect expression field count\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 531, __PRETTY_FUNCTION__))
531 "Incorrect expression field count")((Record.getIdx() == NumExprFields && "Incorrect expression field count"
) ? static_cast<void> (0) : __assert_fail ("Record.getIdx() == NumExprFields && \"Incorrect expression field count\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 531, __PRETTY_FUNCTION__))
;
532}
533
534void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
535 VisitExpr(E);
536 E->ConstantExprBits.ResultKind = Record.readInt();
537 switch (E->ConstantExprBits.ResultKind) {
538 case ConstantExpr::RSK_Int64: {
539 E->Int64Result() = Record.readInt();
540 uint64_t tmp = Record.readInt();
541 E->ConstantExprBits.IsUnsigned = tmp & 0x1;
542 E->ConstantExprBits.BitWidth = tmp >> 1;
543 break;
544 }
545 case ConstantExpr::RSK_APValue:
546 E->APValueResult() = Record.readAPValue();
547 }
548 E->setSubExpr(Record.readSubExpr());
549}
550
551void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
552 VisitExpr(E);
553 bool HasFunctionName = Record.readInt();
554 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
555 E->PredefinedExprBits.Kind = Record.readInt();
556 E->setLocation(ReadSourceLocation());
557 if (HasFunctionName)
558 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
559}
560
561void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
562 VisitExpr(E);
563
564 E->DeclRefExprBits.HasQualifier = Record.readInt();
565 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
566 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
567 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
568 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
569 E->DeclRefExprBits.NonOdrUseReason = Record.readInt();
570 unsigned NumTemplateArgs = 0;
571 if (E->hasTemplateKWAndArgsInfo())
572 NumTemplateArgs = Record.readInt();
573
574 if (E->hasQualifier())
575 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
576 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
577
578 if (E->hasFoundDecl())
579 *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
580
581 if (E->hasTemplateKWAndArgsInfo())
582 ReadTemplateKWAndArgsInfo(
583 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
584 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
585
586 E->setDecl(ReadDeclAs<ValueDecl>());
587 E->setLocation(ReadSourceLocation());
588 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName());
589}
590
591void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
592 VisitExpr(E);
593 E->setLocation(ReadSourceLocation());
594 E->setValue(Record.getContext(), Record.readAPInt());
595}
596
597void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
598 VisitExpr(E);
599 E->setLocation(ReadSourceLocation());
600 E->setValue(Record.getContext(), Record.readAPInt());
601}
602
603void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
604 VisitExpr(E);
605 E->setRawSemantics(
606 static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
607 E->setExact(Record.readInt());
608 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
609 E->setLocation(ReadSourceLocation());
610}
611
612void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
613 VisitExpr(E);
614 E->setSubExpr(Record.readSubExpr());
615}
616
617void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
618 VisitExpr(E);
619
620 // NumConcatenated, Length and CharByteWidth are set by the empty
621 // ctor since they are needed to allocate storage for the trailing objects.
622 unsigned NumConcatenated = Record.readInt();
623 unsigned Length = Record.readInt();
624 unsigned CharByteWidth = Record.readInt();
625 assert((NumConcatenated == E->getNumConcatenated()) &&(((NumConcatenated == E->getNumConcatenated()) && "Wrong number of concatenated tokens!"
) ? static_cast<void> (0) : __assert_fail ("(NumConcatenated == E->getNumConcatenated()) && \"Wrong number of concatenated tokens!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 626, __PRETTY_FUNCTION__))
626 "Wrong number of concatenated tokens!")(((NumConcatenated == E->getNumConcatenated()) && "Wrong number of concatenated tokens!"
) ? static_cast<void> (0) : __assert_fail ("(NumConcatenated == E->getNumConcatenated()) && \"Wrong number of concatenated tokens!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 626, __PRETTY_FUNCTION__))
;
627 assert((Length == E->getLength()) && "Wrong Length!")(((Length == E->getLength()) && "Wrong Length!") ?
static_cast<void> (0) : __assert_fail ("(Length == E->getLength()) && \"Wrong Length!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 627, __PRETTY_FUNCTION__))
;
628 assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!")(((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!"
) ? static_cast<void> (0) : __assert_fail ("(CharByteWidth == E->getCharByteWidth()) && \"Wrong character width!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 628, __PRETTY_FUNCTION__))
;
629 E->StringLiteralBits.Kind = Record.readInt();
630 E->StringLiteralBits.IsPascal = Record.readInt();
631
632 // The character width is originally computed via mapCharByteWidth.
633 // Check that the deserialized character width is consistant with the result
634 // of calling mapCharByteWidth.
635 assert((CharByteWidth ==(((CharByteWidth == StringLiteral::mapCharByteWidth(Record.getContext
().getTargetInfo(), E->getKind())) && "Wrong character width!"
) ? static_cast<void> (0) : __assert_fail ("(CharByteWidth == StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(), E->getKind())) && \"Wrong character width!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 638, __PRETTY_FUNCTION__))
636 StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),(((CharByteWidth == StringLiteral::mapCharByteWidth(Record.getContext
().getTargetInfo(), E->getKind())) && "Wrong character width!"
) ? static_cast<void> (0) : __assert_fail ("(CharByteWidth == StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(), E->getKind())) && \"Wrong character width!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 638, __PRETTY_FUNCTION__))
637 E->getKind())) &&(((CharByteWidth == StringLiteral::mapCharByteWidth(Record.getContext
().getTargetInfo(), E->getKind())) && "Wrong character width!"
) ? static_cast<void> (0) : __assert_fail ("(CharByteWidth == StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(), E->getKind())) && \"Wrong character width!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 638, __PRETTY_FUNCTION__))
638 "Wrong character width!")(((CharByteWidth == StringLiteral::mapCharByteWidth(Record.getContext
().getTargetInfo(), E->getKind())) && "Wrong character width!"
) ? static_cast<void> (0) : __assert_fail ("(CharByteWidth == StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(), E->getKind())) && \"Wrong character width!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 638, __PRETTY_FUNCTION__))
;
639
640 // Deserialize the trailing array of SourceLocation.
641 for (unsigned I = 0; I < NumConcatenated; ++I)
642 E->setStrTokenLoc(I, ReadSourceLocation());
643
644 // Deserialize the trailing array of char holding the string data.
645 char *StrData = E->getStrDataAsChar();
646 for (unsigned I = 0; I < Length * CharByteWidth; ++I)
647 StrData[I] = Record.readInt();
648}
649
650void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
651 VisitExpr(E);
652 E->setValue(Record.readInt());
653 E->setLocation(ReadSourceLocation());
654 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
655}
656
657void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
658 VisitExpr(E);
659 E->setLParen(ReadSourceLocation());
660 E->setRParen(ReadSourceLocation());
661 E->setSubExpr(Record.readSubExpr());
662}
663
664void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
665 VisitExpr(E);
666 unsigned NumExprs = Record.readInt();
667 assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!")(((NumExprs == E->getNumExprs()) && "Wrong NumExprs!"
) ? static_cast<void> (0) : __assert_fail ("(NumExprs == E->getNumExprs()) && \"Wrong NumExprs!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 667, __PRETTY_FUNCTION__))
;
668 for (unsigned I = 0; I != NumExprs; ++I)
669 E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
670 E->LParenLoc = ReadSourceLocation();
671 E->RParenLoc = ReadSourceLocation();
672}
673
674void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
675 VisitExpr(E);
676 E->setSubExpr(Record.readSubExpr());
677 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
678 E->setOperatorLoc(ReadSourceLocation());
679 E->setCanOverflow(Record.readInt());
680}
681
682void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
683 VisitExpr(E);
684 assert(E->getNumComponents() == Record.peekInt())((E->getNumComponents() == Record.peekInt()) ? static_cast
<void> (0) : __assert_fail ("E->getNumComponents() == Record.peekInt()"
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 684, __PRETTY_FUNCTION__))
;
685 Record.skipInts(1);
686 assert(E->getNumExpressions() == Record.peekInt())((E->getNumExpressions() == Record.peekInt()) ? static_cast
<void> (0) : __assert_fail ("E->getNumExpressions() == Record.peekInt()"
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 686, __PRETTY_FUNCTION__))
;
687 Record.skipInts(1);
688 E->setOperatorLoc(ReadSourceLocation());
689 E->setRParenLoc(ReadSourceLocation());
690 E->setTypeSourceInfo(GetTypeSourceInfo());
691 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
692 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
693 SourceLocation Start = ReadSourceLocation();
694 SourceLocation End = ReadSourceLocation();
695 switch (Kind) {
696 case OffsetOfNode::Array:
697 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
698 break;
699
700 case OffsetOfNode::Field:
701 E->setComponent(
702 I, OffsetOfNode(Start, ReadDeclAs<FieldDecl>(), End));
703 break;
704
705 case OffsetOfNode::Identifier:
706 E->setComponent(
707 I,
708 OffsetOfNode(Start, Record.getIdentifierInfo(), End));
709 break;
710
711 case OffsetOfNode::Base: {
712 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
713 *Base = Record.readCXXBaseSpecifier();
714 E->setComponent(I, OffsetOfNode(Base));
715 break;
716 }
717 }
718 }
719
720 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
721 E->setIndexExpr(I, Record.readSubExpr());
722}
723
724void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
725 VisitExpr(E);
726 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
727 if (Record.peekInt() == 0) {
728 E->setArgument(Record.readSubExpr());
729 Record.skipInts(1);
730 } else {
731 E->setArgument(GetTypeSourceInfo());
732 }
733 E->setOperatorLoc(ReadSourceLocation());
734 E->setRParenLoc(ReadSourceLocation());
735}
736
737void ASTStmtReader::VisitConceptSpecializationExpr(
738 ConceptSpecializationExpr *E) {
739 VisitExpr(E);
740 unsigned NumTemplateArgs = Record.readInt();
741 E->NestedNameSpec = Record.readNestedNameSpecifierLoc();
742 E->TemplateKWLoc = Record.readSourceLocation();
743 E->ConceptNameLoc = Record.readSourceLocation();
744 E->FoundDecl = ReadDeclAs<NamedDecl>();
745 E->NamedConcept.setPointer(ReadDeclAs<ConceptDecl>());
746 const ASTTemplateArgumentListInfo *ArgsAsWritten =
747 Record.readASTTemplateArgumentListInfo();
748 llvm::SmallVector<TemplateArgument, 4> Args;
749 for (unsigned I = 0; I < NumTemplateArgs; ++I)
750 Args.push_back(Record.readTemplateArgument());
751 E->setTemplateArguments(ArgsAsWritten, Args);
752 E->NamedConcept.setInt(Record.readInt() == 1);
753}
754
755void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
756 VisitExpr(E);
757 E->setLHS(Record.readSubExpr());
758 E->setRHS(Record.readSubExpr());
759 E->setRBracketLoc(ReadSourceLocation());
760}
761
762void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
763 VisitExpr(E);
764 E->setBase(Record.readSubExpr());
765 E->setLowerBound(Record.readSubExpr());
766 E->setLength(Record.readSubExpr());
767 E->setColonLoc(ReadSourceLocation());
768 E->setRBracketLoc(ReadSourceLocation());
769}
770
771void ASTStmtReader::VisitCallExpr(CallExpr *E) {
772 VisitExpr(E);
773 unsigned NumArgs = Record.readInt();
774 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!")(((NumArgs == E->getNumArgs()) && "Wrong NumArgs!"
) ? static_cast<void> (0) : __assert_fail ("(NumArgs == E->getNumArgs()) && \"Wrong NumArgs!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 774, __PRETTY_FUNCTION__))
;
775 E->setRParenLoc(ReadSourceLocation());
776 E->setCallee(Record.readSubExpr());
777 for (unsigned I = 0; I != NumArgs; ++I)
778 E->setArg(I, Record.readSubExpr());
779 E->setADLCallKind(static_cast<CallExpr::ADLCallKind>(Record.readInt()));
780}
781
782void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
783 VisitCallExpr(E);
784}
785
786void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
787 VisitExpr(E);
788
789 bool HasQualifier = Record.readInt();
790 bool HasFoundDecl = Record.readInt();
791 bool HasTemplateInfo = Record.readInt();
792 unsigned NumTemplateArgs = Record.readInt();
793
794 E->Base = Record.readSubExpr();
795 E->MemberDecl = Record.readDeclAs<ValueDecl>();
796 Record.readDeclarationNameLoc(E->MemberDNLoc, E->MemberDecl->getDeclName());
797 E->MemberLoc = Record.readSourceLocation();
798 E->MemberExprBits.IsArrow = Record.readInt();
799 E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
800 E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
801 E->MemberExprBits.HadMultipleCandidates = Record.readInt();
802 E->MemberExprBits.NonOdrUseReason = Record.readInt();
803 E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
804
805 if (HasQualifier || HasFoundDecl) {
806 DeclAccessPair FoundDecl;
807 if (HasFoundDecl) {
808 auto *FoundD = Record.readDeclAs<NamedDecl>();
809 auto AS = (AccessSpecifier)Record.readInt();
810 FoundDecl = DeclAccessPair::make(FoundD, AS);
811 } else {
812 FoundDecl = DeclAccessPair::make(E->MemberDecl,
813 E->MemberDecl->getAccess());
814 }
815 E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
816
817 NestedNameSpecifierLoc QualifierLoc;
818 if (HasQualifier)
819 QualifierLoc = Record.readNestedNameSpecifierLoc();
820 E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
821 QualifierLoc;
822 }
823
824 if (HasTemplateInfo)
825 ReadTemplateKWAndArgsInfo(
826 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
827 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
828}
829
830void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
831 VisitExpr(E);
832 E->setBase(Record.readSubExpr());
833 E->setIsaMemberLoc(ReadSourceLocation());
834 E->setOpLoc(ReadSourceLocation());
835 E->setArrow(Record.readInt());
836}
837
838void ASTStmtReader::
839VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
840 VisitExpr(E);
841 E->Operand = Record.readSubExpr();
842 E->setShouldCopy(Record.readInt());
843}
844
845void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
846 VisitExplicitCastExpr(E);
847 E->LParenLoc = ReadSourceLocation();
848 E->BridgeKeywordLoc = ReadSourceLocation();
849 E->Kind = Record.readInt();
850}
851
852void ASTStmtReader::VisitCastExpr(CastExpr *E) {
853 VisitExpr(E);
854 unsigned NumBaseSpecs = Record.readInt();
855 assert(NumBaseSpecs == E->path_size())((NumBaseSpecs == E->path_size()) ? static_cast<void>
(0) : __assert_fail ("NumBaseSpecs == E->path_size()", "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 855, __PRETTY_FUNCTION__))
;
856 E->setSubExpr(Record.readSubExpr());
857 E->setCastKind((CastKind)Record.readInt());
858 CastExpr::path_iterator BaseI = E->path_begin();
859 while (NumBaseSpecs--) {
860 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
861 *BaseSpec = Record.readCXXBaseSpecifier();
862 *BaseI++ = BaseSpec;
863 }
864}
865
866void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
867 VisitExpr(E);
868 E->setLHS(Record.readSubExpr());
869 E->setRHS(Record.readSubExpr());
870 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
871 E->setOperatorLoc(ReadSourceLocation());
872 E->setFPFeatures(FPOptions(Record.readInt()));
873}
874
875void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
876 VisitBinaryOperator(E);
877 E->setComputationLHSType(Record.readType());
878 E->setComputationResultType(Record.readType());
879}
880
881void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
882 VisitExpr(E);
883 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
884 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
885 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
886 E->QuestionLoc = ReadSourceLocation();
887 E->ColonLoc = ReadSourceLocation();
888}
889
890void
891ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
892 VisitExpr(E);
893 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
894 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
895 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
896 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
897 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
898 E->QuestionLoc = ReadSourceLocation();
899 E->ColonLoc = ReadSourceLocation();
900}
901
902void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
903 VisitCastExpr(E);
904 E->setIsPartOfExplicitCast(Record.readInt());
905}
906
907void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
908 VisitCastExpr(E);
909 E->setTypeInfoAsWritten(GetTypeSourceInfo());
910}
911
912void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
913 VisitExplicitCastExpr(E);
914 E->setLParenLoc(ReadSourceLocation());
915 E->setRParenLoc(ReadSourceLocation());
916}
917
918void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
919 VisitExpr(E);
920 E->setLParenLoc(ReadSourceLocation());
921 E->setTypeSourceInfo(GetTypeSourceInfo());
922 E->setInitializer(Record.readSubExpr());
923 E->setFileScope(Record.readInt());
924}
925
926void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
927 VisitExpr(E);
928 E->setBase(Record.readSubExpr());
929 E->setAccessor(Record.getIdentifierInfo());
930 E->setAccessorLoc(ReadSourceLocation());
931}
932
933void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
934 VisitExpr(E);
935 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
936 E->setSyntacticForm(SyntForm);
937 E->setLBraceLoc(ReadSourceLocation());
938 E->setRBraceLoc(ReadSourceLocation());
939 bool isArrayFiller = Record.readInt();
940 Expr *filler = nullptr;
941 if (isArrayFiller) {
942 filler = Record.readSubExpr();
943 E->ArrayFillerOrUnionFieldInit = filler;
944 } else
945 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>();
946 E->sawArrayRangeDesignator(Record.readInt());
947 unsigned NumInits = Record.readInt();
948 E->reserveInits(Record.getContext(), NumInits);
949 if (isArrayFiller) {
950 for (unsigned I = 0; I != NumInits; ++I) {
951 Expr *init = Record.readSubExpr();
952 E->updateInit(Record.getContext(), I, init ? init : filler);
953 }
954 } else {
955 for (unsigned I = 0; I != NumInits; ++I)
956 E->updateInit(Record.getContext(), I, Record.readSubExpr());
957 }
958}
959
960void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
961 using Designator = DesignatedInitExpr::Designator;
962
963 VisitExpr(E);
964 unsigned NumSubExprs = Record.readInt();
965 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs")((NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs"
) ? static_cast<void> (0) : __assert_fail ("NumSubExprs == E->getNumSubExprs() && \"Wrong number of subexprs\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 965, __PRETTY_FUNCTION__))
;
966 for (unsigned I = 0; I != NumSubExprs; ++I)
967 E->setSubExpr(I, Record.readSubExpr());
968 E->setEqualOrColonLoc(ReadSourceLocation());
969 E->setGNUSyntax(Record.readInt());
970
971 SmallVector<Designator, 4> Designators;
972 while (Record.getIdx() < Record.size()) {
973 switch ((DesignatorTypes)Record.readInt()) {
974 case DESIG_FIELD_DECL: {
975 auto *Field = ReadDeclAs<FieldDecl>();
976 SourceLocation DotLoc = ReadSourceLocation();
977 SourceLocation FieldLoc = ReadSourceLocation();
978 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
979 FieldLoc));
980 Designators.back().setField(Field);
981 break;
982 }
983
984 case DESIG_FIELD_NAME: {
985 const IdentifierInfo *Name = Record.getIdentifierInfo();
986 SourceLocation DotLoc = ReadSourceLocation();
987 SourceLocation FieldLoc = ReadSourceLocation();
988 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
989 break;
990 }
991
992 case DESIG_ARRAY: {
993 unsigned Index = Record.readInt();
994 SourceLocation LBracketLoc = ReadSourceLocation();
995 SourceLocation RBracketLoc = ReadSourceLocation();
996 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
997 break;
998 }
999
1000 case DESIG_ARRAY_RANGE: {
1001 unsigned Index = Record.readInt();
1002 SourceLocation LBracketLoc = ReadSourceLocation();
1003 SourceLocation EllipsisLoc = ReadSourceLocation();
1004 SourceLocation RBracketLoc = ReadSourceLocation();
1005 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
1006 RBracketLoc));
1007 break;
1008 }
1009 }
1010 }
1011 E->setDesignators(Record.getContext(),
1012 Designators.data(), Designators.size());
1013}
1014
1015void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1016 VisitExpr(E);
1017 E->setBase(Record.readSubExpr());
1018 E->setUpdater(Record.readSubExpr());
1019}
1020
1021void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1022 VisitExpr(E);
1023}
1024
1025void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1026 VisitExpr(E);
1027 E->SubExprs[0] = Record.readSubExpr();
1028 E->SubExprs[1] = Record.readSubExpr();
1029}
1030
1031void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1032 VisitExpr(E);
1033}
1034
1035void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
1036 VisitExpr(E);
1037}
1038
1039void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
1040 VisitExpr(E);
1041 E->setSubExpr(Record.readSubExpr());
1042 E->setWrittenTypeInfo(GetTypeSourceInfo());
1043 E->setBuiltinLoc(ReadSourceLocation());
1044 E->setRParenLoc(ReadSourceLocation());
1045 E->setIsMicrosoftABI(Record.readInt());
1046}
1047
1048void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1049 VisitExpr(E);
1050 E->ParentContext = ReadDeclAs<DeclContext>();
1051 E->BuiltinLoc = ReadSourceLocation();
1052 E->RParenLoc = ReadSourceLocation();
1053 E->SourceLocExprBits.Kind =
1054 static_cast<SourceLocExpr::IdentKind>(Record.readInt());
1055}
1056
1057void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
1058 VisitExpr(E);
1059 E->setAmpAmpLoc(ReadSourceLocation());
1060 E->setLabelLoc(ReadSourceLocation());
1061 E->setLabel(ReadDeclAs<LabelDecl>());
1062}
1063
1064void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
1065 VisitExpr(E);
1066 E->setLParenLoc(ReadSourceLocation());
1067 E->setRParenLoc(ReadSourceLocation());
1068 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
1069}
1070
1071void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
1072 VisitExpr(E);
1073 E->setCond(Record.readSubExpr());
1074 E->setLHS(Record.readSubExpr());
1075 E->setRHS(Record.readSubExpr());
1076 E->setBuiltinLoc(ReadSourceLocation());
1077 E->setRParenLoc(ReadSourceLocation());
1078 E->setIsConditionTrue(Record.readInt());
1079}
1080
1081void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
1082 VisitExpr(E);
1083 E->setTokenLocation(ReadSourceLocation());
1084}
1085
1086void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
1087 VisitExpr(E);
1088 SmallVector<Expr *, 16> Exprs;
1089 unsigned NumExprs = Record.readInt();
1090 while (NumExprs--)
1091 Exprs.push_back(Record.readSubExpr());
1092 E->setExprs(Record.getContext(), Exprs);
1093 E->setBuiltinLoc(ReadSourceLocation());
1094 E->setRParenLoc(ReadSourceLocation());
1095}
1096
1097void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1098 VisitExpr(E);
1099 E->BuiltinLoc = ReadSourceLocation();
1100 E->RParenLoc = ReadSourceLocation();
1101 E->TInfo = GetTypeSourceInfo();
1102 E->SrcExpr = Record.readSubExpr();
1103}
1104
1105void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
1106 VisitExpr(E);
1107 E->setBlockDecl(ReadDeclAs<BlockDecl>());
1108}
1109
1110void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1111 VisitExpr(E);
1112
1113 unsigned NumAssocs = Record.readInt();
1114 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!")((NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!"
) ? static_cast<void> (0) : __assert_fail ("NumAssocs == E->getNumAssocs() && \"Wrong NumAssocs!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1114, __PRETTY_FUNCTION__))
;
1115 E->ResultIndex = Record.readInt();
1116 E->GenericSelectionExprBits.GenericLoc = ReadSourceLocation();
1117 E->DefaultLoc = ReadSourceLocation();
1118 E->RParenLoc = ReadSourceLocation();
1119
1120 Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1121 // Add 1 to account for the controlling expression which is the first
1122 // expression in the trailing array of Stmt *. This is not needed for
1123 // the trailing array of TypeSourceInfo *.
1124 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1125 Stmts[I] = Record.readSubExpr();
1126
1127 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1128 for (unsigned I = 0, N = NumAssocs; I < N; ++I)
1129 TSIs[I] = GetTypeSourceInfo();
1130}
1131
1132void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1133 VisitExpr(E);
1134 unsigned numSemanticExprs = Record.readInt();
1135 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs)((numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs
) ? static_cast<void> (0) : __assert_fail ("numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs"
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1135, __PRETTY_FUNCTION__))
;
1136 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
1137
1138 // Read the syntactic expression.
1139 E->getSubExprsBuffer()[0] = Record.readSubExpr();
1140
1141 // Read all the semantic expressions.
1142 for (unsigned i = 0; i != numSemanticExprs; ++i) {
1143 Expr *subExpr = Record.readSubExpr();
1144 E->getSubExprsBuffer()[i+1] = subExpr;
1145 }
1146}
1147
1148void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1149 VisitExpr(E);
1150 E->Op = AtomicExpr::AtomicOp(Record.readInt());
1151 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1152 for (unsigned I = 0; I != E->NumSubExprs; ++I)
1153 E->SubExprs[I] = Record.readSubExpr();
1154 E->BuiltinLoc = ReadSourceLocation();
1155 E->RParenLoc = ReadSourceLocation();
1156}
1157
1158//===----------------------------------------------------------------------===//
1159// Objective-C Expressions and Statements
1160
1161void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
1162 VisitExpr(E);
1163 E->setString(cast<StringLiteral>(Record.readSubStmt()));
1164 E->setAtLoc(ReadSourceLocation());
1165}
1166
1167void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
1168 VisitExpr(E);
1169 // could be one of several IntegerLiteral, FloatLiteral, etc.
1170 E->SubExpr = Record.readSubStmt();
1171 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>();
1172 E->Range = ReadSourceRange();
1173}
1174
1175void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1176 VisitExpr(E);
1177 unsigned NumElements = Record.readInt();
1178 assert(NumElements == E->getNumElements() && "Wrong number of elements")((NumElements == E->getNumElements() && "Wrong number of elements"
) ? static_cast<void> (0) : __assert_fail ("NumElements == E->getNumElements() && \"Wrong number of elements\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1178, __PRETTY_FUNCTION__))
;
1179 Expr **Elements = E->getElements();
1180 for (unsigned I = 0, N = NumElements; I != N; ++I)
1181 Elements[I] = Record.readSubExpr();
1182 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1183 E->Range = ReadSourceRange();
1184}
1185
1186void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1187 VisitExpr(E);
1188 unsigned NumElements = Record.readInt();
1189 assert(NumElements == E->getNumElements() && "Wrong number of elements")((NumElements == E->getNumElements() && "Wrong number of elements"
) ? static_cast<void> (0) : __assert_fail ("NumElements == E->getNumElements() && \"Wrong number of elements\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1189, __PRETTY_FUNCTION__))
;
1190 bool HasPackExpansions = Record.readInt();
1191 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch")((HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch"
) ? static_cast<void> (0) : __assert_fail ("HasPackExpansions == E->HasPackExpansions &&\"Pack expansion mismatch\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1191, __PRETTY_FUNCTION__))
;
1192 auto *KeyValues =
1193 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
1194 auto *Expansions =
1195 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
1196 for (unsigned I = 0; I != NumElements; ++I) {
1197 KeyValues[I].Key = Record.readSubExpr();
1198 KeyValues[I].Value = Record.readSubExpr();
1199 if (HasPackExpansions) {
1200 Expansions[I].EllipsisLoc = ReadSourceLocation();
1201 Expansions[I].NumExpansionsPlusOne = Record.readInt();
1202 }
1203 }
1204 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1205 E->Range = ReadSourceRange();
1206}
1207
1208void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
1209 VisitExpr(E);
1210 E->setEncodedTypeSourceInfo(GetTypeSourceInfo());
1211 E->setAtLoc(ReadSourceLocation());
1212 E->setRParenLoc(ReadSourceLocation());
1213}
1214
1215void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
1216 VisitExpr(E);
1217 E->setSelector(Record.readSelector());
1218 E->setAtLoc(ReadSourceLocation());
1219 E->setRParenLoc(ReadSourceLocation());
1220}
1221
1222void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
1223 VisitExpr(E);
1224 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>());
1225 E->setAtLoc(ReadSourceLocation());
1226 E->ProtoLoc = ReadSourceLocation();
1227 E->setRParenLoc(ReadSourceLocation());
1228}
1229
1230void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
1231 VisitExpr(E);
1232 E->setDecl(ReadDeclAs<ObjCIvarDecl>());
1233 E->setLocation(ReadSourceLocation());
1234 E->setOpLoc(ReadSourceLocation());
1235 E->setBase(Record.readSubExpr());
1236 E->setIsArrow(Record.readInt());
1237 E->setIsFreeIvar(Record.readInt());
1238}
1239
1240void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
1241 VisitExpr(E);
1242 unsigned MethodRefFlags = Record.readInt();
1243 bool Implicit = Record.readInt() != 0;
1244 if (Implicit) {
1245 auto *Getter = ReadDeclAs<ObjCMethodDecl>();
1246 auto *Setter = ReadDeclAs<ObjCMethodDecl>();
1247 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
1248 } else {
1249 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
1250 }
1251 E->setLocation(ReadSourceLocation());
1252 E->setReceiverLocation(ReadSourceLocation());
1253 switch (Record.readInt()) {
1254 case 0:
1255 E->setBase(Record.readSubExpr());
1256 break;
1257 case 1:
1258 E->setSuperReceiver(Record.readType());
1259 break;
1260 case 2:
1261 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>());
1262 break;
1263 }
1264}
1265
1266void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1267 VisitExpr(E);
1268 E->setRBracket(ReadSourceLocation());
1269 E->setBaseExpr(Record.readSubExpr());
1270 E->setKeyExpr(Record.readSubExpr());
1271 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1272 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1273}
1274
1275void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1276 VisitExpr(E);
1277 assert(Record.peekInt() == E->getNumArgs())((Record.peekInt() == E->getNumArgs()) ? static_cast<void
> (0) : __assert_fail ("Record.peekInt() == E->getNumArgs()"
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1277, __PRETTY_FUNCTION__))
;
1278 Record.skipInts(1);
1279 unsigned NumStoredSelLocs = Record.readInt();
1280 E->SelLocsKind = Record.readInt();
1281 E->setDelegateInitCall(Record.readInt());
1282 E->IsImplicit = Record.readInt();
1283 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
1284 switch (Kind) {
1285 case ObjCMessageExpr::Instance:
1286 E->setInstanceReceiver(Record.readSubExpr());
1287 break;
1288
1289 case ObjCMessageExpr::Class:
1290 E->setClassReceiver(GetTypeSourceInfo());
1291 break;
1292
1293 case ObjCMessageExpr::SuperClass:
1294 case ObjCMessageExpr::SuperInstance: {
1295 QualType T = Record.readType();
1296 SourceLocation SuperLoc = ReadSourceLocation();
1297 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1298 break;
1299 }
1300 }
1301
1302 assert(Kind == E->getReceiverKind())((Kind == E->getReceiverKind()) ? static_cast<void> (
0) : __assert_fail ("Kind == E->getReceiverKind()", "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1302, __PRETTY_FUNCTION__))
;
1303
1304 if (Record.readInt())
1305 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>());
1306 else
1307 E->setSelector(Record.readSelector());
1308
1309 E->LBracLoc = ReadSourceLocation();
1310 E->RBracLoc = ReadSourceLocation();
1311
1312 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1313 E->setArg(I, Record.readSubExpr());
1314
1315 SourceLocation *Locs = E->getStoredSelLocs();
1316 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1317 Locs[I] = ReadSourceLocation();
1318}
1319
1320void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1321 VisitStmt(S);
1322 S->setElement(Record.readSubStmt());
1323 S->setCollection(Record.readSubExpr());
1324 S->setBody(Record.readSubStmt());
1325 S->setForLoc(ReadSourceLocation());
1326 S->setRParenLoc(ReadSourceLocation());
1327}
1328
1329void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1330 VisitStmt(S);
1331 S->setCatchBody(Record.readSubStmt());
1332 S->setCatchParamDecl(ReadDeclAs<VarDecl>());
1333 S->setAtCatchLoc(ReadSourceLocation());
1334 S->setRParenLoc(ReadSourceLocation());
1335}
1336
1337void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1338 VisitStmt(S);
1339 S->setFinallyBody(Record.readSubStmt());
1340 S->setAtFinallyLoc(ReadSourceLocation());
1341}
1342
1343void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1344 VisitStmt(S); // FIXME: no test coverage.
1345 S->setSubStmt(Record.readSubStmt());
1346 S->setAtLoc(ReadSourceLocation());
1347}
1348
1349void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1350 VisitStmt(S);
1351 assert(Record.peekInt() == S->getNumCatchStmts())((Record.peekInt() == S->getNumCatchStmts()) ? static_cast
<void> (0) : __assert_fail ("Record.peekInt() == S->getNumCatchStmts()"
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1351, __PRETTY_FUNCTION__))
;
1352 Record.skipInts(1);
1353 bool HasFinally = Record.readInt();
1354 S->setTryBody(Record.readSubStmt());
1355 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
1356 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
1357
1358 if (HasFinally)
1359 S->setFinallyStmt(Record.readSubStmt());
1360 S->setAtTryLoc(ReadSourceLocation());
1361}
1362
1363void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1364 VisitStmt(S); // FIXME: no test coverage.
1365 S->setSynchExpr(Record.readSubStmt());
1366 S->setSynchBody(Record.readSubStmt());
1367 S->setAtSynchronizedLoc(ReadSourceLocation());
1368}
1369
1370void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1371 VisitStmt(S); // FIXME: no test coverage.
1372 S->setThrowExpr(Record.readSubStmt());
1373 S->setThrowLoc(ReadSourceLocation());
1374}
1375
1376void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1377 VisitExpr(E);
1378 E->setValue(Record.readInt());
1379 E->setLocation(ReadSourceLocation());
1380}
1381
1382void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1383 VisitExpr(E);
1384 SourceRange R = Record.readSourceRange();
1385 E->AtLoc = R.getBegin();
1386 E->RParen = R.getEnd();
1387 E->VersionToCheck = Record.readVersionTuple();
1388}
1389
1390//===----------------------------------------------------------------------===//
1391// C++ Expressions and Statements
1392//===----------------------------------------------------------------------===//
1393
1394void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
1395 VisitStmt(S);
1396 S->CatchLoc = ReadSourceLocation();
1397 S->ExceptionDecl = ReadDeclAs<VarDecl>();
1398 S->HandlerBlock = Record.readSubStmt();
1399}
1400
1401void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
1402 VisitStmt(S);
1403 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?")((Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?"
) ? static_cast<void> (0) : __assert_fail ("Record.peekInt() == S->getNumHandlers() && \"NumStmtFields is wrong ?\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1403, __PRETTY_FUNCTION__))
;
1404 Record.skipInts(1);
1405 S->TryLoc = ReadSourceLocation();
1406 S->getStmts()[0] = Record.readSubStmt();
1407 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1408 S->getStmts()[i + 1] = Record.readSubStmt();
1409}
1410
1411void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1412 VisitStmt(S);
1413 S->ForLoc = ReadSourceLocation();
1414 S->CoawaitLoc = ReadSourceLocation();
1415 S->ColonLoc = ReadSourceLocation();
1416 S->RParenLoc = ReadSourceLocation();
1417 S->setInit(Record.readSubStmt());
1418 S->setRangeStmt(Record.readSubStmt());
1419 S->setBeginStmt(Record.readSubStmt());
1420 S->setEndStmt(Record.readSubStmt());
1421 S->setCond(Record.readSubExpr());
1422 S->setInc(Record.readSubExpr());
1423 S->setLoopVarStmt(Record.readSubStmt());
1424 S->setBody(Record.readSubStmt());
1425}
1426
1427void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1428 VisitStmt(S);
1429 S->KeywordLoc = ReadSourceLocation();
1430 S->IsIfExists = Record.readInt();
1431 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
1432 ReadDeclarationNameInfo(S->NameInfo);
1433 S->SubStmt = Record.readSubStmt();
1434}
1435
1436void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1437 VisitCallExpr(E);
1438 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1439 E->CXXOperatorCallExprBits.FPFeatures = Record.readInt();
1440 E->Range = Record.readSourceRange();
1441}
1442
1443void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1444 CXXRewrittenBinaryOperator *E) {
1445 VisitExpr(E);
1446 E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1447 E->SemanticForm = Record.readSubExpr();
1448}
1449
1450void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
1451 VisitExpr(E);
1452
1453 unsigned NumArgs = Record.readInt();
1454 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!")(((NumArgs == E->getNumArgs()) && "Wrong NumArgs!"
) ? static_cast<void> (0) : __assert_fail ("(NumArgs == E->getNumArgs()) && \"Wrong NumArgs!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1454, __PRETTY_FUNCTION__))
;
1455
1456 E->CXXConstructExprBits.Elidable = Record.readInt();
1457 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1458 E->CXXConstructExprBits.ListInitialization = Record.readInt();
1459 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1460 E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1461 E->CXXConstructExprBits.ConstructionKind = Record.readInt();
1462 E->CXXConstructExprBits.Loc = ReadSourceLocation();
1463 E->Constructor = ReadDeclAs<CXXConstructorDecl>();
1464 E->ParenOrBraceRange = ReadSourceRange();
1465
1466 for (unsigned I = 0; I != NumArgs; ++I)
1467 E->setArg(I, Record.readSubExpr());
1468}
1469
1470void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1471 VisitExpr(E);
1472 E->Constructor = ReadDeclAs<CXXConstructorDecl>();
1473 E->Loc = ReadSourceLocation();
1474 E->ConstructsVirtualBase = Record.readInt();
1475 E->InheritedFromVirtualBase = Record.readInt();
1476}
1477
1478void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1479 VisitCXXConstructExpr(E);
1480 E->TSI = GetTypeSourceInfo();
1481}
1482
1483void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1484 VisitExpr(E);
1485 unsigned NumCaptures = Record.readInt();
1486 assert(NumCaptures == E->NumCaptures)((NumCaptures == E->NumCaptures) ? static_cast<void>
(0) : __assert_fail ("NumCaptures == E->NumCaptures", "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1486, __PRETTY_FUNCTION__))
;(void)NumCaptures;
1487 E->IntroducerRange = ReadSourceRange();
1488 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
1489 E->CaptureDefaultLoc = ReadSourceLocation();
1490 E->ExplicitParams = Record.readInt();
1491 E->ExplicitResultType = Record.readInt();
1492 E->ClosingBrace = ReadSourceLocation();
1493
1494 // Read capture initializers.
1495 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1496 CEnd = E->capture_init_end();
1497 C != CEnd; ++C)
1498 *C = Record.readSubExpr();
1499}
1500
1501void
1502ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1503 VisitExpr(E);
1504 E->SubExpr = Record.readSubExpr();
1505}
1506
1507void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1508 VisitExplicitCastExpr(E);
1509 SourceRange R = ReadSourceRange();
1510 E->Loc = R.getBegin();
1511 E->RParenLoc = R.getEnd();
1512 R = ReadSourceRange();
1513 E->AngleBrackets = R;
1514}
1515
1516void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1517 return VisitCXXNamedCastExpr(E);
1518}
1519
1520void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1521 return VisitCXXNamedCastExpr(E);
1522}
1523
1524void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1525 return VisitCXXNamedCastExpr(E);
1526}
1527
1528void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1529 return VisitCXXNamedCastExpr(E);
1530}
1531
1532void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1533 VisitExplicitCastExpr(E);
1534 E->setLParenLoc(ReadSourceLocation());
1535 E->setRParenLoc(ReadSourceLocation());
1536}
1537
1538void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1539 VisitExplicitCastExpr(E);
1540 E->KWLoc = ReadSourceLocation();
1541 E->RParenLoc = ReadSourceLocation();
1542}
1543
1544void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1545 VisitCallExpr(E);
1546 E->UDSuffixLoc = ReadSourceLocation();
1547}
1548
1549void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1550 VisitExpr(E);
1551 E->setValue(Record.readInt());
1552 E->setLocation(ReadSourceLocation());
1553}
1554
1555void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1556 VisitExpr(E);
1557 E->setLocation(ReadSourceLocation());
1558}
1559
1560void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1561 VisitExpr(E);
1562 E->setSourceRange(ReadSourceRange());
1563 if (E->isTypeOperand()) { // typeid(int)
1564 E->setTypeOperandSourceInfo(
1565 GetTypeSourceInfo());
1566 return;
1567 }
1568
1569 // typeid(42+2)
1570 E->setExprOperand(Record.readSubExpr());
1571}
1572
1573void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
1574 VisitExpr(E);
1575 E->setLocation(ReadSourceLocation());
1576 E->setImplicit(Record.readInt());
1577}
1578
1579void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
1580 VisitExpr(E);
1581 E->CXXThrowExprBits.ThrowLoc = ReadSourceLocation();
1582 E->Operand = Record.readSubExpr();
1583 E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
1584}
1585
1586void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1587 VisitExpr(E);
1588 E->Param = ReadDeclAs<ParmVarDecl>();
1589 E->UsedContext = ReadDeclAs<DeclContext>();
1590 E->CXXDefaultArgExprBits.Loc = ReadSourceLocation();
1591}
1592
1593void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1594 VisitExpr(E);
1595 E->Field = ReadDeclAs<FieldDecl>();
1596 E->UsedContext = ReadDeclAs<DeclContext>();
1597 E->CXXDefaultInitExprBits.Loc = ReadSourceLocation();
1598}
1599
1600void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1601 VisitExpr(E);
1602 E->setTemporary(Record.readCXXTemporary());
1603 E->setSubExpr(Record.readSubExpr());
1604}
1605
1606void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1607 VisitExpr(E);
1608 E->TypeInfo = GetTypeSourceInfo();
1609 E->CXXScalarValueInitExprBits.RParenLoc = ReadSourceLocation();
1610}
1611
1612void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
1613 VisitExpr(E);
1614
1615 bool IsArray = Record.readInt();
1616 bool HasInit = Record.readInt();
1617 unsigned NumPlacementArgs = Record.readInt();
1618 bool IsParenTypeId = Record.readInt();
1619
1620 E->CXXNewExprBits.IsGlobalNew = Record.readInt();
1621 E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
1622 E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1623 E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
1624
1625 assert((IsArray == E->isArray()) && "Wrong IsArray!")(((IsArray == E->isArray()) && "Wrong IsArray!") ?
static_cast<void> (0) : __assert_fail ("(IsArray == E->isArray()) && \"Wrong IsArray!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1625, __PRETTY_FUNCTION__))
;
1626 assert((HasInit == E->hasInitializer()) && "Wrong HasInit!")(((HasInit == E->hasInitializer()) && "Wrong HasInit!"
) ? static_cast<void> (0) : __assert_fail ("(HasInit == E->hasInitializer()) && \"Wrong HasInit!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1626, __PRETTY_FUNCTION__))
;
1627 assert((NumPlacementArgs == E->getNumPlacementArgs()) &&(((NumPlacementArgs == E->getNumPlacementArgs()) &&
"Wrong NumPlacementArgs!") ? static_cast<void> (0) : __assert_fail
("(NumPlacementArgs == E->getNumPlacementArgs()) && \"Wrong NumPlacementArgs!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1628, __PRETTY_FUNCTION__))
1628 "Wrong NumPlacementArgs!")(((NumPlacementArgs == E->getNumPlacementArgs()) &&
"Wrong NumPlacementArgs!") ? static_cast<void> (0) : __assert_fail
("(NumPlacementArgs == E->getNumPlacementArgs()) && \"Wrong NumPlacementArgs!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1628, __PRETTY_FUNCTION__))
;
1629 assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!")(((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!"
) ? static_cast<void> (0) : __assert_fail ("(IsParenTypeId == E->isParenTypeId()) && \"Wrong IsParenTypeId!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1629, __PRETTY_FUNCTION__))
;
1630 (void)IsArray;
1631 (void)HasInit;
1632 (void)NumPlacementArgs;
1633
1634 E->setOperatorNew(ReadDeclAs<FunctionDecl>());
1635 E->setOperatorDelete(ReadDeclAs<FunctionDecl>());
1636 E->AllocatedTypeInfo = GetTypeSourceInfo();
1637 if (IsParenTypeId)
1638 E->getTrailingObjects<SourceRange>()[0] = ReadSourceRange();
1639 E->Range = ReadSourceRange();
1640 E->DirectInitRange = ReadSourceRange();
1641
1642 // Install all the subexpressions.
1643 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
1644 N = E->raw_arg_end();
1645 I != N; ++I)
1646 *I = Record.readSubStmt();
1647}
1648
1649void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1650 VisitExpr(E);
1651 E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
1652 E->CXXDeleteExprBits.ArrayForm = Record.readInt();
1653 E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
1654 E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1655 E->OperatorDelete = ReadDeclAs<FunctionDecl>();
1656 E->Argument = Record.readSubExpr();
1657 E->CXXDeleteExprBits.Loc = ReadSourceLocation();
1658}
1659
1660void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1661 VisitExpr(E);
1662
1663 E->Base = Record.readSubExpr();
1664 E->IsArrow = Record.readInt();
1665 E->OperatorLoc = ReadSourceLocation();
1666 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1667 E->ScopeType = GetTypeSourceInfo();
1668 E->ColonColonLoc = ReadSourceLocation();
1669 E->TildeLoc = ReadSourceLocation();
1670
1671 IdentifierInfo *II = Record.getIdentifierInfo();
1672 if (II)
1673 E->setDestroyedType(II, ReadSourceLocation());
1674 else
1675 E->setDestroyedType(GetTypeSourceInfo());
1676}
1677
1678void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
1679 VisitExpr(E);
1680
1681 unsigned NumObjects = Record.readInt();
1682 assert(NumObjects == E->getNumObjects())((NumObjects == E->getNumObjects()) ? static_cast<void>
(0) : __assert_fail ("NumObjects == E->getNumObjects()", "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1682, __PRETTY_FUNCTION__))
;
1683 for (unsigned i = 0; i != NumObjects; ++i)
1684 E->getTrailingObjects<BlockDecl *>()[i] =
1685 ReadDeclAs<BlockDecl>();
1686
1687 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
1688 E->SubExpr = Record.readSubExpr();
1689}
1690
1691void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1692 CXXDependentScopeMemberExpr *E) {
1693 VisitExpr(E);
1694
1695 bool HasTemplateKWAndArgsInfo = Record.readInt();
1696 unsigned NumTemplateArgs = Record.readInt();
1697 bool HasFirstQualifierFoundInScope = Record.readInt();
1698
1699 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&(((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo
()) && "Wrong HasTemplateKWAndArgsInfo!") ? static_cast
<void> (0) : __assert_fail ("(HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) && \"Wrong HasTemplateKWAndArgsInfo!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1700, __PRETTY_FUNCTION__))
1700 "Wrong HasTemplateKWAndArgsInfo!")(((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo
()) && "Wrong HasTemplateKWAndArgsInfo!") ? static_cast
<void> (0) : __assert_fail ("(HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) && \"Wrong HasTemplateKWAndArgsInfo!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1700, __PRETTY_FUNCTION__))
;
1701 assert((((HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope
()) && "Wrong HasFirstQualifierFoundInScope!") ? static_cast
<void> (0) : __assert_fail ("(HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) && \"Wrong HasFirstQualifierFoundInScope!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1703, __PRETTY_FUNCTION__))
1702 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&(((HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope
()) && "Wrong HasFirstQualifierFoundInScope!") ? static_cast
<void> (0) : __assert_fail ("(HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) && \"Wrong HasFirstQualifierFoundInScope!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1703, __PRETTY_FUNCTION__))
1703 "Wrong HasFirstQualifierFoundInScope!")(((HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope
()) && "Wrong HasFirstQualifierFoundInScope!") ? static_cast
<void> (0) : __assert_fail ("(HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) && \"Wrong HasFirstQualifierFoundInScope!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1703, __PRETTY_FUNCTION__))
;
1704
1705 if (HasTemplateKWAndArgsInfo)
1706 ReadTemplateKWAndArgsInfo(
1707 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1708 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
1709
1710 assert((NumTemplateArgs == E->getNumTemplateArgs()) &&(((NumTemplateArgs == E->getNumTemplateArgs()) && "Wrong NumTemplateArgs!"
) ? static_cast<void> (0) : __assert_fail ("(NumTemplateArgs == E->getNumTemplateArgs()) && \"Wrong NumTemplateArgs!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1711, __PRETTY_FUNCTION__))
1711 "Wrong NumTemplateArgs!")(((NumTemplateArgs == E->getNumTemplateArgs()) && "Wrong NumTemplateArgs!"
) ? static_cast<void> (0) : __assert_fail ("(NumTemplateArgs == E->getNumTemplateArgs()) && \"Wrong NumTemplateArgs!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1711, __PRETTY_FUNCTION__))
;
1712
1713 E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
1714 E->CXXDependentScopeMemberExprBits.OperatorLoc = ReadSourceLocation();
1715 E->BaseType = Record.readType();
1716 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1717 E->Base = Record.readSubExpr();
1718
1719 if (HasFirstQualifierFoundInScope)
1720 *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
1721
1722 ReadDeclarationNameInfo(E->MemberNameInfo);
1723}
1724
1725void
1726ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
1727 VisitExpr(E);
1728
1729 if (Record.readInt()) // HasTemplateKWAndArgsInfo
1730 ReadTemplateKWAndArgsInfo(
1731 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1732 E->getTrailingObjects<TemplateArgumentLoc>(),
1733 /*NumTemplateArgs=*/Record.readInt());
1734
1735 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1736 ReadDeclarationNameInfo(E->NameInfo);
1737}
1738
1739void
1740ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
1741 VisitExpr(E);
1742 assert(Record.peekInt() == E->arg_size() &&((Record.peekInt() == E->arg_size() && "Read wrong record during creation ?"
) ? static_cast<void> (0) : __assert_fail ("Record.peekInt() == E->arg_size() && \"Read wrong record during creation ?\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1743, __PRETTY_FUNCTION__))
1743 "Read wrong record during creation ?")((Record.peekInt() == E->arg_size() && "Read wrong record during creation ?"
) ? static_cast<void> (0) : __assert_fail ("Record.peekInt() == E->arg_size() && \"Read wrong record during creation ?\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1743, __PRETTY_FUNCTION__))
;
1744 Record.skipInts(1);
1745 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
1746 E->setArg(I, Record.readSubExpr());
1747 E->TSI = GetTypeSourceInfo();
1748 E->setLParenLoc(ReadSourceLocation());
1749 E->setRParenLoc(ReadSourceLocation());
1750}
1751
1752void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
1753 VisitExpr(E);
1754
1755 unsigned NumResults = Record.readInt();
1756 bool HasTemplateKWAndArgsInfo = Record.readInt();
1757 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!")(((E->getNumDecls() == NumResults) && "Wrong NumResults!"
) ? static_cast<void> (0) : __assert_fail ("(E->getNumDecls() == NumResults) && \"Wrong NumResults!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1757, __PRETTY_FUNCTION__))
;
1758 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&(((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo
) && "Wrong HasTemplateKWAndArgsInfo!") ? static_cast
<void> (0) : __assert_fail ("(E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) && \"Wrong HasTemplateKWAndArgsInfo!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1759, __PRETTY_FUNCTION__))
1759 "Wrong HasTemplateKWAndArgsInfo!")(((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo
) && "Wrong HasTemplateKWAndArgsInfo!") ? static_cast
<void> (0) : __assert_fail ("(E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) && \"Wrong HasTemplateKWAndArgsInfo!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1759, __PRETTY_FUNCTION__))
;
1760
1761 if (HasTemplateKWAndArgsInfo) {
1762 unsigned NumTemplateArgs = Record.readInt();
1763 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1764 E->getTrailingTemplateArgumentLoc(),
1765 NumTemplateArgs);
1766 assert((E->getNumTemplateArgs() == NumTemplateArgs) &&(((E->getNumTemplateArgs() == NumTemplateArgs) && "Wrong NumTemplateArgs!"
) ? static_cast<void> (0) : __assert_fail ("(E->getNumTemplateArgs() == NumTemplateArgs) && \"Wrong NumTemplateArgs!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1767, __PRETTY_FUNCTION__))
1767 "Wrong NumTemplateArgs!")(((E->getNumTemplateArgs() == NumTemplateArgs) && "Wrong NumTemplateArgs!"
) ? static_cast<void> (0) : __assert_fail ("(E->getNumTemplateArgs() == NumTemplateArgs) && \"Wrong NumTemplateArgs!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1767, __PRETTY_FUNCTION__))
;
1768 }
1769
1770 UnresolvedSet<8> Decls;
1771 for (unsigned I = 0; I != NumResults; ++I) {
1772 auto *D = ReadDeclAs<NamedDecl>();
1773 auto AS = (AccessSpecifier)Record.readInt();
1774 Decls.addDecl(D, AS);
1775 }
1776
1777 DeclAccessPair *Results = E->getTrailingResults();
1778 UnresolvedSetIterator Iter = Decls.begin();
1779 for (unsigned I = 0; I != NumResults; ++I) {
1780 Results[I] = (Iter + I).getPair();
1781 }
1782
1783 ReadDeclarationNameInfo(E->NameInfo);
1784 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1785}
1786
1787void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
1788 VisitOverloadExpr(E);
1789 E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
1790 E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
1791 E->Base = Record.readSubExpr();
1792 E->BaseType = Record.readType();
1793 E->OperatorLoc = ReadSourceLocation();
1794}
1795
1796void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
1797 VisitOverloadExpr(E);
1798 E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
1799 E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
1800 E->NamingClass = ReadDeclAs<CXXRecordDecl>();
1801}
1802
1803void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1804 VisitExpr(E);
1805 E->TypeTraitExprBits.NumArgs = Record.readInt();
1806 E->TypeTraitExprBits.Kind = Record.readInt();
1807 E->TypeTraitExprBits.Value = Record.readInt();
1808 SourceRange Range = ReadSourceRange();
1809 E->Loc = Range.getBegin();
1810 E->RParenLoc = Range.getEnd();
1811
1812 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
1813 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1814 Args[I] = GetTypeSourceInfo();
1815}
1816
1817void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1818 VisitExpr(E);
1819 E->ATT = (ArrayTypeTrait)Record.readInt();
1820 E->Value = (unsigned int)Record.readInt();
1821 SourceRange Range = ReadSourceRange();
1822 E->Loc = Range.getBegin();
1823 E->RParen = Range.getEnd();
1824 E->QueriedType = GetTypeSourceInfo();
1825 E->Dimension = Record.readSubExpr();
1826}
1827
1828void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1829 VisitExpr(E);
1830 E->ET = (ExpressionTrait)Record.readInt();
1831 E->Value = (bool)Record.readInt();
1832 SourceRange Range = ReadSourceRange();
1833 E->QueriedExpression = Record.readSubExpr();
1834 E->Loc = Range.getBegin();
1835 E->RParen = Range.getEnd();
1836}
1837
1838void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1839 VisitExpr(E);
1840 E->CXXNoexceptExprBits.Value = Record.readInt();
1841 E->Range = ReadSourceRange();
1842 E->Operand = Record.readSubExpr();
1843}
1844
1845void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1846 VisitExpr(E);
1847 E->EllipsisLoc = ReadSourceLocation();
1848 E->NumExpansions = Record.readInt();
1849 E->Pattern = Record.readSubExpr();
1850}
1851
1852void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1853 VisitExpr(E);
1854 unsigned NumPartialArgs = Record.readInt();
1855 E->OperatorLoc = ReadSourceLocation();
1856 E->PackLoc = ReadSourceLocation();
1857 E->RParenLoc = ReadSourceLocation();
1858 E->Pack = Record.readDeclAs<NamedDecl>();
1859 if (E->isPartiallySubstituted()) {
1860 assert(E->Length == NumPartialArgs)((E->Length == NumPartialArgs) ? static_cast<void> (
0) : __assert_fail ("E->Length == NumPartialArgs", "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1860, __PRETTY_FUNCTION__))
;
1861 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
1862 *E = I + NumPartialArgs;
1863 I != E; ++I)
1864 new (I) TemplateArgument(Record.readTemplateArgument());
1865 } else if (!E->isValueDependent()) {
1866 E->Length = Record.readInt();
1867 }
1868}
1869
1870void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1871 SubstNonTypeTemplateParmExpr *E) {
1872 VisitExpr(E);
1873 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1874 E->SubstNonTypeTemplateParmExprBits.NameLoc = ReadSourceLocation();
1875 E->Replacement = Record.readSubExpr();
1876}
1877
1878void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1879 SubstNonTypeTemplateParmPackExpr *E) {
1880 VisitExpr(E);
1881 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1882 TemplateArgument ArgPack = Record.readTemplateArgument();
1883 if (ArgPack.getKind() != TemplateArgument::Pack)
1884 return;
1885
1886 E->Arguments = ArgPack.pack_begin();
1887 E->NumArguments = ArgPack.pack_size();
1888 E->NameLoc = ReadSourceLocation();
1889}
1890
1891void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1892 VisitExpr(E);
1893 E->NumParameters = Record.readInt();
1894 E->ParamPack = ReadDeclAs<ParmVarDecl>();
1895 E->NameLoc = ReadSourceLocation();
1896 auto **Parms = E->getTrailingObjects<VarDecl *>();
1897 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
1898 Parms[i] = ReadDeclAs<VarDecl>();
1899}
1900
1901void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1902 VisitExpr(E);
1903 E->State = Record.readSubExpr();
1904 auto *VD = ReadDeclAs<ValueDecl>();
1905 unsigned ManglingNumber = Record.readInt();
1906 E->setExtendingDecl(VD, ManglingNumber);
1907}
1908
1909void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
1910 VisitExpr(E);
1911 E->LParenLoc = ReadSourceLocation();
1912 E->EllipsisLoc = ReadSourceLocation();
1913 E->RParenLoc = ReadSourceLocation();
1914 E->NumExpansions = Record.readInt();
1915 E->SubExprs[0] = Record.readSubExpr();
1916 E->SubExprs[1] = Record.readSubExpr();
1917 E->Opcode = (BinaryOperatorKind)Record.readInt();
1918}
1919
1920void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1921 VisitExpr(E);
1922 E->SourceExpr = Record.readSubExpr();
1923 E->OpaqueValueExprBits.Loc = ReadSourceLocation();
1924 E->setIsUnique(Record.readInt());
1925}
1926
1927void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
1928 llvm_unreachable("Cannot read TypoExpr nodes")::llvm::llvm_unreachable_internal("Cannot read TypoExpr nodes"
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 1928)
;
1929}
1930
1931//===----------------------------------------------------------------------===//
1932// Microsoft Expressions and Statements
1933//===----------------------------------------------------------------------===//
1934void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1935 VisitExpr(E);
1936 E->IsArrow = (Record.readInt() != 0);
1937 E->BaseExpr = Record.readSubExpr();
1938 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1939 E->MemberLoc = ReadSourceLocation();
1940 E->TheDecl = ReadDeclAs<MSPropertyDecl>();
1941}
1942
1943void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
1944 VisitExpr(E);
1945 E->setBase(Record.readSubExpr());
1946 E->setIdx(Record.readSubExpr());
1947 E->setRBracketLoc(ReadSourceLocation());
1948}
1949
1950void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1951 VisitExpr(E);
1952 E->setSourceRange(ReadSourceRange());
1953 std::string UuidStr = ReadString();
1954 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
1955 if (E->isTypeOperand()) { // __uuidof(ComType)
1956 E->setTypeOperandSourceInfo(
1957 GetTypeSourceInfo());
1958 return;
1959 }
1960
1961 // __uuidof(expr)
1962 E->setExprOperand(Record.readSubExpr());
1963}
1964
1965void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1966 VisitStmt(S);
1967 S->setLeaveLoc(ReadSourceLocation());
1968}
1969
1970void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1971 VisitStmt(S);
1972 S->Loc = ReadSourceLocation();
1973 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
1974 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
1975}
1976
1977void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1978 VisitStmt(S);
1979 S->Loc = ReadSourceLocation();
1980 S->Block = Record.readSubStmt();
1981}
1982
1983void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1984 VisitStmt(S);
1985 S->IsCXXTry = Record.readInt();
1986 S->TryLoc = ReadSourceLocation();
1987 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
1988 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
1989}
1990
1991//===----------------------------------------------------------------------===//
1992// CUDA Expressions and Statements
1993//===----------------------------------------------------------------------===//
1994
1995void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1996 VisitCallExpr(E);
1997 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
1998}
1999
2000//===----------------------------------------------------------------------===//
2001// OpenCL Expressions and Statements.
2002//===----------------------------------------------------------------------===//
2003void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2004 VisitExpr(E);
2005 E->BuiltinLoc = ReadSourceLocation();
2006 E->RParenLoc = ReadSourceLocation();
2007 E->SrcExpr = Record.readSubExpr();
2008}
2009
2010//===----------------------------------------------------------------------===//
2011// OpenMP Directives.
2012//===----------------------------------------------------------------------===//
2013
2014void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
2015 E->setLocStart(ReadSourceLocation());
2016 E->setLocEnd(ReadSourceLocation());
2017 OMPClauseReader ClauseReader(Record);
2018 SmallVector<OMPClause *, 5> Clauses;
2019 for (unsigned i = 0; i < E->getNumClauses(); ++i)
2020 Clauses.push_back(ClauseReader.readClause());
2021 E->setClauses(Clauses);
2022 if (E->hasAssociatedStmt())
2023 E->setAssociatedStmt(Record.readSubStmt());
2024}
2025
2026void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2027 VisitStmt(D);
2028 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
2029 Record.skipInts(2);
2030 VisitOMPExecutableDirective(D);
2031 D->setIterationVariable(Record.readSubExpr());
2032 D->setLastIteration(Record.readSubExpr());
2033 D->setCalcLastIteration(Record.readSubExpr());
2034 D->setPreCond(Record.readSubExpr());
2035 D->setCond(Record.readSubExpr());
2036 D->setInit(Record.readSubExpr());
2037 D->setInc(Record.readSubExpr());
2038 D->setPreInits(Record.readSubStmt());
2039 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
2040 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2041 isOpenMPDistributeDirective(D->getDirectiveKind())) {
2042 D->setIsLastIterVariable(Record.readSubExpr());
2043 D->setLowerBoundVariable(Record.readSubExpr());
2044 D->setUpperBoundVariable(Record.readSubExpr());
2045 D->setStrideVariable(Record.readSubExpr());
2046 D->setEnsureUpperBound(Record.readSubExpr());
2047 D->setNextLowerBound(Record.readSubExpr());
2048 D->setNextUpperBound(Record.readSubExpr());
2049 D->setNumIterations(Record.readSubExpr());
2050 }
2051 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
2052 D->setPrevLowerBoundVariable(Record.readSubExpr());
2053 D->setPrevUpperBoundVariable(Record.readSubExpr());
2054 D->setDistInc(Record.readSubExpr());
2055 D->setPrevEnsureUpperBound(Record.readSubExpr());
2056 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2057 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2058 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2059 D->setCombinedInit(Record.readSubExpr());
2060 D->setCombinedCond(Record.readSubExpr());
2061 D->setCombinedNextLowerBound(Record.readSubExpr());
2062 D->setCombinedNextUpperBound(Record.readSubExpr());
2063 D->setCombinedDistCond(Record.readSubExpr());
2064 D->setCombinedParForInDistCond(Record.readSubExpr());
2065 }
2066 SmallVector<Expr *, 4> Sub;
2067 unsigned CollapsedNum = D->getCollapsedNumber();
2068 Sub.reserve(CollapsedNum);
2069 for (unsigned i = 0; i < CollapsedNum; ++i)
2070 Sub.push_back(Record.readSubExpr());
2071 D->setCounters(Sub);
2072 Sub.clear();
2073 for (unsigned i = 0; i < CollapsedNum; ++i)
2074 Sub.push_back(Record.readSubExpr());
2075 D->setPrivateCounters(Sub);
2076 Sub.clear();
2077 for (unsigned i = 0; i < CollapsedNum; ++i)
2078 Sub.push_back(Record.readSubExpr());
2079 D->setInits(Sub);
2080 Sub.clear();
2081 for (unsigned i = 0; i < CollapsedNum; ++i)
2082 Sub.push_back(Record.readSubExpr());
2083 D->setUpdates(Sub);
2084 Sub.clear();
2085 for (unsigned i = 0; i < CollapsedNum; ++i)
2086 Sub.push_back(Record.readSubExpr());
2087 D->setFinals(Sub);
2088 Sub.clear();
2089 for (unsigned i = 0; i < CollapsedNum; ++i)
2090 Sub.push_back(Record.readSubExpr());
2091 D->setDependentCounters(Sub);
2092 Sub.clear();
2093 for (unsigned i = 0; i < CollapsedNum; ++i)
2094 Sub.push_back(Record.readSubExpr());
2095 D->setDependentInits(Sub);
2096 Sub.clear();
2097 for (unsigned i = 0; i < CollapsedNum; ++i)
2098 Sub.push_back(Record.readSubExpr());
2099 D->setFinalsConditions(Sub);
2100}
2101
2102void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
2103 VisitStmt(D);
2104 // The NumClauses field was read in ReadStmtFromStream.
2105 Record.skipInts(1);
2106 VisitOMPExecutableDirective(D);
2107 D->setHasCancel(Record.readInt());
2108}
2109
2110void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
2111 VisitOMPLoopDirective(D);
2112}
2113
2114void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
2115 VisitOMPLoopDirective(D);
2116 D->setHasCancel(Record.readInt());
2117}
2118
2119void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2120 VisitOMPLoopDirective(D);
2121}
2122
2123void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2124 VisitStmt(D);
2125 // The NumClauses field was read in ReadStmtFromStream.
2126 Record.skipInts(1);
2127 VisitOMPExecutableDirective(D);
2128 D->setHasCancel(Record.readInt());
2129}
2130
2131void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2132 VisitStmt(D);
2133 VisitOMPExecutableDirective(D);
2134 D->setHasCancel(Record.readInt());
2135}
2136
2137void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2138 VisitStmt(D);
2139 // The NumClauses field was read in ReadStmtFromStream.
2140 Record.skipInts(1);
2141 VisitOMPExecutableDirective(D);
2142}
2143
2144void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2145 VisitStmt(D);
2146 VisitOMPExecutableDirective(D);
2147}
2148
2149void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2150 VisitStmt(D);
2151 // The NumClauses field was read in ReadStmtFromStream.
2152 Record.skipInts(1);
2153 VisitOMPExecutableDirective(D);
2154 ReadDeclarationNameInfo(D->DirName);
2155}
2156
2157void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
2158 VisitOMPLoopDirective(D);
2159 D->setHasCancel(Record.readInt());
2160}
2161
2162void ASTStmtReader::VisitOMPParallelForSimdDirective(
2163 OMPParallelForSimdDirective *D) {
2164 VisitOMPLoopDirective(D);
2165}
2166
2167void ASTStmtReader::VisitOMPParallelSectionsDirective(
2168 OMPParallelSectionsDirective *D) {
2169 VisitStmt(D);
2170 // The NumClauses field was read in ReadStmtFromStream.
2171 Record.skipInts(1);
2172 VisitOMPExecutableDirective(D);
2173 D->setHasCancel(Record.readInt());
2174}
2175
2176void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2177 VisitStmt(D);
2178 // The NumClauses field was read in ReadStmtFromStream.
2179 Record.skipInts(1);
2180 VisitOMPExecutableDirective(D);
2181 D->setHasCancel(Record.readInt());
2182}
2183
2184void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2185 VisitStmt(D);
2186 VisitOMPExecutableDirective(D);
2187}
2188
2189void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2190 VisitStmt(D);
2191 VisitOMPExecutableDirective(D);
2192}
2193
2194void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2195 VisitStmt(D);
2196 VisitOMPExecutableDirective(D);
2197}
2198
2199void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2200 VisitStmt(D);
2201 // The NumClauses field was read in ReadStmtFromStream.
2202 Record.skipInts(1);
2203 VisitOMPExecutableDirective(D);
2204 D->setReductionRef(Record.readSubExpr());
2205}
2206
2207void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2208 VisitStmt(D);
2209 // The NumClauses field was read in ReadStmtFromStream.
2210 Record.skipInts(1);
2211 VisitOMPExecutableDirective(D);
2212}
2213
2214void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2215 VisitStmt(D);
2216 // The NumClauses field was read in ReadStmtFromStream.
2217 Record.skipInts(1);
2218 VisitOMPExecutableDirective(D);
2219}
2220
2221void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2222 VisitStmt(D);
2223 // The NumClauses field was read in ReadStmtFromStream.
2224 Record.skipInts(1);
2225 VisitOMPExecutableDirective(D);
2226 D->setX(Record.readSubExpr());
2227 D->setV(Record.readSubExpr());
2228 D->setExpr(Record.readSubExpr());
2229 D->setUpdateExpr(Record.readSubExpr());
2230 D->IsXLHSInRHSPart = Record.readInt() != 0;
2231 D->IsPostfixUpdate = Record.readInt() != 0;
2232}
2233
2234void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2235 VisitStmt(D);
2236 // The NumClauses field was read in ReadStmtFromStream.
2237 Record.skipInts(1);
2238 VisitOMPExecutableDirective(D);
2239}
2240
2241void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2242 VisitStmt(D);
2243 Record.skipInts(1);
2244 VisitOMPExecutableDirective(D);
2245}
2246
2247void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2248 OMPTargetEnterDataDirective *D) {
2249 VisitStmt(D);
2250 Record.skipInts(1);
2251 VisitOMPExecutableDirective(D);
2252}
2253
2254void ASTStmtReader::VisitOMPTargetExitDataDirective(
2255 OMPTargetExitDataDirective *D) {
2256 VisitStmt(D);
2257 Record.skipInts(1);
2258 VisitOMPExecutableDirective(D);
2259}
2260
2261void ASTStmtReader::VisitOMPTargetParallelDirective(
2262 OMPTargetParallelDirective *D) {
2263 VisitStmt(D);
2264 Record.skipInts(1);
2265 VisitOMPExecutableDirective(D);
2266}
2267
2268void ASTStmtReader::VisitOMPTargetParallelForDirective(
2269 OMPTargetParallelForDirective *D) {
2270 VisitOMPLoopDirective(D);
2271 D->setHasCancel(Record.readInt());
2272}
2273
2274void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2275 VisitStmt(D);
2276 // The NumClauses field was read in ReadStmtFromStream.
2277 Record.skipInts(1);
2278 VisitOMPExecutableDirective(D);
2279}
2280
2281void ASTStmtReader::VisitOMPCancellationPointDirective(
2282 OMPCancellationPointDirective *D) {
2283 VisitStmt(D);
2284 VisitOMPExecutableDirective(D);
2285 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2286}
2287
2288void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2289 VisitStmt(D);
2290 // The NumClauses field was read in ReadStmtFromStream.
2291 Record.skipInts(1);
2292 VisitOMPExecutableDirective(D);
2293 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2294}
2295
2296void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2297 VisitOMPLoopDirective(D);
2298}
2299
2300void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2301 VisitOMPLoopDirective(D);
2302}
2303
2304void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2305 OMPMasterTaskLoopDirective *D) {
2306 VisitOMPLoopDirective(D);
2307}
2308
2309void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2310 OMPMasterTaskLoopSimdDirective *D) {
2311 VisitOMPLoopDirective(D);
2312}
2313
2314void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2315 OMPParallelMasterTaskLoopDirective *D) {
2316 VisitOMPLoopDirective(D);
2317}
2318
2319void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2320 OMPParallelMasterTaskLoopSimdDirective *D) {
2321 VisitOMPLoopDirective(D);
2322}
2323
2324void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2325 VisitOMPLoopDirective(D);
2326}
2327
2328void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2329 VisitStmt(D);
2330 Record.skipInts(1);
2331 VisitOMPExecutableDirective(D);
2332}
2333
2334void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2335 OMPDistributeParallelForDirective *D) {
2336 VisitOMPLoopDirective(D);
2337 D->setHasCancel(Record.readInt());
2338}
2339
2340void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2341 OMPDistributeParallelForSimdDirective *D) {
2342 VisitOMPLoopDirective(D);
2343}
2344
2345void ASTStmtReader::VisitOMPDistributeSimdDirective(
2346 OMPDistributeSimdDirective *D) {
2347 VisitOMPLoopDirective(D);
2348}
2349
2350void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2351 OMPTargetParallelForSimdDirective *D) {
2352 VisitOMPLoopDirective(D);
2353}
2354
2355void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2356 VisitOMPLoopDirective(D);
2357}
2358
2359void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2360 OMPTeamsDistributeDirective *D) {
2361 VisitOMPLoopDirective(D);
2362}
2363
2364void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2365 OMPTeamsDistributeSimdDirective *D) {
2366 VisitOMPLoopDirective(D);
2367}
2368
2369void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2370 OMPTeamsDistributeParallelForSimdDirective *D) {
2371 VisitOMPLoopDirective(D);
2372}
2373
2374void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2375 OMPTeamsDistributeParallelForDirective *D) {
2376 VisitOMPLoopDirective(D);
2377 D->setHasCancel(Record.readInt());
2378}
2379
2380void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2381 VisitStmt(D);
2382 // The NumClauses field was read in ReadStmtFromStream.
2383 Record.skipInts(1);
2384 VisitOMPExecutableDirective(D);
2385}
2386
2387void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2388 OMPTargetTeamsDistributeDirective *D) {
2389 VisitOMPLoopDirective(D);
2390}
2391
2392void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2393 OMPTargetTeamsDistributeParallelForDirective *D) {
2394 VisitOMPLoopDirective(D);
2395 D->setHasCancel(Record.readInt());
2396}
2397
2398void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2399 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2400 VisitOMPLoopDirective(D);
2401}
2402
2403void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2404 OMPTargetTeamsDistributeSimdDirective *D) {
2405 VisitOMPLoopDirective(D);
2406}
2407
2408//===----------------------------------------------------------------------===//
2409// ASTReader Implementation
2410//===----------------------------------------------------------------------===//
2411
2412Stmt *ASTReader::ReadStmt(ModuleFile &F) {
2413 switch (ReadingKind) {
2414 case Read_None:
2415 llvm_unreachable("should not call this when not reading anything")::llvm::llvm_unreachable_internal("should not call this when not reading anything"
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 2415)
;
2416 case Read_Decl:
2417 case Read_Type:
2418 return ReadStmtFromStream(F);
2419 case Read_Stmt:
2420 return ReadSubStmt();
2421 }
2422
2423 llvm_unreachable("ReadingKind not set ?")::llvm::llvm_unreachable_internal("ReadingKind not set ?", "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 2423)
;
2424}
2425
2426Expr *ASTReader::ReadExpr(ModuleFile &F) {
2427 return cast_or_null<Expr>(ReadStmt(F));
2428}
2429
2430Expr *ASTReader::ReadSubExpr() {
2431 return cast_or_null<Expr>(ReadSubStmt());
2432}
2433
2434// Within the bitstream, expressions are stored in Reverse Polish
2435// Notation, with each of the subexpressions preceding the
2436// expression they are stored in. Subexpressions are stored from last to first.
2437// To evaluate expressions, we continue reading expressions and placing them on
2438// the stack, with expressions having operands removing those operands from the
2439// stack. Evaluation terminates when we see a STMT_STOP record, and
2440// the single remaining expression on the stack is our result.
2441Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
2442 ReadingKindTracker ReadingKind(Read_Stmt, *this);
2443 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
2444
2445 // Map of offset to previously deserialized stmt. The offset points
2446 // just after the stmt record.
2447 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
2448
2449#ifndef NDEBUG
2450 unsigned PrevNumStmts = StmtStack.size();
2451#endif
2452
2453 ASTRecordReader Record(*this, F);
2454 ASTStmtReader Reader(Record, Cursor);
2455 Stmt::EmptyShell Empty;
2456
2457 while (true) {
1
Loop condition is true. Entering loop body
2458 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2459 Cursor.advanceSkippingSubblocks();
2
Calling 'BitstreamCursor::advanceSkippingSubblocks'
2460 if (!MaybeEntry) {
2461 Error(toString(MaybeEntry.takeError()));
2462 return nullptr;
2463 }
2464 llvm::BitstreamEntry Entry = MaybeEntry.get();
2465
2466 switch (Entry.Kind) {
2467 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2468 case llvm::BitstreamEntry::Error:
2469 Error("malformed block record in AST file");
2470 return nullptr;
2471 case llvm::BitstreamEntry::EndBlock:
2472 goto Done;
2473 case llvm::BitstreamEntry::Record:
2474 // The interesting case.
2475 break;
2476 }
2477
2478 ASTContext &Context = getContext();
2479 Stmt *S = nullptr;
2480 bool Finished = false;
2481 bool IsStmtReference = false;
2482 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2483 if (!MaybeStmtCode) {
2484 Error(toString(MaybeStmtCode.takeError()));
2485 return nullptr;
2486 }
2487 switch ((StmtCode)MaybeStmtCode.get()) {
2488 case STMT_STOP:
2489 Finished = true;
2490 break;
2491
2492 case STMT_REF_PTR:
2493 IsStmtReference = true;
2494 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&((StmtEntries.find(Record[0]) != StmtEntries.end() &&
"No stmt was recorded for this offset reference!") ? static_cast
<void> (0) : __assert_fail ("StmtEntries.find(Record[0]) != StmtEntries.end() && \"No stmt was recorded for this offset reference!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 2495, __PRETTY_FUNCTION__))
2495 "No stmt was recorded for this offset reference!")((StmtEntries.find(Record[0]) != StmtEntries.end() &&
"No stmt was recorded for this offset reference!") ? static_cast
<void> (0) : __assert_fail ("StmtEntries.find(Record[0]) != StmtEntries.end() && \"No stmt was recorded for this offset reference!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 2495, __PRETTY_FUNCTION__))
;
2496 S = StmtEntries[Record.readInt()];
2497 break;
2498
2499 case STMT_NULL_PTR:
2500 S = nullptr;
2501 break;
2502
2503 case STMT_NULL:
2504 S = new (Context) NullStmt(Empty);
2505 break;
2506
2507 case STMT_COMPOUND:
2508 S = CompoundStmt::CreateEmpty(
2509 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
2510 break;
2511
2512 case STMT_CASE:
2513 S = CaseStmt::CreateEmpty(
2514 Context,
2515 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
2516 break;
2517
2518 case STMT_DEFAULT:
2519 S = new (Context) DefaultStmt(Empty);
2520 break;
2521
2522 case STMT_LABEL:
2523 S = new (Context) LabelStmt(Empty);
2524 break;
2525
2526 case STMT_ATTRIBUTED:
2527 S = AttributedStmt::CreateEmpty(
2528 Context,
2529 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
2530 break;
2531
2532 case STMT_IF:
2533 S = IfStmt::CreateEmpty(
2534 Context,
2535 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2536 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2537 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
2538 break;
2539
2540 case STMT_SWITCH:
2541 S = SwitchStmt::CreateEmpty(
2542 Context,
2543 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
2544 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
2545 break;
2546
2547 case STMT_WHILE:
2548 S = WhileStmt::CreateEmpty(
2549 Context,
2550 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
2551 break;
2552
2553 case STMT_DO:
2554 S = new (Context) DoStmt(Empty);
2555 break;
2556
2557 case STMT_FOR:
2558 S = new (Context) ForStmt(Empty);
2559 break;
2560
2561 case STMT_GOTO:
2562 S = new (Context) GotoStmt(Empty);
2563 break;
2564
2565 case STMT_INDIRECT_GOTO:
2566 S = new (Context) IndirectGotoStmt(Empty);
2567 break;
2568
2569 case STMT_CONTINUE:
2570 S = new (Context) ContinueStmt(Empty);
2571 break;
2572
2573 case STMT_BREAK:
2574 S = new (Context) BreakStmt(Empty);
2575 break;
2576
2577 case STMT_RETURN:
2578 S = ReturnStmt::CreateEmpty(
2579 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
2580 break;
2581
2582 case STMT_DECL:
2583 S = new (Context) DeclStmt(Empty);
2584 break;
2585
2586 case STMT_GCCASM:
2587 S = new (Context) GCCAsmStmt(Empty);
2588 break;
2589
2590 case STMT_MSASM:
2591 S = new (Context) MSAsmStmt(Empty);
2592 break;
2593
2594 case STMT_CAPTURED:
2595 S = CapturedStmt::CreateDeserialized(
2596 Context, Record[ASTStmtReader::NumStmtFields]);
2597 break;
2598
2599 case EXPR_CONSTANT:
2600 S = ConstantExpr::CreateEmpty(
2601 Context,
2602 static_cast<ConstantExpr::ResultStorageKind>(
2603 Record[ASTStmtReader::NumExprFields]),
2604 Empty);
2605 break;
2606
2607 case EXPR_PREDEFINED:
2608 S = PredefinedExpr::CreateEmpty(
2609 Context,
2610 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
2611 break;
2612
2613 case EXPR_DECL_REF:
2614 S = DeclRefExpr::CreateEmpty(
2615 Context,
2616 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2617 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
2618 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
2619 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
2620 Record[ASTStmtReader::NumExprFields + 6] : 0);
2621 break;
2622
2623 case EXPR_INTEGER_LITERAL:
2624 S = IntegerLiteral::Create(Context, Empty);
2625 break;
2626
2627 case EXPR_FLOATING_LITERAL:
2628 S = FloatingLiteral::Create(Context, Empty);
2629 break;
2630
2631 case EXPR_IMAGINARY_LITERAL:
2632 S = new (Context) ImaginaryLiteral(Empty);
2633 break;
2634
2635 case EXPR_STRING_LITERAL:
2636 S = StringLiteral::CreateEmpty(
2637 Context,
2638 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
2639 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2640 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
2641 break;
2642
2643 case EXPR_CHARACTER_LITERAL:
2644 S = new (Context) CharacterLiteral(Empty);
2645 break;
2646
2647 case EXPR_PAREN:
2648 S = new (Context) ParenExpr(Empty);
2649 break;
2650
2651 case EXPR_PAREN_LIST:
2652 S = ParenListExpr::CreateEmpty(
2653 Context,
2654 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
2655 break;
2656
2657 case EXPR_UNARY_OPERATOR:
2658 S = new (Context) UnaryOperator(Empty);
2659 break;
2660
2661 case EXPR_OFFSETOF:
2662 S = OffsetOfExpr::CreateEmpty(Context,
2663 Record[ASTStmtReader::NumExprFields],
2664 Record[ASTStmtReader::NumExprFields + 1]);
2665 break;
2666
2667 case EXPR_SIZEOF_ALIGN_OF:
2668 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
2669 break;
2670
2671 case EXPR_ARRAY_SUBSCRIPT:
2672 S = new (Context) ArraySubscriptExpr(Empty);
2673 break;
2674
2675 case EXPR_OMP_ARRAY_SECTION:
2676 S = new (Context) OMPArraySectionExpr(Empty);
2677 break;
2678
2679 case EXPR_CALL:
2680 S = CallExpr::CreateEmpty(
2681 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
2682 break;
2683
2684 case EXPR_MEMBER:
2685 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
2686 Record[ASTStmtReader::NumExprFields + 1],
2687 Record[ASTStmtReader::NumExprFields + 2],
2688 Record[ASTStmtReader::NumExprFields + 3]);
2689 break;
2690
2691 case EXPR_BINARY_OPERATOR:
2692 S = new (Context) BinaryOperator(Empty);
2693 break;
2694
2695 case EXPR_COMPOUND_ASSIGN_OPERATOR:
2696 S = new (Context) CompoundAssignOperator(Empty);
2697 break;
2698
2699 case EXPR_CONDITIONAL_OPERATOR:
2700 S = new (Context) ConditionalOperator(Empty);
2701 break;
2702
2703 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2704 S = new (Context) BinaryConditionalOperator(Empty);
2705 break;
2706
2707 case EXPR_IMPLICIT_CAST:
2708 S = ImplicitCastExpr::CreateEmpty(Context,
2709 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2710 break;
2711
2712 case EXPR_CSTYLE_CAST:
2713 S = CStyleCastExpr::CreateEmpty(Context,
2714 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2715 break;
2716
2717 case EXPR_COMPOUND_LITERAL:
2718 S = new (Context) CompoundLiteralExpr(Empty);
2719 break;
2720
2721 case EXPR_EXT_VECTOR_ELEMENT:
2722 S = new (Context) ExtVectorElementExpr(Empty);
2723 break;
2724
2725 case EXPR_INIT_LIST:
2726 S = new (Context) InitListExpr(Empty);
2727 break;
2728
2729 case EXPR_DESIGNATED_INIT:
2730 S = DesignatedInitExpr::CreateEmpty(Context,
2731 Record[ASTStmtReader::NumExprFields] - 1);
2732
2733 break;
2734
2735 case EXPR_DESIGNATED_INIT_UPDATE:
2736 S = new (Context) DesignatedInitUpdateExpr(Empty);
2737 break;
2738
2739 case EXPR_IMPLICIT_VALUE_INIT:
2740 S = new (Context) ImplicitValueInitExpr(Empty);
2741 break;
2742
2743 case EXPR_NO_INIT:
2744 S = new (Context) NoInitExpr(Empty);
2745 break;
2746
2747 case EXPR_ARRAY_INIT_LOOP:
2748 S = new (Context) ArrayInitLoopExpr(Empty);
2749 break;
2750
2751 case EXPR_ARRAY_INIT_INDEX:
2752 S = new (Context) ArrayInitIndexExpr(Empty);
2753 break;
2754
2755 case EXPR_VA_ARG:
2756 S = new (Context) VAArgExpr(Empty);
2757 break;
2758
2759 case EXPR_SOURCE_LOC:
2760 S = new (Context) SourceLocExpr(Empty);
2761 break;
2762
2763 case EXPR_ADDR_LABEL:
2764 S = new (Context) AddrLabelExpr(Empty);
2765 break;
2766
2767 case EXPR_STMT:
2768 S = new (Context) StmtExpr(Empty);
2769 break;
2770
2771 case EXPR_CHOOSE:
2772 S = new (Context) ChooseExpr(Empty);
2773 break;
2774
2775 case EXPR_GNU_NULL:
2776 S = new (Context) GNUNullExpr(Empty);
2777 break;
2778
2779 case EXPR_SHUFFLE_VECTOR:
2780 S = new (Context) ShuffleVectorExpr(Empty);
2781 break;
2782
2783 case EXPR_CONVERT_VECTOR:
2784 S = new (Context) ConvertVectorExpr(Empty);
2785 break;
2786
2787 case EXPR_BLOCK:
2788 S = new (Context) BlockExpr(Empty);
2789 break;
2790
2791 case EXPR_GENERIC_SELECTION:
2792 S = GenericSelectionExpr::CreateEmpty(
2793 Context,
2794 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
2795 break;
2796
2797 case EXPR_OBJC_STRING_LITERAL:
2798 S = new (Context) ObjCStringLiteral(Empty);
2799 break;
2800
2801 case EXPR_OBJC_BOXED_EXPRESSION:
2802 S = new (Context) ObjCBoxedExpr(Empty);
2803 break;
2804
2805 case EXPR_OBJC_ARRAY_LITERAL:
2806 S = ObjCArrayLiteral::CreateEmpty(Context,
2807 Record[ASTStmtReader::NumExprFields]);
2808 break;
2809
2810 case EXPR_OBJC_DICTIONARY_LITERAL:
2811 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2812 Record[ASTStmtReader::NumExprFields],
2813 Record[ASTStmtReader::NumExprFields + 1]);
2814 break;
2815
2816 case EXPR_OBJC_ENCODE:
2817 S = new (Context) ObjCEncodeExpr(Empty);
2818 break;
2819
2820 case EXPR_OBJC_SELECTOR_EXPR:
2821 S = new (Context) ObjCSelectorExpr(Empty);
2822 break;
2823
2824 case EXPR_OBJC_PROTOCOL_EXPR:
2825 S = new (Context) ObjCProtocolExpr(Empty);
2826 break;
2827
2828 case EXPR_OBJC_IVAR_REF_EXPR:
2829 S = new (Context) ObjCIvarRefExpr(Empty);
2830 break;
2831
2832 case EXPR_OBJC_PROPERTY_REF_EXPR:
2833 S = new (Context) ObjCPropertyRefExpr(Empty);
2834 break;
2835
2836 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2837 S = new (Context) ObjCSubscriptRefExpr(Empty);
2838 break;
2839
2840 case EXPR_OBJC_KVC_REF_EXPR:
2841 llvm_unreachable("mismatching AST file")::llvm::llvm_unreachable_internal("mismatching AST file", "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 2841)
;
2842
2843 case EXPR_OBJC_MESSAGE_EXPR:
2844 S = ObjCMessageExpr::CreateEmpty(Context,
2845 Record[ASTStmtReader::NumExprFields],
2846 Record[ASTStmtReader::NumExprFields + 1]);
2847 break;
2848
2849 case EXPR_OBJC_ISA:
2850 S = new (Context) ObjCIsaExpr(Empty);
2851 break;
2852
2853 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2854 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2855 break;
2856
2857 case EXPR_OBJC_BRIDGED_CAST:
2858 S = new (Context) ObjCBridgedCastExpr(Empty);
2859 break;
2860
2861 case STMT_OBJC_FOR_COLLECTION:
2862 S = new (Context) ObjCForCollectionStmt(Empty);
2863 break;
2864
2865 case STMT_OBJC_CATCH:
2866 S = new (Context) ObjCAtCatchStmt(Empty);
2867 break;
2868
2869 case STMT_OBJC_FINALLY:
2870 S = new (Context) ObjCAtFinallyStmt(Empty);
2871 break;
2872
2873 case STMT_OBJC_AT_TRY:
2874 S = ObjCAtTryStmt::CreateEmpty(Context,
2875 Record[ASTStmtReader::NumStmtFields],
2876 Record[ASTStmtReader::NumStmtFields + 1]);
2877 break;
2878
2879 case STMT_OBJC_AT_SYNCHRONIZED:
2880 S = new (Context) ObjCAtSynchronizedStmt(Empty);
2881 break;
2882
2883 case STMT_OBJC_AT_THROW:
2884 S = new (Context) ObjCAtThrowStmt(Empty);
2885 break;
2886
2887 case STMT_OBJC_AUTORELEASE_POOL:
2888 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2889 break;
2890
2891 case EXPR_OBJC_BOOL_LITERAL:
2892 S = new (Context) ObjCBoolLiteralExpr(Empty);
2893 break;
2894
2895 case EXPR_OBJC_AVAILABILITY_CHECK:
2896 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
2897 break;
2898
2899 case STMT_SEH_LEAVE:
2900 S = new (Context) SEHLeaveStmt(Empty);
2901 break;
2902
2903 case STMT_SEH_EXCEPT:
2904 S = new (Context) SEHExceptStmt(Empty);
2905 break;
2906
2907 case STMT_SEH_FINALLY:
2908 S = new (Context) SEHFinallyStmt(Empty);
2909 break;
2910
2911 case STMT_SEH_TRY:
2912 S = new (Context) SEHTryStmt(Empty);
2913 break;
2914
2915 case STMT_CXX_CATCH:
2916 S = new (Context) CXXCatchStmt(Empty);
2917 break;
2918
2919 case STMT_CXX_TRY:
2920 S = CXXTryStmt::Create(Context, Empty,
2921 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
2922 break;
2923
2924 case STMT_CXX_FOR_RANGE:
2925 S = new (Context) CXXForRangeStmt(Empty);
2926 break;
2927
2928 case STMT_MS_DEPENDENT_EXISTS:
2929 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2930 NestedNameSpecifierLoc(),
2931 DeclarationNameInfo(),
2932 nullptr);
2933 break;
2934
2935 case STMT_OMP_PARALLEL_DIRECTIVE:
2936 S =
2937 OMPParallelDirective::CreateEmpty(Context,
2938 Record[ASTStmtReader::NumStmtFields],
2939 Empty);
2940 break;
2941
2942 case STMT_OMP_SIMD_DIRECTIVE: {
2943 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2944 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2945 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
2946 CollapsedNum, Empty);
2947 break;
2948 }
2949
2950 case STMT_OMP_FOR_DIRECTIVE: {
2951 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2952 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2953 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2954 Empty);
2955 break;
2956 }
2957
2958 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
2959 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2960 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2961 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2962 Empty);
2963 break;
2964 }
2965
2966 case STMT_OMP_SECTIONS_DIRECTIVE:
2967 S = OMPSectionsDirective::CreateEmpty(
2968 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2969 break;
2970
2971 case STMT_OMP_SECTION_DIRECTIVE:
2972 S = OMPSectionDirective::CreateEmpty(Context, Empty);
2973 break;
2974
2975 case STMT_OMP_SINGLE_DIRECTIVE:
2976 S = OMPSingleDirective::CreateEmpty(
2977 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2978 break;
2979
2980 case STMT_OMP_MASTER_DIRECTIVE:
2981 S = OMPMasterDirective::CreateEmpty(Context, Empty);
2982 break;
2983
2984 case STMT_OMP_CRITICAL_DIRECTIVE:
2985 S = OMPCriticalDirective::CreateEmpty(
2986 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2987 break;
2988
2989 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
2990 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2991 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2992 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
2993 CollapsedNum, Empty);
2994 break;
2995 }
2996
2997 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
2998 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2999 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3000 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3001 CollapsedNum, Empty);
3002 break;
3003 }
3004
3005 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3006 S = OMPParallelSectionsDirective::CreateEmpty(
3007 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3008 break;
3009
3010 case STMT_OMP_TASK_DIRECTIVE:
3011 S = OMPTaskDirective::CreateEmpty(
3012 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3013 break;
3014
3015 case STMT_OMP_TASKYIELD_DIRECTIVE:
3016 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3017 break;
3018
3019 case STMT_OMP_BARRIER_DIRECTIVE:
3020 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3021 break;
3022
3023 case STMT_OMP_TASKWAIT_DIRECTIVE:
3024 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3025 break;
3026
3027 case STMT_OMP_TASKGROUP_DIRECTIVE:
3028 S = OMPTaskgroupDirective::CreateEmpty(
3029 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3030 break;
3031
3032 case STMT_OMP_FLUSH_DIRECTIVE:
3033 S = OMPFlushDirective::CreateEmpty(
3034 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3035 break;
3036
3037 case STMT_OMP_ORDERED_DIRECTIVE:
3038 S = OMPOrderedDirective::CreateEmpty(
3039 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3040 break;
3041
3042 case STMT_OMP_ATOMIC_DIRECTIVE:
3043 S = OMPAtomicDirective::CreateEmpty(
3044 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3045 break;
3046
3047 case STMT_OMP_TARGET_DIRECTIVE:
3048 S = OMPTargetDirective::CreateEmpty(
3049 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3050 break;
3051
3052 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3053 S = OMPTargetDataDirective::CreateEmpty(
3054 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3055 break;
3056
3057 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3058 S = OMPTargetEnterDataDirective::CreateEmpty(
3059 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3060 break;
3061
3062 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3063 S = OMPTargetExitDataDirective::CreateEmpty(
3064 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3065 break;
3066
3067 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3068 S = OMPTargetParallelDirective::CreateEmpty(
3069 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3070 break;
3071
3072 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3073 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3074 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3075 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3076 CollapsedNum, Empty);
3077 break;
3078 }
3079
3080 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3081 S = OMPTargetUpdateDirective::CreateEmpty(
3082 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3083 break;
3084
3085 case STMT_OMP_TEAMS_DIRECTIVE:
3086 S = OMPTeamsDirective::CreateEmpty(
3087 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3088 break;
3089
3090 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3091 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3092 break;
3093
3094 case STMT_OMP_CANCEL_DIRECTIVE:
3095 S = OMPCancelDirective::CreateEmpty(
3096 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3097 break;
3098
3099 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3100 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3101 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3102 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3103 Empty);
3104 break;
3105 }
3106
3107 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3108 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3109 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3110 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3111 CollapsedNum, Empty);
3112 break;
3113 }
3114
3115 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3116 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3117 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3118 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3119 CollapsedNum, Empty);
3120 break;
3121 }
3122
3123 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3124 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3125 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3126 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3127 CollapsedNum, Empty);
3128 break;
3129 }
3130
3131 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3132 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3133 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3134 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3135 CollapsedNum, Empty);
3136 break;
3137 }
3138
3139 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3140 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3141 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3142 S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3143 Context, NumClauses, CollapsedNum, Empty);
3144 break;
3145 }
3146
3147 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3148 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3149 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3150 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3151 Empty);
3152 break;
3153 }
3154
3155 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3156 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3157 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3158 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3159 CollapsedNum, Empty);
3160 break;
3161 }
3162
3163 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3164 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3165 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3166 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3167 CollapsedNum,
3168 Empty);
3169 break;
3170 }
3171
3172 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3173 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3174 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3175 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3176 CollapsedNum, Empty);
3177 break;
3178 }
3179
3180 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3181 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3182 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3183 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3184 CollapsedNum, Empty);
3185 break;
3186 }
3187
3188 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3189 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3190 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3191 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3192 Empty);
3193 break;
3194 }
3195
3196 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
3197 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3198 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3199 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3200 CollapsedNum, Empty);
3201 break;
3202 }
3203
3204 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3205 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3206 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3207 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3208 CollapsedNum, Empty);
3209 break;
3210 }
3211
3212 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3213 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3214 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3215 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3216 Context, NumClauses, CollapsedNum, Empty);
3217 break;
3218 }
3219
3220 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3221 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3222 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3223 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3224 Context, NumClauses, CollapsedNum, Empty);
3225 break;
3226 }
3227
3228 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
3229 S = OMPTargetTeamsDirective::CreateEmpty(
3230 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3231 break;
3232
3233 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3234 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3235 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3236 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3237 CollapsedNum, Empty);
3238 break;
3239 }
3240
3241 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3242 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3243 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3244 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3245 Context, NumClauses, CollapsedNum, Empty);
3246 break;
3247 }
3248
3249 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3250 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3251 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3252 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3253 Context, NumClauses, CollapsedNum, Empty);
3254 break;
3255 }
3256
3257 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3258 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3259 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3260 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3261 Context, NumClauses, CollapsedNum, Empty);
3262 break;
3263 }
3264
3265 case EXPR_CXX_OPERATOR_CALL:
3266 S = CXXOperatorCallExpr::CreateEmpty(
3267 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3268 break;
3269
3270 case EXPR_CXX_MEMBER_CALL:
3271 S = CXXMemberCallExpr::CreateEmpty(
3272 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3273 break;
3274
3275 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3276 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3277 break;
3278
3279 case EXPR_CXX_CONSTRUCT:
3280 S = CXXConstructExpr::CreateEmpty(
3281 Context,
3282 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3283 break;
3284
3285 case EXPR_CXX_INHERITED_CTOR_INIT:
3286 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3287 break;
3288
3289 case EXPR_CXX_TEMPORARY_OBJECT:
3290 S = CXXTemporaryObjectExpr::CreateEmpty(
3291 Context,
3292 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3293 break;
3294
3295 case EXPR_CXX_STATIC_CAST:
3296 S = CXXStaticCastExpr::CreateEmpty(Context,
3297 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3298 break;
3299
3300 case EXPR_CXX_DYNAMIC_CAST:
3301 S = CXXDynamicCastExpr::CreateEmpty(Context,
3302 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3303 break;
3304
3305 case EXPR_CXX_REINTERPRET_CAST:
3306 S = CXXReinterpretCastExpr::CreateEmpty(Context,
3307 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3308 break;
3309
3310 case EXPR_CXX_CONST_CAST:
3311 S = CXXConstCastExpr::CreateEmpty(Context);
3312 break;
3313
3314 case EXPR_CXX_FUNCTIONAL_CAST:
3315 S = CXXFunctionalCastExpr::CreateEmpty(Context,
3316 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3317 break;
3318
3319 case EXPR_USER_DEFINED_LITERAL:
3320 S = UserDefinedLiteral::CreateEmpty(
3321 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3322 break;
3323
3324 case EXPR_CXX_STD_INITIALIZER_LIST:
3325 S = new (Context) CXXStdInitializerListExpr(Empty);
3326 break;
3327
3328 case EXPR_CXX_BOOL_LITERAL:
3329 S = new (Context) CXXBoolLiteralExpr(Empty);
3330 break;
3331
3332 case EXPR_CXX_NULL_PTR_LITERAL:
3333 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3334 break;
3335
3336 case EXPR_CXX_TYPEID_EXPR:
3337 S = new (Context) CXXTypeidExpr(Empty, true);
3338 break;
3339
3340 case EXPR_CXX_TYPEID_TYPE:
3341 S = new (Context) CXXTypeidExpr(Empty, false);
3342 break;
3343
3344 case EXPR_CXX_UUIDOF_EXPR:
3345 S = new (Context) CXXUuidofExpr(Empty, true);
3346 break;
3347
3348 case EXPR_CXX_PROPERTY_REF_EXPR:
3349 S = new (Context) MSPropertyRefExpr(Empty);
3350 break;
3351
3352 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3353 S = new (Context) MSPropertySubscriptExpr(Empty);
3354 break;
3355
3356 case EXPR_CXX_UUIDOF_TYPE:
3357 S = new (Context) CXXUuidofExpr(Empty, false);
3358 break;
3359
3360 case EXPR_CXX_THIS:
3361 S = new (Context) CXXThisExpr(Empty);
3362 break;
3363
3364 case EXPR_CXX_THROW:
3365 S = new (Context) CXXThrowExpr(Empty);
3366 break;
3367
3368 case EXPR_CXX_DEFAULT_ARG:
3369 S = new (Context) CXXDefaultArgExpr(Empty);
3370 break;
3371
3372 case EXPR_CXX_DEFAULT_INIT:
3373 S = new (Context) CXXDefaultInitExpr(Empty);
3374 break;
3375
3376 case EXPR_CXX_BIND_TEMPORARY:
3377 S = new (Context) CXXBindTemporaryExpr(Empty);
3378 break;
3379
3380 case EXPR_CXX_SCALAR_VALUE_INIT:
3381 S = new (Context) CXXScalarValueInitExpr(Empty);
3382 break;
3383
3384 case EXPR_CXX_NEW:
3385 S = CXXNewExpr::CreateEmpty(
3386 Context,
3387 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3388 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3389 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3390 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
3391 break;
3392
3393 case EXPR_CXX_DELETE:
3394 S = new (Context) CXXDeleteExpr(Empty);
3395 break;
3396
3397 case EXPR_CXX_PSEUDO_DESTRUCTOR:
3398 S = new (Context) CXXPseudoDestructorExpr(Empty);
3399 break;
3400
3401 case EXPR_EXPR_WITH_CLEANUPS:
3402 S = ExprWithCleanups::Create(Context, Empty,
3403 Record[ASTStmtReader::NumExprFields]);
3404 break;
3405
3406 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
3407 S = CXXDependentScopeMemberExpr::CreateEmpty(
3408 Context,
3409 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3410 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3411 /*HasFirstQualifierFoundInScope=*/
3412 Record[ASTStmtReader::NumExprFields + 2]);
3413 break;
3414
3415 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
3416 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
3417 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3418 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3419 ? Record[ASTStmtReader::NumExprFields + 1]
3420 : 0);
3421 break;
3422
3423 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
3424 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
3425 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3426 break;
3427
3428 case EXPR_CXX_UNRESOLVED_MEMBER:
3429 S = UnresolvedMemberExpr::CreateEmpty(
3430 Context,
3431 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3432 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3433 /*NumTemplateArgs=*/
3434 Record[ASTStmtReader::NumExprFields + 1]
3435 ? Record[ASTStmtReader::NumExprFields + 2]
3436 : 0);
3437 break;
3438
3439 case EXPR_CXX_UNRESOLVED_LOOKUP:
3440 S = UnresolvedLookupExpr::CreateEmpty(
3441 Context,
3442 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3443 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3444 /*NumTemplateArgs=*/
3445 Record[ASTStmtReader::NumExprFields + 1]
3446 ? Record[ASTStmtReader::NumExprFields + 2]
3447 : 0);
3448 break;
3449
3450 case EXPR_TYPE_TRAIT:
3451 S = TypeTraitExpr::CreateDeserialized(Context,
3452 Record[ASTStmtReader::NumExprFields]);
3453 break;
3454
3455 case EXPR_ARRAY_TYPE_TRAIT:
3456 S = new (Context) ArrayTypeTraitExpr(Empty);
3457 break;
3458
3459 case EXPR_CXX_EXPRESSION_TRAIT:
3460 S = new (Context) ExpressionTraitExpr(Empty);
3461 break;
3462
3463 case EXPR_CXX_NOEXCEPT:
3464 S = new (Context) CXXNoexceptExpr(Empty);
3465 break;
3466
3467 case EXPR_PACK_EXPANSION:
3468 S = new (Context) PackExpansionExpr(Empty);
3469 break;
3470
3471 case EXPR_SIZEOF_PACK:
3472 S = SizeOfPackExpr::CreateDeserialized(
3473 Context,
3474 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
3475 break;
3476
3477 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3478 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3479 break;
3480
3481 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3482 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3483 break;
3484
3485 case EXPR_FUNCTION_PARM_PACK:
3486 S = FunctionParmPackExpr::CreateEmpty(Context,
3487 Record[ASTStmtReader::NumExprFields]);
3488 break;
3489
3490 case EXPR_MATERIALIZE_TEMPORARY:
3491 S = new (Context) MaterializeTemporaryExpr(Empty);
3492 break;
3493
3494 case EXPR_CXX_FOLD:
3495 S = new (Context) CXXFoldExpr(Empty);
3496 break;
3497
3498 case EXPR_OPAQUE_VALUE:
3499 S = new (Context) OpaqueValueExpr(Empty);
3500 break;
3501
3502 case EXPR_CUDA_KERNEL_CALL:
3503 S = CUDAKernelCallExpr::CreateEmpty(
3504 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3505 break;
3506
3507 case EXPR_ASTYPE:
3508 S = new (Context) AsTypeExpr(Empty);
3509 break;
3510
3511 case EXPR_PSEUDO_OBJECT: {
3512 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3513 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3514 break;
3515 }
3516
3517 case EXPR_ATOMIC:
3518 S = new (Context) AtomicExpr(Empty);
3519 break;
3520
3521 case EXPR_LAMBDA: {
3522 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
3523 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
3524 break;
3525 }
3526
3527 case STMT_COROUTINE_BODY: {
3528 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3529 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3530 break;
3531 }
3532
3533 case STMT_CORETURN:
3534 S = new (Context) CoreturnStmt(Empty);
3535 break;
3536
3537 case EXPR_COAWAIT:
3538 S = new (Context) CoawaitExpr(Empty);
3539 break;
3540
3541 case EXPR_COYIELD:
3542 S = new (Context) CoyieldExpr(Empty);
3543 break;
3544
3545 case EXPR_DEPENDENT_COAWAIT:
3546 S = new (Context) DependentCoawaitExpr(Empty);
3547 break;
3548
3549 case EXPR_CONCEPT_SPECIALIZATION:
3550 unsigned numTemplateArgs = Record[ASTStmtReader::NumExprFields];
3551 S = ConceptSpecializationExpr::Create(Context, Empty, numTemplateArgs);
3552 break;
3553
3554 }
3555
3556 // We hit a STMT_STOP, so we're done with this expression.
3557 if (Finished)
3558 break;
3559
3560 ++NumStatementsRead;
3561
3562 if (S && !IsStmtReference) {
3563 Reader.Visit(S);
3564 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3565 }
3566
3567 assert(Record.getIdx() == Record.size() &&((Record.getIdx() == Record.size() && "Invalid deserialization of statement"
) ? static_cast<void> (0) : __assert_fail ("Record.getIdx() == Record.size() && \"Invalid deserialization of statement\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 3568, __PRETTY_FUNCTION__))
3568 "Invalid deserialization of statement")((Record.getIdx() == Record.size() && "Invalid deserialization of statement"
) ? static_cast<void> (0) : __assert_fail ("Record.getIdx() == Record.size() && \"Invalid deserialization of statement\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 3568, __PRETTY_FUNCTION__))
;
3569 StmtStack.push_back(S);
3570 }
3571Done:
3572 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!")((StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!"
) ? static_cast<void> (0) : __assert_fail ("StmtStack.size() > PrevNumStmts && \"Read too many sub-stmts!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 3572, __PRETTY_FUNCTION__))
;
3573 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!")((StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!"
) ? static_cast<void> (0) : __assert_fail ("StmtStack.size() == PrevNumStmts + 1 && \"Extra expressions on stack!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/clang/lib/Serialization/ASTReaderStmt.cpp"
, 3573, __PRETTY_FUNCTION__))
;
3574 return StmtStack.pop_back_val();
3575}

/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/llvm/include/llvm/Bitstream/BitstreamReader.h

1//===- BitstreamReader.h - Low-level bitstream reader interface -*- C++ -*-===//
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// This header defines the BitstreamReader class. This class can be used to
10// read an arbitrary bitstream, regardless of its contents.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_BITSTREAM_BITSTREAMREADER_H
15#define LLVM_BITSTREAM_BITSTREAMREADER_H
16
17#include "llvm/ADT/ArrayRef.h"
18#include "llvm/ADT/SmallVector.h"
19#include "llvm/Bitstream/BitCodes.h"
20#include "llvm/Support/Endian.h"
21#include "llvm/Support/ErrorHandling.h"
22#include "llvm/Support/MathExtras.h"
23#include "llvm/Support/MemoryBuffer.h"
24#include <algorithm>
25#include <cassert>
26#include <climits>
27#include <cstddef>
28#include <cstdint>
29#include <memory>
30#include <string>
31#include <utility>
32#include <vector>
33
34namespace llvm {
35
36/// This class maintains the abbreviations read from a block info block.
37class BitstreamBlockInfo {
38public:
39 /// This contains information emitted to BLOCKINFO_BLOCK blocks. These
40 /// describe abbreviations that all blocks of the specified ID inherit.
41 struct BlockInfo {
42 unsigned BlockID = 0;
43 std::vector<std::shared_ptr<BitCodeAbbrev>> Abbrevs;
44 std::string Name;
45 std::vector<std::pair<unsigned, std::string>> RecordNames;
46 };
47
48private:
49 std::vector<BlockInfo> BlockInfoRecords;
50
51public:
52 /// If there is block info for the specified ID, return it, otherwise return
53 /// null.
54 const BlockInfo *getBlockInfo(unsigned BlockID) const {
55 // Common case, the most recent entry matches BlockID.
56 if (!BlockInfoRecords.empty() && BlockInfoRecords.back().BlockID == BlockID)
57 return &BlockInfoRecords.back();
58
59 for (unsigned i = 0, e = static_cast<unsigned>(BlockInfoRecords.size());
60 i != e; ++i)
61 if (BlockInfoRecords[i].BlockID == BlockID)
62 return &BlockInfoRecords[i];
63 return nullptr;
64 }
65
66 BlockInfo &getOrCreateBlockInfo(unsigned BlockID) {
67 if (const BlockInfo *BI = getBlockInfo(BlockID))
68 return *const_cast<BlockInfo*>(BI);
69
70 // Otherwise, add a new record.
71 BlockInfoRecords.emplace_back();
72 BlockInfoRecords.back().BlockID = BlockID;
73 return BlockInfoRecords.back();
74 }
75};
76
77/// This represents a position within a bitstream. There may be multiple
78/// independent cursors reading within one bitstream, each maintaining their
79/// own local state.
80class SimpleBitstreamCursor {
81 ArrayRef<uint8_t> BitcodeBytes;
82 size_t NextChar = 0;
83
84public:
85 /// This is the current data we have pulled from the stream but have not
86 /// returned to the client. This is specifically and intentionally defined to
87 /// follow the word size of the host machine for efficiency. We use word_t in
88 /// places that are aware of this to make it perfectly explicit what is going
89 /// on.
90 using word_t = size_t;
91
92private:
93 word_t CurWord = 0;
94
95 /// This is the number of bits in CurWord that are valid. This is always from
96 /// [0...bits_of(size_t)-1] inclusive.
97 unsigned BitsInCurWord = 0;
98
99public:
100 static const constexpr size_t MaxChunkSize = sizeof(word_t) * 8;
101
102 SimpleBitstreamCursor() = default;
103 explicit SimpleBitstreamCursor(ArrayRef<uint8_t> BitcodeBytes)
104 : BitcodeBytes(BitcodeBytes) {}
105 explicit SimpleBitstreamCursor(StringRef BitcodeBytes)
106 : BitcodeBytes(arrayRefFromStringRef(BitcodeBytes)) {}
107 explicit SimpleBitstreamCursor(MemoryBufferRef BitcodeBytes)
108 : SimpleBitstreamCursor(BitcodeBytes.getBuffer()) {}
109
110 bool canSkipToPos(size_t pos) const {
111 // pos can be skipped to if it is a valid address or one byte past the end.
112 return pos <= BitcodeBytes.size();
113 }
114
115 bool AtEndOfStream() {
116 return BitsInCurWord == 0 && BitcodeBytes.size() <= NextChar;
117 }
118
119 /// Return the bit # of the bit we are reading.
120 uint64_t GetCurrentBitNo() const {
121 return NextChar*CHAR_BIT8 - BitsInCurWord;
122 }
123
124 // Return the byte # of the current bit.
125 uint64_t getCurrentByteNo() const { return GetCurrentBitNo() / 8; }
126
127 ArrayRef<uint8_t> getBitcodeBytes() const { return BitcodeBytes; }
128
129 /// Reset the stream to the specified bit number.
130 Error JumpToBit(uint64_t BitNo) {
131 size_t ByteNo = size_t(BitNo/8) & ~(sizeof(word_t)-1);
132 unsigned WordBitNo = unsigned(BitNo & (sizeof(word_t)*8-1));
133 assert(canSkipToPos(ByteNo) && "Invalid location")((canSkipToPos(ByteNo) && "Invalid location") ? static_cast
<void> (0) : __assert_fail ("canSkipToPos(ByteNo) && \"Invalid location\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/llvm/include/llvm/Bitstream/BitstreamReader.h"
, 133, __PRETTY_FUNCTION__))
;
134
135 // Move the cursor to the right word.
136 NextChar = ByteNo;
137 BitsInCurWord = 0;
138
139 // Skip over any bits that are already consumed.
140 if (WordBitNo) {
141 if (Expected<word_t> Res = Read(WordBitNo))
142 return Error::success();
143 else
144 return Res.takeError();
145 }
146
147 return Error::success();
148 }
149
150 /// Get a pointer into the bitstream at the specified byte offset.
151 const uint8_t *getPointerToByte(uint64_t ByteNo, uint64_t NumBytes) {
152 return BitcodeBytes.data() + ByteNo;
153 }
154
155 /// Get a pointer into the bitstream at the specified bit offset.
156 ///
157 /// The bit offset must be on a byte boundary.
158 const uint8_t *getPointerToBit(uint64_t BitNo, uint64_t NumBytes) {
159 assert(!(BitNo % 8) && "Expected bit on byte boundary")((!(BitNo % 8) && "Expected bit on byte boundary") ? static_cast
<void> (0) : __assert_fail ("!(BitNo % 8) && \"Expected bit on byte boundary\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/llvm/include/llvm/Bitstream/BitstreamReader.h"
, 159, __PRETTY_FUNCTION__))
;
160 return getPointerToByte(BitNo / 8, NumBytes);
161 }
162
163 Error fillCurWord() {
164 if (NextChar >= BitcodeBytes.size())
165 return createStringError(std::errc::io_error,
166 "Unexpected end of file reading %u of %u bytes",
167 NextChar, BitcodeBytes.size());
168
169 // Read the next word from the stream.
170 const uint8_t *NextCharPtr = BitcodeBytes.data() + NextChar;
171 unsigned BytesRead;
172 if (BitcodeBytes.size() >= NextChar + sizeof(word_t)) {
173 BytesRead = sizeof(word_t);
174 CurWord =
175 support::endian::read<word_t, support::little, support::unaligned>(
176 NextCharPtr);
177 } else {
178 // Short read.
179 BytesRead = BitcodeBytes.size() - NextChar;
180 CurWord = 0;
181 for (unsigned B = 0; B != BytesRead; ++B)
182 CurWord |= uint64_t(NextCharPtr[B]) << (B * 8);
183 }
184 NextChar += BytesRead;
185 BitsInCurWord = BytesRead * 8;
186 return Error::success();
187 }
188
189 Expected<word_t> Read(unsigned NumBits) {
190 static const unsigned BitsInWord = MaxChunkSize;
191
192 assert(NumBits && NumBits <= BitsInWord &&((NumBits && NumBits <= BitsInWord && "Cannot return zero or more than BitsInWord bits!"
) ? static_cast<void> (0) : __assert_fail ("NumBits && NumBits <= BitsInWord && \"Cannot return zero or more than BitsInWord bits!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/llvm/include/llvm/Bitstream/BitstreamReader.h"
, 193, __PRETTY_FUNCTION__))
9
Assuming 'NumBits' is not equal to 0
10
Assuming 'NumBits' is <= 'BitsInWord'
11
'?' condition is true
193 "Cannot return zero or more than BitsInWord bits!")((NumBits && NumBits <= BitsInWord && "Cannot return zero or more than BitsInWord bits!"
) ? static_cast<void> (0) : __assert_fail ("NumBits && NumBits <= BitsInWord && \"Cannot return zero or more than BitsInWord bits!\""
, "/build/llvm-toolchain-snapshot-10~+201911111502510600c19528f1809/llvm/include/llvm/Bitstream/BitstreamReader.h"
, 193, __PRETTY_FUNCTION__))
;
194
195 static const unsigned Mask = sizeof(word_t) > 4 ? 0x3f : 0x1f;
12
'?' condition is true
196
197 // If the field is fully contained by CurWord, return it quickly.
198 if (BitsInCurWord >= NumBits) {
13
Assuming 'NumBits' is > field 'BitsInCurWord'
14
Taking false branch
199 word_t R = CurWord & (~word_t(0) >> (BitsInWord - NumBits));
200
201 // Use a mask to avoid undefined behavior.
202 CurWord >>= (NumBits & Mask);
203
204 BitsInCurWord -= NumBits;
205 return R;
206 }
207
208 word_t R = BitsInCurWord
14.1
Field 'BitsInCurWord' is not equal to 0
14.1
Field 'BitsInCurWord' is not equal to 0
? CurWord : 0;
15
'?' condition is true
209 unsigned BitsLeft = NumBits - BitsInCurWord;
210
211 if (Error fillResult = fillCurWord())
16
Assuming the condition is false
17
Taking false branch
212 return std::move(fillResult);
213
214 // If we run out of data, abort.
215 if (BitsLeft > BitsInCurWord)
18
Assuming 'BitsLeft' is <= field 'BitsInCurWord'
19
Taking false branch
216 return createStringError(std::errc::io_error,
217 "Unexpected end of file reading %u of %u bits",
218 BitsInCurWord, BitsLeft);
219
220 word_t R2 = CurWord & (~word_t(0) >> (BitsInWord - BitsLeft));
20
The result of the right shift is undefined due to shifting by '64', which is greater or equal to the width of type 'llvm::SimpleBitstreamCursor::word_t'
221
222 // Use a mask to avoid undefined behavior.
223 CurWord >>= (BitsLeft & Mask);
224
225 BitsInCurWord -= BitsLeft;
226
227 R |= R2 << (NumBits - BitsLeft);
228
229 return R;
230 }
231
232 Expected<uint32_t> ReadVBR(unsigned NumBits) {
233 Expected<unsigned> MaybeRead = Read(NumBits);
234 if (!MaybeRead)
235 return MaybeRead;
236 uint32_t Piece = MaybeRead.get();
237
238 if ((Piece & (1U << (NumBits-1))) == 0)
239 return Piece;
240
241 uint32_t Result = 0;
242 unsigned NextBit = 0;
243 while (true) {
244 Result |= (Piece & ((1U << (NumBits-1))-1)) << NextBit;
245
246 if ((Piece & (1U << (NumBits-1))) == 0)
247 return Result;
248
249 NextBit += NumBits-1;
250 MaybeRead = Read(NumBits);
251 if (!MaybeRead)
252 return MaybeRead;
253 Piece = MaybeRead.get();
254 }
255 }
256
257 // Read a VBR that may have a value up to 64-bits in size. The chunk size of
258 // the VBR must still be <= 32 bits though.
259 Expected<uint64_t> ReadVBR64(unsigned NumBits) {
260 Expected<uint64_t> MaybeRead = Read(NumBits);
261 if (!MaybeRead)
262 return MaybeRead;
263 uint32_t Piece = MaybeRead.get();
264
265 if ((Piece & (1U << (NumBits-1))) == 0)
266 return uint64_t(Piece);
267
268 uint64_t Result = 0;
269 unsigned NextBit = 0;
270 while (true) {
271 Result |= uint64_t(Piece & ((1U << (NumBits-1))-1)) << NextBit;
272
273 if ((Piece & (1U << (NumBits-1))) == 0)
274 return Result;
275
276 NextBit += NumBits-1;
277 MaybeRead = Read(NumBits);
278 if (!MaybeRead)
279 return MaybeRead;
280 Piece = MaybeRead.get();
281 }
282 }
283
284 void SkipToFourByteBoundary() {
285 // If word_t is 64-bits and if we've read less than 32 bits, just dump
286 // the bits we have up to the next 32-bit boundary.
287 if (sizeof(word_t) > 4 &&
288 BitsInCurWord >= 32) {
289 CurWord >>= BitsInCurWord-32;
290 BitsInCurWord = 32;
291 return;
292 }
293
294 BitsInCurWord = 0;
295 }
296
297 /// Return the size of the stream in bytes.
298 size_t SizeInBytes() const { return BitcodeBytes.size(); }
299
300 /// Skip to the end of the file.
301 void skipToEnd() { NextChar = BitcodeBytes.size(); }
302};
303
304/// When advancing through a bitstream cursor, each advance can discover a few
305/// different kinds of entries:
306struct BitstreamEntry {
307 enum {
308 Error, // Malformed bitcode was found.
309 EndBlock, // We've reached the end of the current block, (or the end of the
310 // file, which is treated like a series of EndBlock records.
311 SubBlock, // This is the start of a new subblock of a specific ID.
312 Record // This is a record with a specific AbbrevID.
313 } Kind;
314
315 unsigned ID;
316
317 static BitstreamEntry getError() {
318 BitstreamEntry E; E.Kind = Error; return E;
319 }
320
321 static BitstreamEntry getEndBlock() {
322 BitstreamEntry E; E.Kind = EndBlock; return E;
323 }
324
325 static BitstreamEntry getSubBlock(unsigned ID) {
326 BitstreamEntry E; E.Kind = SubBlock; E.ID = ID; return E;
327 }
328
329 static BitstreamEntry getRecord(unsigned AbbrevID) {
330 BitstreamEntry E; E.Kind = Record; E.ID = AbbrevID; return E;
331 }
332};
333
334/// This represents a position within a bitcode file, implemented on top of a
335/// SimpleBitstreamCursor.
336///
337/// Unlike iterators, BitstreamCursors are heavy-weight objects that should not
338/// be passed by value.
339class BitstreamCursor : SimpleBitstreamCursor {
340 // This is the declared size of code values used for the current block, in
341 // bits.
342 unsigned CurCodeSize = 2;
343
344 /// Abbrevs installed at in this block.
345 std::vector<std::shared_ptr<BitCodeAbbrev>> CurAbbrevs;
346
347 struct Block {
348 unsigned PrevCodeSize;
349 std::vector<std::shared_ptr<BitCodeAbbrev>> PrevAbbrevs;
350
351 explicit Block(unsigned PCS) : PrevCodeSize(PCS) {}
352 };
353
354 /// This tracks the codesize of parent blocks.
355 SmallVector<Block, 8> BlockScope;
356
357 BitstreamBlockInfo *BlockInfo = nullptr;
358
359public:
360 static const size_t MaxChunkSize = sizeof(word_t) * 8;
361
362 BitstreamCursor() = default;
363 explicit BitstreamCursor(ArrayRef<uint8_t> BitcodeBytes)
364 : SimpleBitstreamCursor(BitcodeBytes) {}
365 explicit BitstreamCursor(StringRef BitcodeBytes)
366 : SimpleBitstreamCursor(BitcodeBytes) {}
367 explicit BitstreamCursor(MemoryBufferRef BitcodeBytes)
368 : SimpleBitstreamCursor(BitcodeBytes) {}
369
370 using SimpleBitstreamCursor::AtEndOfStream;
371 using SimpleBitstreamCursor::canSkipToPos;
372 using SimpleBitstreamCursor::fillCurWord;
373 using SimpleBitstreamCursor::getBitcodeBytes;
374 using SimpleBitstreamCursor::GetCurrentBitNo;
375 using SimpleBitstreamCursor::getCurrentByteNo;
376 using SimpleBitstreamCursor::getPointerToByte;
377 using SimpleBitstreamCursor::JumpToBit;
378 using SimpleBitstreamCursor::Read;
379 using SimpleBitstreamCursor::ReadVBR;
380 using SimpleBitstreamCursor::ReadVBR64;
381 using SimpleBitstreamCursor::SizeInBytes;
382 using SimpleBitstreamCursor::skipToEnd;
383
384 /// Return the number of bits used to encode an abbrev #.
385 unsigned getAbbrevIDWidth() const { return CurCodeSize; }
386
387 /// Flags that modify the behavior of advance().
388 enum {
389 /// If this flag is used, the advance() method does not automatically pop
390 /// the block scope when the end of a block is reached.
391 AF_DontPopBlockAtEnd = 1,
392
393 /// If this flag is used, abbrev entries are returned just like normal
394 /// records.
395 AF_DontAutoprocessAbbrevs = 2
396 };
397
398 /// Advance the current bitstream, returning the next entry in the stream.
399 Expected<BitstreamEntry> advance(unsigned Flags = 0) {
400 while (true) {
5
Loop condition is true. Entering loop body
401 if (AtEndOfStream())
6
Taking false branch
402 return BitstreamEntry::getError();
403
404 Expected<unsigned> MaybeCode = ReadCode();
7
Calling 'BitstreamCursor::ReadCode'
405 if (!MaybeCode)
406 return MaybeCode.takeError();
407 unsigned Code = MaybeCode.get();
408
409 if (Code == bitc::END_BLOCK) {
410 // Pop the end of the block unless Flags tells us not to.
411 if (!(Flags & AF_DontPopBlockAtEnd) && ReadBlockEnd())
412 return BitstreamEntry::getError();
413 return BitstreamEntry::getEndBlock();
414 }
415
416 if (Code == bitc::ENTER_SUBBLOCK) {
417 if (Expected<unsigned> MaybeSubBlock = ReadSubBlockID())
418 return BitstreamEntry::getSubBlock(MaybeSubBlock.get());
419 else
420 return MaybeSubBlock.takeError();
421 }
422
423 if (Code == bitc::DEFINE_ABBREV &&
424 !(Flags & AF_DontAutoprocessAbbrevs)) {
425 // We read and accumulate abbrev's, the client can't do anything with
426 // them anyway.
427 if (Error Err = ReadAbbrevRecord())
428 return std::move(Err);
429 continue;
430 }
431
432 return BitstreamEntry::getRecord(Code);
433 }
434 }
435
436 /// This is a convenience function for clients that don't expect any
437 /// subblocks. This just skips over them automatically.
438 Expected<BitstreamEntry> advanceSkippingSubblocks(unsigned Flags = 0) {
439 while (true) {
3
Loop condition is true. Entering loop body
440 // If we found a normal entry, return it.
441 Expected<BitstreamEntry> MaybeEntry = advance(Flags);
4
Calling 'BitstreamCursor::advance'
442 if (!MaybeEntry)
443 return MaybeEntry;
444 BitstreamEntry Entry = MaybeEntry.get();
445
446 if (Entry.Kind != BitstreamEntry::SubBlock)
447 return Entry;
448
449 // If we found a sub-block, just skip over it and check the next entry.
450 if (Error Err = SkipBlock())
451 return std::move(Err);
452 }
453 }
454
455 Expected<unsigned> ReadCode() { return Read(CurCodeSize); }
8
Calling 'SimpleBitstreamCursor::Read'
456
457 // Block header:
458 // [ENTER_SUBBLOCK, blockid, newcodelen, <align4bytes>, blocklen]
459
460 /// Having read the ENTER_SUBBLOCK code, read the BlockID for the block.
461 Expected<unsigned> ReadSubBlockID() { return ReadVBR(bitc::BlockIDWidth); }
462
463 /// Having read the ENTER_SUBBLOCK abbrevid and a BlockID, skip over the body
464 /// of this block.
465 Error SkipBlock() {
466 // Read and ignore the codelen value.
467 if (Expected<uint32_t> Res = ReadVBR(bitc::CodeLenWidth))
468 ; // Since we are skipping this block, we don't care what code widths are
469 // used inside of it.
470 else
471 return Res.takeError();
472
473 SkipToFourByteBoundary();
474 Expected<unsigned> MaybeNum = Read(bitc::BlockSizeWidth);
475 if (!MaybeNum)
476 return MaybeNum.takeError();
477 size_t NumFourBytes = MaybeNum.get();
478
479 // Check that the block wasn't partially defined, and that the offset isn't
480 // bogus.
481 size_t SkipTo = GetCurrentBitNo() + NumFourBytes * 4 * 8;
482 if (AtEndOfStream())
483 return createStringError(std::errc::illegal_byte_sequence,
484 "can't skip block: already at end of stream");
485 if (!canSkipToPos(SkipTo / 8))
486 return createStringError(std::errc::illegal_byte_sequence,
487 "can't skip to bit %zu from %" PRIu64"l" "u", SkipTo,
488 GetCurrentBitNo());
489
490 if (Error Res = JumpToBit(SkipTo))
491 return Res;
492
493 return Error::success();
494 }
495
496 /// Having read the ENTER_SUBBLOCK abbrevid, and enter the block.
497 Error EnterSubBlock(unsigned BlockID, unsigned *NumWordsP = nullptr);
498
499 bool ReadBlockEnd() {
500 if (BlockScope.empty()) return true;
501
502 // Block tail:
503 // [END_BLOCK, <align4bytes>]
504 SkipToFourByteBoundary();
505
506 popBlockScope();
507 return false;
508 }
509
510private:
511 void popBlockScope() {
512 CurCodeSize = BlockScope.back().PrevCodeSize;
513
514 CurAbbrevs = std::move(BlockScope.back().PrevAbbrevs);
515 BlockScope.pop_back();
516 }
517
518 //===--------------------------------------------------------------------===//
519 // Record Processing
520 //===--------------------------------------------------------------------===//
521
522public:
523 /// Return the abbreviation for the specified AbbrevId.
524 const BitCodeAbbrev *getAbbrev(unsigned AbbrevID) {
525 unsigned AbbrevNo = AbbrevID - bitc::FIRST_APPLICATION_ABBREV;
526 if (AbbrevNo >= CurAbbrevs.size())
527 report_fatal_error("Invalid abbrev number");
528 return CurAbbrevs[AbbrevNo].get();
529 }
530
531 /// Read the current record and discard it, returning the code for the record.
532 Expected<unsigned> skipRecord(unsigned AbbrevID);
533
534 Expected<unsigned> readRecord(unsigned AbbrevID,
535 SmallVectorImpl<uint64_t> &Vals,
536 StringRef *Blob = nullptr);
537
538 //===--------------------------------------------------------------------===//
539 // Abbrev Processing
540 //===--------------------------------------------------------------------===//
541 Error ReadAbbrevRecord();
542
543 /// Read and return a block info block from the bitstream. If an error was
544 /// encountered, return None.
545 ///
546 /// \param ReadBlockInfoNames Whether to read block/record name information in
547 /// the BlockInfo block. Only llvm-bcanalyzer uses this.
548 Expected<Optional<BitstreamBlockInfo>>
549 ReadBlockInfoBlock(bool ReadBlockInfoNames = false);
550
551 /// Set the block info to be used by this BitstreamCursor to interpret
552 /// abbreviated records.
553 void setBlockInfo(BitstreamBlockInfo *BI) { BlockInfo = BI; }
554};
555
556} // end llvm namespace
557
558#endif // LLVM_BITSTREAM_BITSTREAMREADER_H