blob: 975b7580d8612bd45c7e1a445f1bd5699fead119 [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"
Ilya Biryukovec3060c2020-03-02 16:07:09 +010024#include "clang/AST/DependencyFlags.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"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000053#include "llvm/ADT/DenseMap.h"
Benjamin Kramer49038022012-02-04 13:45:25 +000054#include "llvm/ADT/SmallString.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000055#include "llvm/ADT/SmallVector.h"
56#include "llvm/ADT/StringRef.h"
Francis Visoiu Mistrihe0308272019-07-03 22:40:07 +000057#include "llvm/Bitstream/BitstreamReader.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000058#include "llvm/Support/Casting.h"
59#include "llvm/Support/ErrorHandling.h"
60#include <algorithm>
61#include <cassert>
62#include <cstdint>
63#include <string>
64
Chris Lattner92ba5ff2009-04-27 05:14:47 +000065using namespace clang;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000066using namespace serialization;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000067
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +000068namespace clang {
Argyrios Kyrtzidisddf5f212010-06-28 09:31:42 +000069
Sebastian Redl70c751d2010-08-18 23:56:52 +000070 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
David L. Jonesbe1557a2016-12-21 00:17:49 +000071 ASTRecordReader &Record;
Sebastian Redlc67764e2010-07-22 22:43:28 +000072 llvm::BitstreamCursor &DeclsCursor;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000073
John McCall3ce3d232019-12-13 03:37:23 -050074 SourceLocation readSourceLocation() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000075 return Record.readSourceLocation();
John McCallf413f5e2013-05-03 00:10:13 +000076 }
77
John McCall3ce3d232019-12-13 03:37:23 -050078 SourceRange readSourceRange() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000079 return Record.readSourceRange();
Sebastian Redl2c373b92010-10-05 15:59:54 +000080 }
John McCallf413f5e2013-05-03 00:10:13 +000081
John McCall3ce3d232019-12-13 03:37:23 -050082 std::string readString() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000083 return Record.readString();
Sebastian Redl2c373b92010-10-05 15:59:54 +000084 }
John McCallf413f5e2013-05-03 00:10:13 +000085
John McCall3ce3d232019-12-13 03:37:23 -050086 TypeSourceInfo *readTypeSourceInfo() {
87 return Record.readTypeSourceInfo();
John McCallf413f5e2013-05-03 00:10:13 +000088 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000089
John McCall3ce3d232019-12-13 03:37:23 -050090 Decl *readDecl() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000091 return Record.readDecl();
Sebastian Redl2c373b92010-10-05 15:59:54 +000092 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000093
Douglas Gregor7fb09192011-07-21 22:35:25 +000094 template<typename T>
John McCall3ce3d232019-12-13 03:37:23 -050095 T *readDeclAs() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000096 return Record.readDeclAs<T>();
Douglas Gregor7fb09192011-07-21 22:35:25 +000097 }
98
Chris Lattner92ba5ff2009-04-27 05:14:47 +000099 public:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000100 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
101 : Record(Record), DeclsCursor(Cursor) {}
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000102
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000103 /// The number of record fields required for the Stmt class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000104 /// itself.
Roman Lebedevb5700602019-03-20 16:32:36 +0000105 static const unsigned NumStmtFields = 1;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000106
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000107 /// The number of record fields required for the Expr class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000108 /// itself.
Douglas Gregor678d76c2011-07-01 01:22:09 +0000109 static const unsigned NumExprFields = NumStmtFields + 7;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000110
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000111 /// Read and initialize a ExplicitTemplateArgumentList structure.
Abramo Bagnara7945c982012-01-27 09:46:47 +0000112 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
James Y Knighte7d82282015-12-29 18:15:14 +0000113 TemplateArgumentLoc *ArgsLocArray,
Abramo Bagnara7945c982012-01-27 09:46:47 +0000114 unsigned NumTemplateArgs);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000115
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000116 /// Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisde6aa082011-09-22 20:07:03 +0000117 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000118 unsigned NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000119
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000120 void VisitStmt(Stmt *S);
John McCallfa194042011-07-15 07:00:14 +0000121#define STMT(Type, Base) \
122 void Visit##Type(Type *);
123#include "clang/AST/StmtNodes.inc"
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000124 };
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000125
126} // namespace clang
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000127
James Y Knighte7d82282015-12-29 18:15:14 +0000128void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
129 TemplateArgumentLoc *ArgsLocArray,
130 unsigned NumTemplateArgs) {
John McCall3ce3d232019-12-13 03:37:23 -0500131 SourceLocation TemplateKWLoc = readSourceLocation();
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000132 TemplateArgumentListInfo ArgInfo;
John McCall3ce3d232019-12-13 03:37:23 -0500133 ArgInfo.setLAngleLoc(readSourceLocation());
134 ArgInfo.setRAngleLoc(readSourceLocation());
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000135 for (unsigned i = 0; i != NumTemplateArgs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000136 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
James Y Knighte7d82282015-12-29 18:15:14 +0000137 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000138}
139
Sebastian Redl70c751d2010-08-18 23:56:52 +0000140void ASTStmtReader::VisitStmt(Stmt *S) {
Roman Lebedevb5700602019-03-20 16:32:36 +0000141 S->setIsOMPStructuredBlock(Record.readInt());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000142 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000143}
144
Sebastian Redl70c751d2010-08-18 23:56:52 +0000145void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000146 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500147 S->setSemiLoc(readSourceLocation());
Bruno Ricci41d11c02018-10-27 18:43:27 +0000148 S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000149}
150
Sebastian Redl70c751d2010-08-18 23:56:52 +0000151void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000152 VisitStmt(S);
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000153 SmallVector<Stmt *, 16> Stmts;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000154 unsigned NumStmts = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000155 while (NumStmts--)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000156 Stmts.push_back(Record.readSubStmt());
Benjamin Kramer07420902017-12-24 16:24:20 +0000157 S->setStmts(Stmts);
John McCall3ce3d232019-12-13 03:37:23 -0500158 S->CompoundStmtBits.LBraceLoc = readSourceLocation();
159 S->RBraceLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000160}
161
Sebastian Redl70c751d2010-08-18 23:56:52 +0000162void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000163 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000164 Record.recordSwitchCaseID(S, Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500165 S->setKeywordLoc(readSourceLocation());
166 S->setColonLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000167}
168
Sebastian Redl70c751d2010-08-18 23:56:52 +0000169void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000170 VisitSwitchCase(S);
Bruno Ricci5b30571752018-10-28 12:30:53 +0000171 bool CaseStmtIsGNURange = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000172 S->setLHS(Record.readSubExpr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000173 S->setSubStmt(Record.readSubStmt());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000174 if (CaseStmtIsGNURange) {
175 S->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500176 S->setEllipsisLoc(readSourceLocation());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000177 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000178}
179
Sebastian Redl70c751d2010-08-18 23:56:52 +0000180void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000181 VisitSwitchCase(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000182 S->setSubStmt(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000183}
184
Sebastian Redl70c751d2010-08-18 23:56:52 +0000185void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000186 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500187 auto *LD = readDeclAs<LabelDecl>();
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000188 LD->setStmt(S);
189 S->setDecl(LD);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000190 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500191 S->setIdentLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000192}
193
Richard Smithc202b282012-04-14 00:33:13 +0000194void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
195 VisitStmt(S);
Bruno Ricci41d11c02018-10-27 18:43:27 +0000196 // NumAttrs in AttributedStmt is set when creating an empty
197 // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
198 // to allocate the right amount of space for the trailing Attr *.
David L. Jonesbe1557a2016-12-21 00:17:49 +0000199 uint64_t NumAttrs = Record.readInt();
Richard Smithc202b282012-04-14 00:33:13 +0000200 AttrVec Attrs;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000201 Record.readAttributes(Attrs);
Matt Beaumont-Gayad0bb8e2012-07-09 18:55:31 +0000202 (void)NumAttrs;
Bruno Ricci41d11c02018-10-27 18:43:27 +0000203 assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
Alexander Kornienko20f6fc62012-07-09 10:04:07 +0000204 assert(NumAttrs == Attrs.size());
Aaron Ballmanf3d9b092014-05-13 14:55:01 +0000205 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000206 S->SubStmt = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500207 S->AttributedStmtBits.AttrLoc = readSourceLocation();
Richard Smithc202b282012-04-14 00:33:13 +0000208}
209
Sebastian Redl70c751d2010-08-18 23:56:52 +0000210void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000211 VisitStmt(S);
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000212
David L. Jonesbe1557a2016-12-21 00:17:49 +0000213 S->setConstexpr(Record.readInt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000214 bool HasElse = Record.readInt();
215 bool HasVar = Record.readInt();
216 bool HasInit = Record.readInt();
217
David L. Jonesb6a8f022016-12-21 04:34:52 +0000218 S->setCond(Record.readSubExpr());
219 S->setThen(Record.readSubStmt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000220 if (HasElse)
221 S->setElse(Record.readSubStmt());
222 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500223 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000224 if (HasInit)
225 S->setInit(Record.readSubStmt());
226
John McCall3ce3d232019-12-13 03:37:23 -0500227 S->setIfLoc(readSourceLocation());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000228 if (HasElse)
John McCall3ce3d232019-12-13 03:37:23 -0500229 S->setElseLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000230}
231
Sebastian Redl70c751d2010-08-18 23:56:52 +0000232void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000233 VisitStmt(S);
Bruno Riccie2806f82018-10-29 16:12:37 +0000234
235 bool HasInit = Record.readInt();
236 bool HasVar = Record.readInt();
237 bool AllEnumCasesCovered = Record.readInt();
238 if (AllEnumCasesCovered)
239 S->setAllEnumCasesCovered();
240
David L. Jonesb6a8f022016-12-21 04:34:52 +0000241 S->setCond(Record.readSubExpr());
242 S->setBody(Record.readSubStmt());
Bruno Riccie2806f82018-10-29 16:12:37 +0000243 if (HasInit)
244 S->setInit(Record.readSubStmt());
245 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500246 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccie2806f82018-10-29 16:12:37 +0000247
John McCall3ce3d232019-12-13 03:37:23 -0500248 S->setSwitchLoc(readSourceLocation());
Ted Kremenekc42f3452010-09-09 00:05:53 +0000249
Craig Toppera13603a2014-05-22 05:54:18 +0000250 SwitchCase *PrevSC = nullptr;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000251 for (auto E = Record.size(); Record.getIdx() != E; ) {
252 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000253 if (PrevSC)
254 PrevSC->setNextSwitchCase(SC);
255 else
256 S->setSwitchCaseList(SC);
Mike Stump11289f42009-09-09 15:08:12 +0000257
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000258 PrevSC = SC;
259 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000260}
261
Sebastian Redl70c751d2010-08-18 23:56:52 +0000262void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000263 VisitStmt(S);
Bruno Riccibacf7512018-10-30 13:42:41 +0000264
265 bool HasVar = Record.readInt();
Douglas Gregor7fb09192011-07-21 22:35:25 +0000266
David L. Jonesb6a8f022016-12-21 04:34:52 +0000267 S->setCond(Record.readSubExpr());
268 S->setBody(Record.readSubStmt());
Bruno Riccibacf7512018-10-30 13:42:41 +0000269 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500270 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccibacf7512018-10-30 13:42:41 +0000271
John McCall3ce3d232019-12-13 03:37:23 -0500272 S->setWhileLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000273}
274
Sebastian Redl70c751d2010-08-18 23:56:52 +0000275void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000276 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000277 S->setCond(Record.readSubExpr());
278 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500279 S->setDoLoc(readSourceLocation());
280 S->setWhileLoc(readSourceLocation());
281 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000282}
283
Sebastian Redl70c751d2010-08-18 23:56:52 +0000284void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000285 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000286 S->setInit(Record.readSubStmt());
287 S->setCond(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500288 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000289 S->setInc(Record.readSubExpr());
290 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500291 S->setForLoc(readSourceLocation());
292 S->setLParenLoc(readSourceLocation());
293 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000294}
295
Sebastian Redl70c751d2010-08-18 23:56:52 +0000296void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000297 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500298 S->setLabel(readDeclAs<LabelDecl>());
299 S->setGotoLoc(readSourceLocation());
300 S->setLabelLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000301}
302
Sebastian Redl70c751d2010-08-18 23:56:52 +0000303void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000304 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500305 S->setGotoLoc(readSourceLocation());
306 S->setStarLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000307 S->setTarget(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000308}
309
Sebastian Redl70c751d2010-08-18 23:56:52 +0000310void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000311 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500312 S->setContinueLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000313}
314
Sebastian Redl70c751d2010-08-18 23:56:52 +0000315void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000316 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500317 S->setBreakLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000318}
319
Sebastian Redl70c751d2010-08-18 23:56:52 +0000320void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000321 VisitStmt(S);
Bruno Ricci023b1d12018-10-30 14:40:49 +0000322
323 bool HasNRVOCandidate = Record.readInt();
324
David L. Jonesb6a8f022016-12-21 04:34:52 +0000325 S->setRetValue(Record.readSubExpr());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000326 if (HasNRVOCandidate)
John McCall3ce3d232019-12-13 03:37:23 -0500327 S->setNRVOCandidate(readDeclAs<VarDecl>());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000328
John McCall3ce3d232019-12-13 03:37:23 -0500329 S->setReturnLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000330}
331
Sebastian Redl70c751d2010-08-18 23:56:52 +0000332void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000333 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500334 S->setStartLoc(readSourceLocation());
335 S->setEndLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000336
David L. Jonesbe1557a2016-12-21 00:17:49 +0000337 if (Record.size() - Record.getIdx() == 1) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000338 // Single declaration
John McCall3ce3d232019-12-13 03:37:23 -0500339 S->setDeclGroup(DeclGroupRef(readDecl()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000340 } else {
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000341 SmallVector<Decl *, 16> Decls;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000342 int N = Record.size() - Record.getIdx();
343 Decls.reserve(N);
344 for (int I = 0; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500345 Decls.push_back(readDecl());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000346 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
Douglas Gregor038c3382009-05-22 22:45:36 +0000347 Decls.data(),
348 Decls.size())));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000349 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000350}
351
John McCallf413f5e2013-05-03 00:10:13 +0000352void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000353 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000354 S->NumOutputs = Record.readInt();
355 S->NumInputs = Record.readInt();
356 S->NumClobbers = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500357 S->setAsmLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000358 S->setVolatile(Record.readInt());
359 S->setSimple(Record.readInt());
John McCallf413f5e2013-05-03 00:10:13 +0000360}
Mike Stump11289f42009-09-09 15:08:12 +0000361
John McCallf413f5e2013-05-03 00:10:13 +0000362void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
363 VisitAsmStmt(S);
Jennifer Yub8fee672019-06-03 15:57:25 +0000364 S->NumLabels = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500365 S->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000366 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000367
John McCallf413f5e2013-05-03 00:10:13 +0000368 unsigned NumOutputs = S->getNumOutputs();
369 unsigned NumInputs = S->getNumInputs();
370 unsigned NumClobbers = S->getNumClobbers();
Jennifer Yub8fee672019-06-03 15:57:25 +0000371 unsigned NumLabels = S->getNumLabels();
John McCallf413f5e2013-05-03 00:10:13 +0000372
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000373 // Outputs and inputs
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000374 SmallVector<IdentifierInfo *, 16> Names;
375 SmallVector<StringLiteral*, 16> Constraints;
376 SmallVector<Stmt*, 16> Exprs;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000377 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -0500378 Names.push_back(Record.readIdentifier());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000379 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
380 Exprs.push_back(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000381 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000382
383 // Constraints
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000384 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000385 for (unsigned I = 0; I != NumClobbers; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000386 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000387
Jennifer Yub8fee672019-06-03 15:57:25 +0000388 // Labels
389 for (unsigned I = 0, N = NumLabels; I != N; ++I)
390 Exprs.push_back(Record.readSubStmt());
391
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000392 S->setOutputsAndInputsAndClobbers(Record.getContext(),
393 Names.data(), Constraints.data(),
394 Exprs.data(), NumOutputs, NumInputs,
Jennifer Yub8fee672019-06-03 15:57:25 +0000395 NumLabels,
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000396 Clobbers.data(), NumClobbers);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000397}
398
Chad Rosier32503022012-06-11 20:47:18 +0000399void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
John McCallf413f5e2013-05-03 00:10:13 +0000400 VisitAsmStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500401 S->LBraceLoc = readSourceLocation();
402 S->EndLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000403 S->NumAsmToks = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500404 std::string AsmStr = readString();
John McCallf413f5e2013-05-03 00:10:13 +0000405
406 // Read the tokens.
407 SmallVector<Token, 16> AsmToks;
408 AsmToks.reserve(S->NumAsmToks);
409 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000410 AsmToks.push_back(Record.readToken());
John McCallf413f5e2013-05-03 00:10:13 +0000411 }
412
413 // The calls to reserve() for the FooData vectors are mandatory to
414 // prevent dead StringRefs in the Foo vectors.
415
416 // Read the clobbers.
417 SmallVector<std::string, 16> ClobbersData;
418 SmallVector<StringRef, 16> Clobbers;
419 ClobbersData.reserve(S->NumClobbers);
420 Clobbers.reserve(S->NumClobbers);
421 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
John McCall3ce3d232019-12-13 03:37:23 -0500422 ClobbersData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000423 Clobbers.push_back(ClobbersData.back());
424 }
425
426 // Read the operands.
427 unsigned NumOperands = S->NumOutputs + S->NumInputs;
428 SmallVector<Expr*, 16> Exprs;
429 SmallVector<std::string, 16> ConstraintsData;
430 SmallVector<StringRef, 16> Constraints;
431 Exprs.reserve(NumOperands);
432 ConstraintsData.reserve(NumOperands);
433 Constraints.reserve(NumOperands);
434 for (unsigned i = 0; i != NumOperands; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000435 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -0500436 ConstraintsData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000437 Constraints.push_back(ConstraintsData.back());
438 }
439
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000440 S->initialize(Record.getContext(), AsmStr, AsmToks,
John McCallf413f5e2013-05-03 00:10:13 +0000441 Constraints, Exprs, Clobbers);
Chad Rosier32503022012-06-11 20:47:18 +0000442}
443
Richard Smith9f690bd2015-10-27 06:02:45 +0000444void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000445 VisitStmt(S);
446 assert(Record.peekInt() == S->NumParams);
447 Record.skipInts(1);
448 auto *StoredStmts = S->getStoredStmts();
449 for (unsigned i = 0;
450 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
451 StoredStmts[i] = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000452}
453
454void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000455 VisitStmt(S);
456 S->CoreturnLoc = Record.readSourceLocation();
457 for (auto &SubStmt: S->SubStmts)
458 SubStmt = Record.readSubStmt();
459 S->IsImplicit = Record.readInt() != 0;
Richard Smith9f690bd2015-10-27 06:02:45 +0000460}
461
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000462void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
463 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500464 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000465 for (auto &SubExpr: E->SubExprs)
466 SubExpr = Record.readSubStmt();
467 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
468 E->setIsImplicit(Record.readInt() != 0);
Richard Smith9f690bd2015-10-27 06:02:45 +0000469}
470
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000471void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
472 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500473 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000474 for (auto &SubExpr: E->SubExprs)
475 SubExpr = Record.readSubStmt();
476 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
Eric Fiselier20f25cb2017-03-06 23:38:15 +0000477}
478
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000479void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
480 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500481 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000482 for (auto &SubExpr: E->SubExprs)
483 SubExpr = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000484}
485
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000486void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
Ben Langmuirce914fc2013-05-03 19:20:19 +0000487 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000488 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500489 S->setCapturedDecl(readDeclAs<CapturedDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000490 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500491 S->setCapturedRecordDecl(readDeclAs<RecordDecl>());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000492
493 // Capture inits
494 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
495 E = S->capture_init_end();
496 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000497 *I = Record.readSubExpr();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000498
499 // Body
David L. Jonesb6a8f022016-12-21 04:34:52 +0000500 S->setCapturedStmt(Record.readSubStmt());
Wei Pan17fbf6e2013-05-04 03:59:06 +0000501 S->getCapturedDecl()->setBody(S->getCapturedStmt());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000502
503 // Captures
Aaron Ballmanc656303a2014-03-14 18:08:33 +0000504 for (auto &I : S->captures()) {
John McCall3ce3d232019-12-13 03:37:23 -0500505 I.VarAndKind.setPointer(readDeclAs<VarDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000506 I.VarAndKind.setInt(
507 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500508 I.Loc = readSourceLocation();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000509 }
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000510}
511
Sebastian Redl70c751d2010-08-18 23:56:52 +0000512void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000513 VisitStmt(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000514 E->setType(Record.readType());
Ilya Biryukovec3060c2020-03-02 16:07:09 +0100515
516 // FIXME: write and read all DependentFlags with a single call.
517 bool TypeDependent = Record.readInt();
518 bool ValueDependent = Record.readInt();
519 bool InstantiationDependent = Record.readInt();
520 bool ContainsUnexpandedTemplateParameters = Record.readInt();
521 auto Deps = ExprDependence::None;
522 if (TypeDependent)
523 Deps |= ExprDependence::Type;
524 if (ValueDependent)
525 Deps |= ExprDependence::Value;
526 if (InstantiationDependent)
527 Deps |= ExprDependence::Instantiation;
528 if (ContainsUnexpandedTemplateParameters)
529 Deps |= ExprDependence::UnexpandedPack;
530 E->setDependence(Deps);
531
David L. Jonesbe1557a2016-12-21 00:17:49 +0000532 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
533 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
534 assert(Record.getIdx() == NumExprFields &&
535 "Incorrect expression field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000536}
537
Bill Wendling7c44da22018-10-31 03:48:47 +0000538void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
539 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000540 E->ConstantExprBits.ResultKind = Record.readInt();
541 switch (E->ConstantExprBits.ResultKind) {
542 case ConstantExpr::RSK_Int64: {
543 E->Int64Result() = Record.readInt();
544 uint64_t tmp = Record.readInt();
545 E->ConstantExprBits.IsUnsigned = tmp & 0x1;
546 E->ConstantExprBits.BitWidth = tmp >> 1;
547 break;
548 }
549 case ConstantExpr::RSK_APValue:
550 E->APValueResult() = Record.readAPValue();
551 }
Bill Wendling7c44da22018-10-31 03:48:47 +0000552 E->setSubExpr(Record.readSubExpr());
553}
554
Sebastian Redl70c751d2010-08-18 23:56:52 +0000555void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000556 VisitExpr(E);
Bruno Ricci17ff0262018-10-27 19:21:19 +0000557 bool HasFunctionName = Record.readInt();
558 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
559 E->PredefinedExprBits.Kind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500560 E->setLocation(readSourceLocation());
Bruno Ricci17ff0262018-10-27 19:21:19 +0000561 if (HasFunctionName)
562 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000563}
564
Sebastian Redl70c751d2010-08-18 23:56:52 +0000565void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000566 VisitExpr(E);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000567
David L. Jonesbe1557a2016-12-21 00:17:49 +0000568 E->DeclRefExprBits.HasQualifier = Record.readInt();
569 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
570 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
571 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
572 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
Richard Smith715f7a12019-06-11 17:50:32 +0000573 E->DeclRefExprBits.NonOdrUseReason = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000574 unsigned NumTemplateArgs = 0;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000575 if (E->hasTemplateKWAndArgsInfo())
David L. Jonesbe1557a2016-12-21 00:17:49 +0000576 NumTemplateArgs = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000577
Chandler Carruth0e439962011-05-01 21:29:53 +0000578 if (E->hasQualifier())
James Y Knighte7d82282015-12-29 18:15:14 +0000579 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
David L. Jonesb6a8f022016-12-21 04:34:52 +0000580 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000581
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000582 if (E->hasFoundDecl())
John McCall3ce3d232019-12-13 03:37:23 -0500583 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000584
Abramo Bagnara7945c982012-01-27 09:46:47 +0000585 if (E->hasTemplateKWAndArgsInfo())
James Y Knighte7d82282015-12-29 18:15:14 +0000586 ReadTemplateKWAndArgsInfo(
587 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
588 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000589
John McCall3ce3d232019-12-13 03:37:23 -0500590 E->setDecl(readDeclAs<ValueDecl>());
591 E->setLocation(readSourceLocation());
592 E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000593}
594
Sebastian Redl70c751d2010-08-18 23:56:52 +0000595void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000596 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500597 E->setLocation(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000598 E->setValue(Record.getContext(), Record.readAPInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000599}
600
Leonard Chandb01c3a2018-06-20 17:19:40 +0000601void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
602 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500603 E->setLocation(readSourceLocation());
Leonard Chandb01c3a2018-06-20 17:19:40 +0000604 E->setValue(Record.getContext(), Record.readAPInt());
605}
606
Sebastian Redl70c751d2010-08-18 23:56:52 +0000607void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000608 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000609 E->setRawSemantics(
610 static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
David L. Jonesbe1557a2016-12-21 00:17:49 +0000611 E->setExact(Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000612 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
John McCall3ce3d232019-12-13 03:37:23 -0500613 E->setLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000614}
615
Sebastian Redl70c751d2010-08-18 23:56:52 +0000616void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000617 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000618 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000619}
620
Sebastian Redl70c751d2010-08-18 23:56:52 +0000621void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000622 VisitExpr(E);
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000623
624 // NumConcatenated, Length and CharByteWidth are set by the empty
625 // ctor since they are needed to allocate storage for the trailing objects.
626 unsigned NumConcatenated = Record.readInt();
627 unsigned Length = Record.readInt();
628 unsigned CharByteWidth = Record.readInt();
629 assert((NumConcatenated == E->getNumConcatenated()) &&
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000630 "Wrong number of concatenated tokens!");
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000631 assert((Length == E->getLength()) && "Wrong Length!");
632 assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
633 E->StringLiteralBits.Kind = Record.readInt();
634 E->StringLiteralBits.IsPascal = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000635
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000636 // The character width is originally computed via mapCharByteWidth.
637 // Check that the deserialized character width is consistant with the result
638 // of calling mapCharByteWidth.
639 assert((CharByteWidth ==
640 StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
641 E->getKind())) &&
642 "Wrong character width!");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000643
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000644 // Deserialize the trailing array of SourceLocation.
645 for (unsigned I = 0; I < NumConcatenated; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500646 E->setStrTokenLoc(I, readSourceLocation());
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000647
648 // Deserialize the trailing array of char holding the string data.
649 char *StrData = E->getStrDataAsChar();
650 for (unsigned I = 0; I < Length * CharByteWidth; ++I)
651 StrData[I] = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000652}
653
Sebastian Redl70c751d2010-08-18 23:56:52 +0000654void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000655 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000656 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500657 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000658 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000659}
660
Sebastian Redl70c751d2010-08-18 23:56:52 +0000661void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000662 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500663 E->setLParen(readSourceLocation());
664 E->setRParen(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000665 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000666}
667
Sebastian Redl70c751d2010-08-18 23:56:52 +0000668void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000669 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000670 unsigned NumExprs = Record.readInt();
Bruno Riccif49e1ca2018-11-20 16:20:40 +0000671 assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
672 for (unsigned I = 0; I != NumExprs; ++I)
673 E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500674 E->LParenLoc = readSourceLocation();
675 E->RParenLoc = readSourceLocation();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000676}
677
Sebastian Redl70c751d2010-08-18 23:56:52 +0000678void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000679 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000680 E->setSubExpr(Record.readSubExpr());
681 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500682 E->setOperatorLoc(readSourceLocation());
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000683 E->setCanOverflow(Record.readInt());
684}
685
686void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000687 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000688 assert(E->getNumComponents() == Record.peekInt());
689 Record.skipInts(1);
690 assert(E->getNumExpressions() == Record.peekInt());
691 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500692 E->setOperatorLoc(readSourceLocation());
693 E->setRParenLoc(readSourceLocation());
694 E->setTypeSourceInfo(readTypeSourceInfo());
Douglas Gregor882211c2010-04-28 22:16:22 +0000695 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000696 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500697 SourceLocation Start = readSourceLocation();
698 SourceLocation End = readSourceLocation();
Douglas Gregor882211c2010-04-28 22:16:22 +0000699 switch (Kind) {
James Y Knight7281c352015-12-29 22:31:18 +0000700 case OffsetOfNode::Array:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000701 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000702 break;
703
James Y Knight7281c352015-12-29 22:31:18 +0000704 case OffsetOfNode::Field:
705 E->setComponent(
John McCall3ce3d232019-12-13 03:37:23 -0500706 I, OffsetOfNode(Start, readDeclAs<FieldDecl>(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000707 break;
James Y Knight7281c352015-12-29 22:31:18 +0000708
709 case OffsetOfNode::Identifier:
710 E->setComponent(
711 I,
John McCall3ce3d232019-12-13 03:37:23 -0500712 OffsetOfNode(Start, Record.readIdentifier(), End));
James Y Knight7281c352015-12-29 22:31:18 +0000713 break;
714
715 case OffsetOfNode::Base: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000716 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000717 *Base = Record.readCXXBaseSpecifier();
James Y Knight7281c352015-12-29 22:31:18 +0000718 E->setComponent(I, OffsetOfNode(Base));
Douglas Gregord1702062010-04-29 00:18:15 +0000719 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000720 }
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000721 }
Douglas Gregor882211c2010-04-28 22:16:22 +0000722 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000723
Douglas Gregor882211c2010-04-28 22:16:22 +0000724 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000725 E->setIndexExpr(I, Record.readSubExpr());
Douglas Gregor882211c2010-04-28 22:16:22 +0000726}
727
Peter Collingbournee190dee2011-03-11 19:24:49 +0000728void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000729 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000730 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
731 if (Record.peekInt() == 0) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000732 E->setArgument(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000733 Record.skipInts(1);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000734 } else {
John McCall3ce3d232019-12-13 03:37:23 -0500735 E->setArgument(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000736 }
John McCall3ce3d232019-12-13 03:37:23 -0500737 E->setOperatorLoc(readSourceLocation());
738 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000739}
740
Saar Raza0f50d72020-01-18 09:11:43 +0200741static ConstraintSatisfaction
742readConstraintSatisfaction(ASTRecordReader &Record) {
743 ConstraintSatisfaction Satisfaction;
744 Satisfaction.IsSatisfied = Record.readInt();
745 if (!Satisfaction.IsSatisfied) {
746 unsigned NumDetailRecords = Record.readInt();
747 for (unsigned i = 0; i != NumDetailRecords; ++i) {
748 Expr *ConstraintExpr = Record.readExpr();
Michael Liao70b53a302020-01-19 12:23:11 -0500749 if (/* IsDiagnostic */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200750 SourceLocation DiagLocation = Record.readSourceLocation();
751 std::string DiagMessage = Record.readString();
752 Satisfaction.Details.emplace_back(
753 ConstraintExpr, new (Record.getContext())
754 ConstraintSatisfaction::SubstitutionDiagnostic{
755 DiagLocation, DiagMessage});
756 } else
757 Satisfaction.Details.emplace_back(ConstraintExpr, Record.readExpr());
758 }
759 }
760 return Satisfaction;
761}
762
Saar Raz5d98ba62019-10-15 15:24:26 +0000763void ASTStmtReader::VisitConceptSpecializationExpr(
764 ConceptSpecializationExpr *E) {
765 VisitExpr(E);
766 unsigned NumTemplateArgs = Record.readInt();
767 E->NestedNameSpec = Record.readNestedNameSpecifierLoc();
768 E->TemplateKWLoc = Record.readSourceLocation();
Saar Razff1e0fc2020-01-15 02:48:42 +0200769 E->ConceptName = Record.readDeclarationNameInfo();
John McCall3ce3d232019-12-13 03:37:23 -0500770 E->NamedConcept = readDeclAs<ConceptDecl>();
Saar Razf9e63892020-03-10 22:04:11 +0200771 E->FoundDecl = Record.readDeclAs<NamedDecl>();
Saar Razff1e0fc2020-01-15 02:48:42 +0200772 E->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
Saar Raz5d98ba62019-10-15 15:24:26 +0000773 llvm::SmallVector<TemplateArgument, 4> Args;
774 for (unsigned I = 0; I < NumTemplateArgs; ++I)
775 Args.push_back(Record.readTemplateArgument());
Saar Razff1e0fc2020-01-15 02:48:42 +0200776 E->setTemplateArguments(Args);
Saar Raza0f50d72020-01-18 09:11:43 +0200777 E->Satisfaction = E->isValueDependent() ? nullptr :
778 ASTConstraintSatisfaction::Create(Record.getContext(),
779 readConstraintSatisfaction(Record));
780}
781
782static concepts::Requirement::SubstitutionDiagnostic *
783readSubstitutionDiagnostic(ASTRecordReader &Record) {
784 std::string SubstitutedEntity = Record.readString();
785 SourceLocation DiagLoc = Record.readSourceLocation();
786 std::string DiagMessage = Record.readString();
787 return new (Record.getContext())
788 concepts::Requirement::SubstitutionDiagnostic{SubstitutedEntity, DiagLoc,
789 DiagMessage};
790}
791
792void ASTStmtReader::VisitRequiresExpr(RequiresExpr *E) {
793 VisitExpr(E);
794 unsigned NumLocalParameters = Record.readInt();
795 unsigned NumRequirements = Record.readInt();
796 E->RequiresExprBits.RequiresKWLoc = Record.readSourceLocation();
797 E->RequiresExprBits.IsSatisfied = Record.readInt();
798 E->Body = Record.readDeclAs<RequiresExprBodyDecl>();
799 llvm::SmallVector<ParmVarDecl *, 4> LocalParameters;
800 for (unsigned i = 0; i < NumLocalParameters; ++i)
801 LocalParameters.push_back(cast<ParmVarDecl>(Record.readDecl()));
802 std::copy(LocalParameters.begin(), LocalParameters.end(),
803 E->getTrailingObjects<ParmVarDecl *>());
804 llvm::SmallVector<concepts::Requirement *, 4> Requirements;
805 for (unsigned i = 0; i < NumRequirements; ++i) {
806 auto RK =
807 static_cast<concepts::Requirement::RequirementKind>(Record.readInt());
808 concepts::Requirement *R = nullptr;
809 switch (RK) {
810 case concepts::Requirement::RK_Type: {
811 auto Status =
812 static_cast<concepts::TypeRequirement::SatisfactionStatus>(
813 Record.readInt());
814 if (Status == concepts::TypeRequirement::SS_SubstitutionFailure)
815 R = new (Record.getContext())
816 concepts::TypeRequirement(readSubstitutionDiagnostic(Record));
817 else
818 R = new (Record.getContext())
819 concepts::TypeRequirement(Record.readTypeSourceInfo());
820 } break;
821 case concepts::Requirement::RK_Simple:
822 case concepts::Requirement::RK_Compound: {
823 auto Status =
824 static_cast<concepts::ExprRequirement::SatisfactionStatus>(
825 Record.readInt());
826 llvm::PointerUnion<concepts::Requirement::SubstitutionDiagnostic *,
827 Expr *> E;
828 if (Status == concepts::ExprRequirement::SS_ExprSubstitutionFailure) {
829 E = readSubstitutionDiagnostic(Record);
830 } else
831 E = Record.readExpr();
832
833 llvm::Optional<concepts::ExprRequirement::ReturnTypeRequirement> Req;
834 ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr;
835 SourceLocation NoexceptLoc;
836 if (RK == concepts::Requirement::RK_Simple) {
837 Req.emplace();
838 } else {
839 NoexceptLoc = Record.readSourceLocation();
Michael Liao70b53a302020-01-19 12:23:11 -0500840 switch (/* returnTypeRequirementKind */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200841 case 0:
842 // No return type requirement.
843 Req.emplace();
844 break;
845 case 1: {
846 // type-constraint
847 TemplateParameterList *TPL = Record.readTemplateParameterList();
848 if (Status >=
849 concepts::ExprRequirement::SS_ConstraintsNotSatisfied)
850 SubstitutedConstraintExpr =
851 cast<ConceptSpecializationExpr>(Record.readExpr());
852 Req.emplace(TPL);
853 } break;
854 case 2:
855 // Substitution failure
856 Req.emplace(readSubstitutionDiagnostic(Record));
857 break;
858 }
859 }
860 if (Expr *Ex = E.dyn_cast<Expr *>())
861 R = new (Record.getContext()) concepts::ExprRequirement(
862 Ex, RK == concepts::Requirement::RK_Simple, NoexceptLoc,
863 std::move(*Req), Status, SubstitutedConstraintExpr);
864 else
865 R = new (Record.getContext()) concepts::ExprRequirement(
866 E.get<concepts::Requirement::SubstitutionDiagnostic *>(),
867 RK == concepts::Requirement::RK_Simple, NoexceptLoc,
868 std::move(*Req));
869 } break;
870 case concepts::Requirement::RK_Nested: {
Michael Liao70b53a302020-01-19 12:23:11 -0500871 if (/* IsSubstitutionDiagnostic */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200872 R = new (Record.getContext()) concepts::NestedRequirement(
873 readSubstitutionDiagnostic(Record));
874 break;
875 }
876 Expr *E = Record.readExpr();
877 if (E->isInstantiationDependent())
878 R = new (Record.getContext()) concepts::NestedRequirement(E);
879 else
880 R = new (Record.getContext())
881 concepts::NestedRequirement(Record.getContext(), E,
882 readConstraintSatisfaction(Record));
883 } break;
Saar Razfdf80e82019-12-06 01:30:21 +0200884 }
Saar Raza0f50d72020-01-18 09:11:43 +0200885 if (!R)
886 continue;
887 Requirements.push_back(R);
Saar Razfdf80e82019-12-06 01:30:21 +0200888 }
Saar Raza0f50d72020-01-18 09:11:43 +0200889 std::copy(Requirements.begin(), Requirements.end(),
890 E->getTrailingObjects<concepts::Requirement *>());
891 E->RBraceLoc = Record.readSourceLocation();
Saar Raz5d98ba62019-10-15 15:24:26 +0000892}
893
Sebastian Redl70c751d2010-08-18 23:56:52 +0000894void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000895 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000896 E->setLHS(Record.readSubExpr());
897 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500898 E->setRBracketLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000899}
900
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000901void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
902 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000903 E->setBase(Record.readSubExpr());
904 E->setLowerBound(Record.readSubExpr());
905 E->setLength(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500906 E->setColonLoc(readSourceLocation());
907 E->setRBracketLoc(readSourceLocation());
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000908}
909
Sebastian Redl70c751d2010-08-18 23:56:52 +0000910void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000911 VisitExpr(E);
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000912 unsigned NumArgs = Record.readInt();
913 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
John McCall3ce3d232019-12-13 03:37:23 -0500914 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000915 E->setCallee(Record.readSubExpr());
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000916 for (unsigned I = 0; I != NumArgs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000917 E->setArg(I, Record.readSubExpr());
Eric Fiselier5cdc2cd2018-12-12 21:50:55 +0000918 E->setADLCallKind(static_cast<CallExpr::ADLCallKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000919}
920
John McCallfa194042011-07-15 07:00:14 +0000921void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
922 VisitCallExpr(E);
923}
924
Sebastian Redl70c751d2010-08-18 23:56:52 +0000925void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Richard Smithdcf17de2019-06-06 23:24:15 +0000926 VisitExpr(E);
927
928 bool HasQualifier = Record.readInt();
929 bool HasFoundDecl = Record.readInt();
930 bool HasTemplateInfo = Record.readInt();
931 unsigned NumTemplateArgs = Record.readInt();
932
933 E->Base = Record.readSubExpr();
934 E->MemberDecl = Record.readDeclAs<ValueDecl>();
John McCall3ce3d232019-12-13 03:37:23 -0500935 E->MemberDNLoc = Record.readDeclarationNameLoc(E->MemberDecl->getDeclName());
Richard Smithdcf17de2019-06-06 23:24:15 +0000936 E->MemberLoc = Record.readSourceLocation();
937 E->MemberExprBits.IsArrow = Record.readInt();
938 E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
939 E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
940 E->MemberExprBits.HadMultipleCandidates = Record.readInt();
Richard Smith1bbad592019-06-11 17:50:36 +0000941 E->MemberExprBits.NonOdrUseReason = Record.readInt();
Richard Smithdcf17de2019-06-06 23:24:15 +0000942 E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
943
944 if (HasQualifier || HasFoundDecl) {
945 DeclAccessPair FoundDecl;
946 if (HasFoundDecl) {
947 auto *FoundD = Record.readDeclAs<NamedDecl>();
948 auto AS = (AccessSpecifier)Record.readInt();
949 FoundDecl = DeclAccessPair::make(FoundD, AS);
950 } else {
951 FoundDecl = DeclAccessPair::make(E->MemberDecl,
952 E->MemberDecl->getAccess());
953 }
954 E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
955
956 NestedNameSpecifierLoc QualifierLoc;
957 if (HasQualifier)
958 QualifierLoc = Record.readNestedNameSpecifierLoc();
959 E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
960 QualifierLoc;
961 }
962
963 if (HasTemplateInfo)
964 ReadTemplateKWAndArgsInfo(
965 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
966 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000967}
968
Sebastian Redl70c751d2010-08-18 23:56:52 +0000969void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Naroffe87026a2009-07-24 17:54:45 +0000970 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000971 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500972 E->setIsaMemberLoc(readSourceLocation());
973 E->setOpLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000974 E->setArrow(Record.readInt());
Steve Naroffe87026a2009-07-24 17:54:45 +0000975}
976
John McCall31168b02011-06-15 23:02:42 +0000977void ASTStmtReader::
978VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
979 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000980 E->Operand = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000981 E->setShouldCopy(Record.readInt());
John McCall31168b02011-06-15 23:02:42 +0000982}
983
984void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
985 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500986 E->LParenLoc = readSourceLocation();
987 E->BridgeKeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000988 E->Kind = Record.readInt();
John McCall31168b02011-06-15 23:02:42 +0000989}
990
Sebastian Redl70c751d2010-08-18 23:56:52 +0000991void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000992 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000993 unsigned NumBaseSpecs = Record.readInt();
John McCallcf142162010-08-07 06:22:56 +0000994 assert(NumBaseSpecs == E->path_size());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000995 E->setSubExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000996 E->setCastKind((CastKind)Record.readInt());
John McCallcf142162010-08-07 06:22:56 +0000997 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000998 while (NumBaseSpecs--) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000999 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
David L. Jonesb6a8f022016-12-21 04:34:52 +00001000 *BaseSpec = Record.readCXXBaseSpecifier();
John McCallcf142162010-08-07 06:22:56 +00001001 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +00001002 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001003}
1004
Sebastian Redl70c751d2010-08-18 23:56:52 +00001005void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001006 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001007 E->setLHS(Record.readSubExpr());
1008 E->setRHS(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001009 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001010 E->setOperatorLoc(readSourceLocation());
Adam Nemet484aa452017-03-27 19:17:25 +00001011 E->setFPFeatures(FPOptions(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001012}
1013
Sebastian Redl70c751d2010-08-18 23:56:52 +00001014void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001015 VisitBinaryOperator(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001016 E->setComputationLHSType(Record.readType());
1017 E->setComputationResultType(Record.readType());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001018}
1019
Sebastian Redl70c751d2010-08-18 23:56:52 +00001020void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001021 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001022 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
1023 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
1024 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001025 E->QuestionLoc = readSourceLocation();
1026 E->ColonLoc = readSourceLocation();
John McCallc07a0c72011-02-17 10:25:35 +00001027}
1028
1029void
1030ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
1031 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001032 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
1033 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
1034 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
1035 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
1036 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001037 E->QuestionLoc = readSourceLocation();
1038 E->ColonLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001039}
1040
Sebastian Redl70c751d2010-08-18 23:56:52 +00001041void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001042 VisitCastExpr(E);
Roman Lebedev12216f12018-07-27 07:27:14 +00001043 E->setIsPartOfExplicitCast(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001044}
1045
Sebastian Redl70c751d2010-08-18 23:56:52 +00001046void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001047 VisitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001048 E->setTypeInfoAsWritten(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001049}
1050
Sebastian Redl70c751d2010-08-18 23:56:52 +00001051void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001052 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001053 E->setLParenLoc(readSourceLocation());
1054 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001055}
1056
Sebastian Redl70c751d2010-08-18 23:56:52 +00001057void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001058 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001059 E->setLParenLoc(readSourceLocation());
1060 E->setTypeSourceInfo(readTypeSourceInfo());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001061 E->setInitializer(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001062 E->setFileScope(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001063}
1064
Sebastian Redl70c751d2010-08-18 23:56:52 +00001065void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001066 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001067 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001068 E->setAccessor(Record.readIdentifier());
1069 E->setAccessorLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001070}
1071
Sebastian Redl70c751d2010-08-18 23:56:52 +00001072void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001073 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001074 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
Abramo Bagnara8d16bd42012-11-08 18:41:43 +00001075 E->setSyntacticForm(SyntForm);
John McCall3ce3d232019-12-13 03:37:23 -05001076 E->setLBraceLoc(readSourceLocation());
1077 E->setRBraceLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001078 bool isArrayFiller = Record.readInt();
Craig Toppera13603a2014-05-22 05:54:18 +00001079 Expr *filler = nullptr;
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001080 if (isArrayFiller) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001081 filler = Record.readSubExpr();
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001082 E->ArrayFillerOrUnionFieldInit = filler;
1083 } else
John McCall3ce3d232019-12-13 03:37:23 -05001084 E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001085 E->sawArrayRangeDesignator(Record.readInt());
1086 unsigned NumInits = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001087 E->reserveInits(Record.getContext(), NumInits);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001088 if (isArrayFiller) {
1089 for (unsigned I = 0; I != NumInits; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001090 Expr *init = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001091 E->updateInit(Record.getContext(), I, init ? init : filler);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001092 }
1093 } else {
1094 for (unsigned I = 0; I != NumInits; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001095 E->updateInit(Record.getContext(), I, Record.readSubExpr());
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001096 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001097}
1098
Sebastian Redl70c751d2010-08-18 23:56:52 +00001099void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001100 using Designator = DesignatedInitExpr::Designator;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001101
1102 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001103 unsigned NumSubExprs = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001104 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
1105 for (unsigned I = 0; I != NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001106 E->setSubExpr(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001107 E->setEqualOrColonLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001108 E->setGNUSyntax(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001109
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001110 SmallVector<Designator, 4> Designators;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001111 while (Record.getIdx() < Record.size()) {
1112 switch ((DesignatorTypes)Record.readInt()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00001113 case DESIG_FIELD_DECL: {
John McCall3ce3d232019-12-13 03:37:23 -05001114 auto *Field = readDeclAs<FieldDecl>();
1115 SourceLocation DotLoc = readSourceLocation();
1116 SourceLocation FieldLoc = readSourceLocation();
Mike Stump11289f42009-09-09 15:08:12 +00001117 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001118 FieldLoc));
1119 Designators.back().setField(Field);
1120 break;
1121 }
1122
Sebastian Redl539c5062010-08-18 23:57:32 +00001123 case DESIG_FIELD_NAME: {
John McCall3ce3d232019-12-13 03:37:23 -05001124 const IdentifierInfo *Name = Record.readIdentifier();
1125 SourceLocation DotLoc = readSourceLocation();
1126 SourceLocation FieldLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001127 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
1128 break;
1129 }
Mike Stump11289f42009-09-09 15:08:12 +00001130
Sebastian Redl539c5062010-08-18 23:57:32 +00001131 case DESIG_ARRAY: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001132 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001133 SourceLocation LBracketLoc = readSourceLocation();
1134 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001135 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
1136 break;
1137 }
1138
Sebastian Redl539c5062010-08-18 23:57:32 +00001139 case DESIG_ARRAY_RANGE: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001140 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001141 SourceLocation LBracketLoc = readSourceLocation();
1142 SourceLocation EllipsisLoc = readSourceLocation();
1143 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001144 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
1145 RBracketLoc));
1146 break;
1147 }
1148 }
1149 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001150 E->setDesignators(Record.getContext(),
Douglas Gregor03e8bdc2010-01-06 23:17:19 +00001151 Designators.data(), Designators.size());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001152}
1153
Yunzhong Gaocb779302015-06-10 00:27:52 +00001154void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1155 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001156 E->setBase(Record.readSubExpr());
1157 E->setUpdater(Record.readSubExpr());
Yunzhong Gaocb779302015-06-10 00:27:52 +00001158}
1159
1160void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1161 VisitExpr(E);
1162}
1163
Richard Smith410306b2016-12-12 02:53:20 +00001164void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1165 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001166 E->SubExprs[0] = Record.readSubExpr();
1167 E->SubExprs[1] = Record.readSubExpr();
Richard Smith410306b2016-12-12 02:53:20 +00001168}
1169
1170void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1171 VisitExpr(E);
1172}
1173
Sebastian Redl70c751d2010-08-18 23:56:52 +00001174void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001175 VisitExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001176}
1177
Sebastian Redl70c751d2010-08-18 23:56:52 +00001178void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001179 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001180 E->setSubExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001181 E->setWrittenTypeInfo(readTypeSourceInfo());
1182 E->setBuiltinLoc(readSourceLocation());
1183 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001184 E->setIsMicrosoftABI(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001185}
1186
Eric Fiselier708afb52019-05-16 21:04:15 +00001187void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1188 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001189 E->ParentContext = readDeclAs<DeclContext>();
1190 E->BuiltinLoc = readSourceLocation();
1191 E->RParenLoc = readSourceLocation();
Eric Fiselier708afb52019-05-16 21:04:15 +00001192 E->SourceLocExprBits.Kind =
1193 static_cast<SourceLocExpr::IdentKind>(Record.readInt());
1194}
1195
Sebastian Redl70c751d2010-08-18 23:56:52 +00001196void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001197 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001198 E->setAmpAmpLoc(readSourceLocation());
1199 E->setLabelLoc(readSourceLocation());
1200 E->setLabel(readDeclAs<LabelDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001201}
1202
Sebastian Redl70c751d2010-08-18 23:56:52 +00001203void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001204 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001205 E->setLParenLoc(readSourceLocation());
1206 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001207 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001208}
1209
Sebastian Redl70c751d2010-08-18 23:56:52 +00001210void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001211 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001212 E->setCond(Record.readSubExpr());
1213 E->setLHS(Record.readSubExpr());
1214 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001215 E->setBuiltinLoc(readSourceLocation());
1216 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001217 E->setIsConditionTrue(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001218}
1219
Sebastian Redl70c751d2010-08-18 23:56:52 +00001220void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001221 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001222 E->setTokenLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001223}
1224
Sebastian Redl70c751d2010-08-18 23:56:52 +00001225void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001226 VisitExpr(E);
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001227 SmallVector<Expr *, 16> Exprs;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001228 unsigned NumExprs = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001229 while (NumExprs--)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001230 Exprs.push_back(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001231 E->setExprs(Record.getContext(), Exprs);
John McCall3ce3d232019-12-13 03:37:23 -05001232 E->setBuiltinLoc(readSourceLocation());
1233 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001234}
1235
Hal Finkelc4d7c822013-09-18 03:29:45 +00001236void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1237 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001238 E->BuiltinLoc = readSourceLocation();
1239 E->RParenLoc = readSourceLocation();
1240 E->TInfo = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001241 E->SrcExpr = Record.readSubExpr();
Hal Finkelc4d7c822013-09-18 03:29:45 +00001242}
1243
Sebastian Redl70c751d2010-08-18 23:56:52 +00001244void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001245 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001246 E->setBlockDecl(readDeclAs<BlockDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001247}
1248
Peter Collingbourne91147592011-04-15 00:35:48 +00001249void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1250 VisitExpr(E);
Bruno Riccidb076832019-01-26 14:15:10 +00001251
1252 unsigned NumAssocs = Record.readInt();
1253 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
Bruno Ricci94498c72019-01-26 13:58:15 +00001254 E->ResultIndex = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001255 E->GenericSelectionExprBits.GenericLoc = readSourceLocation();
1256 E->DefaultLoc = readSourceLocation();
1257 E->RParenLoc = readSourceLocation();
Bruno Riccidb076832019-01-26 14:15:10 +00001258
1259 Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1260 // Add 1 to account for the controlling expression which is the first
1261 // expression in the trailing array of Stmt *. This is not needed for
1262 // the trailing array of TypeSourceInfo *.
1263 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1264 Stmts[I] = Record.readSubExpr();
1265
1266 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1267 for (unsigned I = 0, N = NumAssocs; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001268 TSIs[I] = readTypeSourceInfo();
Peter Collingbourne91147592011-04-15 00:35:48 +00001269}
1270
John McCallfe96e0b2011-11-06 09:01:30 +00001271void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1272 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001273 unsigned numSemanticExprs = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001274 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001275 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001276
1277 // Read the syntactic expression.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001278 E->getSubExprsBuffer()[0] = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001279
1280 // Read all the semantic expressions.
1281 for (unsigned i = 0; i != numSemanticExprs; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001282 Expr *subExpr = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001283 E->getSubExprsBuffer()[i+1] = subExpr;
1284 }
1285}
1286
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001287void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1288 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001289 E->Op = AtomicExpr::AtomicOp(Record.readInt());
Richard Smithaa22a8c2012-04-10 22:49:28 +00001290 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1291 for (unsigned I = 0; I != E->NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001292 E->SubExprs[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001293 E->BuiltinLoc = readSourceLocation();
1294 E->RParenLoc = readSourceLocation();
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001295}
1296
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001297//===----------------------------------------------------------------------===//
1298// Objective-C Expressions and Statements
1299
Sebastian Redl70c751d2010-08-18 23:56:52 +00001300void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001301 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001302 E->setString(cast<StringLiteral>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -05001303 E->setAtLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001304}
1305
Patrick Beard0caa3942012-04-19 00:25:12 +00001306void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001307 VisitExpr(E);
1308 // could be one of several IntegerLiteral, FloatLiteral, etc.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001309 E->SubExpr = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -05001310 E->BoxingMethod = readDeclAs<ObjCMethodDecl>();
1311 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001312}
1313
1314void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1315 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001316 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001317 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1318 Expr **Elements = E->getElements();
1319 for (unsigned I = 0, N = NumElements; I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001320 Elements[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001321 E->ArrayWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1322 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001323}
1324
1325void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1326 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001327 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001328 assert(NumElements == E->getNumElements() && "Wrong number of elements");
David L. Jonesbe1557a2016-12-21 00:17:49 +00001329 bool HasPackExpansions = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001330 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001331 auto *KeyValues =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001332 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001333 auto *Expansions =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001334 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001335 for (unsigned I = 0; I != NumElements; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001336 KeyValues[I].Key = Record.readSubExpr();
1337 KeyValues[I].Value = Record.readSubExpr();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001338 if (HasPackExpansions) {
John McCall3ce3d232019-12-13 03:37:23 -05001339 Expansions[I].EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001340 Expansions[I].NumExpansionsPlusOne = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001341 }
1342 }
John McCall3ce3d232019-12-13 03:37:23 -05001343 E->DictWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1344 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001345}
1346
Sebastian Redl70c751d2010-08-18 23:56:52 +00001347void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001348 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001349 E->setEncodedTypeSourceInfo(readTypeSourceInfo());
1350 E->setAtLoc(readSourceLocation());
1351 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001352}
1353
Sebastian Redl70c751d2010-08-18 23:56:52 +00001354void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001355 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001356 E->setSelector(Record.readSelector());
John McCall3ce3d232019-12-13 03:37:23 -05001357 E->setAtLoc(readSourceLocation());
1358 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001359}
1360
Sebastian Redl70c751d2010-08-18 23:56:52 +00001361void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001362 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001363 E->setProtocol(readDeclAs<ObjCProtocolDecl>());
1364 E->setAtLoc(readSourceLocation());
1365 E->ProtoLoc = readSourceLocation();
1366 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001367}
1368
Sebastian Redl70c751d2010-08-18 23:56:52 +00001369void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001370 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001371 E->setDecl(readDeclAs<ObjCIvarDecl>());
1372 E->setLocation(readSourceLocation());
1373 E->setOpLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001374 E->setBase(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001375 E->setIsArrow(Record.readInt());
1376 E->setIsFreeIvar(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001377}
1378
Sebastian Redl70c751d2010-08-18 23:56:52 +00001379void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001380 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001381 unsigned MethodRefFlags = Record.readInt();
1382 bool Implicit = Record.readInt() != 0;
John McCallb7bd14f2010-12-02 01:19:52 +00001383 if (Implicit) {
John McCall3ce3d232019-12-13 03:37:23 -05001384 auto *Getter = readDeclAs<ObjCMethodDecl>();
1385 auto *Setter = readDeclAs<ObjCMethodDecl>();
Argyrios Kyrtzidisab468b02012-03-30 00:19:18 +00001386 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCallb7bd14f2010-12-02 01:19:52 +00001387 } else {
John McCall3ce3d232019-12-13 03:37:23 -05001388 E->setExplicitProperty(readDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001389 }
John McCall3ce3d232019-12-13 03:37:23 -05001390 E->setLocation(readSourceLocation());
1391 E->setReceiverLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001392 switch (Record.readInt()) {
John McCallb7bd14f2010-12-02 01:19:52 +00001393 case 0:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001394 E->setBase(Record.readSubExpr());
John McCallb7bd14f2010-12-02 01:19:52 +00001395 break;
1396 case 1:
David L. Jonesbe1557a2016-12-21 00:17:49 +00001397 E->setSuperReceiver(Record.readType());
John McCallb7bd14f2010-12-02 01:19:52 +00001398 break;
1399 case 2:
John McCall3ce3d232019-12-13 03:37:23 -05001400 E->setClassReceiver(readDeclAs<ObjCInterfaceDecl>());
John McCallb7bd14f2010-12-02 01:19:52 +00001401 break;
1402 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001403}
1404
Ted Kremeneke65b0862012-03-06 20:05:56 +00001405void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1406 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001407 E->setRBracket(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001408 E->setBaseExpr(Record.readSubExpr());
1409 E->setKeyExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001410 E->GetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1411 E->SetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001412}
1413
Sebastian Redl70c751d2010-08-18 23:56:52 +00001414void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001415 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001416 assert(Record.peekInt() == E->getNumArgs());
1417 Record.skipInts(1);
1418 unsigned NumStoredSelLocs = Record.readInt();
1419 E->SelLocsKind = Record.readInt();
1420 E->setDelegateInitCall(Record.readInt());
1421 E->IsImplicit = Record.readInt();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001422 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
Douglas Gregor9a129192010-04-21 00:45:42 +00001423 switch (Kind) {
1424 case ObjCMessageExpr::Instance:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001425 E->setInstanceReceiver(Record.readSubExpr());
Douglas Gregor9a129192010-04-21 00:45:42 +00001426 break;
1427
1428 case ObjCMessageExpr::Class:
John McCall3ce3d232019-12-13 03:37:23 -05001429 E->setClassReceiver(readTypeSourceInfo());
Douglas Gregor9a129192010-04-21 00:45:42 +00001430 break;
1431
1432 case ObjCMessageExpr::SuperClass:
1433 case ObjCMessageExpr::SuperInstance: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001434 QualType T = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001435 SourceLocation SuperLoc = readSourceLocation();
Douglas Gregor9a129192010-04-21 00:45:42 +00001436 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1437 break;
1438 }
1439 }
1440
1441 assert(Kind == E->getReceiverKind());
1442
David L. Jonesbe1557a2016-12-21 00:17:49 +00001443 if (Record.readInt())
John McCall3ce3d232019-12-13 03:37:23 -05001444 E->setMethodDecl(readDeclAs<ObjCMethodDecl>());
Douglas Gregor9a129192010-04-21 00:45:42 +00001445 else
David L. Jonesb6a8f022016-12-21 04:34:52 +00001446 E->setSelector(Record.readSelector());
Douglas Gregor9a129192010-04-21 00:45:42 +00001447
John McCall3ce3d232019-12-13 03:37:23 -05001448 E->LBracLoc = readSourceLocation();
1449 E->RBracLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001450
1451 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001452 E->setArg(I, Record.readSubExpr());
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00001453
1454 SourceLocation *Locs = E->getStoredSelLocs();
1455 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001456 Locs[I] = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001457}
1458
Sebastian Redl70c751d2010-08-18 23:56:52 +00001459void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001460 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001461 S->setElement(Record.readSubStmt());
1462 S->setCollection(Record.readSubExpr());
1463 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001464 S->setForLoc(readSourceLocation());
1465 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001466}
1467
Sebastian Redl70c751d2010-08-18 23:56:52 +00001468void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001469 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001470 S->setCatchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001471 S->setCatchParamDecl(readDeclAs<VarDecl>());
1472 S->setAtCatchLoc(readSourceLocation());
1473 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001474}
1475
Sebastian Redl70c751d2010-08-18 23:56:52 +00001476void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001477 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001478 S->setFinallyBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001479 S->setAtFinallyLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001480}
1481
John McCall31168b02011-06-15 23:02:42 +00001482void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001483 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001484 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001485 S->setAtLoc(readSourceLocation());
John McCall31168b02011-06-15 23:02:42 +00001486}
1487
Sebastian Redl70c751d2010-08-18 23:56:52 +00001488void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001489 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001490 assert(Record.peekInt() == S->getNumCatchStmts());
1491 Record.skipInts(1);
1492 bool HasFinally = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001493 S->setTryBody(Record.readSubStmt());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001494 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001495 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
Douglas Gregor96c79492010-04-23 22:50:49 +00001496
Douglas Gregor96c79492010-04-23 22:50:49 +00001497 if (HasFinally)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001498 S->setFinallyStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001499 S->setAtTryLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001500}
1501
Sebastian Redl70c751d2010-08-18 23:56:52 +00001502void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001503 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001504 S->setSynchExpr(Record.readSubStmt());
1505 S->setSynchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001506 S->setAtSynchronizedLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001507}
1508
Sebastian Redl70c751d2010-08-18 23:56:52 +00001509void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001510 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001511 S->setThrowExpr(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001512 S->setThrowLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001513}
1514
Ted Kremeneke65b0862012-03-06 20:05:56 +00001515void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1516 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001517 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001518 E->setLocation(readSourceLocation());
Ted Kremeneke65b0862012-03-06 20:05:56 +00001519}
1520
Erik Pilkington29099de2016-07-16 00:35:23 +00001521void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1522 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001523 SourceRange R = Record.readSourceRange();
Erik Pilkington29099de2016-07-16 00:35:23 +00001524 E->AtLoc = R.getBegin();
1525 E->RParen = R.getEnd();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001526 E->VersionToCheck = Record.readVersionTuple();
Erik Pilkington29099de2016-07-16 00:35:23 +00001527}
1528
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001529//===----------------------------------------------------------------------===//
1530// C++ Expressions and Statements
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001531//===----------------------------------------------------------------------===//
1532
Sebastian Redl70c751d2010-08-18 23:56:52 +00001533void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001534 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001535 S->CatchLoc = readSourceLocation();
1536 S->ExceptionDecl = readDeclAs<VarDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001537 S->HandlerBlock = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001538}
1539
Sebastian Redl70c751d2010-08-18 23:56:52 +00001540void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001541 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001542 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1543 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -05001544 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001545 S->getStmts()[0] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001546 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001547 S->getStmts()[i + 1] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001548}
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001549
Richard Smith02e85f32011-04-14 22:09:26 +00001550void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1551 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001552 S->ForLoc = readSourceLocation();
1553 S->CoawaitLoc = readSourceLocation();
1554 S->ColonLoc = readSourceLocation();
1555 S->RParenLoc = readSourceLocation();
Richard Smith8baa5002018-09-28 18:44:09 +00001556 S->setInit(Record.readSubStmt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001557 S->setRangeStmt(Record.readSubStmt());
1558 S->setBeginStmt(Record.readSubStmt());
1559 S->setEndStmt(Record.readSubStmt());
1560 S->setCond(Record.readSubExpr());
1561 S->setInc(Record.readSubExpr());
1562 S->setLoopVarStmt(Record.readSubStmt());
1563 S->setBody(Record.readSubStmt());
Richard Smith02e85f32011-04-14 22:09:26 +00001564}
1565
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001566void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1567 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001568 S->KeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001569 S->IsIfExists = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001570 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001571 S->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001572 S->SubStmt = Record.readSubStmt();
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001573}
1574
Sebastian Redl70c751d2010-08-18 23:56:52 +00001575void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001576 VisitCallExpr(E);
Bruno Riccifeb19232018-12-21 16:51:57 +00001577 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1578 E->CXXOperatorCallExprBits.FPFeatures = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001579 E->Range = Record.readSourceRange();
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001580}
1581
Richard Smith778dc0f2019-10-19 00:04:38 +00001582void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1583 CXXRewrittenBinaryOperator *E) {
1584 VisitExpr(E);
1585 E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1586 E->SemanticForm = Record.readSubExpr();
1587}
1588
Sebastian Redl70c751d2010-08-18 23:56:52 +00001589void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001590 VisitExpr(E);
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001591
1592 unsigned NumArgs = Record.readInt();
1593 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1594
1595 E->CXXConstructExprBits.Elidable = Record.readInt();
1596 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1597 E->CXXConstructExprBits.ListInitialization = Record.readInt();
1598 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1599 E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1600 E->CXXConstructExprBits.ConstructionKind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001601 E->CXXConstructExprBits.Loc = readSourceLocation();
1602 E->Constructor = readDeclAs<CXXConstructorDecl>();
1603 E->ParenOrBraceRange = readSourceRange();
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001604
1605 for (unsigned I = 0; I != NumArgs; ++I)
1606 E->setArg(I, Record.readSubExpr());
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001607}
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001608
Richard Smith5179eb72016-06-28 19:03:57 +00001609void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1610 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001611 E->Constructor = readDeclAs<CXXConstructorDecl>();
1612 E->Loc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001613 E->ConstructsVirtualBase = Record.readInt();
1614 E->InheritedFromVirtualBase = Record.readInt();
Richard Smith5179eb72016-06-28 19:03:57 +00001615}
1616
Sebastian Redl70c751d2010-08-18 23:56:52 +00001617void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001618 VisitCXXConstructExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001619 E->TSI = readTypeSourceInfo();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001620}
1621
Douglas Gregore31e6062012-02-07 10:09:13 +00001622void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1623 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001624 unsigned NumCaptures = Record.readInt();
Douglas Gregor99ae8062012-02-14 17:54:36 +00001625 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
John McCall3ce3d232019-12-13 03:37:23 -05001626 E->IntroducerRange = readSourceRange();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001627 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001628 E->CaptureDefaultLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001629 E->ExplicitParams = Record.readInt();
1630 E->ExplicitResultType = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001631 E->ClosingBrace = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001632
Douglas Gregor99ae8062012-02-14 17:54:36 +00001633 // Read capture initializers.
1634 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1635 CEnd = E->capture_init_end();
1636 C != CEnd; ++C)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001637 *C = Record.readSubExpr();
Douglas Gregore31e6062012-02-07 10:09:13 +00001638}
1639
Richard Smithcc1b96d2013-06-12 22:31:48 +00001640void
1641ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1642 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001643 E->SubExpr = Record.readSubExpr();
Richard Smithcc1b96d2013-06-12 22:31:48 +00001644}
1645
Sebastian Redl70c751d2010-08-18 23:56:52 +00001646void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001647 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001648 SourceRange R = readSourceRange();
Douglas Gregor4478f852011-01-12 22:41:29 +00001649 E->Loc = R.getBegin();
1650 E->RParenLoc = R.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05001651 R = readSourceRange();
Fariborz Jahanianf0738712013-02-22 22:02:53 +00001652 E->AngleBrackets = R;
Sam Weinigd01101e2010-01-16 21:21:01 +00001653}
1654
Sebastian Redl70c751d2010-08-18 23:56:52 +00001655void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001656 return VisitCXXNamedCastExpr(E);
1657}
1658
Sebastian Redl70c751d2010-08-18 23:56:52 +00001659void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001660 return VisitCXXNamedCastExpr(E);
1661}
1662
Sebastian Redl70c751d2010-08-18 23:56:52 +00001663void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001664 return VisitCXXNamedCastExpr(E);
1665}
1666
Sebastian Redl70c751d2010-08-18 23:56:52 +00001667void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001668 return VisitCXXNamedCastExpr(E);
1669}
1670
Sebastian Redl70c751d2010-08-18 23:56:52 +00001671void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001672 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001673 E->setLParenLoc(readSourceLocation());
1674 E->setRParenLoc(readSourceLocation());
Sam Weinigd01101e2010-01-16 21:21:01 +00001675}
1676
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001677void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1678 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001679 E->KWLoc = readSourceLocation();
1680 E->RParenLoc = readSourceLocation();
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001681}
1682
Richard Smithc67fdd42012-03-07 08:35:16 +00001683void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1684 VisitCallExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001685 E->UDSuffixLoc = readSourceLocation();
Richard Smithc67fdd42012-03-07 08:35:16 +00001686}
1687
Sebastian Redl70c751d2010-08-18 23:56:52 +00001688void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001689 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001690 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001691 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001692}
1693
Sebastian Redl70c751d2010-08-18 23:56:52 +00001694void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001695 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001696 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001697}
1698
Sebastian Redl70c751d2010-08-18 23:56:52 +00001699void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001700 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001701 E->setSourceRange(readSourceRange());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001702 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redlc67764e2010-07-22 22:43:28 +00001703 E->setTypeOperandSourceInfo(
John McCall3ce3d232019-12-13 03:37:23 -05001704 readTypeSourceInfo());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001705 return;
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001706 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001707
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001708 // typeid(42+2)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001709 E->setExprOperand(Record.readSubExpr());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001710}
1711
Sebastian Redl70c751d2010-08-18 23:56:52 +00001712void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001713 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001714 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001715 E->setImplicit(Record.readInt());
Chris Lattner98267332010-05-09 06:15:05 +00001716}
1717
Sebastian Redl70c751d2010-08-18 23:56:52 +00001718void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001719 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001720 E->CXXThrowExprBits.ThrowLoc = readSourceLocation();
Bruno Riccib7de97b2018-11-17 12:53:56 +00001721 E->Operand = Record.readSubExpr();
1722 E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
Chris Lattner98267332010-05-09 06:15:05 +00001723}
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001724
Sebastian Redl70c751d2010-08-18 23:56:52 +00001725void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattnere2437f42010-05-09 06:40:08 +00001726 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001727 E->Param = readDeclAs<ParmVarDecl>();
1728 E->UsedContext = readDeclAs<DeclContext>();
1729 E->CXXDefaultArgExprBits.Loc = readSourceLocation();
Chris Lattnercba86142010-05-10 00:25:06 +00001730}
1731
Richard Smith852c9db2013-04-20 22:23:05 +00001732void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1733 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001734 E->Field = readDeclAs<FieldDecl>();
1735 E->UsedContext = readDeclAs<DeclContext>();
1736 E->CXXDefaultInitExprBits.Loc = readSourceLocation();
Richard Smith852c9db2013-04-20 22:23:05 +00001737}
1738
Sebastian Redl70c751d2010-08-18 23:56:52 +00001739void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001740 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001741 E->setTemporary(Record.readCXXTemporary());
1742 E->setSubExpr(Record.readSubExpr());
Chris Lattnercba86142010-05-10 00:25:06 +00001743}
1744
Sebastian Redl70c751d2010-08-18 23:56:52 +00001745void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001746 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001747 E->TypeInfo = readTypeSourceInfo();
1748 E->CXXScalarValueInitExprBits.RParenLoc = readSourceLocation();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001749}
1750
Sebastian Redl70c751d2010-08-18 23:56:52 +00001751void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001752 VisitExpr(E);
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001753
1754 bool IsArray = Record.readInt();
1755 bool HasInit = Record.readInt();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001756 unsigned NumPlacementArgs = Record.readInt();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001757 bool IsParenTypeId = Record.readInt();
1758
1759 E->CXXNewExprBits.IsGlobalNew = Record.readInt();
1760 E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
1761 E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1762 E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
1763
1764 assert((IsArray == E->isArray()) && "Wrong IsArray!");
1765 assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
1766 assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
1767 "Wrong NumPlacementArgs!");
1768 assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
1769 (void)IsArray;
1770 (void)HasInit;
1771 (void)NumPlacementArgs;
1772
John McCall3ce3d232019-12-13 03:37:23 -05001773 E->setOperatorNew(readDeclAs<FunctionDecl>());
1774 E->setOperatorDelete(readDeclAs<FunctionDecl>());
1775 E->AllocatedTypeInfo = readTypeSourceInfo();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001776 if (IsParenTypeId)
John McCall3ce3d232019-12-13 03:37:23 -05001777 E->getTrailingObjects<SourceRange>()[0] = readSourceRange();
1778 E->Range = readSourceRange();
1779 E->DirectInitRange = readSourceRange();
Chandler Carruth01718152010-10-25 08:47:36 +00001780
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001781 // Install all the subexpressions.
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001782 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
1783 N = E->raw_arg_end();
1784 I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001785 *I = Record.readSubStmt();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001786}
1787
Sebastian Redl70c751d2010-08-18 23:56:52 +00001788void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001789 VisitExpr(E);
Bruno Ricci91728fc2018-12-03 12:32:32 +00001790 E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
1791 E->CXXDeleteExprBits.ArrayForm = Record.readInt();
1792 E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
1793 E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001794 E->OperatorDelete = readDeclAs<FunctionDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001795 E->Argument = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001796 E->CXXDeleteExprBits.Loc = readSourceLocation();
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001797}
Chris Lattnercba86142010-05-10 00:25:06 +00001798
Sebastian Redl70c751d2010-08-18 23:56:52 +00001799void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001800 VisitExpr(E);
1801
David L. Jonesb6a8f022016-12-21 04:34:52 +00001802 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001803 E->IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001804 E->OperatorLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001805 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001806 E->ScopeType = readTypeSourceInfo();
1807 E->ColonColonLoc = readSourceLocation();
1808 E->TildeLoc = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001809
John McCall3ce3d232019-12-13 03:37:23 -05001810 IdentifierInfo *II = Record.readIdentifier();
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001811 if (II)
John McCall3ce3d232019-12-13 03:37:23 -05001812 E->setDestroyedType(II, readSourceLocation());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001813 else
John McCall3ce3d232019-12-13 03:37:23 -05001814 E->setDestroyedType(readTypeSourceInfo());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001815}
1816
John McCall5d413782010-12-06 08:20:24 +00001817void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001818 VisitExpr(E);
John McCall28fc7092011-11-10 05:35:25 +00001819
David L. Jonesbe1557a2016-12-21 00:17:49 +00001820 unsigned NumObjects = Record.readInt();
John McCall28fc7092011-11-10 05:35:25 +00001821 assert(NumObjects == E->getNumObjects());
1822 for (unsigned i = 0; i != NumObjects; ++i)
James Y Knighte00a67e2015-12-31 04:18:25 +00001823 E->getTrailingObjects<BlockDecl *>()[i] =
John McCall3ce3d232019-12-13 03:37:23 -05001824 readDeclAs<BlockDecl>();
John McCall28fc7092011-11-10 05:35:25 +00001825
David L. Jonesbe1557a2016-12-21 00:17:49 +00001826 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001827 E->SubExpr = Record.readSubExpr();
Chris Lattnere2437f42010-05-09 06:40:08 +00001828}
1829
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001830void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1831 CXXDependentScopeMemberExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001832 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001833
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001834 bool HasTemplateKWAndArgsInfo = Record.readInt();
1835 unsigned NumTemplateArgs = Record.readInt();
1836 bool HasFirstQualifierFoundInScope = Record.readInt();
1837
1838 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
1839 "Wrong HasTemplateKWAndArgsInfo!");
1840 assert(
1841 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
1842 "Wrong HasFirstQualifierFoundInScope!");
1843
1844 if (HasTemplateKWAndArgsInfo)
James Y Knighte7d82282015-12-29 18:15:14 +00001845 ReadTemplateKWAndArgsInfo(
1846 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001847 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001848
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001849 assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
1850 "Wrong NumTemplateArgs!");
1851
1852 E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001853 E->CXXDependentScopeMemberExprBits.OperatorLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001854 E->BaseType = Record.readType();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001855 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001856 E->Base = Record.readSubExpr();
1857
1858 if (HasFirstQualifierFoundInScope)
John McCall3ce3d232019-12-13 03:37:23 -05001859 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001860
John McCall3ce3d232019-12-13 03:37:23 -05001861 E->MemberNameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001862}
1863
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001864void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001865ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001866 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001867
David L. Jonesbe1557a2016-12-21 00:17:49 +00001868 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001869 ReadTemplateKWAndArgsInfo(
1870 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1871 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001872 /*NumTemplateArgs=*/Record.readInt());
Douglas Gregor3a43fd62011-02-25 20:49:16 +00001873
David L. Jonesb6a8f022016-12-21 04:34:52 +00001874 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001875 E->NameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001876}
1877
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001878void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001879ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001880 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001881 assert(Record.peekInt() == E->arg_size() &&
1882 "Read wrong record during creation ?");
1883 Record.skipInts(1);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001884 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001885 E->setArg(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001886 E->TSI = readTypeSourceInfo();
1887 E->setLParenLoc(readSourceLocation());
1888 E->setRParenLoc(readSourceLocation());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001889}
1890
Sebastian Redl70c751d2010-08-18 23:56:52 +00001891void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001892 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001893
Bruno Riccid7628d92019-01-09 15:43:19 +00001894 unsigned NumResults = Record.readInt();
1895 bool HasTemplateKWAndArgsInfo = Record.readInt();
1896 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
1897 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
1898 "Wrong HasTemplateKWAndArgsInfo!");
1899
1900 if (HasTemplateKWAndArgsInfo) {
1901 unsigned NumTemplateArgs = Record.readInt();
James Y Knighte7d82282015-12-29 18:15:14 +00001902 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1903 E->getTrailingTemplateArgumentLoc(),
Bruno Riccid7628d92019-01-09 15:43:19 +00001904 NumTemplateArgs);
1905 assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
1906 "Wrong NumTemplateArgs!");
1907 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001908
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001909 UnresolvedSet<8> Decls;
Bruno Riccid7628d92019-01-09 15:43:19 +00001910 for (unsigned I = 0; I != NumResults; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -05001911 auto *D = readDeclAs<NamedDecl>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001912 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001913 Decls.addDecl(D, AS);
1914 }
Bruno Riccid7628d92019-01-09 15:43:19 +00001915
1916 DeclAccessPair *Results = E->getTrailingResults();
1917 UnresolvedSetIterator Iter = Decls.begin();
1918 for (unsigned I = 0; I != NumResults; ++I) {
1919 Results[I] = (Iter + I).getPair();
1920 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001921
John McCall3ce3d232019-12-13 03:37:23 -05001922 E->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001923 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001924}
1925
Sebastian Redl70c751d2010-08-18 23:56:52 +00001926void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001927 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00001928 E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
1929 E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001930 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001931 E->BaseType = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001932 E->OperatorLoc = readSourceLocation();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001933}
1934
Sebastian Redl70c751d2010-08-18 23:56:52 +00001935void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001936 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00001937 E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
1938 E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001939 E->NamingClass = readDeclAs<CXXRecordDecl>();
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00001940}
1941
Douglas Gregor29c42f22012-02-24 07:38:34 +00001942void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1943 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001944 E->TypeTraitExprBits.NumArgs = Record.readInt();
1945 E->TypeTraitExprBits.Kind = Record.readInt();
1946 E->TypeTraitExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001947 SourceRange Range = readSourceRange();
Jordan Rose99e80c12013-12-20 01:26:47 +00001948 E->Loc = Range.getBegin();
1949 E->RParenLoc = Range.getEnd();
1950
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001951 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001952 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001953 Args[I] = readTypeSourceInfo();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001954}
1955
John Wiegley6242b6a2011-04-28 00:16:57 +00001956void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1957 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001958 E->ATT = (ArrayTypeTrait)Record.readInt();
1959 E->Value = (unsigned int)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001960 SourceRange Range = readSourceRange();
John Wiegley6242b6a2011-04-28 00:16:57 +00001961 E->Loc = Range.getBegin();
1962 E->RParen = Range.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05001963 E->QueriedType = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001964 E->Dimension = Record.readSubExpr();
John Wiegley6242b6a2011-04-28 00:16:57 +00001965}
1966
John Wiegleyf9f65842011-04-25 06:54:41 +00001967void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1968 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001969 E->ET = (ExpressionTrait)Record.readInt();
1970 E->Value = (bool)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001971 SourceRange Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001972 E->QueriedExpression = Record.readSubExpr();
John Wiegleyf9f65842011-04-25 06:54:41 +00001973 E->Loc = Range.getBegin();
1974 E->RParen = Range.getEnd();
1975}
1976
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001977void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1978 VisitExpr(E);
Bruno Riccid56edfe2019-01-08 14:44:34 +00001979 E->CXXNoexceptExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001980 E->Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001981 E->Operand = Record.readSubExpr();
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001982}
1983
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001984void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1985 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001986 E->EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001987 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001988 E->Pattern = Record.readSubExpr();
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001989}
1990
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001991void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1992 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001993 unsigned NumPartialArgs = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001994 E->OperatorLoc = readSourceLocation();
1995 E->PackLoc = readSourceLocation();
1996 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001997 E->Pack = Record.readDeclAs<NamedDecl>();
Richard Smithd784e682015-09-23 21:41:42 +00001998 if (E->isPartiallySubstituted()) {
1999 assert(E->Length == NumPartialArgs);
James Y Knighte00a67e2015-12-31 04:18:25 +00002000 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
Richard Smithd784e682015-09-23 21:41:42 +00002001 *E = I + NumPartialArgs;
2002 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002003 new (I) TemplateArgument(Record.readTemplateArgument());
Richard Smithd784e682015-09-23 21:41:42 +00002004 } else if (!E->isValueDependent()) {
David L. Jonesbe1557a2016-12-21 00:17:49 +00002005 E->Length = Record.readInt();
Richard Smithd784e682015-09-23 21:41:42 +00002006 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00002007}
2008
John McCallfa194042011-07-15 07:00:14 +00002009void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
2010 SubstNonTypeTemplateParmExpr *E) {
2011 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002012 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
2013 E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002014 E->Replacement = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002015}
2016
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002017void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
2018 SubstNonTypeTemplateParmPackExpr *E) {
2019 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002020 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002021 TemplateArgument ArgPack = Record.readTemplateArgument();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002022 if (ArgPack.getKind() != TemplateArgument::Pack)
2023 return;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002024
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002025 E->Arguments = ArgPack.pack_begin();
2026 E->NumArguments = ArgPack.pack_size();
John McCall3ce3d232019-12-13 03:37:23 -05002027 E->NameLoc = readSourceLocation();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002028}
2029
Richard Smithb15fe3a2012-09-12 00:56:43 +00002030void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2031 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002032 E->NumParameters = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002033 E->ParamPack = readDeclAs<ParmVarDecl>();
2034 E->NameLoc = readSourceLocation();
Richard Smithb2997f52019-05-21 20:10:50 +00002035 auto **Parms = E->getTrailingObjects<VarDecl *>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00002036 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
John McCall3ce3d232019-12-13 03:37:23 -05002037 Parms[i] = readDeclAs<VarDecl>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00002038}
2039
Douglas Gregorfe314812011-06-21 17:03:29 +00002040void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
2041 VisitExpr(E);
Tykerb0561b32019-11-17 11:41:55 +01002042 bool HasMaterialzedDecl = Record.readInt();
2043 if (HasMaterialzedDecl)
2044 E->State = cast<LifetimeExtendedTemporaryDecl>(Record.readDecl());
2045 else
2046 E->State = Record.readSubExpr();
Douglas Gregorfe314812011-06-21 17:03:29 +00002047}
2048
Richard Smith0f0af192014-11-08 05:07:16 +00002049void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
2050 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002051 E->LParenLoc = readSourceLocation();
2052 E->EllipsisLoc = readSourceLocation();
2053 E->RParenLoc = readSourceLocation();
Richard Smithc7214f62019-05-13 08:31:14 +00002054 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002055 E->SubExprs[0] = Record.readSubExpr();
2056 E->SubExprs[1] = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002057 E->Opcode = (BinaryOperatorKind)Record.readInt();
Richard Smith0f0af192014-11-08 05:07:16 +00002058}
2059
John McCall8d69a212010-11-15 23:31:06 +00002060void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
2061 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002062 E->SourceExpr = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05002063 E->OpaqueValueExprBits.Loc = readSourceLocation();
Akira Hatanaka797afe32018-03-20 01:47:58 +00002064 E->setIsUnique(Record.readInt());
John McCall8d69a212010-11-15 23:31:06 +00002065}
2066
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00002067void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
2068 llvm_unreachable("Cannot read TypoExpr nodes");
2069}
2070
Peter Collingbourne41f85462011-02-09 21:07:24 +00002071//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002072// Microsoft Expressions and Statements
2073//===----------------------------------------------------------------------===//
John McCall5e77d762013-04-16 07:28:30 +00002074void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
2075 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002076 E->IsArrow = (Record.readInt() != 0);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002077 E->BaseExpr = Record.readSubExpr();
2078 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05002079 E->MemberLoc = readSourceLocation();
2080 E->TheDecl = readDeclAs<MSPropertyDecl>();
John McCall5e77d762013-04-16 07:28:30 +00002081}
2082
Alexey Bataevf7630272015-11-25 12:01:00 +00002083void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
2084 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002085 E->setBase(Record.readSubExpr());
2086 E->setIdx(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05002087 E->setRBracketLoc(readSourceLocation());
Alexey Bataevf7630272015-11-25 12:01:00 +00002088}
2089
John McCallfa194042011-07-15 07:00:14 +00002090void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
2091 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002092 E->setSourceRange(readSourceRange());
2093 std::string UuidStr = readString();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002094 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
John McCallfa194042011-07-15 07:00:14 +00002095 if (E->isTypeOperand()) { // __uuidof(ComType)
2096 E->setTypeOperandSourceInfo(
John McCall3ce3d232019-12-13 03:37:23 -05002097 readTypeSourceInfo());
John McCallfa194042011-07-15 07:00:14 +00002098 return;
2099 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002100
John McCallfa194042011-07-15 07:00:14 +00002101 // __uuidof(expr)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002102 E->setExprOperand(Record.readSubExpr());
John McCallfa194042011-07-15 07:00:14 +00002103}
2104
Nico Weber9b982072014-07-07 00:12:30 +00002105void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
2106 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002107 S->setLeaveLoc(readSourceLocation());
Nico Weber9b982072014-07-07 00:12:30 +00002108}
2109
John McCallfa194042011-07-15 07:00:14 +00002110void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
2111 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002112 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002113 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
2114 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002115}
2116
2117void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
2118 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002119 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002120 S->Block = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002121}
2122
2123void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
2124 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002125 S->IsCXXTry = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002126 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002127 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
2128 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002129}
2130
2131//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00002132// CUDA Expressions and Statements
2133//===----------------------------------------------------------------------===//
2134
2135void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2136 VisitCallExpr(E);
Richard Smithfd420792019-05-24 23:26:07 +00002137 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
Peter Collingbourne41f85462011-02-09 21:07:24 +00002138}
2139
John McCallfa194042011-07-15 07:00:14 +00002140//===----------------------------------------------------------------------===//
2141// OpenCL Expressions and Statements.
2142//===----------------------------------------------------------------------===//
2143void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2144 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002145 E->BuiltinLoc = readSourceLocation();
2146 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002147 E->SrcExpr = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002148}
2149
2150//===----------------------------------------------------------------------===//
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002151// OpenMP Directives.
2152//===----------------------------------------------------------------------===//
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002153
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002154void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
John McCall3ce3d232019-12-13 03:37:23 -05002155 E->setLocStart(readSourceLocation());
2156 E->setLocEnd(readSourceLocation());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002157 SmallVector<OMPClause *, 5> Clauses;
2158 for (unsigned i = 0; i < E->getNumClauses(); ++i)
John McCallc2f18312019-12-14 03:01:28 -05002159 Clauses.push_back(Record.readOMPClause());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002160 E->setClauses(Clauses);
Alexey Bataev68446b72014-07-18 07:47:19 +00002161 if (E->hasAssociatedStmt())
David L. Jonesb6a8f022016-12-21 04:34:52 +00002162 E->setAssociatedStmt(Record.readSubStmt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002163}
2164
Alexander Musman3aaab662014-08-19 11:27:13 +00002165void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2166 VisitStmt(D);
2167 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002168 Record.skipInts(2);
Alexander Musman3aaab662014-08-19 11:27:13 +00002169 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002170 D->setIterationVariable(Record.readSubExpr());
2171 D->setLastIteration(Record.readSubExpr());
2172 D->setCalcLastIteration(Record.readSubExpr());
2173 D->setPreCond(Record.readSubExpr());
2174 D->setCond(Record.readSubExpr());
2175 D->setInit(Record.readSubExpr());
2176 D->setInc(Record.readSubExpr());
2177 D->setPreInits(Record.readSubStmt());
Alexey Bataev3392d762016-02-16 11:18:12 +00002178 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
Carlo Bertollifc35ad22016-03-07 16:04:49 +00002179 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2180 isOpenMPDistributeDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002181 D->setIsLastIterVariable(Record.readSubExpr());
2182 D->setLowerBoundVariable(Record.readSubExpr());
2183 D->setUpperBoundVariable(Record.readSubExpr());
2184 D->setStrideVariable(Record.readSubExpr());
2185 D->setEnsureUpperBound(Record.readSubExpr());
2186 D->setNextLowerBound(Record.readSubExpr());
2187 D->setNextUpperBound(Record.readSubExpr());
2188 D->setNumIterations(Record.readSubExpr());
Alexander Musmanc6388682014-12-15 07:07:06 +00002189 }
Carlo Bertolli9925f152016-06-27 14:55:37 +00002190 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002191 D->setPrevLowerBoundVariable(Record.readSubExpr());
2192 D->setPrevUpperBoundVariable(Record.readSubExpr());
Carlo Bertolli8429d812017-02-17 21:29:13 +00002193 D->setDistInc(Record.readSubExpr());
2194 D->setPrevEnsureUpperBound(Record.readSubExpr());
Carlo Bertolliffafe102017-04-20 00:39:39 +00002195 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2196 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2197 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2198 D->setCombinedInit(Record.readSubExpr());
2199 D->setCombinedCond(Record.readSubExpr());
2200 D->setCombinedNextLowerBound(Record.readSubExpr());
2201 D->setCombinedNextUpperBound(Record.readSubExpr());
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00002202 D->setCombinedDistCond(Record.readSubExpr());
2203 D->setCombinedParForInDistCond(Record.readSubExpr());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002204 }
Alexander Musmana5f070a2014-10-01 06:03:56 +00002205 SmallVector<Expr *, 4> Sub;
2206 unsigned CollapsedNum = D->getCollapsedNumber();
2207 Sub.reserve(CollapsedNum);
2208 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002209 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002210 D->setCounters(Sub);
2211 Sub.clear();
2212 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002213 Sub.push_back(Record.readSubExpr());
Alexey Bataeva8899172015-08-06 12:30:57 +00002214 D->setPrivateCounters(Sub);
2215 Sub.clear();
2216 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002217 Sub.push_back(Record.readSubExpr());
Alexey Bataevb08f89f2015-08-14 12:25:37 +00002218 D->setInits(Sub);
2219 Sub.clear();
2220 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002221 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002222 D->setUpdates(Sub);
2223 Sub.clear();
2224 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002225 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002226 D->setFinals(Sub);
Alexey Bataevf8be4762019-08-14 19:30:06 +00002227 Sub.clear();
2228 for (unsigned i = 0; i < CollapsedNum; ++i)
2229 Sub.push_back(Record.readSubExpr());
2230 D->setDependentCounters(Sub);
2231 Sub.clear();
2232 for (unsigned i = 0; i < CollapsedNum; ++i)
2233 Sub.push_back(Record.readSubExpr());
2234 D->setDependentInits(Sub);
2235 Sub.clear();
2236 for (unsigned i = 0; i < CollapsedNum; ++i)
2237 Sub.push_back(Record.readSubExpr());
2238 D->setFinalsConditions(Sub);
Alexander Musman3aaab662014-08-19 11:27:13 +00002239}
2240
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002241void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002242 VisitStmt(D);
2243 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002244 Record.skipInts(1);
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002245 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002246 D->setHasCancel(Record.readInt());
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002247}
2248
2249void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002250 VisitOMPLoopDirective(D);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002251}
2252
Alexey Bataevf29276e2014-06-18 04:14:57 +00002253void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002254 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002255 D->setHasCancel(Record.readInt());
Alexey Bataevf29276e2014-06-18 04:14:57 +00002256}
2257
Alexander Musmanf82886e2014-09-18 05:12:34 +00002258void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2259 VisitOMPLoopDirective(D);
2260}
2261
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002262void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2263 VisitStmt(D);
2264 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002265 Record.skipInts(1);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002266 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002267 D->setHasCancel(Record.readInt());
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002268}
2269
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002270void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2271 VisitStmt(D);
2272 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002273 D->setHasCancel(Record.readInt());
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002274}
2275
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002276void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2277 VisitStmt(D);
2278 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002279 Record.skipInts(1);
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002280 VisitOMPExecutableDirective(D);
2281}
2282
Alexander Musman80c22892014-07-17 08:54:58 +00002283void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2284 VisitStmt(D);
2285 VisitOMPExecutableDirective(D);
2286}
2287
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002288void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2289 VisitStmt(D);
Alexey Bataev28c75412015-12-15 08:19:24 +00002290 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002291 Record.skipInts(1);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002292 VisitOMPExecutableDirective(D);
John McCall3ce3d232019-12-13 03:37:23 -05002293 D->DirName = Record.readDeclarationNameInfo();
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002294}
2295
Alexey Bataev4acb8592014-07-07 13:01:15 +00002296void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002297 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002298 D->setHasCancel(Record.readInt());
Alexey Bataev4acb8592014-07-07 13:01:15 +00002299}
2300
Alexander Musmane4e893b2014-09-23 09:33:00 +00002301void ASTStmtReader::VisitOMPParallelForSimdDirective(
2302 OMPParallelForSimdDirective *D) {
2303 VisitOMPLoopDirective(D);
2304}
2305
cchen47d60942019-12-05 13:43:48 -05002306void ASTStmtReader::VisitOMPParallelMasterDirective(
2307 OMPParallelMasterDirective *D) {
2308 VisitStmt(D);
2309 // The NumClauses field was read in ReadStmtFromStream.
2310 Record.skipInts(1);
2311 VisitOMPExecutableDirective(D);
2312}
2313
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002314void ASTStmtReader::VisitOMPParallelSectionsDirective(
2315 OMPParallelSectionsDirective *D) {
2316 VisitStmt(D);
2317 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002318 Record.skipInts(1);
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002319 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002320 D->setHasCancel(Record.readInt());
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002321}
2322
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002323void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2324 VisitStmt(D);
2325 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002326 Record.skipInts(1);
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002327 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002328 D->setHasCancel(Record.readInt());
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002329}
2330
Alexey Bataev68446b72014-07-18 07:47:19 +00002331void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2332 VisitStmt(D);
2333 VisitOMPExecutableDirective(D);
2334}
2335
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002336void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2337 VisitStmt(D);
2338 VisitOMPExecutableDirective(D);
2339}
2340
Alexey Bataev2df347a2014-07-18 10:17:07 +00002341void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2342 VisitStmt(D);
2343 VisitOMPExecutableDirective(D);
2344}
2345
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002346void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2347 VisitStmt(D);
Alexey Bataev169d96a2017-07-18 20:17:46 +00002348 // The NumClauses field was read in ReadStmtFromStream.
2349 Record.skipInts(1);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002350 VisitOMPExecutableDirective(D);
Alexey Bataev3b1b8952017-07-25 15:53:26 +00002351 D->setReductionRef(Record.readSubExpr());
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002352}
2353
Alexey Bataev6125da92014-07-21 11:26:11 +00002354void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2355 VisitStmt(D);
2356 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002357 Record.skipInts(1);
Alexey Bataev6125da92014-07-21 11:26:11 +00002358 VisitOMPExecutableDirective(D);
2359}
2360
Alexey Bataevc112e942020-02-28 09:52:15 -05002361void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective *D) {
2362 VisitStmt(D);
2363 // The NumClauses field was read in ReadStmtFromStream.
2364 Record.skipInts(1);
2365 VisitOMPExecutableDirective(D);
2366}
2367
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002368void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2369 VisitStmt(D);
Alexey Bataev346265e2015-09-25 10:37:12 +00002370 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002371 Record.skipInts(1);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002372 VisitOMPExecutableDirective(D);
2373}
2374
Alexey Bataev0162e452014-07-22 10:10:35 +00002375void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2376 VisitStmt(D);
2377 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002378 Record.skipInts(1);
Alexey Bataev0162e452014-07-22 10:10:35 +00002379 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002380 D->setX(Record.readSubExpr());
2381 D->setV(Record.readSubExpr());
2382 D->setExpr(Record.readSubExpr());
2383 D->setUpdateExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002384 D->IsXLHSInRHSPart = Record.readInt() != 0;
2385 D->IsPostfixUpdate = Record.readInt() != 0;
Alexey Bataev0162e452014-07-22 10:10:35 +00002386}
2387
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002388void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2389 VisitStmt(D);
2390 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002391 Record.skipInts(1);
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002392 VisitOMPExecutableDirective(D);
2393}
2394
Michael Wong65f367f2015-07-21 13:44:28 +00002395void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2396 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002397 Record.skipInts(1);
Michael Wong65f367f2015-07-21 13:44:28 +00002398 VisitOMPExecutableDirective(D);
2399}
2400
Samuel Antaodf67fc42016-01-19 19:15:56 +00002401void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2402 OMPTargetEnterDataDirective *D) {
2403 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002404 Record.skipInts(1);
Samuel Antaodf67fc42016-01-19 19:15:56 +00002405 VisitOMPExecutableDirective(D);
2406}
2407
Samuel Antao72590762016-01-19 20:04:50 +00002408void ASTStmtReader::VisitOMPTargetExitDataDirective(
2409 OMPTargetExitDataDirective *D) {
2410 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002411 Record.skipInts(1);
Samuel Antao72590762016-01-19 20:04:50 +00002412 VisitOMPExecutableDirective(D);
2413}
2414
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002415void ASTStmtReader::VisitOMPTargetParallelDirective(
2416 OMPTargetParallelDirective *D) {
2417 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002418 Record.skipInts(1);
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002419 VisitOMPExecutableDirective(D);
2420}
2421
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002422void ASTStmtReader::VisitOMPTargetParallelForDirective(
2423 OMPTargetParallelForDirective *D) {
2424 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002425 D->setHasCancel(Record.readInt());
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002426}
2427
Alexey Bataev13314bf2014-10-09 04:18:56 +00002428void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2429 VisitStmt(D);
2430 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002431 Record.skipInts(1);
Alexey Bataev13314bf2014-10-09 04:18:56 +00002432 VisitOMPExecutableDirective(D);
2433}
2434
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002435void ASTStmtReader::VisitOMPCancellationPointDirective(
2436 OMPCancellationPointDirective *D) {
2437 VisitStmt(D);
2438 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002439 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002440}
2441
Alexey Bataev80909872015-07-02 11:25:17 +00002442void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2443 VisitStmt(D);
Alexey Bataev87933c72015-09-18 08:07:34 +00002444 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002445 Record.skipInts(1);
Alexey Bataev80909872015-07-02 11:25:17 +00002446 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002447 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev80909872015-07-02 11:25:17 +00002448}
2449
Alexey Bataev49f6e782015-12-01 04:18:41 +00002450void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2451 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002452 D->setHasCancel(Record.readInt());
Alexey Bataev49f6e782015-12-01 04:18:41 +00002453}
2454
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002455void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2456 VisitOMPLoopDirective(D);
2457}
2458
Alexey Bataev60e51c42019-10-10 20:13:02 +00002459void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2460 OMPMasterTaskLoopDirective *D) {
2461 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002462 D->setHasCancel(Record.readInt());
Alexey Bataev60e51c42019-10-10 20:13:02 +00002463}
2464
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002465void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2466 OMPMasterTaskLoopSimdDirective *D) {
2467 VisitOMPLoopDirective(D);
2468}
2469
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002470void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2471 OMPParallelMasterTaskLoopDirective *D) {
2472 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002473 D->setHasCancel(Record.readInt());
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002474}
2475
Alexey Bataev14a388f2019-10-25 10:27:13 -04002476void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2477 OMPParallelMasterTaskLoopSimdDirective *D) {
2478 VisitOMPLoopDirective(D);
2479}
2480
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002481void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2482 VisitOMPLoopDirective(D);
2483}
2484
Samuel Antao686c70c2016-05-26 17:30:50 +00002485void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2486 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002487 Record.skipInts(1);
Samuel Antao686c70c2016-05-26 17:30:50 +00002488 VisitOMPExecutableDirective(D);
2489}
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002490
Carlo Bertolli9925f152016-06-27 14:55:37 +00002491void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2492 OMPDistributeParallelForDirective *D) {
2493 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002494 D->setHasCancel(Record.readInt());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002495}
Samuel Antao686c70c2016-05-26 17:30:50 +00002496
Kelvin Li4a39add2016-07-05 05:00:15 +00002497void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2498 OMPDistributeParallelForSimdDirective *D) {
2499 VisitOMPLoopDirective(D);
2500}
2501
Kelvin Li787f3fc2016-07-06 04:45:38 +00002502void ASTStmtReader::VisitOMPDistributeSimdDirective(
2503 OMPDistributeSimdDirective *D) {
2504 VisitOMPLoopDirective(D);
2505}
2506
Kelvin Lia579b912016-07-14 02:54:56 +00002507void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2508 OMPTargetParallelForSimdDirective *D) {
2509 VisitOMPLoopDirective(D);
2510}
2511
Kelvin Li986330c2016-07-20 22:57:10 +00002512void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2513 VisitOMPLoopDirective(D);
2514}
2515
Kelvin Li02532872016-08-05 14:37:37 +00002516void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2517 OMPTeamsDistributeDirective *D) {
2518 VisitOMPLoopDirective(D);
2519}
2520
Kelvin Li4e325f72016-10-25 12:50:55 +00002521void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2522 OMPTeamsDistributeSimdDirective *D) {
2523 VisitOMPLoopDirective(D);
2524}
2525
Kelvin Li579e41c2016-11-30 23:51:03 +00002526void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2527 OMPTeamsDistributeParallelForSimdDirective *D) {
2528 VisitOMPLoopDirective(D);
2529}
2530
Kelvin Li7ade93f2016-12-09 03:24:30 +00002531void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2532 OMPTeamsDistributeParallelForDirective *D) {
2533 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002534 D->setHasCancel(Record.readInt());
Kelvin Li7ade93f2016-12-09 03:24:30 +00002535}
2536
Kelvin Libf594a52016-12-17 05:48:59 +00002537void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2538 VisitStmt(D);
2539 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002540 Record.skipInts(1);
Kelvin Libf594a52016-12-17 05:48:59 +00002541 VisitOMPExecutableDirective(D);
2542}
2543
Kelvin Li83c451e2016-12-25 04:52:54 +00002544void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2545 OMPTargetTeamsDistributeDirective *D) {
2546 VisitOMPLoopDirective(D);
2547}
2548
Kelvin Li80e8f562016-12-29 22:16:30 +00002549void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2550 OMPTargetTeamsDistributeParallelForDirective *D) {
2551 VisitOMPLoopDirective(D);
Alexey Bataev16e79882017-11-22 21:12:03 +00002552 D->setHasCancel(Record.readInt());
Kelvin Li80e8f562016-12-29 22:16:30 +00002553}
2554
Kelvin Li1851df52017-01-03 05:23:48 +00002555void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2556 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2557 VisitOMPLoopDirective(D);
2558}
2559
Kelvin Lida681182017-01-10 18:08:18 +00002560void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2561 OMPTargetTeamsDistributeSimdDirective *D) {
2562 VisitOMPLoopDirective(D);
2563}
2564
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002565//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002566// ASTReader Implementation
2567//===----------------------------------------------------------------------===//
2568
Douglas Gregorde3ef502011-11-30 23:21:26 +00002569Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002570 switch (ReadingKind) {
Richard Smith629ff362013-07-31 00:26:46 +00002571 case Read_None:
2572 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002573 case Read_Decl:
2574 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00002575 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002576 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002577 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002578 }
2579
2580 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002581}
2582
Douglas Gregorde3ef502011-11-30 23:21:26 +00002583Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00002584 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002585}
Chris Lattnere2437f42010-05-09 06:40:08 +00002586
Sebastian Redl2c499f62010-08-18 23:56:43 +00002587Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002588 return cast_or_null<Expr>(ReadSubStmt());
2589}
2590
Chris Lattnerf4262532009-04-27 05:41:06 +00002591// Within the bitstream, expressions are stored in Reverse Polish
2592// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002593// expression they are stored in. Subexpressions are stored from last to first.
2594// To evaluate expressions, we continue reading expressions and placing them on
2595// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00002596// stack. Evaluation terminates when we see a STMT_STOP record, and
2597// the single remaining expression on the stack is our result.
Douglas Gregorde3ef502011-11-30 23:21:26 +00002598Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002599 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00002600 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002601
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002602 // Map of offset to previously deserialized stmt. The offset points
George Burgess IV758cf9d2017-02-14 05:52:57 +00002603 // just after the stmt record.
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002604 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00002605
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002606#ifndef NDEBUG
2607 unsigned PrevNumStmts = StmtStack.size();
2608#endif
2609
David L. Jonesbe1557a2016-12-21 00:17:49 +00002610 ASTRecordReader Record(*this, F);
2611 ASTStmtReader Reader(Record, Cursor);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002612 Stmt::EmptyShell Empty;
2613
2614 while (true) {
JF Bastien0e828952019-06-26 19:50:12 +00002615 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2616 Cursor.advanceSkippingSubblocks();
2617 if (!MaybeEntry) {
2618 Error(toString(MaybeEntry.takeError()));
2619 return nullptr;
2620 }
2621 llvm::BitstreamEntry Entry = MaybeEntry.get();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002622
Chris Lattner0e6c9402013-01-20 02:38:54 +00002623 switch (Entry.Kind) {
2624 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2625 case llvm::BitstreamEntry::Error:
2626 Error("malformed block record in AST file");
Craig Toppera13603a2014-05-22 05:54:18 +00002627 return nullptr;
Chris Lattner0e6c9402013-01-20 02:38:54 +00002628 case llvm::BitstreamEntry::EndBlock:
2629 goto Done;
2630 case llvm::BitstreamEntry::Record:
2631 // The interesting case.
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002632 break;
2633 }
2634
Richard Smithdbafb6c2017-06-29 23:23:46 +00002635 ASTContext &Context = getContext();
Craig Toppera13603a2014-05-22 05:54:18 +00002636 Stmt *S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002637 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002638 bool IsStmtReference = false;
JF Bastien0e828952019-06-26 19:50:12 +00002639 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2640 if (!MaybeStmtCode) {
2641 Error(toString(MaybeStmtCode.takeError()));
2642 return nullptr;
2643 }
2644 switch ((StmtCode)MaybeStmtCode.get()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00002645 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002646 Finished = true;
2647 break;
2648
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002649 case STMT_REF_PTR:
2650 IsStmtReference = true;
2651 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2652 "No stmt was recorded for this offset reference!");
David L. Jonesbe1557a2016-12-21 00:17:49 +00002653 S = StmtEntries[Record.readInt()];
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002654 break;
2655
Sebastian Redl539c5062010-08-18 23:57:32 +00002656 case STMT_NULL_PTR:
Craig Toppera13603a2014-05-22 05:54:18 +00002657 S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002658 break;
2659
Sebastian Redl539c5062010-08-18 23:57:32 +00002660 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002661 S = new (Context) NullStmt(Empty);
2662 break;
2663
Sebastian Redl539c5062010-08-18 23:57:32 +00002664 case STMT_COMPOUND:
Benjamin Kramer07420902017-12-24 16:24:20 +00002665 S = CompoundStmt::CreateEmpty(
2666 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002667 break;
2668
Sebastian Redl539c5062010-08-18 23:57:32 +00002669 case STMT_CASE:
Bruno Ricci5b30571752018-10-28 12:30:53 +00002670 S = CaseStmt::CreateEmpty(
2671 Context,
2672 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002673 break;
2674
Sebastian Redl539c5062010-08-18 23:57:32 +00002675 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002676 S = new (Context) DefaultStmt(Empty);
2677 break;
2678
Sebastian Redl539c5062010-08-18 23:57:32 +00002679 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002680 S = new (Context) LabelStmt(Empty);
2681 break;
2682
Richard Smithc202b282012-04-14 00:33:13 +00002683 case STMT_ATTRIBUTED:
Alexander Kornienko20f6fc62012-07-09 10:04:07 +00002684 S = AttributedStmt::CreateEmpty(
2685 Context,
2686 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smithc202b282012-04-14 00:33:13 +00002687 break;
2688
Sebastian Redl539c5062010-08-18 23:57:32 +00002689 case STMT_IF:
Bruno Riccib1cc94b2018-10-27 21:12:20 +00002690 S = IfStmt::CreateEmpty(
2691 Context,
2692 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2693 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2694 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002695 break;
2696
Sebastian Redl539c5062010-08-18 23:57:32 +00002697 case STMT_SWITCH:
Bruno Riccie2806f82018-10-29 16:12:37 +00002698 S = SwitchStmt::CreateEmpty(
2699 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002700 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
Bruno Riccie2806f82018-10-29 16:12:37 +00002701 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002702 break;
2703
Sebastian Redl539c5062010-08-18 23:57:32 +00002704 case STMT_WHILE:
Bruno Riccibacf7512018-10-30 13:42:41 +00002705 S = WhileStmt::CreateEmpty(
2706 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002707 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002708 break;
2709
Sebastian Redl539c5062010-08-18 23:57:32 +00002710 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002711 S = new (Context) DoStmt(Empty);
2712 break;
Mike Stump11289f42009-09-09 15:08:12 +00002713
Sebastian Redl539c5062010-08-18 23:57:32 +00002714 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002715 S = new (Context) ForStmt(Empty);
2716 break;
2717
Sebastian Redl539c5062010-08-18 23:57:32 +00002718 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002719 S = new (Context) GotoStmt(Empty);
2720 break;
Mike Stump11289f42009-09-09 15:08:12 +00002721
Sebastian Redl539c5062010-08-18 23:57:32 +00002722 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002723 S = new (Context) IndirectGotoStmt(Empty);
2724 break;
2725
Sebastian Redl539c5062010-08-18 23:57:32 +00002726 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002727 S = new (Context) ContinueStmt(Empty);
2728 break;
2729
Sebastian Redl539c5062010-08-18 23:57:32 +00002730 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002731 S = new (Context) BreakStmt(Empty);
2732 break;
2733
Sebastian Redl539c5062010-08-18 23:57:32 +00002734 case STMT_RETURN:
Bruno Ricci023b1d12018-10-30 14:40:49 +00002735 S = ReturnStmt::CreateEmpty(
2736 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002737 break;
2738
Sebastian Redl539c5062010-08-18 23:57:32 +00002739 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002740 S = new (Context) DeclStmt(Empty);
2741 break;
2742
Chad Rosierde70e0e2012-08-25 00:11:56 +00002743 case STMT_GCCASM:
2744 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002745 break;
2746
Chad Rosiere30d4992012-08-24 23:51:02 +00002747 case STMT_MSASM:
2748 S = new (Context) MSAsmStmt(Empty);
2749 break;
2750
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002751 case STMT_CAPTURED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002752 S = CapturedStmt::CreateDeserialized(
2753 Context, Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002754 break;
2755
Bill Wendling7c44da22018-10-31 03:48:47 +00002756 case EXPR_CONSTANT:
Gauthier Harnisch83c7b612019-06-15 10:24:47 +00002757 S = ConstantExpr::CreateEmpty(
2758 Context,
2759 static_cast<ConstantExpr::ResultStorageKind>(
2760 Record[ASTStmtReader::NumExprFields]),
2761 Empty);
Bill Wendling7c44da22018-10-31 03:48:47 +00002762 break;
2763
Sebastian Redl539c5062010-08-18 23:57:32 +00002764 case EXPR_PREDEFINED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002765 S = PredefinedExpr::CreateEmpty(
2766 Context,
2767 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002768 break;
Mike Stump11289f42009-09-09 15:08:12 +00002769
Sebastian Redl539c5062010-08-18 23:57:32 +00002770 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002771 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00002772 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002773 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2774 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnara7945c982012-01-27 09:46:47 +00002775 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002776 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Richard Smith715f7a12019-06-11 17:50:32 +00002777 Record[ASTStmtReader::NumExprFields + 6] : 0);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002778 break;
Mike Stump11289f42009-09-09 15:08:12 +00002779
Sebastian Redl539c5062010-08-18 23:57:32 +00002780 case EXPR_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002781 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002782 break;
Mike Stump11289f42009-09-09 15:08:12 +00002783
Sebastian Redl539c5062010-08-18 23:57:32 +00002784 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002785 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002786 break;
Mike Stump11289f42009-09-09 15:08:12 +00002787
Sebastian Redl539c5062010-08-18 23:57:32 +00002788 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002789 S = new (Context) ImaginaryLiteral(Empty);
2790 break;
2791
Sebastian Redl539c5062010-08-18 23:57:32 +00002792 case EXPR_STRING_LITERAL:
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002793 S = StringLiteral::CreateEmpty(
2794 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002795 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002796 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2797 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002798 break;
2799
Sebastian Redl539c5062010-08-18 23:57:32 +00002800 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002801 S = new (Context) CharacterLiteral(Empty);
2802 break;
2803
Sebastian Redl539c5062010-08-18 23:57:32 +00002804 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002805 S = new (Context) ParenExpr(Empty);
2806 break;
2807
Sebastian Redl539c5062010-08-18 23:57:32 +00002808 case EXPR_PAREN_LIST:
Bruno Riccif49e1ca2018-11-20 16:20:40 +00002809 S = ParenListExpr::CreateEmpty(
2810 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002811 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00002812 break;
2813
Sebastian Redl539c5062010-08-18 23:57:32 +00002814 case EXPR_UNARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002815 S = new (Context) UnaryOperator(Empty);
2816 break;
2817
Sebastian Redl539c5062010-08-18 23:57:32 +00002818 case EXPR_OFFSETOF:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002819 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002820 Record[ASTStmtReader::NumExprFields],
2821 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00002822 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002823
Sebastian Redl539c5062010-08-18 23:57:32 +00002824 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00002825 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002826 break;
2827
Sebastian Redl539c5062010-08-18 23:57:32 +00002828 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002829 S = new (Context) ArraySubscriptExpr(Empty);
2830 break;
2831
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002832 case EXPR_OMP_ARRAY_SECTION:
2833 S = new (Context) OMPArraySectionExpr(Empty);
2834 break;
2835
Sebastian Redl539c5062010-08-18 23:57:32 +00002836 case EXPR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00002837 S = CallExpr::CreateEmpty(
2838 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002839 break;
2840
Richard Smithdcf17de2019-06-06 23:24:15 +00002841 case EXPR_MEMBER:
2842 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
2843 Record[ASTStmtReader::NumExprFields + 1],
2844 Record[ASTStmtReader::NumExprFields + 2],
2845 Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002846 break;
2847
Sebastian Redl539c5062010-08-18 23:57:32 +00002848 case EXPR_BINARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002849 S = new (Context) BinaryOperator(Empty);
2850 break;
2851
Sebastian Redl539c5062010-08-18 23:57:32 +00002852 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002853 S = new (Context) CompoundAssignOperator(Empty);
2854 break;
2855
Sebastian Redl539c5062010-08-18 23:57:32 +00002856 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002857 S = new (Context) ConditionalOperator(Empty);
2858 break;
2859
John McCallc07a0c72011-02-17 10:25:35 +00002860 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2861 S = new (Context) BinaryConditionalOperator(Empty);
2862 break;
2863
Sebastian Redl539c5062010-08-18 23:57:32 +00002864 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002865 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002866 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002867 break;
2868
Sebastian Redl539c5062010-08-18 23:57:32 +00002869 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002870 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002871 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002872 break;
2873
Sebastian Redl539c5062010-08-18 23:57:32 +00002874 case EXPR_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002875 S = new (Context) CompoundLiteralExpr(Empty);
2876 break;
2877
Sebastian Redl539c5062010-08-18 23:57:32 +00002878 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002879 S = new (Context) ExtVectorElementExpr(Empty);
2880 break;
2881
Sebastian Redl539c5062010-08-18 23:57:32 +00002882 case EXPR_INIT_LIST:
Argyrios Kyrtzidis0f05fb92012-11-28 03:56:16 +00002883 S = new (Context) InitListExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002884 break;
2885
Sebastian Redl539c5062010-08-18 23:57:32 +00002886 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002887 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002888 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00002889
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002890 break;
2891
Yunzhong Gaocb779302015-06-10 00:27:52 +00002892 case EXPR_DESIGNATED_INIT_UPDATE:
2893 S = new (Context) DesignatedInitUpdateExpr(Empty);
2894 break;
2895
Sebastian Redl539c5062010-08-18 23:57:32 +00002896 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002897 S = new (Context) ImplicitValueInitExpr(Empty);
2898 break;
2899
Yunzhong Gaocb779302015-06-10 00:27:52 +00002900 case EXPR_NO_INIT:
2901 S = new (Context) NoInitExpr(Empty);
2902 break;
2903
Richard Smith410306b2016-12-12 02:53:20 +00002904 case EXPR_ARRAY_INIT_LOOP:
2905 S = new (Context) ArrayInitLoopExpr(Empty);
2906 break;
2907
2908 case EXPR_ARRAY_INIT_INDEX:
2909 S = new (Context) ArrayInitIndexExpr(Empty);
2910 break;
2911
Sebastian Redl539c5062010-08-18 23:57:32 +00002912 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002913 S = new (Context) VAArgExpr(Empty);
2914 break;
2915
Eric Fiselier708afb52019-05-16 21:04:15 +00002916 case EXPR_SOURCE_LOC:
2917 S = new (Context) SourceLocExpr(Empty);
2918 break;
2919
Sebastian Redl539c5062010-08-18 23:57:32 +00002920 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002921 S = new (Context) AddrLabelExpr(Empty);
2922 break;
2923
Sebastian Redl539c5062010-08-18 23:57:32 +00002924 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002925 S = new (Context) StmtExpr(Empty);
2926 break;
2927
Sebastian Redl539c5062010-08-18 23:57:32 +00002928 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002929 S = new (Context) ChooseExpr(Empty);
2930 break;
2931
Sebastian Redl539c5062010-08-18 23:57:32 +00002932 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002933 S = new (Context) GNUNullExpr(Empty);
2934 break;
2935
Sebastian Redl539c5062010-08-18 23:57:32 +00002936 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002937 S = new (Context) ShuffleVectorExpr(Empty);
2938 break;
Mike Stump11289f42009-09-09 15:08:12 +00002939
Hal Finkelc4d7c822013-09-18 03:29:45 +00002940 case EXPR_CONVERT_VECTOR:
2941 S = new (Context) ConvertVectorExpr(Empty);
2942 break;
2943
Sebastian Redl539c5062010-08-18 23:57:32 +00002944 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002945 S = new (Context) BlockExpr(Empty);
2946 break;
2947
Peter Collingbourne91147592011-04-15 00:35:48 +00002948 case EXPR_GENERIC_SELECTION:
Bruno Riccidb076832019-01-26 14:15:10 +00002949 S = GenericSelectionExpr::CreateEmpty(
2950 Context,
2951 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
Peter Collingbourne91147592011-04-15 00:35:48 +00002952 break;
2953
Sebastian Redl539c5062010-08-18 23:57:32 +00002954 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002955 S = new (Context) ObjCStringLiteral(Empty);
2956 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002957
Patrick Beard0caa3942012-04-19 00:25:12 +00002958 case EXPR_OBJC_BOXED_EXPRESSION:
2959 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremeneke65b0862012-03-06 20:05:56 +00002960 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002961
Ted Kremeneke65b0862012-03-06 20:05:56 +00002962 case EXPR_OBJC_ARRAY_LITERAL:
2963 S = ObjCArrayLiteral::CreateEmpty(Context,
2964 Record[ASTStmtReader::NumExprFields]);
2965 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002966
Ted Kremeneke65b0862012-03-06 20:05:56 +00002967 case EXPR_OBJC_DICTIONARY_LITERAL:
2968 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2969 Record[ASTStmtReader::NumExprFields],
2970 Record[ASTStmtReader::NumExprFields + 1]);
2971 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002972
Sebastian Redl539c5062010-08-18 23:57:32 +00002973 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002974 S = new (Context) ObjCEncodeExpr(Empty);
2975 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002976
Sebastian Redl539c5062010-08-18 23:57:32 +00002977 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002978 S = new (Context) ObjCSelectorExpr(Empty);
2979 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002980
Sebastian Redl539c5062010-08-18 23:57:32 +00002981 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002982 S = new (Context) ObjCProtocolExpr(Empty);
2983 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002984
Sebastian Redl539c5062010-08-18 23:57:32 +00002985 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002986 S = new (Context) ObjCIvarRefExpr(Empty);
2987 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002988
Sebastian Redl539c5062010-08-18 23:57:32 +00002989 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002990 S = new (Context) ObjCPropertyRefExpr(Empty);
2991 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002992
Ted Kremeneke65b0862012-03-06 20:05:56 +00002993 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2994 S = new (Context) ObjCSubscriptRefExpr(Empty);
2995 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002996
Sebastian Redl539c5062010-08-18 23:57:32 +00002997 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00002998 llvm_unreachable("mismatching AST file");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002999
Sebastian Redl539c5062010-08-18 23:57:32 +00003000 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003001 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00003002 Record[ASTStmtReader::NumExprFields],
3003 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003004 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003005
Sebastian Redl539c5062010-08-18 23:57:32 +00003006 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00003007 S = new (Context) ObjCIsaExpr(Empty);
3008 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003009
John McCall31168b02011-06-15 23:02:42 +00003010 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
3011 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
3012 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003013
John McCall31168b02011-06-15 23:02:42 +00003014 case EXPR_OBJC_BRIDGED_CAST:
3015 S = new (Context) ObjCBridgedCastExpr(Empty);
3016 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003017
Sebastian Redl539c5062010-08-18 23:57:32 +00003018 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003019 S = new (Context) ObjCForCollectionStmt(Empty);
3020 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003021
Sebastian Redl539c5062010-08-18 23:57:32 +00003022 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003023 S = new (Context) ObjCAtCatchStmt(Empty);
3024 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003025
Sebastian Redl539c5062010-08-18 23:57:32 +00003026 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003027 S = new (Context) ObjCAtFinallyStmt(Empty);
3028 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003029
Sebastian Redl539c5062010-08-18 23:57:32 +00003030 case STMT_OBJC_AT_TRY:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003031 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003032 Record[ASTStmtReader::NumStmtFields],
3033 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003034 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003035
Sebastian Redl539c5062010-08-18 23:57:32 +00003036 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003037 S = new (Context) ObjCAtSynchronizedStmt(Empty);
3038 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003039
Sebastian Redl539c5062010-08-18 23:57:32 +00003040 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003041 S = new (Context) ObjCAtThrowStmt(Empty);
3042 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003043
John McCall31168b02011-06-15 23:02:42 +00003044 case STMT_OBJC_AUTORELEASE_POOL:
3045 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3046 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003047
Ted Kremeneke65b0862012-03-06 20:05:56 +00003048 case EXPR_OBJC_BOOL_LITERAL:
3049 S = new (Context) ObjCBoolLiteralExpr(Empty);
3050 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003051
Erik Pilkington29099de2016-07-16 00:35:23 +00003052 case EXPR_OBJC_AVAILABILITY_CHECK:
3053 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3054 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003055
Nico Weber9b982072014-07-07 00:12:30 +00003056 case STMT_SEH_LEAVE:
3057 S = new (Context) SEHLeaveStmt(Empty);
3058 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003059
John McCallfa194042011-07-15 07:00:14 +00003060 case STMT_SEH_EXCEPT:
3061 S = new (Context) SEHExceptStmt(Empty);
3062 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003063
John McCallfa194042011-07-15 07:00:14 +00003064 case STMT_SEH_FINALLY:
3065 S = new (Context) SEHFinallyStmt(Empty);
3066 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003067
John McCallfa194042011-07-15 07:00:14 +00003068 case STMT_SEH_TRY:
3069 S = new (Context) SEHTryStmt(Empty);
3070 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003071
Sebastian Redl539c5062010-08-18 23:57:32 +00003072 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003073 S = new (Context) CXXCatchStmt(Empty);
3074 break;
3075
Sebastian Redl539c5062010-08-18 23:57:32 +00003076 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003077 S = CXXTryStmt::Create(Context, Empty,
Rui Ueyama49a3ad22019-07-16 04:46:31 +00003078 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003079 break;
3080
Richard Smith02e85f32011-04-14 22:09:26 +00003081 case STMT_CXX_FOR_RANGE:
3082 S = new (Context) CXXForRangeStmt(Empty);
3083 break;
3084
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003085 case STMT_MS_DEPENDENT_EXISTS:
3086 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3087 NestedNameSpecifierLoc(),
3088 DeclarationNameInfo(),
Craig Toppera13603a2014-05-22 05:54:18 +00003089 nullptr);
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003090 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003091
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00003092 case STMT_OMP_PARALLEL_DIRECTIVE:
3093 S =
3094 OMPParallelDirective::CreateEmpty(Context,
3095 Record[ASTStmtReader::NumStmtFields],
3096 Empty);
3097 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003098
3099 case STMT_OMP_SIMD_DIRECTIVE: {
3100 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3101 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3102 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3103 CollapsedNum, Empty);
3104 break;
3105 }
3106
Alexey Bataevf29276e2014-06-18 04:14:57 +00003107 case STMT_OMP_FOR_DIRECTIVE: {
3108 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3109 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3110 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3111 Empty);
3112 break;
3113 }
3114
Alexander Musmanf82886e2014-09-18 05:12:34 +00003115 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3116 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3117 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3118 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3119 Empty);
3120 break;
3121 }
3122
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00003123 case STMT_OMP_SECTIONS_DIRECTIVE:
3124 S = OMPSectionsDirective::CreateEmpty(
3125 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3126 break;
3127
Alexey Bataev1e0498a2014-06-26 08:21:58 +00003128 case STMT_OMP_SECTION_DIRECTIVE:
3129 S = OMPSectionDirective::CreateEmpty(Context, Empty);
3130 break;
3131
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00003132 case STMT_OMP_SINGLE_DIRECTIVE:
3133 S = OMPSingleDirective::CreateEmpty(
3134 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3135 break;
3136
Alexander Musman80c22892014-07-17 08:54:58 +00003137 case STMT_OMP_MASTER_DIRECTIVE:
3138 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3139 break;
3140
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003141 case STMT_OMP_CRITICAL_DIRECTIVE:
Alexey Bataev28c75412015-12-15 08:19:24 +00003142 S = OMPCriticalDirective::CreateEmpty(
3143 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003144 break;
3145
Alexey Bataev4acb8592014-07-07 13:01:15 +00003146 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3147 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3148 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3149 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3150 CollapsedNum, Empty);
3151 break;
3152 }
3153
Alexander Musmane4e893b2014-09-23 09:33:00 +00003154 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3155 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3156 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3157 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3158 CollapsedNum, Empty);
3159 break;
3160 }
3161
cchen47d60942019-12-05 13:43:48 -05003162 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3163 S = OMPParallelMasterDirective::CreateEmpty(
3164 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3165 break;
3166
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00003167 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3168 S = OMPParallelSectionsDirective::CreateEmpty(
3169 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3170 break;
3171
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00003172 case STMT_OMP_TASK_DIRECTIVE:
3173 S = OMPTaskDirective::CreateEmpty(
3174 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3175 break;
3176
Alexey Bataev68446b72014-07-18 07:47:19 +00003177 case STMT_OMP_TASKYIELD_DIRECTIVE:
3178 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3179 break;
3180
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00003181 case STMT_OMP_BARRIER_DIRECTIVE:
3182 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3183 break;
3184
Alexey Bataev2df347a2014-07-18 10:17:07 +00003185 case STMT_OMP_TASKWAIT_DIRECTIVE:
3186 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3187 break;
3188
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003189 case STMT_OMP_TASKGROUP_DIRECTIVE:
Alexey Bataev169d96a2017-07-18 20:17:46 +00003190 S = OMPTaskgroupDirective::CreateEmpty(
3191 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003192 break;
3193
Alexey Bataev6125da92014-07-21 11:26:11 +00003194 case STMT_OMP_FLUSH_DIRECTIVE:
3195 S = OMPFlushDirective::CreateEmpty(
3196 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3197 break;
3198
Alexey Bataevc112e942020-02-28 09:52:15 -05003199 case STMT_OMP_DEPOBJ_DIRECTIVE:
3200 S = OMPDepobjDirective::CreateEmpty(
3201 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3202 break;
3203
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003204 case STMT_OMP_ORDERED_DIRECTIVE:
Alexey Bataev346265e2015-09-25 10:37:12 +00003205 S = OMPOrderedDirective::CreateEmpty(
3206 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003207 break;
3208
Alexey Bataev0162e452014-07-22 10:10:35 +00003209 case STMT_OMP_ATOMIC_DIRECTIVE:
3210 S = OMPAtomicDirective::CreateEmpty(
3211 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3212 break;
3213
Alexey Bataev0bd520b2014-09-19 08:19:49 +00003214 case STMT_OMP_TARGET_DIRECTIVE:
3215 S = OMPTargetDirective::CreateEmpty(
3216 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3217 break;
3218
Michael Wong65f367f2015-07-21 13:44:28 +00003219 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3220 S = OMPTargetDataDirective::CreateEmpty(
3221 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3222 break;
3223
Samuel Antaodf67fc42016-01-19 19:15:56 +00003224 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3225 S = OMPTargetEnterDataDirective::CreateEmpty(
3226 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3227 break;
3228
Samuel Antao72590762016-01-19 20:04:50 +00003229 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3230 S = OMPTargetExitDataDirective::CreateEmpty(
3231 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3232 break;
3233
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00003234 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3235 S = OMPTargetParallelDirective::CreateEmpty(
3236 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3237 break;
3238
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00003239 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3240 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3241 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3242 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3243 CollapsedNum, Empty);
3244 break;
3245 }
3246
Samuel Antao686c70c2016-05-26 17:30:50 +00003247 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3248 S = OMPTargetUpdateDirective::CreateEmpty(
3249 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3250 break;
3251
Alexey Bataev13314bf2014-10-09 04:18:56 +00003252 case STMT_OMP_TEAMS_DIRECTIVE:
3253 S = OMPTeamsDirective::CreateEmpty(
3254 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3255 break;
3256
Alexey Bataev6d4ed052015-07-01 06:57:41 +00003257 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3258 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3259 break;
3260
Alexey Bataev80909872015-07-02 11:25:17 +00003261 case STMT_OMP_CANCEL_DIRECTIVE:
Alexey Bataev87933c72015-09-18 08:07:34 +00003262 S = OMPCancelDirective::CreateEmpty(
3263 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev80909872015-07-02 11:25:17 +00003264 break;
3265
Alexey Bataev49f6e782015-12-01 04:18:41 +00003266 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3267 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3268 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3269 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3270 Empty);
3271 break;
3272 }
3273
Alexey Bataev0a6ed842015-12-03 09:40:15 +00003274 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3275 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3276 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3277 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3278 CollapsedNum, Empty);
3279 break;
3280 }
3281
Alexey Bataev60e51c42019-10-10 20:13:02 +00003282 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3283 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3284 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3285 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3286 CollapsedNum, Empty);
3287 break;
3288 }
3289
Alexey Bataevb8552ab2019-10-18 16:47:35 +00003290 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3291 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3292 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3293 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3294 CollapsedNum, Empty);
3295 break;
3296 }
3297
Alexey Bataev5bbcead2019-10-14 17:17:41 +00003298 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3299 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3300 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3301 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3302 CollapsedNum, Empty);
3303 break;
3304 }
3305
Alexey Bataev14a388f2019-10-25 10:27:13 -04003306 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3307 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3308 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3309 S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3310 Context, NumClauses, CollapsedNum, Empty);
3311 break;
3312 }
3313
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00003314 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3315 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3316 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3317 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3318 Empty);
3319 break;
3320 }
3321
Carlo Bertolli9925f152016-06-27 14:55:37 +00003322 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3323 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3324 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3325 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3326 CollapsedNum, Empty);
3327 break;
3328 }
3329
Kelvin Li4a39add2016-07-05 05:00:15 +00003330 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3331 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3332 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3333 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3334 CollapsedNum,
3335 Empty);
3336 break;
3337 }
3338
Kelvin Li787f3fc2016-07-06 04:45:38 +00003339 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3340 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3341 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3342 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3343 CollapsedNum, Empty);
3344 break;
3345 }
3346
Kelvin Lia579b912016-07-14 02:54:56 +00003347 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3348 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3349 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3350 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3351 CollapsedNum, Empty);
3352 break;
3353 }
3354
Kelvin Li986330c2016-07-20 22:57:10 +00003355 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3356 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3357 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3358 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3359 Empty);
3360 break;
3361 }
3362
Kelvin Li83c451e2016-12-25 04:52:54 +00003363 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
Kelvin Li02532872016-08-05 14:37:37 +00003364 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3365 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3366 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3367 CollapsedNum, Empty);
3368 break;
3369 }
3370
Kelvin Li4e325f72016-10-25 12:50:55 +00003371 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3372 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3373 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3374 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3375 CollapsedNum, Empty);
3376 break;
3377 }
3378
Kelvin Li579e41c2016-11-30 23:51:03 +00003379 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3380 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3381 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3382 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3383 Context, NumClauses, CollapsedNum, Empty);
3384 break;
3385 }
3386
Kelvin Li7ade93f2016-12-09 03:24:30 +00003387 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3388 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3389 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3390 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3391 Context, NumClauses, CollapsedNum, Empty);
3392 break;
3393 }
3394
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003395 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
Kelvin Libf594a52016-12-17 05:48:59 +00003396 S = OMPTargetTeamsDirective::CreateEmpty(
3397 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3398 break;
Kelvin Li83c451e2016-12-25 04:52:54 +00003399
3400 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3401 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3402 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3403 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3404 CollapsedNum, Empty);
3405 break;
3406 }
3407
Kelvin Li80e8f562016-12-29 22:16:30 +00003408 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3409 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3410 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3411 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3412 Context, NumClauses, CollapsedNum, Empty);
3413 break;
3414 }
3415
Kelvin Li1851df52017-01-03 05:23:48 +00003416 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3417 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3418 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3419 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3420 Context, NumClauses, CollapsedNum, Empty);
3421 break;
3422 }
3423
Kelvin Lida681182017-01-10 18:08:18 +00003424 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3425 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3426 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3427 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3428 Context, NumClauses, CollapsedNum, Empty);
3429 break;
3430 }
3431
Sebastian Redl539c5062010-08-18 23:57:32 +00003432 case EXPR_CXX_OPERATOR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003433 S = CXXOperatorCallExpr::CreateEmpty(
3434 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00003435 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003436
Sebastian Redl539c5062010-08-18 23:57:32 +00003437 case EXPR_CXX_MEMBER_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003438 S = CXXMemberCallExpr::CreateEmpty(
3439 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003440 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003441
Richard Smith778dc0f2019-10-19 00:04:38 +00003442 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3443 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3444 break;
3445
Sebastian Redl539c5062010-08-18 23:57:32 +00003446 case EXPR_CXX_CONSTRUCT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003447 S = CXXConstructExpr::CreateEmpty(
3448 Context,
3449 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003450 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003451
Richard Smith5179eb72016-06-28 19:03:57 +00003452 case EXPR_CXX_INHERITED_CTOR_INIT:
3453 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3454 break;
3455
Sebastian Redl539c5062010-08-18 23:57:32 +00003456 case EXPR_CXX_TEMPORARY_OBJECT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003457 S = CXXTemporaryObjectExpr::CreateEmpty(
3458 Context,
3459 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00003460 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003461
Sebastian Redl539c5062010-08-18 23:57:32 +00003462 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003463 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003464 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003465 break;
3466
Sebastian Redl539c5062010-08-18 23:57:32 +00003467 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003468 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003469 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003470 break;
3471
Sebastian Redl539c5062010-08-18 23:57:32 +00003472 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003473 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003474 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003475 break;
3476
Sebastian Redl539c5062010-08-18 23:57:32 +00003477 case EXPR_CXX_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003478 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00003479 break;
3480
Sebastian Redl539c5062010-08-18 23:57:32 +00003481 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003482 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003483 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003484 break;
3485
Richard Smithc67fdd42012-03-07 08:35:16 +00003486 case EXPR_USER_DEFINED_LITERAL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003487 S = UserDefinedLiteral::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003488 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Richard Smithc67fdd42012-03-07 08:35:16 +00003489 break;
3490
Richard Smithcc1b96d2013-06-12 22:31:48 +00003491 case EXPR_CXX_STD_INITIALIZER_LIST:
3492 S = new (Context) CXXStdInitializerListExpr(Empty);
3493 break;
3494
Sebastian Redl539c5062010-08-18 23:57:32 +00003495 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003496 S = new (Context) CXXBoolLiteralExpr(Empty);
3497 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003498
Sebastian Redl539c5062010-08-18 23:57:32 +00003499 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003500 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3501 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003502
Sebastian Redl539c5062010-08-18 23:57:32 +00003503 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003504 S = new (Context) CXXTypeidExpr(Empty, true);
3505 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003506
Sebastian Redl539c5062010-08-18 23:57:32 +00003507 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003508 S = new (Context) CXXTypeidExpr(Empty, false);
3509 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003510
Francois Pichet9f4f2072010-09-08 12:20:18 +00003511 case EXPR_CXX_UUIDOF_EXPR:
3512 S = new (Context) CXXUuidofExpr(Empty, true);
3513 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003514
John McCall5e77d762013-04-16 07:28:30 +00003515 case EXPR_CXX_PROPERTY_REF_EXPR:
3516 S = new (Context) MSPropertyRefExpr(Empty);
3517 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003518
Alexey Bataevf7630272015-11-25 12:01:00 +00003519 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3520 S = new (Context) MSPropertySubscriptExpr(Empty);
3521 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003522
Francois Pichet9f4f2072010-09-08 12:20:18 +00003523 case EXPR_CXX_UUIDOF_TYPE:
3524 S = new (Context) CXXUuidofExpr(Empty, false);
3525 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003526
Sebastian Redl539c5062010-08-18 23:57:32 +00003527 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00003528 S = new (Context) CXXThisExpr(Empty);
3529 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003530
Sebastian Redl539c5062010-08-18 23:57:32 +00003531 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00003532 S = new (Context) CXXThrowExpr(Empty);
3533 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003534
John McCall32791cc2016-01-06 22:34:54 +00003535 case EXPR_CXX_DEFAULT_ARG:
3536 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00003537 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003538
Richard Smith852c9db2013-04-20 22:23:05 +00003539 case EXPR_CXX_DEFAULT_INIT:
3540 S = new (Context) CXXDefaultInitExpr(Empty);
3541 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003542
Sebastian Redl539c5062010-08-18 23:57:32 +00003543 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00003544 S = new (Context) CXXBindTemporaryExpr(Empty);
3545 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003546
Sebastian Redl539c5062010-08-18 23:57:32 +00003547 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00003548 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003549 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003550
Sebastian Redl539c5062010-08-18 23:57:32 +00003551 case EXPR_CXX_NEW:
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00003552 S = CXXNewExpr::CreateEmpty(
3553 Context,
3554 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3555 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3556 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3557 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003558 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003559
Sebastian Redl539c5062010-08-18 23:57:32 +00003560 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00003561 S = new (Context) CXXDeleteExpr(Empty);
3562 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003563
Sebastian Redl539c5062010-08-18 23:57:32 +00003564 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00003565 S = new (Context) CXXPseudoDestructorExpr(Empty);
3566 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003567
John McCall5d413782010-12-06 08:20:24 +00003568 case EXPR_EXPR_WITH_CLEANUPS:
John McCall28fc7092011-11-10 05:35:25 +00003569 S = ExprWithCleanups::Create(Context, Empty,
3570 Record[ASTStmtReader::NumExprFields]);
Chris Lattnercba86142010-05-10 00:25:06 +00003571 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003572
Sebastian Redl539c5062010-08-18 23:57:32 +00003573 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Bruno Ricci2e6dc532019-01-08 14:17:00 +00003574 S = CXXDependentScopeMemberExpr::CreateEmpty(
3575 Context,
3576 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3577 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3578 /*HasFirstQualifierFoundInScope=*/
3579 Record[ASTStmtReader::NumExprFields + 2]);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003580 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003581
Sebastian Redl539c5062010-08-18 23:57:32 +00003582 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003583 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003584 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003585 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003586 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003587 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00003588 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003589
Sebastian Redl539c5062010-08-18 23:57:32 +00003590 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003591 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003592 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00003593 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003594
Sebastian Redl539c5062010-08-18 23:57:32 +00003595 case EXPR_CXX_UNRESOLVED_MEMBER:
Bruno Riccid7628d92019-01-09 15:43:19 +00003596 S = UnresolvedMemberExpr::CreateEmpty(
3597 Context,
3598 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3599 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3600 /*NumTemplateArgs=*/
3601 Record[ASTStmtReader::NumExprFields + 1]
3602 ? Record[ASTStmtReader::NumExprFields + 2]
3603 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003604 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003605
Sebastian Redl539c5062010-08-18 23:57:32 +00003606 case EXPR_CXX_UNRESOLVED_LOOKUP:
Bruno Riccid7628d92019-01-09 15:43:19 +00003607 S = UnresolvedLookupExpr::CreateEmpty(
3608 Context,
3609 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3610 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3611 /*NumTemplateArgs=*/
3612 Record[ASTStmtReader::NumExprFields + 1]
3613 ? Record[ASTStmtReader::NumExprFields + 2]
3614 : 0);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00003615 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003616
Douglas Gregor29c42f22012-02-24 07:38:34 +00003617 case EXPR_TYPE_TRAIT:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003618 S = TypeTraitExpr::CreateDeserialized(Context,
Douglas Gregor29c42f22012-02-24 07:38:34 +00003619 Record[ASTStmtReader::NumExprFields]);
3620 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003621
John Wiegley6242b6a2011-04-28 00:16:57 +00003622 case EXPR_ARRAY_TYPE_TRAIT:
3623 S = new (Context) ArrayTypeTraitExpr(Empty);
3624 break;
3625
John Wiegleyf9f65842011-04-25 06:54:41 +00003626 case EXPR_CXX_EXPRESSION_TRAIT:
3627 S = new (Context) ExpressionTraitExpr(Empty);
3628 break;
3629
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003630 case EXPR_CXX_NOEXCEPT:
3631 S = new (Context) CXXNoexceptExpr(Empty);
3632 break;
John McCall8d69a212010-11-15 23:31:06 +00003633
Douglas Gregore8e9dd62011-01-03 17:17:50 +00003634 case EXPR_PACK_EXPANSION:
3635 S = new (Context) PackExpansionExpr(Empty);
3636 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003637
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003638 case EXPR_SIZEOF_PACK:
Richard Smithd784e682015-09-23 21:41:42 +00003639 S = SizeOfPackExpr::CreateDeserialized(
3640 Context,
3641 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003642 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003643
John McCallfa194042011-07-15 07:00:14 +00003644 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3645 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3646 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003647
Douglas Gregorcdbc5392011-01-15 01:15:58 +00003648 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3649 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3650 break;
Richard Smithb15fe3a2012-09-12 00:56:43 +00003651
3652 case EXPR_FUNCTION_PARM_PACK:
3653 S = FunctionParmPackExpr::CreateEmpty(Context,
3654 Record[ASTStmtReader::NumExprFields]);
3655 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003656
Douglas Gregorfe314812011-06-21 17:03:29 +00003657 case EXPR_MATERIALIZE_TEMPORARY:
3658 S = new (Context) MaterializeTemporaryExpr(Empty);
3659 break;
Richard Smith0f0af192014-11-08 05:07:16 +00003660
3661 case EXPR_CXX_FOLD:
3662 S = new (Context) CXXFoldExpr(Empty);
3663 break;
3664
Argyrios Kyrtzidisb2b07952011-12-03 03:49:52 +00003665 case EXPR_OPAQUE_VALUE:
3666 S = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00003667 break;
Peter Collingbourne41f85462011-02-09 21:07:24 +00003668
3669 case EXPR_CUDA_KERNEL_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003670 S = CUDAKernelCallExpr::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003671 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00003672 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003673
Tanya Lattner55808c12011-06-04 00:47:47 +00003674 case EXPR_ASTYPE:
3675 S = new (Context) AsTypeExpr(Empty);
3676 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003677
John McCallfe96e0b2011-11-06 09:01:30 +00003678 case EXPR_PSEUDO_OBJECT: {
3679 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3680 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3681 break;
3682 }
3683
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003684 case EXPR_ATOMIC:
3685 S = new (Context) AtomicExpr(Empty);
3686 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003687
Douglas Gregor99ae8062012-02-14 17:54:36 +00003688 case EXPR_LAMBDA: {
3689 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
Richard Smith30e304e2016-12-14 00:03:17 +00003690 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
Douglas Gregor99ae8062012-02-14 17:54:36 +00003691 break;
3692 }
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +00003693
3694 case STMT_COROUTINE_BODY: {
3695 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3696 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3697 break;
3698 }
3699
3700 case STMT_CORETURN:
3701 S = new (Context) CoreturnStmt(Empty);
3702 break;
3703
3704 case EXPR_COAWAIT:
3705 S = new (Context) CoawaitExpr(Empty);
3706 break;
3707
3708 case EXPR_COYIELD:
3709 S = new (Context) CoyieldExpr(Empty);
3710 break;
3711
3712 case EXPR_DEPENDENT_COAWAIT:
3713 S = new (Context) DependentCoawaitExpr(Empty);
3714 break;
Saar Raz5d98ba62019-10-15 15:24:26 +00003715
Saar Raza0f50d72020-01-18 09:11:43 +02003716 case EXPR_CONCEPT_SPECIALIZATION: {
Saar Raz5d98ba62019-10-15 15:24:26 +00003717 unsigned numTemplateArgs = Record[ASTStmtReader::NumExprFields];
3718 S = ConceptSpecializationExpr::Create(Context, Empty, numTemplateArgs);
3719 break;
Saar Raza0f50d72020-01-18 09:11:43 +02003720 }
3721
3722 case EXPR_REQUIRES:
3723 unsigned numLocalParameters = Record[ASTStmtReader::NumExprFields];
3724 unsigned numRequirement = Record[ASTStmtReader::NumExprFields + 1];
3725 S = RequiresExpr::Create(Context, Empty, numLocalParameters,
3726 numRequirement);
3727 break;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003728 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003729
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003730 // We hit a STMT_STOP, so we're done with this expression.
3731 if (Finished)
3732 break;
3733
3734 ++NumStatementsRead;
3735
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003736 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003737 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003738 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3739 }
3740
David L. Jonesbe1557a2016-12-21 00:17:49 +00003741 assert(Record.getIdx() == Record.size() &&
3742 "Invalid deserialization of statement");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003743 StmtStack.push_back(S);
3744 }
Chris Lattner0e6c9402013-01-20 02:38:54 +00003745Done:
Alp Toker028ed912013-12-06 17:56:43 +00003746 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003747 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003748 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003749}