blob: 0c379839ba839eed6ebd77e1c9a6db77b2a40fb7 [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);
Bruno Riccie7ce0522020-06-21 13:02:48 +0100544
545 auto StorageKind = Record.readInt();
546 assert(E->ConstantExprBits.ResultKind == StorageKind && "Wrong ResultKind!");
547
548 E->ConstantExprBits.APValueKind = Record.readInt();
549 E->ConstantExprBits.IsUnsigned = Record.readInt();
550 E->ConstantExprBits.BitWidth = Record.readInt();
551 E->ConstantExprBits.HasCleanup = false; // Not serialized, see below.
552 E->ConstantExprBits.IsImmediateInvocation = Record.readInt();
553
554 switch (StorageKind) {
555 case ConstantExpr::RSK_None:
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000556 break;
Bruno Riccie7ce0522020-06-21 13:02:48 +0100557
558 case ConstantExpr::RSK_Int64:
559 E->Int64Result() = Record.readInt();
560 break;
561
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000562 case ConstantExpr::RSK_APValue:
563 E->APValueResult() = Record.readAPValue();
Bruno Riccie7ce0522020-06-21 13:02:48 +0100564 if (E->APValueResult().needsCleanup()) {
565 E->ConstantExprBits.HasCleanup = true;
566 Record.getContext().addDestruction(&E->APValueResult());
567 }
568 break;
569 default:
570 llvm_unreachable("unexpected ResultKind!");
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000571 }
Bruno Riccie7ce0522020-06-21 13:02:48 +0100572
Bill Wendling7c44da22018-10-31 03:48:47 +0000573 E->setSubExpr(Record.readSubExpr());
574}
575
Sebastian Redl70c751d2010-08-18 23:56:52 +0000576void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000577 VisitExpr(E);
Bruno Ricci17ff0262018-10-27 19:21:19 +0000578 bool HasFunctionName = Record.readInt();
579 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
580 E->PredefinedExprBits.Kind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500581 E->setLocation(readSourceLocation());
Bruno Ricci17ff0262018-10-27 19:21:19 +0000582 if (HasFunctionName)
583 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000584}
585
Sebastian Redl70c751d2010-08-18 23:56:52 +0000586void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000587 VisitExpr(E);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000588
David L. Jonesbe1557a2016-12-21 00:17:49 +0000589 E->DeclRefExprBits.HasQualifier = Record.readInt();
590 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
591 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
592 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
593 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
Richard Smith715f7a12019-06-11 17:50:32 +0000594 E->DeclRefExprBits.NonOdrUseReason = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000595 unsigned NumTemplateArgs = 0;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000596 if (E->hasTemplateKWAndArgsInfo())
David L. Jonesbe1557a2016-12-21 00:17:49 +0000597 NumTemplateArgs = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000598
Chandler Carruth0e439962011-05-01 21:29:53 +0000599 if (E->hasQualifier())
James Y Knighte7d82282015-12-29 18:15:14 +0000600 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
David L. Jonesb6a8f022016-12-21 04:34:52 +0000601 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000602
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000603 if (E->hasFoundDecl())
John McCall3ce3d232019-12-13 03:37:23 -0500604 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000605
Abramo Bagnara7945c982012-01-27 09:46:47 +0000606 if (E->hasTemplateKWAndArgsInfo())
James Y Knighte7d82282015-12-29 18:15:14 +0000607 ReadTemplateKWAndArgsInfo(
608 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
609 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000610
John McCall3ce3d232019-12-13 03:37:23 -0500611 E->setDecl(readDeclAs<ValueDecl>());
612 E->setLocation(readSourceLocation());
613 E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000614}
615
Sebastian Redl70c751d2010-08-18 23:56:52 +0000616void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000617 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500618 E->setLocation(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000619 E->setValue(Record.getContext(), Record.readAPInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000620}
621
Leonard Chandb01c3a2018-06-20 17:19:40 +0000622void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
623 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500624 E->setLocation(readSourceLocation());
Vince Bridgers161fc1d2020-04-07 14:46:08 -0500625 E->setScale(Record.readInt());
Leonard Chandb01c3a2018-06-20 17:19:40 +0000626 E->setValue(Record.getContext(), Record.readAPInt());
627}
628
Sebastian Redl70c751d2010-08-18 23:56:52 +0000629void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000630 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000631 E->setRawSemantics(
632 static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
David L. Jonesbe1557a2016-12-21 00:17:49 +0000633 E->setExact(Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000634 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
John McCall3ce3d232019-12-13 03:37:23 -0500635 E->setLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000636}
637
Sebastian Redl70c751d2010-08-18 23:56:52 +0000638void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000639 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000640 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000641}
642
Sebastian Redl70c751d2010-08-18 23:56:52 +0000643void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000644 VisitExpr(E);
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000645
646 // NumConcatenated, Length and CharByteWidth are set by the empty
647 // ctor since they are needed to allocate storage for the trailing objects.
648 unsigned NumConcatenated = Record.readInt();
649 unsigned Length = Record.readInt();
650 unsigned CharByteWidth = Record.readInt();
651 assert((NumConcatenated == E->getNumConcatenated()) &&
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000652 "Wrong number of concatenated tokens!");
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000653 assert((Length == E->getLength()) && "Wrong Length!");
654 assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
655 E->StringLiteralBits.Kind = Record.readInt();
656 E->StringLiteralBits.IsPascal = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000657
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000658 // The character width is originally computed via mapCharByteWidth.
659 // Check that the deserialized character width is consistant with the result
660 // of calling mapCharByteWidth.
661 assert((CharByteWidth ==
662 StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
663 E->getKind())) &&
664 "Wrong character width!");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000665
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000666 // Deserialize the trailing array of SourceLocation.
667 for (unsigned I = 0; I < NumConcatenated; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500668 E->setStrTokenLoc(I, readSourceLocation());
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000669
670 // Deserialize the trailing array of char holding the string data.
671 char *StrData = E->getStrDataAsChar();
672 for (unsigned I = 0; I < Length * CharByteWidth; ++I)
673 StrData[I] = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000674}
675
Sebastian Redl70c751d2010-08-18 23:56:52 +0000676void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000677 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000678 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500679 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000680 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000681}
682
Sebastian Redl70c751d2010-08-18 23:56:52 +0000683void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000684 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500685 E->setLParen(readSourceLocation());
686 E->setRParen(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000687 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000688}
689
Sebastian Redl70c751d2010-08-18 23:56:52 +0000690void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000691 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000692 unsigned NumExprs = Record.readInt();
Bruno Riccif49e1ca2018-11-20 16:20:40 +0000693 assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
694 for (unsigned I = 0; I != NumExprs; ++I)
695 E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500696 E->LParenLoc = readSourceLocation();
697 E->RParenLoc = readSourceLocation();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000698}
699
Sebastian Redl70c751d2010-08-18 23:56:52 +0000700void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000701 VisitExpr(E);
Melanie Blowerf5360d42020-05-01 10:32:06 -0700702 bool hasFP_Features = Record.readInt();
703 assert(hasFP_Features == E->hasStoredFPFeatures());
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000704 E->setSubExpr(Record.readSubExpr());
705 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500706 E->setOperatorLoc(readSourceLocation());
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000707 E->setCanOverflow(Record.readInt());
Melanie Blowerf5360d42020-05-01 10:32:06 -0700708 if (hasFP_Features)
Melanie Blowerdefd43a2020-06-26 08:45:12 -0700709 E->setStoredFPFeatures(FPOptions(Record.readInt()));
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000710}
711
712void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000713 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000714 assert(E->getNumComponents() == Record.peekInt());
715 Record.skipInts(1);
716 assert(E->getNumExpressions() == Record.peekInt());
717 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500718 E->setOperatorLoc(readSourceLocation());
719 E->setRParenLoc(readSourceLocation());
720 E->setTypeSourceInfo(readTypeSourceInfo());
Douglas Gregor882211c2010-04-28 22:16:22 +0000721 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000722 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500723 SourceLocation Start = readSourceLocation();
724 SourceLocation End = readSourceLocation();
Douglas Gregor882211c2010-04-28 22:16:22 +0000725 switch (Kind) {
James Y Knight7281c352015-12-29 22:31:18 +0000726 case OffsetOfNode::Array:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000727 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000728 break;
729
James Y Knight7281c352015-12-29 22:31:18 +0000730 case OffsetOfNode::Field:
731 E->setComponent(
John McCall3ce3d232019-12-13 03:37:23 -0500732 I, OffsetOfNode(Start, readDeclAs<FieldDecl>(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000733 break;
James Y Knight7281c352015-12-29 22:31:18 +0000734
735 case OffsetOfNode::Identifier:
736 E->setComponent(
737 I,
John McCall3ce3d232019-12-13 03:37:23 -0500738 OffsetOfNode(Start, Record.readIdentifier(), End));
James Y Knight7281c352015-12-29 22:31:18 +0000739 break;
740
741 case OffsetOfNode::Base: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000742 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000743 *Base = Record.readCXXBaseSpecifier();
James Y Knight7281c352015-12-29 22:31:18 +0000744 E->setComponent(I, OffsetOfNode(Base));
Douglas Gregord1702062010-04-29 00:18:15 +0000745 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000746 }
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000747 }
Douglas Gregor882211c2010-04-28 22:16:22 +0000748 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000749
Douglas Gregor882211c2010-04-28 22:16:22 +0000750 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000751 E->setIndexExpr(I, Record.readSubExpr());
Douglas Gregor882211c2010-04-28 22:16:22 +0000752}
753
Peter Collingbournee190dee2011-03-11 19:24:49 +0000754void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000755 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000756 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
757 if (Record.peekInt() == 0) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000758 E->setArgument(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000759 Record.skipInts(1);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000760 } else {
John McCall3ce3d232019-12-13 03:37:23 -0500761 E->setArgument(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000762 }
John McCall3ce3d232019-12-13 03:37:23 -0500763 E->setOperatorLoc(readSourceLocation());
764 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000765}
766
Saar Raza0f50d72020-01-18 09:11:43 +0200767static ConstraintSatisfaction
768readConstraintSatisfaction(ASTRecordReader &Record) {
769 ConstraintSatisfaction Satisfaction;
770 Satisfaction.IsSatisfied = Record.readInt();
771 if (!Satisfaction.IsSatisfied) {
772 unsigned NumDetailRecords = Record.readInt();
773 for (unsigned i = 0; i != NumDetailRecords; ++i) {
774 Expr *ConstraintExpr = Record.readExpr();
Michael Liao70b53a302020-01-19 12:23:11 -0500775 if (/* IsDiagnostic */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200776 SourceLocation DiagLocation = Record.readSourceLocation();
777 std::string DiagMessage = Record.readString();
778 Satisfaction.Details.emplace_back(
779 ConstraintExpr, new (Record.getContext())
780 ConstraintSatisfaction::SubstitutionDiagnostic{
781 DiagLocation, DiagMessage});
782 } else
783 Satisfaction.Details.emplace_back(ConstraintExpr, Record.readExpr());
784 }
785 }
786 return Satisfaction;
787}
788
Saar Raz5d98ba62019-10-15 15:24:26 +0000789void ASTStmtReader::VisitConceptSpecializationExpr(
790 ConceptSpecializationExpr *E) {
791 VisitExpr(E);
792 unsigned NumTemplateArgs = Record.readInt();
793 E->NestedNameSpec = Record.readNestedNameSpecifierLoc();
794 E->TemplateKWLoc = Record.readSourceLocation();
Saar Razff1e0fc2020-01-15 02:48:42 +0200795 E->ConceptName = Record.readDeclarationNameInfo();
John McCall3ce3d232019-12-13 03:37:23 -0500796 E->NamedConcept = readDeclAs<ConceptDecl>();
Saar Razf9e63892020-03-10 22:04:11 +0200797 E->FoundDecl = Record.readDeclAs<NamedDecl>();
Saar Razff1e0fc2020-01-15 02:48:42 +0200798 E->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
Saar Raz5d98ba62019-10-15 15:24:26 +0000799 llvm::SmallVector<TemplateArgument, 4> Args;
800 for (unsigned I = 0; I < NumTemplateArgs; ++I)
801 Args.push_back(Record.readTemplateArgument());
Saar Razff1e0fc2020-01-15 02:48:42 +0200802 E->setTemplateArguments(Args);
Saar Raza0f50d72020-01-18 09:11:43 +0200803 E->Satisfaction = E->isValueDependent() ? nullptr :
804 ASTConstraintSatisfaction::Create(Record.getContext(),
805 readConstraintSatisfaction(Record));
806}
807
808static concepts::Requirement::SubstitutionDiagnostic *
809readSubstitutionDiagnostic(ASTRecordReader &Record) {
810 std::string SubstitutedEntity = Record.readString();
811 SourceLocation DiagLoc = Record.readSourceLocation();
812 std::string DiagMessage = Record.readString();
813 return new (Record.getContext())
814 concepts::Requirement::SubstitutionDiagnostic{SubstitutedEntity, DiagLoc,
815 DiagMessage};
816}
817
818void ASTStmtReader::VisitRequiresExpr(RequiresExpr *E) {
819 VisitExpr(E);
820 unsigned NumLocalParameters = Record.readInt();
821 unsigned NumRequirements = Record.readInt();
822 E->RequiresExprBits.RequiresKWLoc = Record.readSourceLocation();
823 E->RequiresExprBits.IsSatisfied = Record.readInt();
824 E->Body = Record.readDeclAs<RequiresExprBodyDecl>();
825 llvm::SmallVector<ParmVarDecl *, 4> LocalParameters;
826 for (unsigned i = 0; i < NumLocalParameters; ++i)
827 LocalParameters.push_back(cast<ParmVarDecl>(Record.readDecl()));
828 std::copy(LocalParameters.begin(), LocalParameters.end(),
829 E->getTrailingObjects<ParmVarDecl *>());
830 llvm::SmallVector<concepts::Requirement *, 4> Requirements;
831 for (unsigned i = 0; i < NumRequirements; ++i) {
832 auto RK =
833 static_cast<concepts::Requirement::RequirementKind>(Record.readInt());
834 concepts::Requirement *R = nullptr;
835 switch (RK) {
836 case concepts::Requirement::RK_Type: {
837 auto Status =
838 static_cast<concepts::TypeRequirement::SatisfactionStatus>(
839 Record.readInt());
840 if (Status == concepts::TypeRequirement::SS_SubstitutionFailure)
841 R = new (Record.getContext())
842 concepts::TypeRequirement(readSubstitutionDiagnostic(Record));
843 else
844 R = new (Record.getContext())
845 concepts::TypeRequirement(Record.readTypeSourceInfo());
846 } break;
847 case concepts::Requirement::RK_Simple:
848 case concepts::Requirement::RK_Compound: {
849 auto Status =
850 static_cast<concepts::ExprRequirement::SatisfactionStatus>(
851 Record.readInt());
852 llvm::PointerUnion<concepts::Requirement::SubstitutionDiagnostic *,
853 Expr *> E;
854 if (Status == concepts::ExprRequirement::SS_ExprSubstitutionFailure) {
855 E = readSubstitutionDiagnostic(Record);
856 } else
857 E = Record.readExpr();
858
859 llvm::Optional<concepts::ExprRequirement::ReturnTypeRequirement> Req;
860 ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr;
861 SourceLocation NoexceptLoc;
862 if (RK == concepts::Requirement::RK_Simple) {
863 Req.emplace();
864 } else {
865 NoexceptLoc = Record.readSourceLocation();
Michael Liao70b53a302020-01-19 12:23:11 -0500866 switch (/* returnTypeRequirementKind */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200867 case 0:
868 // No return type requirement.
869 Req.emplace();
870 break;
871 case 1: {
872 // type-constraint
873 TemplateParameterList *TPL = Record.readTemplateParameterList();
874 if (Status >=
875 concepts::ExprRequirement::SS_ConstraintsNotSatisfied)
876 SubstitutedConstraintExpr =
877 cast<ConceptSpecializationExpr>(Record.readExpr());
878 Req.emplace(TPL);
879 } break;
880 case 2:
881 // Substitution failure
882 Req.emplace(readSubstitutionDiagnostic(Record));
883 break;
884 }
885 }
886 if (Expr *Ex = E.dyn_cast<Expr *>())
887 R = new (Record.getContext()) concepts::ExprRequirement(
888 Ex, RK == concepts::Requirement::RK_Simple, NoexceptLoc,
889 std::move(*Req), Status, SubstitutedConstraintExpr);
890 else
891 R = new (Record.getContext()) concepts::ExprRequirement(
892 E.get<concepts::Requirement::SubstitutionDiagnostic *>(),
893 RK == concepts::Requirement::RK_Simple, NoexceptLoc,
894 std::move(*Req));
895 } break;
896 case concepts::Requirement::RK_Nested: {
Michael Liao70b53a302020-01-19 12:23:11 -0500897 if (/* IsSubstitutionDiagnostic */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200898 R = new (Record.getContext()) concepts::NestedRequirement(
899 readSubstitutionDiagnostic(Record));
900 break;
901 }
902 Expr *E = Record.readExpr();
903 if (E->isInstantiationDependent())
904 R = new (Record.getContext()) concepts::NestedRequirement(E);
905 else
906 R = new (Record.getContext())
907 concepts::NestedRequirement(Record.getContext(), E,
908 readConstraintSatisfaction(Record));
909 } break;
Saar Razfdf80e82019-12-06 01:30:21 +0200910 }
Saar Raza0f50d72020-01-18 09:11:43 +0200911 if (!R)
912 continue;
913 Requirements.push_back(R);
Saar Razfdf80e82019-12-06 01:30:21 +0200914 }
Saar Raza0f50d72020-01-18 09:11:43 +0200915 std::copy(Requirements.begin(), Requirements.end(),
916 E->getTrailingObjects<concepts::Requirement *>());
917 E->RBraceLoc = Record.readSourceLocation();
Saar Raz5d98ba62019-10-15 15:24:26 +0000918}
919
Sebastian Redl70c751d2010-08-18 23:56:52 +0000920void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000921 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000922 E->setLHS(Record.readSubExpr());
923 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500924 E->setRBracketLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000925}
926
Florian Hahn8f3f88d2020-06-01 19:42:03 +0100927void ASTStmtReader::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
928 VisitExpr(E);
929 E->setBase(Record.readSubExpr());
930 E->setRowIdx(Record.readSubExpr());
931 E->setColumnIdx(Record.readSubExpr());
932 E->setRBracketLoc(readSourceLocation());
933}
934
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000935void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
936 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000937 E->setBase(Record.readSubExpr());
938 E->setLowerBound(Record.readSubExpr());
939 E->setLength(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500940 E->setColonLoc(readSourceLocation());
941 E->setRBracketLoc(readSourceLocation());
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000942}
943
Alexey Bataev7ac9efb2020-02-05 09:33:05 -0500944void ASTStmtReader::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *E) {
945 VisitExpr(E);
946 unsigned NumDims = Record.readInt();
947 E->setBase(Record.readSubExpr());
948 SmallVector<Expr *, 4> Dims(NumDims);
949 for (unsigned I = 0; I < NumDims; ++I)
950 Dims[I] = Record.readSubExpr();
951 E->setDimensions(Dims);
952 SmallVector<SourceRange, 4> SRs(NumDims);
953 for (unsigned I = 0; I < NumDims; ++I)
954 SRs[I] = readSourceRange();
955 E->setBracketsRanges(SRs);
956 E->setLParenLoc(readSourceLocation());
957 E->setRParenLoc(readSourceLocation());
958}
959
Alexey Bataev13a15042020-04-01 15:06:38 -0400960void ASTStmtReader::VisitOMPIteratorExpr(OMPIteratorExpr *E) {
961 VisitExpr(E);
962 unsigned NumIters = Record.readInt();
963 E->setIteratorKwLoc(readSourceLocation());
964 E->setLParenLoc(readSourceLocation());
965 E->setRParenLoc(readSourceLocation());
966 for (unsigned I = 0; I < NumIters; ++I) {
967 E->setIteratorDeclaration(I, Record.readDeclRef());
968 E->setAssignmentLoc(I, readSourceLocation());
969 Expr *Begin = Record.readSubExpr();
970 Expr *End = Record.readSubExpr();
971 Expr *Step = Record.readSubExpr();
972 SourceLocation ColonLoc = readSourceLocation();
973 SourceLocation SecColonLoc;
974 if (Step)
975 SecColonLoc = readSourceLocation();
976 E->setIteratorRange(I, Begin, ColonLoc, End, SecColonLoc, Step);
Alexey Bataevbe99c612020-04-06 11:21:43 -0400977 // Deserialize helpers
978 OMPIteratorHelperData HD;
979 HD.CounterVD = cast_or_null<VarDecl>(Record.readDeclRef());
980 HD.Upper = Record.readSubExpr();
981 HD.Update = Record.readSubExpr();
982 HD.CounterUpdate = Record.readSubExpr();
983 E->setHelper(I, HD);
Alexey Bataev13a15042020-04-01 15:06:38 -0400984 }
985}
986
Sebastian Redl70c751d2010-08-18 23:56:52 +0000987void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000988 VisitExpr(E);
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000989 unsigned NumArgs = Record.readInt();
990 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
John McCall3ce3d232019-12-13 03:37:23 -0500991 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000992 E->setCallee(Record.readSubExpr());
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000993 for (unsigned I = 0; I != NumArgs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000994 E->setArg(I, Record.readSubExpr());
Eric Fiselier5cdc2cd2018-12-12 21:50:55 +0000995 E->setADLCallKind(static_cast<CallExpr::ADLCallKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000996}
997
John McCallfa194042011-07-15 07:00:14 +0000998void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
999 VisitCallExpr(E);
1000}
1001
Sebastian Redl70c751d2010-08-18 23:56:52 +00001002void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Richard Smithdcf17de2019-06-06 23:24:15 +00001003 VisitExpr(E);
1004
1005 bool HasQualifier = Record.readInt();
1006 bool HasFoundDecl = Record.readInt();
1007 bool HasTemplateInfo = Record.readInt();
1008 unsigned NumTemplateArgs = Record.readInt();
1009
1010 E->Base = Record.readSubExpr();
1011 E->MemberDecl = Record.readDeclAs<ValueDecl>();
John McCall3ce3d232019-12-13 03:37:23 -05001012 E->MemberDNLoc = Record.readDeclarationNameLoc(E->MemberDecl->getDeclName());
Richard Smithdcf17de2019-06-06 23:24:15 +00001013 E->MemberLoc = Record.readSourceLocation();
1014 E->MemberExprBits.IsArrow = Record.readInt();
1015 E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
1016 E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
1017 E->MemberExprBits.HadMultipleCandidates = Record.readInt();
Richard Smith1bbad592019-06-11 17:50:36 +00001018 E->MemberExprBits.NonOdrUseReason = Record.readInt();
Richard Smithdcf17de2019-06-06 23:24:15 +00001019 E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
1020
1021 if (HasQualifier || HasFoundDecl) {
1022 DeclAccessPair FoundDecl;
1023 if (HasFoundDecl) {
1024 auto *FoundD = Record.readDeclAs<NamedDecl>();
1025 auto AS = (AccessSpecifier)Record.readInt();
1026 FoundDecl = DeclAccessPair::make(FoundD, AS);
1027 } else {
1028 FoundDecl = DeclAccessPair::make(E->MemberDecl,
1029 E->MemberDecl->getAccess());
1030 }
1031 E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
1032
1033 NestedNameSpecifierLoc QualifierLoc;
1034 if (HasQualifier)
1035 QualifierLoc = Record.readNestedNameSpecifierLoc();
1036 E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
1037 QualifierLoc;
1038 }
1039
1040 if (HasTemplateInfo)
1041 ReadTemplateKWAndArgsInfo(
1042 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1043 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001044}
1045
Sebastian Redl70c751d2010-08-18 23:56:52 +00001046void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Naroffe87026a2009-07-24 17:54:45 +00001047 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001048 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001049 E->setIsaMemberLoc(readSourceLocation());
1050 E->setOpLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001051 E->setArrow(Record.readInt());
Steve Naroffe87026a2009-07-24 17:54:45 +00001052}
1053
John McCall31168b02011-06-15 23:02:42 +00001054void ASTStmtReader::
1055VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
1056 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001057 E->Operand = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001058 E->setShouldCopy(Record.readInt());
John McCall31168b02011-06-15 23:02:42 +00001059}
1060
1061void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
1062 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001063 E->LParenLoc = readSourceLocation();
1064 E->BridgeKeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001065 E->Kind = Record.readInt();
John McCall31168b02011-06-15 23:02:42 +00001066}
1067
Sebastian Redl70c751d2010-08-18 23:56:52 +00001068void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001069 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001070 unsigned NumBaseSpecs = Record.readInt();
John McCallcf142162010-08-07 06:22:56 +00001071 assert(NumBaseSpecs == E->path_size());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001072 E->setSubExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001073 E->setCastKind((CastKind)Record.readInt());
John McCallcf142162010-08-07 06:22:56 +00001074 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +00001075 while (NumBaseSpecs--) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001076 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
David L. Jonesb6a8f022016-12-21 04:34:52 +00001077 *BaseSpec = Record.readCXXBaseSpecifier();
John McCallcf142162010-08-07 06:22:56 +00001078 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +00001079 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001080}
1081
Sebastian Redl70c751d2010-08-18 23:56:52 +00001082void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Melanie Blower2ba4e3a2020-04-10 13:34:46 -07001083 bool hasFP_Features;
1084 BinaryOperator::Opcode opc;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001085 VisitExpr(E);
Melanie Blower2ba4e3a2020-04-10 13:34:46 -07001086 E->setHasStoredFPFeatures(hasFP_Features = Record.readInt());
1087 E->setOpcode(opc = (BinaryOperator::Opcode)Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001088 E->setLHS(Record.readSubExpr());
1089 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001090 E->setOperatorLoc(readSourceLocation());
Melanie Blower2ba4e3a2020-04-10 13:34:46 -07001091 if (hasFP_Features)
Melanie Blowerdefd43a2020-06-26 08:45:12 -07001092 E->setStoredFPFeatures(FPOptions(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001093}
1094
Sebastian Redl70c751d2010-08-18 23:56:52 +00001095void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001096 VisitBinaryOperator(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001097 E->setComputationLHSType(Record.readType());
1098 E->setComputationResultType(Record.readType());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001099}
1100
Sebastian Redl70c751d2010-08-18 23:56:52 +00001101void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001102 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001103 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
1104 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
1105 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001106 E->QuestionLoc = readSourceLocation();
1107 E->ColonLoc = readSourceLocation();
John McCallc07a0c72011-02-17 10:25:35 +00001108}
1109
1110void
1111ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
1112 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001113 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
1114 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
1115 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
1116 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
1117 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001118 E->QuestionLoc = readSourceLocation();
1119 E->ColonLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001120}
1121
Sebastian Redl70c751d2010-08-18 23:56:52 +00001122void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001123 VisitCastExpr(E);
Roman Lebedev12216f12018-07-27 07:27:14 +00001124 E->setIsPartOfExplicitCast(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001125}
1126
Sebastian Redl70c751d2010-08-18 23:56:52 +00001127void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001128 VisitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001129 E->setTypeInfoAsWritten(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001130}
1131
Sebastian Redl70c751d2010-08-18 23:56:52 +00001132void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001133 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001134 E->setLParenLoc(readSourceLocation());
1135 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001136}
1137
Sebastian Redl70c751d2010-08-18 23:56:52 +00001138void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001139 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001140 E->setLParenLoc(readSourceLocation());
1141 E->setTypeSourceInfo(readTypeSourceInfo());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001142 E->setInitializer(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001143 E->setFileScope(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001144}
1145
Sebastian Redl70c751d2010-08-18 23:56:52 +00001146void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001147 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001148 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001149 E->setAccessor(Record.readIdentifier());
1150 E->setAccessorLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001151}
1152
Sebastian Redl70c751d2010-08-18 23:56:52 +00001153void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001154 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001155 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
Abramo Bagnara8d16bd42012-11-08 18:41:43 +00001156 E->setSyntacticForm(SyntForm);
John McCall3ce3d232019-12-13 03:37:23 -05001157 E->setLBraceLoc(readSourceLocation());
1158 E->setRBraceLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001159 bool isArrayFiller = Record.readInt();
Craig Toppera13603a2014-05-22 05:54:18 +00001160 Expr *filler = nullptr;
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001161 if (isArrayFiller) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001162 filler = Record.readSubExpr();
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001163 E->ArrayFillerOrUnionFieldInit = filler;
1164 } else
John McCall3ce3d232019-12-13 03:37:23 -05001165 E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001166 E->sawArrayRangeDesignator(Record.readInt());
1167 unsigned NumInits = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001168 E->reserveInits(Record.getContext(), NumInits);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001169 if (isArrayFiller) {
1170 for (unsigned I = 0; I != NumInits; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001171 Expr *init = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001172 E->updateInit(Record.getContext(), I, init ? init : filler);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001173 }
1174 } else {
1175 for (unsigned I = 0; I != NumInits; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001176 E->updateInit(Record.getContext(), I, Record.readSubExpr());
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001177 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001178}
1179
Sebastian Redl70c751d2010-08-18 23:56:52 +00001180void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001181 using Designator = DesignatedInitExpr::Designator;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001182
1183 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001184 unsigned NumSubExprs = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001185 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
1186 for (unsigned I = 0; I != NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001187 E->setSubExpr(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001188 E->setEqualOrColonLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001189 E->setGNUSyntax(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001190
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001191 SmallVector<Designator, 4> Designators;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001192 while (Record.getIdx() < Record.size()) {
1193 switch ((DesignatorTypes)Record.readInt()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00001194 case DESIG_FIELD_DECL: {
John McCall3ce3d232019-12-13 03:37:23 -05001195 auto *Field = readDeclAs<FieldDecl>();
1196 SourceLocation DotLoc = readSourceLocation();
1197 SourceLocation FieldLoc = readSourceLocation();
Mike Stump11289f42009-09-09 15:08:12 +00001198 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001199 FieldLoc));
1200 Designators.back().setField(Field);
1201 break;
1202 }
1203
Sebastian Redl539c5062010-08-18 23:57:32 +00001204 case DESIG_FIELD_NAME: {
John McCall3ce3d232019-12-13 03:37:23 -05001205 const IdentifierInfo *Name = Record.readIdentifier();
1206 SourceLocation DotLoc = readSourceLocation();
1207 SourceLocation FieldLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001208 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
1209 break;
1210 }
Mike Stump11289f42009-09-09 15:08:12 +00001211
Sebastian Redl539c5062010-08-18 23:57:32 +00001212 case DESIG_ARRAY: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001213 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001214 SourceLocation LBracketLoc = readSourceLocation();
1215 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001216 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
1217 break;
1218 }
1219
Sebastian Redl539c5062010-08-18 23:57:32 +00001220 case DESIG_ARRAY_RANGE: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001221 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001222 SourceLocation LBracketLoc = readSourceLocation();
1223 SourceLocation EllipsisLoc = readSourceLocation();
1224 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001225 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
1226 RBracketLoc));
1227 break;
1228 }
1229 }
1230 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001231 E->setDesignators(Record.getContext(),
Douglas Gregor03e8bdc2010-01-06 23:17:19 +00001232 Designators.data(), Designators.size());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001233}
1234
Yunzhong Gaocb779302015-06-10 00:27:52 +00001235void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1236 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001237 E->setBase(Record.readSubExpr());
1238 E->setUpdater(Record.readSubExpr());
Yunzhong Gaocb779302015-06-10 00:27:52 +00001239}
1240
1241void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1242 VisitExpr(E);
1243}
1244
Richard Smith410306b2016-12-12 02:53:20 +00001245void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1246 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001247 E->SubExprs[0] = Record.readSubExpr();
1248 E->SubExprs[1] = Record.readSubExpr();
Richard Smith410306b2016-12-12 02:53:20 +00001249}
1250
1251void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1252 VisitExpr(E);
1253}
1254
Sebastian Redl70c751d2010-08-18 23:56:52 +00001255void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001256 VisitExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001257}
1258
Sebastian Redl70c751d2010-08-18 23:56:52 +00001259void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001260 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001261 E->setSubExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001262 E->setWrittenTypeInfo(readTypeSourceInfo());
1263 E->setBuiltinLoc(readSourceLocation());
1264 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001265 E->setIsMicrosoftABI(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001266}
1267
Eric Fiselier708afb52019-05-16 21:04:15 +00001268void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1269 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001270 E->ParentContext = readDeclAs<DeclContext>();
1271 E->BuiltinLoc = readSourceLocation();
1272 E->RParenLoc = readSourceLocation();
Eric Fiselier708afb52019-05-16 21:04:15 +00001273 E->SourceLocExprBits.Kind =
1274 static_cast<SourceLocExpr::IdentKind>(Record.readInt());
1275}
1276
Sebastian Redl70c751d2010-08-18 23:56:52 +00001277void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001278 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001279 E->setAmpAmpLoc(readSourceLocation());
1280 E->setLabelLoc(readSourceLocation());
1281 E->setLabel(readDeclAs<LabelDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001282}
1283
Sebastian Redl70c751d2010-08-18 23:56:52 +00001284void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001285 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001286 E->setLParenLoc(readSourceLocation());
1287 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001288 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
Richard Smith5c845c12020-03-09 17:34:33 -07001289 E->StmtExprBits.TemplateDepth = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001290}
1291
Sebastian Redl70c751d2010-08-18 23:56:52 +00001292void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001293 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001294 E->setCond(Record.readSubExpr());
1295 E->setLHS(Record.readSubExpr());
1296 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001297 E->setBuiltinLoc(readSourceLocation());
1298 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001299 E->setIsConditionTrue(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001300}
1301
Sebastian Redl70c751d2010-08-18 23:56:52 +00001302void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001303 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001304 E->setTokenLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001305}
1306
Sebastian Redl70c751d2010-08-18 23:56:52 +00001307void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001308 VisitExpr(E);
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001309 SmallVector<Expr *, 16> Exprs;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001310 unsigned NumExprs = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001311 while (NumExprs--)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001312 Exprs.push_back(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001313 E->setExprs(Record.getContext(), Exprs);
John McCall3ce3d232019-12-13 03:37:23 -05001314 E->setBuiltinLoc(readSourceLocation());
1315 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001316}
1317
Hal Finkelc4d7c822013-09-18 03:29:45 +00001318void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1319 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001320 E->BuiltinLoc = readSourceLocation();
1321 E->RParenLoc = readSourceLocation();
1322 E->TInfo = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001323 E->SrcExpr = Record.readSubExpr();
Hal Finkelc4d7c822013-09-18 03:29:45 +00001324}
1325
Sebastian Redl70c751d2010-08-18 23:56:52 +00001326void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001327 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001328 E->setBlockDecl(readDeclAs<BlockDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001329}
1330
Peter Collingbourne91147592011-04-15 00:35:48 +00001331void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1332 VisitExpr(E);
Bruno Riccidb076832019-01-26 14:15:10 +00001333
1334 unsigned NumAssocs = Record.readInt();
1335 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
Bruno Ricci94498c72019-01-26 13:58:15 +00001336 E->ResultIndex = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001337 E->GenericSelectionExprBits.GenericLoc = readSourceLocation();
1338 E->DefaultLoc = readSourceLocation();
1339 E->RParenLoc = readSourceLocation();
Bruno Riccidb076832019-01-26 14:15:10 +00001340
1341 Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1342 // Add 1 to account for the controlling expression which is the first
1343 // expression in the trailing array of Stmt *. This is not needed for
1344 // the trailing array of TypeSourceInfo *.
1345 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1346 Stmts[I] = Record.readSubExpr();
1347
1348 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1349 for (unsigned I = 0, N = NumAssocs; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001350 TSIs[I] = readTypeSourceInfo();
Peter Collingbourne91147592011-04-15 00:35:48 +00001351}
1352
John McCallfe96e0b2011-11-06 09:01:30 +00001353void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1354 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001355 unsigned numSemanticExprs = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001356 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001357 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001358
1359 // Read the syntactic expression.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001360 E->getSubExprsBuffer()[0] = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001361
1362 // Read all the semantic expressions.
1363 for (unsigned i = 0; i != numSemanticExprs; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001364 Expr *subExpr = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001365 E->getSubExprsBuffer()[i+1] = subExpr;
1366 }
1367}
1368
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001369void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1370 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001371 E->Op = AtomicExpr::AtomicOp(Record.readInt());
Richard Smithaa22a8c2012-04-10 22:49:28 +00001372 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1373 for (unsigned I = 0; I != E->NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001374 E->SubExprs[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001375 E->BuiltinLoc = readSourceLocation();
1376 E->RParenLoc = readSourceLocation();
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001377}
1378
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001379//===----------------------------------------------------------------------===//
1380// Objective-C Expressions and Statements
1381
Sebastian Redl70c751d2010-08-18 23:56:52 +00001382void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001383 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001384 E->setString(cast<StringLiteral>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -05001385 E->setAtLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001386}
1387
Patrick Beard0caa3942012-04-19 00:25:12 +00001388void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001389 VisitExpr(E);
1390 // could be one of several IntegerLiteral, FloatLiteral, etc.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001391 E->SubExpr = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -05001392 E->BoxingMethod = readDeclAs<ObjCMethodDecl>();
1393 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001394}
1395
1396void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1397 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001398 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001399 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1400 Expr **Elements = E->getElements();
1401 for (unsigned I = 0, N = NumElements; I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001402 Elements[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001403 E->ArrayWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1404 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001405}
1406
1407void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1408 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001409 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001410 assert(NumElements == E->getNumElements() && "Wrong number of elements");
David L. Jonesbe1557a2016-12-21 00:17:49 +00001411 bool HasPackExpansions = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001412 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001413 auto *KeyValues =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001414 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001415 auto *Expansions =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001416 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001417 for (unsigned I = 0; I != NumElements; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001418 KeyValues[I].Key = Record.readSubExpr();
1419 KeyValues[I].Value = Record.readSubExpr();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001420 if (HasPackExpansions) {
John McCall3ce3d232019-12-13 03:37:23 -05001421 Expansions[I].EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001422 Expansions[I].NumExpansionsPlusOne = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001423 }
1424 }
John McCall3ce3d232019-12-13 03:37:23 -05001425 E->DictWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1426 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001427}
1428
Sebastian Redl70c751d2010-08-18 23:56:52 +00001429void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001430 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001431 E->setEncodedTypeSourceInfo(readTypeSourceInfo());
1432 E->setAtLoc(readSourceLocation());
1433 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001434}
1435
Sebastian Redl70c751d2010-08-18 23:56:52 +00001436void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001437 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001438 E->setSelector(Record.readSelector());
John McCall3ce3d232019-12-13 03:37:23 -05001439 E->setAtLoc(readSourceLocation());
1440 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001441}
1442
Sebastian Redl70c751d2010-08-18 23:56:52 +00001443void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001444 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001445 E->setProtocol(readDeclAs<ObjCProtocolDecl>());
1446 E->setAtLoc(readSourceLocation());
1447 E->ProtoLoc = readSourceLocation();
1448 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001449}
1450
Sebastian Redl70c751d2010-08-18 23:56:52 +00001451void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001452 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001453 E->setDecl(readDeclAs<ObjCIvarDecl>());
1454 E->setLocation(readSourceLocation());
1455 E->setOpLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001456 E->setBase(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001457 E->setIsArrow(Record.readInt());
1458 E->setIsFreeIvar(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001459}
1460
Sebastian Redl70c751d2010-08-18 23:56:52 +00001461void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001462 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001463 unsigned MethodRefFlags = Record.readInt();
1464 bool Implicit = Record.readInt() != 0;
John McCallb7bd14f2010-12-02 01:19:52 +00001465 if (Implicit) {
John McCall3ce3d232019-12-13 03:37:23 -05001466 auto *Getter = readDeclAs<ObjCMethodDecl>();
1467 auto *Setter = readDeclAs<ObjCMethodDecl>();
Argyrios Kyrtzidisab468b02012-03-30 00:19:18 +00001468 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCallb7bd14f2010-12-02 01:19:52 +00001469 } else {
John McCall3ce3d232019-12-13 03:37:23 -05001470 E->setExplicitProperty(readDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001471 }
John McCall3ce3d232019-12-13 03:37:23 -05001472 E->setLocation(readSourceLocation());
1473 E->setReceiverLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001474 switch (Record.readInt()) {
John McCallb7bd14f2010-12-02 01:19:52 +00001475 case 0:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001476 E->setBase(Record.readSubExpr());
John McCallb7bd14f2010-12-02 01:19:52 +00001477 break;
1478 case 1:
David L. Jonesbe1557a2016-12-21 00:17:49 +00001479 E->setSuperReceiver(Record.readType());
John McCallb7bd14f2010-12-02 01:19:52 +00001480 break;
1481 case 2:
John McCall3ce3d232019-12-13 03:37:23 -05001482 E->setClassReceiver(readDeclAs<ObjCInterfaceDecl>());
John McCallb7bd14f2010-12-02 01:19:52 +00001483 break;
1484 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001485}
1486
Ted Kremeneke65b0862012-03-06 20:05:56 +00001487void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1488 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001489 E->setRBracket(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001490 E->setBaseExpr(Record.readSubExpr());
1491 E->setKeyExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001492 E->GetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1493 E->SetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001494}
1495
Sebastian Redl70c751d2010-08-18 23:56:52 +00001496void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001497 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001498 assert(Record.peekInt() == E->getNumArgs());
1499 Record.skipInts(1);
1500 unsigned NumStoredSelLocs = Record.readInt();
1501 E->SelLocsKind = Record.readInt();
1502 E->setDelegateInitCall(Record.readInt());
1503 E->IsImplicit = Record.readInt();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001504 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
Douglas Gregor9a129192010-04-21 00:45:42 +00001505 switch (Kind) {
1506 case ObjCMessageExpr::Instance:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001507 E->setInstanceReceiver(Record.readSubExpr());
Douglas Gregor9a129192010-04-21 00:45:42 +00001508 break;
1509
1510 case ObjCMessageExpr::Class:
John McCall3ce3d232019-12-13 03:37:23 -05001511 E->setClassReceiver(readTypeSourceInfo());
Douglas Gregor9a129192010-04-21 00:45:42 +00001512 break;
1513
1514 case ObjCMessageExpr::SuperClass:
1515 case ObjCMessageExpr::SuperInstance: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001516 QualType T = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001517 SourceLocation SuperLoc = readSourceLocation();
Douglas Gregor9a129192010-04-21 00:45:42 +00001518 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1519 break;
1520 }
1521 }
1522
1523 assert(Kind == E->getReceiverKind());
1524
David L. Jonesbe1557a2016-12-21 00:17:49 +00001525 if (Record.readInt())
John McCall3ce3d232019-12-13 03:37:23 -05001526 E->setMethodDecl(readDeclAs<ObjCMethodDecl>());
Douglas Gregor9a129192010-04-21 00:45:42 +00001527 else
David L. Jonesb6a8f022016-12-21 04:34:52 +00001528 E->setSelector(Record.readSelector());
Douglas Gregor9a129192010-04-21 00:45:42 +00001529
John McCall3ce3d232019-12-13 03:37:23 -05001530 E->LBracLoc = readSourceLocation();
1531 E->RBracLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001532
1533 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001534 E->setArg(I, Record.readSubExpr());
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00001535
1536 SourceLocation *Locs = E->getStoredSelLocs();
1537 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001538 Locs[I] = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001539}
1540
Sebastian Redl70c751d2010-08-18 23:56:52 +00001541void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001542 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001543 S->setElement(Record.readSubStmt());
1544 S->setCollection(Record.readSubExpr());
1545 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001546 S->setForLoc(readSourceLocation());
1547 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001548}
1549
Sebastian Redl70c751d2010-08-18 23:56:52 +00001550void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001551 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001552 S->setCatchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001553 S->setCatchParamDecl(readDeclAs<VarDecl>());
1554 S->setAtCatchLoc(readSourceLocation());
1555 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001556}
1557
Sebastian Redl70c751d2010-08-18 23:56:52 +00001558void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001559 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001560 S->setFinallyBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001561 S->setAtFinallyLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001562}
1563
John McCall31168b02011-06-15 23:02:42 +00001564void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001565 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001566 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001567 S->setAtLoc(readSourceLocation());
John McCall31168b02011-06-15 23:02:42 +00001568}
1569
Sebastian Redl70c751d2010-08-18 23:56:52 +00001570void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001571 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001572 assert(Record.peekInt() == S->getNumCatchStmts());
1573 Record.skipInts(1);
1574 bool HasFinally = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001575 S->setTryBody(Record.readSubStmt());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001576 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001577 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
Douglas Gregor96c79492010-04-23 22:50:49 +00001578
Douglas Gregor96c79492010-04-23 22:50:49 +00001579 if (HasFinally)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001580 S->setFinallyStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001581 S->setAtTryLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001582}
1583
Sebastian Redl70c751d2010-08-18 23:56:52 +00001584void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001585 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001586 S->setSynchExpr(Record.readSubStmt());
1587 S->setSynchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001588 S->setAtSynchronizedLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001589}
1590
Sebastian Redl70c751d2010-08-18 23:56:52 +00001591void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001592 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001593 S->setThrowExpr(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001594 S->setThrowLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001595}
1596
Ted Kremeneke65b0862012-03-06 20:05:56 +00001597void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1598 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001599 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001600 E->setLocation(readSourceLocation());
Ted Kremeneke65b0862012-03-06 20:05:56 +00001601}
1602
Erik Pilkington29099de2016-07-16 00:35:23 +00001603void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1604 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001605 SourceRange R = Record.readSourceRange();
Erik Pilkington29099de2016-07-16 00:35:23 +00001606 E->AtLoc = R.getBegin();
1607 E->RParen = R.getEnd();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001608 E->VersionToCheck = Record.readVersionTuple();
Erik Pilkington29099de2016-07-16 00:35:23 +00001609}
1610
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001611//===----------------------------------------------------------------------===//
1612// C++ Expressions and Statements
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001613//===----------------------------------------------------------------------===//
1614
Sebastian Redl70c751d2010-08-18 23:56:52 +00001615void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001616 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001617 S->CatchLoc = readSourceLocation();
1618 S->ExceptionDecl = readDeclAs<VarDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001619 S->HandlerBlock = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001620}
1621
Sebastian Redl70c751d2010-08-18 23:56:52 +00001622void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001623 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001624 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1625 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -05001626 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001627 S->getStmts()[0] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001628 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001629 S->getStmts()[i + 1] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001630}
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001631
Richard Smith02e85f32011-04-14 22:09:26 +00001632void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1633 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001634 S->ForLoc = readSourceLocation();
1635 S->CoawaitLoc = readSourceLocation();
1636 S->ColonLoc = readSourceLocation();
1637 S->RParenLoc = readSourceLocation();
Richard Smith8baa5002018-09-28 18:44:09 +00001638 S->setInit(Record.readSubStmt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001639 S->setRangeStmt(Record.readSubStmt());
1640 S->setBeginStmt(Record.readSubStmt());
1641 S->setEndStmt(Record.readSubStmt());
1642 S->setCond(Record.readSubExpr());
1643 S->setInc(Record.readSubExpr());
1644 S->setLoopVarStmt(Record.readSubStmt());
1645 S->setBody(Record.readSubStmt());
Richard Smith02e85f32011-04-14 22:09:26 +00001646}
1647
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001648void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1649 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001650 S->KeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001651 S->IsIfExists = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001652 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001653 S->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001654 S->SubStmt = Record.readSubStmt();
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001655}
1656
Sebastian Redl70c751d2010-08-18 23:56:52 +00001657void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001658 VisitCallExpr(E);
Bruno Riccifeb19232018-12-21 16:51:57 +00001659 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
Melanie Blowerdefd43a2020-06-26 08:45:12 -07001660 E->CXXOperatorCallExprBits.FPFeatures = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001661 E->Range = Record.readSourceRange();
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001662}
1663
Richard Smith778dc0f2019-10-19 00:04:38 +00001664void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1665 CXXRewrittenBinaryOperator *E) {
1666 VisitExpr(E);
1667 E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1668 E->SemanticForm = Record.readSubExpr();
1669}
1670
Sebastian Redl70c751d2010-08-18 23:56:52 +00001671void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001672 VisitExpr(E);
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001673
1674 unsigned NumArgs = Record.readInt();
1675 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1676
1677 E->CXXConstructExprBits.Elidable = Record.readInt();
1678 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1679 E->CXXConstructExprBits.ListInitialization = Record.readInt();
1680 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1681 E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1682 E->CXXConstructExprBits.ConstructionKind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001683 E->CXXConstructExprBits.Loc = readSourceLocation();
1684 E->Constructor = readDeclAs<CXXConstructorDecl>();
1685 E->ParenOrBraceRange = readSourceRange();
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001686
1687 for (unsigned I = 0; I != NumArgs; ++I)
1688 E->setArg(I, Record.readSubExpr());
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001689}
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001690
Richard Smith5179eb72016-06-28 19:03:57 +00001691void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1692 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001693 E->Constructor = readDeclAs<CXXConstructorDecl>();
1694 E->Loc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001695 E->ConstructsVirtualBase = Record.readInt();
1696 E->InheritedFromVirtualBase = Record.readInt();
Richard Smith5179eb72016-06-28 19:03:57 +00001697}
1698
Sebastian Redl70c751d2010-08-18 23:56:52 +00001699void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001700 VisitCXXConstructExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001701 E->TSI = readTypeSourceInfo();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001702}
1703
Douglas Gregore31e6062012-02-07 10:09:13 +00001704void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1705 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001706 unsigned NumCaptures = Record.readInt();
Bruno Riccic669a1e2020-06-13 14:17:03 +01001707 (void)NumCaptures;
1708 assert(NumCaptures == E->LambdaExprBits.NumCaptures);
John McCall3ce3d232019-12-13 03:37:23 -05001709 E->IntroducerRange = readSourceRange();
Bruno Riccic669a1e2020-06-13 14:17:03 +01001710 E->LambdaExprBits.CaptureDefault = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001711 E->CaptureDefaultLoc = readSourceLocation();
Bruno Riccic669a1e2020-06-13 14:17:03 +01001712 E->LambdaExprBits.ExplicitParams = Record.readInt();
1713 E->LambdaExprBits.ExplicitResultType = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001714 E->ClosingBrace = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001715
Douglas Gregor99ae8062012-02-14 17:54:36 +00001716 // Read capture initializers.
1717 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1718 CEnd = E->capture_init_end();
1719 C != CEnd; ++C)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001720 *C = Record.readSubExpr();
Bruno Ricci05843dc2020-06-18 12:51:11 +01001721
1722 // Ok, not one past the end.
1723 E->getStoredStmts()[NumCaptures] = Record.readSubStmt();
Douglas Gregore31e6062012-02-07 10:09:13 +00001724}
1725
Richard Smithcc1b96d2013-06-12 22:31:48 +00001726void
1727ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1728 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001729 E->SubExpr = Record.readSubExpr();
Richard Smithcc1b96d2013-06-12 22:31:48 +00001730}
1731
Sebastian Redl70c751d2010-08-18 23:56:52 +00001732void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001733 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001734 SourceRange R = readSourceRange();
Douglas Gregor4478f852011-01-12 22:41:29 +00001735 E->Loc = R.getBegin();
1736 E->RParenLoc = R.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05001737 R = readSourceRange();
Fariborz Jahanianf0738712013-02-22 22:02:53 +00001738 E->AngleBrackets = R;
Sam Weinigd01101e2010-01-16 21:21:01 +00001739}
1740
Sebastian Redl70c751d2010-08-18 23:56:52 +00001741void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001742 return VisitCXXNamedCastExpr(E);
1743}
1744
Sebastian Redl70c751d2010-08-18 23:56:52 +00001745void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001746 return VisitCXXNamedCastExpr(E);
1747}
1748
Sebastian Redl70c751d2010-08-18 23:56:52 +00001749void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001750 return VisitCXXNamedCastExpr(E);
1751}
1752
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01001753void ASTStmtReader::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *E) {
1754 return VisitCXXNamedCastExpr(E);
1755}
1756
Sebastian Redl70c751d2010-08-18 23:56:52 +00001757void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001758 return VisitCXXNamedCastExpr(E);
1759}
1760
Sebastian Redl70c751d2010-08-18 23:56:52 +00001761void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001762 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001763 E->setLParenLoc(readSourceLocation());
1764 E->setRParenLoc(readSourceLocation());
Sam Weinigd01101e2010-01-16 21:21:01 +00001765}
1766
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001767void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1768 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001769 E->KWLoc = readSourceLocation();
1770 E->RParenLoc = readSourceLocation();
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001771}
1772
Richard Smithc67fdd42012-03-07 08:35:16 +00001773void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1774 VisitCallExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001775 E->UDSuffixLoc = readSourceLocation();
Richard Smithc67fdd42012-03-07 08:35:16 +00001776}
1777
Sebastian Redl70c751d2010-08-18 23:56:52 +00001778void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001779 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001780 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001781 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001782}
1783
Sebastian Redl70c751d2010-08-18 23:56:52 +00001784void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001785 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001786 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001787}
1788
Sebastian Redl70c751d2010-08-18 23:56:52 +00001789void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001790 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001791 E->setSourceRange(readSourceRange());
Richard Smith5d3f7172020-04-14 19:26:31 -07001792 if (E->isTypeOperand())
1793 E->Operand = readTypeSourceInfo();
1794 else
1795 E->Operand = Record.readSubExpr();
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001796}
1797
Sebastian Redl70c751d2010-08-18 23:56:52 +00001798void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001799 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001800 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001801 E->setImplicit(Record.readInt());
Chris Lattner98267332010-05-09 06:15:05 +00001802}
1803
Sebastian Redl70c751d2010-08-18 23:56:52 +00001804void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001805 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001806 E->CXXThrowExprBits.ThrowLoc = readSourceLocation();
Bruno Riccib7de97b2018-11-17 12:53:56 +00001807 E->Operand = Record.readSubExpr();
1808 E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
Chris Lattner98267332010-05-09 06:15:05 +00001809}
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001810
Sebastian Redl70c751d2010-08-18 23:56:52 +00001811void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattnere2437f42010-05-09 06:40:08 +00001812 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001813 E->Param = readDeclAs<ParmVarDecl>();
1814 E->UsedContext = readDeclAs<DeclContext>();
1815 E->CXXDefaultArgExprBits.Loc = readSourceLocation();
Chris Lattnercba86142010-05-10 00:25:06 +00001816}
1817
Richard Smith852c9db2013-04-20 22:23:05 +00001818void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1819 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001820 E->Field = readDeclAs<FieldDecl>();
1821 E->UsedContext = readDeclAs<DeclContext>();
1822 E->CXXDefaultInitExprBits.Loc = readSourceLocation();
Richard Smith852c9db2013-04-20 22:23:05 +00001823}
1824
Sebastian Redl70c751d2010-08-18 23:56:52 +00001825void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001826 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001827 E->setTemporary(Record.readCXXTemporary());
1828 E->setSubExpr(Record.readSubExpr());
Chris Lattnercba86142010-05-10 00:25:06 +00001829}
1830
Sebastian Redl70c751d2010-08-18 23:56:52 +00001831void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001832 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001833 E->TypeInfo = readTypeSourceInfo();
1834 E->CXXScalarValueInitExprBits.RParenLoc = readSourceLocation();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001835}
1836
Sebastian Redl70c751d2010-08-18 23:56:52 +00001837void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001838 VisitExpr(E);
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001839
1840 bool IsArray = Record.readInt();
1841 bool HasInit = Record.readInt();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001842 unsigned NumPlacementArgs = Record.readInt();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001843 bool IsParenTypeId = Record.readInt();
1844
1845 E->CXXNewExprBits.IsGlobalNew = Record.readInt();
1846 E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
1847 E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1848 E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
1849
1850 assert((IsArray == E->isArray()) && "Wrong IsArray!");
1851 assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
1852 assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
1853 "Wrong NumPlacementArgs!");
1854 assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
1855 (void)IsArray;
1856 (void)HasInit;
1857 (void)NumPlacementArgs;
1858
John McCall3ce3d232019-12-13 03:37:23 -05001859 E->setOperatorNew(readDeclAs<FunctionDecl>());
1860 E->setOperatorDelete(readDeclAs<FunctionDecl>());
1861 E->AllocatedTypeInfo = readTypeSourceInfo();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001862 if (IsParenTypeId)
John McCall3ce3d232019-12-13 03:37:23 -05001863 E->getTrailingObjects<SourceRange>()[0] = readSourceRange();
1864 E->Range = readSourceRange();
1865 E->DirectInitRange = readSourceRange();
Chandler Carruth01718152010-10-25 08:47:36 +00001866
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001867 // Install all the subexpressions.
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001868 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
1869 N = E->raw_arg_end();
1870 I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001871 *I = Record.readSubStmt();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001872}
1873
Sebastian Redl70c751d2010-08-18 23:56:52 +00001874void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001875 VisitExpr(E);
Bruno Ricci91728fc2018-12-03 12:32:32 +00001876 E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
1877 E->CXXDeleteExprBits.ArrayForm = Record.readInt();
1878 E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
1879 E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001880 E->OperatorDelete = readDeclAs<FunctionDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001881 E->Argument = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001882 E->CXXDeleteExprBits.Loc = readSourceLocation();
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001883}
Chris Lattnercba86142010-05-10 00:25:06 +00001884
Sebastian Redl70c751d2010-08-18 23:56:52 +00001885void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001886 VisitExpr(E);
1887
David L. Jonesb6a8f022016-12-21 04:34:52 +00001888 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001889 E->IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001890 E->OperatorLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001891 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001892 E->ScopeType = readTypeSourceInfo();
1893 E->ColonColonLoc = readSourceLocation();
1894 E->TildeLoc = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001895
John McCall3ce3d232019-12-13 03:37:23 -05001896 IdentifierInfo *II = Record.readIdentifier();
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001897 if (II)
John McCall3ce3d232019-12-13 03:37:23 -05001898 E->setDestroyedType(II, readSourceLocation());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001899 else
John McCall3ce3d232019-12-13 03:37:23 -05001900 E->setDestroyedType(readTypeSourceInfo());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001901}
1902
John McCall5d413782010-12-06 08:20:24 +00001903void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001904 VisitExpr(E);
John McCall28fc7092011-11-10 05:35:25 +00001905
David L. Jonesbe1557a2016-12-21 00:17:49 +00001906 unsigned NumObjects = Record.readInt();
John McCall28fc7092011-11-10 05:35:25 +00001907 assert(NumObjects == E->getNumObjects());
Akira Hatanaka40568fe2020-03-10 14:06:25 -07001908 for (unsigned i = 0; i != NumObjects; ++i) {
1909 unsigned CleanupKind = Record.readInt();
1910 ExprWithCleanups::CleanupObject Obj;
1911 if (CleanupKind == COK_Block)
1912 Obj = readDeclAs<BlockDecl>();
1913 else if (CleanupKind == COK_CompoundLiteral)
1914 Obj = cast<CompoundLiteralExpr>(Record.readSubExpr());
1915 else
1916 llvm_unreachable("unexpected cleanup object type");
1917 E->getTrailingObjects<ExprWithCleanups::CleanupObject>()[i] = Obj;
1918 }
John McCall28fc7092011-11-10 05:35:25 +00001919
David L. Jonesbe1557a2016-12-21 00:17:49 +00001920 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001921 E->SubExpr = Record.readSubExpr();
Chris Lattnere2437f42010-05-09 06:40:08 +00001922}
1923
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001924void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1925 CXXDependentScopeMemberExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001926 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001927
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001928 bool HasTemplateKWAndArgsInfo = Record.readInt();
1929 unsigned NumTemplateArgs = Record.readInt();
1930 bool HasFirstQualifierFoundInScope = Record.readInt();
1931
1932 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
1933 "Wrong HasTemplateKWAndArgsInfo!");
1934 assert(
1935 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
1936 "Wrong HasFirstQualifierFoundInScope!");
1937
1938 if (HasTemplateKWAndArgsInfo)
James Y Knighte7d82282015-12-29 18:15:14 +00001939 ReadTemplateKWAndArgsInfo(
1940 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001941 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001942
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001943 assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
1944 "Wrong NumTemplateArgs!");
1945
1946 E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001947 E->CXXDependentScopeMemberExprBits.OperatorLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001948 E->BaseType = Record.readType();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001949 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001950 E->Base = Record.readSubExpr();
1951
1952 if (HasFirstQualifierFoundInScope)
John McCall3ce3d232019-12-13 03:37:23 -05001953 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001954
John McCall3ce3d232019-12-13 03:37:23 -05001955 E->MemberNameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001956}
1957
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001958void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001959ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001960 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001961
David L. Jonesbe1557a2016-12-21 00:17:49 +00001962 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001963 ReadTemplateKWAndArgsInfo(
1964 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1965 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001966 /*NumTemplateArgs=*/Record.readInt());
Douglas Gregor3a43fd62011-02-25 20:49:16 +00001967
David L. Jonesb6a8f022016-12-21 04:34:52 +00001968 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001969 E->NameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001970}
1971
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001972void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001973ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001974 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001975 assert(Record.peekInt() == E->arg_size() &&
1976 "Read wrong record during creation ?");
1977 Record.skipInts(1);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001978 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001979 E->setArg(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001980 E->TSI = readTypeSourceInfo();
1981 E->setLParenLoc(readSourceLocation());
1982 E->setRParenLoc(readSourceLocation());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001983}
1984
Sebastian Redl70c751d2010-08-18 23:56:52 +00001985void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001986 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001987
Bruno Riccid7628d92019-01-09 15:43:19 +00001988 unsigned NumResults = Record.readInt();
1989 bool HasTemplateKWAndArgsInfo = Record.readInt();
1990 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
1991 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
1992 "Wrong HasTemplateKWAndArgsInfo!");
1993
1994 if (HasTemplateKWAndArgsInfo) {
1995 unsigned NumTemplateArgs = Record.readInt();
James Y Knighte7d82282015-12-29 18:15:14 +00001996 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1997 E->getTrailingTemplateArgumentLoc(),
Bruno Riccid7628d92019-01-09 15:43:19 +00001998 NumTemplateArgs);
1999 assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
2000 "Wrong NumTemplateArgs!");
2001 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00002002
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00002003 UnresolvedSet<8> Decls;
Bruno Riccid7628d92019-01-09 15:43:19 +00002004 for (unsigned I = 0; I != NumResults; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -05002005 auto *D = readDeclAs<NamedDecl>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002006 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00002007 Decls.addDecl(D, AS);
2008 }
Bruno Riccid7628d92019-01-09 15:43:19 +00002009
2010 DeclAccessPair *Results = E->getTrailingResults();
2011 UnresolvedSetIterator Iter = Decls.begin();
2012 for (unsigned I = 0; I != NumResults; ++I) {
2013 Results[I] = (Iter + I).getPair();
2014 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00002015
John McCall3ce3d232019-12-13 03:37:23 -05002016 E->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002017 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00002018}
2019
Sebastian Redl70c751d2010-08-18 23:56:52 +00002020void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002021 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00002022 E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
2023 E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002024 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002025 E->BaseType = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05002026 E->OperatorLoc = readSourceLocation();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00002027}
2028
Sebastian Redl70c751d2010-08-18 23:56:52 +00002029void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002030 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00002031 E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
2032 E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002033 E->NamingClass = readDeclAs<CXXRecordDecl>();
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00002034}
2035
Douglas Gregor29c42f22012-02-24 07:38:34 +00002036void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
2037 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002038 E->TypeTraitExprBits.NumArgs = Record.readInt();
2039 E->TypeTraitExprBits.Kind = Record.readInt();
2040 E->TypeTraitExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002041 SourceRange Range = readSourceRange();
Jordan Rose99e80c12013-12-20 01:26:47 +00002042 E->Loc = Range.getBegin();
2043 E->RParenLoc = Range.getEnd();
2044
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002045 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
Douglas Gregor29c42f22012-02-24 07:38:34 +00002046 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05002047 Args[I] = readTypeSourceInfo();
Douglas Gregor29c42f22012-02-24 07:38:34 +00002048}
2049
John Wiegley6242b6a2011-04-28 00:16:57 +00002050void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
2051 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002052 E->ATT = (ArrayTypeTrait)Record.readInt();
2053 E->Value = (unsigned int)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002054 SourceRange Range = readSourceRange();
John Wiegley6242b6a2011-04-28 00:16:57 +00002055 E->Loc = Range.getBegin();
2056 E->RParen = Range.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05002057 E->QueriedType = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002058 E->Dimension = Record.readSubExpr();
John Wiegley6242b6a2011-04-28 00:16:57 +00002059}
2060
John Wiegleyf9f65842011-04-25 06:54:41 +00002061void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
2062 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002063 E->ET = (ExpressionTrait)Record.readInt();
2064 E->Value = (bool)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002065 SourceRange Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002066 E->QueriedExpression = Record.readSubExpr();
John Wiegleyf9f65842011-04-25 06:54:41 +00002067 E->Loc = Range.getBegin();
2068 E->RParen = Range.getEnd();
2069}
2070
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00002071void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
2072 VisitExpr(E);
Bruno Riccid56edfe2019-01-08 14:44:34 +00002073 E->CXXNoexceptExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002074 E->Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002075 E->Operand = Record.readSubExpr();
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00002076}
2077
Douglas Gregore8e9dd62011-01-03 17:17:50 +00002078void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
2079 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002080 E->EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002081 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002082 E->Pattern = Record.readSubExpr();
Douglas Gregore8e9dd62011-01-03 17:17:50 +00002083}
2084
Douglas Gregor820ba7b2011-01-04 17:33:58 +00002085void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2086 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002087 unsigned NumPartialArgs = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002088 E->OperatorLoc = readSourceLocation();
2089 E->PackLoc = readSourceLocation();
2090 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002091 E->Pack = Record.readDeclAs<NamedDecl>();
Richard Smithd784e682015-09-23 21:41:42 +00002092 if (E->isPartiallySubstituted()) {
2093 assert(E->Length == NumPartialArgs);
James Y Knighte00a67e2015-12-31 04:18:25 +00002094 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
Richard Smithd784e682015-09-23 21:41:42 +00002095 *E = I + NumPartialArgs;
2096 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002097 new (I) TemplateArgument(Record.readTemplateArgument());
Richard Smithd784e682015-09-23 21:41:42 +00002098 } else if (!E->isValueDependent()) {
David L. Jonesbe1557a2016-12-21 00:17:49 +00002099 E->Length = Record.readInt();
Richard Smithd784e682015-09-23 21:41:42 +00002100 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00002101}
2102
John McCallfa194042011-07-15 07:00:14 +00002103void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
2104 SubstNonTypeTemplateParmExpr *E) {
2105 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002106 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
2107 E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002108 E->Replacement = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002109}
2110
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002111void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
2112 SubstNonTypeTemplateParmPackExpr *E) {
2113 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002114 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002115 TemplateArgument ArgPack = Record.readTemplateArgument();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002116 if (ArgPack.getKind() != TemplateArgument::Pack)
2117 return;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002118
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002119 E->Arguments = ArgPack.pack_begin();
2120 E->NumArguments = ArgPack.pack_size();
John McCall3ce3d232019-12-13 03:37:23 -05002121 E->NameLoc = readSourceLocation();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002122}
2123
Richard Smithb15fe3a2012-09-12 00:56:43 +00002124void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2125 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002126 E->NumParameters = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002127 E->ParamPack = readDeclAs<ParmVarDecl>();
2128 E->NameLoc = readSourceLocation();
Richard Smithb2997f52019-05-21 20:10:50 +00002129 auto **Parms = E->getTrailingObjects<VarDecl *>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00002130 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
John McCall3ce3d232019-12-13 03:37:23 -05002131 Parms[i] = readDeclAs<VarDecl>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00002132}
2133
Douglas Gregorfe314812011-06-21 17:03:29 +00002134void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
2135 VisitExpr(E);
Tykerb0561b32019-11-17 11:41:55 +01002136 bool HasMaterialzedDecl = Record.readInt();
2137 if (HasMaterialzedDecl)
2138 E->State = cast<LifetimeExtendedTemporaryDecl>(Record.readDecl());
2139 else
2140 E->State = Record.readSubExpr();
Douglas Gregorfe314812011-06-21 17:03:29 +00002141}
2142
Richard Smith0f0af192014-11-08 05:07:16 +00002143void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
2144 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002145 E->LParenLoc = readSourceLocation();
2146 E->EllipsisLoc = readSourceLocation();
2147 E->RParenLoc = readSourceLocation();
Richard Smithc7214f62019-05-13 08:31:14 +00002148 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002149 E->SubExprs[0] = Record.readSubExpr();
2150 E->SubExprs[1] = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002151 E->Opcode = (BinaryOperatorKind)Record.readInt();
Richard Smith0f0af192014-11-08 05:07:16 +00002152}
2153
John McCall8d69a212010-11-15 23:31:06 +00002154void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
2155 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002156 E->SourceExpr = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05002157 E->OpaqueValueExprBits.Loc = readSourceLocation();
Akira Hatanaka797afe32018-03-20 01:47:58 +00002158 E->setIsUnique(Record.readInt());
John McCall8d69a212010-11-15 23:31:06 +00002159}
2160
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00002161void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
2162 llvm_unreachable("Cannot read TypoExpr nodes");
2163}
2164
Haojian Wu733edf92020-03-19 16:30:40 +01002165void ASTStmtReader::VisitRecoveryExpr(RecoveryExpr *E) {
2166 VisitExpr(E);
2167 unsigned NumArgs = Record.readInt();
2168 E->BeginLoc = readSourceLocation();
2169 E->EndLoc = readSourceLocation();
2170 assert(
2171 (NumArgs == std::distance(E->children().begin(), E->children().end())) &&
2172 "Wrong NumArgs!");
2173 (void)NumArgs;
2174 for (Stmt *&Child : E->children())
2175 Child = Record.readSubStmt();
2176}
2177
Peter Collingbourne41f85462011-02-09 21:07:24 +00002178//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002179// Microsoft Expressions and Statements
2180//===----------------------------------------------------------------------===//
John McCall5e77d762013-04-16 07:28:30 +00002181void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
2182 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002183 E->IsArrow = (Record.readInt() != 0);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002184 E->BaseExpr = Record.readSubExpr();
2185 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05002186 E->MemberLoc = readSourceLocation();
2187 E->TheDecl = readDeclAs<MSPropertyDecl>();
John McCall5e77d762013-04-16 07:28:30 +00002188}
2189
Alexey Bataevf7630272015-11-25 12:01:00 +00002190void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
2191 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002192 E->setBase(Record.readSubExpr());
2193 E->setIdx(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05002194 E->setRBracketLoc(readSourceLocation());
Alexey Bataevf7630272015-11-25 12:01:00 +00002195}
2196
John McCallfa194042011-07-15 07:00:14 +00002197void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
2198 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002199 E->setSourceRange(readSourceRange());
Richard Smithbab6df82020-04-11 22:15:29 -07002200 E->Guid = readDeclAs<MSGuidDecl>();
Richard Smith5d3f7172020-04-14 19:26:31 -07002201 if (E->isTypeOperand())
2202 E->Operand = readTypeSourceInfo();
2203 else
2204 E->Operand = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002205}
2206
Nico Weber9b982072014-07-07 00:12:30 +00002207void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
2208 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002209 S->setLeaveLoc(readSourceLocation());
Nico Weber9b982072014-07-07 00:12:30 +00002210}
2211
John McCallfa194042011-07-15 07:00:14 +00002212void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
2213 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002214 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002215 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
2216 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002217}
2218
2219void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
2220 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002221 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002222 S->Block = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002223}
2224
2225void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
2226 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002227 S->IsCXXTry = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002228 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002229 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
2230 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002231}
2232
2233//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00002234// CUDA Expressions and Statements
2235//===----------------------------------------------------------------------===//
2236
2237void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2238 VisitCallExpr(E);
Richard Smithfd420792019-05-24 23:26:07 +00002239 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
Peter Collingbourne41f85462011-02-09 21:07:24 +00002240}
2241
John McCallfa194042011-07-15 07:00:14 +00002242//===----------------------------------------------------------------------===//
2243// OpenCL Expressions and Statements.
2244//===----------------------------------------------------------------------===//
2245void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2246 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002247 E->BuiltinLoc = readSourceLocation();
2248 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002249 E->SrcExpr = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002250}
2251
2252//===----------------------------------------------------------------------===//
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002253// OpenMP Directives.
2254//===----------------------------------------------------------------------===//
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002255
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002256void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
John McCall3ce3d232019-12-13 03:37:23 -05002257 E->setLocStart(readSourceLocation());
2258 E->setLocEnd(readSourceLocation());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002259 SmallVector<OMPClause *, 5> Clauses;
2260 for (unsigned i = 0; i < E->getNumClauses(); ++i)
John McCallc2f18312019-12-14 03:01:28 -05002261 Clauses.push_back(Record.readOMPClause());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002262 E->setClauses(Clauses);
Alexey Bataev68446b72014-07-18 07:47:19 +00002263 if (E->hasAssociatedStmt())
David L. Jonesb6a8f022016-12-21 04:34:52 +00002264 E->setAssociatedStmt(Record.readSubStmt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002265}
2266
Alexander Musman3aaab662014-08-19 11:27:13 +00002267void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2268 VisitStmt(D);
2269 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002270 Record.skipInts(2);
Alexander Musman3aaab662014-08-19 11:27:13 +00002271 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002272 D->setIterationVariable(Record.readSubExpr());
2273 D->setLastIteration(Record.readSubExpr());
2274 D->setCalcLastIteration(Record.readSubExpr());
2275 D->setPreCond(Record.readSubExpr());
2276 D->setCond(Record.readSubExpr());
2277 D->setInit(Record.readSubExpr());
2278 D->setInc(Record.readSubExpr());
2279 D->setPreInits(Record.readSubStmt());
Alexey Bataev3392d762016-02-16 11:18:12 +00002280 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
Carlo Bertollifc35ad22016-03-07 16:04:49 +00002281 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2282 isOpenMPDistributeDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002283 D->setIsLastIterVariable(Record.readSubExpr());
2284 D->setLowerBoundVariable(Record.readSubExpr());
2285 D->setUpperBoundVariable(Record.readSubExpr());
2286 D->setStrideVariable(Record.readSubExpr());
2287 D->setEnsureUpperBound(Record.readSubExpr());
2288 D->setNextLowerBound(Record.readSubExpr());
2289 D->setNextUpperBound(Record.readSubExpr());
2290 D->setNumIterations(Record.readSubExpr());
Alexander Musmanc6388682014-12-15 07:07:06 +00002291 }
Carlo Bertolli9925f152016-06-27 14:55:37 +00002292 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002293 D->setPrevLowerBoundVariable(Record.readSubExpr());
2294 D->setPrevUpperBoundVariable(Record.readSubExpr());
Carlo Bertolli8429d812017-02-17 21:29:13 +00002295 D->setDistInc(Record.readSubExpr());
2296 D->setPrevEnsureUpperBound(Record.readSubExpr());
Carlo Bertolliffafe102017-04-20 00:39:39 +00002297 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2298 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2299 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2300 D->setCombinedInit(Record.readSubExpr());
2301 D->setCombinedCond(Record.readSubExpr());
2302 D->setCombinedNextLowerBound(Record.readSubExpr());
2303 D->setCombinedNextUpperBound(Record.readSubExpr());
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00002304 D->setCombinedDistCond(Record.readSubExpr());
2305 D->setCombinedParForInDistCond(Record.readSubExpr());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002306 }
Alexander Musmana5f070a2014-10-01 06:03:56 +00002307 SmallVector<Expr *, 4> Sub;
2308 unsigned CollapsedNum = D->getCollapsedNumber();
2309 Sub.reserve(CollapsedNum);
2310 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002311 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002312 D->setCounters(Sub);
2313 Sub.clear();
2314 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002315 Sub.push_back(Record.readSubExpr());
Alexey Bataeva8899172015-08-06 12:30:57 +00002316 D->setPrivateCounters(Sub);
2317 Sub.clear();
2318 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002319 Sub.push_back(Record.readSubExpr());
Alexey Bataevb08f89f2015-08-14 12:25:37 +00002320 D->setInits(Sub);
2321 Sub.clear();
2322 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002323 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002324 D->setUpdates(Sub);
2325 Sub.clear();
2326 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002327 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002328 D->setFinals(Sub);
Alexey Bataevf8be4762019-08-14 19:30:06 +00002329 Sub.clear();
2330 for (unsigned i = 0; i < CollapsedNum; ++i)
2331 Sub.push_back(Record.readSubExpr());
2332 D->setDependentCounters(Sub);
2333 Sub.clear();
2334 for (unsigned i = 0; i < CollapsedNum; ++i)
2335 Sub.push_back(Record.readSubExpr());
2336 D->setDependentInits(Sub);
2337 Sub.clear();
2338 for (unsigned i = 0; i < CollapsedNum; ++i)
2339 Sub.push_back(Record.readSubExpr());
2340 D->setFinalsConditions(Sub);
Alexander Musman3aaab662014-08-19 11:27:13 +00002341}
2342
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002343void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002344 VisitStmt(D);
2345 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002346 Record.skipInts(1);
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002347 VisitOMPExecutableDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002348 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002349 D->setHasCancel(Record.readInt());
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002350}
2351
2352void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002353 VisitOMPLoopDirective(D);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002354}
2355
Alexey Bataevf29276e2014-06-18 04:14:57 +00002356void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002357 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002358 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002359 D->setHasCancel(Record.readInt());
Alexey Bataevf29276e2014-06-18 04:14:57 +00002360}
2361
Alexander Musmanf82886e2014-09-18 05:12:34 +00002362void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2363 VisitOMPLoopDirective(D);
2364}
2365
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002366void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2367 VisitStmt(D);
2368 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002369 Record.skipInts(1);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002370 VisitOMPExecutableDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002371 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002372 D->setHasCancel(Record.readInt());
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002373}
2374
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002375void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2376 VisitStmt(D);
2377 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002378 D->setHasCancel(Record.readInt());
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002379}
2380
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002381void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2382 VisitStmt(D);
2383 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002384 Record.skipInts(1);
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002385 VisitOMPExecutableDirective(D);
2386}
2387
Alexander Musman80c22892014-07-17 08:54:58 +00002388void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2389 VisitStmt(D);
2390 VisitOMPExecutableDirective(D);
2391}
2392
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002393void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2394 VisitStmt(D);
Alexey Bataev28c75412015-12-15 08:19:24 +00002395 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002396 Record.skipInts(1);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002397 VisitOMPExecutableDirective(D);
John McCall3ce3d232019-12-13 03:37:23 -05002398 D->DirName = Record.readDeclarationNameInfo();
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002399}
2400
Alexey Bataev4acb8592014-07-07 13:01:15 +00002401void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002402 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002403 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002404 D->setHasCancel(Record.readInt());
Alexey Bataev4acb8592014-07-07 13:01:15 +00002405}
2406
Alexander Musmane4e893b2014-09-23 09:33:00 +00002407void ASTStmtReader::VisitOMPParallelForSimdDirective(
2408 OMPParallelForSimdDirective *D) {
2409 VisitOMPLoopDirective(D);
2410}
2411
cchen47d60942019-12-05 13:43:48 -05002412void ASTStmtReader::VisitOMPParallelMasterDirective(
2413 OMPParallelMasterDirective *D) {
2414 VisitStmt(D);
2415 // The NumClauses field was read in ReadStmtFromStream.
2416 Record.skipInts(1);
2417 VisitOMPExecutableDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002418 D->setTaskReductionRefExpr(Record.readSubExpr());
cchen47d60942019-12-05 13:43:48 -05002419}
2420
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002421void ASTStmtReader::VisitOMPParallelSectionsDirective(
2422 OMPParallelSectionsDirective *D) {
2423 VisitStmt(D);
2424 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002425 Record.skipInts(1);
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002426 VisitOMPExecutableDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002427 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002428 D->setHasCancel(Record.readInt());
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002429}
2430
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002431void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2432 VisitStmt(D);
2433 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002434 Record.skipInts(1);
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002435 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002436 D->setHasCancel(Record.readInt());
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002437}
2438
Alexey Bataev68446b72014-07-18 07:47:19 +00002439void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2440 VisitStmt(D);
2441 VisitOMPExecutableDirective(D);
2442}
2443
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002444void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2445 VisitStmt(D);
2446 VisitOMPExecutableDirective(D);
2447}
2448
Alexey Bataev2df347a2014-07-18 10:17:07 +00002449void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2450 VisitStmt(D);
2451 VisitOMPExecutableDirective(D);
2452}
2453
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002454void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2455 VisitStmt(D);
Alexey Bataev169d96a2017-07-18 20:17:46 +00002456 // The NumClauses field was read in ReadStmtFromStream.
2457 Record.skipInts(1);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002458 VisitOMPExecutableDirective(D);
Alexey Bataev3b1b8952017-07-25 15:53:26 +00002459 D->setReductionRef(Record.readSubExpr());
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002460}
2461
Alexey Bataev6125da92014-07-21 11:26:11 +00002462void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2463 VisitStmt(D);
2464 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002465 Record.skipInts(1);
Alexey Bataev6125da92014-07-21 11:26:11 +00002466 VisitOMPExecutableDirective(D);
2467}
2468
Alexey Bataevc112e942020-02-28 09:52:15 -05002469void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective *D) {
2470 VisitStmt(D);
2471 // The NumClauses field was read in ReadStmtFromStream.
2472 Record.skipInts(1);
2473 VisitOMPExecutableDirective(D);
2474}
2475
Alexey Bataevfcba7c32020-03-20 07:03:01 -04002476void ASTStmtReader::VisitOMPScanDirective(OMPScanDirective *D) {
2477 VisitStmt(D);
2478 // The NumClauses field was read in ReadStmtFromStream.
2479 Record.skipInts(1);
2480 VisitOMPExecutableDirective(D);
2481}
2482
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002483void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2484 VisitStmt(D);
Alexey Bataev346265e2015-09-25 10:37:12 +00002485 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002486 Record.skipInts(1);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002487 VisitOMPExecutableDirective(D);
2488}
2489
Alexey Bataev0162e452014-07-22 10:10:35 +00002490void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2491 VisitStmt(D);
2492 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002493 Record.skipInts(1);
Alexey Bataev0162e452014-07-22 10:10:35 +00002494 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002495 D->setX(Record.readSubExpr());
2496 D->setV(Record.readSubExpr());
2497 D->setExpr(Record.readSubExpr());
2498 D->setUpdateExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002499 D->IsXLHSInRHSPart = Record.readInt() != 0;
2500 D->IsPostfixUpdate = Record.readInt() != 0;
Alexey Bataev0162e452014-07-22 10:10:35 +00002501}
2502
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002503void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2504 VisitStmt(D);
2505 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002506 Record.skipInts(1);
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002507 VisitOMPExecutableDirective(D);
2508}
2509
Michael Wong65f367f2015-07-21 13:44:28 +00002510void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2511 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002512 Record.skipInts(1);
Michael Wong65f367f2015-07-21 13:44:28 +00002513 VisitOMPExecutableDirective(D);
2514}
2515
Samuel Antaodf67fc42016-01-19 19:15:56 +00002516void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2517 OMPTargetEnterDataDirective *D) {
2518 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002519 Record.skipInts(1);
Samuel Antaodf67fc42016-01-19 19:15:56 +00002520 VisitOMPExecutableDirective(D);
2521}
2522
Samuel Antao72590762016-01-19 20:04:50 +00002523void ASTStmtReader::VisitOMPTargetExitDataDirective(
2524 OMPTargetExitDataDirective *D) {
2525 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002526 Record.skipInts(1);
Samuel Antao72590762016-01-19 20:04:50 +00002527 VisitOMPExecutableDirective(D);
2528}
2529
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002530void ASTStmtReader::VisitOMPTargetParallelDirective(
2531 OMPTargetParallelDirective *D) {
2532 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002533 Record.skipInts(1);
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002534 VisitOMPExecutableDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002535 D->setTaskReductionRefExpr(Record.readSubExpr());
Alexey Bataevb737b812020-04-27 11:37:35 -04002536 D->setHasCancel(Record.readBool());
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002537}
2538
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002539void ASTStmtReader::VisitOMPTargetParallelForDirective(
2540 OMPTargetParallelForDirective *D) {
2541 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002542 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002543 D->setHasCancel(Record.readInt());
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002544}
2545
Alexey Bataev13314bf2014-10-09 04:18:56 +00002546void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2547 VisitStmt(D);
2548 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002549 Record.skipInts(1);
Alexey Bataev13314bf2014-10-09 04:18:56 +00002550 VisitOMPExecutableDirective(D);
2551}
2552
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002553void ASTStmtReader::VisitOMPCancellationPointDirective(
2554 OMPCancellationPointDirective *D) {
2555 VisitStmt(D);
2556 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002557 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002558}
2559
Alexey Bataev80909872015-07-02 11:25:17 +00002560void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2561 VisitStmt(D);
Alexey Bataev87933c72015-09-18 08:07:34 +00002562 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002563 Record.skipInts(1);
Alexey Bataev80909872015-07-02 11:25:17 +00002564 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002565 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev80909872015-07-02 11:25:17 +00002566}
2567
Alexey Bataev49f6e782015-12-01 04:18:41 +00002568void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2569 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002570 D->setHasCancel(Record.readInt());
Alexey Bataev49f6e782015-12-01 04:18:41 +00002571}
2572
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002573void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2574 VisitOMPLoopDirective(D);
2575}
2576
Alexey Bataev60e51c42019-10-10 20:13:02 +00002577void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2578 OMPMasterTaskLoopDirective *D) {
2579 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002580 D->setHasCancel(Record.readInt());
Alexey Bataev60e51c42019-10-10 20:13:02 +00002581}
2582
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002583void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2584 OMPMasterTaskLoopSimdDirective *D) {
2585 VisitOMPLoopDirective(D);
2586}
2587
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002588void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2589 OMPParallelMasterTaskLoopDirective *D) {
2590 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002591 D->setHasCancel(Record.readInt());
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002592}
2593
Alexey Bataev14a388f2019-10-25 10:27:13 -04002594void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2595 OMPParallelMasterTaskLoopSimdDirective *D) {
2596 VisitOMPLoopDirective(D);
2597}
2598
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002599void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2600 VisitOMPLoopDirective(D);
2601}
2602
Samuel Antao686c70c2016-05-26 17:30:50 +00002603void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2604 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002605 Record.skipInts(1);
Samuel Antao686c70c2016-05-26 17:30:50 +00002606 VisitOMPExecutableDirective(D);
2607}
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002608
Carlo Bertolli9925f152016-06-27 14:55:37 +00002609void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2610 OMPDistributeParallelForDirective *D) {
2611 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002612 D->setTaskReductionRefExpr(Record.readSubExpr());
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002613 D->setHasCancel(Record.readInt());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002614}
Samuel Antao686c70c2016-05-26 17:30:50 +00002615
Kelvin Li4a39add2016-07-05 05:00:15 +00002616void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2617 OMPDistributeParallelForSimdDirective *D) {
2618 VisitOMPLoopDirective(D);
2619}
2620
Kelvin Li787f3fc2016-07-06 04:45:38 +00002621void ASTStmtReader::VisitOMPDistributeSimdDirective(
2622 OMPDistributeSimdDirective *D) {
2623 VisitOMPLoopDirective(D);
2624}
2625
Kelvin Lia579b912016-07-14 02:54:56 +00002626void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2627 OMPTargetParallelForSimdDirective *D) {
2628 VisitOMPLoopDirective(D);
2629}
2630
Kelvin Li986330c2016-07-20 22:57:10 +00002631void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2632 VisitOMPLoopDirective(D);
2633}
2634
Kelvin Li02532872016-08-05 14:37:37 +00002635void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2636 OMPTeamsDistributeDirective *D) {
2637 VisitOMPLoopDirective(D);
2638}
2639
Kelvin Li4e325f72016-10-25 12:50:55 +00002640void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2641 OMPTeamsDistributeSimdDirective *D) {
2642 VisitOMPLoopDirective(D);
2643}
2644
Kelvin Li579e41c2016-11-30 23:51:03 +00002645void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2646 OMPTeamsDistributeParallelForSimdDirective *D) {
2647 VisitOMPLoopDirective(D);
2648}
2649
Kelvin Li7ade93f2016-12-09 03:24:30 +00002650void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2651 OMPTeamsDistributeParallelForDirective *D) {
2652 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002653 D->setTaskReductionRefExpr(Record.readSubExpr());
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002654 D->setHasCancel(Record.readInt());
Kelvin Li7ade93f2016-12-09 03:24:30 +00002655}
2656
Kelvin Libf594a52016-12-17 05:48:59 +00002657void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2658 VisitStmt(D);
2659 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002660 Record.skipInts(1);
Kelvin Libf594a52016-12-17 05:48:59 +00002661 VisitOMPExecutableDirective(D);
2662}
2663
Kelvin Li83c451e2016-12-25 04:52:54 +00002664void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2665 OMPTargetTeamsDistributeDirective *D) {
2666 VisitOMPLoopDirective(D);
2667}
2668
Kelvin Li80e8f562016-12-29 22:16:30 +00002669void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2670 OMPTargetTeamsDistributeParallelForDirective *D) {
2671 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002672 D->setTaskReductionRefExpr(Record.readSubExpr());
Alexey Bataev16e79882017-11-22 21:12:03 +00002673 D->setHasCancel(Record.readInt());
Kelvin Li80e8f562016-12-29 22:16:30 +00002674}
2675
Kelvin Li1851df52017-01-03 05:23:48 +00002676void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2677 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2678 VisitOMPLoopDirective(D);
2679}
2680
Kelvin Lida681182017-01-10 18:08:18 +00002681void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2682 OMPTargetTeamsDistributeSimdDirective *D) {
2683 VisitOMPLoopDirective(D);
2684}
2685
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002686//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002687// ASTReader Implementation
2688//===----------------------------------------------------------------------===//
2689
Douglas Gregorde3ef502011-11-30 23:21:26 +00002690Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002691 switch (ReadingKind) {
Richard Smith629ff362013-07-31 00:26:46 +00002692 case Read_None:
2693 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002694 case Read_Decl:
2695 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00002696 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002697 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002698 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002699 }
2700
2701 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002702}
2703
Douglas Gregorde3ef502011-11-30 23:21:26 +00002704Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00002705 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002706}
Chris Lattnere2437f42010-05-09 06:40:08 +00002707
Sebastian Redl2c499f62010-08-18 23:56:43 +00002708Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002709 return cast_or_null<Expr>(ReadSubStmt());
2710}
2711
Chris Lattnerf4262532009-04-27 05:41:06 +00002712// Within the bitstream, expressions are stored in Reverse Polish
2713// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002714// expression they are stored in. Subexpressions are stored from last to first.
2715// To evaluate expressions, we continue reading expressions and placing them on
2716// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00002717// stack. Evaluation terminates when we see a STMT_STOP record, and
2718// the single remaining expression on the stack is our result.
Douglas Gregorde3ef502011-11-30 23:21:26 +00002719Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002720 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00002721 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002722
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002723 // Map of offset to previously deserialized stmt. The offset points
George Burgess IV758cf9d2017-02-14 05:52:57 +00002724 // just after the stmt record.
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002725 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00002726
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002727#ifndef NDEBUG
2728 unsigned PrevNumStmts = StmtStack.size();
2729#endif
2730
David L. Jonesbe1557a2016-12-21 00:17:49 +00002731 ASTRecordReader Record(*this, F);
2732 ASTStmtReader Reader(Record, Cursor);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002733 Stmt::EmptyShell Empty;
2734
2735 while (true) {
JF Bastien0e828952019-06-26 19:50:12 +00002736 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2737 Cursor.advanceSkippingSubblocks();
2738 if (!MaybeEntry) {
2739 Error(toString(MaybeEntry.takeError()));
2740 return nullptr;
2741 }
2742 llvm::BitstreamEntry Entry = MaybeEntry.get();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002743
Chris Lattner0e6c9402013-01-20 02:38:54 +00002744 switch (Entry.Kind) {
2745 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2746 case llvm::BitstreamEntry::Error:
2747 Error("malformed block record in AST file");
Craig Toppera13603a2014-05-22 05:54:18 +00002748 return nullptr;
Chris Lattner0e6c9402013-01-20 02:38:54 +00002749 case llvm::BitstreamEntry::EndBlock:
2750 goto Done;
2751 case llvm::BitstreamEntry::Record:
2752 // The interesting case.
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002753 break;
2754 }
2755
Richard Smithdbafb6c2017-06-29 23:23:46 +00002756 ASTContext &Context = getContext();
Craig Toppera13603a2014-05-22 05:54:18 +00002757 Stmt *S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002758 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002759 bool IsStmtReference = false;
JF Bastien0e828952019-06-26 19:50:12 +00002760 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2761 if (!MaybeStmtCode) {
2762 Error(toString(MaybeStmtCode.takeError()));
2763 return nullptr;
2764 }
2765 switch ((StmtCode)MaybeStmtCode.get()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00002766 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002767 Finished = true;
2768 break;
2769
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002770 case STMT_REF_PTR:
2771 IsStmtReference = true;
2772 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2773 "No stmt was recorded for this offset reference!");
David L. Jonesbe1557a2016-12-21 00:17:49 +00002774 S = StmtEntries[Record.readInt()];
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002775 break;
2776
Sebastian Redl539c5062010-08-18 23:57:32 +00002777 case STMT_NULL_PTR:
Craig Toppera13603a2014-05-22 05:54:18 +00002778 S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002779 break;
2780
Sebastian Redl539c5062010-08-18 23:57:32 +00002781 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002782 S = new (Context) NullStmt(Empty);
2783 break;
2784
Sebastian Redl539c5062010-08-18 23:57:32 +00002785 case STMT_COMPOUND:
Benjamin Kramer07420902017-12-24 16:24:20 +00002786 S = CompoundStmt::CreateEmpty(
2787 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002788 break;
2789
Sebastian Redl539c5062010-08-18 23:57:32 +00002790 case STMT_CASE:
Bruno Ricci5b30571752018-10-28 12:30:53 +00002791 S = CaseStmt::CreateEmpty(
2792 Context,
2793 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002794 break;
2795
Sebastian Redl539c5062010-08-18 23:57:32 +00002796 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002797 S = new (Context) DefaultStmt(Empty);
2798 break;
2799
Sebastian Redl539c5062010-08-18 23:57:32 +00002800 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002801 S = new (Context) LabelStmt(Empty);
2802 break;
2803
Richard Smithc202b282012-04-14 00:33:13 +00002804 case STMT_ATTRIBUTED:
Alexander Kornienko20f6fc62012-07-09 10:04:07 +00002805 S = AttributedStmt::CreateEmpty(
2806 Context,
2807 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smithc202b282012-04-14 00:33:13 +00002808 break;
2809
Sebastian Redl539c5062010-08-18 23:57:32 +00002810 case STMT_IF:
Bruno Riccib1cc94b2018-10-27 21:12:20 +00002811 S = IfStmt::CreateEmpty(
2812 Context,
2813 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2814 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2815 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002816 break;
2817
Sebastian Redl539c5062010-08-18 23:57:32 +00002818 case STMT_SWITCH:
Bruno Riccie2806f82018-10-29 16:12:37 +00002819 S = SwitchStmt::CreateEmpty(
2820 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002821 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
Bruno Riccie2806f82018-10-29 16:12:37 +00002822 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002823 break;
2824
Sebastian Redl539c5062010-08-18 23:57:32 +00002825 case STMT_WHILE:
Bruno Riccibacf7512018-10-30 13:42:41 +00002826 S = WhileStmt::CreateEmpty(
2827 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002828 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002829 break;
2830
Sebastian Redl539c5062010-08-18 23:57:32 +00002831 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002832 S = new (Context) DoStmt(Empty);
2833 break;
Mike Stump11289f42009-09-09 15:08:12 +00002834
Sebastian Redl539c5062010-08-18 23:57:32 +00002835 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002836 S = new (Context) ForStmt(Empty);
2837 break;
2838
Sebastian Redl539c5062010-08-18 23:57:32 +00002839 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002840 S = new (Context) GotoStmt(Empty);
2841 break;
Mike Stump11289f42009-09-09 15:08:12 +00002842
Sebastian Redl539c5062010-08-18 23:57:32 +00002843 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002844 S = new (Context) IndirectGotoStmt(Empty);
2845 break;
2846
Sebastian Redl539c5062010-08-18 23:57:32 +00002847 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002848 S = new (Context) ContinueStmt(Empty);
2849 break;
2850
Sebastian Redl539c5062010-08-18 23:57:32 +00002851 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002852 S = new (Context) BreakStmt(Empty);
2853 break;
2854
Sebastian Redl539c5062010-08-18 23:57:32 +00002855 case STMT_RETURN:
Bruno Ricci023b1d12018-10-30 14:40:49 +00002856 S = ReturnStmt::CreateEmpty(
2857 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002858 break;
2859
Sebastian Redl539c5062010-08-18 23:57:32 +00002860 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002861 S = new (Context) DeclStmt(Empty);
2862 break;
2863
Chad Rosierde70e0e2012-08-25 00:11:56 +00002864 case STMT_GCCASM:
2865 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002866 break;
2867
Chad Rosiere30d4992012-08-24 23:51:02 +00002868 case STMT_MSASM:
2869 S = new (Context) MSAsmStmt(Empty);
2870 break;
2871
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002872 case STMT_CAPTURED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002873 S = CapturedStmt::CreateDeserialized(
2874 Context, Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002875 break;
2876
Bill Wendling7c44da22018-10-31 03:48:47 +00002877 case EXPR_CONSTANT:
Gauthier Harnisch83c7b612019-06-15 10:24:47 +00002878 S = ConstantExpr::CreateEmpty(
Bruno Riccie7ce0522020-06-21 13:02:48 +01002879 Context, static_cast<ConstantExpr::ResultStorageKind>(
2880 /*StorageKind=*/Record[ASTStmtReader::NumExprFields]));
Bill Wendling7c44da22018-10-31 03:48:47 +00002881 break;
2882
Sebastian Redl539c5062010-08-18 23:57:32 +00002883 case EXPR_PREDEFINED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002884 S = PredefinedExpr::CreateEmpty(
2885 Context,
2886 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002887 break;
Mike Stump11289f42009-09-09 15:08:12 +00002888
Sebastian Redl539c5062010-08-18 23:57:32 +00002889 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002890 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00002891 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002892 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2893 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnara7945c982012-01-27 09:46:47 +00002894 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002895 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Richard Smith715f7a12019-06-11 17:50:32 +00002896 Record[ASTStmtReader::NumExprFields + 6] : 0);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002897 break;
Mike Stump11289f42009-09-09 15:08:12 +00002898
Sebastian Redl539c5062010-08-18 23:57:32 +00002899 case EXPR_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002900 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002901 break;
Mike Stump11289f42009-09-09 15:08:12 +00002902
Vince Bridgers161fc1d2020-04-07 14:46:08 -05002903 case EXPR_FIXEDPOINT_LITERAL:
2904 S = FixedPointLiteral::Create(Context, Empty);
2905 break;
2906
Sebastian Redl539c5062010-08-18 23:57:32 +00002907 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002908 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002909 break;
Mike Stump11289f42009-09-09 15:08:12 +00002910
Sebastian Redl539c5062010-08-18 23:57:32 +00002911 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002912 S = new (Context) ImaginaryLiteral(Empty);
2913 break;
2914
Sebastian Redl539c5062010-08-18 23:57:32 +00002915 case EXPR_STRING_LITERAL:
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002916 S = StringLiteral::CreateEmpty(
2917 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002918 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002919 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2920 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002921 break;
2922
Sebastian Redl539c5062010-08-18 23:57:32 +00002923 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002924 S = new (Context) CharacterLiteral(Empty);
2925 break;
2926
Sebastian Redl539c5062010-08-18 23:57:32 +00002927 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002928 S = new (Context) ParenExpr(Empty);
2929 break;
2930
Sebastian Redl539c5062010-08-18 23:57:32 +00002931 case EXPR_PAREN_LIST:
Bruno Riccif49e1ca2018-11-20 16:20:40 +00002932 S = ParenListExpr::CreateEmpty(
2933 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002934 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00002935 break;
2936
Sebastian Redl539c5062010-08-18 23:57:32 +00002937 case EXPR_UNARY_OPERATOR:
Melanie Blowerf5360d42020-05-01 10:32:06 -07002938 S = UnaryOperator::CreateEmpty(Context,
2939 Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002940 break;
2941
Sebastian Redl539c5062010-08-18 23:57:32 +00002942 case EXPR_OFFSETOF:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002943 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002944 Record[ASTStmtReader::NumExprFields],
2945 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00002946 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002947
Sebastian Redl539c5062010-08-18 23:57:32 +00002948 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00002949 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002950 break;
2951
Sebastian Redl539c5062010-08-18 23:57:32 +00002952 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002953 S = new (Context) ArraySubscriptExpr(Empty);
2954 break;
2955
Florian Hahn8f3f88d2020-06-01 19:42:03 +01002956 case EXPR_MATRIX_SUBSCRIPT:
2957 S = new (Context) MatrixSubscriptExpr(Empty);
2958 break;
2959
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002960 case EXPR_OMP_ARRAY_SECTION:
2961 S = new (Context) OMPArraySectionExpr(Empty);
2962 break;
2963
Alexey Bataev7ac9efb2020-02-05 09:33:05 -05002964 case EXPR_OMP_ARRAY_SHAPING:
2965 S = OMPArrayShapingExpr::CreateEmpty(
2966 Context, Record[ASTStmtReader::NumExprFields]);
2967 break;
2968
Alexey Bataev13a15042020-04-01 15:06:38 -04002969 case EXPR_OMP_ITERATOR:
2970 S = OMPIteratorExpr::CreateEmpty(Context,
2971 Record[ASTStmtReader::NumExprFields]);
2972 break;
2973
Sebastian Redl539c5062010-08-18 23:57:32 +00002974 case EXPR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00002975 S = CallExpr::CreateEmpty(
2976 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002977 break;
2978
Haojian Wu733edf92020-03-19 16:30:40 +01002979 case EXPR_RECOVERY:
2980 S = RecoveryExpr::CreateEmpty(
2981 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
2982 break;
2983
Richard Smithdcf17de2019-06-06 23:24:15 +00002984 case EXPR_MEMBER:
2985 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
2986 Record[ASTStmtReader::NumExprFields + 1],
2987 Record[ASTStmtReader::NumExprFields + 2],
2988 Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002989 break;
2990
Sebastian Redl539c5062010-08-18 23:57:32 +00002991 case EXPR_BINARY_OPERATOR:
Melanie Blower2ba4e3a2020-04-10 13:34:46 -07002992 S = BinaryOperator::CreateEmpty(Context,
2993 Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002994 break;
2995
Sebastian Redl539c5062010-08-18 23:57:32 +00002996 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Melanie Blower2ba4e3a2020-04-10 13:34:46 -07002997 S = CompoundAssignOperator::CreateEmpty(
2998 Context, Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002999 break;
3000
Sebastian Redl539c5062010-08-18 23:57:32 +00003001 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003002 S = new (Context) ConditionalOperator(Empty);
3003 break;
3004
John McCallc07a0c72011-02-17 10:25:35 +00003005 case EXPR_BINARY_CONDITIONAL_OPERATOR:
3006 S = new (Context) BinaryConditionalOperator(Empty);
3007 break;
3008
Sebastian Redl539c5062010-08-18 23:57:32 +00003009 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003010 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003011 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003012 break;
3013
Sebastian Redl539c5062010-08-18 23:57:32 +00003014 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003015 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003016 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003017 break;
3018
Sebastian Redl539c5062010-08-18 23:57:32 +00003019 case EXPR_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003020 S = new (Context) CompoundLiteralExpr(Empty);
3021 break;
3022
Sebastian Redl539c5062010-08-18 23:57:32 +00003023 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003024 S = new (Context) ExtVectorElementExpr(Empty);
3025 break;
3026
Sebastian Redl539c5062010-08-18 23:57:32 +00003027 case EXPR_INIT_LIST:
Argyrios Kyrtzidis0f05fb92012-11-28 03:56:16 +00003028 S = new (Context) InitListExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003029 break;
3030
Sebastian Redl539c5062010-08-18 23:57:32 +00003031 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003032 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003033 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00003034
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003035 break;
3036
Yunzhong Gaocb779302015-06-10 00:27:52 +00003037 case EXPR_DESIGNATED_INIT_UPDATE:
3038 S = new (Context) DesignatedInitUpdateExpr(Empty);
3039 break;
3040
Sebastian Redl539c5062010-08-18 23:57:32 +00003041 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003042 S = new (Context) ImplicitValueInitExpr(Empty);
3043 break;
3044
Yunzhong Gaocb779302015-06-10 00:27:52 +00003045 case EXPR_NO_INIT:
3046 S = new (Context) NoInitExpr(Empty);
3047 break;
3048
Richard Smith410306b2016-12-12 02:53:20 +00003049 case EXPR_ARRAY_INIT_LOOP:
3050 S = new (Context) ArrayInitLoopExpr(Empty);
3051 break;
3052
3053 case EXPR_ARRAY_INIT_INDEX:
3054 S = new (Context) ArrayInitIndexExpr(Empty);
3055 break;
3056
Sebastian Redl539c5062010-08-18 23:57:32 +00003057 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003058 S = new (Context) VAArgExpr(Empty);
3059 break;
3060
Eric Fiselier708afb52019-05-16 21:04:15 +00003061 case EXPR_SOURCE_LOC:
3062 S = new (Context) SourceLocExpr(Empty);
3063 break;
3064
Sebastian Redl539c5062010-08-18 23:57:32 +00003065 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003066 S = new (Context) AddrLabelExpr(Empty);
3067 break;
3068
Sebastian Redl539c5062010-08-18 23:57:32 +00003069 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003070 S = new (Context) StmtExpr(Empty);
3071 break;
3072
Sebastian Redl539c5062010-08-18 23:57:32 +00003073 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003074 S = new (Context) ChooseExpr(Empty);
3075 break;
3076
Sebastian Redl539c5062010-08-18 23:57:32 +00003077 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003078 S = new (Context) GNUNullExpr(Empty);
3079 break;
3080
Sebastian Redl539c5062010-08-18 23:57:32 +00003081 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003082 S = new (Context) ShuffleVectorExpr(Empty);
3083 break;
Mike Stump11289f42009-09-09 15:08:12 +00003084
Hal Finkelc4d7c822013-09-18 03:29:45 +00003085 case EXPR_CONVERT_VECTOR:
3086 S = new (Context) ConvertVectorExpr(Empty);
3087 break;
3088
Sebastian Redl539c5062010-08-18 23:57:32 +00003089 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003090 S = new (Context) BlockExpr(Empty);
3091 break;
3092
Peter Collingbourne91147592011-04-15 00:35:48 +00003093 case EXPR_GENERIC_SELECTION:
Bruno Riccidb076832019-01-26 14:15:10 +00003094 S = GenericSelectionExpr::CreateEmpty(
3095 Context,
3096 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
Peter Collingbourne91147592011-04-15 00:35:48 +00003097 break;
3098
Sebastian Redl539c5062010-08-18 23:57:32 +00003099 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003100 S = new (Context) ObjCStringLiteral(Empty);
3101 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003102
Patrick Beard0caa3942012-04-19 00:25:12 +00003103 case EXPR_OBJC_BOXED_EXPRESSION:
3104 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremeneke65b0862012-03-06 20:05:56 +00003105 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003106
Ted Kremeneke65b0862012-03-06 20:05:56 +00003107 case EXPR_OBJC_ARRAY_LITERAL:
3108 S = ObjCArrayLiteral::CreateEmpty(Context,
3109 Record[ASTStmtReader::NumExprFields]);
3110 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003111
Ted Kremeneke65b0862012-03-06 20:05:56 +00003112 case EXPR_OBJC_DICTIONARY_LITERAL:
3113 S = ObjCDictionaryLiteral::CreateEmpty(Context,
3114 Record[ASTStmtReader::NumExprFields],
3115 Record[ASTStmtReader::NumExprFields + 1]);
3116 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003117
Sebastian Redl539c5062010-08-18 23:57:32 +00003118 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003119 S = new (Context) ObjCEncodeExpr(Empty);
3120 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003121
Sebastian Redl539c5062010-08-18 23:57:32 +00003122 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003123 S = new (Context) ObjCSelectorExpr(Empty);
3124 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003125
Sebastian Redl539c5062010-08-18 23:57:32 +00003126 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003127 S = new (Context) ObjCProtocolExpr(Empty);
3128 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003129
Sebastian Redl539c5062010-08-18 23:57:32 +00003130 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003131 S = new (Context) ObjCIvarRefExpr(Empty);
3132 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003133
Sebastian Redl539c5062010-08-18 23:57:32 +00003134 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003135 S = new (Context) ObjCPropertyRefExpr(Empty);
3136 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003137
Ted Kremeneke65b0862012-03-06 20:05:56 +00003138 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
3139 S = new (Context) ObjCSubscriptRefExpr(Empty);
3140 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003141
Sebastian Redl539c5062010-08-18 23:57:32 +00003142 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00003143 llvm_unreachable("mismatching AST file");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003144
Sebastian Redl539c5062010-08-18 23:57:32 +00003145 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003146 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00003147 Record[ASTStmtReader::NumExprFields],
3148 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003149 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003150
Sebastian Redl539c5062010-08-18 23:57:32 +00003151 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00003152 S = new (Context) ObjCIsaExpr(Empty);
3153 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003154
John McCall31168b02011-06-15 23:02:42 +00003155 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
3156 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
3157 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003158
John McCall31168b02011-06-15 23:02:42 +00003159 case EXPR_OBJC_BRIDGED_CAST:
3160 S = new (Context) ObjCBridgedCastExpr(Empty);
3161 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003162
Sebastian Redl539c5062010-08-18 23:57:32 +00003163 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003164 S = new (Context) ObjCForCollectionStmt(Empty);
3165 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003166
Sebastian Redl539c5062010-08-18 23:57:32 +00003167 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003168 S = new (Context) ObjCAtCatchStmt(Empty);
3169 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003170
Sebastian Redl539c5062010-08-18 23:57:32 +00003171 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003172 S = new (Context) ObjCAtFinallyStmt(Empty);
3173 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003174
Sebastian Redl539c5062010-08-18 23:57:32 +00003175 case STMT_OBJC_AT_TRY:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003176 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003177 Record[ASTStmtReader::NumStmtFields],
3178 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003179 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003180
Sebastian Redl539c5062010-08-18 23:57:32 +00003181 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003182 S = new (Context) ObjCAtSynchronizedStmt(Empty);
3183 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003184
Sebastian Redl539c5062010-08-18 23:57:32 +00003185 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003186 S = new (Context) ObjCAtThrowStmt(Empty);
3187 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003188
John McCall31168b02011-06-15 23:02:42 +00003189 case STMT_OBJC_AUTORELEASE_POOL:
3190 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3191 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003192
Ted Kremeneke65b0862012-03-06 20:05:56 +00003193 case EXPR_OBJC_BOOL_LITERAL:
3194 S = new (Context) ObjCBoolLiteralExpr(Empty);
3195 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003196
Erik Pilkington29099de2016-07-16 00:35:23 +00003197 case EXPR_OBJC_AVAILABILITY_CHECK:
3198 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3199 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003200
Nico Weber9b982072014-07-07 00:12:30 +00003201 case STMT_SEH_LEAVE:
3202 S = new (Context) SEHLeaveStmt(Empty);
3203 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003204
John McCallfa194042011-07-15 07:00:14 +00003205 case STMT_SEH_EXCEPT:
3206 S = new (Context) SEHExceptStmt(Empty);
3207 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003208
John McCallfa194042011-07-15 07:00:14 +00003209 case STMT_SEH_FINALLY:
3210 S = new (Context) SEHFinallyStmt(Empty);
3211 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003212
John McCallfa194042011-07-15 07:00:14 +00003213 case STMT_SEH_TRY:
3214 S = new (Context) SEHTryStmt(Empty);
3215 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003216
Sebastian Redl539c5062010-08-18 23:57:32 +00003217 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003218 S = new (Context) CXXCatchStmt(Empty);
3219 break;
3220
Sebastian Redl539c5062010-08-18 23:57:32 +00003221 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003222 S = CXXTryStmt::Create(Context, Empty,
Rui Ueyama49a3ad22019-07-16 04:46:31 +00003223 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003224 break;
3225
Richard Smith02e85f32011-04-14 22:09:26 +00003226 case STMT_CXX_FOR_RANGE:
3227 S = new (Context) CXXForRangeStmt(Empty);
3228 break;
3229
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003230 case STMT_MS_DEPENDENT_EXISTS:
3231 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3232 NestedNameSpecifierLoc(),
3233 DeclarationNameInfo(),
Craig Toppera13603a2014-05-22 05:54:18 +00003234 nullptr);
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003235 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003236
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00003237 case STMT_OMP_PARALLEL_DIRECTIVE:
3238 S =
3239 OMPParallelDirective::CreateEmpty(Context,
3240 Record[ASTStmtReader::NumStmtFields],
3241 Empty);
3242 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003243
3244 case STMT_OMP_SIMD_DIRECTIVE: {
3245 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3246 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3247 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3248 CollapsedNum, Empty);
3249 break;
3250 }
3251
Alexey Bataevf29276e2014-06-18 04:14:57 +00003252 case STMT_OMP_FOR_DIRECTIVE: {
3253 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3254 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3255 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3256 Empty);
3257 break;
3258 }
3259
Alexander Musmanf82886e2014-09-18 05:12:34 +00003260 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3261 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3262 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3263 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3264 Empty);
3265 break;
3266 }
3267
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00003268 case STMT_OMP_SECTIONS_DIRECTIVE:
3269 S = OMPSectionsDirective::CreateEmpty(
3270 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3271 break;
3272
Alexey Bataev1e0498a2014-06-26 08:21:58 +00003273 case STMT_OMP_SECTION_DIRECTIVE:
3274 S = OMPSectionDirective::CreateEmpty(Context, Empty);
3275 break;
3276
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00003277 case STMT_OMP_SINGLE_DIRECTIVE:
3278 S = OMPSingleDirective::CreateEmpty(
3279 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3280 break;
3281
Alexander Musman80c22892014-07-17 08:54:58 +00003282 case STMT_OMP_MASTER_DIRECTIVE:
3283 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3284 break;
3285
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003286 case STMT_OMP_CRITICAL_DIRECTIVE:
Alexey Bataev28c75412015-12-15 08:19:24 +00003287 S = OMPCriticalDirective::CreateEmpty(
3288 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003289 break;
3290
Alexey Bataev4acb8592014-07-07 13:01:15 +00003291 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3292 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3293 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3294 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3295 CollapsedNum, Empty);
3296 break;
3297 }
3298
Alexander Musmane4e893b2014-09-23 09:33:00 +00003299 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3300 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3301 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3302 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3303 CollapsedNum, Empty);
3304 break;
3305 }
3306
cchen47d60942019-12-05 13:43:48 -05003307 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3308 S = OMPParallelMasterDirective::CreateEmpty(
3309 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3310 break;
3311
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00003312 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3313 S = OMPParallelSectionsDirective::CreateEmpty(
3314 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3315 break;
3316
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00003317 case STMT_OMP_TASK_DIRECTIVE:
3318 S = OMPTaskDirective::CreateEmpty(
3319 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3320 break;
3321
Alexey Bataev68446b72014-07-18 07:47:19 +00003322 case STMT_OMP_TASKYIELD_DIRECTIVE:
3323 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3324 break;
3325
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00003326 case STMT_OMP_BARRIER_DIRECTIVE:
3327 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3328 break;
3329
Alexey Bataev2df347a2014-07-18 10:17:07 +00003330 case STMT_OMP_TASKWAIT_DIRECTIVE:
3331 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3332 break;
3333
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003334 case STMT_OMP_TASKGROUP_DIRECTIVE:
Alexey Bataev169d96a2017-07-18 20:17:46 +00003335 S = OMPTaskgroupDirective::CreateEmpty(
3336 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003337 break;
3338
Alexey Bataev6125da92014-07-21 11:26:11 +00003339 case STMT_OMP_FLUSH_DIRECTIVE:
3340 S = OMPFlushDirective::CreateEmpty(
3341 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3342 break;
3343
Alexey Bataevc112e942020-02-28 09:52:15 -05003344 case STMT_OMP_DEPOBJ_DIRECTIVE:
3345 S = OMPDepobjDirective::CreateEmpty(
3346 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3347 break;
3348
Alexey Bataevfcba7c32020-03-20 07:03:01 -04003349 case STMT_OMP_SCAN_DIRECTIVE:
3350 S = OMPScanDirective::CreateEmpty(
3351 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3352 break;
3353
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003354 case STMT_OMP_ORDERED_DIRECTIVE:
Alexey Bataev346265e2015-09-25 10:37:12 +00003355 S = OMPOrderedDirective::CreateEmpty(
3356 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003357 break;
3358
Alexey Bataev0162e452014-07-22 10:10:35 +00003359 case STMT_OMP_ATOMIC_DIRECTIVE:
3360 S = OMPAtomicDirective::CreateEmpty(
3361 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3362 break;
3363
Alexey Bataev0bd520b2014-09-19 08:19:49 +00003364 case STMT_OMP_TARGET_DIRECTIVE:
3365 S = OMPTargetDirective::CreateEmpty(
3366 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3367 break;
3368
Michael Wong65f367f2015-07-21 13:44:28 +00003369 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3370 S = OMPTargetDataDirective::CreateEmpty(
3371 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3372 break;
3373
Samuel Antaodf67fc42016-01-19 19:15:56 +00003374 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3375 S = OMPTargetEnterDataDirective::CreateEmpty(
3376 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3377 break;
3378
Samuel Antao72590762016-01-19 20:04:50 +00003379 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3380 S = OMPTargetExitDataDirective::CreateEmpty(
3381 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3382 break;
3383
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00003384 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3385 S = OMPTargetParallelDirective::CreateEmpty(
3386 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3387 break;
3388
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00003389 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3390 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3391 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3392 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3393 CollapsedNum, Empty);
3394 break;
3395 }
3396
Samuel Antao686c70c2016-05-26 17:30:50 +00003397 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3398 S = OMPTargetUpdateDirective::CreateEmpty(
3399 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3400 break;
3401
Alexey Bataev13314bf2014-10-09 04:18:56 +00003402 case STMT_OMP_TEAMS_DIRECTIVE:
3403 S = OMPTeamsDirective::CreateEmpty(
3404 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3405 break;
3406
Alexey Bataev6d4ed052015-07-01 06:57:41 +00003407 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3408 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3409 break;
3410
Alexey Bataev80909872015-07-02 11:25:17 +00003411 case STMT_OMP_CANCEL_DIRECTIVE:
Alexey Bataev87933c72015-09-18 08:07:34 +00003412 S = OMPCancelDirective::CreateEmpty(
3413 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev80909872015-07-02 11:25:17 +00003414 break;
3415
Alexey Bataev49f6e782015-12-01 04:18:41 +00003416 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3417 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3418 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3419 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3420 Empty);
3421 break;
3422 }
3423
Alexey Bataev0a6ed842015-12-03 09:40:15 +00003424 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3425 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3426 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3427 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3428 CollapsedNum, Empty);
3429 break;
3430 }
3431
Alexey Bataev60e51c42019-10-10 20:13:02 +00003432 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3433 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3434 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3435 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3436 CollapsedNum, Empty);
3437 break;
3438 }
3439
Alexey Bataevb8552ab2019-10-18 16:47:35 +00003440 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3441 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3442 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3443 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3444 CollapsedNum, Empty);
3445 break;
3446 }
3447
Alexey Bataev5bbcead2019-10-14 17:17:41 +00003448 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3449 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3450 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3451 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3452 CollapsedNum, Empty);
3453 break;
3454 }
3455
Alexey Bataev14a388f2019-10-25 10:27:13 -04003456 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3457 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3458 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3459 S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3460 Context, NumClauses, CollapsedNum, Empty);
3461 break;
3462 }
3463
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00003464 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3465 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3466 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3467 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3468 Empty);
3469 break;
3470 }
3471
Carlo Bertolli9925f152016-06-27 14:55:37 +00003472 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3473 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3474 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3475 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3476 CollapsedNum, Empty);
3477 break;
3478 }
3479
Kelvin Li4a39add2016-07-05 05:00:15 +00003480 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3481 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3482 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3483 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3484 CollapsedNum,
3485 Empty);
3486 break;
3487 }
3488
Kelvin Li787f3fc2016-07-06 04:45:38 +00003489 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3490 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3491 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3492 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3493 CollapsedNum, Empty);
3494 break;
3495 }
3496
Kelvin Lia579b912016-07-14 02:54:56 +00003497 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3498 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3499 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3500 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3501 CollapsedNum, Empty);
3502 break;
3503 }
3504
Kelvin Li986330c2016-07-20 22:57:10 +00003505 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3506 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3507 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3508 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3509 Empty);
3510 break;
3511 }
3512
Kelvin Li83c451e2016-12-25 04:52:54 +00003513 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
Kelvin Li02532872016-08-05 14:37:37 +00003514 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3515 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3516 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3517 CollapsedNum, Empty);
3518 break;
3519 }
3520
Kelvin Li4e325f72016-10-25 12:50:55 +00003521 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3522 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3523 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3524 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3525 CollapsedNum, Empty);
3526 break;
3527 }
3528
Kelvin Li579e41c2016-11-30 23:51:03 +00003529 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3530 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3531 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3532 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3533 Context, NumClauses, CollapsedNum, Empty);
3534 break;
3535 }
3536
Kelvin Li7ade93f2016-12-09 03:24:30 +00003537 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3538 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3539 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3540 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3541 Context, NumClauses, CollapsedNum, Empty);
3542 break;
3543 }
3544
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003545 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
Kelvin Libf594a52016-12-17 05:48:59 +00003546 S = OMPTargetTeamsDirective::CreateEmpty(
3547 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3548 break;
Kelvin Li83c451e2016-12-25 04:52:54 +00003549
3550 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3551 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3552 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3553 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3554 CollapsedNum, Empty);
3555 break;
3556 }
3557
Kelvin Li80e8f562016-12-29 22:16:30 +00003558 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3559 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3560 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3561 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3562 Context, NumClauses, CollapsedNum, Empty);
3563 break;
3564 }
3565
Kelvin Li1851df52017-01-03 05:23:48 +00003566 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3567 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3568 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3569 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3570 Context, NumClauses, CollapsedNum, Empty);
3571 break;
3572 }
3573
Kelvin Lida681182017-01-10 18:08:18 +00003574 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3575 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3576 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3577 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3578 Context, NumClauses, CollapsedNum, Empty);
3579 break;
3580 }
3581
Sebastian Redl539c5062010-08-18 23:57:32 +00003582 case EXPR_CXX_OPERATOR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003583 S = CXXOperatorCallExpr::CreateEmpty(
3584 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00003585 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003586
Sebastian Redl539c5062010-08-18 23:57:32 +00003587 case EXPR_CXX_MEMBER_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003588 S = CXXMemberCallExpr::CreateEmpty(
3589 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003590 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003591
Richard Smith778dc0f2019-10-19 00:04:38 +00003592 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3593 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3594 break;
3595
Sebastian Redl539c5062010-08-18 23:57:32 +00003596 case EXPR_CXX_CONSTRUCT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003597 S = CXXConstructExpr::CreateEmpty(
3598 Context,
3599 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003600 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003601
Richard Smith5179eb72016-06-28 19:03:57 +00003602 case EXPR_CXX_INHERITED_CTOR_INIT:
3603 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3604 break;
3605
Sebastian Redl539c5062010-08-18 23:57:32 +00003606 case EXPR_CXX_TEMPORARY_OBJECT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003607 S = CXXTemporaryObjectExpr::CreateEmpty(
3608 Context,
3609 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00003610 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003611
Sebastian Redl539c5062010-08-18 23:57:32 +00003612 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003613 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003614 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003615 break;
3616
Sebastian Redl539c5062010-08-18 23:57:32 +00003617 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003618 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003619 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003620 break;
3621
Sebastian Redl539c5062010-08-18 23:57:32 +00003622 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003623 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003624 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003625 break;
3626
Sebastian Redl539c5062010-08-18 23:57:32 +00003627 case EXPR_CXX_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003628 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00003629 break;
3630
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01003631 case EXPR_CXX_ADDRSPACE_CAST:
3632 S = CXXAddrspaceCastExpr::CreateEmpty(Context);
3633 break;
3634
Sebastian Redl539c5062010-08-18 23:57:32 +00003635 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003636 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003637 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003638 break;
3639
hyd-dev95d7ccb2020-06-11 12:30:16 -04003640 case EXPR_BUILTIN_BIT_CAST:
3641 assert(Record[ASTStmtReader::NumExprFields] == 0 && "Wrong PathSize!");
3642 S = new (Context) BuiltinBitCastExpr(Empty);
3643 break;
3644
Richard Smithc67fdd42012-03-07 08:35:16 +00003645 case EXPR_USER_DEFINED_LITERAL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003646 S = UserDefinedLiteral::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003647 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Richard Smithc67fdd42012-03-07 08:35:16 +00003648 break;
3649
Richard Smithcc1b96d2013-06-12 22:31:48 +00003650 case EXPR_CXX_STD_INITIALIZER_LIST:
3651 S = new (Context) CXXStdInitializerListExpr(Empty);
3652 break;
3653
Sebastian Redl539c5062010-08-18 23:57:32 +00003654 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003655 S = new (Context) CXXBoolLiteralExpr(Empty);
3656 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003657
Sebastian Redl539c5062010-08-18 23:57:32 +00003658 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003659 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3660 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003661
Sebastian Redl539c5062010-08-18 23:57:32 +00003662 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003663 S = new (Context) CXXTypeidExpr(Empty, true);
3664 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003665
Sebastian Redl539c5062010-08-18 23:57:32 +00003666 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003667 S = new (Context) CXXTypeidExpr(Empty, false);
3668 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003669
Francois Pichet9f4f2072010-09-08 12:20:18 +00003670 case EXPR_CXX_UUIDOF_EXPR:
3671 S = new (Context) CXXUuidofExpr(Empty, true);
3672 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003673
John McCall5e77d762013-04-16 07:28:30 +00003674 case EXPR_CXX_PROPERTY_REF_EXPR:
3675 S = new (Context) MSPropertyRefExpr(Empty);
3676 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003677
Alexey Bataevf7630272015-11-25 12:01:00 +00003678 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3679 S = new (Context) MSPropertySubscriptExpr(Empty);
3680 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003681
Francois Pichet9f4f2072010-09-08 12:20:18 +00003682 case EXPR_CXX_UUIDOF_TYPE:
3683 S = new (Context) CXXUuidofExpr(Empty, false);
3684 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003685
Sebastian Redl539c5062010-08-18 23:57:32 +00003686 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00003687 S = new (Context) CXXThisExpr(Empty);
3688 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003689
Sebastian Redl539c5062010-08-18 23:57:32 +00003690 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00003691 S = new (Context) CXXThrowExpr(Empty);
3692 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003693
John McCall32791cc2016-01-06 22:34:54 +00003694 case EXPR_CXX_DEFAULT_ARG:
3695 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00003696 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003697
Richard Smith852c9db2013-04-20 22:23:05 +00003698 case EXPR_CXX_DEFAULT_INIT:
3699 S = new (Context) CXXDefaultInitExpr(Empty);
3700 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003701
Sebastian Redl539c5062010-08-18 23:57:32 +00003702 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00003703 S = new (Context) CXXBindTemporaryExpr(Empty);
3704 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003705
Sebastian Redl539c5062010-08-18 23:57:32 +00003706 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00003707 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003708 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003709
Sebastian Redl539c5062010-08-18 23:57:32 +00003710 case EXPR_CXX_NEW:
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00003711 S = CXXNewExpr::CreateEmpty(
3712 Context,
3713 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3714 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3715 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3716 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003717 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003718
Sebastian Redl539c5062010-08-18 23:57:32 +00003719 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00003720 S = new (Context) CXXDeleteExpr(Empty);
3721 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003722
Sebastian Redl539c5062010-08-18 23:57:32 +00003723 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00003724 S = new (Context) CXXPseudoDestructorExpr(Empty);
3725 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003726
John McCall5d413782010-12-06 08:20:24 +00003727 case EXPR_EXPR_WITH_CLEANUPS:
John McCall28fc7092011-11-10 05:35:25 +00003728 S = ExprWithCleanups::Create(Context, Empty,
3729 Record[ASTStmtReader::NumExprFields]);
Chris Lattnercba86142010-05-10 00:25:06 +00003730 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003731
Sebastian Redl539c5062010-08-18 23:57:32 +00003732 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Bruno Ricci2e6dc532019-01-08 14:17:00 +00003733 S = CXXDependentScopeMemberExpr::CreateEmpty(
3734 Context,
3735 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3736 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3737 /*HasFirstQualifierFoundInScope=*/
3738 Record[ASTStmtReader::NumExprFields + 2]);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003739 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003740
Sebastian Redl539c5062010-08-18 23:57:32 +00003741 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003742 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003743 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003744 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003745 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003746 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00003747 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003748
Sebastian Redl539c5062010-08-18 23:57:32 +00003749 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003750 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003751 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00003752 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003753
Sebastian Redl539c5062010-08-18 23:57:32 +00003754 case EXPR_CXX_UNRESOLVED_MEMBER:
Bruno Riccid7628d92019-01-09 15:43:19 +00003755 S = UnresolvedMemberExpr::CreateEmpty(
3756 Context,
3757 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3758 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3759 /*NumTemplateArgs=*/
3760 Record[ASTStmtReader::NumExprFields + 1]
3761 ? Record[ASTStmtReader::NumExprFields + 2]
3762 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003763 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003764
Sebastian Redl539c5062010-08-18 23:57:32 +00003765 case EXPR_CXX_UNRESOLVED_LOOKUP:
Bruno Riccid7628d92019-01-09 15:43:19 +00003766 S = UnresolvedLookupExpr::CreateEmpty(
3767 Context,
3768 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3769 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3770 /*NumTemplateArgs=*/
3771 Record[ASTStmtReader::NumExprFields + 1]
3772 ? Record[ASTStmtReader::NumExprFields + 2]
3773 : 0);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00003774 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003775
Douglas Gregor29c42f22012-02-24 07:38:34 +00003776 case EXPR_TYPE_TRAIT:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003777 S = TypeTraitExpr::CreateDeserialized(Context,
Douglas Gregor29c42f22012-02-24 07:38:34 +00003778 Record[ASTStmtReader::NumExprFields]);
3779 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003780
John Wiegley6242b6a2011-04-28 00:16:57 +00003781 case EXPR_ARRAY_TYPE_TRAIT:
3782 S = new (Context) ArrayTypeTraitExpr(Empty);
3783 break;
3784
John Wiegleyf9f65842011-04-25 06:54:41 +00003785 case EXPR_CXX_EXPRESSION_TRAIT:
3786 S = new (Context) ExpressionTraitExpr(Empty);
3787 break;
3788
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003789 case EXPR_CXX_NOEXCEPT:
3790 S = new (Context) CXXNoexceptExpr(Empty);
3791 break;
John McCall8d69a212010-11-15 23:31:06 +00003792
Douglas Gregore8e9dd62011-01-03 17:17:50 +00003793 case EXPR_PACK_EXPANSION:
3794 S = new (Context) PackExpansionExpr(Empty);
3795 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003796
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003797 case EXPR_SIZEOF_PACK:
Richard Smithd784e682015-09-23 21:41:42 +00003798 S = SizeOfPackExpr::CreateDeserialized(
3799 Context,
3800 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003801 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003802
John McCallfa194042011-07-15 07:00:14 +00003803 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3804 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3805 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003806
Douglas Gregorcdbc5392011-01-15 01:15:58 +00003807 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3808 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3809 break;
Richard Smithb15fe3a2012-09-12 00:56:43 +00003810
3811 case EXPR_FUNCTION_PARM_PACK:
3812 S = FunctionParmPackExpr::CreateEmpty(Context,
3813 Record[ASTStmtReader::NumExprFields]);
3814 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003815
Douglas Gregorfe314812011-06-21 17:03:29 +00003816 case EXPR_MATERIALIZE_TEMPORARY:
3817 S = new (Context) MaterializeTemporaryExpr(Empty);
3818 break;
Richard Smith0f0af192014-11-08 05:07:16 +00003819
3820 case EXPR_CXX_FOLD:
3821 S = new (Context) CXXFoldExpr(Empty);
3822 break;
3823
Argyrios Kyrtzidisb2b07952011-12-03 03:49:52 +00003824 case EXPR_OPAQUE_VALUE:
3825 S = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00003826 break;
Peter Collingbourne41f85462011-02-09 21:07:24 +00003827
3828 case EXPR_CUDA_KERNEL_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003829 S = CUDAKernelCallExpr::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003830 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00003831 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003832
Tanya Lattner55808c12011-06-04 00:47:47 +00003833 case EXPR_ASTYPE:
3834 S = new (Context) AsTypeExpr(Empty);
3835 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003836
John McCallfe96e0b2011-11-06 09:01:30 +00003837 case EXPR_PSEUDO_OBJECT: {
3838 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3839 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3840 break;
3841 }
3842
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003843 case EXPR_ATOMIC:
3844 S = new (Context) AtomicExpr(Empty);
3845 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003846
Douglas Gregor99ae8062012-02-14 17:54:36 +00003847 case EXPR_LAMBDA: {
3848 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
Richard Smith30e304e2016-12-14 00:03:17 +00003849 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
Douglas Gregor99ae8062012-02-14 17:54:36 +00003850 break;
3851 }
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +00003852
3853 case STMT_COROUTINE_BODY: {
3854 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3855 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3856 break;
3857 }
3858
3859 case STMT_CORETURN:
3860 S = new (Context) CoreturnStmt(Empty);
3861 break;
3862
3863 case EXPR_COAWAIT:
3864 S = new (Context) CoawaitExpr(Empty);
3865 break;
3866
3867 case EXPR_COYIELD:
3868 S = new (Context) CoyieldExpr(Empty);
3869 break;
3870
3871 case EXPR_DEPENDENT_COAWAIT:
3872 S = new (Context) DependentCoawaitExpr(Empty);
3873 break;
Saar Raz5d98ba62019-10-15 15:24:26 +00003874
Saar Raza0f50d72020-01-18 09:11:43 +02003875 case EXPR_CONCEPT_SPECIALIZATION: {
Saar Raz5d98ba62019-10-15 15:24:26 +00003876 unsigned numTemplateArgs = Record[ASTStmtReader::NumExprFields];
3877 S = ConceptSpecializationExpr::Create(Context, Empty, numTemplateArgs);
3878 break;
Saar Raza0f50d72020-01-18 09:11:43 +02003879 }
3880
3881 case EXPR_REQUIRES:
3882 unsigned numLocalParameters = Record[ASTStmtReader::NumExprFields];
3883 unsigned numRequirement = Record[ASTStmtReader::NumExprFields + 1];
3884 S = RequiresExpr::Create(Context, Empty, numLocalParameters,
3885 numRequirement);
3886 break;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003887 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003888
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003889 // We hit a STMT_STOP, so we're done with this expression.
3890 if (Finished)
3891 break;
3892
3893 ++NumStatementsRead;
3894
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003895 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003896 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003897 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3898 }
3899
David L. Jonesbe1557a2016-12-21 00:17:49 +00003900 assert(Record.getIdx() == Record.size() &&
3901 "Invalid deserialization of statement");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003902 StmtStack.push_back(S);
3903 }
Chris Lattner0e6c9402013-01-20 02:38:54 +00003904Done:
Alp Toker028ed912013-12-06 17:56:43 +00003905 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003906 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003907 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003908}