Bug Summary

File: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 -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=none -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -D CLANG_VENDOR="Debian " -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-10~svn374877/build-llvm/tools/clang/lib/Serialization -I /build/llvm-toolchain-snapshot-10~svn374877/tools/clang/lib/Serialization -I /build/llvm-toolchain-snapshot-10~svn374877/tools/clang/include -I /build/llvm-toolchain-snapshot-10~svn374877/build-llvm/tools/clang/include -I /build/llvm-toolchain-snapshot-10~svn374877/build-llvm/include -I /build/llvm-toolchain-snapshot-10~svn374877/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~svn374877/build-llvm/tools/clang/lib/Serialization -fdebug-prefix-map=/build/llvm-toolchain-snapshot-10~svn374877=. -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fno-common -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -o /tmp/scan-build-2019-10-15-233810-7101-1 -x c++ /build/llvm-toolchain-snapshot-10~svn374877/tools/clang/lib/Serialization/ASTReaderStmt.cpp

/build/llvm-toolchain-snapshot-10~svn374877/tools/clang/lib/Serialization/ASTReaderStmt.cpp

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

/build/llvm-toolchain-snapshot-10~svn374877/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;
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~svn374877/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~svn374877/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~svn374877/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~svn374877/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