blob: d5ae8979b1e1a425997214ff0445a5e3075cf5a6 [file] [log] [blame]
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001//===- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------------------===//
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Chris Lattner92ba5ff2009-04-27 05:14:47 +00006//
7//===----------------------------------------------------------------------===//
8//
9// Statement/expression deserialization. This implements the
Sebastian Redl2c499f62010-08-18 23:56:43 +000010// ASTReader::ReadStmt method.
Chris Lattner92ba5ff2009-04-27 05:14:47 +000011//
12//===----------------------------------------------------------------------===//
13
Saar Razfdf80e82019-12-06 01:30:21 +020014#include "clang/AST/ASTConcept.h"
Benjamin Kramer4ab984e2012-07-04 20:19:54 +000015#include "clang/AST/ASTContext.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000016#include "clang/AST/AttrIterator.h"
17#include "clang/AST/Decl.h"
18#include "clang/AST/DeclAccessPair.h"
Douglas Gregor5d3507d2009-09-09 23:08:42 +000019#include "clang/AST/DeclCXX.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000020#include "clang/AST/DeclGroup.h"
21#include "clang/AST/DeclObjC.h"
Douglas Gregorcdbc5392011-01-15 01:15:58 +000022#include "clang/AST/DeclTemplate.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000023#include "clang/AST/DeclarationName.h"
Haojian Wu67d25912020-03-16 13:43:40 +010024#include "clang/AST/DependenceFlags.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000025#include "clang/AST/Expr.h"
26#include "clang/AST/ExprCXX.h"
27#include "clang/AST/ExprObjC.h"
28#include "clang/AST/ExprOpenMP.h"
29#include "clang/AST/NestedNameSpecifier.h"
30#include "clang/AST/OpenMPClause.h"
31#include "clang/AST/OperationKinds.h"
32#include "clang/AST/Stmt.h"
33#include "clang/AST/StmtCXX.h"
34#include "clang/AST/StmtObjC.h"
35#include "clang/AST/StmtOpenMP.h"
Chris Lattner92ba5ff2009-04-27 05:14:47 +000036#include "clang/AST/StmtVisitor.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000037#include "clang/AST/TemplateBase.h"
38#include "clang/AST/Type.h"
39#include "clang/AST/UnresolvedSet.h"
40#include "clang/Basic/CapturedStmt.h"
41#include "clang/Basic/ExpressionTraits.h"
42#include "clang/Basic/LLVM.h"
43#include "clang/Basic/Lambda.h"
44#include "clang/Basic/LangOptions.h"
45#include "clang/Basic/OpenMPKinds.h"
46#include "clang/Basic/OperatorKinds.h"
47#include "clang/Basic/SourceLocation.h"
48#include "clang/Basic/Specifiers.h"
49#include "clang/Basic/TypeTraits.h"
John McCallf413f5e2013-05-03 00:10:13 +000050#include "clang/Lex/Token.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000051#include "clang/Serialization/ASTBitCodes.h"
Ilya Biryukovec3060c2020-03-02 16:07:09 +010052#include "clang/Serialization/ASTRecordReader.h"
Sam McCall6b3bede2020-03-27 19:42:49 +010053#include "llvm/ADT/BitmaskEnum.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000054#include "llvm/ADT/DenseMap.h"
Benjamin Kramer49038022012-02-04 13:45:25 +000055#include "llvm/ADT/SmallString.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000056#include "llvm/ADT/SmallVector.h"
57#include "llvm/ADT/StringRef.h"
Francis Visoiu Mistrihe0308272019-07-03 22:40:07 +000058#include "llvm/Bitstream/BitstreamReader.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000059#include "llvm/Support/Casting.h"
60#include "llvm/Support/ErrorHandling.h"
61#include <algorithm>
62#include <cassert>
63#include <cstdint>
64#include <string>
65
Chris Lattner92ba5ff2009-04-27 05:14:47 +000066using namespace clang;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000067using namespace serialization;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000068
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +000069namespace clang {
Argyrios Kyrtzidisddf5f212010-06-28 09:31:42 +000070
Sebastian Redl70c751d2010-08-18 23:56:52 +000071 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
David L. Jonesbe1557a2016-12-21 00:17:49 +000072 ASTRecordReader &Record;
Sebastian Redlc67764e2010-07-22 22:43:28 +000073 llvm::BitstreamCursor &DeclsCursor;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000074
John McCall3ce3d232019-12-13 03:37:23 -050075 SourceLocation readSourceLocation() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000076 return Record.readSourceLocation();
John McCallf413f5e2013-05-03 00:10:13 +000077 }
78
John McCall3ce3d232019-12-13 03:37:23 -050079 SourceRange readSourceRange() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000080 return Record.readSourceRange();
Sebastian Redl2c373b92010-10-05 15:59:54 +000081 }
John McCallf413f5e2013-05-03 00:10:13 +000082
John McCall3ce3d232019-12-13 03:37:23 -050083 std::string readString() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000084 return Record.readString();
Sebastian Redl2c373b92010-10-05 15:59:54 +000085 }
John McCallf413f5e2013-05-03 00:10:13 +000086
John McCall3ce3d232019-12-13 03:37:23 -050087 TypeSourceInfo *readTypeSourceInfo() {
88 return Record.readTypeSourceInfo();
John McCallf413f5e2013-05-03 00:10:13 +000089 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000090
John McCall3ce3d232019-12-13 03:37:23 -050091 Decl *readDecl() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000092 return Record.readDecl();
Sebastian Redl2c373b92010-10-05 15:59:54 +000093 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000094
Douglas Gregor7fb09192011-07-21 22:35:25 +000095 template<typename T>
John McCall3ce3d232019-12-13 03:37:23 -050096 T *readDeclAs() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000097 return Record.readDeclAs<T>();
Douglas Gregor7fb09192011-07-21 22:35:25 +000098 }
99
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000100 public:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000101 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
102 : Record(Record), DeclsCursor(Cursor) {}
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000103
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000104 /// The number of record fields required for the Stmt class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000105 /// itself.
Roman Lebedevd5edcb92020-03-12 12:18:01 +0300106 static const unsigned NumStmtFields = 0;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000107
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000108 /// The number of record fields required for the Expr class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000109 /// itself.
Haojian Wu4b0f1e12020-03-17 10:36:19 +0100110 static const unsigned NumExprFields =
Sam McCall6b3bede2020-03-27 19:42:49 +0100111 NumStmtFields + llvm::BitWidth<ExprDependence> + 3;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000112
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000113 /// Read and initialize a ExplicitTemplateArgumentList structure.
Abramo Bagnara7945c982012-01-27 09:46:47 +0000114 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
James Y Knighte7d82282015-12-29 18:15:14 +0000115 TemplateArgumentLoc *ArgsLocArray,
Abramo Bagnara7945c982012-01-27 09:46:47 +0000116 unsigned NumTemplateArgs);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000117
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000118 /// Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisde6aa082011-09-22 20:07:03 +0000119 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000120 unsigned NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000121
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000122 void VisitStmt(Stmt *S);
John McCallfa194042011-07-15 07:00:14 +0000123#define STMT(Type, Base) \
124 void Visit##Type(Type *);
125#include "clang/AST/StmtNodes.inc"
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000126 };
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000127
128} // namespace clang
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000129
James Y Knighte7d82282015-12-29 18:15:14 +0000130void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
131 TemplateArgumentLoc *ArgsLocArray,
132 unsigned NumTemplateArgs) {
John McCall3ce3d232019-12-13 03:37:23 -0500133 SourceLocation TemplateKWLoc = readSourceLocation();
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000134 TemplateArgumentListInfo ArgInfo;
John McCall3ce3d232019-12-13 03:37:23 -0500135 ArgInfo.setLAngleLoc(readSourceLocation());
136 ArgInfo.setRAngleLoc(readSourceLocation());
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000137 for (unsigned i = 0; i != NumTemplateArgs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000138 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
James Y Knighte7d82282015-12-29 18:15:14 +0000139 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000140}
141
Sebastian Redl70c751d2010-08-18 23:56:52 +0000142void ASTStmtReader::VisitStmt(Stmt *S) {
David L. Jonesbe1557a2016-12-21 00:17:49 +0000143 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000144}
145
Sebastian Redl70c751d2010-08-18 23:56:52 +0000146void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000147 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500148 S->setSemiLoc(readSourceLocation());
Bruno Ricci41d11c02018-10-27 18:43:27 +0000149 S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000150}
151
Sebastian Redl70c751d2010-08-18 23:56:52 +0000152void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000153 VisitStmt(S);
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000154 SmallVector<Stmt *, 16> Stmts;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000155 unsigned NumStmts = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000156 while (NumStmts--)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000157 Stmts.push_back(Record.readSubStmt());
Benjamin Kramer07420902017-12-24 16:24:20 +0000158 S->setStmts(Stmts);
John McCall3ce3d232019-12-13 03:37:23 -0500159 S->CompoundStmtBits.LBraceLoc = readSourceLocation();
160 S->RBraceLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000161}
162
Sebastian Redl70c751d2010-08-18 23:56:52 +0000163void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000164 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000165 Record.recordSwitchCaseID(S, Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500166 S->setKeywordLoc(readSourceLocation());
167 S->setColonLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000168}
169
Sebastian Redl70c751d2010-08-18 23:56:52 +0000170void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000171 VisitSwitchCase(S);
Bruno Ricci5b30571752018-10-28 12:30:53 +0000172 bool CaseStmtIsGNURange = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000173 S->setLHS(Record.readSubExpr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000174 S->setSubStmt(Record.readSubStmt());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000175 if (CaseStmtIsGNURange) {
176 S->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500177 S->setEllipsisLoc(readSourceLocation());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000178 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000179}
180
Sebastian Redl70c751d2010-08-18 23:56:52 +0000181void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000182 VisitSwitchCase(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000183 S->setSubStmt(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000184}
185
Sebastian Redl70c751d2010-08-18 23:56:52 +0000186void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000187 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500188 auto *LD = readDeclAs<LabelDecl>();
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000189 LD->setStmt(S);
190 S->setDecl(LD);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000191 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500192 S->setIdentLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000193}
194
Richard Smithc202b282012-04-14 00:33:13 +0000195void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
196 VisitStmt(S);
Bruno Ricci41d11c02018-10-27 18:43:27 +0000197 // NumAttrs in AttributedStmt is set when creating an empty
198 // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
199 // to allocate the right amount of space for the trailing Attr *.
David L. Jonesbe1557a2016-12-21 00:17:49 +0000200 uint64_t NumAttrs = Record.readInt();
Richard Smithc202b282012-04-14 00:33:13 +0000201 AttrVec Attrs;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000202 Record.readAttributes(Attrs);
Matt Beaumont-Gayad0bb8e2012-07-09 18:55:31 +0000203 (void)NumAttrs;
Bruno Ricci41d11c02018-10-27 18:43:27 +0000204 assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
Alexander Kornienko20f6fc62012-07-09 10:04:07 +0000205 assert(NumAttrs == Attrs.size());
Aaron Ballmanf3d9b092014-05-13 14:55:01 +0000206 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000207 S->SubStmt = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500208 S->AttributedStmtBits.AttrLoc = readSourceLocation();
Richard Smithc202b282012-04-14 00:33:13 +0000209}
210
Sebastian Redl70c751d2010-08-18 23:56:52 +0000211void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000212 VisitStmt(S);
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000213
David L. Jonesbe1557a2016-12-21 00:17:49 +0000214 S->setConstexpr(Record.readInt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000215 bool HasElse = Record.readInt();
216 bool HasVar = Record.readInt();
217 bool HasInit = Record.readInt();
218
David L. Jonesb6a8f022016-12-21 04:34:52 +0000219 S->setCond(Record.readSubExpr());
220 S->setThen(Record.readSubStmt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000221 if (HasElse)
222 S->setElse(Record.readSubStmt());
223 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500224 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000225 if (HasInit)
226 S->setInit(Record.readSubStmt());
227
John McCall3ce3d232019-12-13 03:37:23 -0500228 S->setIfLoc(readSourceLocation());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000229 if (HasElse)
John McCall3ce3d232019-12-13 03:37:23 -0500230 S->setElseLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000231}
232
Sebastian Redl70c751d2010-08-18 23:56:52 +0000233void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000234 VisitStmt(S);
Bruno Riccie2806f82018-10-29 16:12:37 +0000235
236 bool HasInit = Record.readInt();
237 bool HasVar = Record.readInt();
238 bool AllEnumCasesCovered = Record.readInt();
239 if (AllEnumCasesCovered)
240 S->setAllEnumCasesCovered();
241
David L. Jonesb6a8f022016-12-21 04:34:52 +0000242 S->setCond(Record.readSubExpr());
243 S->setBody(Record.readSubStmt());
Bruno Riccie2806f82018-10-29 16:12:37 +0000244 if (HasInit)
245 S->setInit(Record.readSubStmt());
246 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500247 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccie2806f82018-10-29 16:12:37 +0000248
John McCall3ce3d232019-12-13 03:37:23 -0500249 S->setSwitchLoc(readSourceLocation());
Ted Kremenekc42f3452010-09-09 00:05:53 +0000250
Craig Toppera13603a2014-05-22 05:54:18 +0000251 SwitchCase *PrevSC = nullptr;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000252 for (auto E = Record.size(); Record.getIdx() != E; ) {
253 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000254 if (PrevSC)
255 PrevSC->setNextSwitchCase(SC);
256 else
257 S->setSwitchCaseList(SC);
Mike Stump11289f42009-09-09 15:08:12 +0000258
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000259 PrevSC = SC;
260 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000261}
262
Sebastian Redl70c751d2010-08-18 23:56:52 +0000263void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000264 VisitStmt(S);
Bruno Riccibacf7512018-10-30 13:42:41 +0000265
266 bool HasVar = Record.readInt();
Douglas Gregor7fb09192011-07-21 22:35:25 +0000267
David L. Jonesb6a8f022016-12-21 04:34:52 +0000268 S->setCond(Record.readSubExpr());
269 S->setBody(Record.readSubStmt());
Bruno Riccibacf7512018-10-30 13:42:41 +0000270 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500271 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccibacf7512018-10-30 13:42:41 +0000272
John McCall3ce3d232019-12-13 03:37:23 -0500273 S->setWhileLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000274}
275
Sebastian Redl70c751d2010-08-18 23:56:52 +0000276void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000277 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000278 S->setCond(Record.readSubExpr());
279 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500280 S->setDoLoc(readSourceLocation());
281 S->setWhileLoc(readSourceLocation());
282 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000283}
284
Sebastian Redl70c751d2010-08-18 23:56:52 +0000285void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000286 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000287 S->setInit(Record.readSubStmt());
288 S->setCond(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500289 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000290 S->setInc(Record.readSubExpr());
291 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500292 S->setForLoc(readSourceLocation());
293 S->setLParenLoc(readSourceLocation());
294 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000295}
296
Sebastian Redl70c751d2010-08-18 23:56:52 +0000297void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000298 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500299 S->setLabel(readDeclAs<LabelDecl>());
300 S->setGotoLoc(readSourceLocation());
301 S->setLabelLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000302}
303
Sebastian Redl70c751d2010-08-18 23:56:52 +0000304void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000305 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500306 S->setGotoLoc(readSourceLocation());
307 S->setStarLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000308 S->setTarget(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000309}
310
Sebastian Redl70c751d2010-08-18 23:56:52 +0000311void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000312 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500313 S->setContinueLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000314}
315
Sebastian Redl70c751d2010-08-18 23:56:52 +0000316void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000317 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500318 S->setBreakLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000319}
320
Sebastian Redl70c751d2010-08-18 23:56:52 +0000321void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000322 VisitStmt(S);
Bruno Ricci023b1d12018-10-30 14:40:49 +0000323
324 bool HasNRVOCandidate = Record.readInt();
325
David L. Jonesb6a8f022016-12-21 04:34:52 +0000326 S->setRetValue(Record.readSubExpr());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000327 if (HasNRVOCandidate)
John McCall3ce3d232019-12-13 03:37:23 -0500328 S->setNRVOCandidate(readDeclAs<VarDecl>());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000329
John McCall3ce3d232019-12-13 03:37:23 -0500330 S->setReturnLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000331}
332
Sebastian Redl70c751d2010-08-18 23:56:52 +0000333void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000334 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500335 S->setStartLoc(readSourceLocation());
336 S->setEndLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000337
David L. Jonesbe1557a2016-12-21 00:17:49 +0000338 if (Record.size() - Record.getIdx() == 1) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000339 // Single declaration
John McCall3ce3d232019-12-13 03:37:23 -0500340 S->setDeclGroup(DeclGroupRef(readDecl()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000341 } else {
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000342 SmallVector<Decl *, 16> Decls;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000343 int N = Record.size() - Record.getIdx();
344 Decls.reserve(N);
345 for (int I = 0; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500346 Decls.push_back(readDecl());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000347 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
Douglas Gregor038c3382009-05-22 22:45:36 +0000348 Decls.data(),
349 Decls.size())));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000350 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000351}
352
John McCallf413f5e2013-05-03 00:10:13 +0000353void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000354 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000355 S->NumOutputs = Record.readInt();
356 S->NumInputs = Record.readInt();
357 S->NumClobbers = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500358 S->setAsmLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000359 S->setVolatile(Record.readInt());
360 S->setSimple(Record.readInt());
John McCallf413f5e2013-05-03 00:10:13 +0000361}
Mike Stump11289f42009-09-09 15:08:12 +0000362
John McCallf413f5e2013-05-03 00:10:13 +0000363void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
364 VisitAsmStmt(S);
Jennifer Yub8fee672019-06-03 15:57:25 +0000365 S->NumLabels = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500366 S->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000367 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000368
John McCallf413f5e2013-05-03 00:10:13 +0000369 unsigned NumOutputs = S->getNumOutputs();
370 unsigned NumInputs = S->getNumInputs();
371 unsigned NumClobbers = S->getNumClobbers();
Jennifer Yub8fee672019-06-03 15:57:25 +0000372 unsigned NumLabels = S->getNumLabels();
John McCallf413f5e2013-05-03 00:10:13 +0000373
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000374 // Outputs and inputs
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000375 SmallVector<IdentifierInfo *, 16> Names;
376 SmallVector<StringLiteral*, 16> Constraints;
377 SmallVector<Stmt*, 16> Exprs;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000378 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -0500379 Names.push_back(Record.readIdentifier());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000380 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
381 Exprs.push_back(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000382 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000383
384 // Constraints
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000385 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000386 for (unsigned I = 0; I != NumClobbers; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000387 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000388
Jennifer Yub8fee672019-06-03 15:57:25 +0000389 // Labels
390 for (unsigned I = 0, N = NumLabels; I != N; ++I)
391 Exprs.push_back(Record.readSubStmt());
392
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000393 S->setOutputsAndInputsAndClobbers(Record.getContext(),
394 Names.data(), Constraints.data(),
395 Exprs.data(), NumOutputs, NumInputs,
Jennifer Yub8fee672019-06-03 15:57:25 +0000396 NumLabels,
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000397 Clobbers.data(), NumClobbers);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000398}
399
Chad Rosier32503022012-06-11 20:47:18 +0000400void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
John McCallf413f5e2013-05-03 00:10:13 +0000401 VisitAsmStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500402 S->LBraceLoc = readSourceLocation();
403 S->EndLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000404 S->NumAsmToks = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500405 std::string AsmStr = readString();
John McCallf413f5e2013-05-03 00:10:13 +0000406
407 // Read the tokens.
408 SmallVector<Token, 16> AsmToks;
409 AsmToks.reserve(S->NumAsmToks);
410 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000411 AsmToks.push_back(Record.readToken());
John McCallf413f5e2013-05-03 00:10:13 +0000412 }
413
414 // The calls to reserve() for the FooData vectors are mandatory to
415 // prevent dead StringRefs in the Foo vectors.
416
417 // Read the clobbers.
418 SmallVector<std::string, 16> ClobbersData;
419 SmallVector<StringRef, 16> Clobbers;
420 ClobbersData.reserve(S->NumClobbers);
421 Clobbers.reserve(S->NumClobbers);
422 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
John McCall3ce3d232019-12-13 03:37:23 -0500423 ClobbersData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000424 Clobbers.push_back(ClobbersData.back());
425 }
426
427 // Read the operands.
428 unsigned NumOperands = S->NumOutputs + S->NumInputs;
429 SmallVector<Expr*, 16> Exprs;
430 SmallVector<std::string, 16> ConstraintsData;
431 SmallVector<StringRef, 16> Constraints;
432 Exprs.reserve(NumOperands);
433 ConstraintsData.reserve(NumOperands);
434 Constraints.reserve(NumOperands);
435 for (unsigned i = 0; i != NumOperands; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000436 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -0500437 ConstraintsData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000438 Constraints.push_back(ConstraintsData.back());
439 }
440
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000441 S->initialize(Record.getContext(), AsmStr, AsmToks,
John McCallf413f5e2013-05-03 00:10:13 +0000442 Constraints, Exprs, Clobbers);
Chad Rosier32503022012-06-11 20:47:18 +0000443}
444
Richard Smith9f690bd2015-10-27 06:02:45 +0000445void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000446 VisitStmt(S);
447 assert(Record.peekInt() == S->NumParams);
448 Record.skipInts(1);
449 auto *StoredStmts = S->getStoredStmts();
450 for (unsigned i = 0;
451 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
452 StoredStmts[i] = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000453}
454
455void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000456 VisitStmt(S);
457 S->CoreturnLoc = Record.readSourceLocation();
458 for (auto &SubStmt: S->SubStmts)
459 SubStmt = Record.readSubStmt();
460 S->IsImplicit = Record.readInt() != 0;
Richard Smith9f690bd2015-10-27 06:02:45 +0000461}
462
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000463void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
464 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500465 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000466 for (auto &SubExpr: E->SubExprs)
467 SubExpr = Record.readSubStmt();
468 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
469 E->setIsImplicit(Record.readInt() != 0);
Richard Smith9f690bd2015-10-27 06:02:45 +0000470}
471
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000472void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
473 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500474 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000475 for (auto &SubExpr: E->SubExprs)
476 SubExpr = Record.readSubStmt();
477 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
Eric Fiselier20f25cb2017-03-06 23:38:15 +0000478}
479
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000480void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
481 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500482 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000483 for (auto &SubExpr: E->SubExprs)
484 SubExpr = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000485}
486
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000487void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
Ben Langmuirce914fc2013-05-03 19:20:19 +0000488 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000489 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500490 S->setCapturedDecl(readDeclAs<CapturedDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000491 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500492 S->setCapturedRecordDecl(readDeclAs<RecordDecl>());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000493
494 // Capture inits
495 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
496 E = S->capture_init_end();
497 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000498 *I = Record.readSubExpr();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000499
500 // Body
David L. Jonesb6a8f022016-12-21 04:34:52 +0000501 S->setCapturedStmt(Record.readSubStmt());
Wei Pan17fbf6e2013-05-04 03:59:06 +0000502 S->getCapturedDecl()->setBody(S->getCapturedStmt());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000503
504 // Captures
Aaron Ballmanc656303a2014-03-14 18:08:33 +0000505 for (auto &I : S->captures()) {
John McCall3ce3d232019-12-13 03:37:23 -0500506 I.VarAndKind.setPointer(readDeclAs<VarDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000507 I.VarAndKind.setInt(
508 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500509 I.Loc = readSourceLocation();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000510 }
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000511}
512
Sebastian Redl70c751d2010-08-18 23:56:52 +0000513void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000514 VisitStmt(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000515 E->setType(Record.readType());
Ilya Biryukovec3060c2020-03-02 16:07:09 +0100516
517 // FIXME: write and read all DependentFlags with a single call.
518 bool TypeDependent = Record.readInt();
519 bool ValueDependent = Record.readInt();
520 bool InstantiationDependent = Record.readInt();
521 bool ContainsUnexpandedTemplateParameters = Record.readInt();
Haojian Wu4b0f1e12020-03-17 10:36:19 +0100522 bool ContainsErrors = Record.readInt();
Ilya Biryukovec3060c2020-03-02 16:07:09 +0100523 auto Deps = ExprDependence::None;
524 if (TypeDependent)
525 Deps |= ExprDependence::Type;
526 if (ValueDependent)
527 Deps |= ExprDependence::Value;
528 if (InstantiationDependent)
529 Deps |= ExprDependence::Instantiation;
530 if (ContainsUnexpandedTemplateParameters)
531 Deps |= ExprDependence::UnexpandedPack;
Haojian Wu4b0f1e12020-03-17 10:36:19 +0100532 if (ContainsErrors)
533 Deps |= ExprDependence::Error;
Ilya Biryukovec3060c2020-03-02 16:07:09 +0100534 E->setDependence(Deps);
535
David L. Jonesbe1557a2016-12-21 00:17:49 +0000536 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
537 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
538 assert(Record.getIdx() == NumExprFields &&
539 "Incorrect expression field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000540}
541
Bill Wendling7c44da22018-10-31 03:48:47 +0000542void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
543 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000544 E->ConstantExprBits.ResultKind = Record.readInt();
545 switch (E->ConstantExprBits.ResultKind) {
546 case ConstantExpr::RSK_Int64: {
547 E->Int64Result() = Record.readInt();
548 uint64_t tmp = Record.readInt();
549 E->ConstantExprBits.IsUnsigned = tmp & 0x1;
550 E->ConstantExprBits.BitWidth = tmp >> 1;
551 break;
552 }
553 case ConstantExpr::RSK_APValue:
554 E->APValueResult() = Record.readAPValue();
555 }
Bill Wendling7c44da22018-10-31 03:48:47 +0000556 E->setSubExpr(Record.readSubExpr());
557}
558
Sebastian Redl70c751d2010-08-18 23:56:52 +0000559void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000560 VisitExpr(E);
Bruno Ricci17ff0262018-10-27 19:21:19 +0000561 bool HasFunctionName = Record.readInt();
562 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
563 E->PredefinedExprBits.Kind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500564 E->setLocation(readSourceLocation());
Bruno Ricci17ff0262018-10-27 19:21:19 +0000565 if (HasFunctionName)
566 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000567}
568
Sebastian Redl70c751d2010-08-18 23:56:52 +0000569void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000570 VisitExpr(E);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000571
David L. Jonesbe1557a2016-12-21 00:17:49 +0000572 E->DeclRefExprBits.HasQualifier = Record.readInt();
573 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
574 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
575 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
576 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
Richard Smith715f7a12019-06-11 17:50:32 +0000577 E->DeclRefExprBits.NonOdrUseReason = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000578 unsigned NumTemplateArgs = 0;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000579 if (E->hasTemplateKWAndArgsInfo())
David L. Jonesbe1557a2016-12-21 00:17:49 +0000580 NumTemplateArgs = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000581
Chandler Carruth0e439962011-05-01 21:29:53 +0000582 if (E->hasQualifier())
James Y Knighte7d82282015-12-29 18:15:14 +0000583 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
David L. Jonesb6a8f022016-12-21 04:34:52 +0000584 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000585
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000586 if (E->hasFoundDecl())
John McCall3ce3d232019-12-13 03:37:23 -0500587 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000588
Abramo Bagnara7945c982012-01-27 09:46:47 +0000589 if (E->hasTemplateKWAndArgsInfo())
James Y Knighte7d82282015-12-29 18:15:14 +0000590 ReadTemplateKWAndArgsInfo(
591 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
592 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000593
John McCall3ce3d232019-12-13 03:37:23 -0500594 E->setDecl(readDeclAs<ValueDecl>());
595 E->setLocation(readSourceLocation());
596 E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000597}
598
Sebastian Redl70c751d2010-08-18 23:56:52 +0000599void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000600 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500601 E->setLocation(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000602 E->setValue(Record.getContext(), Record.readAPInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000603}
604
Leonard Chandb01c3a2018-06-20 17:19:40 +0000605void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
606 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500607 E->setLocation(readSourceLocation());
Vince Bridgers161fc1d2020-04-07 14:46:08 -0500608 E->setScale(Record.readInt());
Leonard Chandb01c3a2018-06-20 17:19:40 +0000609 E->setValue(Record.getContext(), Record.readAPInt());
610}
611
Sebastian Redl70c751d2010-08-18 23:56:52 +0000612void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000613 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000614 E->setRawSemantics(
615 static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
David L. Jonesbe1557a2016-12-21 00:17:49 +0000616 E->setExact(Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000617 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
John McCall3ce3d232019-12-13 03:37:23 -0500618 E->setLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000619}
620
Sebastian Redl70c751d2010-08-18 23:56:52 +0000621void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000622 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000623 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000624}
625
Sebastian Redl70c751d2010-08-18 23:56:52 +0000626void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000627 VisitExpr(E);
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000628
629 // NumConcatenated, Length and CharByteWidth are set by the empty
630 // ctor since they are needed to allocate storage for the trailing objects.
631 unsigned NumConcatenated = Record.readInt();
632 unsigned Length = Record.readInt();
633 unsigned CharByteWidth = Record.readInt();
634 assert((NumConcatenated == E->getNumConcatenated()) &&
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000635 "Wrong number of concatenated tokens!");
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000636 assert((Length == E->getLength()) && "Wrong Length!");
637 assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
638 E->StringLiteralBits.Kind = Record.readInt();
639 E->StringLiteralBits.IsPascal = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000640
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000641 // The character width is originally computed via mapCharByteWidth.
642 // Check that the deserialized character width is consistant with the result
643 // of calling mapCharByteWidth.
644 assert((CharByteWidth ==
645 StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
646 E->getKind())) &&
647 "Wrong character width!");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000648
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000649 // Deserialize the trailing array of SourceLocation.
650 for (unsigned I = 0; I < NumConcatenated; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500651 E->setStrTokenLoc(I, readSourceLocation());
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000652
653 // Deserialize the trailing array of char holding the string data.
654 char *StrData = E->getStrDataAsChar();
655 for (unsigned I = 0; I < Length * CharByteWidth; ++I)
656 StrData[I] = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000657}
658
Sebastian Redl70c751d2010-08-18 23:56:52 +0000659void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000660 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000661 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500662 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000663 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000664}
665
Sebastian Redl70c751d2010-08-18 23:56:52 +0000666void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000667 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500668 E->setLParen(readSourceLocation());
669 E->setRParen(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000670 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000671}
672
Sebastian Redl70c751d2010-08-18 23:56:52 +0000673void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000674 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000675 unsigned NumExprs = Record.readInt();
Bruno Riccif49e1ca2018-11-20 16:20:40 +0000676 assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
677 for (unsigned I = 0; I != NumExprs; ++I)
678 E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500679 E->LParenLoc = readSourceLocation();
680 E->RParenLoc = readSourceLocation();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000681}
682
Sebastian Redl70c751d2010-08-18 23:56:52 +0000683void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000684 VisitExpr(E);
Melanie Blowerf5360d42020-05-01 10:32:06 -0700685 bool hasFP_Features = Record.readInt();
686 assert(hasFP_Features == E->hasStoredFPFeatures());
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000687 E->setSubExpr(Record.readSubExpr());
688 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500689 E->setOperatorLoc(readSourceLocation());
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000690 E->setCanOverflow(Record.readInt());
Melanie Blowerf5360d42020-05-01 10:32:06 -0700691 if (hasFP_Features)
692 E->setStoredFPFeatures(FPOptions(Record.readInt()));
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000693}
694
695void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000696 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000697 assert(E->getNumComponents() == Record.peekInt());
698 Record.skipInts(1);
699 assert(E->getNumExpressions() == Record.peekInt());
700 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500701 E->setOperatorLoc(readSourceLocation());
702 E->setRParenLoc(readSourceLocation());
703 E->setTypeSourceInfo(readTypeSourceInfo());
Douglas Gregor882211c2010-04-28 22:16:22 +0000704 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000705 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500706 SourceLocation Start = readSourceLocation();
707 SourceLocation End = readSourceLocation();
Douglas Gregor882211c2010-04-28 22:16:22 +0000708 switch (Kind) {
James Y Knight7281c352015-12-29 22:31:18 +0000709 case OffsetOfNode::Array:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000710 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000711 break;
712
James Y Knight7281c352015-12-29 22:31:18 +0000713 case OffsetOfNode::Field:
714 E->setComponent(
John McCall3ce3d232019-12-13 03:37:23 -0500715 I, OffsetOfNode(Start, readDeclAs<FieldDecl>(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000716 break;
James Y Knight7281c352015-12-29 22:31:18 +0000717
718 case OffsetOfNode::Identifier:
719 E->setComponent(
720 I,
John McCall3ce3d232019-12-13 03:37:23 -0500721 OffsetOfNode(Start, Record.readIdentifier(), End));
James Y Knight7281c352015-12-29 22:31:18 +0000722 break;
723
724 case OffsetOfNode::Base: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000725 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000726 *Base = Record.readCXXBaseSpecifier();
James Y Knight7281c352015-12-29 22:31:18 +0000727 E->setComponent(I, OffsetOfNode(Base));
Douglas Gregord1702062010-04-29 00:18:15 +0000728 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000729 }
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000730 }
Douglas Gregor882211c2010-04-28 22:16:22 +0000731 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000732
Douglas Gregor882211c2010-04-28 22:16:22 +0000733 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000734 E->setIndexExpr(I, Record.readSubExpr());
Douglas Gregor882211c2010-04-28 22:16:22 +0000735}
736
Peter Collingbournee190dee2011-03-11 19:24:49 +0000737void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000738 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000739 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
740 if (Record.peekInt() == 0) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000741 E->setArgument(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000742 Record.skipInts(1);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000743 } else {
John McCall3ce3d232019-12-13 03:37:23 -0500744 E->setArgument(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000745 }
John McCall3ce3d232019-12-13 03:37:23 -0500746 E->setOperatorLoc(readSourceLocation());
747 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000748}
749
Saar Raza0f50d72020-01-18 09:11:43 +0200750static ConstraintSatisfaction
751readConstraintSatisfaction(ASTRecordReader &Record) {
752 ConstraintSatisfaction Satisfaction;
753 Satisfaction.IsSatisfied = Record.readInt();
754 if (!Satisfaction.IsSatisfied) {
755 unsigned NumDetailRecords = Record.readInt();
756 for (unsigned i = 0; i != NumDetailRecords; ++i) {
757 Expr *ConstraintExpr = Record.readExpr();
Michael Liao70b53a302020-01-19 12:23:11 -0500758 if (/* IsDiagnostic */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200759 SourceLocation DiagLocation = Record.readSourceLocation();
760 std::string DiagMessage = Record.readString();
761 Satisfaction.Details.emplace_back(
762 ConstraintExpr, new (Record.getContext())
763 ConstraintSatisfaction::SubstitutionDiagnostic{
764 DiagLocation, DiagMessage});
765 } else
766 Satisfaction.Details.emplace_back(ConstraintExpr, Record.readExpr());
767 }
768 }
769 return Satisfaction;
770}
771
Saar Raz5d98ba62019-10-15 15:24:26 +0000772void ASTStmtReader::VisitConceptSpecializationExpr(
773 ConceptSpecializationExpr *E) {
774 VisitExpr(E);
775 unsigned NumTemplateArgs = Record.readInt();
776 E->NestedNameSpec = Record.readNestedNameSpecifierLoc();
777 E->TemplateKWLoc = Record.readSourceLocation();
Saar Razff1e0fc2020-01-15 02:48:42 +0200778 E->ConceptName = Record.readDeclarationNameInfo();
John McCall3ce3d232019-12-13 03:37:23 -0500779 E->NamedConcept = readDeclAs<ConceptDecl>();
Saar Razf9e63892020-03-10 22:04:11 +0200780 E->FoundDecl = Record.readDeclAs<NamedDecl>();
Saar Razff1e0fc2020-01-15 02:48:42 +0200781 E->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
Saar Raz5d98ba62019-10-15 15:24:26 +0000782 llvm::SmallVector<TemplateArgument, 4> Args;
783 for (unsigned I = 0; I < NumTemplateArgs; ++I)
784 Args.push_back(Record.readTemplateArgument());
Saar Razff1e0fc2020-01-15 02:48:42 +0200785 E->setTemplateArguments(Args);
Saar Raza0f50d72020-01-18 09:11:43 +0200786 E->Satisfaction = E->isValueDependent() ? nullptr :
787 ASTConstraintSatisfaction::Create(Record.getContext(),
788 readConstraintSatisfaction(Record));
789}
790
791static concepts::Requirement::SubstitutionDiagnostic *
792readSubstitutionDiagnostic(ASTRecordReader &Record) {
793 std::string SubstitutedEntity = Record.readString();
794 SourceLocation DiagLoc = Record.readSourceLocation();
795 std::string DiagMessage = Record.readString();
796 return new (Record.getContext())
797 concepts::Requirement::SubstitutionDiagnostic{SubstitutedEntity, DiagLoc,
798 DiagMessage};
799}
800
801void ASTStmtReader::VisitRequiresExpr(RequiresExpr *E) {
802 VisitExpr(E);
803 unsigned NumLocalParameters = Record.readInt();
804 unsigned NumRequirements = Record.readInt();
805 E->RequiresExprBits.RequiresKWLoc = Record.readSourceLocation();
806 E->RequiresExprBits.IsSatisfied = Record.readInt();
807 E->Body = Record.readDeclAs<RequiresExprBodyDecl>();
808 llvm::SmallVector<ParmVarDecl *, 4> LocalParameters;
809 for (unsigned i = 0; i < NumLocalParameters; ++i)
810 LocalParameters.push_back(cast<ParmVarDecl>(Record.readDecl()));
811 std::copy(LocalParameters.begin(), LocalParameters.end(),
812 E->getTrailingObjects<ParmVarDecl *>());
813 llvm::SmallVector<concepts::Requirement *, 4> Requirements;
814 for (unsigned i = 0; i < NumRequirements; ++i) {
815 auto RK =
816 static_cast<concepts::Requirement::RequirementKind>(Record.readInt());
817 concepts::Requirement *R = nullptr;
818 switch (RK) {
819 case concepts::Requirement::RK_Type: {
820 auto Status =
821 static_cast<concepts::TypeRequirement::SatisfactionStatus>(
822 Record.readInt());
823 if (Status == concepts::TypeRequirement::SS_SubstitutionFailure)
824 R = new (Record.getContext())
825 concepts::TypeRequirement(readSubstitutionDiagnostic(Record));
826 else
827 R = new (Record.getContext())
828 concepts::TypeRequirement(Record.readTypeSourceInfo());
829 } break;
830 case concepts::Requirement::RK_Simple:
831 case concepts::Requirement::RK_Compound: {
832 auto Status =
833 static_cast<concepts::ExprRequirement::SatisfactionStatus>(
834 Record.readInt());
835 llvm::PointerUnion<concepts::Requirement::SubstitutionDiagnostic *,
836 Expr *> E;
837 if (Status == concepts::ExprRequirement::SS_ExprSubstitutionFailure) {
838 E = readSubstitutionDiagnostic(Record);
839 } else
840 E = Record.readExpr();
841
842 llvm::Optional<concepts::ExprRequirement::ReturnTypeRequirement> Req;
843 ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr;
844 SourceLocation NoexceptLoc;
845 if (RK == concepts::Requirement::RK_Simple) {
846 Req.emplace();
847 } else {
848 NoexceptLoc = Record.readSourceLocation();
Michael Liao70b53a302020-01-19 12:23:11 -0500849 switch (/* returnTypeRequirementKind */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200850 case 0:
851 // No return type requirement.
852 Req.emplace();
853 break;
854 case 1: {
855 // type-constraint
856 TemplateParameterList *TPL = Record.readTemplateParameterList();
857 if (Status >=
858 concepts::ExprRequirement::SS_ConstraintsNotSatisfied)
859 SubstitutedConstraintExpr =
860 cast<ConceptSpecializationExpr>(Record.readExpr());
861 Req.emplace(TPL);
862 } break;
863 case 2:
864 // Substitution failure
865 Req.emplace(readSubstitutionDiagnostic(Record));
866 break;
867 }
868 }
869 if (Expr *Ex = E.dyn_cast<Expr *>())
870 R = new (Record.getContext()) concepts::ExprRequirement(
871 Ex, RK == concepts::Requirement::RK_Simple, NoexceptLoc,
872 std::move(*Req), Status, SubstitutedConstraintExpr);
873 else
874 R = new (Record.getContext()) concepts::ExprRequirement(
875 E.get<concepts::Requirement::SubstitutionDiagnostic *>(),
876 RK == concepts::Requirement::RK_Simple, NoexceptLoc,
877 std::move(*Req));
878 } break;
879 case concepts::Requirement::RK_Nested: {
Michael Liao70b53a302020-01-19 12:23:11 -0500880 if (/* IsSubstitutionDiagnostic */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200881 R = new (Record.getContext()) concepts::NestedRequirement(
882 readSubstitutionDiagnostic(Record));
883 break;
884 }
885 Expr *E = Record.readExpr();
886 if (E->isInstantiationDependent())
887 R = new (Record.getContext()) concepts::NestedRequirement(E);
888 else
889 R = new (Record.getContext())
890 concepts::NestedRequirement(Record.getContext(), E,
891 readConstraintSatisfaction(Record));
892 } break;
Saar Razfdf80e82019-12-06 01:30:21 +0200893 }
Saar Raza0f50d72020-01-18 09:11:43 +0200894 if (!R)
895 continue;
896 Requirements.push_back(R);
Saar Razfdf80e82019-12-06 01:30:21 +0200897 }
Saar Raza0f50d72020-01-18 09:11:43 +0200898 std::copy(Requirements.begin(), Requirements.end(),
899 E->getTrailingObjects<concepts::Requirement *>());
900 E->RBraceLoc = Record.readSourceLocation();
Saar Raz5d98ba62019-10-15 15:24:26 +0000901}
902
Sebastian Redl70c751d2010-08-18 23:56:52 +0000903void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000904 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000905 E->setLHS(Record.readSubExpr());
906 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500907 E->setRBracketLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000908}
909
Florian Hahn8f3f88d2020-06-01 19:42:03 +0100910void ASTStmtReader::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
911 VisitExpr(E);
912 E->setBase(Record.readSubExpr());
913 E->setRowIdx(Record.readSubExpr());
914 E->setColumnIdx(Record.readSubExpr());
915 E->setRBracketLoc(readSourceLocation());
916}
917
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000918void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
919 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000920 E->setBase(Record.readSubExpr());
921 E->setLowerBound(Record.readSubExpr());
922 E->setLength(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500923 E->setColonLoc(readSourceLocation());
924 E->setRBracketLoc(readSourceLocation());
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000925}
926
Alexey Bataev7ac9efb2020-02-05 09:33:05 -0500927void ASTStmtReader::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *E) {
928 VisitExpr(E);
929 unsigned NumDims = Record.readInt();
930 E->setBase(Record.readSubExpr());
931 SmallVector<Expr *, 4> Dims(NumDims);
932 for (unsigned I = 0; I < NumDims; ++I)
933 Dims[I] = Record.readSubExpr();
934 E->setDimensions(Dims);
935 SmallVector<SourceRange, 4> SRs(NumDims);
936 for (unsigned I = 0; I < NumDims; ++I)
937 SRs[I] = readSourceRange();
938 E->setBracketsRanges(SRs);
939 E->setLParenLoc(readSourceLocation());
940 E->setRParenLoc(readSourceLocation());
941}
942
Alexey Bataev13a15042020-04-01 15:06:38 -0400943void ASTStmtReader::VisitOMPIteratorExpr(OMPIteratorExpr *E) {
944 VisitExpr(E);
945 unsigned NumIters = Record.readInt();
946 E->setIteratorKwLoc(readSourceLocation());
947 E->setLParenLoc(readSourceLocation());
948 E->setRParenLoc(readSourceLocation());
949 for (unsigned I = 0; I < NumIters; ++I) {
950 E->setIteratorDeclaration(I, Record.readDeclRef());
951 E->setAssignmentLoc(I, readSourceLocation());
952 Expr *Begin = Record.readSubExpr();
953 Expr *End = Record.readSubExpr();
954 Expr *Step = Record.readSubExpr();
955 SourceLocation ColonLoc = readSourceLocation();
956 SourceLocation SecColonLoc;
957 if (Step)
958 SecColonLoc = readSourceLocation();
959 E->setIteratorRange(I, Begin, ColonLoc, End, SecColonLoc, Step);
Alexey Bataevbe99c612020-04-06 11:21:43 -0400960 // Deserialize helpers
961 OMPIteratorHelperData HD;
962 HD.CounterVD = cast_or_null<VarDecl>(Record.readDeclRef());
963 HD.Upper = Record.readSubExpr();
964 HD.Update = Record.readSubExpr();
965 HD.CounterUpdate = Record.readSubExpr();
966 E->setHelper(I, HD);
Alexey Bataev13a15042020-04-01 15:06:38 -0400967 }
968}
969
Sebastian Redl70c751d2010-08-18 23:56:52 +0000970void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000971 VisitExpr(E);
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000972 unsigned NumArgs = Record.readInt();
973 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
John McCall3ce3d232019-12-13 03:37:23 -0500974 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000975 E->setCallee(Record.readSubExpr());
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000976 for (unsigned I = 0; I != NumArgs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000977 E->setArg(I, Record.readSubExpr());
Eric Fiselier5cdc2cd2018-12-12 21:50:55 +0000978 E->setADLCallKind(static_cast<CallExpr::ADLCallKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000979}
980
John McCallfa194042011-07-15 07:00:14 +0000981void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
982 VisitCallExpr(E);
983}
984
Sebastian Redl70c751d2010-08-18 23:56:52 +0000985void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Richard Smithdcf17de2019-06-06 23:24:15 +0000986 VisitExpr(E);
987
988 bool HasQualifier = Record.readInt();
989 bool HasFoundDecl = Record.readInt();
990 bool HasTemplateInfo = Record.readInt();
991 unsigned NumTemplateArgs = Record.readInt();
992
993 E->Base = Record.readSubExpr();
994 E->MemberDecl = Record.readDeclAs<ValueDecl>();
John McCall3ce3d232019-12-13 03:37:23 -0500995 E->MemberDNLoc = Record.readDeclarationNameLoc(E->MemberDecl->getDeclName());
Richard Smithdcf17de2019-06-06 23:24:15 +0000996 E->MemberLoc = Record.readSourceLocation();
997 E->MemberExprBits.IsArrow = Record.readInt();
998 E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
999 E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
1000 E->MemberExprBits.HadMultipleCandidates = Record.readInt();
Richard Smith1bbad592019-06-11 17:50:36 +00001001 E->MemberExprBits.NonOdrUseReason = Record.readInt();
Richard Smithdcf17de2019-06-06 23:24:15 +00001002 E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
1003
1004 if (HasQualifier || HasFoundDecl) {
1005 DeclAccessPair FoundDecl;
1006 if (HasFoundDecl) {
1007 auto *FoundD = Record.readDeclAs<NamedDecl>();
1008 auto AS = (AccessSpecifier)Record.readInt();
1009 FoundDecl = DeclAccessPair::make(FoundD, AS);
1010 } else {
1011 FoundDecl = DeclAccessPair::make(E->MemberDecl,
1012 E->MemberDecl->getAccess());
1013 }
1014 E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
1015
1016 NestedNameSpecifierLoc QualifierLoc;
1017 if (HasQualifier)
1018 QualifierLoc = Record.readNestedNameSpecifierLoc();
1019 E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
1020 QualifierLoc;
1021 }
1022
1023 if (HasTemplateInfo)
1024 ReadTemplateKWAndArgsInfo(
1025 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1026 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001027}
1028
Sebastian Redl70c751d2010-08-18 23:56:52 +00001029void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Naroffe87026a2009-07-24 17:54:45 +00001030 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001031 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001032 E->setIsaMemberLoc(readSourceLocation());
1033 E->setOpLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001034 E->setArrow(Record.readInt());
Steve Naroffe87026a2009-07-24 17:54:45 +00001035}
1036
John McCall31168b02011-06-15 23:02:42 +00001037void ASTStmtReader::
1038VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
1039 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001040 E->Operand = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001041 E->setShouldCopy(Record.readInt());
John McCall31168b02011-06-15 23:02:42 +00001042}
1043
1044void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
1045 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001046 E->LParenLoc = readSourceLocation();
1047 E->BridgeKeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001048 E->Kind = Record.readInt();
John McCall31168b02011-06-15 23:02:42 +00001049}
1050
Sebastian Redl70c751d2010-08-18 23:56:52 +00001051void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001052 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001053 unsigned NumBaseSpecs = Record.readInt();
John McCallcf142162010-08-07 06:22:56 +00001054 assert(NumBaseSpecs == E->path_size());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001055 E->setSubExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001056 E->setCastKind((CastKind)Record.readInt());
John McCallcf142162010-08-07 06:22:56 +00001057 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +00001058 while (NumBaseSpecs--) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001059 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
David L. Jonesb6a8f022016-12-21 04:34:52 +00001060 *BaseSpec = Record.readCXXBaseSpecifier();
John McCallcf142162010-08-07 06:22:56 +00001061 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +00001062 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001063}
1064
Sebastian Redl70c751d2010-08-18 23:56:52 +00001065void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Melanie Blower2ba4e3a2020-04-10 13:34:46 -07001066 bool hasFP_Features;
1067 BinaryOperator::Opcode opc;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001068 VisitExpr(E);
Melanie Blower2ba4e3a2020-04-10 13:34:46 -07001069 E->setHasStoredFPFeatures(hasFP_Features = Record.readInt());
1070 E->setOpcode(opc = (BinaryOperator::Opcode)Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001071 E->setLHS(Record.readSubExpr());
1072 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001073 E->setOperatorLoc(readSourceLocation());
Melanie Blower2ba4e3a2020-04-10 13:34:46 -07001074 if (hasFP_Features)
1075 E->setStoredFPFeatures(FPOptions(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001076}
1077
Sebastian Redl70c751d2010-08-18 23:56:52 +00001078void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001079 VisitBinaryOperator(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001080 E->setComputationLHSType(Record.readType());
1081 E->setComputationResultType(Record.readType());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001082}
1083
Sebastian Redl70c751d2010-08-18 23:56:52 +00001084void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001085 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001086 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
1087 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
1088 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001089 E->QuestionLoc = readSourceLocation();
1090 E->ColonLoc = readSourceLocation();
John McCallc07a0c72011-02-17 10:25:35 +00001091}
1092
1093void
1094ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
1095 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001096 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
1097 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
1098 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
1099 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
1100 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001101 E->QuestionLoc = readSourceLocation();
1102 E->ColonLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001103}
1104
Sebastian Redl70c751d2010-08-18 23:56:52 +00001105void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001106 VisitCastExpr(E);
Roman Lebedev12216f12018-07-27 07:27:14 +00001107 E->setIsPartOfExplicitCast(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001108}
1109
Sebastian Redl70c751d2010-08-18 23:56:52 +00001110void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001111 VisitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001112 E->setTypeInfoAsWritten(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001113}
1114
Sebastian Redl70c751d2010-08-18 23:56:52 +00001115void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001116 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001117 E->setLParenLoc(readSourceLocation());
1118 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001119}
1120
Sebastian Redl70c751d2010-08-18 23:56:52 +00001121void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001122 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001123 E->setLParenLoc(readSourceLocation());
1124 E->setTypeSourceInfo(readTypeSourceInfo());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001125 E->setInitializer(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001126 E->setFileScope(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001127}
1128
Sebastian Redl70c751d2010-08-18 23:56:52 +00001129void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001130 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001131 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001132 E->setAccessor(Record.readIdentifier());
1133 E->setAccessorLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001134}
1135
Sebastian Redl70c751d2010-08-18 23:56:52 +00001136void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001137 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001138 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
Abramo Bagnara8d16bd42012-11-08 18:41:43 +00001139 E->setSyntacticForm(SyntForm);
John McCall3ce3d232019-12-13 03:37:23 -05001140 E->setLBraceLoc(readSourceLocation());
1141 E->setRBraceLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001142 bool isArrayFiller = Record.readInt();
Craig Toppera13603a2014-05-22 05:54:18 +00001143 Expr *filler = nullptr;
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001144 if (isArrayFiller) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001145 filler = Record.readSubExpr();
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001146 E->ArrayFillerOrUnionFieldInit = filler;
1147 } else
John McCall3ce3d232019-12-13 03:37:23 -05001148 E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001149 E->sawArrayRangeDesignator(Record.readInt());
1150 unsigned NumInits = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001151 E->reserveInits(Record.getContext(), NumInits);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001152 if (isArrayFiller) {
1153 for (unsigned I = 0; I != NumInits; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001154 Expr *init = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001155 E->updateInit(Record.getContext(), I, init ? init : filler);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001156 }
1157 } else {
1158 for (unsigned I = 0; I != NumInits; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001159 E->updateInit(Record.getContext(), I, Record.readSubExpr());
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001160 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001161}
1162
Sebastian Redl70c751d2010-08-18 23:56:52 +00001163void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001164 using Designator = DesignatedInitExpr::Designator;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001165
1166 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001167 unsigned NumSubExprs = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001168 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
1169 for (unsigned I = 0; I != NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001170 E->setSubExpr(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001171 E->setEqualOrColonLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001172 E->setGNUSyntax(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001173
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001174 SmallVector<Designator, 4> Designators;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001175 while (Record.getIdx() < Record.size()) {
1176 switch ((DesignatorTypes)Record.readInt()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00001177 case DESIG_FIELD_DECL: {
John McCall3ce3d232019-12-13 03:37:23 -05001178 auto *Field = readDeclAs<FieldDecl>();
1179 SourceLocation DotLoc = readSourceLocation();
1180 SourceLocation FieldLoc = readSourceLocation();
Mike Stump11289f42009-09-09 15:08:12 +00001181 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001182 FieldLoc));
1183 Designators.back().setField(Field);
1184 break;
1185 }
1186
Sebastian Redl539c5062010-08-18 23:57:32 +00001187 case DESIG_FIELD_NAME: {
John McCall3ce3d232019-12-13 03:37:23 -05001188 const IdentifierInfo *Name = Record.readIdentifier();
1189 SourceLocation DotLoc = readSourceLocation();
1190 SourceLocation FieldLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001191 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
1192 break;
1193 }
Mike Stump11289f42009-09-09 15:08:12 +00001194
Sebastian Redl539c5062010-08-18 23:57:32 +00001195 case DESIG_ARRAY: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001196 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001197 SourceLocation LBracketLoc = readSourceLocation();
1198 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001199 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
1200 break;
1201 }
1202
Sebastian Redl539c5062010-08-18 23:57:32 +00001203 case DESIG_ARRAY_RANGE: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001204 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001205 SourceLocation LBracketLoc = readSourceLocation();
1206 SourceLocation EllipsisLoc = readSourceLocation();
1207 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001208 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
1209 RBracketLoc));
1210 break;
1211 }
1212 }
1213 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001214 E->setDesignators(Record.getContext(),
Douglas Gregor03e8bdc2010-01-06 23:17:19 +00001215 Designators.data(), Designators.size());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001216}
1217
Yunzhong Gaocb779302015-06-10 00:27:52 +00001218void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1219 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001220 E->setBase(Record.readSubExpr());
1221 E->setUpdater(Record.readSubExpr());
Yunzhong Gaocb779302015-06-10 00:27:52 +00001222}
1223
1224void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1225 VisitExpr(E);
1226}
1227
Richard Smith410306b2016-12-12 02:53:20 +00001228void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1229 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001230 E->SubExprs[0] = Record.readSubExpr();
1231 E->SubExprs[1] = Record.readSubExpr();
Richard Smith410306b2016-12-12 02:53:20 +00001232}
1233
1234void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1235 VisitExpr(E);
1236}
1237
Sebastian Redl70c751d2010-08-18 23:56:52 +00001238void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001239 VisitExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001240}
1241
Sebastian Redl70c751d2010-08-18 23:56:52 +00001242void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001243 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001244 E->setSubExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001245 E->setWrittenTypeInfo(readTypeSourceInfo());
1246 E->setBuiltinLoc(readSourceLocation());
1247 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001248 E->setIsMicrosoftABI(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001249}
1250
Eric Fiselier708afb52019-05-16 21:04:15 +00001251void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1252 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001253 E->ParentContext = readDeclAs<DeclContext>();
1254 E->BuiltinLoc = readSourceLocation();
1255 E->RParenLoc = readSourceLocation();
Eric Fiselier708afb52019-05-16 21:04:15 +00001256 E->SourceLocExprBits.Kind =
1257 static_cast<SourceLocExpr::IdentKind>(Record.readInt());
1258}
1259
Sebastian Redl70c751d2010-08-18 23:56:52 +00001260void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001261 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001262 E->setAmpAmpLoc(readSourceLocation());
1263 E->setLabelLoc(readSourceLocation());
1264 E->setLabel(readDeclAs<LabelDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001265}
1266
Sebastian Redl70c751d2010-08-18 23:56:52 +00001267void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001268 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001269 E->setLParenLoc(readSourceLocation());
1270 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001271 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
Richard Smith5c845c12020-03-09 17:34:33 -07001272 E->StmtExprBits.TemplateDepth = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001273}
1274
Sebastian Redl70c751d2010-08-18 23:56:52 +00001275void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001276 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001277 E->setCond(Record.readSubExpr());
1278 E->setLHS(Record.readSubExpr());
1279 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001280 E->setBuiltinLoc(readSourceLocation());
1281 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001282 E->setIsConditionTrue(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001283}
1284
Sebastian Redl70c751d2010-08-18 23:56:52 +00001285void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001286 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001287 E->setTokenLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001288}
1289
Sebastian Redl70c751d2010-08-18 23:56:52 +00001290void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001291 VisitExpr(E);
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001292 SmallVector<Expr *, 16> Exprs;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001293 unsigned NumExprs = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001294 while (NumExprs--)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001295 Exprs.push_back(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001296 E->setExprs(Record.getContext(), Exprs);
John McCall3ce3d232019-12-13 03:37:23 -05001297 E->setBuiltinLoc(readSourceLocation());
1298 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001299}
1300
Hal Finkelc4d7c822013-09-18 03:29:45 +00001301void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1302 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001303 E->BuiltinLoc = readSourceLocation();
1304 E->RParenLoc = readSourceLocation();
1305 E->TInfo = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001306 E->SrcExpr = Record.readSubExpr();
Hal Finkelc4d7c822013-09-18 03:29:45 +00001307}
1308
Sebastian Redl70c751d2010-08-18 23:56:52 +00001309void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001310 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001311 E->setBlockDecl(readDeclAs<BlockDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001312}
1313
Peter Collingbourne91147592011-04-15 00:35:48 +00001314void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1315 VisitExpr(E);
Bruno Riccidb076832019-01-26 14:15:10 +00001316
1317 unsigned NumAssocs = Record.readInt();
1318 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
Bruno Ricci94498c72019-01-26 13:58:15 +00001319 E->ResultIndex = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001320 E->GenericSelectionExprBits.GenericLoc = readSourceLocation();
1321 E->DefaultLoc = readSourceLocation();
1322 E->RParenLoc = readSourceLocation();
Bruno Riccidb076832019-01-26 14:15:10 +00001323
1324 Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1325 // Add 1 to account for the controlling expression which is the first
1326 // expression in the trailing array of Stmt *. This is not needed for
1327 // the trailing array of TypeSourceInfo *.
1328 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1329 Stmts[I] = Record.readSubExpr();
1330
1331 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1332 for (unsigned I = 0, N = NumAssocs; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001333 TSIs[I] = readTypeSourceInfo();
Peter Collingbourne91147592011-04-15 00:35:48 +00001334}
1335
John McCallfe96e0b2011-11-06 09:01:30 +00001336void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1337 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001338 unsigned numSemanticExprs = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001339 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001340 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001341
1342 // Read the syntactic expression.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001343 E->getSubExprsBuffer()[0] = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001344
1345 // Read all the semantic expressions.
1346 for (unsigned i = 0; i != numSemanticExprs; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001347 Expr *subExpr = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001348 E->getSubExprsBuffer()[i+1] = subExpr;
1349 }
1350}
1351
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001352void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1353 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001354 E->Op = AtomicExpr::AtomicOp(Record.readInt());
Richard Smithaa22a8c2012-04-10 22:49:28 +00001355 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1356 for (unsigned I = 0; I != E->NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001357 E->SubExprs[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001358 E->BuiltinLoc = readSourceLocation();
1359 E->RParenLoc = readSourceLocation();
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001360}
1361
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001362//===----------------------------------------------------------------------===//
1363// Objective-C Expressions and Statements
1364
Sebastian Redl70c751d2010-08-18 23:56:52 +00001365void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001366 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001367 E->setString(cast<StringLiteral>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -05001368 E->setAtLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001369}
1370
Patrick Beard0caa3942012-04-19 00:25:12 +00001371void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001372 VisitExpr(E);
1373 // could be one of several IntegerLiteral, FloatLiteral, etc.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001374 E->SubExpr = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -05001375 E->BoxingMethod = readDeclAs<ObjCMethodDecl>();
1376 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001377}
1378
1379void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1380 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001381 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001382 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1383 Expr **Elements = E->getElements();
1384 for (unsigned I = 0, N = NumElements; I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001385 Elements[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001386 E->ArrayWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1387 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001388}
1389
1390void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1391 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001392 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001393 assert(NumElements == E->getNumElements() && "Wrong number of elements");
David L. Jonesbe1557a2016-12-21 00:17:49 +00001394 bool HasPackExpansions = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001395 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001396 auto *KeyValues =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001397 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001398 auto *Expansions =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001399 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001400 for (unsigned I = 0; I != NumElements; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001401 KeyValues[I].Key = Record.readSubExpr();
1402 KeyValues[I].Value = Record.readSubExpr();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001403 if (HasPackExpansions) {
John McCall3ce3d232019-12-13 03:37:23 -05001404 Expansions[I].EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001405 Expansions[I].NumExpansionsPlusOne = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001406 }
1407 }
John McCall3ce3d232019-12-13 03:37:23 -05001408 E->DictWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1409 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001410}
1411
Sebastian Redl70c751d2010-08-18 23:56:52 +00001412void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001413 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001414 E->setEncodedTypeSourceInfo(readTypeSourceInfo());
1415 E->setAtLoc(readSourceLocation());
1416 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001417}
1418
Sebastian Redl70c751d2010-08-18 23:56:52 +00001419void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001420 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001421 E->setSelector(Record.readSelector());
John McCall3ce3d232019-12-13 03:37:23 -05001422 E->setAtLoc(readSourceLocation());
1423 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001424}
1425
Sebastian Redl70c751d2010-08-18 23:56:52 +00001426void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001427 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001428 E->setProtocol(readDeclAs<ObjCProtocolDecl>());
1429 E->setAtLoc(readSourceLocation());
1430 E->ProtoLoc = readSourceLocation();
1431 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001432}
1433
Sebastian Redl70c751d2010-08-18 23:56:52 +00001434void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001435 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001436 E->setDecl(readDeclAs<ObjCIvarDecl>());
1437 E->setLocation(readSourceLocation());
1438 E->setOpLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001439 E->setBase(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001440 E->setIsArrow(Record.readInt());
1441 E->setIsFreeIvar(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001442}
1443
Sebastian Redl70c751d2010-08-18 23:56:52 +00001444void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001445 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001446 unsigned MethodRefFlags = Record.readInt();
1447 bool Implicit = Record.readInt() != 0;
John McCallb7bd14f2010-12-02 01:19:52 +00001448 if (Implicit) {
John McCall3ce3d232019-12-13 03:37:23 -05001449 auto *Getter = readDeclAs<ObjCMethodDecl>();
1450 auto *Setter = readDeclAs<ObjCMethodDecl>();
Argyrios Kyrtzidisab468b02012-03-30 00:19:18 +00001451 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCallb7bd14f2010-12-02 01:19:52 +00001452 } else {
John McCall3ce3d232019-12-13 03:37:23 -05001453 E->setExplicitProperty(readDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001454 }
John McCall3ce3d232019-12-13 03:37:23 -05001455 E->setLocation(readSourceLocation());
1456 E->setReceiverLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001457 switch (Record.readInt()) {
John McCallb7bd14f2010-12-02 01:19:52 +00001458 case 0:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001459 E->setBase(Record.readSubExpr());
John McCallb7bd14f2010-12-02 01:19:52 +00001460 break;
1461 case 1:
David L. Jonesbe1557a2016-12-21 00:17:49 +00001462 E->setSuperReceiver(Record.readType());
John McCallb7bd14f2010-12-02 01:19:52 +00001463 break;
1464 case 2:
John McCall3ce3d232019-12-13 03:37:23 -05001465 E->setClassReceiver(readDeclAs<ObjCInterfaceDecl>());
John McCallb7bd14f2010-12-02 01:19:52 +00001466 break;
1467 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001468}
1469
Ted Kremeneke65b0862012-03-06 20:05:56 +00001470void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1471 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001472 E->setRBracket(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001473 E->setBaseExpr(Record.readSubExpr());
1474 E->setKeyExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001475 E->GetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1476 E->SetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001477}
1478
Sebastian Redl70c751d2010-08-18 23:56:52 +00001479void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001480 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001481 assert(Record.peekInt() == E->getNumArgs());
1482 Record.skipInts(1);
1483 unsigned NumStoredSelLocs = Record.readInt();
1484 E->SelLocsKind = Record.readInt();
1485 E->setDelegateInitCall(Record.readInt());
1486 E->IsImplicit = Record.readInt();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001487 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
Douglas Gregor9a129192010-04-21 00:45:42 +00001488 switch (Kind) {
1489 case ObjCMessageExpr::Instance:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001490 E->setInstanceReceiver(Record.readSubExpr());
Douglas Gregor9a129192010-04-21 00:45:42 +00001491 break;
1492
1493 case ObjCMessageExpr::Class:
John McCall3ce3d232019-12-13 03:37:23 -05001494 E->setClassReceiver(readTypeSourceInfo());
Douglas Gregor9a129192010-04-21 00:45:42 +00001495 break;
1496
1497 case ObjCMessageExpr::SuperClass:
1498 case ObjCMessageExpr::SuperInstance: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001499 QualType T = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001500 SourceLocation SuperLoc = readSourceLocation();
Douglas Gregor9a129192010-04-21 00:45:42 +00001501 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1502 break;
1503 }
1504 }
1505
1506 assert(Kind == E->getReceiverKind());
1507
David L. Jonesbe1557a2016-12-21 00:17:49 +00001508 if (Record.readInt())
John McCall3ce3d232019-12-13 03:37:23 -05001509 E->setMethodDecl(readDeclAs<ObjCMethodDecl>());
Douglas Gregor9a129192010-04-21 00:45:42 +00001510 else
David L. Jonesb6a8f022016-12-21 04:34:52 +00001511 E->setSelector(Record.readSelector());
Douglas Gregor9a129192010-04-21 00:45:42 +00001512
John McCall3ce3d232019-12-13 03:37:23 -05001513 E->LBracLoc = readSourceLocation();
1514 E->RBracLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001515
1516 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001517 E->setArg(I, Record.readSubExpr());
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00001518
1519 SourceLocation *Locs = E->getStoredSelLocs();
1520 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001521 Locs[I] = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001522}
1523
Sebastian Redl70c751d2010-08-18 23:56:52 +00001524void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001525 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001526 S->setElement(Record.readSubStmt());
1527 S->setCollection(Record.readSubExpr());
1528 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001529 S->setForLoc(readSourceLocation());
1530 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001531}
1532
Sebastian Redl70c751d2010-08-18 23:56:52 +00001533void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001534 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001535 S->setCatchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001536 S->setCatchParamDecl(readDeclAs<VarDecl>());
1537 S->setAtCatchLoc(readSourceLocation());
1538 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001539}
1540
Sebastian Redl70c751d2010-08-18 23:56:52 +00001541void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001542 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001543 S->setFinallyBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001544 S->setAtFinallyLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001545}
1546
John McCall31168b02011-06-15 23:02:42 +00001547void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001548 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001549 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001550 S->setAtLoc(readSourceLocation());
John McCall31168b02011-06-15 23:02:42 +00001551}
1552
Sebastian Redl70c751d2010-08-18 23:56:52 +00001553void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001554 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001555 assert(Record.peekInt() == S->getNumCatchStmts());
1556 Record.skipInts(1);
1557 bool HasFinally = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001558 S->setTryBody(Record.readSubStmt());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001559 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001560 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
Douglas Gregor96c79492010-04-23 22:50:49 +00001561
Douglas Gregor96c79492010-04-23 22:50:49 +00001562 if (HasFinally)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001563 S->setFinallyStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001564 S->setAtTryLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001565}
1566
Sebastian Redl70c751d2010-08-18 23:56:52 +00001567void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001568 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001569 S->setSynchExpr(Record.readSubStmt());
1570 S->setSynchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001571 S->setAtSynchronizedLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001572}
1573
Sebastian Redl70c751d2010-08-18 23:56:52 +00001574void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001575 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001576 S->setThrowExpr(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001577 S->setThrowLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001578}
1579
Ted Kremeneke65b0862012-03-06 20:05:56 +00001580void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1581 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001582 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001583 E->setLocation(readSourceLocation());
Ted Kremeneke65b0862012-03-06 20:05:56 +00001584}
1585
Erik Pilkington29099de2016-07-16 00:35:23 +00001586void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1587 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001588 SourceRange R = Record.readSourceRange();
Erik Pilkington29099de2016-07-16 00:35:23 +00001589 E->AtLoc = R.getBegin();
1590 E->RParen = R.getEnd();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001591 E->VersionToCheck = Record.readVersionTuple();
Erik Pilkington29099de2016-07-16 00:35:23 +00001592}
1593
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001594//===----------------------------------------------------------------------===//
1595// C++ Expressions and Statements
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001596//===----------------------------------------------------------------------===//
1597
Sebastian Redl70c751d2010-08-18 23:56:52 +00001598void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001599 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001600 S->CatchLoc = readSourceLocation();
1601 S->ExceptionDecl = readDeclAs<VarDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001602 S->HandlerBlock = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001603}
1604
Sebastian Redl70c751d2010-08-18 23:56:52 +00001605void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001606 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001607 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1608 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -05001609 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001610 S->getStmts()[0] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001611 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001612 S->getStmts()[i + 1] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001613}
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001614
Richard Smith02e85f32011-04-14 22:09:26 +00001615void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1616 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001617 S->ForLoc = readSourceLocation();
1618 S->CoawaitLoc = readSourceLocation();
1619 S->ColonLoc = readSourceLocation();
1620 S->RParenLoc = readSourceLocation();
Richard Smith8baa5002018-09-28 18:44:09 +00001621 S->setInit(Record.readSubStmt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001622 S->setRangeStmt(Record.readSubStmt());
1623 S->setBeginStmt(Record.readSubStmt());
1624 S->setEndStmt(Record.readSubStmt());
1625 S->setCond(Record.readSubExpr());
1626 S->setInc(Record.readSubExpr());
1627 S->setLoopVarStmt(Record.readSubStmt());
1628 S->setBody(Record.readSubStmt());
Richard Smith02e85f32011-04-14 22:09:26 +00001629}
1630
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001631void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1632 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001633 S->KeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001634 S->IsIfExists = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001635 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001636 S->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001637 S->SubStmt = Record.readSubStmt();
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001638}
1639
Sebastian Redl70c751d2010-08-18 23:56:52 +00001640void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001641 VisitCallExpr(E);
Bruno Riccifeb19232018-12-21 16:51:57 +00001642 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1643 E->CXXOperatorCallExprBits.FPFeatures = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001644 E->Range = Record.readSourceRange();
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001645}
1646
Richard Smith778dc0f2019-10-19 00:04:38 +00001647void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1648 CXXRewrittenBinaryOperator *E) {
1649 VisitExpr(E);
1650 E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1651 E->SemanticForm = Record.readSubExpr();
1652}
1653
Sebastian Redl70c751d2010-08-18 23:56:52 +00001654void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001655 VisitExpr(E);
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001656
1657 unsigned NumArgs = Record.readInt();
1658 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1659
1660 E->CXXConstructExprBits.Elidable = Record.readInt();
1661 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1662 E->CXXConstructExprBits.ListInitialization = Record.readInt();
1663 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1664 E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1665 E->CXXConstructExprBits.ConstructionKind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001666 E->CXXConstructExprBits.Loc = readSourceLocation();
1667 E->Constructor = readDeclAs<CXXConstructorDecl>();
1668 E->ParenOrBraceRange = readSourceRange();
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001669
1670 for (unsigned I = 0; I != NumArgs; ++I)
1671 E->setArg(I, Record.readSubExpr());
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001672}
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001673
Richard Smith5179eb72016-06-28 19:03:57 +00001674void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1675 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001676 E->Constructor = readDeclAs<CXXConstructorDecl>();
1677 E->Loc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001678 E->ConstructsVirtualBase = Record.readInt();
1679 E->InheritedFromVirtualBase = Record.readInt();
Richard Smith5179eb72016-06-28 19:03:57 +00001680}
1681
Sebastian Redl70c751d2010-08-18 23:56:52 +00001682void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001683 VisitCXXConstructExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001684 E->TSI = readTypeSourceInfo();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001685}
1686
Douglas Gregore31e6062012-02-07 10:09:13 +00001687void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1688 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001689 unsigned NumCaptures = Record.readInt();
Bruno Riccic669a1e2020-06-13 14:17:03 +01001690 (void)NumCaptures;
1691 assert(NumCaptures == E->LambdaExprBits.NumCaptures);
John McCall3ce3d232019-12-13 03:37:23 -05001692 E->IntroducerRange = readSourceRange();
Bruno Riccic669a1e2020-06-13 14:17:03 +01001693 E->LambdaExprBits.CaptureDefault = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001694 E->CaptureDefaultLoc = readSourceLocation();
Bruno Riccic669a1e2020-06-13 14:17:03 +01001695 E->LambdaExprBits.ExplicitParams = Record.readInt();
1696 E->LambdaExprBits.ExplicitResultType = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001697 E->ClosingBrace = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001698
Douglas Gregor99ae8062012-02-14 17:54:36 +00001699 // Read capture initializers.
1700 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1701 CEnd = E->capture_init_end();
1702 C != CEnd; ++C)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001703 *C = Record.readSubExpr();
Bruno Ricci05843dc2020-06-18 12:51:11 +01001704
1705 // Ok, not one past the end.
1706 E->getStoredStmts()[NumCaptures] = Record.readSubStmt();
Douglas Gregore31e6062012-02-07 10:09:13 +00001707}
1708
Richard Smithcc1b96d2013-06-12 22:31:48 +00001709void
1710ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1711 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001712 E->SubExpr = Record.readSubExpr();
Richard Smithcc1b96d2013-06-12 22:31:48 +00001713}
1714
Sebastian Redl70c751d2010-08-18 23:56:52 +00001715void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001716 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001717 SourceRange R = readSourceRange();
Douglas Gregor4478f852011-01-12 22:41:29 +00001718 E->Loc = R.getBegin();
1719 E->RParenLoc = R.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05001720 R = readSourceRange();
Fariborz Jahanianf0738712013-02-22 22:02:53 +00001721 E->AngleBrackets = R;
Sam Weinigd01101e2010-01-16 21:21:01 +00001722}
1723
Sebastian Redl70c751d2010-08-18 23:56:52 +00001724void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001725 return VisitCXXNamedCastExpr(E);
1726}
1727
Sebastian Redl70c751d2010-08-18 23:56:52 +00001728void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001729 return VisitCXXNamedCastExpr(E);
1730}
1731
Sebastian Redl70c751d2010-08-18 23:56:52 +00001732void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001733 return VisitCXXNamedCastExpr(E);
1734}
1735
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01001736void ASTStmtReader::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *E) {
1737 return VisitCXXNamedCastExpr(E);
1738}
1739
Sebastian Redl70c751d2010-08-18 23:56:52 +00001740void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001741 return VisitCXXNamedCastExpr(E);
1742}
1743
Sebastian Redl70c751d2010-08-18 23:56:52 +00001744void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001745 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001746 E->setLParenLoc(readSourceLocation());
1747 E->setRParenLoc(readSourceLocation());
Sam Weinigd01101e2010-01-16 21:21:01 +00001748}
1749
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001750void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1751 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001752 E->KWLoc = readSourceLocation();
1753 E->RParenLoc = readSourceLocation();
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001754}
1755
Richard Smithc67fdd42012-03-07 08:35:16 +00001756void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1757 VisitCallExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001758 E->UDSuffixLoc = readSourceLocation();
Richard Smithc67fdd42012-03-07 08:35:16 +00001759}
1760
Sebastian Redl70c751d2010-08-18 23:56:52 +00001761void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001762 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001763 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001764 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001765}
1766
Sebastian Redl70c751d2010-08-18 23:56:52 +00001767void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001768 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001769 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001770}
1771
Sebastian Redl70c751d2010-08-18 23:56:52 +00001772void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001773 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001774 E->setSourceRange(readSourceRange());
Richard Smith5d3f7172020-04-14 19:26:31 -07001775 if (E->isTypeOperand())
1776 E->Operand = readTypeSourceInfo();
1777 else
1778 E->Operand = Record.readSubExpr();
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001779}
1780
Sebastian Redl70c751d2010-08-18 23:56:52 +00001781void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001782 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001783 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001784 E->setImplicit(Record.readInt());
Chris Lattner98267332010-05-09 06:15:05 +00001785}
1786
Sebastian Redl70c751d2010-08-18 23:56:52 +00001787void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001788 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001789 E->CXXThrowExprBits.ThrowLoc = readSourceLocation();
Bruno Riccib7de97b2018-11-17 12:53:56 +00001790 E->Operand = Record.readSubExpr();
1791 E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
Chris Lattner98267332010-05-09 06:15:05 +00001792}
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001793
Sebastian Redl70c751d2010-08-18 23:56:52 +00001794void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattnere2437f42010-05-09 06:40:08 +00001795 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001796 E->Param = readDeclAs<ParmVarDecl>();
1797 E->UsedContext = readDeclAs<DeclContext>();
1798 E->CXXDefaultArgExprBits.Loc = readSourceLocation();
Chris Lattnercba86142010-05-10 00:25:06 +00001799}
1800
Richard Smith852c9db2013-04-20 22:23:05 +00001801void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1802 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001803 E->Field = readDeclAs<FieldDecl>();
1804 E->UsedContext = readDeclAs<DeclContext>();
1805 E->CXXDefaultInitExprBits.Loc = readSourceLocation();
Richard Smith852c9db2013-04-20 22:23:05 +00001806}
1807
Sebastian Redl70c751d2010-08-18 23:56:52 +00001808void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001809 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001810 E->setTemporary(Record.readCXXTemporary());
1811 E->setSubExpr(Record.readSubExpr());
Chris Lattnercba86142010-05-10 00:25:06 +00001812}
1813
Sebastian Redl70c751d2010-08-18 23:56:52 +00001814void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001815 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001816 E->TypeInfo = readTypeSourceInfo();
1817 E->CXXScalarValueInitExprBits.RParenLoc = readSourceLocation();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001818}
1819
Sebastian Redl70c751d2010-08-18 23:56:52 +00001820void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001821 VisitExpr(E);
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001822
1823 bool IsArray = Record.readInt();
1824 bool HasInit = Record.readInt();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001825 unsigned NumPlacementArgs = Record.readInt();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001826 bool IsParenTypeId = Record.readInt();
1827
1828 E->CXXNewExprBits.IsGlobalNew = Record.readInt();
1829 E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
1830 E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1831 E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
1832
1833 assert((IsArray == E->isArray()) && "Wrong IsArray!");
1834 assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
1835 assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
1836 "Wrong NumPlacementArgs!");
1837 assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
1838 (void)IsArray;
1839 (void)HasInit;
1840 (void)NumPlacementArgs;
1841
John McCall3ce3d232019-12-13 03:37:23 -05001842 E->setOperatorNew(readDeclAs<FunctionDecl>());
1843 E->setOperatorDelete(readDeclAs<FunctionDecl>());
1844 E->AllocatedTypeInfo = readTypeSourceInfo();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001845 if (IsParenTypeId)
John McCall3ce3d232019-12-13 03:37:23 -05001846 E->getTrailingObjects<SourceRange>()[0] = readSourceRange();
1847 E->Range = readSourceRange();
1848 E->DirectInitRange = readSourceRange();
Chandler Carruth01718152010-10-25 08:47:36 +00001849
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001850 // Install all the subexpressions.
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001851 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
1852 N = E->raw_arg_end();
1853 I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001854 *I = Record.readSubStmt();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001855}
1856
Sebastian Redl70c751d2010-08-18 23:56:52 +00001857void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001858 VisitExpr(E);
Bruno Ricci91728fc2018-12-03 12:32:32 +00001859 E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
1860 E->CXXDeleteExprBits.ArrayForm = Record.readInt();
1861 E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
1862 E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001863 E->OperatorDelete = readDeclAs<FunctionDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001864 E->Argument = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001865 E->CXXDeleteExprBits.Loc = readSourceLocation();
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001866}
Chris Lattnercba86142010-05-10 00:25:06 +00001867
Sebastian Redl70c751d2010-08-18 23:56:52 +00001868void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001869 VisitExpr(E);
1870
David L. Jonesb6a8f022016-12-21 04:34:52 +00001871 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001872 E->IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001873 E->OperatorLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001874 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001875 E->ScopeType = readTypeSourceInfo();
1876 E->ColonColonLoc = readSourceLocation();
1877 E->TildeLoc = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001878
John McCall3ce3d232019-12-13 03:37:23 -05001879 IdentifierInfo *II = Record.readIdentifier();
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001880 if (II)
John McCall3ce3d232019-12-13 03:37:23 -05001881 E->setDestroyedType(II, readSourceLocation());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001882 else
John McCall3ce3d232019-12-13 03:37:23 -05001883 E->setDestroyedType(readTypeSourceInfo());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001884}
1885
John McCall5d413782010-12-06 08:20:24 +00001886void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001887 VisitExpr(E);
John McCall28fc7092011-11-10 05:35:25 +00001888
David L. Jonesbe1557a2016-12-21 00:17:49 +00001889 unsigned NumObjects = Record.readInt();
John McCall28fc7092011-11-10 05:35:25 +00001890 assert(NumObjects == E->getNumObjects());
Akira Hatanaka40568fe2020-03-10 14:06:25 -07001891 for (unsigned i = 0; i != NumObjects; ++i) {
1892 unsigned CleanupKind = Record.readInt();
1893 ExprWithCleanups::CleanupObject Obj;
1894 if (CleanupKind == COK_Block)
1895 Obj = readDeclAs<BlockDecl>();
1896 else if (CleanupKind == COK_CompoundLiteral)
1897 Obj = cast<CompoundLiteralExpr>(Record.readSubExpr());
1898 else
1899 llvm_unreachable("unexpected cleanup object type");
1900 E->getTrailingObjects<ExprWithCleanups::CleanupObject>()[i] = Obj;
1901 }
John McCall28fc7092011-11-10 05:35:25 +00001902
David L. Jonesbe1557a2016-12-21 00:17:49 +00001903 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001904 E->SubExpr = Record.readSubExpr();
Chris Lattnere2437f42010-05-09 06:40:08 +00001905}
1906
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001907void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1908 CXXDependentScopeMemberExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001909 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001910
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001911 bool HasTemplateKWAndArgsInfo = Record.readInt();
1912 unsigned NumTemplateArgs = Record.readInt();
1913 bool HasFirstQualifierFoundInScope = Record.readInt();
1914
1915 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
1916 "Wrong HasTemplateKWAndArgsInfo!");
1917 assert(
1918 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
1919 "Wrong HasFirstQualifierFoundInScope!");
1920
1921 if (HasTemplateKWAndArgsInfo)
James Y Knighte7d82282015-12-29 18:15:14 +00001922 ReadTemplateKWAndArgsInfo(
1923 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001924 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001925
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001926 assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
1927 "Wrong NumTemplateArgs!");
1928
1929 E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001930 E->CXXDependentScopeMemberExprBits.OperatorLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001931 E->BaseType = Record.readType();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001932 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001933 E->Base = Record.readSubExpr();
1934
1935 if (HasFirstQualifierFoundInScope)
John McCall3ce3d232019-12-13 03:37:23 -05001936 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001937
John McCall3ce3d232019-12-13 03:37:23 -05001938 E->MemberNameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001939}
1940
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001941void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001942ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001943 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001944
David L. Jonesbe1557a2016-12-21 00:17:49 +00001945 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001946 ReadTemplateKWAndArgsInfo(
1947 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1948 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001949 /*NumTemplateArgs=*/Record.readInt());
Douglas Gregor3a43fd62011-02-25 20:49:16 +00001950
David L. Jonesb6a8f022016-12-21 04:34:52 +00001951 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001952 E->NameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001953}
1954
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001955void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001956ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001957 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001958 assert(Record.peekInt() == E->arg_size() &&
1959 "Read wrong record during creation ?");
1960 Record.skipInts(1);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001961 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001962 E->setArg(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001963 E->TSI = readTypeSourceInfo();
1964 E->setLParenLoc(readSourceLocation());
1965 E->setRParenLoc(readSourceLocation());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001966}
1967
Sebastian Redl70c751d2010-08-18 23:56:52 +00001968void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001969 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001970
Bruno Riccid7628d92019-01-09 15:43:19 +00001971 unsigned NumResults = Record.readInt();
1972 bool HasTemplateKWAndArgsInfo = Record.readInt();
1973 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
1974 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
1975 "Wrong HasTemplateKWAndArgsInfo!");
1976
1977 if (HasTemplateKWAndArgsInfo) {
1978 unsigned NumTemplateArgs = Record.readInt();
James Y Knighte7d82282015-12-29 18:15:14 +00001979 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1980 E->getTrailingTemplateArgumentLoc(),
Bruno Riccid7628d92019-01-09 15:43:19 +00001981 NumTemplateArgs);
1982 assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
1983 "Wrong NumTemplateArgs!");
1984 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001985
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001986 UnresolvedSet<8> Decls;
Bruno Riccid7628d92019-01-09 15:43:19 +00001987 for (unsigned I = 0; I != NumResults; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -05001988 auto *D = readDeclAs<NamedDecl>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001989 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001990 Decls.addDecl(D, AS);
1991 }
Bruno Riccid7628d92019-01-09 15:43:19 +00001992
1993 DeclAccessPair *Results = E->getTrailingResults();
1994 UnresolvedSetIterator Iter = Decls.begin();
1995 for (unsigned I = 0; I != NumResults; ++I) {
1996 Results[I] = (Iter + I).getPair();
1997 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001998
John McCall3ce3d232019-12-13 03:37:23 -05001999 E->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002000 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00002001}
2002
Sebastian Redl70c751d2010-08-18 23:56:52 +00002003void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002004 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00002005 E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
2006 E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002007 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002008 E->BaseType = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05002009 E->OperatorLoc = readSourceLocation();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00002010}
2011
Sebastian Redl70c751d2010-08-18 23:56:52 +00002012void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002013 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00002014 E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
2015 E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002016 E->NamingClass = readDeclAs<CXXRecordDecl>();
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00002017}
2018
Douglas Gregor29c42f22012-02-24 07:38:34 +00002019void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
2020 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002021 E->TypeTraitExprBits.NumArgs = Record.readInt();
2022 E->TypeTraitExprBits.Kind = Record.readInt();
2023 E->TypeTraitExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002024 SourceRange Range = readSourceRange();
Jordan Rose99e80c12013-12-20 01:26:47 +00002025 E->Loc = Range.getBegin();
2026 E->RParenLoc = Range.getEnd();
2027
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002028 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
Douglas Gregor29c42f22012-02-24 07:38:34 +00002029 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05002030 Args[I] = readTypeSourceInfo();
Douglas Gregor29c42f22012-02-24 07:38:34 +00002031}
2032
John Wiegley6242b6a2011-04-28 00:16:57 +00002033void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
2034 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002035 E->ATT = (ArrayTypeTrait)Record.readInt();
2036 E->Value = (unsigned int)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002037 SourceRange Range = readSourceRange();
John Wiegley6242b6a2011-04-28 00:16:57 +00002038 E->Loc = Range.getBegin();
2039 E->RParen = Range.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05002040 E->QueriedType = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002041 E->Dimension = Record.readSubExpr();
John Wiegley6242b6a2011-04-28 00:16:57 +00002042}
2043
John Wiegleyf9f65842011-04-25 06:54:41 +00002044void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
2045 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002046 E->ET = (ExpressionTrait)Record.readInt();
2047 E->Value = (bool)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002048 SourceRange Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002049 E->QueriedExpression = Record.readSubExpr();
John Wiegleyf9f65842011-04-25 06:54:41 +00002050 E->Loc = Range.getBegin();
2051 E->RParen = Range.getEnd();
2052}
2053
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00002054void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
2055 VisitExpr(E);
Bruno Riccid56edfe2019-01-08 14:44:34 +00002056 E->CXXNoexceptExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002057 E->Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002058 E->Operand = Record.readSubExpr();
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00002059}
2060
Douglas Gregore8e9dd62011-01-03 17:17:50 +00002061void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
2062 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002063 E->EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002064 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002065 E->Pattern = Record.readSubExpr();
Douglas Gregore8e9dd62011-01-03 17:17:50 +00002066}
2067
Douglas Gregor820ba7b2011-01-04 17:33:58 +00002068void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2069 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002070 unsigned NumPartialArgs = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002071 E->OperatorLoc = readSourceLocation();
2072 E->PackLoc = readSourceLocation();
2073 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002074 E->Pack = Record.readDeclAs<NamedDecl>();
Richard Smithd784e682015-09-23 21:41:42 +00002075 if (E->isPartiallySubstituted()) {
2076 assert(E->Length == NumPartialArgs);
James Y Knighte00a67e2015-12-31 04:18:25 +00002077 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
Richard Smithd784e682015-09-23 21:41:42 +00002078 *E = I + NumPartialArgs;
2079 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002080 new (I) TemplateArgument(Record.readTemplateArgument());
Richard Smithd784e682015-09-23 21:41:42 +00002081 } else if (!E->isValueDependent()) {
David L. Jonesbe1557a2016-12-21 00:17:49 +00002082 E->Length = Record.readInt();
Richard Smithd784e682015-09-23 21:41:42 +00002083 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00002084}
2085
John McCallfa194042011-07-15 07:00:14 +00002086void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
2087 SubstNonTypeTemplateParmExpr *E) {
2088 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002089 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
2090 E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002091 E->Replacement = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002092}
2093
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002094void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
2095 SubstNonTypeTemplateParmPackExpr *E) {
2096 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002097 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002098 TemplateArgument ArgPack = Record.readTemplateArgument();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002099 if (ArgPack.getKind() != TemplateArgument::Pack)
2100 return;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002101
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002102 E->Arguments = ArgPack.pack_begin();
2103 E->NumArguments = ArgPack.pack_size();
John McCall3ce3d232019-12-13 03:37:23 -05002104 E->NameLoc = readSourceLocation();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002105}
2106
Richard Smithb15fe3a2012-09-12 00:56:43 +00002107void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2108 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002109 E->NumParameters = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002110 E->ParamPack = readDeclAs<ParmVarDecl>();
2111 E->NameLoc = readSourceLocation();
Richard Smithb2997f52019-05-21 20:10:50 +00002112 auto **Parms = E->getTrailingObjects<VarDecl *>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00002113 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
John McCall3ce3d232019-12-13 03:37:23 -05002114 Parms[i] = readDeclAs<VarDecl>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00002115}
2116
Douglas Gregorfe314812011-06-21 17:03:29 +00002117void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
2118 VisitExpr(E);
Tykerb0561b32019-11-17 11:41:55 +01002119 bool HasMaterialzedDecl = Record.readInt();
2120 if (HasMaterialzedDecl)
2121 E->State = cast<LifetimeExtendedTemporaryDecl>(Record.readDecl());
2122 else
2123 E->State = Record.readSubExpr();
Douglas Gregorfe314812011-06-21 17:03:29 +00002124}
2125
Richard Smith0f0af192014-11-08 05:07:16 +00002126void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
2127 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002128 E->LParenLoc = readSourceLocation();
2129 E->EllipsisLoc = readSourceLocation();
2130 E->RParenLoc = readSourceLocation();
Richard Smithc7214f62019-05-13 08:31:14 +00002131 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002132 E->SubExprs[0] = Record.readSubExpr();
2133 E->SubExprs[1] = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002134 E->Opcode = (BinaryOperatorKind)Record.readInt();
Richard Smith0f0af192014-11-08 05:07:16 +00002135}
2136
John McCall8d69a212010-11-15 23:31:06 +00002137void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
2138 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002139 E->SourceExpr = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05002140 E->OpaqueValueExprBits.Loc = readSourceLocation();
Akira Hatanaka797afe32018-03-20 01:47:58 +00002141 E->setIsUnique(Record.readInt());
John McCall8d69a212010-11-15 23:31:06 +00002142}
2143
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00002144void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
2145 llvm_unreachable("Cannot read TypoExpr nodes");
2146}
2147
Haojian Wu733edf92020-03-19 16:30:40 +01002148void ASTStmtReader::VisitRecoveryExpr(RecoveryExpr *E) {
2149 VisitExpr(E);
2150 unsigned NumArgs = Record.readInt();
2151 E->BeginLoc = readSourceLocation();
2152 E->EndLoc = readSourceLocation();
2153 assert(
2154 (NumArgs == std::distance(E->children().begin(), E->children().end())) &&
2155 "Wrong NumArgs!");
2156 (void)NumArgs;
2157 for (Stmt *&Child : E->children())
2158 Child = Record.readSubStmt();
2159}
2160
Peter Collingbourne41f85462011-02-09 21:07:24 +00002161//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002162// Microsoft Expressions and Statements
2163//===----------------------------------------------------------------------===//
John McCall5e77d762013-04-16 07:28:30 +00002164void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
2165 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002166 E->IsArrow = (Record.readInt() != 0);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002167 E->BaseExpr = Record.readSubExpr();
2168 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05002169 E->MemberLoc = readSourceLocation();
2170 E->TheDecl = readDeclAs<MSPropertyDecl>();
John McCall5e77d762013-04-16 07:28:30 +00002171}
2172
Alexey Bataevf7630272015-11-25 12:01:00 +00002173void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
2174 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002175 E->setBase(Record.readSubExpr());
2176 E->setIdx(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05002177 E->setRBracketLoc(readSourceLocation());
Alexey Bataevf7630272015-11-25 12:01:00 +00002178}
2179
John McCallfa194042011-07-15 07:00:14 +00002180void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
2181 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002182 E->setSourceRange(readSourceRange());
Richard Smithbab6df82020-04-11 22:15:29 -07002183 E->Guid = readDeclAs<MSGuidDecl>();
Richard Smith5d3f7172020-04-14 19:26:31 -07002184 if (E->isTypeOperand())
2185 E->Operand = readTypeSourceInfo();
2186 else
2187 E->Operand = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002188}
2189
Nico Weber9b982072014-07-07 00:12:30 +00002190void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
2191 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002192 S->setLeaveLoc(readSourceLocation());
Nico Weber9b982072014-07-07 00:12:30 +00002193}
2194
John McCallfa194042011-07-15 07:00:14 +00002195void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
2196 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002197 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002198 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
2199 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002200}
2201
2202void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
2203 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002204 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002205 S->Block = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002206}
2207
2208void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
2209 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002210 S->IsCXXTry = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002211 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002212 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
2213 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002214}
2215
2216//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00002217// CUDA Expressions and Statements
2218//===----------------------------------------------------------------------===//
2219
2220void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2221 VisitCallExpr(E);
Richard Smithfd420792019-05-24 23:26:07 +00002222 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
Peter Collingbourne41f85462011-02-09 21:07:24 +00002223}
2224
John McCallfa194042011-07-15 07:00:14 +00002225//===----------------------------------------------------------------------===//
2226// OpenCL Expressions and Statements.
2227//===----------------------------------------------------------------------===//
2228void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2229 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002230 E->BuiltinLoc = readSourceLocation();
2231 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002232 E->SrcExpr = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002233}
2234
2235//===----------------------------------------------------------------------===//
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002236// OpenMP Directives.
2237//===----------------------------------------------------------------------===//
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002238
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002239void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
John McCall3ce3d232019-12-13 03:37:23 -05002240 E->setLocStart(readSourceLocation());
2241 E->setLocEnd(readSourceLocation());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002242 SmallVector<OMPClause *, 5> Clauses;
2243 for (unsigned i = 0; i < E->getNumClauses(); ++i)
John McCallc2f18312019-12-14 03:01:28 -05002244 Clauses.push_back(Record.readOMPClause());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002245 E->setClauses(Clauses);
Alexey Bataev68446b72014-07-18 07:47:19 +00002246 if (E->hasAssociatedStmt())
David L. Jonesb6a8f022016-12-21 04:34:52 +00002247 E->setAssociatedStmt(Record.readSubStmt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002248}
2249
Alexander Musman3aaab662014-08-19 11:27:13 +00002250void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2251 VisitStmt(D);
2252 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002253 Record.skipInts(2);
Alexander Musman3aaab662014-08-19 11:27:13 +00002254 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002255 D->setIterationVariable(Record.readSubExpr());
2256 D->setLastIteration(Record.readSubExpr());
2257 D->setCalcLastIteration(Record.readSubExpr());
2258 D->setPreCond(Record.readSubExpr());
2259 D->setCond(Record.readSubExpr());
2260 D->setInit(Record.readSubExpr());
2261 D->setInc(Record.readSubExpr());
2262 D->setPreInits(Record.readSubStmt());
Alexey Bataev3392d762016-02-16 11:18:12 +00002263 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
Carlo Bertollifc35ad22016-03-07 16:04:49 +00002264 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2265 isOpenMPDistributeDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002266 D->setIsLastIterVariable(Record.readSubExpr());
2267 D->setLowerBoundVariable(Record.readSubExpr());
2268 D->setUpperBoundVariable(Record.readSubExpr());
2269 D->setStrideVariable(Record.readSubExpr());
2270 D->setEnsureUpperBound(Record.readSubExpr());
2271 D->setNextLowerBound(Record.readSubExpr());
2272 D->setNextUpperBound(Record.readSubExpr());
2273 D->setNumIterations(Record.readSubExpr());
Alexander Musmanc6388682014-12-15 07:07:06 +00002274 }
Carlo Bertolli9925f152016-06-27 14:55:37 +00002275 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002276 D->setPrevLowerBoundVariable(Record.readSubExpr());
2277 D->setPrevUpperBoundVariable(Record.readSubExpr());
Carlo Bertolli8429d812017-02-17 21:29:13 +00002278 D->setDistInc(Record.readSubExpr());
2279 D->setPrevEnsureUpperBound(Record.readSubExpr());
Carlo Bertolliffafe102017-04-20 00:39:39 +00002280 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2281 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2282 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2283 D->setCombinedInit(Record.readSubExpr());
2284 D->setCombinedCond(Record.readSubExpr());
2285 D->setCombinedNextLowerBound(Record.readSubExpr());
2286 D->setCombinedNextUpperBound(Record.readSubExpr());
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00002287 D->setCombinedDistCond(Record.readSubExpr());
2288 D->setCombinedParForInDistCond(Record.readSubExpr());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002289 }
Alexander Musmana5f070a2014-10-01 06:03:56 +00002290 SmallVector<Expr *, 4> Sub;
2291 unsigned CollapsedNum = D->getCollapsedNumber();
2292 Sub.reserve(CollapsedNum);
2293 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002294 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002295 D->setCounters(Sub);
2296 Sub.clear();
2297 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002298 Sub.push_back(Record.readSubExpr());
Alexey Bataeva8899172015-08-06 12:30:57 +00002299 D->setPrivateCounters(Sub);
2300 Sub.clear();
2301 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002302 Sub.push_back(Record.readSubExpr());
Alexey Bataevb08f89f2015-08-14 12:25:37 +00002303 D->setInits(Sub);
2304 Sub.clear();
2305 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002306 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002307 D->setUpdates(Sub);
2308 Sub.clear();
2309 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002310 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002311 D->setFinals(Sub);
Alexey Bataevf8be4762019-08-14 19:30:06 +00002312 Sub.clear();
2313 for (unsigned i = 0; i < CollapsedNum; ++i)
2314 Sub.push_back(Record.readSubExpr());
2315 D->setDependentCounters(Sub);
2316 Sub.clear();
2317 for (unsigned i = 0; i < CollapsedNum; ++i)
2318 Sub.push_back(Record.readSubExpr());
2319 D->setDependentInits(Sub);
2320 Sub.clear();
2321 for (unsigned i = 0; i < CollapsedNum; ++i)
2322 Sub.push_back(Record.readSubExpr());
2323 D->setFinalsConditions(Sub);
Alexander Musman3aaab662014-08-19 11:27:13 +00002324}
2325
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002326void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002327 VisitStmt(D);
2328 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002329 Record.skipInts(1);
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002330 VisitOMPExecutableDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002331 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002332 D->setHasCancel(Record.readInt());
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002333}
2334
2335void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002336 VisitOMPLoopDirective(D);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002337}
2338
Alexey Bataevf29276e2014-06-18 04:14:57 +00002339void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002340 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002341 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002342 D->setHasCancel(Record.readInt());
Alexey Bataevf29276e2014-06-18 04:14:57 +00002343}
2344
Alexander Musmanf82886e2014-09-18 05:12:34 +00002345void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2346 VisitOMPLoopDirective(D);
2347}
2348
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002349void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2350 VisitStmt(D);
2351 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002352 Record.skipInts(1);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002353 VisitOMPExecutableDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002354 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002355 D->setHasCancel(Record.readInt());
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002356}
2357
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002358void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2359 VisitStmt(D);
2360 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002361 D->setHasCancel(Record.readInt());
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002362}
2363
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002364void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2365 VisitStmt(D);
2366 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002367 Record.skipInts(1);
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002368 VisitOMPExecutableDirective(D);
2369}
2370
Alexander Musman80c22892014-07-17 08:54:58 +00002371void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2372 VisitStmt(D);
2373 VisitOMPExecutableDirective(D);
2374}
2375
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002376void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2377 VisitStmt(D);
Alexey Bataev28c75412015-12-15 08:19:24 +00002378 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002379 Record.skipInts(1);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002380 VisitOMPExecutableDirective(D);
John McCall3ce3d232019-12-13 03:37:23 -05002381 D->DirName = Record.readDeclarationNameInfo();
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002382}
2383
Alexey Bataev4acb8592014-07-07 13:01:15 +00002384void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002385 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002386 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002387 D->setHasCancel(Record.readInt());
Alexey Bataev4acb8592014-07-07 13:01:15 +00002388}
2389
Alexander Musmane4e893b2014-09-23 09:33:00 +00002390void ASTStmtReader::VisitOMPParallelForSimdDirective(
2391 OMPParallelForSimdDirective *D) {
2392 VisitOMPLoopDirective(D);
2393}
2394
cchen47d60942019-12-05 13:43:48 -05002395void ASTStmtReader::VisitOMPParallelMasterDirective(
2396 OMPParallelMasterDirective *D) {
2397 VisitStmt(D);
2398 // The NumClauses field was read in ReadStmtFromStream.
2399 Record.skipInts(1);
2400 VisitOMPExecutableDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002401 D->setTaskReductionRefExpr(Record.readSubExpr());
cchen47d60942019-12-05 13:43:48 -05002402}
2403
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002404void ASTStmtReader::VisitOMPParallelSectionsDirective(
2405 OMPParallelSectionsDirective *D) {
2406 VisitStmt(D);
2407 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002408 Record.skipInts(1);
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002409 VisitOMPExecutableDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002410 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002411 D->setHasCancel(Record.readInt());
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002412}
2413
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002414void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2415 VisitStmt(D);
2416 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002417 Record.skipInts(1);
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002418 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002419 D->setHasCancel(Record.readInt());
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002420}
2421
Alexey Bataev68446b72014-07-18 07:47:19 +00002422void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2423 VisitStmt(D);
2424 VisitOMPExecutableDirective(D);
2425}
2426
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002427void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2428 VisitStmt(D);
2429 VisitOMPExecutableDirective(D);
2430}
2431
Alexey Bataev2df347a2014-07-18 10:17:07 +00002432void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2433 VisitStmt(D);
2434 VisitOMPExecutableDirective(D);
2435}
2436
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002437void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2438 VisitStmt(D);
Alexey Bataev169d96a2017-07-18 20:17:46 +00002439 // The NumClauses field was read in ReadStmtFromStream.
2440 Record.skipInts(1);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002441 VisitOMPExecutableDirective(D);
Alexey Bataev3b1b8952017-07-25 15:53:26 +00002442 D->setReductionRef(Record.readSubExpr());
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002443}
2444
Alexey Bataev6125da92014-07-21 11:26:11 +00002445void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2446 VisitStmt(D);
2447 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002448 Record.skipInts(1);
Alexey Bataev6125da92014-07-21 11:26:11 +00002449 VisitOMPExecutableDirective(D);
2450}
2451
Alexey Bataevc112e942020-02-28 09:52:15 -05002452void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective *D) {
2453 VisitStmt(D);
2454 // The NumClauses field was read in ReadStmtFromStream.
2455 Record.skipInts(1);
2456 VisitOMPExecutableDirective(D);
2457}
2458
Alexey Bataevfcba7c32020-03-20 07:03:01 -04002459void ASTStmtReader::VisitOMPScanDirective(OMPScanDirective *D) {
2460 VisitStmt(D);
2461 // The NumClauses field was read in ReadStmtFromStream.
2462 Record.skipInts(1);
2463 VisitOMPExecutableDirective(D);
2464}
2465
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002466void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2467 VisitStmt(D);
Alexey Bataev346265e2015-09-25 10:37:12 +00002468 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002469 Record.skipInts(1);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002470 VisitOMPExecutableDirective(D);
2471}
2472
Alexey Bataev0162e452014-07-22 10:10:35 +00002473void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2474 VisitStmt(D);
2475 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002476 Record.skipInts(1);
Alexey Bataev0162e452014-07-22 10:10:35 +00002477 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002478 D->setX(Record.readSubExpr());
2479 D->setV(Record.readSubExpr());
2480 D->setExpr(Record.readSubExpr());
2481 D->setUpdateExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002482 D->IsXLHSInRHSPart = Record.readInt() != 0;
2483 D->IsPostfixUpdate = Record.readInt() != 0;
Alexey Bataev0162e452014-07-22 10:10:35 +00002484}
2485
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002486void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2487 VisitStmt(D);
2488 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002489 Record.skipInts(1);
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002490 VisitOMPExecutableDirective(D);
2491}
2492
Michael Wong65f367f2015-07-21 13:44:28 +00002493void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2494 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002495 Record.skipInts(1);
Michael Wong65f367f2015-07-21 13:44:28 +00002496 VisitOMPExecutableDirective(D);
2497}
2498
Samuel Antaodf67fc42016-01-19 19:15:56 +00002499void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2500 OMPTargetEnterDataDirective *D) {
2501 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002502 Record.skipInts(1);
Samuel Antaodf67fc42016-01-19 19:15:56 +00002503 VisitOMPExecutableDirective(D);
2504}
2505
Samuel Antao72590762016-01-19 20:04:50 +00002506void ASTStmtReader::VisitOMPTargetExitDataDirective(
2507 OMPTargetExitDataDirective *D) {
2508 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002509 Record.skipInts(1);
Samuel Antao72590762016-01-19 20:04:50 +00002510 VisitOMPExecutableDirective(D);
2511}
2512
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002513void ASTStmtReader::VisitOMPTargetParallelDirective(
2514 OMPTargetParallelDirective *D) {
2515 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002516 Record.skipInts(1);
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002517 VisitOMPExecutableDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002518 D->setTaskReductionRefExpr(Record.readSubExpr());
Alexey Bataevb737b812020-04-27 11:37:35 -04002519 D->setHasCancel(Record.readBool());
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002520}
2521
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002522void ASTStmtReader::VisitOMPTargetParallelForDirective(
2523 OMPTargetParallelForDirective *D) {
2524 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002525 D->setTaskReductionRefExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002526 D->setHasCancel(Record.readInt());
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002527}
2528
Alexey Bataev13314bf2014-10-09 04:18:56 +00002529void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2530 VisitStmt(D);
2531 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002532 Record.skipInts(1);
Alexey Bataev13314bf2014-10-09 04:18:56 +00002533 VisitOMPExecutableDirective(D);
2534}
2535
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002536void ASTStmtReader::VisitOMPCancellationPointDirective(
2537 OMPCancellationPointDirective *D) {
2538 VisitStmt(D);
2539 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002540 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002541}
2542
Alexey Bataev80909872015-07-02 11:25:17 +00002543void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2544 VisitStmt(D);
Alexey Bataev87933c72015-09-18 08:07:34 +00002545 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002546 Record.skipInts(1);
Alexey Bataev80909872015-07-02 11:25:17 +00002547 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002548 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev80909872015-07-02 11:25:17 +00002549}
2550
Alexey Bataev49f6e782015-12-01 04:18:41 +00002551void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2552 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002553 D->setHasCancel(Record.readInt());
Alexey Bataev49f6e782015-12-01 04:18:41 +00002554}
2555
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002556void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2557 VisitOMPLoopDirective(D);
2558}
2559
Alexey Bataev60e51c42019-10-10 20:13:02 +00002560void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2561 OMPMasterTaskLoopDirective *D) {
2562 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002563 D->setHasCancel(Record.readInt());
Alexey Bataev60e51c42019-10-10 20:13:02 +00002564}
2565
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002566void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2567 OMPMasterTaskLoopSimdDirective *D) {
2568 VisitOMPLoopDirective(D);
2569}
2570
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002571void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2572 OMPParallelMasterTaskLoopDirective *D) {
2573 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002574 D->setHasCancel(Record.readInt());
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002575}
2576
Alexey Bataev14a388f2019-10-25 10:27:13 -04002577void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2578 OMPParallelMasterTaskLoopSimdDirective *D) {
2579 VisitOMPLoopDirective(D);
2580}
2581
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002582void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2583 VisitOMPLoopDirective(D);
2584}
2585
Samuel Antao686c70c2016-05-26 17:30:50 +00002586void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2587 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002588 Record.skipInts(1);
Samuel Antao686c70c2016-05-26 17:30:50 +00002589 VisitOMPExecutableDirective(D);
2590}
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002591
Carlo Bertolli9925f152016-06-27 14:55:37 +00002592void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2593 OMPDistributeParallelForDirective *D) {
2594 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002595 D->setTaskReductionRefExpr(Record.readSubExpr());
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002596 D->setHasCancel(Record.readInt());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002597}
Samuel Antao686c70c2016-05-26 17:30:50 +00002598
Kelvin Li4a39add2016-07-05 05:00:15 +00002599void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2600 OMPDistributeParallelForSimdDirective *D) {
2601 VisitOMPLoopDirective(D);
2602}
2603
Kelvin Li787f3fc2016-07-06 04:45:38 +00002604void ASTStmtReader::VisitOMPDistributeSimdDirective(
2605 OMPDistributeSimdDirective *D) {
2606 VisitOMPLoopDirective(D);
2607}
2608
Kelvin Lia579b912016-07-14 02:54:56 +00002609void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2610 OMPTargetParallelForSimdDirective *D) {
2611 VisitOMPLoopDirective(D);
2612}
2613
Kelvin Li986330c2016-07-20 22:57:10 +00002614void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2615 VisitOMPLoopDirective(D);
2616}
2617
Kelvin Li02532872016-08-05 14:37:37 +00002618void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2619 OMPTeamsDistributeDirective *D) {
2620 VisitOMPLoopDirective(D);
2621}
2622
Kelvin Li4e325f72016-10-25 12:50:55 +00002623void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2624 OMPTeamsDistributeSimdDirective *D) {
2625 VisitOMPLoopDirective(D);
2626}
2627
Kelvin Li579e41c2016-11-30 23:51:03 +00002628void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2629 OMPTeamsDistributeParallelForSimdDirective *D) {
2630 VisitOMPLoopDirective(D);
2631}
2632
Kelvin Li7ade93f2016-12-09 03:24:30 +00002633void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2634 OMPTeamsDistributeParallelForDirective *D) {
2635 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002636 D->setTaskReductionRefExpr(Record.readSubExpr());
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002637 D->setHasCancel(Record.readInt());
Kelvin Li7ade93f2016-12-09 03:24:30 +00002638}
2639
Kelvin Libf594a52016-12-17 05:48:59 +00002640void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2641 VisitStmt(D);
2642 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002643 Record.skipInts(1);
Kelvin Libf594a52016-12-17 05:48:59 +00002644 VisitOMPExecutableDirective(D);
2645}
2646
Kelvin Li83c451e2016-12-25 04:52:54 +00002647void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2648 OMPTargetTeamsDistributeDirective *D) {
2649 VisitOMPLoopDirective(D);
2650}
2651
Kelvin Li80e8f562016-12-29 22:16:30 +00002652void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2653 OMPTargetTeamsDistributeParallelForDirective *D) {
2654 VisitOMPLoopDirective(D);
Alexey Bataev8c2f4e02020-04-24 09:56:29 -04002655 D->setTaskReductionRefExpr(Record.readSubExpr());
Alexey Bataev16e79882017-11-22 21:12:03 +00002656 D->setHasCancel(Record.readInt());
Kelvin Li80e8f562016-12-29 22:16:30 +00002657}
2658
Kelvin Li1851df52017-01-03 05:23:48 +00002659void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2660 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2661 VisitOMPLoopDirective(D);
2662}
2663
Kelvin Lida681182017-01-10 18:08:18 +00002664void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2665 OMPTargetTeamsDistributeSimdDirective *D) {
2666 VisitOMPLoopDirective(D);
2667}
2668
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002669//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002670// ASTReader Implementation
2671//===----------------------------------------------------------------------===//
2672
Douglas Gregorde3ef502011-11-30 23:21:26 +00002673Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002674 switch (ReadingKind) {
Richard Smith629ff362013-07-31 00:26:46 +00002675 case Read_None:
2676 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002677 case Read_Decl:
2678 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00002679 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002680 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002681 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002682 }
2683
2684 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002685}
2686
Douglas Gregorde3ef502011-11-30 23:21:26 +00002687Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00002688 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002689}
Chris Lattnere2437f42010-05-09 06:40:08 +00002690
Sebastian Redl2c499f62010-08-18 23:56:43 +00002691Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002692 return cast_or_null<Expr>(ReadSubStmt());
2693}
2694
Chris Lattnerf4262532009-04-27 05:41:06 +00002695// Within the bitstream, expressions are stored in Reverse Polish
2696// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002697// expression they are stored in. Subexpressions are stored from last to first.
2698// To evaluate expressions, we continue reading expressions and placing them on
2699// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00002700// stack. Evaluation terminates when we see a STMT_STOP record, and
2701// the single remaining expression on the stack is our result.
Douglas Gregorde3ef502011-11-30 23:21:26 +00002702Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002703 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00002704 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002705
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002706 // Map of offset to previously deserialized stmt. The offset points
George Burgess IV758cf9d2017-02-14 05:52:57 +00002707 // just after the stmt record.
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002708 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00002709
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002710#ifndef NDEBUG
2711 unsigned PrevNumStmts = StmtStack.size();
2712#endif
2713
David L. Jonesbe1557a2016-12-21 00:17:49 +00002714 ASTRecordReader Record(*this, F);
2715 ASTStmtReader Reader(Record, Cursor);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002716 Stmt::EmptyShell Empty;
2717
2718 while (true) {
JF Bastien0e828952019-06-26 19:50:12 +00002719 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2720 Cursor.advanceSkippingSubblocks();
2721 if (!MaybeEntry) {
2722 Error(toString(MaybeEntry.takeError()));
2723 return nullptr;
2724 }
2725 llvm::BitstreamEntry Entry = MaybeEntry.get();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002726
Chris Lattner0e6c9402013-01-20 02:38:54 +00002727 switch (Entry.Kind) {
2728 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2729 case llvm::BitstreamEntry::Error:
2730 Error("malformed block record in AST file");
Craig Toppera13603a2014-05-22 05:54:18 +00002731 return nullptr;
Chris Lattner0e6c9402013-01-20 02:38:54 +00002732 case llvm::BitstreamEntry::EndBlock:
2733 goto Done;
2734 case llvm::BitstreamEntry::Record:
2735 // The interesting case.
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002736 break;
2737 }
2738
Richard Smithdbafb6c2017-06-29 23:23:46 +00002739 ASTContext &Context = getContext();
Craig Toppera13603a2014-05-22 05:54:18 +00002740 Stmt *S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002741 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002742 bool IsStmtReference = false;
JF Bastien0e828952019-06-26 19:50:12 +00002743 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2744 if (!MaybeStmtCode) {
2745 Error(toString(MaybeStmtCode.takeError()));
2746 return nullptr;
2747 }
2748 switch ((StmtCode)MaybeStmtCode.get()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00002749 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002750 Finished = true;
2751 break;
2752
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002753 case STMT_REF_PTR:
2754 IsStmtReference = true;
2755 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2756 "No stmt was recorded for this offset reference!");
David L. Jonesbe1557a2016-12-21 00:17:49 +00002757 S = StmtEntries[Record.readInt()];
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002758 break;
2759
Sebastian Redl539c5062010-08-18 23:57:32 +00002760 case STMT_NULL_PTR:
Craig Toppera13603a2014-05-22 05:54:18 +00002761 S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002762 break;
2763
Sebastian Redl539c5062010-08-18 23:57:32 +00002764 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002765 S = new (Context) NullStmt(Empty);
2766 break;
2767
Sebastian Redl539c5062010-08-18 23:57:32 +00002768 case STMT_COMPOUND:
Benjamin Kramer07420902017-12-24 16:24:20 +00002769 S = CompoundStmt::CreateEmpty(
2770 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002771 break;
2772
Sebastian Redl539c5062010-08-18 23:57:32 +00002773 case STMT_CASE:
Bruno Ricci5b30571752018-10-28 12:30:53 +00002774 S = CaseStmt::CreateEmpty(
2775 Context,
2776 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002777 break;
2778
Sebastian Redl539c5062010-08-18 23:57:32 +00002779 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002780 S = new (Context) DefaultStmt(Empty);
2781 break;
2782
Sebastian Redl539c5062010-08-18 23:57:32 +00002783 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002784 S = new (Context) LabelStmt(Empty);
2785 break;
2786
Richard Smithc202b282012-04-14 00:33:13 +00002787 case STMT_ATTRIBUTED:
Alexander Kornienko20f6fc62012-07-09 10:04:07 +00002788 S = AttributedStmt::CreateEmpty(
2789 Context,
2790 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smithc202b282012-04-14 00:33:13 +00002791 break;
2792
Sebastian Redl539c5062010-08-18 23:57:32 +00002793 case STMT_IF:
Bruno Riccib1cc94b2018-10-27 21:12:20 +00002794 S = IfStmt::CreateEmpty(
2795 Context,
2796 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2797 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2798 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002799 break;
2800
Sebastian Redl539c5062010-08-18 23:57:32 +00002801 case STMT_SWITCH:
Bruno Riccie2806f82018-10-29 16:12:37 +00002802 S = SwitchStmt::CreateEmpty(
2803 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002804 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
Bruno Riccie2806f82018-10-29 16:12:37 +00002805 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002806 break;
2807
Sebastian Redl539c5062010-08-18 23:57:32 +00002808 case STMT_WHILE:
Bruno Riccibacf7512018-10-30 13:42:41 +00002809 S = WhileStmt::CreateEmpty(
2810 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002811 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002812 break;
2813
Sebastian Redl539c5062010-08-18 23:57:32 +00002814 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002815 S = new (Context) DoStmt(Empty);
2816 break;
Mike Stump11289f42009-09-09 15:08:12 +00002817
Sebastian Redl539c5062010-08-18 23:57:32 +00002818 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002819 S = new (Context) ForStmt(Empty);
2820 break;
2821
Sebastian Redl539c5062010-08-18 23:57:32 +00002822 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002823 S = new (Context) GotoStmt(Empty);
2824 break;
Mike Stump11289f42009-09-09 15:08:12 +00002825
Sebastian Redl539c5062010-08-18 23:57:32 +00002826 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002827 S = new (Context) IndirectGotoStmt(Empty);
2828 break;
2829
Sebastian Redl539c5062010-08-18 23:57:32 +00002830 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002831 S = new (Context) ContinueStmt(Empty);
2832 break;
2833
Sebastian Redl539c5062010-08-18 23:57:32 +00002834 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002835 S = new (Context) BreakStmt(Empty);
2836 break;
2837
Sebastian Redl539c5062010-08-18 23:57:32 +00002838 case STMT_RETURN:
Bruno Ricci023b1d12018-10-30 14:40:49 +00002839 S = ReturnStmt::CreateEmpty(
2840 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002841 break;
2842
Sebastian Redl539c5062010-08-18 23:57:32 +00002843 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002844 S = new (Context) DeclStmt(Empty);
2845 break;
2846
Chad Rosierde70e0e2012-08-25 00:11:56 +00002847 case STMT_GCCASM:
2848 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002849 break;
2850
Chad Rosiere30d4992012-08-24 23:51:02 +00002851 case STMT_MSASM:
2852 S = new (Context) MSAsmStmt(Empty);
2853 break;
2854
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002855 case STMT_CAPTURED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002856 S = CapturedStmt::CreateDeserialized(
2857 Context, Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002858 break;
2859
Bill Wendling7c44da22018-10-31 03:48:47 +00002860 case EXPR_CONSTANT:
Gauthier Harnisch83c7b612019-06-15 10:24:47 +00002861 S = ConstantExpr::CreateEmpty(
2862 Context,
2863 static_cast<ConstantExpr::ResultStorageKind>(
2864 Record[ASTStmtReader::NumExprFields]),
2865 Empty);
Bill Wendling7c44da22018-10-31 03:48:47 +00002866 break;
2867
Sebastian Redl539c5062010-08-18 23:57:32 +00002868 case EXPR_PREDEFINED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002869 S = PredefinedExpr::CreateEmpty(
2870 Context,
2871 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002872 break;
Mike Stump11289f42009-09-09 15:08:12 +00002873
Sebastian Redl539c5062010-08-18 23:57:32 +00002874 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002875 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00002876 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002877 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2878 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnara7945c982012-01-27 09:46:47 +00002879 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002880 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Richard Smith715f7a12019-06-11 17:50:32 +00002881 Record[ASTStmtReader::NumExprFields + 6] : 0);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002882 break;
Mike Stump11289f42009-09-09 15:08:12 +00002883
Sebastian Redl539c5062010-08-18 23:57:32 +00002884 case EXPR_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002885 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002886 break;
Mike Stump11289f42009-09-09 15:08:12 +00002887
Vince Bridgers161fc1d2020-04-07 14:46:08 -05002888 case EXPR_FIXEDPOINT_LITERAL:
2889 S = FixedPointLiteral::Create(Context, Empty);
2890 break;
2891
Sebastian Redl539c5062010-08-18 23:57:32 +00002892 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002893 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002894 break;
Mike Stump11289f42009-09-09 15:08:12 +00002895
Sebastian Redl539c5062010-08-18 23:57:32 +00002896 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002897 S = new (Context) ImaginaryLiteral(Empty);
2898 break;
2899
Sebastian Redl539c5062010-08-18 23:57:32 +00002900 case EXPR_STRING_LITERAL:
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002901 S = StringLiteral::CreateEmpty(
2902 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002903 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002904 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2905 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002906 break;
2907
Sebastian Redl539c5062010-08-18 23:57:32 +00002908 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002909 S = new (Context) CharacterLiteral(Empty);
2910 break;
2911
Sebastian Redl539c5062010-08-18 23:57:32 +00002912 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002913 S = new (Context) ParenExpr(Empty);
2914 break;
2915
Sebastian Redl539c5062010-08-18 23:57:32 +00002916 case EXPR_PAREN_LIST:
Bruno Riccif49e1ca2018-11-20 16:20:40 +00002917 S = ParenListExpr::CreateEmpty(
2918 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002919 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00002920 break;
2921
Sebastian Redl539c5062010-08-18 23:57:32 +00002922 case EXPR_UNARY_OPERATOR:
Melanie Blowerf5360d42020-05-01 10:32:06 -07002923 S = UnaryOperator::CreateEmpty(Context,
2924 Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002925 break;
2926
Sebastian Redl539c5062010-08-18 23:57:32 +00002927 case EXPR_OFFSETOF:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002928 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002929 Record[ASTStmtReader::NumExprFields],
2930 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00002931 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002932
Sebastian Redl539c5062010-08-18 23:57:32 +00002933 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00002934 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002935 break;
2936
Sebastian Redl539c5062010-08-18 23:57:32 +00002937 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002938 S = new (Context) ArraySubscriptExpr(Empty);
2939 break;
2940
Florian Hahn8f3f88d2020-06-01 19:42:03 +01002941 case EXPR_MATRIX_SUBSCRIPT:
2942 S = new (Context) MatrixSubscriptExpr(Empty);
2943 break;
2944
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002945 case EXPR_OMP_ARRAY_SECTION:
2946 S = new (Context) OMPArraySectionExpr(Empty);
2947 break;
2948
Alexey Bataev7ac9efb2020-02-05 09:33:05 -05002949 case EXPR_OMP_ARRAY_SHAPING:
2950 S = OMPArrayShapingExpr::CreateEmpty(
2951 Context, Record[ASTStmtReader::NumExprFields]);
2952 break;
2953
Alexey Bataev13a15042020-04-01 15:06:38 -04002954 case EXPR_OMP_ITERATOR:
2955 S = OMPIteratorExpr::CreateEmpty(Context,
2956 Record[ASTStmtReader::NumExprFields]);
2957 break;
2958
Sebastian Redl539c5062010-08-18 23:57:32 +00002959 case EXPR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00002960 S = CallExpr::CreateEmpty(
2961 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002962 break;
2963
Haojian Wu733edf92020-03-19 16:30:40 +01002964 case EXPR_RECOVERY:
2965 S = RecoveryExpr::CreateEmpty(
2966 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
2967 break;
2968
Richard Smithdcf17de2019-06-06 23:24:15 +00002969 case EXPR_MEMBER:
2970 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
2971 Record[ASTStmtReader::NumExprFields + 1],
2972 Record[ASTStmtReader::NumExprFields + 2],
2973 Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002974 break;
2975
Sebastian Redl539c5062010-08-18 23:57:32 +00002976 case EXPR_BINARY_OPERATOR:
Melanie Blower2ba4e3a2020-04-10 13:34:46 -07002977 S = BinaryOperator::CreateEmpty(Context,
2978 Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002979 break;
2980
Sebastian Redl539c5062010-08-18 23:57:32 +00002981 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Melanie Blower2ba4e3a2020-04-10 13:34:46 -07002982 S = CompoundAssignOperator::CreateEmpty(
2983 Context, Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002984 break;
2985
Sebastian Redl539c5062010-08-18 23:57:32 +00002986 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002987 S = new (Context) ConditionalOperator(Empty);
2988 break;
2989
John McCallc07a0c72011-02-17 10:25:35 +00002990 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2991 S = new (Context) BinaryConditionalOperator(Empty);
2992 break;
2993
Sebastian Redl539c5062010-08-18 23:57:32 +00002994 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002995 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002996 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002997 break;
2998
Sebastian Redl539c5062010-08-18 23:57:32 +00002999 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003000 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003001 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003002 break;
3003
Sebastian Redl539c5062010-08-18 23:57:32 +00003004 case EXPR_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003005 S = new (Context) CompoundLiteralExpr(Empty);
3006 break;
3007
Sebastian Redl539c5062010-08-18 23:57:32 +00003008 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003009 S = new (Context) ExtVectorElementExpr(Empty);
3010 break;
3011
Sebastian Redl539c5062010-08-18 23:57:32 +00003012 case EXPR_INIT_LIST:
Argyrios Kyrtzidis0f05fb92012-11-28 03:56:16 +00003013 S = new (Context) InitListExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003014 break;
3015
Sebastian Redl539c5062010-08-18 23:57:32 +00003016 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003017 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003018 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00003019
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003020 break;
3021
Yunzhong Gaocb779302015-06-10 00:27:52 +00003022 case EXPR_DESIGNATED_INIT_UPDATE:
3023 S = new (Context) DesignatedInitUpdateExpr(Empty);
3024 break;
3025
Sebastian Redl539c5062010-08-18 23:57:32 +00003026 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003027 S = new (Context) ImplicitValueInitExpr(Empty);
3028 break;
3029
Yunzhong Gaocb779302015-06-10 00:27:52 +00003030 case EXPR_NO_INIT:
3031 S = new (Context) NoInitExpr(Empty);
3032 break;
3033
Richard Smith410306b2016-12-12 02:53:20 +00003034 case EXPR_ARRAY_INIT_LOOP:
3035 S = new (Context) ArrayInitLoopExpr(Empty);
3036 break;
3037
3038 case EXPR_ARRAY_INIT_INDEX:
3039 S = new (Context) ArrayInitIndexExpr(Empty);
3040 break;
3041
Sebastian Redl539c5062010-08-18 23:57:32 +00003042 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003043 S = new (Context) VAArgExpr(Empty);
3044 break;
3045
Eric Fiselier708afb52019-05-16 21:04:15 +00003046 case EXPR_SOURCE_LOC:
3047 S = new (Context) SourceLocExpr(Empty);
3048 break;
3049
Sebastian Redl539c5062010-08-18 23:57:32 +00003050 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003051 S = new (Context) AddrLabelExpr(Empty);
3052 break;
3053
Sebastian Redl539c5062010-08-18 23:57:32 +00003054 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003055 S = new (Context) StmtExpr(Empty);
3056 break;
3057
Sebastian Redl539c5062010-08-18 23:57:32 +00003058 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003059 S = new (Context) ChooseExpr(Empty);
3060 break;
3061
Sebastian Redl539c5062010-08-18 23:57:32 +00003062 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003063 S = new (Context) GNUNullExpr(Empty);
3064 break;
3065
Sebastian Redl539c5062010-08-18 23:57:32 +00003066 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003067 S = new (Context) ShuffleVectorExpr(Empty);
3068 break;
Mike Stump11289f42009-09-09 15:08:12 +00003069
Hal Finkelc4d7c822013-09-18 03:29:45 +00003070 case EXPR_CONVERT_VECTOR:
3071 S = new (Context) ConvertVectorExpr(Empty);
3072 break;
3073
Sebastian Redl539c5062010-08-18 23:57:32 +00003074 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003075 S = new (Context) BlockExpr(Empty);
3076 break;
3077
Peter Collingbourne91147592011-04-15 00:35:48 +00003078 case EXPR_GENERIC_SELECTION:
Bruno Riccidb076832019-01-26 14:15:10 +00003079 S = GenericSelectionExpr::CreateEmpty(
3080 Context,
3081 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
Peter Collingbourne91147592011-04-15 00:35:48 +00003082 break;
3083
Sebastian Redl539c5062010-08-18 23:57:32 +00003084 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003085 S = new (Context) ObjCStringLiteral(Empty);
3086 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003087
Patrick Beard0caa3942012-04-19 00:25:12 +00003088 case EXPR_OBJC_BOXED_EXPRESSION:
3089 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremeneke65b0862012-03-06 20:05:56 +00003090 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003091
Ted Kremeneke65b0862012-03-06 20:05:56 +00003092 case EXPR_OBJC_ARRAY_LITERAL:
3093 S = ObjCArrayLiteral::CreateEmpty(Context,
3094 Record[ASTStmtReader::NumExprFields]);
3095 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003096
Ted Kremeneke65b0862012-03-06 20:05:56 +00003097 case EXPR_OBJC_DICTIONARY_LITERAL:
3098 S = ObjCDictionaryLiteral::CreateEmpty(Context,
3099 Record[ASTStmtReader::NumExprFields],
3100 Record[ASTStmtReader::NumExprFields + 1]);
3101 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003102
Sebastian Redl539c5062010-08-18 23:57:32 +00003103 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003104 S = new (Context) ObjCEncodeExpr(Empty);
3105 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003106
Sebastian Redl539c5062010-08-18 23:57:32 +00003107 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003108 S = new (Context) ObjCSelectorExpr(Empty);
3109 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003110
Sebastian Redl539c5062010-08-18 23:57:32 +00003111 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003112 S = new (Context) ObjCProtocolExpr(Empty);
3113 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003114
Sebastian Redl539c5062010-08-18 23:57:32 +00003115 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003116 S = new (Context) ObjCIvarRefExpr(Empty);
3117 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003118
Sebastian Redl539c5062010-08-18 23:57:32 +00003119 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003120 S = new (Context) ObjCPropertyRefExpr(Empty);
3121 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003122
Ted Kremeneke65b0862012-03-06 20:05:56 +00003123 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
3124 S = new (Context) ObjCSubscriptRefExpr(Empty);
3125 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003126
Sebastian Redl539c5062010-08-18 23:57:32 +00003127 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00003128 llvm_unreachable("mismatching AST file");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003129
Sebastian Redl539c5062010-08-18 23:57:32 +00003130 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003131 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00003132 Record[ASTStmtReader::NumExprFields],
3133 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003134 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003135
Sebastian Redl539c5062010-08-18 23:57:32 +00003136 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00003137 S = new (Context) ObjCIsaExpr(Empty);
3138 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003139
John McCall31168b02011-06-15 23:02:42 +00003140 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
3141 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
3142 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003143
John McCall31168b02011-06-15 23:02:42 +00003144 case EXPR_OBJC_BRIDGED_CAST:
3145 S = new (Context) ObjCBridgedCastExpr(Empty);
3146 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003147
Sebastian Redl539c5062010-08-18 23:57:32 +00003148 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003149 S = new (Context) ObjCForCollectionStmt(Empty);
3150 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003151
Sebastian Redl539c5062010-08-18 23:57:32 +00003152 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003153 S = new (Context) ObjCAtCatchStmt(Empty);
3154 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003155
Sebastian Redl539c5062010-08-18 23:57:32 +00003156 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003157 S = new (Context) ObjCAtFinallyStmt(Empty);
3158 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003159
Sebastian Redl539c5062010-08-18 23:57:32 +00003160 case STMT_OBJC_AT_TRY:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003161 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003162 Record[ASTStmtReader::NumStmtFields],
3163 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003164 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003165
Sebastian Redl539c5062010-08-18 23:57:32 +00003166 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003167 S = new (Context) ObjCAtSynchronizedStmt(Empty);
3168 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003169
Sebastian Redl539c5062010-08-18 23:57:32 +00003170 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003171 S = new (Context) ObjCAtThrowStmt(Empty);
3172 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003173
John McCall31168b02011-06-15 23:02:42 +00003174 case STMT_OBJC_AUTORELEASE_POOL:
3175 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3176 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003177
Ted Kremeneke65b0862012-03-06 20:05:56 +00003178 case EXPR_OBJC_BOOL_LITERAL:
3179 S = new (Context) ObjCBoolLiteralExpr(Empty);
3180 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003181
Erik Pilkington29099de2016-07-16 00:35:23 +00003182 case EXPR_OBJC_AVAILABILITY_CHECK:
3183 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3184 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003185
Nico Weber9b982072014-07-07 00:12:30 +00003186 case STMT_SEH_LEAVE:
3187 S = new (Context) SEHLeaveStmt(Empty);
3188 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003189
John McCallfa194042011-07-15 07:00:14 +00003190 case STMT_SEH_EXCEPT:
3191 S = new (Context) SEHExceptStmt(Empty);
3192 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003193
John McCallfa194042011-07-15 07:00:14 +00003194 case STMT_SEH_FINALLY:
3195 S = new (Context) SEHFinallyStmt(Empty);
3196 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003197
John McCallfa194042011-07-15 07:00:14 +00003198 case STMT_SEH_TRY:
3199 S = new (Context) SEHTryStmt(Empty);
3200 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003201
Sebastian Redl539c5062010-08-18 23:57:32 +00003202 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003203 S = new (Context) CXXCatchStmt(Empty);
3204 break;
3205
Sebastian Redl539c5062010-08-18 23:57:32 +00003206 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003207 S = CXXTryStmt::Create(Context, Empty,
Rui Ueyama49a3ad22019-07-16 04:46:31 +00003208 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003209 break;
3210
Richard Smith02e85f32011-04-14 22:09:26 +00003211 case STMT_CXX_FOR_RANGE:
3212 S = new (Context) CXXForRangeStmt(Empty);
3213 break;
3214
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003215 case STMT_MS_DEPENDENT_EXISTS:
3216 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3217 NestedNameSpecifierLoc(),
3218 DeclarationNameInfo(),
Craig Toppera13603a2014-05-22 05:54:18 +00003219 nullptr);
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003220 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003221
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00003222 case STMT_OMP_PARALLEL_DIRECTIVE:
3223 S =
3224 OMPParallelDirective::CreateEmpty(Context,
3225 Record[ASTStmtReader::NumStmtFields],
3226 Empty);
3227 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003228
3229 case STMT_OMP_SIMD_DIRECTIVE: {
3230 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3231 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3232 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3233 CollapsedNum, Empty);
3234 break;
3235 }
3236
Alexey Bataevf29276e2014-06-18 04:14:57 +00003237 case STMT_OMP_FOR_DIRECTIVE: {
3238 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3239 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3240 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3241 Empty);
3242 break;
3243 }
3244
Alexander Musmanf82886e2014-09-18 05:12:34 +00003245 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3246 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3247 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3248 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3249 Empty);
3250 break;
3251 }
3252
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00003253 case STMT_OMP_SECTIONS_DIRECTIVE:
3254 S = OMPSectionsDirective::CreateEmpty(
3255 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3256 break;
3257
Alexey Bataev1e0498a2014-06-26 08:21:58 +00003258 case STMT_OMP_SECTION_DIRECTIVE:
3259 S = OMPSectionDirective::CreateEmpty(Context, Empty);
3260 break;
3261
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00003262 case STMT_OMP_SINGLE_DIRECTIVE:
3263 S = OMPSingleDirective::CreateEmpty(
3264 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3265 break;
3266
Alexander Musman80c22892014-07-17 08:54:58 +00003267 case STMT_OMP_MASTER_DIRECTIVE:
3268 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3269 break;
3270
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003271 case STMT_OMP_CRITICAL_DIRECTIVE:
Alexey Bataev28c75412015-12-15 08:19:24 +00003272 S = OMPCriticalDirective::CreateEmpty(
3273 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003274 break;
3275
Alexey Bataev4acb8592014-07-07 13:01:15 +00003276 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3277 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3278 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3279 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3280 CollapsedNum, Empty);
3281 break;
3282 }
3283
Alexander Musmane4e893b2014-09-23 09:33:00 +00003284 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3285 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3286 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3287 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3288 CollapsedNum, Empty);
3289 break;
3290 }
3291
cchen47d60942019-12-05 13:43:48 -05003292 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3293 S = OMPParallelMasterDirective::CreateEmpty(
3294 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3295 break;
3296
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00003297 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3298 S = OMPParallelSectionsDirective::CreateEmpty(
3299 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3300 break;
3301
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00003302 case STMT_OMP_TASK_DIRECTIVE:
3303 S = OMPTaskDirective::CreateEmpty(
3304 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3305 break;
3306
Alexey Bataev68446b72014-07-18 07:47:19 +00003307 case STMT_OMP_TASKYIELD_DIRECTIVE:
3308 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3309 break;
3310
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00003311 case STMT_OMP_BARRIER_DIRECTIVE:
3312 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3313 break;
3314
Alexey Bataev2df347a2014-07-18 10:17:07 +00003315 case STMT_OMP_TASKWAIT_DIRECTIVE:
3316 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3317 break;
3318
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003319 case STMT_OMP_TASKGROUP_DIRECTIVE:
Alexey Bataev169d96a2017-07-18 20:17:46 +00003320 S = OMPTaskgroupDirective::CreateEmpty(
3321 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003322 break;
3323
Alexey Bataev6125da92014-07-21 11:26:11 +00003324 case STMT_OMP_FLUSH_DIRECTIVE:
3325 S = OMPFlushDirective::CreateEmpty(
3326 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3327 break;
3328
Alexey Bataevc112e942020-02-28 09:52:15 -05003329 case STMT_OMP_DEPOBJ_DIRECTIVE:
3330 S = OMPDepobjDirective::CreateEmpty(
3331 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3332 break;
3333
Alexey Bataevfcba7c32020-03-20 07:03:01 -04003334 case STMT_OMP_SCAN_DIRECTIVE:
3335 S = OMPScanDirective::CreateEmpty(
3336 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3337 break;
3338
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003339 case STMT_OMP_ORDERED_DIRECTIVE:
Alexey Bataev346265e2015-09-25 10:37:12 +00003340 S = OMPOrderedDirective::CreateEmpty(
3341 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003342 break;
3343
Alexey Bataev0162e452014-07-22 10:10:35 +00003344 case STMT_OMP_ATOMIC_DIRECTIVE:
3345 S = OMPAtomicDirective::CreateEmpty(
3346 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3347 break;
3348
Alexey Bataev0bd520b2014-09-19 08:19:49 +00003349 case STMT_OMP_TARGET_DIRECTIVE:
3350 S = OMPTargetDirective::CreateEmpty(
3351 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3352 break;
3353
Michael Wong65f367f2015-07-21 13:44:28 +00003354 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3355 S = OMPTargetDataDirective::CreateEmpty(
3356 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3357 break;
3358
Samuel Antaodf67fc42016-01-19 19:15:56 +00003359 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3360 S = OMPTargetEnterDataDirective::CreateEmpty(
3361 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3362 break;
3363
Samuel Antao72590762016-01-19 20:04:50 +00003364 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3365 S = OMPTargetExitDataDirective::CreateEmpty(
3366 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3367 break;
3368
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00003369 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3370 S = OMPTargetParallelDirective::CreateEmpty(
3371 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3372 break;
3373
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00003374 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3375 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3376 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3377 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3378 CollapsedNum, Empty);
3379 break;
3380 }
3381
Samuel Antao686c70c2016-05-26 17:30:50 +00003382 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3383 S = OMPTargetUpdateDirective::CreateEmpty(
3384 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3385 break;
3386
Alexey Bataev13314bf2014-10-09 04:18:56 +00003387 case STMT_OMP_TEAMS_DIRECTIVE:
3388 S = OMPTeamsDirective::CreateEmpty(
3389 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3390 break;
3391
Alexey Bataev6d4ed052015-07-01 06:57:41 +00003392 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3393 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3394 break;
3395
Alexey Bataev80909872015-07-02 11:25:17 +00003396 case STMT_OMP_CANCEL_DIRECTIVE:
Alexey Bataev87933c72015-09-18 08:07:34 +00003397 S = OMPCancelDirective::CreateEmpty(
3398 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev80909872015-07-02 11:25:17 +00003399 break;
3400
Alexey Bataev49f6e782015-12-01 04:18:41 +00003401 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3402 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3403 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3404 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3405 Empty);
3406 break;
3407 }
3408
Alexey Bataev0a6ed842015-12-03 09:40:15 +00003409 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3410 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3411 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3412 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3413 CollapsedNum, Empty);
3414 break;
3415 }
3416
Alexey Bataev60e51c42019-10-10 20:13:02 +00003417 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3418 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3419 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3420 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3421 CollapsedNum, Empty);
3422 break;
3423 }
3424
Alexey Bataevb8552ab2019-10-18 16:47:35 +00003425 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3426 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3427 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3428 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3429 CollapsedNum, Empty);
3430 break;
3431 }
3432
Alexey Bataev5bbcead2019-10-14 17:17:41 +00003433 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3434 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3435 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3436 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3437 CollapsedNum, Empty);
3438 break;
3439 }
3440
Alexey Bataev14a388f2019-10-25 10:27:13 -04003441 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3442 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3443 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3444 S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3445 Context, NumClauses, CollapsedNum, Empty);
3446 break;
3447 }
3448
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00003449 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3450 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3451 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3452 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3453 Empty);
3454 break;
3455 }
3456
Carlo Bertolli9925f152016-06-27 14:55:37 +00003457 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3458 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3459 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3460 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3461 CollapsedNum, Empty);
3462 break;
3463 }
3464
Kelvin Li4a39add2016-07-05 05:00:15 +00003465 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3466 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3467 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3468 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3469 CollapsedNum,
3470 Empty);
3471 break;
3472 }
3473
Kelvin Li787f3fc2016-07-06 04:45:38 +00003474 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3475 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3476 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3477 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3478 CollapsedNum, Empty);
3479 break;
3480 }
3481
Kelvin Lia579b912016-07-14 02:54:56 +00003482 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3483 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3484 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3485 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3486 CollapsedNum, Empty);
3487 break;
3488 }
3489
Kelvin Li986330c2016-07-20 22:57:10 +00003490 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3491 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3492 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3493 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3494 Empty);
3495 break;
3496 }
3497
Kelvin Li83c451e2016-12-25 04:52:54 +00003498 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
Kelvin Li02532872016-08-05 14:37:37 +00003499 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3500 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3501 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3502 CollapsedNum, Empty);
3503 break;
3504 }
3505
Kelvin Li4e325f72016-10-25 12:50:55 +00003506 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3507 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3508 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3509 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3510 CollapsedNum, Empty);
3511 break;
3512 }
3513
Kelvin Li579e41c2016-11-30 23:51:03 +00003514 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3515 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3516 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3517 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3518 Context, NumClauses, CollapsedNum, Empty);
3519 break;
3520 }
3521
Kelvin Li7ade93f2016-12-09 03:24:30 +00003522 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3523 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3524 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3525 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3526 Context, NumClauses, CollapsedNum, Empty);
3527 break;
3528 }
3529
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003530 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
Kelvin Libf594a52016-12-17 05:48:59 +00003531 S = OMPTargetTeamsDirective::CreateEmpty(
3532 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3533 break;
Kelvin Li83c451e2016-12-25 04:52:54 +00003534
3535 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3536 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3537 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3538 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3539 CollapsedNum, Empty);
3540 break;
3541 }
3542
Kelvin Li80e8f562016-12-29 22:16:30 +00003543 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3544 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3545 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3546 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3547 Context, NumClauses, CollapsedNum, Empty);
3548 break;
3549 }
3550
Kelvin Li1851df52017-01-03 05:23:48 +00003551 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3552 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3553 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3554 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3555 Context, NumClauses, CollapsedNum, Empty);
3556 break;
3557 }
3558
Kelvin Lida681182017-01-10 18:08:18 +00003559 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3560 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3561 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3562 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3563 Context, NumClauses, CollapsedNum, Empty);
3564 break;
3565 }
3566
Sebastian Redl539c5062010-08-18 23:57:32 +00003567 case EXPR_CXX_OPERATOR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003568 S = CXXOperatorCallExpr::CreateEmpty(
3569 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00003570 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003571
Sebastian Redl539c5062010-08-18 23:57:32 +00003572 case EXPR_CXX_MEMBER_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003573 S = CXXMemberCallExpr::CreateEmpty(
3574 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003575 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003576
Richard Smith778dc0f2019-10-19 00:04:38 +00003577 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3578 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3579 break;
3580
Sebastian Redl539c5062010-08-18 23:57:32 +00003581 case EXPR_CXX_CONSTRUCT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003582 S = CXXConstructExpr::CreateEmpty(
3583 Context,
3584 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003585 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003586
Richard Smith5179eb72016-06-28 19:03:57 +00003587 case EXPR_CXX_INHERITED_CTOR_INIT:
3588 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3589 break;
3590
Sebastian Redl539c5062010-08-18 23:57:32 +00003591 case EXPR_CXX_TEMPORARY_OBJECT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003592 S = CXXTemporaryObjectExpr::CreateEmpty(
3593 Context,
3594 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00003595 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003596
Sebastian Redl539c5062010-08-18 23:57:32 +00003597 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003598 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003599 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003600 break;
3601
Sebastian Redl539c5062010-08-18 23:57:32 +00003602 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003603 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003604 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003605 break;
3606
Sebastian Redl539c5062010-08-18 23:57:32 +00003607 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003608 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003609 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003610 break;
3611
Sebastian Redl539c5062010-08-18 23:57:32 +00003612 case EXPR_CXX_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003613 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00003614 break;
3615
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01003616 case EXPR_CXX_ADDRSPACE_CAST:
3617 S = CXXAddrspaceCastExpr::CreateEmpty(Context);
3618 break;
3619
Sebastian Redl539c5062010-08-18 23:57:32 +00003620 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003621 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003622 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003623 break;
3624
hyd-dev95d7ccb2020-06-11 12:30:16 -04003625 case EXPR_BUILTIN_BIT_CAST:
3626 assert(Record[ASTStmtReader::NumExprFields] == 0 && "Wrong PathSize!");
3627 S = new (Context) BuiltinBitCastExpr(Empty);
3628 break;
3629
Richard Smithc67fdd42012-03-07 08:35:16 +00003630 case EXPR_USER_DEFINED_LITERAL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003631 S = UserDefinedLiteral::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003632 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Richard Smithc67fdd42012-03-07 08:35:16 +00003633 break;
3634
Richard Smithcc1b96d2013-06-12 22:31:48 +00003635 case EXPR_CXX_STD_INITIALIZER_LIST:
3636 S = new (Context) CXXStdInitializerListExpr(Empty);
3637 break;
3638
Sebastian Redl539c5062010-08-18 23:57:32 +00003639 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003640 S = new (Context) CXXBoolLiteralExpr(Empty);
3641 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003642
Sebastian Redl539c5062010-08-18 23:57:32 +00003643 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003644 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3645 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003646
Sebastian Redl539c5062010-08-18 23:57:32 +00003647 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003648 S = new (Context) CXXTypeidExpr(Empty, true);
3649 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003650
Sebastian Redl539c5062010-08-18 23:57:32 +00003651 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003652 S = new (Context) CXXTypeidExpr(Empty, false);
3653 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003654
Francois Pichet9f4f2072010-09-08 12:20:18 +00003655 case EXPR_CXX_UUIDOF_EXPR:
3656 S = new (Context) CXXUuidofExpr(Empty, true);
3657 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003658
John McCall5e77d762013-04-16 07:28:30 +00003659 case EXPR_CXX_PROPERTY_REF_EXPR:
3660 S = new (Context) MSPropertyRefExpr(Empty);
3661 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003662
Alexey Bataevf7630272015-11-25 12:01:00 +00003663 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3664 S = new (Context) MSPropertySubscriptExpr(Empty);
3665 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003666
Francois Pichet9f4f2072010-09-08 12:20:18 +00003667 case EXPR_CXX_UUIDOF_TYPE:
3668 S = new (Context) CXXUuidofExpr(Empty, false);
3669 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003670
Sebastian Redl539c5062010-08-18 23:57:32 +00003671 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00003672 S = new (Context) CXXThisExpr(Empty);
3673 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003674
Sebastian Redl539c5062010-08-18 23:57:32 +00003675 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00003676 S = new (Context) CXXThrowExpr(Empty);
3677 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003678
John McCall32791cc2016-01-06 22:34:54 +00003679 case EXPR_CXX_DEFAULT_ARG:
3680 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00003681 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003682
Richard Smith852c9db2013-04-20 22:23:05 +00003683 case EXPR_CXX_DEFAULT_INIT:
3684 S = new (Context) CXXDefaultInitExpr(Empty);
3685 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003686
Sebastian Redl539c5062010-08-18 23:57:32 +00003687 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00003688 S = new (Context) CXXBindTemporaryExpr(Empty);
3689 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003690
Sebastian Redl539c5062010-08-18 23:57:32 +00003691 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00003692 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003693 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003694
Sebastian Redl539c5062010-08-18 23:57:32 +00003695 case EXPR_CXX_NEW:
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00003696 S = CXXNewExpr::CreateEmpty(
3697 Context,
3698 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3699 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3700 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3701 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003702 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003703
Sebastian Redl539c5062010-08-18 23:57:32 +00003704 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00003705 S = new (Context) CXXDeleteExpr(Empty);
3706 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003707
Sebastian Redl539c5062010-08-18 23:57:32 +00003708 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00003709 S = new (Context) CXXPseudoDestructorExpr(Empty);
3710 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003711
John McCall5d413782010-12-06 08:20:24 +00003712 case EXPR_EXPR_WITH_CLEANUPS:
John McCall28fc7092011-11-10 05:35:25 +00003713 S = ExprWithCleanups::Create(Context, Empty,
3714 Record[ASTStmtReader::NumExprFields]);
Chris Lattnercba86142010-05-10 00:25:06 +00003715 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003716
Sebastian Redl539c5062010-08-18 23:57:32 +00003717 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Bruno Ricci2e6dc532019-01-08 14:17:00 +00003718 S = CXXDependentScopeMemberExpr::CreateEmpty(
3719 Context,
3720 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3721 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3722 /*HasFirstQualifierFoundInScope=*/
3723 Record[ASTStmtReader::NumExprFields + 2]);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003724 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003725
Sebastian Redl539c5062010-08-18 23:57:32 +00003726 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003727 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003728 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003729 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003730 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003731 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00003732 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003733
Sebastian Redl539c5062010-08-18 23:57:32 +00003734 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003735 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003736 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00003737 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003738
Sebastian Redl539c5062010-08-18 23:57:32 +00003739 case EXPR_CXX_UNRESOLVED_MEMBER:
Bruno Riccid7628d92019-01-09 15:43:19 +00003740 S = UnresolvedMemberExpr::CreateEmpty(
3741 Context,
3742 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3743 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3744 /*NumTemplateArgs=*/
3745 Record[ASTStmtReader::NumExprFields + 1]
3746 ? Record[ASTStmtReader::NumExprFields + 2]
3747 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003748 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003749
Sebastian Redl539c5062010-08-18 23:57:32 +00003750 case EXPR_CXX_UNRESOLVED_LOOKUP:
Bruno Riccid7628d92019-01-09 15:43:19 +00003751 S = UnresolvedLookupExpr::CreateEmpty(
3752 Context,
3753 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3754 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3755 /*NumTemplateArgs=*/
3756 Record[ASTStmtReader::NumExprFields + 1]
3757 ? Record[ASTStmtReader::NumExprFields + 2]
3758 : 0);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00003759 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003760
Douglas Gregor29c42f22012-02-24 07:38:34 +00003761 case EXPR_TYPE_TRAIT:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003762 S = TypeTraitExpr::CreateDeserialized(Context,
Douglas Gregor29c42f22012-02-24 07:38:34 +00003763 Record[ASTStmtReader::NumExprFields]);
3764 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003765
John Wiegley6242b6a2011-04-28 00:16:57 +00003766 case EXPR_ARRAY_TYPE_TRAIT:
3767 S = new (Context) ArrayTypeTraitExpr(Empty);
3768 break;
3769
John Wiegleyf9f65842011-04-25 06:54:41 +00003770 case EXPR_CXX_EXPRESSION_TRAIT:
3771 S = new (Context) ExpressionTraitExpr(Empty);
3772 break;
3773
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003774 case EXPR_CXX_NOEXCEPT:
3775 S = new (Context) CXXNoexceptExpr(Empty);
3776 break;
John McCall8d69a212010-11-15 23:31:06 +00003777
Douglas Gregore8e9dd62011-01-03 17:17:50 +00003778 case EXPR_PACK_EXPANSION:
3779 S = new (Context) PackExpansionExpr(Empty);
3780 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003781
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003782 case EXPR_SIZEOF_PACK:
Richard Smithd784e682015-09-23 21:41:42 +00003783 S = SizeOfPackExpr::CreateDeserialized(
3784 Context,
3785 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003786 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003787
John McCallfa194042011-07-15 07:00:14 +00003788 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3789 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3790 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003791
Douglas Gregorcdbc5392011-01-15 01:15:58 +00003792 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3793 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3794 break;
Richard Smithb15fe3a2012-09-12 00:56:43 +00003795
3796 case EXPR_FUNCTION_PARM_PACK:
3797 S = FunctionParmPackExpr::CreateEmpty(Context,
3798 Record[ASTStmtReader::NumExprFields]);
3799 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003800
Douglas Gregorfe314812011-06-21 17:03:29 +00003801 case EXPR_MATERIALIZE_TEMPORARY:
3802 S = new (Context) MaterializeTemporaryExpr(Empty);
3803 break;
Richard Smith0f0af192014-11-08 05:07:16 +00003804
3805 case EXPR_CXX_FOLD:
3806 S = new (Context) CXXFoldExpr(Empty);
3807 break;
3808
Argyrios Kyrtzidisb2b07952011-12-03 03:49:52 +00003809 case EXPR_OPAQUE_VALUE:
3810 S = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00003811 break;
Peter Collingbourne41f85462011-02-09 21:07:24 +00003812
3813 case EXPR_CUDA_KERNEL_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003814 S = CUDAKernelCallExpr::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003815 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00003816 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003817
Tanya Lattner55808c12011-06-04 00:47:47 +00003818 case EXPR_ASTYPE:
3819 S = new (Context) AsTypeExpr(Empty);
3820 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003821
John McCallfe96e0b2011-11-06 09:01:30 +00003822 case EXPR_PSEUDO_OBJECT: {
3823 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3824 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3825 break;
3826 }
3827
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003828 case EXPR_ATOMIC:
3829 S = new (Context) AtomicExpr(Empty);
3830 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003831
Douglas Gregor99ae8062012-02-14 17:54:36 +00003832 case EXPR_LAMBDA: {
3833 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
Richard Smith30e304e2016-12-14 00:03:17 +00003834 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
Douglas Gregor99ae8062012-02-14 17:54:36 +00003835 break;
3836 }
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +00003837
3838 case STMT_COROUTINE_BODY: {
3839 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3840 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3841 break;
3842 }
3843
3844 case STMT_CORETURN:
3845 S = new (Context) CoreturnStmt(Empty);
3846 break;
3847
3848 case EXPR_COAWAIT:
3849 S = new (Context) CoawaitExpr(Empty);
3850 break;
3851
3852 case EXPR_COYIELD:
3853 S = new (Context) CoyieldExpr(Empty);
3854 break;
3855
3856 case EXPR_DEPENDENT_COAWAIT:
3857 S = new (Context) DependentCoawaitExpr(Empty);
3858 break;
Saar Raz5d98ba62019-10-15 15:24:26 +00003859
Saar Raza0f50d72020-01-18 09:11:43 +02003860 case EXPR_CONCEPT_SPECIALIZATION: {
Saar Raz5d98ba62019-10-15 15:24:26 +00003861 unsigned numTemplateArgs = Record[ASTStmtReader::NumExprFields];
3862 S = ConceptSpecializationExpr::Create(Context, Empty, numTemplateArgs);
3863 break;
Saar Raza0f50d72020-01-18 09:11:43 +02003864 }
3865
3866 case EXPR_REQUIRES:
3867 unsigned numLocalParameters = Record[ASTStmtReader::NumExprFields];
3868 unsigned numRequirement = Record[ASTStmtReader::NumExprFields + 1];
3869 S = RequiresExpr::Create(Context, Empty, numLocalParameters,
3870 numRequirement);
3871 break;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003872 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003873
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003874 // We hit a STMT_STOP, so we're done with this expression.
3875 if (Finished)
3876 break;
3877
3878 ++NumStatementsRead;
3879
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003880 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003881 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003882 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3883 }
3884
David L. Jonesbe1557a2016-12-21 00:17:49 +00003885 assert(Record.getIdx() == Record.size() &&
3886 "Invalid deserialization of statement");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003887 StmtStack.push_back(S);
3888 }
Chris Lattner0e6c9402013-01-20 02:38:54 +00003889Done:
Alp Toker028ed912013-12-06 17:56:43 +00003890 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003891 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003892 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003893}