Bug Summary

File:llvm/include/llvm/Bitstream/BitstreamReader.h
Warning:line 221, 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 -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-11/lib/clang/11.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-11~++20200309111110+2c36c23f347/build-llvm/tools/clang/lib/Serialization -I /build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/clang/lib/Serialization -I /build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/clang/include -I /build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/build-llvm/tools/clang/include -I /build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/build-llvm/include -I /build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/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-11/lib/clang/11.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-11~++20200309111110+2c36c23f347/build-llvm/tools/clang/lib/Serialization -fdebug-prefix-map=/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347=. -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-2020-03-09-184146-41876-1 -x c++ /build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/clang/lib/Serialization/ASTReaderStmt.cpp

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

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