blob: f2338a1228df710a16f92e9082ae789637f7be17 [file] [log] [blame]
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001//===- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------------------===//
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Chris Lattner92ba5ff2009-04-27 05:14:47 +00006//
7//===----------------------------------------------------------------------===//
8//
9// Statement/expression deserialization. This implements the
Sebastian Redl2c499f62010-08-18 23:56:43 +000010// ASTReader::ReadStmt method.
Chris Lattner92ba5ff2009-04-27 05:14:47 +000011//
12//===----------------------------------------------------------------------===//
13
Saar Razfdf80e82019-12-06 01:30:21 +020014#include "clang/AST/ASTConcept.h"
Benjamin Kramer4ab984e2012-07-04 20:19:54 +000015#include "clang/AST/ASTContext.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000016#include "clang/AST/AttrIterator.h"
17#include "clang/AST/Decl.h"
18#include "clang/AST/DeclAccessPair.h"
Douglas Gregor5d3507d2009-09-09 23:08:42 +000019#include "clang/AST/DeclCXX.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000020#include "clang/AST/DeclGroup.h"
21#include "clang/AST/DeclObjC.h"
Douglas Gregorcdbc5392011-01-15 01:15:58 +000022#include "clang/AST/DeclTemplate.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000023#include "clang/AST/DeclarationName.h"
Haojian Wu67d25912020-03-16 13:43:40 +010024#include "clang/AST/DependenceFlags.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000025#include "clang/AST/Expr.h"
26#include "clang/AST/ExprCXX.h"
27#include "clang/AST/ExprObjC.h"
28#include "clang/AST/ExprOpenMP.h"
29#include "clang/AST/NestedNameSpecifier.h"
30#include "clang/AST/OpenMPClause.h"
31#include "clang/AST/OperationKinds.h"
32#include "clang/AST/Stmt.h"
33#include "clang/AST/StmtCXX.h"
34#include "clang/AST/StmtObjC.h"
35#include "clang/AST/StmtOpenMP.h"
Chris Lattner92ba5ff2009-04-27 05:14:47 +000036#include "clang/AST/StmtVisitor.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000037#include "clang/AST/TemplateBase.h"
38#include "clang/AST/Type.h"
39#include "clang/AST/UnresolvedSet.h"
40#include "clang/Basic/CapturedStmt.h"
41#include "clang/Basic/ExpressionTraits.h"
42#include "clang/Basic/LLVM.h"
43#include "clang/Basic/Lambda.h"
44#include "clang/Basic/LangOptions.h"
45#include "clang/Basic/OpenMPKinds.h"
46#include "clang/Basic/OperatorKinds.h"
47#include "clang/Basic/SourceLocation.h"
48#include "clang/Basic/Specifiers.h"
49#include "clang/Basic/TypeTraits.h"
John McCallf413f5e2013-05-03 00:10:13 +000050#include "clang/Lex/Token.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000051#include "clang/Serialization/ASTBitCodes.h"
Ilya Biryukovec3060c2020-03-02 16:07:09 +010052#include "clang/Serialization/ASTRecordReader.h"
Sam McCall6b3bede2020-03-27 19:42:49 +010053#include "llvm/ADT/BitmaskEnum.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000054#include "llvm/ADT/DenseMap.h"
Benjamin Kramer49038022012-02-04 13:45:25 +000055#include "llvm/ADT/SmallString.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000056#include "llvm/ADT/SmallVector.h"
57#include "llvm/ADT/StringRef.h"
Francis Visoiu Mistrihe0308272019-07-03 22:40:07 +000058#include "llvm/Bitstream/BitstreamReader.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000059#include "llvm/Support/Casting.h"
60#include "llvm/Support/ErrorHandling.h"
61#include <algorithm>
62#include <cassert>
63#include <cstdint>
64#include <string>
65
Chris Lattner92ba5ff2009-04-27 05:14:47 +000066using namespace clang;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000067using namespace serialization;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000068
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +000069namespace clang {
Argyrios Kyrtzidisddf5f212010-06-28 09:31:42 +000070
Sebastian Redl70c751d2010-08-18 23:56:52 +000071 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
David L. Jonesbe1557a2016-12-21 00:17:49 +000072 ASTRecordReader &Record;
Sebastian Redlc67764e2010-07-22 22:43:28 +000073 llvm::BitstreamCursor &DeclsCursor;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000074
John McCall3ce3d232019-12-13 03:37:23 -050075 SourceLocation readSourceLocation() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000076 return Record.readSourceLocation();
John McCallf413f5e2013-05-03 00:10:13 +000077 }
78
John McCall3ce3d232019-12-13 03:37:23 -050079 SourceRange readSourceRange() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000080 return Record.readSourceRange();
Sebastian Redl2c373b92010-10-05 15:59:54 +000081 }
John McCallf413f5e2013-05-03 00:10:13 +000082
John McCall3ce3d232019-12-13 03:37:23 -050083 std::string readString() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000084 return Record.readString();
Sebastian Redl2c373b92010-10-05 15:59:54 +000085 }
John McCallf413f5e2013-05-03 00:10:13 +000086
John McCall3ce3d232019-12-13 03:37:23 -050087 TypeSourceInfo *readTypeSourceInfo() {
88 return Record.readTypeSourceInfo();
John McCallf413f5e2013-05-03 00:10:13 +000089 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000090
John McCall3ce3d232019-12-13 03:37:23 -050091 Decl *readDecl() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000092 return Record.readDecl();
Sebastian Redl2c373b92010-10-05 15:59:54 +000093 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000094
Douglas Gregor7fb09192011-07-21 22:35:25 +000095 template<typename T>
John McCall3ce3d232019-12-13 03:37:23 -050096 T *readDeclAs() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000097 return Record.readDeclAs<T>();
Douglas Gregor7fb09192011-07-21 22:35:25 +000098 }
99
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000100 public:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000101 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
102 : Record(Record), DeclsCursor(Cursor) {}
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000103
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000104 /// The number of record fields required for the Stmt class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000105 /// itself.
Roman Lebedevd5edcb92020-03-12 12:18:01 +0300106 static const unsigned NumStmtFields = 0;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000107
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000108 /// The number of record fields required for the Expr class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000109 /// itself.
Haojian Wu4b0f1e12020-03-17 10:36:19 +0100110 static const unsigned NumExprFields =
Sam McCall6b3bede2020-03-27 19:42:49 +0100111 NumStmtFields + llvm::BitWidth<ExprDependence> + 3;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000112
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000113 /// Read and initialize a ExplicitTemplateArgumentList structure.
Abramo Bagnara7945c982012-01-27 09:46:47 +0000114 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
James Y Knighte7d82282015-12-29 18:15:14 +0000115 TemplateArgumentLoc *ArgsLocArray,
Abramo Bagnara7945c982012-01-27 09:46:47 +0000116 unsigned NumTemplateArgs);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000117
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000118 /// Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisde6aa082011-09-22 20:07:03 +0000119 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000120 unsigned NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000121
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000122 void VisitStmt(Stmt *S);
John McCallfa194042011-07-15 07:00:14 +0000123#define STMT(Type, Base) \
124 void Visit##Type(Type *);
125#include "clang/AST/StmtNodes.inc"
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000126 };
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000127
128} // namespace clang
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000129
James Y Knighte7d82282015-12-29 18:15:14 +0000130void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
131 TemplateArgumentLoc *ArgsLocArray,
132 unsigned NumTemplateArgs) {
John McCall3ce3d232019-12-13 03:37:23 -0500133 SourceLocation TemplateKWLoc = readSourceLocation();
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000134 TemplateArgumentListInfo ArgInfo;
John McCall3ce3d232019-12-13 03:37:23 -0500135 ArgInfo.setLAngleLoc(readSourceLocation());
136 ArgInfo.setRAngleLoc(readSourceLocation());
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000137 for (unsigned i = 0; i != NumTemplateArgs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000138 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
James Y Knighte7d82282015-12-29 18:15:14 +0000139 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000140}
141
Sebastian Redl70c751d2010-08-18 23:56:52 +0000142void ASTStmtReader::VisitStmt(Stmt *S) {
David L. Jonesbe1557a2016-12-21 00:17:49 +0000143 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000144}
145
Sebastian Redl70c751d2010-08-18 23:56:52 +0000146void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000147 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500148 S->setSemiLoc(readSourceLocation());
Bruno Ricci41d11c02018-10-27 18:43:27 +0000149 S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000150}
151
Sebastian Redl70c751d2010-08-18 23:56:52 +0000152void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000153 VisitStmt(S);
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000154 SmallVector<Stmt *, 16> Stmts;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000155 unsigned NumStmts = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000156 while (NumStmts--)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000157 Stmts.push_back(Record.readSubStmt());
Benjamin Kramer07420902017-12-24 16:24:20 +0000158 S->setStmts(Stmts);
John McCall3ce3d232019-12-13 03:37:23 -0500159 S->CompoundStmtBits.LBraceLoc = readSourceLocation();
160 S->RBraceLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000161}
162
Sebastian Redl70c751d2010-08-18 23:56:52 +0000163void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000164 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000165 Record.recordSwitchCaseID(S, Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500166 S->setKeywordLoc(readSourceLocation());
167 S->setColonLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000168}
169
Sebastian Redl70c751d2010-08-18 23:56:52 +0000170void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000171 VisitSwitchCase(S);
Bruno Ricci5b30571752018-10-28 12:30:53 +0000172 bool CaseStmtIsGNURange = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000173 S->setLHS(Record.readSubExpr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000174 S->setSubStmt(Record.readSubStmt());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000175 if (CaseStmtIsGNURange) {
176 S->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500177 S->setEllipsisLoc(readSourceLocation());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000178 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000179}
180
Sebastian Redl70c751d2010-08-18 23:56:52 +0000181void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000182 VisitSwitchCase(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000183 S->setSubStmt(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000184}
185
Sebastian Redl70c751d2010-08-18 23:56:52 +0000186void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000187 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500188 auto *LD = readDeclAs<LabelDecl>();
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000189 LD->setStmt(S);
190 S->setDecl(LD);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000191 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500192 S->setIdentLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000193}
194
Richard Smithc202b282012-04-14 00:33:13 +0000195void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
196 VisitStmt(S);
Bruno Ricci41d11c02018-10-27 18:43:27 +0000197 // NumAttrs in AttributedStmt is set when creating an empty
198 // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
199 // to allocate the right amount of space for the trailing Attr *.
David L. Jonesbe1557a2016-12-21 00:17:49 +0000200 uint64_t NumAttrs = Record.readInt();
Richard Smithc202b282012-04-14 00:33:13 +0000201 AttrVec Attrs;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000202 Record.readAttributes(Attrs);
Matt Beaumont-Gayad0bb8e2012-07-09 18:55:31 +0000203 (void)NumAttrs;
Bruno Ricci41d11c02018-10-27 18:43:27 +0000204 assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
Alexander Kornienko20f6fc62012-07-09 10:04:07 +0000205 assert(NumAttrs == Attrs.size());
Aaron Ballmanf3d9b092014-05-13 14:55:01 +0000206 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000207 S->SubStmt = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500208 S->AttributedStmtBits.AttrLoc = readSourceLocation();
Richard Smithc202b282012-04-14 00:33:13 +0000209}
210
Sebastian Redl70c751d2010-08-18 23:56:52 +0000211void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000212 VisitStmt(S);
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000213
David L. Jonesbe1557a2016-12-21 00:17:49 +0000214 S->setConstexpr(Record.readInt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000215 bool HasElse = Record.readInt();
216 bool HasVar = Record.readInt();
217 bool HasInit = Record.readInt();
218
David L. Jonesb6a8f022016-12-21 04:34:52 +0000219 S->setCond(Record.readSubExpr());
220 S->setThen(Record.readSubStmt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000221 if (HasElse)
222 S->setElse(Record.readSubStmt());
223 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500224 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000225 if (HasInit)
226 S->setInit(Record.readSubStmt());
227
John McCall3ce3d232019-12-13 03:37:23 -0500228 S->setIfLoc(readSourceLocation());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000229 if (HasElse)
John McCall3ce3d232019-12-13 03:37:23 -0500230 S->setElseLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000231}
232
Sebastian Redl70c751d2010-08-18 23:56:52 +0000233void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000234 VisitStmt(S);
Bruno Riccie2806f82018-10-29 16:12:37 +0000235
236 bool HasInit = Record.readInt();
237 bool HasVar = Record.readInt();
238 bool AllEnumCasesCovered = Record.readInt();
239 if (AllEnumCasesCovered)
240 S->setAllEnumCasesCovered();
241
David L. Jonesb6a8f022016-12-21 04:34:52 +0000242 S->setCond(Record.readSubExpr());
243 S->setBody(Record.readSubStmt());
Bruno Riccie2806f82018-10-29 16:12:37 +0000244 if (HasInit)
245 S->setInit(Record.readSubStmt());
246 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500247 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccie2806f82018-10-29 16:12:37 +0000248
John McCall3ce3d232019-12-13 03:37:23 -0500249 S->setSwitchLoc(readSourceLocation());
Ted Kremenekc42f3452010-09-09 00:05:53 +0000250
Craig Toppera13603a2014-05-22 05:54:18 +0000251 SwitchCase *PrevSC = nullptr;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000252 for (auto E = Record.size(); Record.getIdx() != E; ) {
253 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000254 if (PrevSC)
255 PrevSC->setNextSwitchCase(SC);
256 else
257 S->setSwitchCaseList(SC);
Mike Stump11289f42009-09-09 15:08:12 +0000258
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000259 PrevSC = SC;
260 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000261}
262
Sebastian Redl70c751d2010-08-18 23:56:52 +0000263void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000264 VisitStmt(S);
Bruno Riccibacf7512018-10-30 13:42:41 +0000265
266 bool HasVar = Record.readInt();
Douglas Gregor7fb09192011-07-21 22:35:25 +0000267
David L. Jonesb6a8f022016-12-21 04:34:52 +0000268 S->setCond(Record.readSubExpr());
269 S->setBody(Record.readSubStmt());
Bruno Riccibacf7512018-10-30 13:42:41 +0000270 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500271 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccibacf7512018-10-30 13:42:41 +0000272
John McCall3ce3d232019-12-13 03:37:23 -0500273 S->setWhileLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000274}
275
Sebastian Redl70c751d2010-08-18 23:56:52 +0000276void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000277 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000278 S->setCond(Record.readSubExpr());
279 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500280 S->setDoLoc(readSourceLocation());
281 S->setWhileLoc(readSourceLocation());
282 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000283}
284
Sebastian Redl70c751d2010-08-18 23:56:52 +0000285void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000286 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000287 S->setInit(Record.readSubStmt());
288 S->setCond(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500289 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000290 S->setInc(Record.readSubExpr());
291 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500292 S->setForLoc(readSourceLocation());
293 S->setLParenLoc(readSourceLocation());
294 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000295}
296
Sebastian Redl70c751d2010-08-18 23:56:52 +0000297void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000298 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500299 S->setLabel(readDeclAs<LabelDecl>());
300 S->setGotoLoc(readSourceLocation());
301 S->setLabelLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000302}
303
Sebastian Redl70c751d2010-08-18 23:56:52 +0000304void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000305 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500306 S->setGotoLoc(readSourceLocation());
307 S->setStarLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000308 S->setTarget(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000309}
310
Sebastian Redl70c751d2010-08-18 23:56:52 +0000311void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000312 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500313 S->setContinueLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000314}
315
Sebastian Redl70c751d2010-08-18 23:56:52 +0000316void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000317 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500318 S->setBreakLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000319}
320
Sebastian Redl70c751d2010-08-18 23:56:52 +0000321void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000322 VisitStmt(S);
Bruno Ricci023b1d12018-10-30 14:40:49 +0000323
324 bool HasNRVOCandidate = Record.readInt();
325
David L. Jonesb6a8f022016-12-21 04:34:52 +0000326 S->setRetValue(Record.readSubExpr());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000327 if (HasNRVOCandidate)
John McCall3ce3d232019-12-13 03:37:23 -0500328 S->setNRVOCandidate(readDeclAs<VarDecl>());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000329
John McCall3ce3d232019-12-13 03:37:23 -0500330 S->setReturnLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000331}
332
Sebastian Redl70c751d2010-08-18 23:56:52 +0000333void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000334 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500335 S->setStartLoc(readSourceLocation());
336 S->setEndLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000337
David L. Jonesbe1557a2016-12-21 00:17:49 +0000338 if (Record.size() - Record.getIdx() == 1) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000339 // Single declaration
John McCall3ce3d232019-12-13 03:37:23 -0500340 S->setDeclGroup(DeclGroupRef(readDecl()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000341 } else {
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000342 SmallVector<Decl *, 16> Decls;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000343 int N = Record.size() - Record.getIdx();
344 Decls.reserve(N);
345 for (int I = 0; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500346 Decls.push_back(readDecl());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000347 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
Douglas Gregor038c3382009-05-22 22:45:36 +0000348 Decls.data(),
349 Decls.size())));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000350 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000351}
352
John McCallf413f5e2013-05-03 00:10:13 +0000353void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000354 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000355 S->NumOutputs = Record.readInt();
356 S->NumInputs = Record.readInt();
357 S->NumClobbers = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500358 S->setAsmLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000359 S->setVolatile(Record.readInt());
360 S->setSimple(Record.readInt());
John McCallf413f5e2013-05-03 00:10:13 +0000361}
Mike Stump11289f42009-09-09 15:08:12 +0000362
John McCallf413f5e2013-05-03 00:10:13 +0000363void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
364 VisitAsmStmt(S);
Jennifer Yub8fee672019-06-03 15:57:25 +0000365 S->NumLabels = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500366 S->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000367 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000368
John McCallf413f5e2013-05-03 00:10:13 +0000369 unsigned NumOutputs = S->getNumOutputs();
370 unsigned NumInputs = S->getNumInputs();
371 unsigned NumClobbers = S->getNumClobbers();
Jennifer Yub8fee672019-06-03 15:57:25 +0000372 unsigned NumLabels = S->getNumLabels();
John McCallf413f5e2013-05-03 00:10:13 +0000373
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000374 // Outputs and inputs
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000375 SmallVector<IdentifierInfo *, 16> Names;
376 SmallVector<StringLiteral*, 16> Constraints;
377 SmallVector<Stmt*, 16> Exprs;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000378 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -0500379 Names.push_back(Record.readIdentifier());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000380 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
381 Exprs.push_back(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000382 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000383
384 // Constraints
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000385 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000386 for (unsigned I = 0; I != NumClobbers; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000387 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000388
Jennifer Yub8fee672019-06-03 15:57:25 +0000389 // Labels
390 for (unsigned I = 0, N = NumLabels; I != N; ++I)
391 Exprs.push_back(Record.readSubStmt());
392
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000393 S->setOutputsAndInputsAndClobbers(Record.getContext(),
394 Names.data(), Constraints.data(),
395 Exprs.data(), NumOutputs, NumInputs,
Jennifer Yub8fee672019-06-03 15:57:25 +0000396 NumLabels,
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000397 Clobbers.data(), NumClobbers);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000398}
399
Chad Rosier32503022012-06-11 20:47:18 +0000400void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
John McCallf413f5e2013-05-03 00:10:13 +0000401 VisitAsmStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500402 S->LBraceLoc = readSourceLocation();
403 S->EndLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000404 S->NumAsmToks = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500405 std::string AsmStr = readString();
John McCallf413f5e2013-05-03 00:10:13 +0000406
407 // Read the tokens.
408 SmallVector<Token, 16> AsmToks;
409 AsmToks.reserve(S->NumAsmToks);
410 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000411 AsmToks.push_back(Record.readToken());
John McCallf413f5e2013-05-03 00:10:13 +0000412 }
413
414 // The calls to reserve() for the FooData vectors are mandatory to
415 // prevent dead StringRefs in the Foo vectors.
416
417 // Read the clobbers.
418 SmallVector<std::string, 16> ClobbersData;
419 SmallVector<StringRef, 16> Clobbers;
420 ClobbersData.reserve(S->NumClobbers);
421 Clobbers.reserve(S->NumClobbers);
422 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
John McCall3ce3d232019-12-13 03:37:23 -0500423 ClobbersData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000424 Clobbers.push_back(ClobbersData.back());
425 }
426
427 // Read the operands.
428 unsigned NumOperands = S->NumOutputs + S->NumInputs;
429 SmallVector<Expr*, 16> Exprs;
430 SmallVector<std::string, 16> ConstraintsData;
431 SmallVector<StringRef, 16> Constraints;
432 Exprs.reserve(NumOperands);
433 ConstraintsData.reserve(NumOperands);
434 Constraints.reserve(NumOperands);
435 for (unsigned i = 0; i != NumOperands; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000436 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -0500437 ConstraintsData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000438 Constraints.push_back(ConstraintsData.back());
439 }
440
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000441 S->initialize(Record.getContext(), AsmStr, AsmToks,
John McCallf413f5e2013-05-03 00:10:13 +0000442 Constraints, Exprs, Clobbers);
Chad Rosier32503022012-06-11 20:47:18 +0000443}
444
Richard Smith9f690bd2015-10-27 06:02:45 +0000445void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000446 VisitStmt(S);
447 assert(Record.peekInt() == S->NumParams);
448 Record.skipInts(1);
449 auto *StoredStmts = S->getStoredStmts();
450 for (unsigned i = 0;
451 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
452 StoredStmts[i] = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000453}
454
455void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000456 VisitStmt(S);
457 S->CoreturnLoc = Record.readSourceLocation();
458 for (auto &SubStmt: S->SubStmts)
459 SubStmt = Record.readSubStmt();
460 S->IsImplicit = Record.readInt() != 0;
Richard Smith9f690bd2015-10-27 06:02:45 +0000461}
462
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000463void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
464 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500465 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000466 for (auto &SubExpr: E->SubExprs)
467 SubExpr = Record.readSubStmt();
468 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
469 E->setIsImplicit(Record.readInt() != 0);
Richard Smith9f690bd2015-10-27 06:02:45 +0000470}
471
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000472void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
473 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500474 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000475 for (auto &SubExpr: E->SubExprs)
476 SubExpr = Record.readSubStmt();
477 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
Eric Fiselier20f25cb2017-03-06 23:38:15 +0000478}
479
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000480void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
481 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500482 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000483 for (auto &SubExpr: E->SubExprs)
484 SubExpr = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000485}
486
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000487void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
Ben Langmuirce914fc2013-05-03 19:20:19 +0000488 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000489 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500490 S->setCapturedDecl(readDeclAs<CapturedDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000491 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500492 S->setCapturedRecordDecl(readDeclAs<RecordDecl>());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000493
494 // Capture inits
495 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
496 E = S->capture_init_end();
497 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000498 *I = Record.readSubExpr();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000499
500 // Body
David L. Jonesb6a8f022016-12-21 04:34:52 +0000501 S->setCapturedStmt(Record.readSubStmt());
Wei Pan17fbf6e2013-05-04 03:59:06 +0000502 S->getCapturedDecl()->setBody(S->getCapturedStmt());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000503
504 // Captures
Aaron Ballmanc656303a2014-03-14 18:08:33 +0000505 for (auto &I : S->captures()) {
John McCall3ce3d232019-12-13 03:37:23 -0500506 I.VarAndKind.setPointer(readDeclAs<VarDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000507 I.VarAndKind.setInt(
508 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500509 I.Loc = readSourceLocation();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000510 }
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000511}
512
Sebastian Redl70c751d2010-08-18 23:56:52 +0000513void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000514 VisitStmt(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000515 E->setType(Record.readType());
Ilya Biryukovec3060c2020-03-02 16:07:09 +0100516
517 // FIXME: write and read all DependentFlags with a single call.
518 bool TypeDependent = Record.readInt();
519 bool ValueDependent = Record.readInt();
520 bool InstantiationDependent = Record.readInt();
521 bool ContainsUnexpandedTemplateParameters = Record.readInt();
Haojian Wu4b0f1e12020-03-17 10:36:19 +0100522 bool ContainsErrors = Record.readInt();
Ilya Biryukovec3060c2020-03-02 16:07:09 +0100523 auto Deps = ExprDependence::None;
524 if (TypeDependent)
525 Deps |= ExprDependence::Type;
526 if (ValueDependent)
527 Deps |= ExprDependence::Value;
528 if (InstantiationDependent)
529 Deps |= ExprDependence::Instantiation;
530 if (ContainsUnexpandedTemplateParameters)
531 Deps |= ExprDependence::UnexpandedPack;
Haojian Wu4b0f1e12020-03-17 10:36:19 +0100532 if (ContainsErrors)
533 Deps |= ExprDependence::Error;
Ilya Biryukovec3060c2020-03-02 16:07:09 +0100534 E->setDependence(Deps);
535
David L. Jonesbe1557a2016-12-21 00:17:49 +0000536 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
537 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
538 assert(Record.getIdx() == NumExprFields &&
539 "Incorrect expression field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000540}
541
Bill Wendling7c44da22018-10-31 03:48:47 +0000542void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
543 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000544 E->ConstantExprBits.ResultKind = Record.readInt();
545 switch (E->ConstantExprBits.ResultKind) {
546 case ConstantExpr::RSK_Int64: {
547 E->Int64Result() = Record.readInt();
548 uint64_t tmp = Record.readInt();
549 E->ConstantExprBits.IsUnsigned = tmp & 0x1;
550 E->ConstantExprBits.BitWidth = tmp >> 1;
551 break;
552 }
553 case ConstantExpr::RSK_APValue:
554 E->APValueResult() = Record.readAPValue();
555 }
Bill Wendling7c44da22018-10-31 03:48:47 +0000556 E->setSubExpr(Record.readSubExpr());
557}
558
Sebastian Redl70c751d2010-08-18 23:56:52 +0000559void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000560 VisitExpr(E);
Bruno Ricci17ff0262018-10-27 19:21:19 +0000561 bool HasFunctionName = Record.readInt();
562 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
563 E->PredefinedExprBits.Kind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500564 E->setLocation(readSourceLocation());
Bruno Ricci17ff0262018-10-27 19:21:19 +0000565 if (HasFunctionName)
566 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000567}
568
Sebastian Redl70c751d2010-08-18 23:56:52 +0000569void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000570 VisitExpr(E);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000571
David L. Jonesbe1557a2016-12-21 00:17:49 +0000572 E->DeclRefExprBits.HasQualifier = Record.readInt();
573 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
574 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
575 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
576 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
Richard Smith715f7a12019-06-11 17:50:32 +0000577 E->DeclRefExprBits.NonOdrUseReason = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000578 unsigned NumTemplateArgs = 0;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000579 if (E->hasTemplateKWAndArgsInfo())
David L. Jonesbe1557a2016-12-21 00:17:49 +0000580 NumTemplateArgs = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000581
Chandler Carruth0e439962011-05-01 21:29:53 +0000582 if (E->hasQualifier())
James Y Knighte7d82282015-12-29 18:15:14 +0000583 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
David L. Jonesb6a8f022016-12-21 04:34:52 +0000584 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000585
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000586 if (E->hasFoundDecl())
John McCall3ce3d232019-12-13 03:37:23 -0500587 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000588
Abramo Bagnara7945c982012-01-27 09:46:47 +0000589 if (E->hasTemplateKWAndArgsInfo())
James Y Knighte7d82282015-12-29 18:15:14 +0000590 ReadTemplateKWAndArgsInfo(
591 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
592 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000593
John McCall3ce3d232019-12-13 03:37:23 -0500594 E->setDecl(readDeclAs<ValueDecl>());
595 E->setLocation(readSourceLocation());
596 E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000597}
598
Sebastian Redl70c751d2010-08-18 23:56:52 +0000599void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000600 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500601 E->setLocation(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000602 E->setValue(Record.getContext(), Record.readAPInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000603}
604
Leonard Chandb01c3a2018-06-20 17:19:40 +0000605void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
606 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500607 E->setLocation(readSourceLocation());
Vince Bridgers161fc1d2020-04-07 14:46:08 -0500608 E->setScale(Record.readInt());
Leonard Chandb01c3a2018-06-20 17:19:40 +0000609 E->setValue(Record.getContext(), Record.readAPInt());
610}
611
Sebastian Redl70c751d2010-08-18 23:56:52 +0000612void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000613 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000614 E->setRawSemantics(
615 static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
David L. Jonesbe1557a2016-12-21 00:17:49 +0000616 E->setExact(Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000617 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
John McCall3ce3d232019-12-13 03:37:23 -0500618 E->setLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000619}
620
Sebastian Redl70c751d2010-08-18 23:56:52 +0000621void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000622 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000623 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000624}
625
Sebastian Redl70c751d2010-08-18 23:56:52 +0000626void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000627 VisitExpr(E);
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000628
629 // NumConcatenated, Length and CharByteWidth are set by the empty
630 // ctor since they are needed to allocate storage for the trailing objects.
631 unsigned NumConcatenated = Record.readInt();
632 unsigned Length = Record.readInt();
633 unsigned CharByteWidth = Record.readInt();
634 assert((NumConcatenated == E->getNumConcatenated()) &&
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000635 "Wrong number of concatenated tokens!");
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000636 assert((Length == E->getLength()) && "Wrong Length!");
637 assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
638 E->StringLiteralBits.Kind = Record.readInt();
639 E->StringLiteralBits.IsPascal = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000640
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000641 // The character width is originally computed via mapCharByteWidth.
642 // Check that the deserialized character width is consistant with the result
643 // of calling mapCharByteWidth.
644 assert((CharByteWidth ==
645 StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
646 E->getKind())) &&
647 "Wrong character width!");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000648
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000649 // Deserialize the trailing array of SourceLocation.
650 for (unsigned I = 0; I < NumConcatenated; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500651 E->setStrTokenLoc(I, readSourceLocation());
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000652
653 // Deserialize the trailing array of char holding the string data.
654 char *StrData = E->getStrDataAsChar();
655 for (unsigned I = 0; I < Length * CharByteWidth; ++I)
656 StrData[I] = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000657}
658
Sebastian Redl70c751d2010-08-18 23:56:52 +0000659void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000660 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000661 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500662 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000663 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000664}
665
Sebastian Redl70c751d2010-08-18 23:56:52 +0000666void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000667 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500668 E->setLParen(readSourceLocation());
669 E->setRParen(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000670 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000671}
672
Sebastian Redl70c751d2010-08-18 23:56:52 +0000673void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000674 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000675 unsigned NumExprs = Record.readInt();
Bruno Riccif49e1ca2018-11-20 16:20:40 +0000676 assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
677 for (unsigned I = 0; I != NumExprs; ++I)
678 E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500679 E->LParenLoc = readSourceLocation();
680 E->RParenLoc = readSourceLocation();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000681}
682
Sebastian Redl70c751d2010-08-18 23:56:52 +0000683void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000684 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000685 E->setSubExpr(Record.readSubExpr());
686 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500687 E->setOperatorLoc(readSourceLocation());
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000688 E->setCanOverflow(Record.readInt());
689}
690
691void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000692 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000693 assert(E->getNumComponents() == Record.peekInt());
694 Record.skipInts(1);
695 assert(E->getNumExpressions() == Record.peekInt());
696 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500697 E->setOperatorLoc(readSourceLocation());
698 E->setRParenLoc(readSourceLocation());
699 E->setTypeSourceInfo(readTypeSourceInfo());
Douglas Gregor882211c2010-04-28 22:16:22 +0000700 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000701 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500702 SourceLocation Start = readSourceLocation();
703 SourceLocation End = readSourceLocation();
Douglas Gregor882211c2010-04-28 22:16:22 +0000704 switch (Kind) {
James Y Knight7281c352015-12-29 22:31:18 +0000705 case OffsetOfNode::Array:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000706 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000707 break;
708
James Y Knight7281c352015-12-29 22:31:18 +0000709 case OffsetOfNode::Field:
710 E->setComponent(
John McCall3ce3d232019-12-13 03:37:23 -0500711 I, OffsetOfNode(Start, readDeclAs<FieldDecl>(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000712 break;
James Y Knight7281c352015-12-29 22:31:18 +0000713
714 case OffsetOfNode::Identifier:
715 E->setComponent(
716 I,
John McCall3ce3d232019-12-13 03:37:23 -0500717 OffsetOfNode(Start, Record.readIdentifier(), End));
James Y Knight7281c352015-12-29 22:31:18 +0000718 break;
719
720 case OffsetOfNode::Base: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000721 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000722 *Base = Record.readCXXBaseSpecifier();
James Y Knight7281c352015-12-29 22:31:18 +0000723 E->setComponent(I, OffsetOfNode(Base));
Douglas Gregord1702062010-04-29 00:18:15 +0000724 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000725 }
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000726 }
Douglas Gregor882211c2010-04-28 22:16:22 +0000727 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000728
Douglas Gregor882211c2010-04-28 22:16:22 +0000729 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000730 E->setIndexExpr(I, Record.readSubExpr());
Douglas Gregor882211c2010-04-28 22:16:22 +0000731}
732
Peter Collingbournee190dee2011-03-11 19:24:49 +0000733void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000734 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000735 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
736 if (Record.peekInt() == 0) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000737 E->setArgument(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000738 Record.skipInts(1);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000739 } else {
John McCall3ce3d232019-12-13 03:37:23 -0500740 E->setArgument(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000741 }
John McCall3ce3d232019-12-13 03:37:23 -0500742 E->setOperatorLoc(readSourceLocation());
743 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000744}
745
Saar Raza0f50d72020-01-18 09:11:43 +0200746static ConstraintSatisfaction
747readConstraintSatisfaction(ASTRecordReader &Record) {
748 ConstraintSatisfaction Satisfaction;
749 Satisfaction.IsSatisfied = Record.readInt();
750 if (!Satisfaction.IsSatisfied) {
751 unsigned NumDetailRecords = Record.readInt();
752 for (unsigned i = 0; i != NumDetailRecords; ++i) {
753 Expr *ConstraintExpr = Record.readExpr();
Michael Liao70b53a302020-01-19 12:23:11 -0500754 if (/* IsDiagnostic */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200755 SourceLocation DiagLocation = Record.readSourceLocation();
756 std::string DiagMessage = Record.readString();
757 Satisfaction.Details.emplace_back(
758 ConstraintExpr, new (Record.getContext())
759 ConstraintSatisfaction::SubstitutionDiagnostic{
760 DiagLocation, DiagMessage});
761 } else
762 Satisfaction.Details.emplace_back(ConstraintExpr, Record.readExpr());
763 }
764 }
765 return Satisfaction;
766}
767
Saar Raz5d98ba62019-10-15 15:24:26 +0000768void ASTStmtReader::VisitConceptSpecializationExpr(
769 ConceptSpecializationExpr *E) {
770 VisitExpr(E);
771 unsigned NumTemplateArgs = Record.readInt();
772 E->NestedNameSpec = Record.readNestedNameSpecifierLoc();
773 E->TemplateKWLoc = Record.readSourceLocation();
Saar Razff1e0fc2020-01-15 02:48:42 +0200774 E->ConceptName = Record.readDeclarationNameInfo();
John McCall3ce3d232019-12-13 03:37:23 -0500775 E->NamedConcept = readDeclAs<ConceptDecl>();
Saar Razf9e63892020-03-10 22:04:11 +0200776 E->FoundDecl = Record.readDeclAs<NamedDecl>();
Saar Razff1e0fc2020-01-15 02:48:42 +0200777 E->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
Saar Raz5d98ba62019-10-15 15:24:26 +0000778 llvm::SmallVector<TemplateArgument, 4> Args;
779 for (unsigned I = 0; I < NumTemplateArgs; ++I)
780 Args.push_back(Record.readTemplateArgument());
Saar Razff1e0fc2020-01-15 02:48:42 +0200781 E->setTemplateArguments(Args);
Saar Raza0f50d72020-01-18 09:11:43 +0200782 E->Satisfaction = E->isValueDependent() ? nullptr :
783 ASTConstraintSatisfaction::Create(Record.getContext(),
784 readConstraintSatisfaction(Record));
785}
786
787static concepts::Requirement::SubstitutionDiagnostic *
788readSubstitutionDiagnostic(ASTRecordReader &Record) {
789 std::string SubstitutedEntity = Record.readString();
790 SourceLocation DiagLoc = Record.readSourceLocation();
791 std::string DiagMessage = Record.readString();
792 return new (Record.getContext())
793 concepts::Requirement::SubstitutionDiagnostic{SubstitutedEntity, DiagLoc,
794 DiagMessage};
795}
796
797void ASTStmtReader::VisitRequiresExpr(RequiresExpr *E) {
798 VisitExpr(E);
799 unsigned NumLocalParameters = Record.readInt();
800 unsigned NumRequirements = Record.readInt();
801 E->RequiresExprBits.RequiresKWLoc = Record.readSourceLocation();
802 E->RequiresExprBits.IsSatisfied = Record.readInt();
803 E->Body = Record.readDeclAs<RequiresExprBodyDecl>();
804 llvm::SmallVector<ParmVarDecl *, 4> LocalParameters;
805 for (unsigned i = 0; i < NumLocalParameters; ++i)
806 LocalParameters.push_back(cast<ParmVarDecl>(Record.readDecl()));
807 std::copy(LocalParameters.begin(), LocalParameters.end(),
808 E->getTrailingObjects<ParmVarDecl *>());
809 llvm::SmallVector<concepts::Requirement *, 4> Requirements;
810 for (unsigned i = 0; i < NumRequirements; ++i) {
811 auto RK =
812 static_cast<concepts::Requirement::RequirementKind>(Record.readInt());
813 concepts::Requirement *R = nullptr;
814 switch (RK) {
815 case concepts::Requirement::RK_Type: {
816 auto Status =
817 static_cast<concepts::TypeRequirement::SatisfactionStatus>(
818 Record.readInt());
819 if (Status == concepts::TypeRequirement::SS_SubstitutionFailure)
820 R = new (Record.getContext())
821 concepts::TypeRequirement(readSubstitutionDiagnostic(Record));
822 else
823 R = new (Record.getContext())
824 concepts::TypeRequirement(Record.readTypeSourceInfo());
825 } break;
826 case concepts::Requirement::RK_Simple:
827 case concepts::Requirement::RK_Compound: {
828 auto Status =
829 static_cast<concepts::ExprRequirement::SatisfactionStatus>(
830 Record.readInt());
831 llvm::PointerUnion<concepts::Requirement::SubstitutionDiagnostic *,
832 Expr *> E;
833 if (Status == concepts::ExprRequirement::SS_ExprSubstitutionFailure) {
834 E = readSubstitutionDiagnostic(Record);
835 } else
836 E = Record.readExpr();
837
838 llvm::Optional<concepts::ExprRequirement::ReturnTypeRequirement> Req;
839 ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr;
840 SourceLocation NoexceptLoc;
841 if (RK == concepts::Requirement::RK_Simple) {
842 Req.emplace();
843 } else {
844 NoexceptLoc = Record.readSourceLocation();
Michael Liao70b53a302020-01-19 12:23:11 -0500845 switch (/* returnTypeRequirementKind */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200846 case 0:
847 // No return type requirement.
848 Req.emplace();
849 break;
850 case 1: {
851 // type-constraint
852 TemplateParameterList *TPL = Record.readTemplateParameterList();
853 if (Status >=
854 concepts::ExprRequirement::SS_ConstraintsNotSatisfied)
855 SubstitutedConstraintExpr =
856 cast<ConceptSpecializationExpr>(Record.readExpr());
857 Req.emplace(TPL);
858 } break;
859 case 2:
860 // Substitution failure
861 Req.emplace(readSubstitutionDiagnostic(Record));
862 break;
863 }
864 }
865 if (Expr *Ex = E.dyn_cast<Expr *>())
866 R = new (Record.getContext()) concepts::ExprRequirement(
867 Ex, RK == concepts::Requirement::RK_Simple, NoexceptLoc,
868 std::move(*Req), Status, SubstitutedConstraintExpr);
869 else
870 R = new (Record.getContext()) concepts::ExprRequirement(
871 E.get<concepts::Requirement::SubstitutionDiagnostic *>(),
872 RK == concepts::Requirement::RK_Simple, NoexceptLoc,
873 std::move(*Req));
874 } break;
875 case concepts::Requirement::RK_Nested: {
Michael Liao70b53a302020-01-19 12:23:11 -0500876 if (/* IsSubstitutionDiagnostic */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200877 R = new (Record.getContext()) concepts::NestedRequirement(
878 readSubstitutionDiagnostic(Record));
879 break;
880 }
881 Expr *E = Record.readExpr();
882 if (E->isInstantiationDependent())
883 R = new (Record.getContext()) concepts::NestedRequirement(E);
884 else
885 R = new (Record.getContext())
886 concepts::NestedRequirement(Record.getContext(), E,
887 readConstraintSatisfaction(Record));
888 } break;
Saar Razfdf80e82019-12-06 01:30:21 +0200889 }
Saar Raza0f50d72020-01-18 09:11:43 +0200890 if (!R)
891 continue;
892 Requirements.push_back(R);
Saar Razfdf80e82019-12-06 01:30:21 +0200893 }
Saar Raza0f50d72020-01-18 09:11:43 +0200894 std::copy(Requirements.begin(), Requirements.end(),
895 E->getTrailingObjects<concepts::Requirement *>());
896 E->RBraceLoc = Record.readSourceLocation();
Saar Raz5d98ba62019-10-15 15:24:26 +0000897}
898
Sebastian Redl70c751d2010-08-18 23:56:52 +0000899void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000900 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000901 E->setLHS(Record.readSubExpr());
902 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500903 E->setRBracketLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000904}
905
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000906void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
907 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000908 E->setBase(Record.readSubExpr());
909 E->setLowerBound(Record.readSubExpr());
910 E->setLength(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500911 E->setColonLoc(readSourceLocation());
912 E->setRBracketLoc(readSourceLocation());
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000913}
914
Alexey Bataev7ac9efb2020-02-05 09:33:05 -0500915void ASTStmtReader::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *E) {
916 VisitExpr(E);
917 unsigned NumDims = Record.readInt();
918 E->setBase(Record.readSubExpr());
919 SmallVector<Expr *, 4> Dims(NumDims);
920 for (unsigned I = 0; I < NumDims; ++I)
921 Dims[I] = Record.readSubExpr();
922 E->setDimensions(Dims);
923 SmallVector<SourceRange, 4> SRs(NumDims);
924 for (unsigned I = 0; I < NumDims; ++I)
925 SRs[I] = readSourceRange();
926 E->setBracketsRanges(SRs);
927 E->setLParenLoc(readSourceLocation());
928 E->setRParenLoc(readSourceLocation());
929}
930
Alexey Bataev13a15042020-04-01 15:06:38 -0400931void ASTStmtReader::VisitOMPIteratorExpr(OMPIteratorExpr *E) {
932 VisitExpr(E);
933 unsigned NumIters = Record.readInt();
934 E->setIteratorKwLoc(readSourceLocation());
935 E->setLParenLoc(readSourceLocation());
936 E->setRParenLoc(readSourceLocation());
937 for (unsigned I = 0; I < NumIters; ++I) {
938 E->setIteratorDeclaration(I, Record.readDeclRef());
939 E->setAssignmentLoc(I, readSourceLocation());
940 Expr *Begin = Record.readSubExpr();
941 Expr *End = Record.readSubExpr();
942 Expr *Step = Record.readSubExpr();
943 SourceLocation ColonLoc = readSourceLocation();
944 SourceLocation SecColonLoc;
945 if (Step)
946 SecColonLoc = readSourceLocation();
947 E->setIteratorRange(I, Begin, ColonLoc, End, SecColonLoc, Step);
Alexey Bataevbe99c612020-04-06 11:21:43 -0400948 // Deserialize helpers
949 OMPIteratorHelperData HD;
950 HD.CounterVD = cast_or_null<VarDecl>(Record.readDeclRef());
951 HD.Upper = Record.readSubExpr();
952 HD.Update = Record.readSubExpr();
953 HD.CounterUpdate = Record.readSubExpr();
954 E->setHelper(I, HD);
Alexey Bataev13a15042020-04-01 15:06:38 -0400955 }
956}
957
Sebastian Redl70c751d2010-08-18 23:56:52 +0000958void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000959 VisitExpr(E);
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000960 unsigned NumArgs = Record.readInt();
961 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
John McCall3ce3d232019-12-13 03:37:23 -0500962 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000963 E->setCallee(Record.readSubExpr());
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000964 for (unsigned I = 0; I != NumArgs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000965 E->setArg(I, Record.readSubExpr());
Eric Fiselier5cdc2cd2018-12-12 21:50:55 +0000966 E->setADLCallKind(static_cast<CallExpr::ADLCallKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000967}
968
John McCallfa194042011-07-15 07:00:14 +0000969void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
970 VisitCallExpr(E);
971}
972
Sebastian Redl70c751d2010-08-18 23:56:52 +0000973void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Richard Smithdcf17de2019-06-06 23:24:15 +0000974 VisitExpr(E);
975
976 bool HasQualifier = Record.readInt();
977 bool HasFoundDecl = Record.readInt();
978 bool HasTemplateInfo = Record.readInt();
979 unsigned NumTemplateArgs = Record.readInt();
980
981 E->Base = Record.readSubExpr();
982 E->MemberDecl = Record.readDeclAs<ValueDecl>();
John McCall3ce3d232019-12-13 03:37:23 -0500983 E->MemberDNLoc = Record.readDeclarationNameLoc(E->MemberDecl->getDeclName());
Richard Smithdcf17de2019-06-06 23:24:15 +0000984 E->MemberLoc = Record.readSourceLocation();
985 E->MemberExprBits.IsArrow = Record.readInt();
986 E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
987 E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
988 E->MemberExprBits.HadMultipleCandidates = Record.readInt();
Richard Smith1bbad592019-06-11 17:50:36 +0000989 E->MemberExprBits.NonOdrUseReason = Record.readInt();
Richard Smithdcf17de2019-06-06 23:24:15 +0000990 E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
991
992 if (HasQualifier || HasFoundDecl) {
993 DeclAccessPair FoundDecl;
994 if (HasFoundDecl) {
995 auto *FoundD = Record.readDeclAs<NamedDecl>();
996 auto AS = (AccessSpecifier)Record.readInt();
997 FoundDecl = DeclAccessPair::make(FoundD, AS);
998 } else {
999 FoundDecl = DeclAccessPair::make(E->MemberDecl,
1000 E->MemberDecl->getAccess());
1001 }
1002 E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
1003
1004 NestedNameSpecifierLoc QualifierLoc;
1005 if (HasQualifier)
1006 QualifierLoc = Record.readNestedNameSpecifierLoc();
1007 E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
1008 QualifierLoc;
1009 }
1010
1011 if (HasTemplateInfo)
1012 ReadTemplateKWAndArgsInfo(
1013 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1014 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001015}
1016
Sebastian Redl70c751d2010-08-18 23:56:52 +00001017void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Naroffe87026a2009-07-24 17:54:45 +00001018 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001019 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001020 E->setIsaMemberLoc(readSourceLocation());
1021 E->setOpLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001022 E->setArrow(Record.readInt());
Steve Naroffe87026a2009-07-24 17:54:45 +00001023}
1024
John McCall31168b02011-06-15 23:02:42 +00001025void ASTStmtReader::
1026VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
1027 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001028 E->Operand = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001029 E->setShouldCopy(Record.readInt());
John McCall31168b02011-06-15 23:02:42 +00001030}
1031
1032void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
1033 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001034 E->LParenLoc = readSourceLocation();
1035 E->BridgeKeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001036 E->Kind = Record.readInt();
John McCall31168b02011-06-15 23:02:42 +00001037}
1038
Sebastian Redl70c751d2010-08-18 23:56:52 +00001039void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001040 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001041 unsigned NumBaseSpecs = Record.readInt();
John McCallcf142162010-08-07 06:22:56 +00001042 assert(NumBaseSpecs == E->path_size());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001043 E->setSubExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001044 E->setCastKind((CastKind)Record.readInt());
John McCallcf142162010-08-07 06:22:56 +00001045 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +00001046 while (NumBaseSpecs--) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001047 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
David L. Jonesb6a8f022016-12-21 04:34:52 +00001048 *BaseSpec = Record.readCXXBaseSpecifier();
John McCallcf142162010-08-07 06:22:56 +00001049 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +00001050 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001051}
1052
Sebastian Redl70c751d2010-08-18 23:56:52 +00001053void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001054 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001055 E->setLHS(Record.readSubExpr());
1056 E->setRHS(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001057 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001058 E->setOperatorLoc(readSourceLocation());
Adam Nemet484aa452017-03-27 19:17:25 +00001059 E->setFPFeatures(FPOptions(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001060}
1061
Sebastian Redl70c751d2010-08-18 23:56:52 +00001062void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001063 VisitBinaryOperator(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001064 E->setComputationLHSType(Record.readType());
1065 E->setComputationResultType(Record.readType());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001066}
1067
Sebastian Redl70c751d2010-08-18 23:56:52 +00001068void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001069 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001070 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
1071 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
1072 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001073 E->QuestionLoc = readSourceLocation();
1074 E->ColonLoc = readSourceLocation();
John McCallc07a0c72011-02-17 10:25:35 +00001075}
1076
1077void
1078ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
1079 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001080 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
1081 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
1082 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
1083 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
1084 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001085 E->QuestionLoc = readSourceLocation();
1086 E->ColonLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001087}
1088
Sebastian Redl70c751d2010-08-18 23:56:52 +00001089void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001090 VisitCastExpr(E);
Roman Lebedev12216f12018-07-27 07:27:14 +00001091 E->setIsPartOfExplicitCast(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001092}
1093
Sebastian Redl70c751d2010-08-18 23:56:52 +00001094void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001095 VisitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001096 E->setTypeInfoAsWritten(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001097}
1098
Sebastian Redl70c751d2010-08-18 23:56:52 +00001099void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001100 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001101 E->setLParenLoc(readSourceLocation());
1102 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001103}
1104
Sebastian Redl70c751d2010-08-18 23:56:52 +00001105void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001106 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001107 E->setLParenLoc(readSourceLocation());
1108 E->setTypeSourceInfo(readTypeSourceInfo());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001109 E->setInitializer(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001110 E->setFileScope(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001111}
1112
Sebastian Redl70c751d2010-08-18 23:56:52 +00001113void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001114 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001115 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001116 E->setAccessor(Record.readIdentifier());
1117 E->setAccessorLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001118}
1119
Sebastian Redl70c751d2010-08-18 23:56:52 +00001120void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001121 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001122 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
Abramo Bagnara8d16bd42012-11-08 18:41:43 +00001123 E->setSyntacticForm(SyntForm);
John McCall3ce3d232019-12-13 03:37:23 -05001124 E->setLBraceLoc(readSourceLocation());
1125 E->setRBraceLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001126 bool isArrayFiller = Record.readInt();
Craig Toppera13603a2014-05-22 05:54:18 +00001127 Expr *filler = nullptr;
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001128 if (isArrayFiller) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001129 filler = Record.readSubExpr();
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001130 E->ArrayFillerOrUnionFieldInit = filler;
1131 } else
John McCall3ce3d232019-12-13 03:37:23 -05001132 E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001133 E->sawArrayRangeDesignator(Record.readInt());
1134 unsigned NumInits = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001135 E->reserveInits(Record.getContext(), NumInits);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001136 if (isArrayFiller) {
1137 for (unsigned I = 0; I != NumInits; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001138 Expr *init = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001139 E->updateInit(Record.getContext(), I, init ? init : filler);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001140 }
1141 } else {
1142 for (unsigned I = 0; I != NumInits; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001143 E->updateInit(Record.getContext(), I, Record.readSubExpr());
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001144 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001145}
1146
Sebastian Redl70c751d2010-08-18 23:56:52 +00001147void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001148 using Designator = DesignatedInitExpr::Designator;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001149
1150 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001151 unsigned NumSubExprs = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001152 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
1153 for (unsigned I = 0; I != NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001154 E->setSubExpr(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001155 E->setEqualOrColonLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001156 E->setGNUSyntax(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001157
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001158 SmallVector<Designator, 4> Designators;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001159 while (Record.getIdx() < Record.size()) {
1160 switch ((DesignatorTypes)Record.readInt()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00001161 case DESIG_FIELD_DECL: {
John McCall3ce3d232019-12-13 03:37:23 -05001162 auto *Field = readDeclAs<FieldDecl>();
1163 SourceLocation DotLoc = readSourceLocation();
1164 SourceLocation FieldLoc = readSourceLocation();
Mike Stump11289f42009-09-09 15:08:12 +00001165 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001166 FieldLoc));
1167 Designators.back().setField(Field);
1168 break;
1169 }
1170
Sebastian Redl539c5062010-08-18 23:57:32 +00001171 case DESIG_FIELD_NAME: {
John McCall3ce3d232019-12-13 03:37:23 -05001172 const IdentifierInfo *Name = Record.readIdentifier();
1173 SourceLocation DotLoc = readSourceLocation();
1174 SourceLocation FieldLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001175 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
1176 break;
1177 }
Mike Stump11289f42009-09-09 15:08:12 +00001178
Sebastian Redl539c5062010-08-18 23:57:32 +00001179 case DESIG_ARRAY: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001180 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001181 SourceLocation LBracketLoc = readSourceLocation();
1182 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001183 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
1184 break;
1185 }
1186
Sebastian Redl539c5062010-08-18 23:57:32 +00001187 case DESIG_ARRAY_RANGE: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001188 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001189 SourceLocation LBracketLoc = readSourceLocation();
1190 SourceLocation EllipsisLoc = readSourceLocation();
1191 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001192 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
1193 RBracketLoc));
1194 break;
1195 }
1196 }
1197 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001198 E->setDesignators(Record.getContext(),
Douglas Gregor03e8bdc2010-01-06 23:17:19 +00001199 Designators.data(), Designators.size());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001200}
1201
Yunzhong Gaocb779302015-06-10 00:27:52 +00001202void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1203 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001204 E->setBase(Record.readSubExpr());
1205 E->setUpdater(Record.readSubExpr());
Yunzhong Gaocb779302015-06-10 00:27:52 +00001206}
1207
1208void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1209 VisitExpr(E);
1210}
1211
Richard Smith410306b2016-12-12 02:53:20 +00001212void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1213 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001214 E->SubExprs[0] = Record.readSubExpr();
1215 E->SubExprs[1] = Record.readSubExpr();
Richard Smith410306b2016-12-12 02:53:20 +00001216}
1217
1218void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1219 VisitExpr(E);
1220}
1221
Sebastian Redl70c751d2010-08-18 23:56:52 +00001222void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001223 VisitExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001224}
1225
Sebastian Redl70c751d2010-08-18 23:56:52 +00001226void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001227 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001228 E->setSubExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001229 E->setWrittenTypeInfo(readTypeSourceInfo());
1230 E->setBuiltinLoc(readSourceLocation());
1231 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001232 E->setIsMicrosoftABI(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001233}
1234
Eric Fiselier708afb52019-05-16 21:04:15 +00001235void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1236 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001237 E->ParentContext = readDeclAs<DeclContext>();
1238 E->BuiltinLoc = readSourceLocation();
1239 E->RParenLoc = readSourceLocation();
Eric Fiselier708afb52019-05-16 21:04:15 +00001240 E->SourceLocExprBits.Kind =
1241 static_cast<SourceLocExpr::IdentKind>(Record.readInt());
1242}
1243
Sebastian Redl70c751d2010-08-18 23:56:52 +00001244void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001245 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001246 E->setAmpAmpLoc(readSourceLocation());
1247 E->setLabelLoc(readSourceLocation());
1248 E->setLabel(readDeclAs<LabelDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001249}
1250
Sebastian Redl70c751d2010-08-18 23:56:52 +00001251void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001252 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001253 E->setLParenLoc(readSourceLocation());
1254 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001255 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
Richard Smith5c845c12020-03-09 17:34:33 -07001256 E->StmtExprBits.TemplateDepth = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001257}
1258
Sebastian Redl70c751d2010-08-18 23:56:52 +00001259void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001260 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001261 E->setCond(Record.readSubExpr());
1262 E->setLHS(Record.readSubExpr());
1263 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001264 E->setBuiltinLoc(readSourceLocation());
1265 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001266 E->setIsConditionTrue(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001267}
1268
Sebastian Redl70c751d2010-08-18 23:56:52 +00001269void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001270 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001271 E->setTokenLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001272}
1273
Sebastian Redl70c751d2010-08-18 23:56:52 +00001274void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001275 VisitExpr(E);
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001276 SmallVector<Expr *, 16> Exprs;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001277 unsigned NumExprs = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001278 while (NumExprs--)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001279 Exprs.push_back(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001280 E->setExprs(Record.getContext(), Exprs);
John McCall3ce3d232019-12-13 03:37:23 -05001281 E->setBuiltinLoc(readSourceLocation());
1282 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001283}
1284
Hal Finkelc4d7c822013-09-18 03:29:45 +00001285void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1286 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001287 E->BuiltinLoc = readSourceLocation();
1288 E->RParenLoc = readSourceLocation();
1289 E->TInfo = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001290 E->SrcExpr = Record.readSubExpr();
Hal Finkelc4d7c822013-09-18 03:29:45 +00001291}
1292
Sebastian Redl70c751d2010-08-18 23:56:52 +00001293void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001294 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001295 E->setBlockDecl(readDeclAs<BlockDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001296}
1297
Peter Collingbourne91147592011-04-15 00:35:48 +00001298void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1299 VisitExpr(E);
Bruno Riccidb076832019-01-26 14:15:10 +00001300
1301 unsigned NumAssocs = Record.readInt();
1302 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
Bruno Ricci94498c72019-01-26 13:58:15 +00001303 E->ResultIndex = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001304 E->GenericSelectionExprBits.GenericLoc = readSourceLocation();
1305 E->DefaultLoc = readSourceLocation();
1306 E->RParenLoc = readSourceLocation();
Bruno Riccidb076832019-01-26 14:15:10 +00001307
1308 Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1309 // Add 1 to account for the controlling expression which is the first
1310 // expression in the trailing array of Stmt *. This is not needed for
1311 // the trailing array of TypeSourceInfo *.
1312 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1313 Stmts[I] = Record.readSubExpr();
1314
1315 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1316 for (unsigned I = 0, N = NumAssocs; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001317 TSIs[I] = readTypeSourceInfo();
Peter Collingbourne91147592011-04-15 00:35:48 +00001318}
1319
John McCallfe96e0b2011-11-06 09:01:30 +00001320void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1321 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001322 unsigned numSemanticExprs = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001323 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001324 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001325
1326 // Read the syntactic expression.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001327 E->getSubExprsBuffer()[0] = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001328
1329 // Read all the semantic expressions.
1330 for (unsigned i = 0; i != numSemanticExprs; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001331 Expr *subExpr = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001332 E->getSubExprsBuffer()[i+1] = subExpr;
1333 }
1334}
1335
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001336void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1337 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001338 E->Op = AtomicExpr::AtomicOp(Record.readInt());
Richard Smithaa22a8c2012-04-10 22:49:28 +00001339 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1340 for (unsigned I = 0; I != E->NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001341 E->SubExprs[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001342 E->BuiltinLoc = readSourceLocation();
1343 E->RParenLoc = readSourceLocation();
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001344}
1345
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001346//===----------------------------------------------------------------------===//
1347// Objective-C Expressions and Statements
1348
Sebastian Redl70c751d2010-08-18 23:56:52 +00001349void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001350 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001351 E->setString(cast<StringLiteral>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -05001352 E->setAtLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001353}
1354
Patrick Beard0caa3942012-04-19 00:25:12 +00001355void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001356 VisitExpr(E);
1357 // could be one of several IntegerLiteral, FloatLiteral, etc.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001358 E->SubExpr = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -05001359 E->BoxingMethod = readDeclAs<ObjCMethodDecl>();
1360 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001361}
1362
1363void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1364 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001365 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001366 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1367 Expr **Elements = E->getElements();
1368 for (unsigned I = 0, N = NumElements; I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001369 Elements[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001370 E->ArrayWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1371 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001372}
1373
1374void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1375 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001376 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001377 assert(NumElements == E->getNumElements() && "Wrong number of elements");
David L. Jonesbe1557a2016-12-21 00:17:49 +00001378 bool HasPackExpansions = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001379 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001380 auto *KeyValues =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001381 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001382 auto *Expansions =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001383 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001384 for (unsigned I = 0; I != NumElements; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001385 KeyValues[I].Key = Record.readSubExpr();
1386 KeyValues[I].Value = Record.readSubExpr();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001387 if (HasPackExpansions) {
John McCall3ce3d232019-12-13 03:37:23 -05001388 Expansions[I].EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001389 Expansions[I].NumExpansionsPlusOne = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001390 }
1391 }
John McCall3ce3d232019-12-13 03:37:23 -05001392 E->DictWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1393 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001394}
1395
Sebastian Redl70c751d2010-08-18 23:56:52 +00001396void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001397 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001398 E->setEncodedTypeSourceInfo(readTypeSourceInfo());
1399 E->setAtLoc(readSourceLocation());
1400 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001401}
1402
Sebastian Redl70c751d2010-08-18 23:56:52 +00001403void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001404 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001405 E->setSelector(Record.readSelector());
John McCall3ce3d232019-12-13 03:37:23 -05001406 E->setAtLoc(readSourceLocation());
1407 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001408}
1409
Sebastian Redl70c751d2010-08-18 23:56:52 +00001410void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001411 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001412 E->setProtocol(readDeclAs<ObjCProtocolDecl>());
1413 E->setAtLoc(readSourceLocation());
1414 E->ProtoLoc = readSourceLocation();
1415 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001416}
1417
Sebastian Redl70c751d2010-08-18 23:56:52 +00001418void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001419 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001420 E->setDecl(readDeclAs<ObjCIvarDecl>());
1421 E->setLocation(readSourceLocation());
1422 E->setOpLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001423 E->setBase(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001424 E->setIsArrow(Record.readInt());
1425 E->setIsFreeIvar(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001426}
1427
Sebastian Redl70c751d2010-08-18 23:56:52 +00001428void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001429 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001430 unsigned MethodRefFlags = Record.readInt();
1431 bool Implicit = Record.readInt() != 0;
John McCallb7bd14f2010-12-02 01:19:52 +00001432 if (Implicit) {
John McCall3ce3d232019-12-13 03:37:23 -05001433 auto *Getter = readDeclAs<ObjCMethodDecl>();
1434 auto *Setter = readDeclAs<ObjCMethodDecl>();
Argyrios Kyrtzidisab468b02012-03-30 00:19:18 +00001435 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCallb7bd14f2010-12-02 01:19:52 +00001436 } else {
John McCall3ce3d232019-12-13 03:37:23 -05001437 E->setExplicitProperty(readDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001438 }
John McCall3ce3d232019-12-13 03:37:23 -05001439 E->setLocation(readSourceLocation());
1440 E->setReceiverLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001441 switch (Record.readInt()) {
John McCallb7bd14f2010-12-02 01:19:52 +00001442 case 0:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001443 E->setBase(Record.readSubExpr());
John McCallb7bd14f2010-12-02 01:19:52 +00001444 break;
1445 case 1:
David L. Jonesbe1557a2016-12-21 00:17:49 +00001446 E->setSuperReceiver(Record.readType());
John McCallb7bd14f2010-12-02 01:19:52 +00001447 break;
1448 case 2:
John McCall3ce3d232019-12-13 03:37:23 -05001449 E->setClassReceiver(readDeclAs<ObjCInterfaceDecl>());
John McCallb7bd14f2010-12-02 01:19:52 +00001450 break;
1451 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001452}
1453
Ted Kremeneke65b0862012-03-06 20:05:56 +00001454void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1455 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001456 E->setRBracket(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001457 E->setBaseExpr(Record.readSubExpr());
1458 E->setKeyExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001459 E->GetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1460 E->SetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001461}
1462
Sebastian Redl70c751d2010-08-18 23:56:52 +00001463void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001464 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001465 assert(Record.peekInt() == E->getNumArgs());
1466 Record.skipInts(1);
1467 unsigned NumStoredSelLocs = Record.readInt();
1468 E->SelLocsKind = Record.readInt();
1469 E->setDelegateInitCall(Record.readInt());
1470 E->IsImplicit = Record.readInt();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001471 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
Douglas Gregor9a129192010-04-21 00:45:42 +00001472 switch (Kind) {
1473 case ObjCMessageExpr::Instance:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001474 E->setInstanceReceiver(Record.readSubExpr());
Douglas Gregor9a129192010-04-21 00:45:42 +00001475 break;
1476
1477 case ObjCMessageExpr::Class:
John McCall3ce3d232019-12-13 03:37:23 -05001478 E->setClassReceiver(readTypeSourceInfo());
Douglas Gregor9a129192010-04-21 00:45:42 +00001479 break;
1480
1481 case ObjCMessageExpr::SuperClass:
1482 case ObjCMessageExpr::SuperInstance: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001483 QualType T = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001484 SourceLocation SuperLoc = readSourceLocation();
Douglas Gregor9a129192010-04-21 00:45:42 +00001485 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1486 break;
1487 }
1488 }
1489
1490 assert(Kind == E->getReceiverKind());
1491
David L. Jonesbe1557a2016-12-21 00:17:49 +00001492 if (Record.readInt())
John McCall3ce3d232019-12-13 03:37:23 -05001493 E->setMethodDecl(readDeclAs<ObjCMethodDecl>());
Douglas Gregor9a129192010-04-21 00:45:42 +00001494 else
David L. Jonesb6a8f022016-12-21 04:34:52 +00001495 E->setSelector(Record.readSelector());
Douglas Gregor9a129192010-04-21 00:45:42 +00001496
John McCall3ce3d232019-12-13 03:37:23 -05001497 E->LBracLoc = readSourceLocation();
1498 E->RBracLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001499
1500 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001501 E->setArg(I, Record.readSubExpr());
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00001502
1503 SourceLocation *Locs = E->getStoredSelLocs();
1504 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001505 Locs[I] = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001506}
1507
Sebastian Redl70c751d2010-08-18 23:56:52 +00001508void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001509 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001510 S->setElement(Record.readSubStmt());
1511 S->setCollection(Record.readSubExpr());
1512 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001513 S->setForLoc(readSourceLocation());
1514 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001515}
1516
Sebastian Redl70c751d2010-08-18 23:56:52 +00001517void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001518 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001519 S->setCatchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001520 S->setCatchParamDecl(readDeclAs<VarDecl>());
1521 S->setAtCatchLoc(readSourceLocation());
1522 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001523}
1524
Sebastian Redl70c751d2010-08-18 23:56:52 +00001525void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001526 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001527 S->setFinallyBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001528 S->setAtFinallyLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001529}
1530
John McCall31168b02011-06-15 23:02:42 +00001531void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001532 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001533 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001534 S->setAtLoc(readSourceLocation());
John McCall31168b02011-06-15 23:02:42 +00001535}
1536
Sebastian Redl70c751d2010-08-18 23:56:52 +00001537void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001538 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001539 assert(Record.peekInt() == S->getNumCatchStmts());
1540 Record.skipInts(1);
1541 bool HasFinally = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001542 S->setTryBody(Record.readSubStmt());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001543 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001544 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
Douglas Gregor96c79492010-04-23 22:50:49 +00001545
Douglas Gregor96c79492010-04-23 22:50:49 +00001546 if (HasFinally)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001547 S->setFinallyStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001548 S->setAtTryLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001549}
1550
Sebastian Redl70c751d2010-08-18 23:56:52 +00001551void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001552 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001553 S->setSynchExpr(Record.readSubStmt());
1554 S->setSynchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001555 S->setAtSynchronizedLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001556}
1557
Sebastian Redl70c751d2010-08-18 23:56:52 +00001558void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001559 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001560 S->setThrowExpr(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001561 S->setThrowLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001562}
1563
Ted Kremeneke65b0862012-03-06 20:05:56 +00001564void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1565 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001566 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001567 E->setLocation(readSourceLocation());
Ted Kremeneke65b0862012-03-06 20:05:56 +00001568}
1569
Erik Pilkington29099de2016-07-16 00:35:23 +00001570void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1571 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001572 SourceRange R = Record.readSourceRange();
Erik Pilkington29099de2016-07-16 00:35:23 +00001573 E->AtLoc = R.getBegin();
1574 E->RParen = R.getEnd();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001575 E->VersionToCheck = Record.readVersionTuple();
Erik Pilkington29099de2016-07-16 00:35:23 +00001576}
1577
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001578//===----------------------------------------------------------------------===//
1579// C++ Expressions and Statements
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001580//===----------------------------------------------------------------------===//
1581
Sebastian Redl70c751d2010-08-18 23:56:52 +00001582void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001583 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001584 S->CatchLoc = readSourceLocation();
1585 S->ExceptionDecl = readDeclAs<VarDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001586 S->HandlerBlock = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001587}
1588
Sebastian Redl70c751d2010-08-18 23:56:52 +00001589void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001590 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001591 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1592 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -05001593 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001594 S->getStmts()[0] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001595 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001596 S->getStmts()[i + 1] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001597}
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001598
Richard Smith02e85f32011-04-14 22:09:26 +00001599void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1600 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001601 S->ForLoc = readSourceLocation();
1602 S->CoawaitLoc = readSourceLocation();
1603 S->ColonLoc = readSourceLocation();
1604 S->RParenLoc = readSourceLocation();
Richard Smith8baa5002018-09-28 18:44:09 +00001605 S->setInit(Record.readSubStmt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001606 S->setRangeStmt(Record.readSubStmt());
1607 S->setBeginStmt(Record.readSubStmt());
1608 S->setEndStmt(Record.readSubStmt());
1609 S->setCond(Record.readSubExpr());
1610 S->setInc(Record.readSubExpr());
1611 S->setLoopVarStmt(Record.readSubStmt());
1612 S->setBody(Record.readSubStmt());
Richard Smith02e85f32011-04-14 22:09:26 +00001613}
1614
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001615void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1616 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001617 S->KeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001618 S->IsIfExists = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001619 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001620 S->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001621 S->SubStmt = Record.readSubStmt();
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001622}
1623
Sebastian Redl70c751d2010-08-18 23:56:52 +00001624void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001625 VisitCallExpr(E);
Bruno Riccifeb19232018-12-21 16:51:57 +00001626 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1627 E->CXXOperatorCallExprBits.FPFeatures = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001628 E->Range = Record.readSourceRange();
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001629}
1630
Richard Smith778dc0f2019-10-19 00:04:38 +00001631void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1632 CXXRewrittenBinaryOperator *E) {
1633 VisitExpr(E);
1634 E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1635 E->SemanticForm = Record.readSubExpr();
1636}
1637
Sebastian Redl70c751d2010-08-18 23:56:52 +00001638void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001639 VisitExpr(E);
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001640
1641 unsigned NumArgs = Record.readInt();
1642 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1643
1644 E->CXXConstructExprBits.Elidable = Record.readInt();
1645 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1646 E->CXXConstructExprBits.ListInitialization = Record.readInt();
1647 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1648 E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1649 E->CXXConstructExprBits.ConstructionKind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001650 E->CXXConstructExprBits.Loc = readSourceLocation();
1651 E->Constructor = readDeclAs<CXXConstructorDecl>();
1652 E->ParenOrBraceRange = readSourceRange();
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001653
1654 for (unsigned I = 0; I != NumArgs; ++I)
1655 E->setArg(I, Record.readSubExpr());
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001656}
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001657
Richard Smith5179eb72016-06-28 19:03:57 +00001658void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1659 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001660 E->Constructor = readDeclAs<CXXConstructorDecl>();
1661 E->Loc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001662 E->ConstructsVirtualBase = Record.readInt();
1663 E->InheritedFromVirtualBase = Record.readInt();
Richard Smith5179eb72016-06-28 19:03:57 +00001664}
1665
Sebastian Redl70c751d2010-08-18 23:56:52 +00001666void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001667 VisitCXXConstructExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001668 E->TSI = readTypeSourceInfo();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001669}
1670
Douglas Gregore31e6062012-02-07 10:09:13 +00001671void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1672 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001673 unsigned NumCaptures = Record.readInt();
Douglas Gregor99ae8062012-02-14 17:54:36 +00001674 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
John McCall3ce3d232019-12-13 03:37:23 -05001675 E->IntroducerRange = readSourceRange();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001676 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001677 E->CaptureDefaultLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001678 E->ExplicitParams = Record.readInt();
1679 E->ExplicitResultType = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001680 E->ClosingBrace = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001681
Douglas Gregor99ae8062012-02-14 17:54:36 +00001682 // Read capture initializers.
1683 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1684 CEnd = E->capture_init_end();
1685 C != CEnd; ++C)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001686 *C = Record.readSubExpr();
Douglas Gregore31e6062012-02-07 10:09:13 +00001687}
1688
Richard Smithcc1b96d2013-06-12 22:31:48 +00001689void
1690ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1691 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001692 E->SubExpr = Record.readSubExpr();
Richard Smithcc1b96d2013-06-12 22:31:48 +00001693}
1694
Sebastian Redl70c751d2010-08-18 23:56:52 +00001695void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001696 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001697 SourceRange R = readSourceRange();
Douglas Gregor4478f852011-01-12 22:41:29 +00001698 E->Loc = R.getBegin();
1699 E->RParenLoc = R.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05001700 R = readSourceRange();
Fariborz Jahanianf0738712013-02-22 22:02:53 +00001701 E->AngleBrackets = R;
Sam Weinigd01101e2010-01-16 21:21:01 +00001702}
1703
Sebastian Redl70c751d2010-08-18 23:56:52 +00001704void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001705 return VisitCXXNamedCastExpr(E);
1706}
1707
Sebastian Redl70c751d2010-08-18 23:56:52 +00001708void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001709 return VisitCXXNamedCastExpr(E);
1710}
1711
Sebastian Redl70c751d2010-08-18 23:56:52 +00001712void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001713 return VisitCXXNamedCastExpr(E);
1714}
1715
Sebastian Redl70c751d2010-08-18 23:56:52 +00001716void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001717 return VisitCXXNamedCastExpr(E);
1718}
1719
Sebastian Redl70c751d2010-08-18 23:56:52 +00001720void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001721 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001722 E->setLParenLoc(readSourceLocation());
1723 E->setRParenLoc(readSourceLocation());
Sam Weinigd01101e2010-01-16 21:21:01 +00001724}
1725
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001726void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1727 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001728 E->KWLoc = readSourceLocation();
1729 E->RParenLoc = readSourceLocation();
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001730}
1731
Richard Smithc67fdd42012-03-07 08:35:16 +00001732void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1733 VisitCallExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001734 E->UDSuffixLoc = readSourceLocation();
Richard Smithc67fdd42012-03-07 08:35:16 +00001735}
1736
Sebastian Redl70c751d2010-08-18 23:56:52 +00001737void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001738 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001739 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001740 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001741}
1742
Sebastian Redl70c751d2010-08-18 23:56:52 +00001743void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001744 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001745 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001746}
1747
Sebastian Redl70c751d2010-08-18 23:56:52 +00001748void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001749 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001750 E->setSourceRange(readSourceRange());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001751 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redlc67764e2010-07-22 22:43:28 +00001752 E->setTypeOperandSourceInfo(
John McCall3ce3d232019-12-13 03:37:23 -05001753 readTypeSourceInfo());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001754 return;
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001755 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001756
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001757 // typeid(42+2)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001758 E->setExprOperand(Record.readSubExpr());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001759}
1760
Sebastian Redl70c751d2010-08-18 23:56:52 +00001761void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001762 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001763 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001764 E->setImplicit(Record.readInt());
Chris Lattner98267332010-05-09 06:15:05 +00001765}
1766
Sebastian Redl70c751d2010-08-18 23:56:52 +00001767void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001768 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001769 E->CXXThrowExprBits.ThrowLoc = readSourceLocation();
Bruno Riccib7de97b2018-11-17 12:53:56 +00001770 E->Operand = Record.readSubExpr();
1771 E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
Chris Lattner98267332010-05-09 06:15:05 +00001772}
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001773
Sebastian Redl70c751d2010-08-18 23:56:52 +00001774void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattnere2437f42010-05-09 06:40:08 +00001775 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001776 E->Param = readDeclAs<ParmVarDecl>();
1777 E->UsedContext = readDeclAs<DeclContext>();
1778 E->CXXDefaultArgExprBits.Loc = readSourceLocation();
Chris Lattnercba86142010-05-10 00:25:06 +00001779}
1780
Richard Smith852c9db2013-04-20 22:23:05 +00001781void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1782 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001783 E->Field = readDeclAs<FieldDecl>();
1784 E->UsedContext = readDeclAs<DeclContext>();
1785 E->CXXDefaultInitExprBits.Loc = readSourceLocation();
Richard Smith852c9db2013-04-20 22:23:05 +00001786}
1787
Sebastian Redl70c751d2010-08-18 23:56:52 +00001788void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001789 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001790 E->setTemporary(Record.readCXXTemporary());
1791 E->setSubExpr(Record.readSubExpr());
Chris Lattnercba86142010-05-10 00:25:06 +00001792}
1793
Sebastian Redl70c751d2010-08-18 23:56:52 +00001794void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001795 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001796 E->TypeInfo = readTypeSourceInfo();
1797 E->CXXScalarValueInitExprBits.RParenLoc = readSourceLocation();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001798}
1799
Sebastian Redl70c751d2010-08-18 23:56:52 +00001800void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001801 VisitExpr(E);
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001802
1803 bool IsArray = Record.readInt();
1804 bool HasInit = Record.readInt();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001805 unsigned NumPlacementArgs = Record.readInt();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001806 bool IsParenTypeId = Record.readInt();
1807
1808 E->CXXNewExprBits.IsGlobalNew = Record.readInt();
1809 E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
1810 E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1811 E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
1812
1813 assert((IsArray == E->isArray()) && "Wrong IsArray!");
1814 assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
1815 assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
1816 "Wrong NumPlacementArgs!");
1817 assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
1818 (void)IsArray;
1819 (void)HasInit;
1820 (void)NumPlacementArgs;
1821
John McCall3ce3d232019-12-13 03:37:23 -05001822 E->setOperatorNew(readDeclAs<FunctionDecl>());
1823 E->setOperatorDelete(readDeclAs<FunctionDecl>());
1824 E->AllocatedTypeInfo = readTypeSourceInfo();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001825 if (IsParenTypeId)
John McCall3ce3d232019-12-13 03:37:23 -05001826 E->getTrailingObjects<SourceRange>()[0] = readSourceRange();
1827 E->Range = readSourceRange();
1828 E->DirectInitRange = readSourceRange();
Chandler Carruth01718152010-10-25 08:47:36 +00001829
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001830 // Install all the subexpressions.
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001831 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
1832 N = E->raw_arg_end();
1833 I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001834 *I = Record.readSubStmt();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001835}
1836
Sebastian Redl70c751d2010-08-18 23:56:52 +00001837void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001838 VisitExpr(E);
Bruno Ricci91728fc2018-12-03 12:32:32 +00001839 E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
1840 E->CXXDeleteExprBits.ArrayForm = Record.readInt();
1841 E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
1842 E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001843 E->OperatorDelete = readDeclAs<FunctionDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001844 E->Argument = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001845 E->CXXDeleteExprBits.Loc = readSourceLocation();
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001846}
Chris Lattnercba86142010-05-10 00:25:06 +00001847
Sebastian Redl70c751d2010-08-18 23:56:52 +00001848void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001849 VisitExpr(E);
1850
David L. Jonesb6a8f022016-12-21 04:34:52 +00001851 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001852 E->IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001853 E->OperatorLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001854 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001855 E->ScopeType = readTypeSourceInfo();
1856 E->ColonColonLoc = readSourceLocation();
1857 E->TildeLoc = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001858
John McCall3ce3d232019-12-13 03:37:23 -05001859 IdentifierInfo *II = Record.readIdentifier();
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001860 if (II)
John McCall3ce3d232019-12-13 03:37:23 -05001861 E->setDestroyedType(II, readSourceLocation());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001862 else
John McCall3ce3d232019-12-13 03:37:23 -05001863 E->setDestroyedType(readTypeSourceInfo());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001864}
1865
John McCall5d413782010-12-06 08:20:24 +00001866void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001867 VisitExpr(E);
John McCall28fc7092011-11-10 05:35:25 +00001868
David L. Jonesbe1557a2016-12-21 00:17:49 +00001869 unsigned NumObjects = Record.readInt();
John McCall28fc7092011-11-10 05:35:25 +00001870 assert(NumObjects == E->getNumObjects());
Akira Hatanaka40568fe2020-03-10 14:06:25 -07001871 for (unsigned i = 0; i != NumObjects; ++i) {
1872 unsigned CleanupKind = Record.readInt();
1873 ExprWithCleanups::CleanupObject Obj;
1874 if (CleanupKind == COK_Block)
1875 Obj = readDeclAs<BlockDecl>();
1876 else if (CleanupKind == COK_CompoundLiteral)
1877 Obj = cast<CompoundLiteralExpr>(Record.readSubExpr());
1878 else
1879 llvm_unreachable("unexpected cleanup object type");
1880 E->getTrailingObjects<ExprWithCleanups::CleanupObject>()[i] = Obj;
1881 }
John McCall28fc7092011-11-10 05:35:25 +00001882
David L. Jonesbe1557a2016-12-21 00:17:49 +00001883 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001884 E->SubExpr = Record.readSubExpr();
Chris Lattnere2437f42010-05-09 06:40:08 +00001885}
1886
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001887void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1888 CXXDependentScopeMemberExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001889 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001890
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001891 bool HasTemplateKWAndArgsInfo = Record.readInt();
1892 unsigned NumTemplateArgs = Record.readInt();
1893 bool HasFirstQualifierFoundInScope = Record.readInt();
1894
1895 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
1896 "Wrong HasTemplateKWAndArgsInfo!");
1897 assert(
1898 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
1899 "Wrong HasFirstQualifierFoundInScope!");
1900
1901 if (HasTemplateKWAndArgsInfo)
James Y Knighte7d82282015-12-29 18:15:14 +00001902 ReadTemplateKWAndArgsInfo(
1903 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001904 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001905
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001906 assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
1907 "Wrong NumTemplateArgs!");
1908
1909 E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001910 E->CXXDependentScopeMemberExprBits.OperatorLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001911 E->BaseType = Record.readType();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001912 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001913 E->Base = Record.readSubExpr();
1914
1915 if (HasFirstQualifierFoundInScope)
John McCall3ce3d232019-12-13 03:37:23 -05001916 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001917
John McCall3ce3d232019-12-13 03:37:23 -05001918 E->MemberNameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001919}
1920
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001921void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001922ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001923 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001924
David L. Jonesbe1557a2016-12-21 00:17:49 +00001925 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001926 ReadTemplateKWAndArgsInfo(
1927 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1928 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001929 /*NumTemplateArgs=*/Record.readInt());
Douglas Gregor3a43fd62011-02-25 20:49:16 +00001930
David L. Jonesb6a8f022016-12-21 04:34:52 +00001931 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001932 E->NameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001933}
1934
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001935void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001936ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001937 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001938 assert(Record.peekInt() == E->arg_size() &&
1939 "Read wrong record during creation ?");
1940 Record.skipInts(1);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001941 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001942 E->setArg(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001943 E->TSI = readTypeSourceInfo();
1944 E->setLParenLoc(readSourceLocation());
1945 E->setRParenLoc(readSourceLocation());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001946}
1947
Sebastian Redl70c751d2010-08-18 23:56:52 +00001948void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001949 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001950
Bruno Riccid7628d92019-01-09 15:43:19 +00001951 unsigned NumResults = Record.readInt();
1952 bool HasTemplateKWAndArgsInfo = Record.readInt();
1953 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
1954 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
1955 "Wrong HasTemplateKWAndArgsInfo!");
1956
1957 if (HasTemplateKWAndArgsInfo) {
1958 unsigned NumTemplateArgs = Record.readInt();
James Y Knighte7d82282015-12-29 18:15:14 +00001959 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1960 E->getTrailingTemplateArgumentLoc(),
Bruno Riccid7628d92019-01-09 15:43:19 +00001961 NumTemplateArgs);
1962 assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
1963 "Wrong NumTemplateArgs!");
1964 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001965
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001966 UnresolvedSet<8> Decls;
Bruno Riccid7628d92019-01-09 15:43:19 +00001967 for (unsigned I = 0; I != NumResults; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -05001968 auto *D = readDeclAs<NamedDecl>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001969 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001970 Decls.addDecl(D, AS);
1971 }
Bruno Riccid7628d92019-01-09 15:43:19 +00001972
1973 DeclAccessPair *Results = E->getTrailingResults();
1974 UnresolvedSetIterator Iter = Decls.begin();
1975 for (unsigned I = 0; I != NumResults; ++I) {
1976 Results[I] = (Iter + I).getPair();
1977 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001978
John McCall3ce3d232019-12-13 03:37:23 -05001979 E->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001980 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001981}
1982
Sebastian Redl70c751d2010-08-18 23:56:52 +00001983void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001984 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00001985 E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
1986 E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001987 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001988 E->BaseType = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001989 E->OperatorLoc = readSourceLocation();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001990}
1991
Sebastian Redl70c751d2010-08-18 23:56:52 +00001992void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001993 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00001994 E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
1995 E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001996 E->NamingClass = readDeclAs<CXXRecordDecl>();
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00001997}
1998
Douglas Gregor29c42f22012-02-24 07:38:34 +00001999void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
2000 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002001 E->TypeTraitExprBits.NumArgs = Record.readInt();
2002 E->TypeTraitExprBits.Kind = Record.readInt();
2003 E->TypeTraitExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002004 SourceRange Range = readSourceRange();
Jordan Rose99e80c12013-12-20 01:26:47 +00002005 E->Loc = Range.getBegin();
2006 E->RParenLoc = Range.getEnd();
2007
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002008 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
Douglas Gregor29c42f22012-02-24 07:38:34 +00002009 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05002010 Args[I] = readTypeSourceInfo();
Douglas Gregor29c42f22012-02-24 07:38:34 +00002011}
2012
John Wiegley6242b6a2011-04-28 00:16:57 +00002013void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
2014 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002015 E->ATT = (ArrayTypeTrait)Record.readInt();
2016 E->Value = (unsigned int)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002017 SourceRange Range = readSourceRange();
John Wiegley6242b6a2011-04-28 00:16:57 +00002018 E->Loc = Range.getBegin();
2019 E->RParen = Range.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05002020 E->QueriedType = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002021 E->Dimension = Record.readSubExpr();
John Wiegley6242b6a2011-04-28 00:16:57 +00002022}
2023
John Wiegleyf9f65842011-04-25 06:54:41 +00002024void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
2025 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002026 E->ET = (ExpressionTrait)Record.readInt();
2027 E->Value = (bool)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002028 SourceRange Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002029 E->QueriedExpression = Record.readSubExpr();
John Wiegleyf9f65842011-04-25 06:54:41 +00002030 E->Loc = Range.getBegin();
2031 E->RParen = Range.getEnd();
2032}
2033
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00002034void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
2035 VisitExpr(E);
Bruno Riccid56edfe2019-01-08 14:44:34 +00002036 E->CXXNoexceptExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002037 E->Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002038 E->Operand = Record.readSubExpr();
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00002039}
2040
Douglas Gregore8e9dd62011-01-03 17:17:50 +00002041void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
2042 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002043 E->EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002044 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002045 E->Pattern = Record.readSubExpr();
Douglas Gregore8e9dd62011-01-03 17:17:50 +00002046}
2047
Douglas Gregor820ba7b2011-01-04 17:33:58 +00002048void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2049 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002050 unsigned NumPartialArgs = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002051 E->OperatorLoc = readSourceLocation();
2052 E->PackLoc = readSourceLocation();
2053 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002054 E->Pack = Record.readDeclAs<NamedDecl>();
Richard Smithd784e682015-09-23 21:41:42 +00002055 if (E->isPartiallySubstituted()) {
2056 assert(E->Length == NumPartialArgs);
James Y Knighte00a67e2015-12-31 04:18:25 +00002057 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
Richard Smithd784e682015-09-23 21:41:42 +00002058 *E = I + NumPartialArgs;
2059 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002060 new (I) TemplateArgument(Record.readTemplateArgument());
Richard Smithd784e682015-09-23 21:41:42 +00002061 } else if (!E->isValueDependent()) {
David L. Jonesbe1557a2016-12-21 00:17:49 +00002062 E->Length = Record.readInt();
Richard Smithd784e682015-09-23 21:41:42 +00002063 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00002064}
2065
John McCallfa194042011-07-15 07:00:14 +00002066void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
2067 SubstNonTypeTemplateParmExpr *E) {
2068 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002069 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
2070 E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002071 E->Replacement = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002072}
2073
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002074void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
2075 SubstNonTypeTemplateParmPackExpr *E) {
2076 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002077 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002078 TemplateArgument ArgPack = Record.readTemplateArgument();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002079 if (ArgPack.getKind() != TemplateArgument::Pack)
2080 return;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002081
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002082 E->Arguments = ArgPack.pack_begin();
2083 E->NumArguments = ArgPack.pack_size();
John McCall3ce3d232019-12-13 03:37:23 -05002084 E->NameLoc = readSourceLocation();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002085}
2086
Richard Smithb15fe3a2012-09-12 00:56:43 +00002087void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2088 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002089 E->NumParameters = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002090 E->ParamPack = readDeclAs<ParmVarDecl>();
2091 E->NameLoc = readSourceLocation();
Richard Smithb2997f52019-05-21 20:10:50 +00002092 auto **Parms = E->getTrailingObjects<VarDecl *>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00002093 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
John McCall3ce3d232019-12-13 03:37:23 -05002094 Parms[i] = readDeclAs<VarDecl>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00002095}
2096
Douglas Gregorfe314812011-06-21 17:03:29 +00002097void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
2098 VisitExpr(E);
Tykerb0561b32019-11-17 11:41:55 +01002099 bool HasMaterialzedDecl = Record.readInt();
2100 if (HasMaterialzedDecl)
2101 E->State = cast<LifetimeExtendedTemporaryDecl>(Record.readDecl());
2102 else
2103 E->State = Record.readSubExpr();
Douglas Gregorfe314812011-06-21 17:03:29 +00002104}
2105
Richard Smith0f0af192014-11-08 05:07:16 +00002106void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
2107 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002108 E->LParenLoc = readSourceLocation();
2109 E->EllipsisLoc = readSourceLocation();
2110 E->RParenLoc = readSourceLocation();
Richard Smithc7214f62019-05-13 08:31:14 +00002111 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002112 E->SubExprs[0] = Record.readSubExpr();
2113 E->SubExprs[1] = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002114 E->Opcode = (BinaryOperatorKind)Record.readInt();
Richard Smith0f0af192014-11-08 05:07:16 +00002115}
2116
John McCall8d69a212010-11-15 23:31:06 +00002117void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
2118 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002119 E->SourceExpr = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05002120 E->OpaqueValueExprBits.Loc = readSourceLocation();
Akira Hatanaka797afe32018-03-20 01:47:58 +00002121 E->setIsUnique(Record.readInt());
John McCall8d69a212010-11-15 23:31:06 +00002122}
2123
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00002124void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
2125 llvm_unreachable("Cannot read TypoExpr nodes");
2126}
2127
Haojian Wu733edf92020-03-19 16:30:40 +01002128void ASTStmtReader::VisitRecoveryExpr(RecoveryExpr *E) {
2129 VisitExpr(E);
2130 unsigned NumArgs = Record.readInt();
2131 E->BeginLoc = readSourceLocation();
2132 E->EndLoc = readSourceLocation();
2133 assert(
2134 (NumArgs == std::distance(E->children().begin(), E->children().end())) &&
2135 "Wrong NumArgs!");
2136 (void)NumArgs;
2137 for (Stmt *&Child : E->children())
2138 Child = Record.readSubStmt();
2139}
2140
Peter Collingbourne41f85462011-02-09 21:07:24 +00002141//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002142// Microsoft Expressions and Statements
2143//===----------------------------------------------------------------------===//
John McCall5e77d762013-04-16 07:28:30 +00002144void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
2145 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002146 E->IsArrow = (Record.readInt() != 0);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002147 E->BaseExpr = Record.readSubExpr();
2148 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05002149 E->MemberLoc = readSourceLocation();
2150 E->TheDecl = readDeclAs<MSPropertyDecl>();
John McCall5e77d762013-04-16 07:28:30 +00002151}
2152
Alexey Bataevf7630272015-11-25 12:01:00 +00002153void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
2154 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002155 E->setBase(Record.readSubExpr());
2156 E->setIdx(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05002157 E->setRBracketLoc(readSourceLocation());
Alexey Bataevf7630272015-11-25 12:01:00 +00002158}
2159
John McCallfa194042011-07-15 07:00:14 +00002160void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
2161 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002162 E->setSourceRange(readSourceRange());
2163 std::string UuidStr = readString();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002164 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
John McCallfa194042011-07-15 07:00:14 +00002165 if (E->isTypeOperand()) { // __uuidof(ComType)
2166 E->setTypeOperandSourceInfo(
John McCall3ce3d232019-12-13 03:37:23 -05002167 readTypeSourceInfo());
John McCallfa194042011-07-15 07:00:14 +00002168 return;
2169 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002170
John McCallfa194042011-07-15 07:00:14 +00002171 // __uuidof(expr)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002172 E->setExprOperand(Record.readSubExpr());
John McCallfa194042011-07-15 07:00:14 +00002173}
2174
Nico Weber9b982072014-07-07 00:12:30 +00002175void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
2176 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002177 S->setLeaveLoc(readSourceLocation());
Nico Weber9b982072014-07-07 00:12:30 +00002178}
2179
John McCallfa194042011-07-15 07:00:14 +00002180void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
2181 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002182 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002183 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
2184 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002185}
2186
2187void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
2188 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002189 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002190 S->Block = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002191}
2192
2193void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
2194 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002195 S->IsCXXTry = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002196 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002197 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
2198 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002199}
2200
2201//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00002202// CUDA Expressions and Statements
2203//===----------------------------------------------------------------------===//
2204
2205void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2206 VisitCallExpr(E);
Richard Smithfd420792019-05-24 23:26:07 +00002207 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
Peter Collingbourne41f85462011-02-09 21:07:24 +00002208}
2209
John McCallfa194042011-07-15 07:00:14 +00002210//===----------------------------------------------------------------------===//
2211// OpenCL Expressions and Statements.
2212//===----------------------------------------------------------------------===//
2213void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2214 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002215 E->BuiltinLoc = readSourceLocation();
2216 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002217 E->SrcExpr = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002218}
2219
2220//===----------------------------------------------------------------------===//
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002221// OpenMP Directives.
2222//===----------------------------------------------------------------------===//
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002223
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002224void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
John McCall3ce3d232019-12-13 03:37:23 -05002225 E->setLocStart(readSourceLocation());
2226 E->setLocEnd(readSourceLocation());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002227 SmallVector<OMPClause *, 5> Clauses;
2228 for (unsigned i = 0; i < E->getNumClauses(); ++i)
John McCallc2f18312019-12-14 03:01:28 -05002229 Clauses.push_back(Record.readOMPClause());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002230 E->setClauses(Clauses);
Alexey Bataev68446b72014-07-18 07:47:19 +00002231 if (E->hasAssociatedStmt())
David L. Jonesb6a8f022016-12-21 04:34:52 +00002232 E->setAssociatedStmt(Record.readSubStmt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002233}
2234
Alexander Musman3aaab662014-08-19 11:27:13 +00002235void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2236 VisitStmt(D);
2237 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002238 Record.skipInts(2);
Alexander Musman3aaab662014-08-19 11:27:13 +00002239 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002240 D->setIterationVariable(Record.readSubExpr());
2241 D->setLastIteration(Record.readSubExpr());
2242 D->setCalcLastIteration(Record.readSubExpr());
2243 D->setPreCond(Record.readSubExpr());
2244 D->setCond(Record.readSubExpr());
2245 D->setInit(Record.readSubExpr());
2246 D->setInc(Record.readSubExpr());
2247 D->setPreInits(Record.readSubStmt());
Alexey Bataev3392d762016-02-16 11:18:12 +00002248 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
Carlo Bertollifc35ad22016-03-07 16:04:49 +00002249 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2250 isOpenMPDistributeDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002251 D->setIsLastIterVariable(Record.readSubExpr());
2252 D->setLowerBoundVariable(Record.readSubExpr());
2253 D->setUpperBoundVariable(Record.readSubExpr());
2254 D->setStrideVariable(Record.readSubExpr());
2255 D->setEnsureUpperBound(Record.readSubExpr());
2256 D->setNextLowerBound(Record.readSubExpr());
2257 D->setNextUpperBound(Record.readSubExpr());
2258 D->setNumIterations(Record.readSubExpr());
Alexander Musmanc6388682014-12-15 07:07:06 +00002259 }
Carlo Bertolli9925f152016-06-27 14:55:37 +00002260 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002261 D->setPrevLowerBoundVariable(Record.readSubExpr());
2262 D->setPrevUpperBoundVariable(Record.readSubExpr());
Carlo Bertolli8429d812017-02-17 21:29:13 +00002263 D->setDistInc(Record.readSubExpr());
2264 D->setPrevEnsureUpperBound(Record.readSubExpr());
Carlo Bertolliffafe102017-04-20 00:39:39 +00002265 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2266 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2267 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2268 D->setCombinedInit(Record.readSubExpr());
2269 D->setCombinedCond(Record.readSubExpr());
2270 D->setCombinedNextLowerBound(Record.readSubExpr());
2271 D->setCombinedNextUpperBound(Record.readSubExpr());
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00002272 D->setCombinedDistCond(Record.readSubExpr());
2273 D->setCombinedParForInDistCond(Record.readSubExpr());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002274 }
Alexander Musmana5f070a2014-10-01 06:03:56 +00002275 SmallVector<Expr *, 4> Sub;
2276 unsigned CollapsedNum = D->getCollapsedNumber();
2277 Sub.reserve(CollapsedNum);
2278 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002279 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002280 D->setCounters(Sub);
2281 Sub.clear();
2282 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002283 Sub.push_back(Record.readSubExpr());
Alexey Bataeva8899172015-08-06 12:30:57 +00002284 D->setPrivateCounters(Sub);
2285 Sub.clear();
2286 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002287 Sub.push_back(Record.readSubExpr());
Alexey Bataevb08f89f2015-08-14 12:25:37 +00002288 D->setInits(Sub);
2289 Sub.clear();
2290 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002291 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002292 D->setUpdates(Sub);
2293 Sub.clear();
2294 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002295 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002296 D->setFinals(Sub);
Alexey Bataevf8be4762019-08-14 19:30:06 +00002297 Sub.clear();
2298 for (unsigned i = 0; i < CollapsedNum; ++i)
2299 Sub.push_back(Record.readSubExpr());
2300 D->setDependentCounters(Sub);
2301 Sub.clear();
2302 for (unsigned i = 0; i < CollapsedNum; ++i)
2303 Sub.push_back(Record.readSubExpr());
2304 D->setDependentInits(Sub);
2305 Sub.clear();
2306 for (unsigned i = 0; i < CollapsedNum; ++i)
2307 Sub.push_back(Record.readSubExpr());
2308 D->setFinalsConditions(Sub);
Alexander Musman3aaab662014-08-19 11:27:13 +00002309}
2310
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002311void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002312 VisitStmt(D);
2313 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002314 Record.skipInts(1);
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002315 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002316 D->setHasCancel(Record.readInt());
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002317}
2318
2319void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002320 VisitOMPLoopDirective(D);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002321}
2322
Alexey Bataevf29276e2014-06-18 04:14:57 +00002323void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002324 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002325 D->setHasCancel(Record.readInt());
Alexey Bataevf29276e2014-06-18 04:14:57 +00002326}
2327
Alexander Musmanf82886e2014-09-18 05:12:34 +00002328void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2329 VisitOMPLoopDirective(D);
2330}
2331
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002332void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2333 VisitStmt(D);
2334 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002335 Record.skipInts(1);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002336 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002337 D->setHasCancel(Record.readInt());
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002338}
2339
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002340void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2341 VisitStmt(D);
2342 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002343 D->setHasCancel(Record.readInt());
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002344}
2345
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002346void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2347 VisitStmt(D);
2348 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002349 Record.skipInts(1);
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002350 VisitOMPExecutableDirective(D);
2351}
2352
Alexander Musman80c22892014-07-17 08:54:58 +00002353void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2354 VisitStmt(D);
2355 VisitOMPExecutableDirective(D);
2356}
2357
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002358void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2359 VisitStmt(D);
Alexey Bataev28c75412015-12-15 08:19:24 +00002360 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002361 Record.skipInts(1);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002362 VisitOMPExecutableDirective(D);
John McCall3ce3d232019-12-13 03:37:23 -05002363 D->DirName = Record.readDeclarationNameInfo();
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002364}
2365
Alexey Bataev4acb8592014-07-07 13:01:15 +00002366void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002367 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002368 D->setHasCancel(Record.readInt());
Alexey Bataev4acb8592014-07-07 13:01:15 +00002369}
2370
Alexander Musmane4e893b2014-09-23 09:33:00 +00002371void ASTStmtReader::VisitOMPParallelForSimdDirective(
2372 OMPParallelForSimdDirective *D) {
2373 VisitOMPLoopDirective(D);
2374}
2375
cchen47d60942019-12-05 13:43:48 -05002376void ASTStmtReader::VisitOMPParallelMasterDirective(
2377 OMPParallelMasterDirective *D) {
2378 VisitStmt(D);
2379 // The NumClauses field was read in ReadStmtFromStream.
2380 Record.skipInts(1);
2381 VisitOMPExecutableDirective(D);
2382}
2383
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002384void ASTStmtReader::VisitOMPParallelSectionsDirective(
2385 OMPParallelSectionsDirective *D) {
2386 VisitStmt(D);
2387 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002388 Record.skipInts(1);
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002389 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002390 D->setHasCancel(Record.readInt());
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002391}
2392
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002393void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2394 VisitStmt(D);
2395 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002396 Record.skipInts(1);
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002397 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002398 D->setHasCancel(Record.readInt());
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002399}
2400
Alexey Bataev68446b72014-07-18 07:47:19 +00002401void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2402 VisitStmt(D);
2403 VisitOMPExecutableDirective(D);
2404}
2405
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002406void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2407 VisitStmt(D);
2408 VisitOMPExecutableDirective(D);
2409}
2410
Alexey Bataev2df347a2014-07-18 10:17:07 +00002411void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2412 VisitStmt(D);
2413 VisitOMPExecutableDirective(D);
2414}
2415
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002416void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2417 VisitStmt(D);
Alexey Bataev169d96a2017-07-18 20:17:46 +00002418 // The NumClauses field was read in ReadStmtFromStream.
2419 Record.skipInts(1);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002420 VisitOMPExecutableDirective(D);
Alexey Bataev3b1b8952017-07-25 15:53:26 +00002421 D->setReductionRef(Record.readSubExpr());
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002422}
2423
Alexey Bataev6125da92014-07-21 11:26:11 +00002424void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2425 VisitStmt(D);
2426 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002427 Record.skipInts(1);
Alexey Bataev6125da92014-07-21 11:26:11 +00002428 VisitOMPExecutableDirective(D);
2429}
2430
Alexey Bataevc112e942020-02-28 09:52:15 -05002431void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective *D) {
2432 VisitStmt(D);
2433 // The NumClauses field was read in ReadStmtFromStream.
2434 Record.skipInts(1);
2435 VisitOMPExecutableDirective(D);
2436}
2437
Alexey Bataevfcba7c32020-03-20 07:03:01 -04002438void ASTStmtReader::VisitOMPScanDirective(OMPScanDirective *D) {
2439 VisitStmt(D);
2440 // The NumClauses field was read in ReadStmtFromStream.
2441 Record.skipInts(1);
2442 VisitOMPExecutableDirective(D);
2443}
2444
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002445void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2446 VisitStmt(D);
Alexey Bataev346265e2015-09-25 10:37:12 +00002447 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002448 Record.skipInts(1);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002449 VisitOMPExecutableDirective(D);
2450}
2451
Alexey Bataev0162e452014-07-22 10:10:35 +00002452void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2453 VisitStmt(D);
2454 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002455 Record.skipInts(1);
Alexey Bataev0162e452014-07-22 10:10:35 +00002456 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002457 D->setX(Record.readSubExpr());
2458 D->setV(Record.readSubExpr());
2459 D->setExpr(Record.readSubExpr());
2460 D->setUpdateExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002461 D->IsXLHSInRHSPart = Record.readInt() != 0;
2462 D->IsPostfixUpdate = Record.readInt() != 0;
Alexey Bataev0162e452014-07-22 10:10:35 +00002463}
2464
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002465void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2466 VisitStmt(D);
2467 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002468 Record.skipInts(1);
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002469 VisitOMPExecutableDirective(D);
2470}
2471
Michael Wong65f367f2015-07-21 13:44:28 +00002472void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2473 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002474 Record.skipInts(1);
Michael Wong65f367f2015-07-21 13:44:28 +00002475 VisitOMPExecutableDirective(D);
2476}
2477
Samuel Antaodf67fc42016-01-19 19:15:56 +00002478void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2479 OMPTargetEnterDataDirective *D) {
2480 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002481 Record.skipInts(1);
Samuel Antaodf67fc42016-01-19 19:15:56 +00002482 VisitOMPExecutableDirective(D);
2483}
2484
Samuel Antao72590762016-01-19 20:04:50 +00002485void ASTStmtReader::VisitOMPTargetExitDataDirective(
2486 OMPTargetExitDataDirective *D) {
2487 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002488 Record.skipInts(1);
Samuel Antao72590762016-01-19 20:04:50 +00002489 VisitOMPExecutableDirective(D);
2490}
2491
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002492void ASTStmtReader::VisitOMPTargetParallelDirective(
2493 OMPTargetParallelDirective *D) {
2494 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002495 Record.skipInts(1);
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002496 VisitOMPExecutableDirective(D);
2497}
2498
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002499void ASTStmtReader::VisitOMPTargetParallelForDirective(
2500 OMPTargetParallelForDirective *D) {
2501 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002502 D->setHasCancel(Record.readInt());
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002503}
2504
Alexey Bataev13314bf2014-10-09 04:18:56 +00002505void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2506 VisitStmt(D);
2507 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002508 Record.skipInts(1);
Alexey Bataev13314bf2014-10-09 04:18:56 +00002509 VisitOMPExecutableDirective(D);
2510}
2511
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002512void ASTStmtReader::VisitOMPCancellationPointDirective(
2513 OMPCancellationPointDirective *D) {
2514 VisitStmt(D);
2515 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002516 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002517}
2518
Alexey Bataev80909872015-07-02 11:25:17 +00002519void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2520 VisitStmt(D);
Alexey Bataev87933c72015-09-18 08:07:34 +00002521 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002522 Record.skipInts(1);
Alexey Bataev80909872015-07-02 11:25:17 +00002523 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002524 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev80909872015-07-02 11:25:17 +00002525}
2526
Alexey Bataev49f6e782015-12-01 04:18:41 +00002527void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2528 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002529 D->setHasCancel(Record.readInt());
Alexey Bataev49f6e782015-12-01 04:18:41 +00002530}
2531
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002532void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2533 VisitOMPLoopDirective(D);
2534}
2535
Alexey Bataev60e51c42019-10-10 20:13:02 +00002536void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2537 OMPMasterTaskLoopDirective *D) {
2538 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002539 D->setHasCancel(Record.readInt());
Alexey Bataev60e51c42019-10-10 20:13:02 +00002540}
2541
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002542void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2543 OMPMasterTaskLoopSimdDirective *D) {
2544 VisitOMPLoopDirective(D);
2545}
2546
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002547void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2548 OMPParallelMasterTaskLoopDirective *D) {
2549 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002550 D->setHasCancel(Record.readInt());
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002551}
2552
Alexey Bataev14a388f2019-10-25 10:27:13 -04002553void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2554 OMPParallelMasterTaskLoopSimdDirective *D) {
2555 VisitOMPLoopDirective(D);
2556}
2557
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002558void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2559 VisitOMPLoopDirective(D);
2560}
2561
Samuel Antao686c70c2016-05-26 17:30:50 +00002562void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2563 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002564 Record.skipInts(1);
Samuel Antao686c70c2016-05-26 17:30:50 +00002565 VisitOMPExecutableDirective(D);
2566}
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002567
Carlo Bertolli9925f152016-06-27 14:55:37 +00002568void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2569 OMPDistributeParallelForDirective *D) {
2570 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002571 D->setHasCancel(Record.readInt());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002572}
Samuel Antao686c70c2016-05-26 17:30:50 +00002573
Kelvin Li4a39add2016-07-05 05:00:15 +00002574void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2575 OMPDistributeParallelForSimdDirective *D) {
2576 VisitOMPLoopDirective(D);
2577}
2578
Kelvin Li787f3fc2016-07-06 04:45:38 +00002579void ASTStmtReader::VisitOMPDistributeSimdDirective(
2580 OMPDistributeSimdDirective *D) {
2581 VisitOMPLoopDirective(D);
2582}
2583
Kelvin Lia579b912016-07-14 02:54:56 +00002584void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2585 OMPTargetParallelForSimdDirective *D) {
2586 VisitOMPLoopDirective(D);
2587}
2588
Kelvin Li986330c2016-07-20 22:57:10 +00002589void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2590 VisitOMPLoopDirective(D);
2591}
2592
Kelvin Li02532872016-08-05 14:37:37 +00002593void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2594 OMPTeamsDistributeDirective *D) {
2595 VisitOMPLoopDirective(D);
2596}
2597
Kelvin Li4e325f72016-10-25 12:50:55 +00002598void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2599 OMPTeamsDistributeSimdDirective *D) {
2600 VisitOMPLoopDirective(D);
2601}
2602
Kelvin Li579e41c2016-11-30 23:51:03 +00002603void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2604 OMPTeamsDistributeParallelForSimdDirective *D) {
2605 VisitOMPLoopDirective(D);
2606}
2607
Kelvin Li7ade93f2016-12-09 03:24:30 +00002608void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2609 OMPTeamsDistributeParallelForDirective *D) {
2610 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002611 D->setHasCancel(Record.readInt());
Kelvin Li7ade93f2016-12-09 03:24:30 +00002612}
2613
Kelvin Libf594a52016-12-17 05:48:59 +00002614void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2615 VisitStmt(D);
2616 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002617 Record.skipInts(1);
Kelvin Libf594a52016-12-17 05:48:59 +00002618 VisitOMPExecutableDirective(D);
2619}
2620
Kelvin Li83c451e2016-12-25 04:52:54 +00002621void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2622 OMPTargetTeamsDistributeDirective *D) {
2623 VisitOMPLoopDirective(D);
2624}
2625
Kelvin Li80e8f562016-12-29 22:16:30 +00002626void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2627 OMPTargetTeamsDistributeParallelForDirective *D) {
2628 VisitOMPLoopDirective(D);
Alexey Bataev16e79882017-11-22 21:12:03 +00002629 D->setHasCancel(Record.readInt());
Kelvin Li80e8f562016-12-29 22:16:30 +00002630}
2631
Kelvin Li1851df52017-01-03 05:23:48 +00002632void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2633 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2634 VisitOMPLoopDirective(D);
2635}
2636
Kelvin Lida681182017-01-10 18:08:18 +00002637void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2638 OMPTargetTeamsDistributeSimdDirective *D) {
2639 VisitOMPLoopDirective(D);
2640}
2641
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002642//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002643// ASTReader Implementation
2644//===----------------------------------------------------------------------===//
2645
Douglas Gregorde3ef502011-11-30 23:21:26 +00002646Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002647 switch (ReadingKind) {
Richard Smith629ff362013-07-31 00:26:46 +00002648 case Read_None:
2649 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002650 case Read_Decl:
2651 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00002652 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002653 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002654 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002655 }
2656
2657 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002658}
2659
Douglas Gregorde3ef502011-11-30 23:21:26 +00002660Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00002661 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002662}
Chris Lattnere2437f42010-05-09 06:40:08 +00002663
Sebastian Redl2c499f62010-08-18 23:56:43 +00002664Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002665 return cast_or_null<Expr>(ReadSubStmt());
2666}
2667
Chris Lattnerf4262532009-04-27 05:41:06 +00002668// Within the bitstream, expressions are stored in Reverse Polish
2669// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002670// expression they are stored in. Subexpressions are stored from last to first.
2671// To evaluate expressions, we continue reading expressions and placing them on
2672// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00002673// stack. Evaluation terminates when we see a STMT_STOP record, and
2674// the single remaining expression on the stack is our result.
Douglas Gregorde3ef502011-11-30 23:21:26 +00002675Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002676 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00002677 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002678
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002679 // Map of offset to previously deserialized stmt. The offset points
George Burgess IV758cf9d2017-02-14 05:52:57 +00002680 // just after the stmt record.
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002681 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00002682
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002683#ifndef NDEBUG
2684 unsigned PrevNumStmts = StmtStack.size();
2685#endif
2686
David L. Jonesbe1557a2016-12-21 00:17:49 +00002687 ASTRecordReader Record(*this, F);
2688 ASTStmtReader Reader(Record, Cursor);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002689 Stmt::EmptyShell Empty;
2690
2691 while (true) {
JF Bastien0e828952019-06-26 19:50:12 +00002692 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2693 Cursor.advanceSkippingSubblocks();
2694 if (!MaybeEntry) {
2695 Error(toString(MaybeEntry.takeError()));
2696 return nullptr;
2697 }
2698 llvm::BitstreamEntry Entry = MaybeEntry.get();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002699
Chris Lattner0e6c9402013-01-20 02:38:54 +00002700 switch (Entry.Kind) {
2701 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2702 case llvm::BitstreamEntry::Error:
2703 Error("malformed block record in AST file");
Craig Toppera13603a2014-05-22 05:54:18 +00002704 return nullptr;
Chris Lattner0e6c9402013-01-20 02:38:54 +00002705 case llvm::BitstreamEntry::EndBlock:
2706 goto Done;
2707 case llvm::BitstreamEntry::Record:
2708 // The interesting case.
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002709 break;
2710 }
2711
Richard Smithdbafb6c2017-06-29 23:23:46 +00002712 ASTContext &Context = getContext();
Craig Toppera13603a2014-05-22 05:54:18 +00002713 Stmt *S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002714 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002715 bool IsStmtReference = false;
JF Bastien0e828952019-06-26 19:50:12 +00002716 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2717 if (!MaybeStmtCode) {
2718 Error(toString(MaybeStmtCode.takeError()));
2719 return nullptr;
2720 }
2721 switch ((StmtCode)MaybeStmtCode.get()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00002722 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002723 Finished = true;
2724 break;
2725
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002726 case STMT_REF_PTR:
2727 IsStmtReference = true;
2728 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2729 "No stmt was recorded for this offset reference!");
David L. Jonesbe1557a2016-12-21 00:17:49 +00002730 S = StmtEntries[Record.readInt()];
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002731 break;
2732
Sebastian Redl539c5062010-08-18 23:57:32 +00002733 case STMT_NULL_PTR:
Craig Toppera13603a2014-05-22 05:54:18 +00002734 S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002735 break;
2736
Sebastian Redl539c5062010-08-18 23:57:32 +00002737 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002738 S = new (Context) NullStmt(Empty);
2739 break;
2740
Sebastian Redl539c5062010-08-18 23:57:32 +00002741 case STMT_COMPOUND:
Benjamin Kramer07420902017-12-24 16:24:20 +00002742 S = CompoundStmt::CreateEmpty(
2743 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002744 break;
2745
Sebastian Redl539c5062010-08-18 23:57:32 +00002746 case STMT_CASE:
Bruno Ricci5b30571752018-10-28 12:30:53 +00002747 S = CaseStmt::CreateEmpty(
2748 Context,
2749 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002750 break;
2751
Sebastian Redl539c5062010-08-18 23:57:32 +00002752 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002753 S = new (Context) DefaultStmt(Empty);
2754 break;
2755
Sebastian Redl539c5062010-08-18 23:57:32 +00002756 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002757 S = new (Context) LabelStmt(Empty);
2758 break;
2759
Richard Smithc202b282012-04-14 00:33:13 +00002760 case STMT_ATTRIBUTED:
Alexander Kornienko20f6fc62012-07-09 10:04:07 +00002761 S = AttributedStmt::CreateEmpty(
2762 Context,
2763 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smithc202b282012-04-14 00:33:13 +00002764 break;
2765
Sebastian Redl539c5062010-08-18 23:57:32 +00002766 case STMT_IF:
Bruno Riccib1cc94b2018-10-27 21:12:20 +00002767 S = IfStmt::CreateEmpty(
2768 Context,
2769 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2770 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2771 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002772 break;
2773
Sebastian Redl539c5062010-08-18 23:57:32 +00002774 case STMT_SWITCH:
Bruno Riccie2806f82018-10-29 16:12:37 +00002775 S = SwitchStmt::CreateEmpty(
2776 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002777 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
Bruno Riccie2806f82018-10-29 16:12:37 +00002778 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002779 break;
2780
Sebastian Redl539c5062010-08-18 23:57:32 +00002781 case STMT_WHILE:
Bruno Riccibacf7512018-10-30 13:42:41 +00002782 S = WhileStmt::CreateEmpty(
2783 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002784 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002785 break;
2786
Sebastian Redl539c5062010-08-18 23:57:32 +00002787 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002788 S = new (Context) DoStmt(Empty);
2789 break;
Mike Stump11289f42009-09-09 15:08:12 +00002790
Sebastian Redl539c5062010-08-18 23:57:32 +00002791 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002792 S = new (Context) ForStmt(Empty);
2793 break;
2794
Sebastian Redl539c5062010-08-18 23:57:32 +00002795 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002796 S = new (Context) GotoStmt(Empty);
2797 break;
Mike Stump11289f42009-09-09 15:08:12 +00002798
Sebastian Redl539c5062010-08-18 23:57:32 +00002799 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002800 S = new (Context) IndirectGotoStmt(Empty);
2801 break;
2802
Sebastian Redl539c5062010-08-18 23:57:32 +00002803 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002804 S = new (Context) ContinueStmt(Empty);
2805 break;
2806
Sebastian Redl539c5062010-08-18 23:57:32 +00002807 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002808 S = new (Context) BreakStmt(Empty);
2809 break;
2810
Sebastian Redl539c5062010-08-18 23:57:32 +00002811 case STMT_RETURN:
Bruno Ricci023b1d12018-10-30 14:40:49 +00002812 S = ReturnStmt::CreateEmpty(
2813 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002814 break;
2815
Sebastian Redl539c5062010-08-18 23:57:32 +00002816 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002817 S = new (Context) DeclStmt(Empty);
2818 break;
2819
Chad Rosierde70e0e2012-08-25 00:11:56 +00002820 case STMT_GCCASM:
2821 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002822 break;
2823
Chad Rosiere30d4992012-08-24 23:51:02 +00002824 case STMT_MSASM:
2825 S = new (Context) MSAsmStmt(Empty);
2826 break;
2827
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002828 case STMT_CAPTURED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002829 S = CapturedStmt::CreateDeserialized(
2830 Context, Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002831 break;
2832
Bill Wendling7c44da22018-10-31 03:48:47 +00002833 case EXPR_CONSTANT:
Gauthier Harnisch83c7b612019-06-15 10:24:47 +00002834 S = ConstantExpr::CreateEmpty(
2835 Context,
2836 static_cast<ConstantExpr::ResultStorageKind>(
2837 Record[ASTStmtReader::NumExprFields]),
2838 Empty);
Bill Wendling7c44da22018-10-31 03:48:47 +00002839 break;
2840
Sebastian Redl539c5062010-08-18 23:57:32 +00002841 case EXPR_PREDEFINED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002842 S = PredefinedExpr::CreateEmpty(
2843 Context,
2844 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002845 break;
Mike Stump11289f42009-09-09 15:08:12 +00002846
Sebastian Redl539c5062010-08-18 23:57:32 +00002847 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002848 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00002849 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002850 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2851 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnara7945c982012-01-27 09:46:47 +00002852 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002853 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Richard Smith715f7a12019-06-11 17:50:32 +00002854 Record[ASTStmtReader::NumExprFields + 6] : 0);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002855 break;
Mike Stump11289f42009-09-09 15:08:12 +00002856
Sebastian Redl539c5062010-08-18 23:57:32 +00002857 case EXPR_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002858 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002859 break;
Mike Stump11289f42009-09-09 15:08:12 +00002860
Vince Bridgers161fc1d2020-04-07 14:46:08 -05002861 case EXPR_FIXEDPOINT_LITERAL:
2862 S = FixedPointLiteral::Create(Context, Empty);
2863 break;
2864
Sebastian Redl539c5062010-08-18 23:57:32 +00002865 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002866 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002867 break;
Mike Stump11289f42009-09-09 15:08:12 +00002868
Sebastian Redl539c5062010-08-18 23:57:32 +00002869 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002870 S = new (Context) ImaginaryLiteral(Empty);
2871 break;
2872
Sebastian Redl539c5062010-08-18 23:57:32 +00002873 case EXPR_STRING_LITERAL:
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002874 S = StringLiteral::CreateEmpty(
2875 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002876 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002877 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2878 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002879 break;
2880
Sebastian Redl539c5062010-08-18 23:57:32 +00002881 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002882 S = new (Context) CharacterLiteral(Empty);
2883 break;
2884
Sebastian Redl539c5062010-08-18 23:57:32 +00002885 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002886 S = new (Context) ParenExpr(Empty);
2887 break;
2888
Sebastian Redl539c5062010-08-18 23:57:32 +00002889 case EXPR_PAREN_LIST:
Bruno Riccif49e1ca2018-11-20 16:20:40 +00002890 S = ParenListExpr::CreateEmpty(
2891 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002892 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00002893 break;
2894
Sebastian Redl539c5062010-08-18 23:57:32 +00002895 case EXPR_UNARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002896 S = new (Context) UnaryOperator(Empty);
2897 break;
2898
Sebastian Redl539c5062010-08-18 23:57:32 +00002899 case EXPR_OFFSETOF:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002900 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002901 Record[ASTStmtReader::NumExprFields],
2902 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00002903 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002904
Sebastian Redl539c5062010-08-18 23:57:32 +00002905 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00002906 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002907 break;
2908
Sebastian Redl539c5062010-08-18 23:57:32 +00002909 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002910 S = new (Context) ArraySubscriptExpr(Empty);
2911 break;
2912
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002913 case EXPR_OMP_ARRAY_SECTION:
2914 S = new (Context) OMPArraySectionExpr(Empty);
2915 break;
2916
Alexey Bataev7ac9efb2020-02-05 09:33:05 -05002917 case EXPR_OMP_ARRAY_SHAPING:
2918 S = OMPArrayShapingExpr::CreateEmpty(
2919 Context, Record[ASTStmtReader::NumExprFields]);
2920 break;
2921
Alexey Bataev13a15042020-04-01 15:06:38 -04002922 case EXPR_OMP_ITERATOR:
2923 S = OMPIteratorExpr::CreateEmpty(Context,
2924 Record[ASTStmtReader::NumExprFields]);
2925 break;
2926
Sebastian Redl539c5062010-08-18 23:57:32 +00002927 case EXPR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00002928 S = CallExpr::CreateEmpty(
2929 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002930 break;
2931
Haojian Wu733edf92020-03-19 16:30:40 +01002932 case EXPR_RECOVERY:
2933 S = RecoveryExpr::CreateEmpty(
2934 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
2935 break;
2936
Richard Smithdcf17de2019-06-06 23:24:15 +00002937 case EXPR_MEMBER:
2938 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
2939 Record[ASTStmtReader::NumExprFields + 1],
2940 Record[ASTStmtReader::NumExprFields + 2],
2941 Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002942 break;
2943
Sebastian Redl539c5062010-08-18 23:57:32 +00002944 case EXPR_BINARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002945 S = new (Context) BinaryOperator(Empty);
2946 break;
2947
Sebastian Redl539c5062010-08-18 23:57:32 +00002948 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002949 S = new (Context) CompoundAssignOperator(Empty);
2950 break;
2951
Sebastian Redl539c5062010-08-18 23:57:32 +00002952 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002953 S = new (Context) ConditionalOperator(Empty);
2954 break;
2955
John McCallc07a0c72011-02-17 10:25:35 +00002956 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2957 S = new (Context) BinaryConditionalOperator(Empty);
2958 break;
2959
Sebastian Redl539c5062010-08-18 23:57:32 +00002960 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002961 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002962 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002963 break;
2964
Sebastian Redl539c5062010-08-18 23:57:32 +00002965 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002966 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002967 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002968 break;
2969
Sebastian Redl539c5062010-08-18 23:57:32 +00002970 case EXPR_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002971 S = new (Context) CompoundLiteralExpr(Empty);
2972 break;
2973
Sebastian Redl539c5062010-08-18 23:57:32 +00002974 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002975 S = new (Context) ExtVectorElementExpr(Empty);
2976 break;
2977
Sebastian Redl539c5062010-08-18 23:57:32 +00002978 case EXPR_INIT_LIST:
Argyrios Kyrtzidis0f05fb92012-11-28 03:56:16 +00002979 S = new (Context) InitListExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002980 break;
2981
Sebastian Redl539c5062010-08-18 23:57:32 +00002982 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002983 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002984 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00002985
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002986 break;
2987
Yunzhong Gaocb779302015-06-10 00:27:52 +00002988 case EXPR_DESIGNATED_INIT_UPDATE:
2989 S = new (Context) DesignatedInitUpdateExpr(Empty);
2990 break;
2991
Sebastian Redl539c5062010-08-18 23:57:32 +00002992 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002993 S = new (Context) ImplicitValueInitExpr(Empty);
2994 break;
2995
Yunzhong Gaocb779302015-06-10 00:27:52 +00002996 case EXPR_NO_INIT:
2997 S = new (Context) NoInitExpr(Empty);
2998 break;
2999
Richard Smith410306b2016-12-12 02:53:20 +00003000 case EXPR_ARRAY_INIT_LOOP:
3001 S = new (Context) ArrayInitLoopExpr(Empty);
3002 break;
3003
3004 case EXPR_ARRAY_INIT_INDEX:
3005 S = new (Context) ArrayInitIndexExpr(Empty);
3006 break;
3007
Sebastian Redl539c5062010-08-18 23:57:32 +00003008 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003009 S = new (Context) VAArgExpr(Empty);
3010 break;
3011
Eric Fiselier708afb52019-05-16 21:04:15 +00003012 case EXPR_SOURCE_LOC:
3013 S = new (Context) SourceLocExpr(Empty);
3014 break;
3015
Sebastian Redl539c5062010-08-18 23:57:32 +00003016 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003017 S = new (Context) AddrLabelExpr(Empty);
3018 break;
3019
Sebastian Redl539c5062010-08-18 23:57:32 +00003020 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003021 S = new (Context) StmtExpr(Empty);
3022 break;
3023
Sebastian Redl539c5062010-08-18 23:57:32 +00003024 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003025 S = new (Context) ChooseExpr(Empty);
3026 break;
3027
Sebastian Redl539c5062010-08-18 23:57:32 +00003028 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003029 S = new (Context) GNUNullExpr(Empty);
3030 break;
3031
Sebastian Redl539c5062010-08-18 23:57:32 +00003032 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003033 S = new (Context) ShuffleVectorExpr(Empty);
3034 break;
Mike Stump11289f42009-09-09 15:08:12 +00003035
Hal Finkelc4d7c822013-09-18 03:29:45 +00003036 case EXPR_CONVERT_VECTOR:
3037 S = new (Context) ConvertVectorExpr(Empty);
3038 break;
3039
Sebastian Redl539c5062010-08-18 23:57:32 +00003040 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003041 S = new (Context) BlockExpr(Empty);
3042 break;
3043
Peter Collingbourne91147592011-04-15 00:35:48 +00003044 case EXPR_GENERIC_SELECTION:
Bruno Riccidb076832019-01-26 14:15:10 +00003045 S = GenericSelectionExpr::CreateEmpty(
3046 Context,
3047 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
Peter Collingbourne91147592011-04-15 00:35:48 +00003048 break;
3049
Sebastian Redl539c5062010-08-18 23:57:32 +00003050 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003051 S = new (Context) ObjCStringLiteral(Empty);
3052 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003053
Patrick Beard0caa3942012-04-19 00:25:12 +00003054 case EXPR_OBJC_BOXED_EXPRESSION:
3055 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremeneke65b0862012-03-06 20:05:56 +00003056 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003057
Ted Kremeneke65b0862012-03-06 20:05:56 +00003058 case EXPR_OBJC_ARRAY_LITERAL:
3059 S = ObjCArrayLiteral::CreateEmpty(Context,
3060 Record[ASTStmtReader::NumExprFields]);
3061 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003062
Ted Kremeneke65b0862012-03-06 20:05:56 +00003063 case EXPR_OBJC_DICTIONARY_LITERAL:
3064 S = ObjCDictionaryLiteral::CreateEmpty(Context,
3065 Record[ASTStmtReader::NumExprFields],
3066 Record[ASTStmtReader::NumExprFields + 1]);
3067 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003068
Sebastian Redl539c5062010-08-18 23:57:32 +00003069 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003070 S = new (Context) ObjCEncodeExpr(Empty);
3071 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003072
Sebastian Redl539c5062010-08-18 23:57:32 +00003073 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003074 S = new (Context) ObjCSelectorExpr(Empty);
3075 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003076
Sebastian Redl539c5062010-08-18 23:57:32 +00003077 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003078 S = new (Context) ObjCProtocolExpr(Empty);
3079 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003080
Sebastian Redl539c5062010-08-18 23:57:32 +00003081 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003082 S = new (Context) ObjCIvarRefExpr(Empty);
3083 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003084
Sebastian Redl539c5062010-08-18 23:57:32 +00003085 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003086 S = new (Context) ObjCPropertyRefExpr(Empty);
3087 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003088
Ted Kremeneke65b0862012-03-06 20:05:56 +00003089 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
3090 S = new (Context) ObjCSubscriptRefExpr(Empty);
3091 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003092
Sebastian Redl539c5062010-08-18 23:57:32 +00003093 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00003094 llvm_unreachable("mismatching AST file");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003095
Sebastian Redl539c5062010-08-18 23:57:32 +00003096 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003097 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00003098 Record[ASTStmtReader::NumExprFields],
3099 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003100 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003101
Sebastian Redl539c5062010-08-18 23:57:32 +00003102 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00003103 S = new (Context) ObjCIsaExpr(Empty);
3104 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003105
John McCall31168b02011-06-15 23:02:42 +00003106 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
3107 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
3108 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003109
John McCall31168b02011-06-15 23:02:42 +00003110 case EXPR_OBJC_BRIDGED_CAST:
3111 S = new (Context) ObjCBridgedCastExpr(Empty);
3112 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003113
Sebastian Redl539c5062010-08-18 23:57:32 +00003114 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003115 S = new (Context) ObjCForCollectionStmt(Empty);
3116 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003117
Sebastian Redl539c5062010-08-18 23:57:32 +00003118 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003119 S = new (Context) ObjCAtCatchStmt(Empty);
3120 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003121
Sebastian Redl539c5062010-08-18 23:57:32 +00003122 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003123 S = new (Context) ObjCAtFinallyStmt(Empty);
3124 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003125
Sebastian Redl539c5062010-08-18 23:57:32 +00003126 case STMT_OBJC_AT_TRY:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003127 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003128 Record[ASTStmtReader::NumStmtFields],
3129 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003130 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003131
Sebastian Redl539c5062010-08-18 23:57:32 +00003132 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003133 S = new (Context) ObjCAtSynchronizedStmt(Empty);
3134 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003135
Sebastian Redl539c5062010-08-18 23:57:32 +00003136 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003137 S = new (Context) ObjCAtThrowStmt(Empty);
3138 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003139
John McCall31168b02011-06-15 23:02:42 +00003140 case STMT_OBJC_AUTORELEASE_POOL:
3141 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3142 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003143
Ted Kremeneke65b0862012-03-06 20:05:56 +00003144 case EXPR_OBJC_BOOL_LITERAL:
3145 S = new (Context) ObjCBoolLiteralExpr(Empty);
3146 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003147
Erik Pilkington29099de2016-07-16 00:35:23 +00003148 case EXPR_OBJC_AVAILABILITY_CHECK:
3149 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3150 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003151
Nico Weber9b982072014-07-07 00:12:30 +00003152 case STMT_SEH_LEAVE:
3153 S = new (Context) SEHLeaveStmt(Empty);
3154 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003155
John McCallfa194042011-07-15 07:00:14 +00003156 case STMT_SEH_EXCEPT:
3157 S = new (Context) SEHExceptStmt(Empty);
3158 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003159
John McCallfa194042011-07-15 07:00:14 +00003160 case STMT_SEH_FINALLY:
3161 S = new (Context) SEHFinallyStmt(Empty);
3162 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003163
John McCallfa194042011-07-15 07:00:14 +00003164 case STMT_SEH_TRY:
3165 S = new (Context) SEHTryStmt(Empty);
3166 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003167
Sebastian Redl539c5062010-08-18 23:57:32 +00003168 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003169 S = new (Context) CXXCatchStmt(Empty);
3170 break;
3171
Sebastian Redl539c5062010-08-18 23:57:32 +00003172 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003173 S = CXXTryStmt::Create(Context, Empty,
Rui Ueyama49a3ad22019-07-16 04:46:31 +00003174 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003175 break;
3176
Richard Smith02e85f32011-04-14 22:09:26 +00003177 case STMT_CXX_FOR_RANGE:
3178 S = new (Context) CXXForRangeStmt(Empty);
3179 break;
3180
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003181 case STMT_MS_DEPENDENT_EXISTS:
3182 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3183 NestedNameSpecifierLoc(),
3184 DeclarationNameInfo(),
Craig Toppera13603a2014-05-22 05:54:18 +00003185 nullptr);
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003186 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003187
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00003188 case STMT_OMP_PARALLEL_DIRECTIVE:
3189 S =
3190 OMPParallelDirective::CreateEmpty(Context,
3191 Record[ASTStmtReader::NumStmtFields],
3192 Empty);
3193 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003194
3195 case STMT_OMP_SIMD_DIRECTIVE: {
3196 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3197 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3198 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3199 CollapsedNum, Empty);
3200 break;
3201 }
3202
Alexey Bataevf29276e2014-06-18 04:14:57 +00003203 case STMT_OMP_FOR_DIRECTIVE: {
3204 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3205 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3206 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3207 Empty);
3208 break;
3209 }
3210
Alexander Musmanf82886e2014-09-18 05:12:34 +00003211 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3212 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3213 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3214 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3215 Empty);
3216 break;
3217 }
3218
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00003219 case STMT_OMP_SECTIONS_DIRECTIVE:
3220 S = OMPSectionsDirective::CreateEmpty(
3221 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3222 break;
3223
Alexey Bataev1e0498a2014-06-26 08:21:58 +00003224 case STMT_OMP_SECTION_DIRECTIVE:
3225 S = OMPSectionDirective::CreateEmpty(Context, Empty);
3226 break;
3227
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00003228 case STMT_OMP_SINGLE_DIRECTIVE:
3229 S = OMPSingleDirective::CreateEmpty(
3230 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3231 break;
3232
Alexander Musman80c22892014-07-17 08:54:58 +00003233 case STMT_OMP_MASTER_DIRECTIVE:
3234 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3235 break;
3236
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003237 case STMT_OMP_CRITICAL_DIRECTIVE:
Alexey Bataev28c75412015-12-15 08:19:24 +00003238 S = OMPCriticalDirective::CreateEmpty(
3239 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003240 break;
3241
Alexey Bataev4acb8592014-07-07 13:01:15 +00003242 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3243 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3244 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3245 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3246 CollapsedNum, Empty);
3247 break;
3248 }
3249
Alexander Musmane4e893b2014-09-23 09:33:00 +00003250 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3251 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3252 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3253 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3254 CollapsedNum, Empty);
3255 break;
3256 }
3257
cchen47d60942019-12-05 13:43:48 -05003258 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3259 S = OMPParallelMasterDirective::CreateEmpty(
3260 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3261 break;
3262
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00003263 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3264 S = OMPParallelSectionsDirective::CreateEmpty(
3265 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3266 break;
3267
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00003268 case STMT_OMP_TASK_DIRECTIVE:
3269 S = OMPTaskDirective::CreateEmpty(
3270 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3271 break;
3272
Alexey Bataev68446b72014-07-18 07:47:19 +00003273 case STMT_OMP_TASKYIELD_DIRECTIVE:
3274 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3275 break;
3276
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00003277 case STMT_OMP_BARRIER_DIRECTIVE:
3278 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3279 break;
3280
Alexey Bataev2df347a2014-07-18 10:17:07 +00003281 case STMT_OMP_TASKWAIT_DIRECTIVE:
3282 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3283 break;
3284
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003285 case STMT_OMP_TASKGROUP_DIRECTIVE:
Alexey Bataev169d96a2017-07-18 20:17:46 +00003286 S = OMPTaskgroupDirective::CreateEmpty(
3287 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003288 break;
3289
Alexey Bataev6125da92014-07-21 11:26:11 +00003290 case STMT_OMP_FLUSH_DIRECTIVE:
3291 S = OMPFlushDirective::CreateEmpty(
3292 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3293 break;
3294
Alexey Bataevc112e942020-02-28 09:52:15 -05003295 case STMT_OMP_DEPOBJ_DIRECTIVE:
3296 S = OMPDepobjDirective::CreateEmpty(
3297 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3298 break;
3299
Alexey Bataevfcba7c32020-03-20 07:03:01 -04003300 case STMT_OMP_SCAN_DIRECTIVE:
3301 S = OMPScanDirective::CreateEmpty(
3302 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3303 break;
3304
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003305 case STMT_OMP_ORDERED_DIRECTIVE:
Alexey Bataev346265e2015-09-25 10:37:12 +00003306 S = OMPOrderedDirective::CreateEmpty(
3307 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003308 break;
3309
Alexey Bataev0162e452014-07-22 10:10:35 +00003310 case STMT_OMP_ATOMIC_DIRECTIVE:
3311 S = OMPAtomicDirective::CreateEmpty(
3312 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3313 break;
3314
Alexey Bataev0bd520b2014-09-19 08:19:49 +00003315 case STMT_OMP_TARGET_DIRECTIVE:
3316 S = OMPTargetDirective::CreateEmpty(
3317 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3318 break;
3319
Michael Wong65f367f2015-07-21 13:44:28 +00003320 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3321 S = OMPTargetDataDirective::CreateEmpty(
3322 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3323 break;
3324
Samuel Antaodf67fc42016-01-19 19:15:56 +00003325 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3326 S = OMPTargetEnterDataDirective::CreateEmpty(
3327 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3328 break;
3329
Samuel Antao72590762016-01-19 20:04:50 +00003330 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3331 S = OMPTargetExitDataDirective::CreateEmpty(
3332 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3333 break;
3334
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00003335 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3336 S = OMPTargetParallelDirective::CreateEmpty(
3337 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3338 break;
3339
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00003340 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3341 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3342 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3343 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3344 CollapsedNum, Empty);
3345 break;
3346 }
3347
Samuel Antao686c70c2016-05-26 17:30:50 +00003348 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3349 S = OMPTargetUpdateDirective::CreateEmpty(
3350 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3351 break;
3352
Alexey Bataev13314bf2014-10-09 04:18:56 +00003353 case STMT_OMP_TEAMS_DIRECTIVE:
3354 S = OMPTeamsDirective::CreateEmpty(
3355 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3356 break;
3357
Alexey Bataev6d4ed052015-07-01 06:57:41 +00003358 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3359 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3360 break;
3361
Alexey Bataev80909872015-07-02 11:25:17 +00003362 case STMT_OMP_CANCEL_DIRECTIVE:
Alexey Bataev87933c72015-09-18 08:07:34 +00003363 S = OMPCancelDirective::CreateEmpty(
3364 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev80909872015-07-02 11:25:17 +00003365 break;
3366
Alexey Bataev49f6e782015-12-01 04:18:41 +00003367 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3368 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3369 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3370 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3371 Empty);
3372 break;
3373 }
3374
Alexey Bataev0a6ed842015-12-03 09:40:15 +00003375 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3376 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3377 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3378 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3379 CollapsedNum, Empty);
3380 break;
3381 }
3382
Alexey Bataev60e51c42019-10-10 20:13:02 +00003383 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3384 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3385 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3386 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3387 CollapsedNum, Empty);
3388 break;
3389 }
3390
Alexey Bataevb8552ab2019-10-18 16:47:35 +00003391 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3392 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3393 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3394 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3395 CollapsedNum, Empty);
3396 break;
3397 }
3398
Alexey Bataev5bbcead2019-10-14 17:17:41 +00003399 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3400 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3401 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3402 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3403 CollapsedNum, Empty);
3404 break;
3405 }
3406
Alexey Bataev14a388f2019-10-25 10:27:13 -04003407 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3408 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3409 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3410 S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3411 Context, NumClauses, CollapsedNum, Empty);
3412 break;
3413 }
3414
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00003415 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3416 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3417 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3418 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3419 Empty);
3420 break;
3421 }
3422
Carlo Bertolli9925f152016-06-27 14:55:37 +00003423 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3424 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3425 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3426 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3427 CollapsedNum, Empty);
3428 break;
3429 }
3430
Kelvin Li4a39add2016-07-05 05:00:15 +00003431 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3432 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3433 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3434 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3435 CollapsedNum,
3436 Empty);
3437 break;
3438 }
3439
Kelvin Li787f3fc2016-07-06 04:45:38 +00003440 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3441 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3442 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3443 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3444 CollapsedNum, Empty);
3445 break;
3446 }
3447
Kelvin Lia579b912016-07-14 02:54:56 +00003448 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3449 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3450 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3451 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3452 CollapsedNum, Empty);
3453 break;
3454 }
3455
Kelvin Li986330c2016-07-20 22:57:10 +00003456 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3457 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3458 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3459 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3460 Empty);
3461 break;
3462 }
3463
Kelvin Li83c451e2016-12-25 04:52:54 +00003464 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
Kelvin Li02532872016-08-05 14:37:37 +00003465 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3466 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3467 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3468 CollapsedNum, Empty);
3469 break;
3470 }
3471
Kelvin Li4e325f72016-10-25 12:50:55 +00003472 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3473 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3474 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3475 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3476 CollapsedNum, Empty);
3477 break;
3478 }
3479
Kelvin Li579e41c2016-11-30 23:51:03 +00003480 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3481 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3482 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3483 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3484 Context, NumClauses, CollapsedNum, Empty);
3485 break;
3486 }
3487
Kelvin Li7ade93f2016-12-09 03:24:30 +00003488 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3489 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3490 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3491 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3492 Context, NumClauses, CollapsedNum, Empty);
3493 break;
3494 }
3495
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003496 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
Kelvin Libf594a52016-12-17 05:48:59 +00003497 S = OMPTargetTeamsDirective::CreateEmpty(
3498 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3499 break;
Kelvin Li83c451e2016-12-25 04:52:54 +00003500
3501 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3502 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3503 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3504 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3505 CollapsedNum, Empty);
3506 break;
3507 }
3508
Kelvin Li80e8f562016-12-29 22:16:30 +00003509 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3510 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3511 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3512 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3513 Context, NumClauses, CollapsedNum, Empty);
3514 break;
3515 }
3516
Kelvin Li1851df52017-01-03 05:23:48 +00003517 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3518 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3519 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3520 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3521 Context, NumClauses, CollapsedNum, Empty);
3522 break;
3523 }
3524
Kelvin Lida681182017-01-10 18:08:18 +00003525 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3526 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3527 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3528 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3529 Context, NumClauses, CollapsedNum, Empty);
3530 break;
3531 }
3532
Sebastian Redl539c5062010-08-18 23:57:32 +00003533 case EXPR_CXX_OPERATOR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003534 S = CXXOperatorCallExpr::CreateEmpty(
3535 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00003536 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003537
Sebastian Redl539c5062010-08-18 23:57:32 +00003538 case EXPR_CXX_MEMBER_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003539 S = CXXMemberCallExpr::CreateEmpty(
3540 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003541 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003542
Richard Smith778dc0f2019-10-19 00:04:38 +00003543 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3544 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3545 break;
3546
Sebastian Redl539c5062010-08-18 23:57:32 +00003547 case EXPR_CXX_CONSTRUCT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003548 S = CXXConstructExpr::CreateEmpty(
3549 Context,
3550 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003551 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003552
Richard Smith5179eb72016-06-28 19:03:57 +00003553 case EXPR_CXX_INHERITED_CTOR_INIT:
3554 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3555 break;
3556
Sebastian Redl539c5062010-08-18 23:57:32 +00003557 case EXPR_CXX_TEMPORARY_OBJECT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003558 S = CXXTemporaryObjectExpr::CreateEmpty(
3559 Context,
3560 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00003561 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003562
Sebastian Redl539c5062010-08-18 23:57:32 +00003563 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003564 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003565 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003566 break;
3567
Sebastian Redl539c5062010-08-18 23:57:32 +00003568 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003569 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003570 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003571 break;
3572
Sebastian Redl539c5062010-08-18 23:57:32 +00003573 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003574 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003575 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003576 break;
3577
Sebastian Redl539c5062010-08-18 23:57:32 +00003578 case EXPR_CXX_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003579 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00003580 break;
3581
Sebastian Redl539c5062010-08-18 23:57:32 +00003582 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003583 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003584 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003585 break;
3586
Richard Smithc67fdd42012-03-07 08:35:16 +00003587 case EXPR_USER_DEFINED_LITERAL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003588 S = UserDefinedLiteral::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003589 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Richard Smithc67fdd42012-03-07 08:35:16 +00003590 break;
3591
Richard Smithcc1b96d2013-06-12 22:31:48 +00003592 case EXPR_CXX_STD_INITIALIZER_LIST:
3593 S = new (Context) CXXStdInitializerListExpr(Empty);
3594 break;
3595
Sebastian Redl539c5062010-08-18 23:57:32 +00003596 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003597 S = new (Context) CXXBoolLiteralExpr(Empty);
3598 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003599
Sebastian Redl539c5062010-08-18 23:57:32 +00003600 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003601 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3602 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003603
Sebastian Redl539c5062010-08-18 23:57:32 +00003604 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003605 S = new (Context) CXXTypeidExpr(Empty, true);
3606 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003607
Sebastian Redl539c5062010-08-18 23:57:32 +00003608 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003609 S = new (Context) CXXTypeidExpr(Empty, false);
3610 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003611
Francois Pichet9f4f2072010-09-08 12:20:18 +00003612 case EXPR_CXX_UUIDOF_EXPR:
3613 S = new (Context) CXXUuidofExpr(Empty, true);
3614 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003615
John McCall5e77d762013-04-16 07:28:30 +00003616 case EXPR_CXX_PROPERTY_REF_EXPR:
3617 S = new (Context) MSPropertyRefExpr(Empty);
3618 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003619
Alexey Bataevf7630272015-11-25 12:01:00 +00003620 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3621 S = new (Context) MSPropertySubscriptExpr(Empty);
3622 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003623
Francois Pichet9f4f2072010-09-08 12:20:18 +00003624 case EXPR_CXX_UUIDOF_TYPE:
3625 S = new (Context) CXXUuidofExpr(Empty, false);
3626 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003627
Sebastian Redl539c5062010-08-18 23:57:32 +00003628 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00003629 S = new (Context) CXXThisExpr(Empty);
3630 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003631
Sebastian Redl539c5062010-08-18 23:57:32 +00003632 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00003633 S = new (Context) CXXThrowExpr(Empty);
3634 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003635
John McCall32791cc2016-01-06 22:34:54 +00003636 case EXPR_CXX_DEFAULT_ARG:
3637 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00003638 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003639
Richard Smith852c9db2013-04-20 22:23:05 +00003640 case EXPR_CXX_DEFAULT_INIT:
3641 S = new (Context) CXXDefaultInitExpr(Empty);
3642 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003643
Sebastian Redl539c5062010-08-18 23:57:32 +00003644 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00003645 S = new (Context) CXXBindTemporaryExpr(Empty);
3646 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003647
Sebastian Redl539c5062010-08-18 23:57:32 +00003648 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00003649 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003650 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003651
Sebastian Redl539c5062010-08-18 23:57:32 +00003652 case EXPR_CXX_NEW:
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00003653 S = CXXNewExpr::CreateEmpty(
3654 Context,
3655 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3656 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3657 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3658 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003659 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003660
Sebastian Redl539c5062010-08-18 23:57:32 +00003661 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00003662 S = new (Context) CXXDeleteExpr(Empty);
3663 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003664
Sebastian Redl539c5062010-08-18 23:57:32 +00003665 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00003666 S = new (Context) CXXPseudoDestructorExpr(Empty);
3667 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003668
John McCall5d413782010-12-06 08:20:24 +00003669 case EXPR_EXPR_WITH_CLEANUPS:
John McCall28fc7092011-11-10 05:35:25 +00003670 S = ExprWithCleanups::Create(Context, Empty,
3671 Record[ASTStmtReader::NumExprFields]);
Chris Lattnercba86142010-05-10 00:25:06 +00003672 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003673
Sebastian Redl539c5062010-08-18 23:57:32 +00003674 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Bruno Ricci2e6dc532019-01-08 14:17:00 +00003675 S = CXXDependentScopeMemberExpr::CreateEmpty(
3676 Context,
3677 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3678 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3679 /*HasFirstQualifierFoundInScope=*/
3680 Record[ASTStmtReader::NumExprFields + 2]);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003681 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003682
Sebastian Redl539c5062010-08-18 23:57:32 +00003683 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003684 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003685 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003686 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003687 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003688 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00003689 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003690
Sebastian Redl539c5062010-08-18 23:57:32 +00003691 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003692 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003693 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00003694 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003695
Sebastian Redl539c5062010-08-18 23:57:32 +00003696 case EXPR_CXX_UNRESOLVED_MEMBER:
Bruno Riccid7628d92019-01-09 15:43:19 +00003697 S = UnresolvedMemberExpr::CreateEmpty(
3698 Context,
3699 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3700 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3701 /*NumTemplateArgs=*/
3702 Record[ASTStmtReader::NumExprFields + 1]
3703 ? Record[ASTStmtReader::NumExprFields + 2]
3704 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003705 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003706
Sebastian Redl539c5062010-08-18 23:57:32 +00003707 case EXPR_CXX_UNRESOLVED_LOOKUP:
Bruno Riccid7628d92019-01-09 15:43:19 +00003708 S = UnresolvedLookupExpr::CreateEmpty(
3709 Context,
3710 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3711 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3712 /*NumTemplateArgs=*/
3713 Record[ASTStmtReader::NumExprFields + 1]
3714 ? Record[ASTStmtReader::NumExprFields + 2]
3715 : 0);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00003716 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003717
Douglas Gregor29c42f22012-02-24 07:38:34 +00003718 case EXPR_TYPE_TRAIT:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003719 S = TypeTraitExpr::CreateDeserialized(Context,
Douglas Gregor29c42f22012-02-24 07:38:34 +00003720 Record[ASTStmtReader::NumExprFields]);
3721 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003722
John Wiegley6242b6a2011-04-28 00:16:57 +00003723 case EXPR_ARRAY_TYPE_TRAIT:
3724 S = new (Context) ArrayTypeTraitExpr(Empty);
3725 break;
3726
John Wiegleyf9f65842011-04-25 06:54:41 +00003727 case EXPR_CXX_EXPRESSION_TRAIT:
3728 S = new (Context) ExpressionTraitExpr(Empty);
3729 break;
3730
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003731 case EXPR_CXX_NOEXCEPT:
3732 S = new (Context) CXXNoexceptExpr(Empty);
3733 break;
John McCall8d69a212010-11-15 23:31:06 +00003734
Douglas Gregore8e9dd62011-01-03 17:17:50 +00003735 case EXPR_PACK_EXPANSION:
3736 S = new (Context) PackExpansionExpr(Empty);
3737 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003738
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003739 case EXPR_SIZEOF_PACK:
Richard Smithd784e682015-09-23 21:41:42 +00003740 S = SizeOfPackExpr::CreateDeserialized(
3741 Context,
3742 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003743 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003744
John McCallfa194042011-07-15 07:00:14 +00003745 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3746 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3747 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003748
Douglas Gregorcdbc5392011-01-15 01:15:58 +00003749 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3750 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3751 break;
Richard Smithb15fe3a2012-09-12 00:56:43 +00003752
3753 case EXPR_FUNCTION_PARM_PACK:
3754 S = FunctionParmPackExpr::CreateEmpty(Context,
3755 Record[ASTStmtReader::NumExprFields]);
3756 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003757
Douglas Gregorfe314812011-06-21 17:03:29 +00003758 case EXPR_MATERIALIZE_TEMPORARY:
3759 S = new (Context) MaterializeTemporaryExpr(Empty);
3760 break;
Richard Smith0f0af192014-11-08 05:07:16 +00003761
3762 case EXPR_CXX_FOLD:
3763 S = new (Context) CXXFoldExpr(Empty);
3764 break;
3765
Argyrios Kyrtzidisb2b07952011-12-03 03:49:52 +00003766 case EXPR_OPAQUE_VALUE:
3767 S = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00003768 break;
Peter Collingbourne41f85462011-02-09 21:07:24 +00003769
3770 case EXPR_CUDA_KERNEL_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003771 S = CUDAKernelCallExpr::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003772 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00003773 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003774
Tanya Lattner55808c12011-06-04 00:47:47 +00003775 case EXPR_ASTYPE:
3776 S = new (Context) AsTypeExpr(Empty);
3777 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003778
John McCallfe96e0b2011-11-06 09:01:30 +00003779 case EXPR_PSEUDO_OBJECT: {
3780 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3781 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3782 break;
3783 }
3784
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003785 case EXPR_ATOMIC:
3786 S = new (Context) AtomicExpr(Empty);
3787 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003788
Douglas Gregor99ae8062012-02-14 17:54:36 +00003789 case EXPR_LAMBDA: {
3790 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
Richard Smith30e304e2016-12-14 00:03:17 +00003791 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
Douglas Gregor99ae8062012-02-14 17:54:36 +00003792 break;
3793 }
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +00003794
3795 case STMT_COROUTINE_BODY: {
3796 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3797 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3798 break;
3799 }
3800
3801 case STMT_CORETURN:
3802 S = new (Context) CoreturnStmt(Empty);
3803 break;
3804
3805 case EXPR_COAWAIT:
3806 S = new (Context) CoawaitExpr(Empty);
3807 break;
3808
3809 case EXPR_COYIELD:
3810 S = new (Context) CoyieldExpr(Empty);
3811 break;
3812
3813 case EXPR_DEPENDENT_COAWAIT:
3814 S = new (Context) DependentCoawaitExpr(Empty);
3815 break;
Saar Raz5d98ba62019-10-15 15:24:26 +00003816
Saar Raza0f50d72020-01-18 09:11:43 +02003817 case EXPR_CONCEPT_SPECIALIZATION: {
Saar Raz5d98ba62019-10-15 15:24:26 +00003818 unsigned numTemplateArgs = Record[ASTStmtReader::NumExprFields];
3819 S = ConceptSpecializationExpr::Create(Context, Empty, numTemplateArgs);
3820 break;
Saar Raza0f50d72020-01-18 09:11:43 +02003821 }
3822
3823 case EXPR_REQUIRES:
3824 unsigned numLocalParameters = Record[ASTStmtReader::NumExprFields];
3825 unsigned numRequirement = Record[ASTStmtReader::NumExprFields + 1];
3826 S = RequiresExpr::Create(Context, Empty, numLocalParameters,
3827 numRequirement);
3828 break;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003829 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003830
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003831 // We hit a STMT_STOP, so we're done with this expression.
3832 if (Finished)
3833 break;
3834
3835 ++NumStatementsRead;
3836
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003837 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003838 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003839 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3840 }
3841
David L. Jonesbe1557a2016-12-21 00:17:49 +00003842 assert(Record.getIdx() == Record.size() &&
3843 "Invalid deserialization of statement");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003844 StmtStack.push_back(S);
3845 }
Chris Lattner0e6c9402013-01-20 02:38:54 +00003846Done:
Alp Toker028ed912013-12-06 17:56:43 +00003847 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003848 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003849 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003850}