blob: ea21d5e33c2e8ca8ba888a8bd613282830938212 [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) {
Melanie Blower2ba4e3a2020-04-10 13:34:46 -07001054 bool hasFP_Features;
1055 BinaryOperator::Opcode opc;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001056 VisitExpr(E);
Melanie Blower2ba4e3a2020-04-10 13:34:46 -07001057 E->setHasStoredFPFeatures(hasFP_Features = Record.readInt());
1058 E->setOpcode(opc = (BinaryOperator::Opcode)Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001059 E->setLHS(Record.readSubExpr());
1060 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001061 E->setOperatorLoc(readSourceLocation());
Melanie Blower2ba4e3a2020-04-10 13:34:46 -07001062 if (hasFP_Features)
1063 E->setStoredFPFeatures(FPOptions(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001064}
1065
Sebastian Redl70c751d2010-08-18 23:56:52 +00001066void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001067 VisitBinaryOperator(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001068 E->setComputationLHSType(Record.readType());
1069 E->setComputationResultType(Record.readType());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001070}
1071
Sebastian Redl70c751d2010-08-18 23:56:52 +00001072void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001073 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001074 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
1075 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
1076 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001077 E->QuestionLoc = readSourceLocation();
1078 E->ColonLoc = readSourceLocation();
John McCallc07a0c72011-02-17 10:25:35 +00001079}
1080
1081void
1082ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
1083 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001084 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
1085 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
1086 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
1087 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
1088 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001089 E->QuestionLoc = readSourceLocation();
1090 E->ColonLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001091}
1092
Sebastian Redl70c751d2010-08-18 23:56:52 +00001093void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001094 VisitCastExpr(E);
Roman Lebedev12216f12018-07-27 07:27:14 +00001095 E->setIsPartOfExplicitCast(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001096}
1097
Sebastian Redl70c751d2010-08-18 23:56:52 +00001098void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001099 VisitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001100 E->setTypeInfoAsWritten(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001101}
1102
Sebastian Redl70c751d2010-08-18 23:56:52 +00001103void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001104 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001105 E->setLParenLoc(readSourceLocation());
1106 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001107}
1108
Sebastian Redl70c751d2010-08-18 23:56:52 +00001109void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001110 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001111 E->setLParenLoc(readSourceLocation());
1112 E->setTypeSourceInfo(readTypeSourceInfo());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001113 E->setInitializer(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001114 E->setFileScope(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001115}
1116
Sebastian Redl70c751d2010-08-18 23:56:52 +00001117void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001118 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001119 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001120 E->setAccessor(Record.readIdentifier());
1121 E->setAccessorLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001122}
1123
Sebastian Redl70c751d2010-08-18 23:56:52 +00001124void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001125 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001126 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
Abramo Bagnara8d16bd42012-11-08 18:41:43 +00001127 E->setSyntacticForm(SyntForm);
John McCall3ce3d232019-12-13 03:37:23 -05001128 E->setLBraceLoc(readSourceLocation());
1129 E->setRBraceLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001130 bool isArrayFiller = Record.readInt();
Craig Toppera13603a2014-05-22 05:54:18 +00001131 Expr *filler = nullptr;
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001132 if (isArrayFiller) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001133 filler = Record.readSubExpr();
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001134 E->ArrayFillerOrUnionFieldInit = filler;
1135 } else
John McCall3ce3d232019-12-13 03:37:23 -05001136 E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001137 E->sawArrayRangeDesignator(Record.readInt());
1138 unsigned NumInits = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001139 E->reserveInits(Record.getContext(), NumInits);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001140 if (isArrayFiller) {
1141 for (unsigned I = 0; I != NumInits; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001142 Expr *init = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001143 E->updateInit(Record.getContext(), I, init ? init : filler);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001144 }
1145 } else {
1146 for (unsigned I = 0; I != NumInits; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001147 E->updateInit(Record.getContext(), I, Record.readSubExpr());
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001148 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001149}
1150
Sebastian Redl70c751d2010-08-18 23:56:52 +00001151void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001152 using Designator = DesignatedInitExpr::Designator;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001153
1154 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001155 unsigned NumSubExprs = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001156 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
1157 for (unsigned I = 0; I != NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001158 E->setSubExpr(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001159 E->setEqualOrColonLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001160 E->setGNUSyntax(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001161
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001162 SmallVector<Designator, 4> Designators;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001163 while (Record.getIdx() < Record.size()) {
1164 switch ((DesignatorTypes)Record.readInt()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00001165 case DESIG_FIELD_DECL: {
John McCall3ce3d232019-12-13 03:37:23 -05001166 auto *Field = readDeclAs<FieldDecl>();
1167 SourceLocation DotLoc = readSourceLocation();
1168 SourceLocation FieldLoc = readSourceLocation();
Mike Stump11289f42009-09-09 15:08:12 +00001169 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001170 FieldLoc));
1171 Designators.back().setField(Field);
1172 break;
1173 }
1174
Sebastian Redl539c5062010-08-18 23:57:32 +00001175 case DESIG_FIELD_NAME: {
John McCall3ce3d232019-12-13 03:37:23 -05001176 const IdentifierInfo *Name = Record.readIdentifier();
1177 SourceLocation DotLoc = readSourceLocation();
1178 SourceLocation FieldLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001179 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
1180 break;
1181 }
Mike Stump11289f42009-09-09 15:08:12 +00001182
Sebastian Redl539c5062010-08-18 23:57:32 +00001183 case DESIG_ARRAY: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001184 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001185 SourceLocation LBracketLoc = readSourceLocation();
1186 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001187 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
1188 break;
1189 }
1190
Sebastian Redl539c5062010-08-18 23:57:32 +00001191 case DESIG_ARRAY_RANGE: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001192 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001193 SourceLocation LBracketLoc = readSourceLocation();
1194 SourceLocation EllipsisLoc = readSourceLocation();
1195 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001196 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
1197 RBracketLoc));
1198 break;
1199 }
1200 }
1201 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001202 E->setDesignators(Record.getContext(),
Douglas Gregor03e8bdc2010-01-06 23:17:19 +00001203 Designators.data(), Designators.size());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001204}
1205
Yunzhong Gaocb779302015-06-10 00:27:52 +00001206void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1207 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001208 E->setBase(Record.readSubExpr());
1209 E->setUpdater(Record.readSubExpr());
Yunzhong Gaocb779302015-06-10 00:27:52 +00001210}
1211
1212void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1213 VisitExpr(E);
1214}
1215
Richard Smith410306b2016-12-12 02:53:20 +00001216void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1217 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001218 E->SubExprs[0] = Record.readSubExpr();
1219 E->SubExprs[1] = Record.readSubExpr();
Richard Smith410306b2016-12-12 02:53:20 +00001220}
1221
1222void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1223 VisitExpr(E);
1224}
1225
Sebastian Redl70c751d2010-08-18 23:56:52 +00001226void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001227 VisitExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001228}
1229
Sebastian Redl70c751d2010-08-18 23:56:52 +00001230void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001231 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001232 E->setSubExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001233 E->setWrittenTypeInfo(readTypeSourceInfo());
1234 E->setBuiltinLoc(readSourceLocation());
1235 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001236 E->setIsMicrosoftABI(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001237}
1238
Eric Fiselier708afb52019-05-16 21:04:15 +00001239void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1240 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001241 E->ParentContext = readDeclAs<DeclContext>();
1242 E->BuiltinLoc = readSourceLocation();
1243 E->RParenLoc = readSourceLocation();
Eric Fiselier708afb52019-05-16 21:04:15 +00001244 E->SourceLocExprBits.Kind =
1245 static_cast<SourceLocExpr::IdentKind>(Record.readInt());
1246}
1247
Sebastian Redl70c751d2010-08-18 23:56:52 +00001248void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001249 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001250 E->setAmpAmpLoc(readSourceLocation());
1251 E->setLabelLoc(readSourceLocation());
1252 E->setLabel(readDeclAs<LabelDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001253}
1254
Sebastian Redl70c751d2010-08-18 23:56:52 +00001255void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001256 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001257 E->setLParenLoc(readSourceLocation());
1258 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001259 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
Richard Smith5c845c12020-03-09 17:34:33 -07001260 E->StmtExprBits.TemplateDepth = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001261}
1262
Sebastian Redl70c751d2010-08-18 23:56:52 +00001263void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001264 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001265 E->setCond(Record.readSubExpr());
1266 E->setLHS(Record.readSubExpr());
1267 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001268 E->setBuiltinLoc(readSourceLocation());
1269 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001270 E->setIsConditionTrue(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001271}
1272
Sebastian Redl70c751d2010-08-18 23:56:52 +00001273void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001274 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001275 E->setTokenLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001276}
1277
Sebastian Redl70c751d2010-08-18 23:56:52 +00001278void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001279 VisitExpr(E);
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001280 SmallVector<Expr *, 16> Exprs;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001281 unsigned NumExprs = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001282 while (NumExprs--)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001283 Exprs.push_back(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001284 E->setExprs(Record.getContext(), Exprs);
John McCall3ce3d232019-12-13 03:37:23 -05001285 E->setBuiltinLoc(readSourceLocation());
1286 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001287}
1288
Hal Finkelc4d7c822013-09-18 03:29:45 +00001289void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1290 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001291 E->BuiltinLoc = readSourceLocation();
1292 E->RParenLoc = readSourceLocation();
1293 E->TInfo = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001294 E->SrcExpr = Record.readSubExpr();
Hal Finkelc4d7c822013-09-18 03:29:45 +00001295}
1296
Sebastian Redl70c751d2010-08-18 23:56:52 +00001297void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001298 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001299 E->setBlockDecl(readDeclAs<BlockDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001300}
1301
Peter Collingbourne91147592011-04-15 00:35:48 +00001302void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1303 VisitExpr(E);
Bruno Riccidb076832019-01-26 14:15:10 +00001304
1305 unsigned NumAssocs = Record.readInt();
1306 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
Bruno Ricci94498c72019-01-26 13:58:15 +00001307 E->ResultIndex = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001308 E->GenericSelectionExprBits.GenericLoc = readSourceLocation();
1309 E->DefaultLoc = readSourceLocation();
1310 E->RParenLoc = readSourceLocation();
Bruno Riccidb076832019-01-26 14:15:10 +00001311
1312 Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1313 // Add 1 to account for the controlling expression which is the first
1314 // expression in the trailing array of Stmt *. This is not needed for
1315 // the trailing array of TypeSourceInfo *.
1316 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1317 Stmts[I] = Record.readSubExpr();
1318
1319 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1320 for (unsigned I = 0, N = NumAssocs; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001321 TSIs[I] = readTypeSourceInfo();
Peter Collingbourne91147592011-04-15 00:35:48 +00001322}
1323
John McCallfe96e0b2011-11-06 09:01:30 +00001324void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1325 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001326 unsigned numSemanticExprs = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001327 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001328 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001329
1330 // Read the syntactic expression.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001331 E->getSubExprsBuffer()[0] = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001332
1333 // Read all the semantic expressions.
1334 for (unsigned i = 0; i != numSemanticExprs; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001335 Expr *subExpr = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001336 E->getSubExprsBuffer()[i+1] = subExpr;
1337 }
1338}
1339
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001340void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1341 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001342 E->Op = AtomicExpr::AtomicOp(Record.readInt());
Richard Smithaa22a8c2012-04-10 22:49:28 +00001343 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1344 for (unsigned I = 0; I != E->NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001345 E->SubExprs[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001346 E->BuiltinLoc = readSourceLocation();
1347 E->RParenLoc = readSourceLocation();
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001348}
1349
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001350//===----------------------------------------------------------------------===//
1351// Objective-C Expressions and Statements
1352
Sebastian Redl70c751d2010-08-18 23:56:52 +00001353void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001354 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001355 E->setString(cast<StringLiteral>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -05001356 E->setAtLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001357}
1358
Patrick Beard0caa3942012-04-19 00:25:12 +00001359void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001360 VisitExpr(E);
1361 // could be one of several IntegerLiteral, FloatLiteral, etc.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001362 E->SubExpr = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -05001363 E->BoxingMethod = readDeclAs<ObjCMethodDecl>();
1364 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001365}
1366
1367void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1368 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001369 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001370 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1371 Expr **Elements = E->getElements();
1372 for (unsigned I = 0, N = NumElements; I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001373 Elements[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001374 E->ArrayWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1375 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001376}
1377
1378void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1379 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001380 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001381 assert(NumElements == E->getNumElements() && "Wrong number of elements");
David L. Jonesbe1557a2016-12-21 00:17:49 +00001382 bool HasPackExpansions = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001383 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001384 auto *KeyValues =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001385 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001386 auto *Expansions =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001387 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001388 for (unsigned I = 0; I != NumElements; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001389 KeyValues[I].Key = Record.readSubExpr();
1390 KeyValues[I].Value = Record.readSubExpr();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001391 if (HasPackExpansions) {
John McCall3ce3d232019-12-13 03:37:23 -05001392 Expansions[I].EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001393 Expansions[I].NumExpansionsPlusOne = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001394 }
1395 }
John McCall3ce3d232019-12-13 03:37:23 -05001396 E->DictWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1397 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001398}
1399
Sebastian Redl70c751d2010-08-18 23:56:52 +00001400void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001401 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001402 E->setEncodedTypeSourceInfo(readTypeSourceInfo());
1403 E->setAtLoc(readSourceLocation());
1404 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001405}
1406
Sebastian Redl70c751d2010-08-18 23:56:52 +00001407void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001408 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001409 E->setSelector(Record.readSelector());
John McCall3ce3d232019-12-13 03:37:23 -05001410 E->setAtLoc(readSourceLocation());
1411 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001412}
1413
Sebastian Redl70c751d2010-08-18 23:56:52 +00001414void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001415 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001416 E->setProtocol(readDeclAs<ObjCProtocolDecl>());
1417 E->setAtLoc(readSourceLocation());
1418 E->ProtoLoc = readSourceLocation();
1419 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001420}
1421
Sebastian Redl70c751d2010-08-18 23:56:52 +00001422void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001423 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001424 E->setDecl(readDeclAs<ObjCIvarDecl>());
1425 E->setLocation(readSourceLocation());
1426 E->setOpLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001427 E->setBase(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001428 E->setIsArrow(Record.readInt());
1429 E->setIsFreeIvar(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001430}
1431
Sebastian Redl70c751d2010-08-18 23:56:52 +00001432void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001433 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001434 unsigned MethodRefFlags = Record.readInt();
1435 bool Implicit = Record.readInt() != 0;
John McCallb7bd14f2010-12-02 01:19:52 +00001436 if (Implicit) {
John McCall3ce3d232019-12-13 03:37:23 -05001437 auto *Getter = readDeclAs<ObjCMethodDecl>();
1438 auto *Setter = readDeclAs<ObjCMethodDecl>();
Argyrios Kyrtzidisab468b02012-03-30 00:19:18 +00001439 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCallb7bd14f2010-12-02 01:19:52 +00001440 } else {
John McCall3ce3d232019-12-13 03:37:23 -05001441 E->setExplicitProperty(readDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001442 }
John McCall3ce3d232019-12-13 03:37:23 -05001443 E->setLocation(readSourceLocation());
1444 E->setReceiverLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001445 switch (Record.readInt()) {
John McCallb7bd14f2010-12-02 01:19:52 +00001446 case 0:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001447 E->setBase(Record.readSubExpr());
John McCallb7bd14f2010-12-02 01:19:52 +00001448 break;
1449 case 1:
David L. Jonesbe1557a2016-12-21 00:17:49 +00001450 E->setSuperReceiver(Record.readType());
John McCallb7bd14f2010-12-02 01:19:52 +00001451 break;
1452 case 2:
John McCall3ce3d232019-12-13 03:37:23 -05001453 E->setClassReceiver(readDeclAs<ObjCInterfaceDecl>());
John McCallb7bd14f2010-12-02 01:19:52 +00001454 break;
1455 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001456}
1457
Ted Kremeneke65b0862012-03-06 20:05:56 +00001458void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1459 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001460 E->setRBracket(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001461 E->setBaseExpr(Record.readSubExpr());
1462 E->setKeyExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001463 E->GetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1464 E->SetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001465}
1466
Sebastian Redl70c751d2010-08-18 23:56:52 +00001467void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001468 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001469 assert(Record.peekInt() == E->getNumArgs());
1470 Record.skipInts(1);
1471 unsigned NumStoredSelLocs = Record.readInt();
1472 E->SelLocsKind = Record.readInt();
1473 E->setDelegateInitCall(Record.readInt());
1474 E->IsImplicit = Record.readInt();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001475 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
Douglas Gregor9a129192010-04-21 00:45:42 +00001476 switch (Kind) {
1477 case ObjCMessageExpr::Instance:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001478 E->setInstanceReceiver(Record.readSubExpr());
Douglas Gregor9a129192010-04-21 00:45:42 +00001479 break;
1480
1481 case ObjCMessageExpr::Class:
John McCall3ce3d232019-12-13 03:37:23 -05001482 E->setClassReceiver(readTypeSourceInfo());
Douglas Gregor9a129192010-04-21 00:45:42 +00001483 break;
1484
1485 case ObjCMessageExpr::SuperClass:
1486 case ObjCMessageExpr::SuperInstance: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001487 QualType T = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001488 SourceLocation SuperLoc = readSourceLocation();
Douglas Gregor9a129192010-04-21 00:45:42 +00001489 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1490 break;
1491 }
1492 }
1493
1494 assert(Kind == E->getReceiverKind());
1495
David L. Jonesbe1557a2016-12-21 00:17:49 +00001496 if (Record.readInt())
John McCall3ce3d232019-12-13 03:37:23 -05001497 E->setMethodDecl(readDeclAs<ObjCMethodDecl>());
Douglas Gregor9a129192010-04-21 00:45:42 +00001498 else
David L. Jonesb6a8f022016-12-21 04:34:52 +00001499 E->setSelector(Record.readSelector());
Douglas Gregor9a129192010-04-21 00:45:42 +00001500
John McCall3ce3d232019-12-13 03:37:23 -05001501 E->LBracLoc = readSourceLocation();
1502 E->RBracLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001503
1504 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001505 E->setArg(I, Record.readSubExpr());
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00001506
1507 SourceLocation *Locs = E->getStoredSelLocs();
1508 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001509 Locs[I] = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001510}
1511
Sebastian Redl70c751d2010-08-18 23:56:52 +00001512void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001513 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001514 S->setElement(Record.readSubStmt());
1515 S->setCollection(Record.readSubExpr());
1516 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001517 S->setForLoc(readSourceLocation());
1518 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001519}
1520
Sebastian Redl70c751d2010-08-18 23:56:52 +00001521void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001522 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001523 S->setCatchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001524 S->setCatchParamDecl(readDeclAs<VarDecl>());
1525 S->setAtCatchLoc(readSourceLocation());
1526 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001527}
1528
Sebastian Redl70c751d2010-08-18 23:56:52 +00001529void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001530 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001531 S->setFinallyBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001532 S->setAtFinallyLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001533}
1534
John McCall31168b02011-06-15 23:02:42 +00001535void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001536 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001537 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001538 S->setAtLoc(readSourceLocation());
John McCall31168b02011-06-15 23:02:42 +00001539}
1540
Sebastian Redl70c751d2010-08-18 23:56:52 +00001541void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001542 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001543 assert(Record.peekInt() == S->getNumCatchStmts());
1544 Record.skipInts(1);
1545 bool HasFinally = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001546 S->setTryBody(Record.readSubStmt());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001547 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001548 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
Douglas Gregor96c79492010-04-23 22:50:49 +00001549
Douglas Gregor96c79492010-04-23 22:50:49 +00001550 if (HasFinally)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001551 S->setFinallyStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001552 S->setAtTryLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001553}
1554
Sebastian Redl70c751d2010-08-18 23:56:52 +00001555void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001556 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001557 S->setSynchExpr(Record.readSubStmt());
1558 S->setSynchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001559 S->setAtSynchronizedLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001560}
1561
Sebastian Redl70c751d2010-08-18 23:56:52 +00001562void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001563 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001564 S->setThrowExpr(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001565 S->setThrowLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001566}
1567
Ted Kremeneke65b0862012-03-06 20:05:56 +00001568void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1569 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001570 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001571 E->setLocation(readSourceLocation());
Ted Kremeneke65b0862012-03-06 20:05:56 +00001572}
1573
Erik Pilkington29099de2016-07-16 00:35:23 +00001574void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1575 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001576 SourceRange R = Record.readSourceRange();
Erik Pilkington29099de2016-07-16 00:35:23 +00001577 E->AtLoc = R.getBegin();
1578 E->RParen = R.getEnd();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001579 E->VersionToCheck = Record.readVersionTuple();
Erik Pilkington29099de2016-07-16 00:35:23 +00001580}
1581
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001582//===----------------------------------------------------------------------===//
1583// C++ Expressions and Statements
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001584//===----------------------------------------------------------------------===//
1585
Sebastian Redl70c751d2010-08-18 23:56:52 +00001586void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001587 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001588 S->CatchLoc = readSourceLocation();
1589 S->ExceptionDecl = readDeclAs<VarDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001590 S->HandlerBlock = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001591}
1592
Sebastian Redl70c751d2010-08-18 23:56:52 +00001593void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001594 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001595 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1596 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -05001597 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001598 S->getStmts()[0] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001599 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001600 S->getStmts()[i + 1] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001601}
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001602
Richard Smith02e85f32011-04-14 22:09:26 +00001603void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1604 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001605 S->ForLoc = readSourceLocation();
1606 S->CoawaitLoc = readSourceLocation();
1607 S->ColonLoc = readSourceLocation();
1608 S->RParenLoc = readSourceLocation();
Richard Smith8baa5002018-09-28 18:44:09 +00001609 S->setInit(Record.readSubStmt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001610 S->setRangeStmt(Record.readSubStmt());
1611 S->setBeginStmt(Record.readSubStmt());
1612 S->setEndStmt(Record.readSubStmt());
1613 S->setCond(Record.readSubExpr());
1614 S->setInc(Record.readSubExpr());
1615 S->setLoopVarStmt(Record.readSubStmt());
1616 S->setBody(Record.readSubStmt());
Richard Smith02e85f32011-04-14 22:09:26 +00001617}
1618
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001619void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1620 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001621 S->KeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001622 S->IsIfExists = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001623 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001624 S->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001625 S->SubStmt = Record.readSubStmt();
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001626}
1627
Sebastian Redl70c751d2010-08-18 23:56:52 +00001628void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001629 VisitCallExpr(E);
Bruno Riccifeb19232018-12-21 16:51:57 +00001630 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1631 E->CXXOperatorCallExprBits.FPFeatures = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001632 E->Range = Record.readSourceRange();
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001633}
1634
Richard Smith778dc0f2019-10-19 00:04:38 +00001635void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1636 CXXRewrittenBinaryOperator *E) {
1637 VisitExpr(E);
1638 E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1639 E->SemanticForm = Record.readSubExpr();
1640}
1641
Sebastian Redl70c751d2010-08-18 23:56:52 +00001642void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001643 VisitExpr(E);
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001644
1645 unsigned NumArgs = Record.readInt();
1646 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1647
1648 E->CXXConstructExprBits.Elidable = Record.readInt();
1649 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1650 E->CXXConstructExprBits.ListInitialization = Record.readInt();
1651 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1652 E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1653 E->CXXConstructExprBits.ConstructionKind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001654 E->CXXConstructExprBits.Loc = readSourceLocation();
1655 E->Constructor = readDeclAs<CXXConstructorDecl>();
1656 E->ParenOrBraceRange = readSourceRange();
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001657
1658 for (unsigned I = 0; I != NumArgs; ++I)
1659 E->setArg(I, Record.readSubExpr());
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001660}
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001661
Richard Smith5179eb72016-06-28 19:03:57 +00001662void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1663 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001664 E->Constructor = readDeclAs<CXXConstructorDecl>();
1665 E->Loc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001666 E->ConstructsVirtualBase = Record.readInt();
1667 E->InheritedFromVirtualBase = Record.readInt();
Richard Smith5179eb72016-06-28 19:03:57 +00001668}
1669
Sebastian Redl70c751d2010-08-18 23:56:52 +00001670void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001671 VisitCXXConstructExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001672 E->TSI = readTypeSourceInfo();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001673}
1674
Douglas Gregore31e6062012-02-07 10:09:13 +00001675void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1676 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001677 unsigned NumCaptures = Record.readInt();
Douglas Gregor99ae8062012-02-14 17:54:36 +00001678 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
John McCall3ce3d232019-12-13 03:37:23 -05001679 E->IntroducerRange = readSourceRange();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001680 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001681 E->CaptureDefaultLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001682 E->ExplicitParams = Record.readInt();
1683 E->ExplicitResultType = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001684 E->ClosingBrace = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001685
Douglas Gregor99ae8062012-02-14 17:54:36 +00001686 // Read capture initializers.
1687 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1688 CEnd = E->capture_init_end();
1689 C != CEnd; ++C)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001690 *C = Record.readSubExpr();
Douglas Gregore31e6062012-02-07 10:09:13 +00001691}
1692
Richard Smithcc1b96d2013-06-12 22:31:48 +00001693void
1694ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1695 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001696 E->SubExpr = Record.readSubExpr();
Richard Smithcc1b96d2013-06-12 22:31:48 +00001697}
1698
Sebastian Redl70c751d2010-08-18 23:56:52 +00001699void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001700 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001701 SourceRange R = readSourceRange();
Douglas Gregor4478f852011-01-12 22:41:29 +00001702 E->Loc = R.getBegin();
1703 E->RParenLoc = R.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05001704 R = readSourceRange();
Fariborz Jahanianf0738712013-02-22 22:02:53 +00001705 E->AngleBrackets = R;
Sam Weinigd01101e2010-01-16 21:21:01 +00001706}
1707
Sebastian Redl70c751d2010-08-18 23:56:52 +00001708void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001709 return VisitCXXNamedCastExpr(E);
1710}
1711
Sebastian Redl70c751d2010-08-18 23:56:52 +00001712void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001713 return VisitCXXNamedCastExpr(E);
1714}
1715
Sebastian Redl70c751d2010-08-18 23:56:52 +00001716void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001717 return VisitCXXNamedCastExpr(E);
1718}
1719
Sebastian Redl70c751d2010-08-18 23:56:52 +00001720void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001721 return VisitCXXNamedCastExpr(E);
1722}
1723
Sebastian Redl70c751d2010-08-18 23:56:52 +00001724void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001725 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001726 E->setLParenLoc(readSourceLocation());
1727 E->setRParenLoc(readSourceLocation());
Sam Weinigd01101e2010-01-16 21:21:01 +00001728}
1729
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001730void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1731 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001732 E->KWLoc = readSourceLocation();
1733 E->RParenLoc = readSourceLocation();
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001734}
1735
Richard Smithc67fdd42012-03-07 08:35:16 +00001736void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1737 VisitCallExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001738 E->UDSuffixLoc = readSourceLocation();
Richard Smithc67fdd42012-03-07 08:35:16 +00001739}
1740
Sebastian Redl70c751d2010-08-18 23:56:52 +00001741void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001742 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001743 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001744 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001745}
1746
Sebastian Redl70c751d2010-08-18 23:56:52 +00001747void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001748 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001749 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001750}
1751
Sebastian Redl70c751d2010-08-18 23:56:52 +00001752void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001753 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001754 E->setSourceRange(readSourceRange());
Richard Smith5d3f7172020-04-14 19:26:31 -07001755 if (E->isTypeOperand())
1756 E->Operand = readTypeSourceInfo();
1757 else
1758 E->Operand = 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());
Richard Smithbab6df82020-04-11 22:15:29 -07002163 E->Guid = readDeclAs<MSGuidDecl>();
Richard Smith5d3f7172020-04-14 19:26:31 -07002164 if (E->isTypeOperand())
2165 E->Operand = readTypeSourceInfo();
2166 else
2167 E->Operand = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002168}
2169
Nico Weber9b982072014-07-07 00:12:30 +00002170void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
2171 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002172 S->setLeaveLoc(readSourceLocation());
Nico Weber9b982072014-07-07 00:12:30 +00002173}
2174
John McCallfa194042011-07-15 07:00:14 +00002175void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
2176 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002177 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002178 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
2179 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002180}
2181
2182void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
2183 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002184 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002185 S->Block = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002186}
2187
2188void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
2189 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002190 S->IsCXXTry = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002191 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002192 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
2193 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002194}
2195
2196//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00002197// CUDA Expressions and Statements
2198//===----------------------------------------------------------------------===//
2199
2200void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2201 VisitCallExpr(E);
Richard Smithfd420792019-05-24 23:26:07 +00002202 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
Peter Collingbourne41f85462011-02-09 21:07:24 +00002203}
2204
John McCallfa194042011-07-15 07:00:14 +00002205//===----------------------------------------------------------------------===//
2206// OpenCL Expressions and Statements.
2207//===----------------------------------------------------------------------===//
2208void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2209 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002210 E->BuiltinLoc = readSourceLocation();
2211 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002212 E->SrcExpr = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002213}
2214
2215//===----------------------------------------------------------------------===//
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002216// OpenMP Directives.
2217//===----------------------------------------------------------------------===//
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002218
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002219void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
John McCall3ce3d232019-12-13 03:37:23 -05002220 E->setLocStart(readSourceLocation());
2221 E->setLocEnd(readSourceLocation());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002222 SmallVector<OMPClause *, 5> Clauses;
2223 for (unsigned i = 0; i < E->getNumClauses(); ++i)
John McCallc2f18312019-12-14 03:01:28 -05002224 Clauses.push_back(Record.readOMPClause());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002225 E->setClauses(Clauses);
Alexey Bataev68446b72014-07-18 07:47:19 +00002226 if (E->hasAssociatedStmt())
David L. Jonesb6a8f022016-12-21 04:34:52 +00002227 E->setAssociatedStmt(Record.readSubStmt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002228}
2229
Alexander Musman3aaab662014-08-19 11:27:13 +00002230void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2231 VisitStmt(D);
2232 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002233 Record.skipInts(2);
Alexander Musman3aaab662014-08-19 11:27:13 +00002234 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002235 D->setIterationVariable(Record.readSubExpr());
2236 D->setLastIteration(Record.readSubExpr());
2237 D->setCalcLastIteration(Record.readSubExpr());
2238 D->setPreCond(Record.readSubExpr());
2239 D->setCond(Record.readSubExpr());
2240 D->setInit(Record.readSubExpr());
2241 D->setInc(Record.readSubExpr());
2242 D->setPreInits(Record.readSubStmt());
Alexey Bataev3392d762016-02-16 11:18:12 +00002243 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
Carlo Bertollifc35ad22016-03-07 16:04:49 +00002244 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2245 isOpenMPDistributeDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002246 D->setIsLastIterVariable(Record.readSubExpr());
2247 D->setLowerBoundVariable(Record.readSubExpr());
2248 D->setUpperBoundVariable(Record.readSubExpr());
2249 D->setStrideVariable(Record.readSubExpr());
2250 D->setEnsureUpperBound(Record.readSubExpr());
2251 D->setNextLowerBound(Record.readSubExpr());
2252 D->setNextUpperBound(Record.readSubExpr());
2253 D->setNumIterations(Record.readSubExpr());
Alexander Musmanc6388682014-12-15 07:07:06 +00002254 }
Carlo Bertolli9925f152016-06-27 14:55:37 +00002255 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002256 D->setPrevLowerBoundVariable(Record.readSubExpr());
2257 D->setPrevUpperBoundVariable(Record.readSubExpr());
Carlo Bertolli8429d812017-02-17 21:29:13 +00002258 D->setDistInc(Record.readSubExpr());
2259 D->setPrevEnsureUpperBound(Record.readSubExpr());
Carlo Bertolliffafe102017-04-20 00:39:39 +00002260 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2261 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2262 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2263 D->setCombinedInit(Record.readSubExpr());
2264 D->setCombinedCond(Record.readSubExpr());
2265 D->setCombinedNextLowerBound(Record.readSubExpr());
2266 D->setCombinedNextUpperBound(Record.readSubExpr());
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00002267 D->setCombinedDistCond(Record.readSubExpr());
2268 D->setCombinedParForInDistCond(Record.readSubExpr());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002269 }
Alexander Musmana5f070a2014-10-01 06:03:56 +00002270 SmallVector<Expr *, 4> Sub;
2271 unsigned CollapsedNum = D->getCollapsedNumber();
2272 Sub.reserve(CollapsedNum);
2273 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002274 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002275 D->setCounters(Sub);
2276 Sub.clear();
2277 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002278 Sub.push_back(Record.readSubExpr());
Alexey Bataeva8899172015-08-06 12:30:57 +00002279 D->setPrivateCounters(Sub);
2280 Sub.clear();
2281 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002282 Sub.push_back(Record.readSubExpr());
Alexey Bataevb08f89f2015-08-14 12:25:37 +00002283 D->setInits(Sub);
2284 Sub.clear();
2285 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002286 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002287 D->setUpdates(Sub);
2288 Sub.clear();
2289 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002290 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002291 D->setFinals(Sub);
Alexey Bataevf8be4762019-08-14 19:30:06 +00002292 Sub.clear();
2293 for (unsigned i = 0; i < CollapsedNum; ++i)
2294 Sub.push_back(Record.readSubExpr());
2295 D->setDependentCounters(Sub);
2296 Sub.clear();
2297 for (unsigned i = 0; i < CollapsedNum; ++i)
2298 Sub.push_back(Record.readSubExpr());
2299 D->setDependentInits(Sub);
2300 Sub.clear();
2301 for (unsigned i = 0; i < CollapsedNum; ++i)
2302 Sub.push_back(Record.readSubExpr());
2303 D->setFinalsConditions(Sub);
Alexander Musman3aaab662014-08-19 11:27:13 +00002304}
2305
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002306void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002307 VisitStmt(D);
2308 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002309 Record.skipInts(1);
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002310 VisitOMPExecutableDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002311 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002312 D->setHasCancel(Record.readInt());
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002313}
2314
2315void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002316 VisitOMPLoopDirective(D);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002317}
2318
Alexey Bataevf29276e2014-06-18 04:14:57 +00002319void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002320 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002321 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002322 D->setHasCancel(Record.readInt());
Alexey Bataevf29276e2014-06-18 04:14:57 +00002323}
2324
Alexander Musmanf82886e2014-09-18 05:12:34 +00002325void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2326 VisitOMPLoopDirective(D);
2327}
2328
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002329void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2330 VisitStmt(D);
2331 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002332 Record.skipInts(1);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002333 VisitOMPExecutableDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002334 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002335 D->setHasCancel(Record.readInt());
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002336}
2337
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002338void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2339 VisitStmt(D);
2340 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002341 D->setHasCancel(Record.readInt());
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002342}
2343
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002344void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2345 VisitStmt(D);
2346 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002347 Record.skipInts(1);
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002348 VisitOMPExecutableDirective(D);
2349}
2350
Alexander Musman80c22892014-07-17 08:54:58 +00002351void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2352 VisitStmt(D);
2353 VisitOMPExecutableDirective(D);
2354}
2355
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002356void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2357 VisitStmt(D);
Alexey Bataev28c75412015-12-15 08:19:24 +00002358 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002359 Record.skipInts(1);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002360 VisitOMPExecutableDirective(D);
John McCall3ce3d232019-12-13 03:37:23 -05002361 D->DirName = Record.readDeclarationNameInfo();
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002362}
2363
Alexey Bataev4acb8592014-07-07 13:01:15 +00002364void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002365 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002366 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002367 D->setHasCancel(Record.readInt());
Alexey Bataev4acb8592014-07-07 13:01:15 +00002368}
2369
Alexander Musmane4e893b2014-09-23 09:33:00 +00002370void ASTStmtReader::VisitOMPParallelForSimdDirective(
2371 OMPParallelForSimdDirective *D) {
2372 VisitOMPLoopDirective(D);
2373}
2374
cchen47d60942019-12-05 13:43:48 -05002375void ASTStmtReader::VisitOMPParallelMasterDirective(
2376 OMPParallelMasterDirective *D) {
2377 VisitStmt(D);
2378 // The NumClauses field was read in ReadStmtFromStream.
2379 Record.skipInts(1);
2380 VisitOMPExecutableDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002381 D->setTaskReductionRefExpr(Record.readSubExpr());
cchen47d60942019-12-05 13:43:48 -05002382}
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);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002390 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002391 D->setHasCancel(Record.readInt());
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002392}
2393
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002394void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2395 VisitStmt(D);
2396 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002397 Record.skipInts(1);
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002398 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002399 D->setHasCancel(Record.readInt());
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002400}
2401
Alexey Bataev68446b72014-07-18 07:47:19 +00002402void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2403 VisitStmt(D);
2404 VisitOMPExecutableDirective(D);
2405}
2406
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002407void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2408 VisitStmt(D);
2409 VisitOMPExecutableDirective(D);
2410}
2411
Alexey Bataev2df347a2014-07-18 10:17:07 +00002412void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2413 VisitStmt(D);
2414 VisitOMPExecutableDirective(D);
2415}
2416
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002417void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2418 VisitStmt(D);
Alexey Bataev169d96a2017-07-18 20:17:46 +00002419 // The NumClauses field was read in ReadStmtFromStream.
2420 Record.skipInts(1);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002421 VisitOMPExecutableDirective(D);
Alexey Bataev3b1b8952017-07-25 15:53:26 +00002422 D->setReductionRef(Record.readSubExpr());
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002423}
2424
Alexey Bataev6125da92014-07-21 11:26:11 +00002425void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2426 VisitStmt(D);
2427 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002428 Record.skipInts(1);
Alexey Bataev6125da92014-07-21 11:26:11 +00002429 VisitOMPExecutableDirective(D);
2430}
2431
Alexey Bataevc112e942020-02-28 09:52:15 -05002432void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective *D) {
2433 VisitStmt(D);
2434 // The NumClauses field was read in ReadStmtFromStream.
2435 Record.skipInts(1);
2436 VisitOMPExecutableDirective(D);
2437}
2438
Alexey Bataevfcba7c32020-03-20 07:03:01 -04002439void ASTStmtReader::VisitOMPScanDirective(OMPScanDirective *D) {
2440 VisitStmt(D);
2441 // The NumClauses field was read in ReadStmtFromStream.
2442 Record.skipInts(1);
2443 VisitOMPExecutableDirective(D);
2444}
2445
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002446void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2447 VisitStmt(D);
Alexey Bataev346265e2015-09-25 10:37:12 +00002448 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002449 Record.skipInts(1);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002450 VisitOMPExecutableDirective(D);
2451}
2452
Alexey Bataev0162e452014-07-22 10:10:35 +00002453void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2454 VisitStmt(D);
2455 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002456 Record.skipInts(1);
Alexey Bataev0162e452014-07-22 10:10:35 +00002457 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002458 D->setX(Record.readSubExpr());
2459 D->setV(Record.readSubExpr());
2460 D->setExpr(Record.readSubExpr());
2461 D->setUpdateExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002462 D->IsXLHSInRHSPart = Record.readInt() != 0;
2463 D->IsPostfixUpdate = Record.readInt() != 0;
Alexey Bataev0162e452014-07-22 10:10:35 +00002464}
2465
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002466void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2467 VisitStmt(D);
2468 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002469 Record.skipInts(1);
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002470 VisitOMPExecutableDirective(D);
2471}
2472
Michael Wong65f367f2015-07-21 13:44:28 +00002473void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2474 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002475 Record.skipInts(1);
Michael Wong65f367f2015-07-21 13:44:28 +00002476 VisitOMPExecutableDirective(D);
2477}
2478
Samuel Antaodf67fc42016-01-19 19:15:56 +00002479void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2480 OMPTargetEnterDataDirective *D) {
2481 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002482 Record.skipInts(1);
Samuel Antaodf67fc42016-01-19 19:15:56 +00002483 VisitOMPExecutableDirective(D);
2484}
2485
Samuel Antao72590762016-01-19 20:04:50 +00002486void ASTStmtReader::VisitOMPTargetExitDataDirective(
2487 OMPTargetExitDataDirective *D) {
2488 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002489 Record.skipInts(1);
Samuel Antao72590762016-01-19 20:04:50 +00002490 VisitOMPExecutableDirective(D);
2491}
2492
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002493void ASTStmtReader::VisitOMPTargetParallelDirective(
2494 OMPTargetParallelDirective *D) {
2495 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002496 Record.skipInts(1);
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002497 VisitOMPExecutableDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002498 D->setTaskReductionRefExpr(Record.readSubExpr());
Alexey Bataevb737b812020-04-27 11:37:35 -04002499 D->setHasCancel(Record.readBool());
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002500}
2501
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002502void ASTStmtReader::VisitOMPTargetParallelForDirective(
2503 OMPTargetParallelForDirective *D) {
2504 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002505 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002506 D->setHasCancel(Record.readInt());
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002507}
2508
Alexey Bataev13314bf2014-10-09 04:18:56 +00002509void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2510 VisitStmt(D);
2511 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002512 Record.skipInts(1);
Alexey Bataev13314bf2014-10-09 04:18:56 +00002513 VisitOMPExecutableDirective(D);
2514}
2515
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002516void ASTStmtReader::VisitOMPCancellationPointDirective(
2517 OMPCancellationPointDirective *D) {
2518 VisitStmt(D);
2519 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002520 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002521}
2522
Alexey Bataev80909872015-07-02 11:25:17 +00002523void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2524 VisitStmt(D);
Alexey Bataev87933c72015-09-18 08:07:34 +00002525 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002526 Record.skipInts(1);
Alexey Bataev80909872015-07-02 11:25:17 +00002527 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002528 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev80909872015-07-02 11:25:17 +00002529}
2530
Alexey Bataev49f6e782015-12-01 04:18:41 +00002531void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2532 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002533 D->setHasCancel(Record.readInt());
Alexey Bataev49f6e782015-12-01 04:18:41 +00002534}
2535
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002536void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2537 VisitOMPLoopDirective(D);
2538}
2539
Alexey Bataev60e51c42019-10-10 20:13:02 +00002540void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2541 OMPMasterTaskLoopDirective *D) {
2542 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002543 D->setHasCancel(Record.readInt());
Alexey Bataev60e51c42019-10-10 20:13:02 +00002544}
2545
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002546void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2547 OMPMasterTaskLoopSimdDirective *D) {
2548 VisitOMPLoopDirective(D);
2549}
2550
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002551void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2552 OMPParallelMasterTaskLoopDirective *D) {
2553 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002554 D->setHasCancel(Record.readInt());
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002555}
2556
Alexey Bataev14a388f2019-10-25 10:27:13 -04002557void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2558 OMPParallelMasterTaskLoopSimdDirective *D) {
2559 VisitOMPLoopDirective(D);
2560}
2561
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002562void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2563 VisitOMPLoopDirective(D);
2564}
2565
Samuel Antao686c70c2016-05-26 17:30:50 +00002566void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2567 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002568 Record.skipInts(1);
Samuel Antao686c70c2016-05-26 17:30:50 +00002569 VisitOMPExecutableDirective(D);
2570}
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002571
Carlo Bertolli9925f152016-06-27 14:55:37 +00002572void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2573 OMPDistributeParallelForDirective *D) {
2574 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002575 D->setTaskReductionRefExpr(Record.readSubExpr());
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002576 D->setHasCancel(Record.readInt());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002577}
Samuel Antao686c70c2016-05-26 17:30:50 +00002578
Kelvin Li4a39add2016-07-05 05:00:15 +00002579void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2580 OMPDistributeParallelForSimdDirective *D) {
2581 VisitOMPLoopDirective(D);
2582}
2583
Kelvin Li787f3fc2016-07-06 04:45:38 +00002584void ASTStmtReader::VisitOMPDistributeSimdDirective(
2585 OMPDistributeSimdDirective *D) {
2586 VisitOMPLoopDirective(D);
2587}
2588
Kelvin Lia579b912016-07-14 02:54:56 +00002589void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2590 OMPTargetParallelForSimdDirective *D) {
2591 VisitOMPLoopDirective(D);
2592}
2593
Kelvin Li986330c2016-07-20 22:57:10 +00002594void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2595 VisitOMPLoopDirective(D);
2596}
2597
Kelvin Li02532872016-08-05 14:37:37 +00002598void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2599 OMPTeamsDistributeDirective *D) {
2600 VisitOMPLoopDirective(D);
2601}
2602
Kelvin Li4e325f72016-10-25 12:50:55 +00002603void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2604 OMPTeamsDistributeSimdDirective *D) {
2605 VisitOMPLoopDirective(D);
2606}
2607
Kelvin Li579e41c2016-11-30 23:51:03 +00002608void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2609 OMPTeamsDistributeParallelForSimdDirective *D) {
2610 VisitOMPLoopDirective(D);
2611}
2612
Kelvin Li7ade93f2016-12-09 03:24:30 +00002613void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2614 OMPTeamsDistributeParallelForDirective *D) {
2615 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002616 D->setTaskReductionRefExpr(Record.readSubExpr());
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002617 D->setHasCancel(Record.readInt());
Kelvin Li7ade93f2016-12-09 03:24:30 +00002618}
2619
Kelvin Libf594a52016-12-17 05:48:59 +00002620void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2621 VisitStmt(D);
2622 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002623 Record.skipInts(1);
Kelvin Libf594a52016-12-17 05:48:59 +00002624 VisitOMPExecutableDirective(D);
2625}
2626
Kelvin Li83c451e2016-12-25 04:52:54 +00002627void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2628 OMPTargetTeamsDistributeDirective *D) {
2629 VisitOMPLoopDirective(D);
2630}
2631
Kelvin Li80e8f562016-12-29 22:16:30 +00002632void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2633 OMPTargetTeamsDistributeParallelForDirective *D) {
2634 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002635 D->setTaskReductionRefExpr(Record.readSubExpr());
Alexey Bataev16e79882017-11-22 21:12:03 +00002636 D->setHasCancel(Record.readInt());
Kelvin Li80e8f562016-12-29 22:16:30 +00002637}
2638
Kelvin Li1851df52017-01-03 05:23:48 +00002639void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2640 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2641 VisitOMPLoopDirective(D);
2642}
2643
Kelvin Lida681182017-01-10 18:08:18 +00002644void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2645 OMPTargetTeamsDistributeSimdDirective *D) {
2646 VisitOMPLoopDirective(D);
2647}
2648
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002649//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002650// ASTReader Implementation
2651//===----------------------------------------------------------------------===//
2652
Douglas Gregorde3ef502011-11-30 23:21:26 +00002653Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002654 switch (ReadingKind) {
Richard Smith629ff362013-07-31 00:26:46 +00002655 case Read_None:
2656 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002657 case Read_Decl:
2658 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00002659 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002660 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002661 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002662 }
2663
2664 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002665}
2666
Douglas Gregorde3ef502011-11-30 23:21:26 +00002667Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00002668 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002669}
Chris Lattnere2437f42010-05-09 06:40:08 +00002670
Sebastian Redl2c499f62010-08-18 23:56:43 +00002671Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002672 return cast_or_null<Expr>(ReadSubStmt());
2673}
2674
Chris Lattnerf4262532009-04-27 05:41:06 +00002675// Within the bitstream, expressions are stored in Reverse Polish
2676// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002677// expression they are stored in. Subexpressions are stored from last to first.
2678// To evaluate expressions, we continue reading expressions and placing them on
2679// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00002680// stack. Evaluation terminates when we see a STMT_STOP record, and
2681// the single remaining expression on the stack is our result.
Douglas Gregorde3ef502011-11-30 23:21:26 +00002682Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002683 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00002684 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002685
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002686 // Map of offset to previously deserialized stmt. The offset points
George Burgess IV758cf9d2017-02-14 05:52:57 +00002687 // just after the stmt record.
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002688 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00002689
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002690#ifndef NDEBUG
2691 unsigned PrevNumStmts = StmtStack.size();
2692#endif
2693
David L. Jonesbe1557a2016-12-21 00:17:49 +00002694 ASTRecordReader Record(*this, F);
2695 ASTStmtReader Reader(Record, Cursor);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002696 Stmt::EmptyShell Empty;
2697
2698 while (true) {
JF Bastien0e828952019-06-26 19:50:12 +00002699 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2700 Cursor.advanceSkippingSubblocks();
2701 if (!MaybeEntry) {
2702 Error(toString(MaybeEntry.takeError()));
2703 return nullptr;
2704 }
2705 llvm::BitstreamEntry Entry = MaybeEntry.get();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002706
Chris Lattner0e6c9402013-01-20 02:38:54 +00002707 switch (Entry.Kind) {
2708 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2709 case llvm::BitstreamEntry::Error:
2710 Error("malformed block record in AST file");
Craig Toppera13603a2014-05-22 05:54:18 +00002711 return nullptr;
Chris Lattner0e6c9402013-01-20 02:38:54 +00002712 case llvm::BitstreamEntry::EndBlock:
2713 goto Done;
2714 case llvm::BitstreamEntry::Record:
2715 // The interesting case.
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002716 break;
2717 }
2718
Richard Smithdbafb6c2017-06-29 23:23:46 +00002719 ASTContext &Context = getContext();
Craig Toppera13603a2014-05-22 05:54:18 +00002720 Stmt *S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002721 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002722 bool IsStmtReference = false;
JF Bastien0e828952019-06-26 19:50:12 +00002723 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2724 if (!MaybeStmtCode) {
2725 Error(toString(MaybeStmtCode.takeError()));
2726 return nullptr;
2727 }
2728 switch ((StmtCode)MaybeStmtCode.get()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00002729 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002730 Finished = true;
2731 break;
2732
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002733 case STMT_REF_PTR:
2734 IsStmtReference = true;
2735 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2736 "No stmt was recorded for this offset reference!");
David L. Jonesbe1557a2016-12-21 00:17:49 +00002737 S = StmtEntries[Record.readInt()];
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002738 break;
2739
Sebastian Redl539c5062010-08-18 23:57:32 +00002740 case STMT_NULL_PTR:
Craig Toppera13603a2014-05-22 05:54:18 +00002741 S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002742 break;
2743
Sebastian Redl539c5062010-08-18 23:57:32 +00002744 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002745 S = new (Context) NullStmt(Empty);
2746 break;
2747
Sebastian Redl539c5062010-08-18 23:57:32 +00002748 case STMT_COMPOUND:
Benjamin Kramer07420902017-12-24 16:24:20 +00002749 S = CompoundStmt::CreateEmpty(
2750 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002751 break;
2752
Sebastian Redl539c5062010-08-18 23:57:32 +00002753 case STMT_CASE:
Bruno Ricci5b30571752018-10-28 12:30:53 +00002754 S = CaseStmt::CreateEmpty(
2755 Context,
2756 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002757 break;
2758
Sebastian Redl539c5062010-08-18 23:57:32 +00002759 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002760 S = new (Context) DefaultStmt(Empty);
2761 break;
2762
Sebastian Redl539c5062010-08-18 23:57:32 +00002763 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002764 S = new (Context) LabelStmt(Empty);
2765 break;
2766
Richard Smithc202b282012-04-14 00:33:13 +00002767 case STMT_ATTRIBUTED:
Alexander Kornienko20f6fc62012-07-09 10:04:07 +00002768 S = AttributedStmt::CreateEmpty(
2769 Context,
2770 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smithc202b282012-04-14 00:33:13 +00002771 break;
2772
Sebastian Redl539c5062010-08-18 23:57:32 +00002773 case STMT_IF:
Bruno Riccib1cc94b2018-10-27 21:12:20 +00002774 S = IfStmt::CreateEmpty(
2775 Context,
2776 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2777 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2778 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002779 break;
2780
Sebastian Redl539c5062010-08-18 23:57:32 +00002781 case STMT_SWITCH:
Bruno Riccie2806f82018-10-29 16:12:37 +00002782 S = SwitchStmt::CreateEmpty(
2783 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002784 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
Bruno Riccie2806f82018-10-29 16:12:37 +00002785 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002786 break;
2787
Sebastian Redl539c5062010-08-18 23:57:32 +00002788 case STMT_WHILE:
Bruno Riccibacf7512018-10-30 13:42:41 +00002789 S = WhileStmt::CreateEmpty(
2790 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002791 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002792 break;
2793
Sebastian Redl539c5062010-08-18 23:57:32 +00002794 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002795 S = new (Context) DoStmt(Empty);
2796 break;
Mike Stump11289f42009-09-09 15:08:12 +00002797
Sebastian Redl539c5062010-08-18 23:57:32 +00002798 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002799 S = new (Context) ForStmt(Empty);
2800 break;
2801
Sebastian Redl539c5062010-08-18 23:57:32 +00002802 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002803 S = new (Context) GotoStmt(Empty);
2804 break;
Mike Stump11289f42009-09-09 15:08:12 +00002805
Sebastian Redl539c5062010-08-18 23:57:32 +00002806 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002807 S = new (Context) IndirectGotoStmt(Empty);
2808 break;
2809
Sebastian Redl539c5062010-08-18 23:57:32 +00002810 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002811 S = new (Context) ContinueStmt(Empty);
2812 break;
2813
Sebastian Redl539c5062010-08-18 23:57:32 +00002814 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002815 S = new (Context) BreakStmt(Empty);
2816 break;
2817
Sebastian Redl539c5062010-08-18 23:57:32 +00002818 case STMT_RETURN:
Bruno Ricci023b1d12018-10-30 14:40:49 +00002819 S = ReturnStmt::CreateEmpty(
2820 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002821 break;
2822
Sebastian Redl539c5062010-08-18 23:57:32 +00002823 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002824 S = new (Context) DeclStmt(Empty);
2825 break;
2826
Chad Rosierde70e0e2012-08-25 00:11:56 +00002827 case STMT_GCCASM:
2828 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002829 break;
2830
Chad Rosiere30d4992012-08-24 23:51:02 +00002831 case STMT_MSASM:
2832 S = new (Context) MSAsmStmt(Empty);
2833 break;
2834
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002835 case STMT_CAPTURED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002836 S = CapturedStmt::CreateDeserialized(
2837 Context, Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002838 break;
2839
Bill Wendling7c44da22018-10-31 03:48:47 +00002840 case EXPR_CONSTANT:
Gauthier Harnisch83c7b612019-06-15 10:24:47 +00002841 S = ConstantExpr::CreateEmpty(
2842 Context,
2843 static_cast<ConstantExpr::ResultStorageKind>(
2844 Record[ASTStmtReader::NumExprFields]),
2845 Empty);
Bill Wendling7c44da22018-10-31 03:48:47 +00002846 break;
2847
Sebastian Redl539c5062010-08-18 23:57:32 +00002848 case EXPR_PREDEFINED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002849 S = PredefinedExpr::CreateEmpty(
2850 Context,
2851 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002852 break;
Mike Stump11289f42009-09-09 15:08:12 +00002853
Sebastian Redl539c5062010-08-18 23:57:32 +00002854 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002855 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00002856 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002857 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2858 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnara7945c982012-01-27 09:46:47 +00002859 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002860 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Richard Smith715f7a12019-06-11 17:50:32 +00002861 Record[ASTStmtReader::NumExprFields + 6] : 0);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002862 break;
Mike Stump11289f42009-09-09 15:08:12 +00002863
Sebastian Redl539c5062010-08-18 23:57:32 +00002864 case EXPR_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002865 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002866 break;
Mike Stump11289f42009-09-09 15:08:12 +00002867
Vince Bridgers161fc1d2020-04-07 14:46:08 -05002868 case EXPR_FIXEDPOINT_LITERAL:
2869 S = FixedPointLiteral::Create(Context, Empty);
2870 break;
2871
Sebastian Redl539c5062010-08-18 23:57:32 +00002872 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002873 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002874 break;
Mike Stump11289f42009-09-09 15:08:12 +00002875
Sebastian Redl539c5062010-08-18 23:57:32 +00002876 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002877 S = new (Context) ImaginaryLiteral(Empty);
2878 break;
2879
Sebastian Redl539c5062010-08-18 23:57:32 +00002880 case EXPR_STRING_LITERAL:
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002881 S = StringLiteral::CreateEmpty(
2882 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002883 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002884 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2885 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002886 break;
2887
Sebastian Redl539c5062010-08-18 23:57:32 +00002888 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002889 S = new (Context) CharacterLiteral(Empty);
2890 break;
2891
Sebastian Redl539c5062010-08-18 23:57:32 +00002892 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002893 S = new (Context) ParenExpr(Empty);
2894 break;
2895
Sebastian Redl539c5062010-08-18 23:57:32 +00002896 case EXPR_PAREN_LIST:
Bruno Riccif49e1ca2018-11-20 16:20:40 +00002897 S = ParenListExpr::CreateEmpty(
2898 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002899 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00002900 break;
2901
Sebastian Redl539c5062010-08-18 23:57:32 +00002902 case EXPR_UNARY_OPERATOR:
Melanie Blowerfce82c02020-05-01 10:31:09 -07002903 S = new (Context) UnaryOperator(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002904 break;
2905
Sebastian Redl539c5062010-08-18 23:57:32 +00002906 case EXPR_OFFSETOF:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002907 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002908 Record[ASTStmtReader::NumExprFields],
2909 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00002910 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002911
Sebastian Redl539c5062010-08-18 23:57:32 +00002912 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00002913 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002914 break;
2915
Sebastian Redl539c5062010-08-18 23:57:32 +00002916 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002917 S = new (Context) ArraySubscriptExpr(Empty);
2918 break;
2919
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002920 case EXPR_OMP_ARRAY_SECTION:
2921 S = new (Context) OMPArraySectionExpr(Empty);
2922 break;
2923
Alexey Bataev7ac9efb2020-02-05 09:33:05 -05002924 case EXPR_OMP_ARRAY_SHAPING:
2925 S = OMPArrayShapingExpr::CreateEmpty(
2926 Context, Record[ASTStmtReader::NumExprFields]);
2927 break;
2928
Alexey Bataev13a15042020-04-01 15:06:38 -04002929 case EXPR_OMP_ITERATOR:
2930 S = OMPIteratorExpr::CreateEmpty(Context,
2931 Record[ASTStmtReader::NumExprFields]);
2932 break;
2933
Sebastian Redl539c5062010-08-18 23:57:32 +00002934 case EXPR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00002935 S = CallExpr::CreateEmpty(
2936 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002937 break;
2938
Haojian Wu733edf92020-03-19 16:30:40 +01002939 case EXPR_RECOVERY:
2940 S = RecoveryExpr::CreateEmpty(
2941 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
2942 break;
2943
Richard Smithdcf17de2019-06-06 23:24:15 +00002944 case EXPR_MEMBER:
2945 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
2946 Record[ASTStmtReader::NumExprFields + 1],
2947 Record[ASTStmtReader::NumExprFields + 2],
2948 Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002949 break;
2950
Sebastian Redl539c5062010-08-18 23:57:32 +00002951 case EXPR_BINARY_OPERATOR:
Melanie Blower2ba4e3a2020-04-10 13:34:46 -07002952 S = BinaryOperator::CreateEmpty(Context,
2953 Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002954 break;
2955
Sebastian Redl539c5062010-08-18 23:57:32 +00002956 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Melanie Blower2ba4e3a2020-04-10 13:34:46 -07002957 S = CompoundAssignOperator::CreateEmpty(
2958 Context, Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002959 break;
2960
Sebastian Redl539c5062010-08-18 23:57:32 +00002961 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002962 S = new (Context) ConditionalOperator(Empty);
2963 break;
2964
John McCallc07a0c72011-02-17 10:25:35 +00002965 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2966 S = new (Context) BinaryConditionalOperator(Empty);
2967 break;
2968
Sebastian Redl539c5062010-08-18 23:57:32 +00002969 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002970 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002971 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002972 break;
2973
Sebastian Redl539c5062010-08-18 23:57:32 +00002974 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002975 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002976 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002977 break;
2978
Sebastian Redl539c5062010-08-18 23:57:32 +00002979 case EXPR_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002980 S = new (Context) CompoundLiteralExpr(Empty);
2981 break;
2982
Sebastian Redl539c5062010-08-18 23:57:32 +00002983 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002984 S = new (Context) ExtVectorElementExpr(Empty);
2985 break;
2986
Sebastian Redl539c5062010-08-18 23:57:32 +00002987 case EXPR_INIT_LIST:
Argyrios Kyrtzidis0f05fb92012-11-28 03:56:16 +00002988 S = new (Context) InitListExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002989 break;
2990
Sebastian Redl539c5062010-08-18 23:57:32 +00002991 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002992 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002993 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00002994
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002995 break;
2996
Yunzhong Gaocb779302015-06-10 00:27:52 +00002997 case EXPR_DESIGNATED_INIT_UPDATE:
2998 S = new (Context) DesignatedInitUpdateExpr(Empty);
2999 break;
3000
Sebastian Redl539c5062010-08-18 23:57:32 +00003001 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003002 S = new (Context) ImplicitValueInitExpr(Empty);
3003 break;
3004
Yunzhong Gaocb779302015-06-10 00:27:52 +00003005 case EXPR_NO_INIT:
3006 S = new (Context) NoInitExpr(Empty);
3007 break;
3008
Richard Smith410306b2016-12-12 02:53:20 +00003009 case EXPR_ARRAY_INIT_LOOP:
3010 S = new (Context) ArrayInitLoopExpr(Empty);
3011 break;
3012
3013 case EXPR_ARRAY_INIT_INDEX:
3014 S = new (Context) ArrayInitIndexExpr(Empty);
3015 break;
3016
Sebastian Redl539c5062010-08-18 23:57:32 +00003017 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003018 S = new (Context) VAArgExpr(Empty);
3019 break;
3020
Eric Fiselier708afb52019-05-16 21:04:15 +00003021 case EXPR_SOURCE_LOC:
3022 S = new (Context) SourceLocExpr(Empty);
3023 break;
3024
Sebastian Redl539c5062010-08-18 23:57:32 +00003025 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003026 S = new (Context) AddrLabelExpr(Empty);
3027 break;
3028
Sebastian Redl539c5062010-08-18 23:57:32 +00003029 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003030 S = new (Context) StmtExpr(Empty);
3031 break;
3032
Sebastian Redl539c5062010-08-18 23:57:32 +00003033 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003034 S = new (Context) ChooseExpr(Empty);
3035 break;
3036
Sebastian Redl539c5062010-08-18 23:57:32 +00003037 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003038 S = new (Context) GNUNullExpr(Empty);
3039 break;
3040
Sebastian Redl539c5062010-08-18 23:57:32 +00003041 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003042 S = new (Context) ShuffleVectorExpr(Empty);
3043 break;
Mike Stump11289f42009-09-09 15:08:12 +00003044
Hal Finkelc4d7c822013-09-18 03:29:45 +00003045 case EXPR_CONVERT_VECTOR:
3046 S = new (Context) ConvertVectorExpr(Empty);
3047 break;
3048
Sebastian Redl539c5062010-08-18 23:57:32 +00003049 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003050 S = new (Context) BlockExpr(Empty);
3051 break;
3052
Peter Collingbourne91147592011-04-15 00:35:48 +00003053 case EXPR_GENERIC_SELECTION:
Bruno Riccidb076832019-01-26 14:15:10 +00003054 S = GenericSelectionExpr::CreateEmpty(
3055 Context,
3056 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
Peter Collingbourne91147592011-04-15 00:35:48 +00003057 break;
3058
Sebastian Redl539c5062010-08-18 23:57:32 +00003059 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003060 S = new (Context) ObjCStringLiteral(Empty);
3061 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003062
Patrick Beard0caa3942012-04-19 00:25:12 +00003063 case EXPR_OBJC_BOXED_EXPRESSION:
3064 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremeneke65b0862012-03-06 20:05:56 +00003065 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003066
Ted Kremeneke65b0862012-03-06 20:05:56 +00003067 case EXPR_OBJC_ARRAY_LITERAL:
3068 S = ObjCArrayLiteral::CreateEmpty(Context,
3069 Record[ASTStmtReader::NumExprFields]);
3070 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003071
Ted Kremeneke65b0862012-03-06 20:05:56 +00003072 case EXPR_OBJC_DICTIONARY_LITERAL:
3073 S = ObjCDictionaryLiteral::CreateEmpty(Context,
3074 Record[ASTStmtReader::NumExprFields],
3075 Record[ASTStmtReader::NumExprFields + 1]);
3076 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003077
Sebastian Redl539c5062010-08-18 23:57:32 +00003078 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003079 S = new (Context) ObjCEncodeExpr(Empty);
3080 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003081
Sebastian Redl539c5062010-08-18 23:57:32 +00003082 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003083 S = new (Context) ObjCSelectorExpr(Empty);
3084 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003085
Sebastian Redl539c5062010-08-18 23:57:32 +00003086 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003087 S = new (Context) ObjCProtocolExpr(Empty);
3088 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003089
Sebastian Redl539c5062010-08-18 23:57:32 +00003090 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003091 S = new (Context) ObjCIvarRefExpr(Empty);
3092 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003093
Sebastian Redl539c5062010-08-18 23:57:32 +00003094 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003095 S = new (Context) ObjCPropertyRefExpr(Empty);
3096 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003097
Ted Kremeneke65b0862012-03-06 20:05:56 +00003098 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
3099 S = new (Context) ObjCSubscriptRefExpr(Empty);
3100 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003101
Sebastian Redl539c5062010-08-18 23:57:32 +00003102 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00003103 llvm_unreachable("mismatching AST file");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003104
Sebastian Redl539c5062010-08-18 23:57:32 +00003105 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003106 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00003107 Record[ASTStmtReader::NumExprFields],
3108 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003109 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003110
Sebastian Redl539c5062010-08-18 23:57:32 +00003111 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00003112 S = new (Context) ObjCIsaExpr(Empty);
3113 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003114
John McCall31168b02011-06-15 23:02:42 +00003115 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
3116 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
3117 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003118
John McCall31168b02011-06-15 23:02:42 +00003119 case EXPR_OBJC_BRIDGED_CAST:
3120 S = new (Context) ObjCBridgedCastExpr(Empty);
3121 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003122
Sebastian Redl539c5062010-08-18 23:57:32 +00003123 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003124 S = new (Context) ObjCForCollectionStmt(Empty);
3125 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003126
Sebastian Redl539c5062010-08-18 23:57:32 +00003127 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003128 S = new (Context) ObjCAtCatchStmt(Empty);
3129 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003130
Sebastian Redl539c5062010-08-18 23:57:32 +00003131 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003132 S = new (Context) ObjCAtFinallyStmt(Empty);
3133 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003134
Sebastian Redl539c5062010-08-18 23:57:32 +00003135 case STMT_OBJC_AT_TRY:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003136 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003137 Record[ASTStmtReader::NumStmtFields],
3138 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003139 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003140
Sebastian Redl539c5062010-08-18 23:57:32 +00003141 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003142 S = new (Context) ObjCAtSynchronizedStmt(Empty);
3143 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003144
Sebastian Redl539c5062010-08-18 23:57:32 +00003145 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003146 S = new (Context) ObjCAtThrowStmt(Empty);
3147 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003148
John McCall31168b02011-06-15 23:02:42 +00003149 case STMT_OBJC_AUTORELEASE_POOL:
3150 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3151 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003152
Ted Kremeneke65b0862012-03-06 20:05:56 +00003153 case EXPR_OBJC_BOOL_LITERAL:
3154 S = new (Context) ObjCBoolLiteralExpr(Empty);
3155 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003156
Erik Pilkington29099de2016-07-16 00:35:23 +00003157 case EXPR_OBJC_AVAILABILITY_CHECK:
3158 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3159 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003160
Nico Weber9b982072014-07-07 00:12:30 +00003161 case STMT_SEH_LEAVE:
3162 S = new (Context) SEHLeaveStmt(Empty);
3163 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003164
John McCallfa194042011-07-15 07:00:14 +00003165 case STMT_SEH_EXCEPT:
3166 S = new (Context) SEHExceptStmt(Empty);
3167 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003168
John McCallfa194042011-07-15 07:00:14 +00003169 case STMT_SEH_FINALLY:
3170 S = new (Context) SEHFinallyStmt(Empty);
3171 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003172
John McCallfa194042011-07-15 07:00:14 +00003173 case STMT_SEH_TRY:
3174 S = new (Context) SEHTryStmt(Empty);
3175 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003176
Sebastian Redl539c5062010-08-18 23:57:32 +00003177 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003178 S = new (Context) CXXCatchStmt(Empty);
3179 break;
3180
Sebastian Redl539c5062010-08-18 23:57:32 +00003181 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003182 S = CXXTryStmt::Create(Context, Empty,
Rui Ueyama49a3ad22019-07-16 04:46:31 +00003183 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003184 break;
3185
Richard Smith02e85f32011-04-14 22:09:26 +00003186 case STMT_CXX_FOR_RANGE:
3187 S = new (Context) CXXForRangeStmt(Empty);
3188 break;
3189
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003190 case STMT_MS_DEPENDENT_EXISTS:
3191 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3192 NestedNameSpecifierLoc(),
3193 DeclarationNameInfo(),
Craig Toppera13603a2014-05-22 05:54:18 +00003194 nullptr);
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003195 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003196
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00003197 case STMT_OMP_PARALLEL_DIRECTIVE:
3198 S =
3199 OMPParallelDirective::CreateEmpty(Context,
3200 Record[ASTStmtReader::NumStmtFields],
3201 Empty);
3202 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003203
3204 case STMT_OMP_SIMD_DIRECTIVE: {
3205 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3206 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3207 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3208 CollapsedNum, Empty);
3209 break;
3210 }
3211
Alexey Bataevf29276e2014-06-18 04:14:57 +00003212 case STMT_OMP_FOR_DIRECTIVE: {
3213 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3214 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3215 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3216 Empty);
3217 break;
3218 }
3219
Alexander Musmanf82886e2014-09-18 05:12:34 +00003220 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3221 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3222 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3223 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3224 Empty);
3225 break;
3226 }
3227
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00003228 case STMT_OMP_SECTIONS_DIRECTIVE:
3229 S = OMPSectionsDirective::CreateEmpty(
3230 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3231 break;
3232
Alexey Bataev1e0498a2014-06-26 08:21:58 +00003233 case STMT_OMP_SECTION_DIRECTIVE:
3234 S = OMPSectionDirective::CreateEmpty(Context, Empty);
3235 break;
3236
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00003237 case STMT_OMP_SINGLE_DIRECTIVE:
3238 S = OMPSingleDirective::CreateEmpty(
3239 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3240 break;
3241
Alexander Musman80c22892014-07-17 08:54:58 +00003242 case STMT_OMP_MASTER_DIRECTIVE:
3243 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3244 break;
3245
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003246 case STMT_OMP_CRITICAL_DIRECTIVE:
Alexey Bataev28c75412015-12-15 08:19:24 +00003247 S = OMPCriticalDirective::CreateEmpty(
3248 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003249 break;
3250
Alexey Bataev4acb8592014-07-07 13:01:15 +00003251 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3252 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3253 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3254 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3255 CollapsedNum, Empty);
3256 break;
3257 }
3258
Alexander Musmane4e893b2014-09-23 09:33:00 +00003259 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3260 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3261 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3262 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3263 CollapsedNum, Empty);
3264 break;
3265 }
3266
cchen47d60942019-12-05 13:43:48 -05003267 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3268 S = OMPParallelMasterDirective::CreateEmpty(
3269 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3270 break;
3271
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00003272 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3273 S = OMPParallelSectionsDirective::CreateEmpty(
3274 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3275 break;
3276
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00003277 case STMT_OMP_TASK_DIRECTIVE:
3278 S = OMPTaskDirective::CreateEmpty(
3279 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3280 break;
3281
Alexey Bataev68446b72014-07-18 07:47:19 +00003282 case STMT_OMP_TASKYIELD_DIRECTIVE:
3283 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3284 break;
3285
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00003286 case STMT_OMP_BARRIER_DIRECTIVE:
3287 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3288 break;
3289
Alexey Bataev2df347a2014-07-18 10:17:07 +00003290 case STMT_OMP_TASKWAIT_DIRECTIVE:
3291 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3292 break;
3293
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003294 case STMT_OMP_TASKGROUP_DIRECTIVE:
Alexey Bataev169d96a2017-07-18 20:17:46 +00003295 S = OMPTaskgroupDirective::CreateEmpty(
3296 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003297 break;
3298
Alexey Bataev6125da92014-07-21 11:26:11 +00003299 case STMT_OMP_FLUSH_DIRECTIVE:
3300 S = OMPFlushDirective::CreateEmpty(
3301 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3302 break;
3303
Alexey Bataevc112e942020-02-28 09:52:15 -05003304 case STMT_OMP_DEPOBJ_DIRECTIVE:
3305 S = OMPDepobjDirective::CreateEmpty(
3306 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3307 break;
3308
Alexey Bataevfcba7c32020-03-20 07:03:01 -04003309 case STMT_OMP_SCAN_DIRECTIVE:
3310 S = OMPScanDirective::CreateEmpty(
3311 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3312 break;
3313
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003314 case STMT_OMP_ORDERED_DIRECTIVE:
Alexey Bataev346265e2015-09-25 10:37:12 +00003315 S = OMPOrderedDirective::CreateEmpty(
3316 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003317 break;
3318
Alexey Bataev0162e452014-07-22 10:10:35 +00003319 case STMT_OMP_ATOMIC_DIRECTIVE:
3320 S = OMPAtomicDirective::CreateEmpty(
3321 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3322 break;
3323
Alexey Bataev0bd520b2014-09-19 08:19:49 +00003324 case STMT_OMP_TARGET_DIRECTIVE:
3325 S = OMPTargetDirective::CreateEmpty(
3326 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3327 break;
3328
Michael Wong65f367f2015-07-21 13:44:28 +00003329 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3330 S = OMPTargetDataDirective::CreateEmpty(
3331 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3332 break;
3333
Samuel Antaodf67fc42016-01-19 19:15:56 +00003334 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3335 S = OMPTargetEnterDataDirective::CreateEmpty(
3336 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3337 break;
3338
Samuel Antao72590762016-01-19 20:04:50 +00003339 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3340 S = OMPTargetExitDataDirective::CreateEmpty(
3341 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3342 break;
3343
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00003344 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3345 S = OMPTargetParallelDirective::CreateEmpty(
3346 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3347 break;
3348
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00003349 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3350 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3351 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3352 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3353 CollapsedNum, Empty);
3354 break;
3355 }
3356
Samuel Antao686c70c2016-05-26 17:30:50 +00003357 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3358 S = OMPTargetUpdateDirective::CreateEmpty(
3359 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3360 break;
3361
Alexey Bataev13314bf2014-10-09 04:18:56 +00003362 case STMT_OMP_TEAMS_DIRECTIVE:
3363 S = OMPTeamsDirective::CreateEmpty(
3364 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3365 break;
3366
Alexey Bataev6d4ed052015-07-01 06:57:41 +00003367 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3368 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3369 break;
3370
Alexey Bataev80909872015-07-02 11:25:17 +00003371 case STMT_OMP_CANCEL_DIRECTIVE:
Alexey Bataev87933c72015-09-18 08:07:34 +00003372 S = OMPCancelDirective::CreateEmpty(
3373 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev80909872015-07-02 11:25:17 +00003374 break;
3375
Alexey Bataev49f6e782015-12-01 04:18:41 +00003376 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3377 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3378 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3379 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3380 Empty);
3381 break;
3382 }
3383
Alexey Bataev0a6ed842015-12-03 09:40:15 +00003384 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3385 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3386 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3387 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3388 CollapsedNum, Empty);
3389 break;
3390 }
3391
Alexey Bataev60e51c42019-10-10 20:13:02 +00003392 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3393 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3394 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3395 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3396 CollapsedNum, Empty);
3397 break;
3398 }
3399
Alexey Bataevb8552ab2019-10-18 16:47:35 +00003400 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3401 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3402 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3403 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3404 CollapsedNum, Empty);
3405 break;
3406 }
3407
Alexey Bataev5bbcead2019-10-14 17:17:41 +00003408 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3409 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3410 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3411 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3412 CollapsedNum, Empty);
3413 break;
3414 }
3415
Alexey Bataev14a388f2019-10-25 10:27:13 -04003416 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3417 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3418 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3419 S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3420 Context, NumClauses, CollapsedNum, Empty);
3421 break;
3422 }
3423
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00003424 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3425 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3426 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3427 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3428 Empty);
3429 break;
3430 }
3431
Carlo Bertolli9925f152016-06-27 14:55:37 +00003432 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3433 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3434 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3435 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3436 CollapsedNum, Empty);
3437 break;
3438 }
3439
Kelvin Li4a39add2016-07-05 05:00:15 +00003440 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3441 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3442 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3443 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3444 CollapsedNum,
3445 Empty);
3446 break;
3447 }
3448
Kelvin Li787f3fc2016-07-06 04:45:38 +00003449 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3450 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3451 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3452 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3453 CollapsedNum, Empty);
3454 break;
3455 }
3456
Kelvin Lia579b912016-07-14 02:54:56 +00003457 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3458 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3459 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3460 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3461 CollapsedNum, Empty);
3462 break;
3463 }
3464
Kelvin Li986330c2016-07-20 22:57:10 +00003465 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3466 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3467 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3468 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3469 Empty);
3470 break;
3471 }
3472
Kelvin Li83c451e2016-12-25 04:52:54 +00003473 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
Kelvin Li02532872016-08-05 14:37:37 +00003474 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3475 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3476 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3477 CollapsedNum, Empty);
3478 break;
3479 }
3480
Kelvin Li4e325f72016-10-25 12:50:55 +00003481 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3482 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3483 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3484 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3485 CollapsedNum, Empty);
3486 break;
3487 }
3488
Kelvin Li579e41c2016-11-30 23:51:03 +00003489 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3490 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3491 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3492 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3493 Context, NumClauses, CollapsedNum, Empty);
3494 break;
3495 }
3496
Kelvin Li7ade93f2016-12-09 03:24:30 +00003497 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3498 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3499 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3500 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3501 Context, NumClauses, CollapsedNum, Empty);
3502 break;
3503 }
3504
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003505 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
Kelvin Libf594a52016-12-17 05:48:59 +00003506 S = OMPTargetTeamsDirective::CreateEmpty(
3507 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3508 break;
Kelvin Li83c451e2016-12-25 04:52:54 +00003509
3510 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3511 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3512 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3513 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3514 CollapsedNum, Empty);
3515 break;
3516 }
3517
Kelvin Li80e8f562016-12-29 22:16:30 +00003518 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3519 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3520 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3521 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3522 Context, NumClauses, CollapsedNum, Empty);
3523 break;
3524 }
3525
Kelvin Li1851df52017-01-03 05:23:48 +00003526 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3527 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3528 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3529 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3530 Context, NumClauses, CollapsedNum, Empty);
3531 break;
3532 }
3533
Kelvin Lida681182017-01-10 18:08:18 +00003534 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3535 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3536 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3537 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3538 Context, NumClauses, CollapsedNum, Empty);
3539 break;
3540 }
3541
Sebastian Redl539c5062010-08-18 23:57:32 +00003542 case EXPR_CXX_OPERATOR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003543 S = CXXOperatorCallExpr::CreateEmpty(
3544 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00003545 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003546
Sebastian Redl539c5062010-08-18 23:57:32 +00003547 case EXPR_CXX_MEMBER_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003548 S = CXXMemberCallExpr::CreateEmpty(
3549 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003550 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003551
Richard Smith778dc0f2019-10-19 00:04:38 +00003552 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3553 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3554 break;
3555
Sebastian Redl539c5062010-08-18 23:57:32 +00003556 case EXPR_CXX_CONSTRUCT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003557 S = CXXConstructExpr::CreateEmpty(
3558 Context,
3559 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003560 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003561
Richard Smith5179eb72016-06-28 19:03:57 +00003562 case EXPR_CXX_INHERITED_CTOR_INIT:
3563 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3564 break;
3565
Sebastian Redl539c5062010-08-18 23:57:32 +00003566 case EXPR_CXX_TEMPORARY_OBJECT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003567 S = CXXTemporaryObjectExpr::CreateEmpty(
3568 Context,
3569 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00003570 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003571
Sebastian Redl539c5062010-08-18 23:57:32 +00003572 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003573 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003574 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003575 break;
3576
Sebastian Redl539c5062010-08-18 23:57:32 +00003577 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003578 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003579 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003580 break;
3581
Sebastian Redl539c5062010-08-18 23:57:32 +00003582 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003583 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003584 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003585 break;
3586
Sebastian Redl539c5062010-08-18 23:57:32 +00003587 case EXPR_CXX_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003588 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00003589 break;
3590
Sebastian Redl539c5062010-08-18 23:57:32 +00003591 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003592 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003593 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003594 break;
3595
Richard Smithc67fdd42012-03-07 08:35:16 +00003596 case EXPR_USER_DEFINED_LITERAL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003597 S = UserDefinedLiteral::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003598 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Richard Smithc67fdd42012-03-07 08:35:16 +00003599 break;
3600
Richard Smithcc1b96d2013-06-12 22:31:48 +00003601 case EXPR_CXX_STD_INITIALIZER_LIST:
3602 S = new (Context) CXXStdInitializerListExpr(Empty);
3603 break;
3604
Sebastian Redl539c5062010-08-18 23:57:32 +00003605 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003606 S = new (Context) CXXBoolLiteralExpr(Empty);
3607 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003608
Sebastian Redl539c5062010-08-18 23:57:32 +00003609 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003610 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3611 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003612
Sebastian Redl539c5062010-08-18 23:57:32 +00003613 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003614 S = new (Context) CXXTypeidExpr(Empty, true);
3615 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003616
Sebastian Redl539c5062010-08-18 23:57:32 +00003617 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003618 S = new (Context) CXXTypeidExpr(Empty, false);
3619 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003620
Francois Pichet9f4f2072010-09-08 12:20:18 +00003621 case EXPR_CXX_UUIDOF_EXPR:
3622 S = new (Context) CXXUuidofExpr(Empty, true);
3623 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003624
John McCall5e77d762013-04-16 07:28:30 +00003625 case EXPR_CXX_PROPERTY_REF_EXPR:
3626 S = new (Context) MSPropertyRefExpr(Empty);
3627 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003628
Alexey Bataevf7630272015-11-25 12:01:00 +00003629 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3630 S = new (Context) MSPropertySubscriptExpr(Empty);
3631 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003632
Francois Pichet9f4f2072010-09-08 12:20:18 +00003633 case EXPR_CXX_UUIDOF_TYPE:
3634 S = new (Context) CXXUuidofExpr(Empty, false);
3635 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003636
Sebastian Redl539c5062010-08-18 23:57:32 +00003637 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00003638 S = new (Context) CXXThisExpr(Empty);
3639 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003640
Sebastian Redl539c5062010-08-18 23:57:32 +00003641 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00003642 S = new (Context) CXXThrowExpr(Empty);
3643 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003644
John McCall32791cc2016-01-06 22:34:54 +00003645 case EXPR_CXX_DEFAULT_ARG:
3646 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00003647 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003648
Richard Smith852c9db2013-04-20 22:23:05 +00003649 case EXPR_CXX_DEFAULT_INIT:
3650 S = new (Context) CXXDefaultInitExpr(Empty);
3651 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003652
Sebastian Redl539c5062010-08-18 23:57:32 +00003653 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00003654 S = new (Context) CXXBindTemporaryExpr(Empty);
3655 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003656
Sebastian Redl539c5062010-08-18 23:57:32 +00003657 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00003658 S = new (Context) CXXScalarValueInitExpr(Empty);
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_NEW:
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00003662 S = CXXNewExpr::CreateEmpty(
3663 Context,
3664 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3665 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3666 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3667 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003668 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003669
Sebastian Redl539c5062010-08-18 23:57:32 +00003670 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00003671 S = new (Context) CXXDeleteExpr(Empty);
3672 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003673
Sebastian Redl539c5062010-08-18 23:57:32 +00003674 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00003675 S = new (Context) CXXPseudoDestructorExpr(Empty);
3676 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003677
John McCall5d413782010-12-06 08:20:24 +00003678 case EXPR_EXPR_WITH_CLEANUPS:
John McCall28fc7092011-11-10 05:35:25 +00003679 S = ExprWithCleanups::Create(Context, Empty,
3680 Record[ASTStmtReader::NumExprFields]);
Chris Lattnercba86142010-05-10 00:25:06 +00003681 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003682
Sebastian Redl539c5062010-08-18 23:57:32 +00003683 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Bruno Ricci2e6dc532019-01-08 14:17:00 +00003684 S = CXXDependentScopeMemberExpr::CreateEmpty(
3685 Context,
3686 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3687 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3688 /*HasFirstQualifierFoundInScope=*/
3689 Record[ASTStmtReader::NumExprFields + 2]);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003690 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003691
Sebastian Redl539c5062010-08-18 23:57:32 +00003692 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003693 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003694 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003695 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003696 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003697 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00003698 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003699
Sebastian Redl539c5062010-08-18 23:57:32 +00003700 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003701 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003702 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00003703 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003704
Sebastian Redl539c5062010-08-18 23:57:32 +00003705 case EXPR_CXX_UNRESOLVED_MEMBER:
Bruno Riccid7628d92019-01-09 15:43:19 +00003706 S = UnresolvedMemberExpr::CreateEmpty(
3707 Context,
3708 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3709 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3710 /*NumTemplateArgs=*/
3711 Record[ASTStmtReader::NumExprFields + 1]
3712 ? Record[ASTStmtReader::NumExprFields + 2]
3713 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003714 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003715
Sebastian Redl539c5062010-08-18 23:57:32 +00003716 case EXPR_CXX_UNRESOLVED_LOOKUP:
Bruno Riccid7628d92019-01-09 15:43:19 +00003717 S = UnresolvedLookupExpr::CreateEmpty(
3718 Context,
3719 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3720 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3721 /*NumTemplateArgs=*/
3722 Record[ASTStmtReader::NumExprFields + 1]
3723 ? Record[ASTStmtReader::NumExprFields + 2]
3724 : 0);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00003725 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003726
Douglas Gregor29c42f22012-02-24 07:38:34 +00003727 case EXPR_TYPE_TRAIT:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003728 S = TypeTraitExpr::CreateDeserialized(Context,
Douglas Gregor29c42f22012-02-24 07:38:34 +00003729 Record[ASTStmtReader::NumExprFields]);
3730 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003731
John Wiegley6242b6a2011-04-28 00:16:57 +00003732 case EXPR_ARRAY_TYPE_TRAIT:
3733 S = new (Context) ArrayTypeTraitExpr(Empty);
3734 break;
3735
John Wiegleyf9f65842011-04-25 06:54:41 +00003736 case EXPR_CXX_EXPRESSION_TRAIT:
3737 S = new (Context) ExpressionTraitExpr(Empty);
3738 break;
3739
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003740 case EXPR_CXX_NOEXCEPT:
3741 S = new (Context) CXXNoexceptExpr(Empty);
3742 break;
John McCall8d69a212010-11-15 23:31:06 +00003743
Douglas Gregore8e9dd62011-01-03 17:17:50 +00003744 case EXPR_PACK_EXPANSION:
3745 S = new (Context) PackExpansionExpr(Empty);
3746 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003747
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003748 case EXPR_SIZEOF_PACK:
Richard Smithd784e682015-09-23 21:41:42 +00003749 S = SizeOfPackExpr::CreateDeserialized(
3750 Context,
3751 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003752 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003753
John McCallfa194042011-07-15 07:00:14 +00003754 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3755 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3756 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003757
Douglas Gregorcdbc5392011-01-15 01:15:58 +00003758 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3759 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3760 break;
Richard Smithb15fe3a2012-09-12 00:56:43 +00003761
3762 case EXPR_FUNCTION_PARM_PACK:
3763 S = FunctionParmPackExpr::CreateEmpty(Context,
3764 Record[ASTStmtReader::NumExprFields]);
3765 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003766
Douglas Gregorfe314812011-06-21 17:03:29 +00003767 case EXPR_MATERIALIZE_TEMPORARY:
3768 S = new (Context) MaterializeTemporaryExpr(Empty);
3769 break;
Richard Smith0f0af192014-11-08 05:07:16 +00003770
3771 case EXPR_CXX_FOLD:
3772 S = new (Context) CXXFoldExpr(Empty);
3773 break;
3774
Argyrios Kyrtzidisb2b07952011-12-03 03:49:52 +00003775 case EXPR_OPAQUE_VALUE:
3776 S = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00003777 break;
Peter Collingbourne41f85462011-02-09 21:07:24 +00003778
3779 case EXPR_CUDA_KERNEL_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003780 S = CUDAKernelCallExpr::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003781 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00003782 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003783
Tanya Lattner55808c12011-06-04 00:47:47 +00003784 case EXPR_ASTYPE:
3785 S = new (Context) AsTypeExpr(Empty);
3786 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003787
John McCallfe96e0b2011-11-06 09:01:30 +00003788 case EXPR_PSEUDO_OBJECT: {
3789 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3790 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3791 break;
3792 }
3793
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003794 case EXPR_ATOMIC:
3795 S = new (Context) AtomicExpr(Empty);
3796 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003797
Douglas Gregor99ae8062012-02-14 17:54:36 +00003798 case EXPR_LAMBDA: {
3799 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
Richard Smith30e304e2016-12-14 00:03:17 +00003800 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
Douglas Gregor99ae8062012-02-14 17:54:36 +00003801 break;
3802 }
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +00003803
3804 case STMT_COROUTINE_BODY: {
3805 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3806 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3807 break;
3808 }
3809
3810 case STMT_CORETURN:
3811 S = new (Context) CoreturnStmt(Empty);
3812 break;
3813
3814 case EXPR_COAWAIT:
3815 S = new (Context) CoawaitExpr(Empty);
3816 break;
3817
3818 case EXPR_COYIELD:
3819 S = new (Context) CoyieldExpr(Empty);
3820 break;
3821
3822 case EXPR_DEPENDENT_COAWAIT:
3823 S = new (Context) DependentCoawaitExpr(Empty);
3824 break;
Saar Raz5d98ba62019-10-15 15:24:26 +00003825
Saar Raza0f50d72020-01-18 09:11:43 +02003826 case EXPR_CONCEPT_SPECIALIZATION: {
Saar Raz5d98ba62019-10-15 15:24:26 +00003827 unsigned numTemplateArgs = Record[ASTStmtReader::NumExprFields];
3828 S = ConceptSpecializationExpr::Create(Context, Empty, numTemplateArgs);
3829 break;
Saar Raza0f50d72020-01-18 09:11:43 +02003830 }
3831
3832 case EXPR_REQUIRES:
3833 unsigned numLocalParameters = Record[ASTStmtReader::NumExprFields];
3834 unsigned numRequirement = Record[ASTStmtReader::NumExprFields + 1];
3835 S = RequiresExpr::Create(Context, Empty, numLocalParameters,
3836 numRequirement);
3837 break;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003838 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003839
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003840 // We hit a STMT_STOP, so we're done with this expression.
3841 if (Finished)
3842 break;
3843
3844 ++NumStatementsRead;
3845
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003846 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003847 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003848 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3849 }
3850
David L. Jonesbe1557a2016-12-21 00:17:49 +00003851 assert(Record.getIdx() == Record.size() &&
3852 "Invalid deserialization of statement");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003853 StmtStack.push_back(S);
3854 }
Chris Lattner0e6c9402013-01-20 02:38:54 +00003855Done:
Alp Toker028ed912013-12-06 17:56:43 +00003856 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003857 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003858 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003859}