Bug Summary

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

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name ASTReaderStmt.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=none -relaxed-aliasing -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -D CLANG_VENDOR="Debian " -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-10~++20200112100611+7fa5290d5bd/build-llvm/tools/clang/lib/Serialization -I /build/llvm-toolchain-snapshot-10~++20200112100611+7fa5290d5bd/clang/lib/Serialization -I /build/llvm-toolchain-snapshot-10~++20200112100611+7fa5290d5bd/clang/include -I /build/llvm-toolchain-snapshot-10~++20200112100611+7fa5290d5bd/build-llvm/tools/clang/include -I /build/llvm-toolchain-snapshot-10~++20200112100611+7fa5290d5bd/build-llvm/include -I /build/llvm-toolchain-snapshot-10~++20200112100611+7fa5290d5bd/llvm/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-10/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -std=c++14 -fdeprecated-macro -fdebug-compilation-dir /build/llvm-toolchain-snapshot-10~++20200112100611+7fa5290d5bd/build-llvm/tools/clang/lib/Serialization -fdebug-prefix-map=/build/llvm-toolchain-snapshot-10~++20200112100611+7fa5290d5bd=. -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-01-13-084841-49055-1 -x c++ /build/llvm-toolchain-snapshot-10~++20200112100611+7fa5290d5bd/clang/lib/Serialization/ASTReaderStmt.cpp

/build/llvm-toolchain-snapshot-10~++20200112100611+7fa5290d5bd/clang/lib/Serialization/ASTReaderStmt.cpp

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

/build/llvm-toolchain-snapshot-10~++20200112100611+7fa5290d5bd/llvm/include/llvm/Bitstream/BitstreamReader.h

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