blob: d74b0d514eda05d915c7b58d9f77c2d8b2531606 [file] [log] [blame]
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001//===- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------------------===//
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Chris Lattner92ba5ff2009-04-27 05:14:47 +00006//
7//===----------------------------------------------------------------------===//
8//
9// Statement/expression deserialization. This implements the
Sebastian Redl2c499f62010-08-18 23:56:43 +000010// ASTReader::ReadStmt method.
Chris Lattner92ba5ff2009-04-27 05:14:47 +000011//
12//===----------------------------------------------------------------------===//
13
Saar Razfdf80e82019-12-06 01:30:21 +020014#include "clang/AST/ASTConcept.h"
Benjamin Kramer4ab984e2012-07-04 20:19:54 +000015#include "clang/AST/ASTContext.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000016#include "clang/AST/AttrIterator.h"
17#include "clang/AST/Decl.h"
18#include "clang/AST/DeclAccessPair.h"
Douglas Gregor5d3507d2009-09-09 23:08:42 +000019#include "clang/AST/DeclCXX.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000020#include "clang/AST/DeclGroup.h"
21#include "clang/AST/DeclObjC.h"
Douglas Gregorcdbc5392011-01-15 01:15:58 +000022#include "clang/AST/DeclTemplate.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000023#include "clang/AST/DeclarationName.h"
Haojian Wu67d25912020-03-16 13:43:40 +010024#include "clang/AST/DependenceFlags.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000025#include "clang/AST/Expr.h"
26#include "clang/AST/ExprCXX.h"
27#include "clang/AST/ExprObjC.h"
28#include "clang/AST/ExprOpenMP.h"
29#include "clang/AST/NestedNameSpecifier.h"
30#include "clang/AST/OpenMPClause.h"
31#include "clang/AST/OperationKinds.h"
32#include "clang/AST/Stmt.h"
33#include "clang/AST/StmtCXX.h"
34#include "clang/AST/StmtObjC.h"
35#include "clang/AST/StmtOpenMP.h"
Chris Lattner92ba5ff2009-04-27 05:14:47 +000036#include "clang/AST/StmtVisitor.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000037#include "clang/AST/TemplateBase.h"
38#include "clang/AST/Type.h"
39#include "clang/AST/UnresolvedSet.h"
40#include "clang/Basic/CapturedStmt.h"
41#include "clang/Basic/ExpressionTraits.h"
42#include "clang/Basic/LLVM.h"
43#include "clang/Basic/Lambda.h"
44#include "clang/Basic/LangOptions.h"
45#include "clang/Basic/OpenMPKinds.h"
46#include "clang/Basic/OperatorKinds.h"
47#include "clang/Basic/SourceLocation.h"
48#include "clang/Basic/Specifiers.h"
49#include "clang/Basic/TypeTraits.h"
John McCallf413f5e2013-05-03 00:10:13 +000050#include "clang/Lex/Token.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000051#include "clang/Serialization/ASTBitCodes.h"
Ilya Biryukovec3060c2020-03-02 16:07:09 +010052#include "clang/Serialization/ASTRecordReader.h"
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 Lebedevd5edcb92020-03-12 12:18:01 +0300105 static const unsigned NumStmtFields = 0;
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) {
David L. Jonesbe1557a2016-12-21 00:17:49 +0000141 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000142}
143
Sebastian Redl70c751d2010-08-18 23:56:52 +0000144void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000145 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500146 S->setSemiLoc(readSourceLocation());
Bruno Ricci41d11c02018-10-27 18:43:27 +0000147 S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000148}
149
Sebastian Redl70c751d2010-08-18 23:56:52 +0000150void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000151 VisitStmt(S);
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000152 SmallVector<Stmt *, 16> Stmts;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000153 unsigned NumStmts = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000154 while (NumStmts--)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000155 Stmts.push_back(Record.readSubStmt());
Benjamin Kramer07420902017-12-24 16:24:20 +0000156 S->setStmts(Stmts);
John McCall3ce3d232019-12-13 03:37:23 -0500157 S->CompoundStmtBits.LBraceLoc = readSourceLocation();
158 S->RBraceLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000159}
160
Sebastian Redl70c751d2010-08-18 23:56:52 +0000161void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000162 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000163 Record.recordSwitchCaseID(S, Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500164 S->setKeywordLoc(readSourceLocation());
165 S->setColonLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000166}
167
Sebastian Redl70c751d2010-08-18 23:56:52 +0000168void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000169 VisitSwitchCase(S);
Bruno Ricci5b30571752018-10-28 12:30:53 +0000170 bool CaseStmtIsGNURange = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000171 S->setLHS(Record.readSubExpr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000172 S->setSubStmt(Record.readSubStmt());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000173 if (CaseStmtIsGNURange) {
174 S->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500175 S->setEllipsisLoc(readSourceLocation());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000176 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000177}
178
Sebastian Redl70c751d2010-08-18 23:56:52 +0000179void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000180 VisitSwitchCase(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000181 S->setSubStmt(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000182}
183
Sebastian Redl70c751d2010-08-18 23:56:52 +0000184void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000185 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500186 auto *LD = readDeclAs<LabelDecl>();
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000187 LD->setStmt(S);
188 S->setDecl(LD);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000189 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500190 S->setIdentLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000191}
192
Richard Smithc202b282012-04-14 00:33:13 +0000193void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
194 VisitStmt(S);
Bruno Ricci41d11c02018-10-27 18:43:27 +0000195 // NumAttrs in AttributedStmt is set when creating an empty
196 // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
197 // to allocate the right amount of space for the trailing Attr *.
David L. Jonesbe1557a2016-12-21 00:17:49 +0000198 uint64_t NumAttrs = Record.readInt();
Richard Smithc202b282012-04-14 00:33:13 +0000199 AttrVec Attrs;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000200 Record.readAttributes(Attrs);
Matt Beaumont-Gayad0bb8e2012-07-09 18:55:31 +0000201 (void)NumAttrs;
Bruno Ricci41d11c02018-10-27 18:43:27 +0000202 assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
Alexander Kornienko20f6fc62012-07-09 10:04:07 +0000203 assert(NumAttrs == Attrs.size());
Aaron Ballmanf3d9b092014-05-13 14:55:01 +0000204 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000205 S->SubStmt = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500206 S->AttributedStmtBits.AttrLoc = readSourceLocation();
Richard Smithc202b282012-04-14 00:33:13 +0000207}
208
Sebastian Redl70c751d2010-08-18 23:56:52 +0000209void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000210 VisitStmt(S);
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000211
David L. Jonesbe1557a2016-12-21 00:17:49 +0000212 S->setConstexpr(Record.readInt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000213 bool HasElse = Record.readInt();
214 bool HasVar = Record.readInt();
215 bool HasInit = Record.readInt();
216
David L. Jonesb6a8f022016-12-21 04:34:52 +0000217 S->setCond(Record.readSubExpr());
218 S->setThen(Record.readSubStmt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000219 if (HasElse)
220 S->setElse(Record.readSubStmt());
221 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500222 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000223 if (HasInit)
224 S->setInit(Record.readSubStmt());
225
John McCall3ce3d232019-12-13 03:37:23 -0500226 S->setIfLoc(readSourceLocation());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000227 if (HasElse)
John McCall3ce3d232019-12-13 03:37:23 -0500228 S->setElseLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000229}
230
Sebastian Redl70c751d2010-08-18 23:56:52 +0000231void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000232 VisitStmt(S);
Bruno Riccie2806f82018-10-29 16:12:37 +0000233
234 bool HasInit = Record.readInt();
235 bool HasVar = Record.readInt();
236 bool AllEnumCasesCovered = Record.readInt();
237 if (AllEnumCasesCovered)
238 S->setAllEnumCasesCovered();
239
David L. Jonesb6a8f022016-12-21 04:34:52 +0000240 S->setCond(Record.readSubExpr());
241 S->setBody(Record.readSubStmt());
Bruno Riccie2806f82018-10-29 16:12:37 +0000242 if (HasInit)
243 S->setInit(Record.readSubStmt());
244 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500245 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccie2806f82018-10-29 16:12:37 +0000246
John McCall3ce3d232019-12-13 03:37:23 -0500247 S->setSwitchLoc(readSourceLocation());
Ted Kremenekc42f3452010-09-09 00:05:53 +0000248
Craig Toppera13603a2014-05-22 05:54:18 +0000249 SwitchCase *PrevSC = nullptr;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000250 for (auto E = Record.size(); Record.getIdx() != E; ) {
251 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000252 if (PrevSC)
253 PrevSC->setNextSwitchCase(SC);
254 else
255 S->setSwitchCaseList(SC);
Mike Stump11289f42009-09-09 15:08:12 +0000256
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000257 PrevSC = SC;
258 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000259}
260
Sebastian Redl70c751d2010-08-18 23:56:52 +0000261void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000262 VisitStmt(S);
Bruno Riccibacf7512018-10-30 13:42:41 +0000263
264 bool HasVar = Record.readInt();
Douglas Gregor7fb09192011-07-21 22:35:25 +0000265
David L. Jonesb6a8f022016-12-21 04:34:52 +0000266 S->setCond(Record.readSubExpr());
267 S->setBody(Record.readSubStmt());
Bruno Riccibacf7512018-10-30 13:42:41 +0000268 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500269 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccibacf7512018-10-30 13:42:41 +0000270
John McCall3ce3d232019-12-13 03:37:23 -0500271 S->setWhileLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000272}
273
Sebastian Redl70c751d2010-08-18 23:56:52 +0000274void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000275 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000276 S->setCond(Record.readSubExpr());
277 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500278 S->setDoLoc(readSourceLocation());
279 S->setWhileLoc(readSourceLocation());
280 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000281}
282
Sebastian Redl70c751d2010-08-18 23:56:52 +0000283void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000284 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000285 S->setInit(Record.readSubStmt());
286 S->setCond(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500287 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000288 S->setInc(Record.readSubExpr());
289 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500290 S->setForLoc(readSourceLocation());
291 S->setLParenLoc(readSourceLocation());
292 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000293}
294
Sebastian Redl70c751d2010-08-18 23:56:52 +0000295void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000296 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500297 S->setLabel(readDeclAs<LabelDecl>());
298 S->setGotoLoc(readSourceLocation());
299 S->setLabelLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000300}
301
Sebastian Redl70c751d2010-08-18 23:56:52 +0000302void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000303 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500304 S->setGotoLoc(readSourceLocation());
305 S->setStarLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000306 S->setTarget(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000307}
308
Sebastian Redl70c751d2010-08-18 23:56:52 +0000309void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000310 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500311 S->setContinueLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000312}
313
Sebastian Redl70c751d2010-08-18 23:56:52 +0000314void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000315 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500316 S->setBreakLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000317}
318
Sebastian Redl70c751d2010-08-18 23:56:52 +0000319void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000320 VisitStmt(S);
Bruno Ricci023b1d12018-10-30 14:40:49 +0000321
322 bool HasNRVOCandidate = Record.readInt();
323
David L. Jonesb6a8f022016-12-21 04:34:52 +0000324 S->setRetValue(Record.readSubExpr());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000325 if (HasNRVOCandidate)
John McCall3ce3d232019-12-13 03:37:23 -0500326 S->setNRVOCandidate(readDeclAs<VarDecl>());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000327
John McCall3ce3d232019-12-13 03:37:23 -0500328 S->setReturnLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000329}
330
Sebastian Redl70c751d2010-08-18 23:56:52 +0000331void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000332 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500333 S->setStartLoc(readSourceLocation());
334 S->setEndLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000335
David L. Jonesbe1557a2016-12-21 00:17:49 +0000336 if (Record.size() - Record.getIdx() == 1) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000337 // Single declaration
John McCall3ce3d232019-12-13 03:37:23 -0500338 S->setDeclGroup(DeclGroupRef(readDecl()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000339 } else {
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000340 SmallVector<Decl *, 16> Decls;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000341 int N = Record.size() - Record.getIdx();
342 Decls.reserve(N);
343 for (int I = 0; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500344 Decls.push_back(readDecl());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000345 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
Douglas Gregor038c3382009-05-22 22:45:36 +0000346 Decls.data(),
347 Decls.size())));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000348 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000349}
350
John McCallf413f5e2013-05-03 00:10:13 +0000351void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000352 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000353 S->NumOutputs = Record.readInt();
354 S->NumInputs = Record.readInt();
355 S->NumClobbers = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500356 S->setAsmLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000357 S->setVolatile(Record.readInt());
358 S->setSimple(Record.readInt());
John McCallf413f5e2013-05-03 00:10:13 +0000359}
Mike Stump11289f42009-09-09 15:08:12 +0000360
John McCallf413f5e2013-05-03 00:10:13 +0000361void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
362 VisitAsmStmt(S);
Jennifer Yub8fee672019-06-03 15:57:25 +0000363 S->NumLabels = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500364 S->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000365 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000366
John McCallf413f5e2013-05-03 00:10:13 +0000367 unsigned NumOutputs = S->getNumOutputs();
368 unsigned NumInputs = S->getNumInputs();
369 unsigned NumClobbers = S->getNumClobbers();
Jennifer Yub8fee672019-06-03 15:57:25 +0000370 unsigned NumLabels = S->getNumLabels();
John McCallf413f5e2013-05-03 00:10:13 +0000371
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000372 // Outputs and inputs
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000373 SmallVector<IdentifierInfo *, 16> Names;
374 SmallVector<StringLiteral*, 16> Constraints;
375 SmallVector<Stmt*, 16> Exprs;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000376 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -0500377 Names.push_back(Record.readIdentifier());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000378 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
379 Exprs.push_back(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000380 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000381
382 // Constraints
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000383 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000384 for (unsigned I = 0; I != NumClobbers; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000385 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000386
Jennifer Yub8fee672019-06-03 15:57:25 +0000387 // Labels
388 for (unsigned I = 0, N = NumLabels; I != N; ++I)
389 Exprs.push_back(Record.readSubStmt());
390
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000391 S->setOutputsAndInputsAndClobbers(Record.getContext(),
392 Names.data(), Constraints.data(),
393 Exprs.data(), NumOutputs, NumInputs,
Jennifer Yub8fee672019-06-03 15:57:25 +0000394 NumLabels,
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000395 Clobbers.data(), NumClobbers);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000396}
397
Chad Rosier32503022012-06-11 20:47:18 +0000398void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
John McCallf413f5e2013-05-03 00:10:13 +0000399 VisitAsmStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500400 S->LBraceLoc = readSourceLocation();
401 S->EndLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000402 S->NumAsmToks = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500403 std::string AsmStr = readString();
John McCallf413f5e2013-05-03 00:10:13 +0000404
405 // Read the tokens.
406 SmallVector<Token, 16> AsmToks;
407 AsmToks.reserve(S->NumAsmToks);
408 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000409 AsmToks.push_back(Record.readToken());
John McCallf413f5e2013-05-03 00:10:13 +0000410 }
411
412 // The calls to reserve() for the FooData vectors are mandatory to
413 // prevent dead StringRefs in the Foo vectors.
414
415 // Read the clobbers.
416 SmallVector<std::string, 16> ClobbersData;
417 SmallVector<StringRef, 16> Clobbers;
418 ClobbersData.reserve(S->NumClobbers);
419 Clobbers.reserve(S->NumClobbers);
420 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
John McCall3ce3d232019-12-13 03:37:23 -0500421 ClobbersData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000422 Clobbers.push_back(ClobbersData.back());
423 }
424
425 // Read the operands.
426 unsigned NumOperands = S->NumOutputs + S->NumInputs;
427 SmallVector<Expr*, 16> Exprs;
428 SmallVector<std::string, 16> ConstraintsData;
429 SmallVector<StringRef, 16> Constraints;
430 Exprs.reserve(NumOperands);
431 ConstraintsData.reserve(NumOperands);
432 Constraints.reserve(NumOperands);
433 for (unsigned i = 0; i != NumOperands; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000434 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -0500435 ConstraintsData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000436 Constraints.push_back(ConstraintsData.back());
437 }
438
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000439 S->initialize(Record.getContext(), AsmStr, AsmToks,
John McCallf413f5e2013-05-03 00:10:13 +0000440 Constraints, Exprs, Clobbers);
Chad Rosier32503022012-06-11 20:47:18 +0000441}
442
Richard Smith9f690bd2015-10-27 06:02:45 +0000443void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000444 VisitStmt(S);
445 assert(Record.peekInt() == S->NumParams);
446 Record.skipInts(1);
447 auto *StoredStmts = S->getStoredStmts();
448 for (unsigned i = 0;
449 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
450 StoredStmts[i] = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000451}
452
453void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000454 VisitStmt(S);
455 S->CoreturnLoc = Record.readSourceLocation();
456 for (auto &SubStmt: S->SubStmts)
457 SubStmt = Record.readSubStmt();
458 S->IsImplicit = Record.readInt() != 0;
Richard Smith9f690bd2015-10-27 06:02:45 +0000459}
460
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000461void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
462 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500463 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000464 for (auto &SubExpr: E->SubExprs)
465 SubExpr = Record.readSubStmt();
466 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
467 E->setIsImplicit(Record.readInt() != 0);
Richard Smith9f690bd2015-10-27 06:02:45 +0000468}
469
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000470void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
471 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500472 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000473 for (auto &SubExpr: E->SubExprs)
474 SubExpr = Record.readSubStmt();
475 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
Eric Fiselier20f25cb2017-03-06 23:38:15 +0000476}
477
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000478void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
479 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500480 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000481 for (auto &SubExpr: E->SubExprs)
482 SubExpr = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000483}
484
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000485void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
Ben Langmuirce914fc2013-05-03 19:20:19 +0000486 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000487 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500488 S->setCapturedDecl(readDeclAs<CapturedDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000489 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500490 S->setCapturedRecordDecl(readDeclAs<RecordDecl>());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000491
492 // Capture inits
493 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
494 E = S->capture_init_end();
495 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000496 *I = Record.readSubExpr();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000497
498 // Body
David L. Jonesb6a8f022016-12-21 04:34:52 +0000499 S->setCapturedStmt(Record.readSubStmt());
Wei Pan17fbf6e2013-05-04 03:59:06 +0000500 S->getCapturedDecl()->setBody(S->getCapturedStmt());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000501
502 // Captures
Aaron Ballmanc656303a2014-03-14 18:08:33 +0000503 for (auto &I : S->captures()) {
John McCall3ce3d232019-12-13 03:37:23 -0500504 I.VarAndKind.setPointer(readDeclAs<VarDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000505 I.VarAndKind.setInt(
506 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500507 I.Loc = readSourceLocation();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000508 }
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000509}
510
Sebastian Redl70c751d2010-08-18 23:56:52 +0000511void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000512 VisitStmt(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000513 E->setType(Record.readType());
Ilya Biryukovec3060c2020-03-02 16:07:09 +0100514
515 // FIXME: write and read all DependentFlags with a single call.
516 bool TypeDependent = Record.readInt();
517 bool ValueDependent = Record.readInt();
518 bool InstantiationDependent = Record.readInt();
519 bool ContainsUnexpandedTemplateParameters = Record.readInt();
520 auto Deps = ExprDependence::None;
521 if (TypeDependent)
522 Deps |= ExprDependence::Type;
523 if (ValueDependent)
524 Deps |= ExprDependence::Value;
525 if (InstantiationDependent)
526 Deps |= ExprDependence::Instantiation;
527 if (ContainsUnexpandedTemplateParameters)
528 Deps |= ExprDependence::UnexpandedPack;
529 E->setDependence(Deps);
530
David L. Jonesbe1557a2016-12-21 00:17:49 +0000531 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
532 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
533 assert(Record.getIdx() == NumExprFields &&
534 "Incorrect expression field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000535}
536
Bill Wendling7c44da22018-10-31 03:48:47 +0000537void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
538 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000539 E->ConstantExprBits.ResultKind = Record.readInt();
540 switch (E->ConstantExprBits.ResultKind) {
541 case ConstantExpr::RSK_Int64: {
542 E->Int64Result() = Record.readInt();
543 uint64_t tmp = Record.readInt();
544 E->ConstantExprBits.IsUnsigned = tmp & 0x1;
545 E->ConstantExprBits.BitWidth = tmp >> 1;
546 break;
547 }
548 case ConstantExpr::RSK_APValue:
549 E->APValueResult() = Record.readAPValue();
550 }
Bill Wendling7c44da22018-10-31 03:48:47 +0000551 E->setSubExpr(Record.readSubExpr());
552}
553
Sebastian Redl70c751d2010-08-18 23:56:52 +0000554void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000555 VisitExpr(E);
Bruno Ricci17ff0262018-10-27 19:21:19 +0000556 bool HasFunctionName = Record.readInt();
557 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
558 E->PredefinedExprBits.Kind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500559 E->setLocation(readSourceLocation());
Bruno Ricci17ff0262018-10-27 19:21:19 +0000560 if (HasFunctionName)
561 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000562}
563
Sebastian Redl70c751d2010-08-18 23:56:52 +0000564void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000565 VisitExpr(E);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000566
David L. Jonesbe1557a2016-12-21 00:17:49 +0000567 E->DeclRefExprBits.HasQualifier = Record.readInt();
568 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
569 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
570 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
571 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
Richard Smith715f7a12019-06-11 17:50:32 +0000572 E->DeclRefExprBits.NonOdrUseReason = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000573 unsigned NumTemplateArgs = 0;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000574 if (E->hasTemplateKWAndArgsInfo())
David L. Jonesbe1557a2016-12-21 00:17:49 +0000575 NumTemplateArgs = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000576
Chandler Carruth0e439962011-05-01 21:29:53 +0000577 if (E->hasQualifier())
James Y Knighte7d82282015-12-29 18:15:14 +0000578 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
David L. Jonesb6a8f022016-12-21 04:34:52 +0000579 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000580
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000581 if (E->hasFoundDecl())
John McCall3ce3d232019-12-13 03:37:23 -0500582 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000583
Abramo Bagnara7945c982012-01-27 09:46:47 +0000584 if (E->hasTemplateKWAndArgsInfo())
James Y Knighte7d82282015-12-29 18:15:14 +0000585 ReadTemplateKWAndArgsInfo(
586 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
587 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000588
John McCall3ce3d232019-12-13 03:37:23 -0500589 E->setDecl(readDeclAs<ValueDecl>());
590 E->setLocation(readSourceLocation());
591 E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000592}
593
Sebastian Redl70c751d2010-08-18 23:56:52 +0000594void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000595 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500596 E->setLocation(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000597 E->setValue(Record.getContext(), Record.readAPInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000598}
599
Leonard Chandb01c3a2018-06-20 17:19:40 +0000600void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
601 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500602 E->setLocation(readSourceLocation());
Leonard Chandb01c3a2018-06-20 17:19:40 +0000603 E->setValue(Record.getContext(), Record.readAPInt());
604}
605
Sebastian Redl70c751d2010-08-18 23:56:52 +0000606void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000607 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000608 E->setRawSemantics(
609 static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
David L. Jonesbe1557a2016-12-21 00:17:49 +0000610 E->setExact(Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000611 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
John McCall3ce3d232019-12-13 03:37:23 -0500612 E->setLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000613}
614
Sebastian Redl70c751d2010-08-18 23:56:52 +0000615void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000616 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000617 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000618}
619
Sebastian Redl70c751d2010-08-18 23:56:52 +0000620void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000621 VisitExpr(E);
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000622
623 // NumConcatenated, Length and CharByteWidth are set by the empty
624 // ctor since they are needed to allocate storage for the trailing objects.
625 unsigned NumConcatenated = Record.readInt();
626 unsigned Length = Record.readInt();
627 unsigned CharByteWidth = Record.readInt();
628 assert((NumConcatenated == E->getNumConcatenated()) &&
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000629 "Wrong number of concatenated tokens!");
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000630 assert((Length == E->getLength()) && "Wrong Length!");
631 assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
632 E->StringLiteralBits.Kind = Record.readInt();
633 E->StringLiteralBits.IsPascal = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000634
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000635 // The character width is originally computed via mapCharByteWidth.
636 // Check that the deserialized character width is consistant with the result
637 // of calling mapCharByteWidth.
638 assert((CharByteWidth ==
639 StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
640 E->getKind())) &&
641 "Wrong character width!");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000642
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000643 // Deserialize the trailing array of SourceLocation.
644 for (unsigned I = 0; I < NumConcatenated; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500645 E->setStrTokenLoc(I, readSourceLocation());
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000646
647 // Deserialize the trailing array of char holding the string data.
648 char *StrData = E->getStrDataAsChar();
649 for (unsigned I = 0; I < Length * CharByteWidth; ++I)
650 StrData[I] = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000651}
652
Sebastian Redl70c751d2010-08-18 23:56:52 +0000653void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000654 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000655 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500656 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000657 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000658}
659
Sebastian Redl70c751d2010-08-18 23:56:52 +0000660void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000661 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500662 E->setLParen(readSourceLocation());
663 E->setRParen(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000664 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000665}
666
Sebastian Redl70c751d2010-08-18 23:56:52 +0000667void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000668 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000669 unsigned NumExprs = Record.readInt();
Bruno Riccif49e1ca2018-11-20 16:20:40 +0000670 assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
671 for (unsigned I = 0; I != NumExprs; ++I)
672 E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500673 E->LParenLoc = readSourceLocation();
674 E->RParenLoc = readSourceLocation();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000675}
676
Sebastian Redl70c751d2010-08-18 23:56:52 +0000677void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000678 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000679 E->setSubExpr(Record.readSubExpr());
680 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500681 E->setOperatorLoc(readSourceLocation());
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000682 E->setCanOverflow(Record.readInt());
683}
684
685void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000686 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000687 assert(E->getNumComponents() == Record.peekInt());
688 Record.skipInts(1);
689 assert(E->getNumExpressions() == Record.peekInt());
690 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500691 E->setOperatorLoc(readSourceLocation());
692 E->setRParenLoc(readSourceLocation());
693 E->setTypeSourceInfo(readTypeSourceInfo());
Douglas Gregor882211c2010-04-28 22:16:22 +0000694 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000695 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500696 SourceLocation Start = readSourceLocation();
697 SourceLocation End = readSourceLocation();
Douglas Gregor882211c2010-04-28 22:16:22 +0000698 switch (Kind) {
James Y Knight7281c352015-12-29 22:31:18 +0000699 case OffsetOfNode::Array:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000700 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000701 break;
702
James Y Knight7281c352015-12-29 22:31:18 +0000703 case OffsetOfNode::Field:
704 E->setComponent(
John McCall3ce3d232019-12-13 03:37:23 -0500705 I, OffsetOfNode(Start, readDeclAs<FieldDecl>(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000706 break;
James Y Knight7281c352015-12-29 22:31:18 +0000707
708 case OffsetOfNode::Identifier:
709 E->setComponent(
710 I,
John McCall3ce3d232019-12-13 03:37:23 -0500711 OffsetOfNode(Start, Record.readIdentifier(), End));
James Y Knight7281c352015-12-29 22:31:18 +0000712 break;
713
714 case OffsetOfNode::Base: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000715 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000716 *Base = Record.readCXXBaseSpecifier();
James Y Knight7281c352015-12-29 22:31:18 +0000717 E->setComponent(I, OffsetOfNode(Base));
Douglas Gregord1702062010-04-29 00:18:15 +0000718 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000719 }
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000720 }
Douglas Gregor882211c2010-04-28 22:16:22 +0000721 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000722
Douglas Gregor882211c2010-04-28 22:16:22 +0000723 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000724 E->setIndexExpr(I, Record.readSubExpr());
Douglas Gregor882211c2010-04-28 22:16:22 +0000725}
726
Peter Collingbournee190dee2011-03-11 19:24:49 +0000727void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000728 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000729 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
730 if (Record.peekInt() == 0) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000731 E->setArgument(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000732 Record.skipInts(1);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000733 } else {
John McCall3ce3d232019-12-13 03:37:23 -0500734 E->setArgument(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000735 }
John McCall3ce3d232019-12-13 03:37:23 -0500736 E->setOperatorLoc(readSourceLocation());
737 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000738}
739
Saar Raza0f50d72020-01-18 09:11:43 +0200740static ConstraintSatisfaction
741readConstraintSatisfaction(ASTRecordReader &Record) {
742 ConstraintSatisfaction Satisfaction;
743 Satisfaction.IsSatisfied = Record.readInt();
744 if (!Satisfaction.IsSatisfied) {
745 unsigned NumDetailRecords = Record.readInt();
746 for (unsigned i = 0; i != NumDetailRecords; ++i) {
747 Expr *ConstraintExpr = Record.readExpr();
Michael Liao70b53a302020-01-19 12:23:11 -0500748 if (/* IsDiagnostic */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200749 SourceLocation DiagLocation = Record.readSourceLocation();
750 std::string DiagMessage = Record.readString();
751 Satisfaction.Details.emplace_back(
752 ConstraintExpr, new (Record.getContext())
753 ConstraintSatisfaction::SubstitutionDiagnostic{
754 DiagLocation, DiagMessage});
755 } else
756 Satisfaction.Details.emplace_back(ConstraintExpr, Record.readExpr());
757 }
758 }
759 return Satisfaction;
760}
761
Saar Raz5d98ba62019-10-15 15:24:26 +0000762void ASTStmtReader::VisitConceptSpecializationExpr(
763 ConceptSpecializationExpr *E) {
764 VisitExpr(E);
765 unsigned NumTemplateArgs = Record.readInt();
766 E->NestedNameSpec = Record.readNestedNameSpecifierLoc();
767 E->TemplateKWLoc = Record.readSourceLocation();
Saar Razff1e0fc2020-01-15 02:48:42 +0200768 E->ConceptName = Record.readDeclarationNameInfo();
John McCall3ce3d232019-12-13 03:37:23 -0500769 E->NamedConcept = readDeclAs<ConceptDecl>();
Saar Razf9e63892020-03-10 22:04:11 +0200770 E->FoundDecl = Record.readDeclAs<NamedDecl>();
Saar Razff1e0fc2020-01-15 02:48:42 +0200771 E->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
Saar Raz5d98ba62019-10-15 15:24:26 +0000772 llvm::SmallVector<TemplateArgument, 4> Args;
773 for (unsigned I = 0; I < NumTemplateArgs; ++I)
774 Args.push_back(Record.readTemplateArgument());
Saar Razff1e0fc2020-01-15 02:48:42 +0200775 E->setTemplateArguments(Args);
Saar Raza0f50d72020-01-18 09:11:43 +0200776 E->Satisfaction = E->isValueDependent() ? nullptr :
777 ASTConstraintSatisfaction::Create(Record.getContext(),
778 readConstraintSatisfaction(Record));
779}
780
781static concepts::Requirement::SubstitutionDiagnostic *
782readSubstitutionDiagnostic(ASTRecordReader &Record) {
783 std::string SubstitutedEntity = Record.readString();
784 SourceLocation DiagLoc = Record.readSourceLocation();
785 std::string DiagMessage = Record.readString();
786 return new (Record.getContext())
787 concepts::Requirement::SubstitutionDiagnostic{SubstitutedEntity, DiagLoc,
788 DiagMessage};
789}
790
791void ASTStmtReader::VisitRequiresExpr(RequiresExpr *E) {
792 VisitExpr(E);
793 unsigned NumLocalParameters = Record.readInt();
794 unsigned NumRequirements = Record.readInt();
795 E->RequiresExprBits.RequiresKWLoc = Record.readSourceLocation();
796 E->RequiresExprBits.IsSatisfied = Record.readInt();
797 E->Body = Record.readDeclAs<RequiresExprBodyDecl>();
798 llvm::SmallVector<ParmVarDecl *, 4> LocalParameters;
799 for (unsigned i = 0; i < NumLocalParameters; ++i)
800 LocalParameters.push_back(cast<ParmVarDecl>(Record.readDecl()));
801 std::copy(LocalParameters.begin(), LocalParameters.end(),
802 E->getTrailingObjects<ParmVarDecl *>());
803 llvm::SmallVector<concepts::Requirement *, 4> Requirements;
804 for (unsigned i = 0; i < NumRequirements; ++i) {
805 auto RK =
806 static_cast<concepts::Requirement::RequirementKind>(Record.readInt());
807 concepts::Requirement *R = nullptr;
808 switch (RK) {
809 case concepts::Requirement::RK_Type: {
810 auto Status =
811 static_cast<concepts::TypeRequirement::SatisfactionStatus>(
812 Record.readInt());
813 if (Status == concepts::TypeRequirement::SS_SubstitutionFailure)
814 R = new (Record.getContext())
815 concepts::TypeRequirement(readSubstitutionDiagnostic(Record));
816 else
817 R = new (Record.getContext())
818 concepts::TypeRequirement(Record.readTypeSourceInfo());
819 } break;
820 case concepts::Requirement::RK_Simple:
821 case concepts::Requirement::RK_Compound: {
822 auto Status =
823 static_cast<concepts::ExprRequirement::SatisfactionStatus>(
824 Record.readInt());
825 llvm::PointerUnion<concepts::Requirement::SubstitutionDiagnostic *,
826 Expr *> E;
827 if (Status == concepts::ExprRequirement::SS_ExprSubstitutionFailure) {
828 E = readSubstitutionDiagnostic(Record);
829 } else
830 E = Record.readExpr();
831
832 llvm::Optional<concepts::ExprRequirement::ReturnTypeRequirement> Req;
833 ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr;
834 SourceLocation NoexceptLoc;
835 if (RK == concepts::Requirement::RK_Simple) {
836 Req.emplace();
837 } else {
838 NoexceptLoc = Record.readSourceLocation();
Michael Liao70b53a302020-01-19 12:23:11 -0500839 switch (/* returnTypeRequirementKind */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200840 case 0:
841 // No return type requirement.
842 Req.emplace();
843 break;
844 case 1: {
845 // type-constraint
846 TemplateParameterList *TPL = Record.readTemplateParameterList();
847 if (Status >=
848 concepts::ExprRequirement::SS_ConstraintsNotSatisfied)
849 SubstitutedConstraintExpr =
850 cast<ConceptSpecializationExpr>(Record.readExpr());
851 Req.emplace(TPL);
852 } break;
853 case 2:
854 // Substitution failure
855 Req.emplace(readSubstitutionDiagnostic(Record));
856 break;
857 }
858 }
859 if (Expr *Ex = E.dyn_cast<Expr *>())
860 R = new (Record.getContext()) concepts::ExprRequirement(
861 Ex, RK == concepts::Requirement::RK_Simple, NoexceptLoc,
862 std::move(*Req), Status, SubstitutedConstraintExpr);
863 else
864 R = new (Record.getContext()) concepts::ExprRequirement(
865 E.get<concepts::Requirement::SubstitutionDiagnostic *>(),
866 RK == concepts::Requirement::RK_Simple, NoexceptLoc,
867 std::move(*Req));
868 } break;
869 case concepts::Requirement::RK_Nested: {
Michael Liao70b53a302020-01-19 12:23:11 -0500870 if (/* IsSubstitutionDiagnostic */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200871 R = new (Record.getContext()) concepts::NestedRequirement(
872 readSubstitutionDiagnostic(Record));
873 break;
874 }
875 Expr *E = Record.readExpr();
876 if (E->isInstantiationDependent())
877 R = new (Record.getContext()) concepts::NestedRequirement(E);
878 else
879 R = new (Record.getContext())
880 concepts::NestedRequirement(Record.getContext(), E,
881 readConstraintSatisfaction(Record));
882 } break;
Saar Razfdf80e82019-12-06 01:30:21 +0200883 }
Saar Raza0f50d72020-01-18 09:11:43 +0200884 if (!R)
885 continue;
886 Requirements.push_back(R);
Saar Razfdf80e82019-12-06 01:30:21 +0200887 }
Saar Raza0f50d72020-01-18 09:11:43 +0200888 std::copy(Requirements.begin(), Requirements.end(),
889 E->getTrailingObjects<concepts::Requirement *>());
890 E->RBraceLoc = Record.readSourceLocation();
Saar Raz5d98ba62019-10-15 15:24:26 +0000891}
892
Sebastian Redl70c751d2010-08-18 23:56:52 +0000893void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000894 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000895 E->setLHS(Record.readSubExpr());
896 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500897 E->setRBracketLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000898}
899
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000900void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
901 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000902 E->setBase(Record.readSubExpr());
903 E->setLowerBound(Record.readSubExpr());
904 E->setLength(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500905 E->setColonLoc(readSourceLocation());
906 E->setRBracketLoc(readSourceLocation());
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000907}
908
Sebastian Redl70c751d2010-08-18 23:56:52 +0000909void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000910 VisitExpr(E);
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000911 unsigned NumArgs = Record.readInt();
912 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
John McCall3ce3d232019-12-13 03:37:23 -0500913 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000914 E->setCallee(Record.readSubExpr());
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000915 for (unsigned I = 0; I != NumArgs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000916 E->setArg(I, Record.readSubExpr());
Eric Fiselier5cdc2cd2018-12-12 21:50:55 +0000917 E->setADLCallKind(static_cast<CallExpr::ADLCallKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000918}
919
John McCallfa194042011-07-15 07:00:14 +0000920void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
921 VisitCallExpr(E);
922}
923
Sebastian Redl70c751d2010-08-18 23:56:52 +0000924void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Richard Smithdcf17de2019-06-06 23:24:15 +0000925 VisitExpr(E);
926
927 bool HasQualifier = Record.readInt();
928 bool HasFoundDecl = Record.readInt();
929 bool HasTemplateInfo = Record.readInt();
930 unsigned NumTemplateArgs = Record.readInt();
931
932 E->Base = Record.readSubExpr();
933 E->MemberDecl = Record.readDeclAs<ValueDecl>();
John McCall3ce3d232019-12-13 03:37:23 -0500934 E->MemberDNLoc = Record.readDeclarationNameLoc(E->MemberDecl->getDeclName());
Richard Smithdcf17de2019-06-06 23:24:15 +0000935 E->MemberLoc = Record.readSourceLocation();
936 E->MemberExprBits.IsArrow = Record.readInt();
937 E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
938 E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
939 E->MemberExprBits.HadMultipleCandidates = Record.readInt();
Richard Smith1bbad592019-06-11 17:50:36 +0000940 E->MemberExprBits.NonOdrUseReason = Record.readInt();
Richard Smithdcf17de2019-06-06 23:24:15 +0000941 E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
942
943 if (HasQualifier || HasFoundDecl) {
944 DeclAccessPair FoundDecl;
945 if (HasFoundDecl) {
946 auto *FoundD = Record.readDeclAs<NamedDecl>();
947 auto AS = (AccessSpecifier)Record.readInt();
948 FoundDecl = DeclAccessPair::make(FoundD, AS);
949 } else {
950 FoundDecl = DeclAccessPair::make(E->MemberDecl,
951 E->MemberDecl->getAccess());
952 }
953 E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
954
955 NestedNameSpecifierLoc QualifierLoc;
956 if (HasQualifier)
957 QualifierLoc = Record.readNestedNameSpecifierLoc();
958 E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
959 QualifierLoc;
960 }
961
962 if (HasTemplateInfo)
963 ReadTemplateKWAndArgsInfo(
964 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
965 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000966}
967
Sebastian Redl70c751d2010-08-18 23:56:52 +0000968void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Naroffe87026a2009-07-24 17:54:45 +0000969 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000970 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500971 E->setIsaMemberLoc(readSourceLocation());
972 E->setOpLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000973 E->setArrow(Record.readInt());
Steve Naroffe87026a2009-07-24 17:54:45 +0000974}
975
John McCall31168b02011-06-15 23:02:42 +0000976void ASTStmtReader::
977VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
978 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000979 E->Operand = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000980 E->setShouldCopy(Record.readInt());
John McCall31168b02011-06-15 23:02:42 +0000981}
982
983void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
984 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500985 E->LParenLoc = readSourceLocation();
986 E->BridgeKeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000987 E->Kind = Record.readInt();
John McCall31168b02011-06-15 23:02:42 +0000988}
989
Sebastian Redl70c751d2010-08-18 23:56:52 +0000990void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000991 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000992 unsigned NumBaseSpecs = Record.readInt();
John McCallcf142162010-08-07 06:22:56 +0000993 assert(NumBaseSpecs == E->path_size());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000994 E->setSubExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000995 E->setCastKind((CastKind)Record.readInt());
John McCallcf142162010-08-07 06:22:56 +0000996 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000997 while (NumBaseSpecs--) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000998 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000999 *BaseSpec = Record.readCXXBaseSpecifier();
John McCallcf142162010-08-07 06:22:56 +00001000 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +00001001 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001002}
1003
Sebastian Redl70c751d2010-08-18 23:56:52 +00001004void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001005 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001006 E->setLHS(Record.readSubExpr());
1007 E->setRHS(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001008 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001009 E->setOperatorLoc(readSourceLocation());
Adam Nemet484aa452017-03-27 19:17:25 +00001010 E->setFPFeatures(FPOptions(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001011}
1012
Sebastian Redl70c751d2010-08-18 23:56:52 +00001013void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001014 VisitBinaryOperator(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001015 E->setComputationLHSType(Record.readType());
1016 E->setComputationResultType(Record.readType());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001017}
1018
Sebastian Redl70c751d2010-08-18 23:56:52 +00001019void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001020 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001021 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
1022 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
1023 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001024 E->QuestionLoc = readSourceLocation();
1025 E->ColonLoc = readSourceLocation();
John McCallc07a0c72011-02-17 10:25:35 +00001026}
1027
1028void
1029ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
1030 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001031 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
1032 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
1033 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
1034 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
1035 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001036 E->QuestionLoc = readSourceLocation();
1037 E->ColonLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001038}
1039
Sebastian Redl70c751d2010-08-18 23:56:52 +00001040void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001041 VisitCastExpr(E);
Roman Lebedev12216f12018-07-27 07:27:14 +00001042 E->setIsPartOfExplicitCast(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001043}
1044
Sebastian Redl70c751d2010-08-18 23:56:52 +00001045void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001046 VisitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001047 E->setTypeInfoAsWritten(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001048}
1049
Sebastian Redl70c751d2010-08-18 23:56:52 +00001050void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001051 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001052 E->setLParenLoc(readSourceLocation());
1053 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001054}
1055
Sebastian Redl70c751d2010-08-18 23:56:52 +00001056void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001057 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001058 E->setLParenLoc(readSourceLocation());
1059 E->setTypeSourceInfo(readTypeSourceInfo());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001060 E->setInitializer(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001061 E->setFileScope(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001062}
1063
Sebastian Redl70c751d2010-08-18 23:56:52 +00001064void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001065 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001066 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001067 E->setAccessor(Record.readIdentifier());
1068 E->setAccessorLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001069}
1070
Sebastian Redl70c751d2010-08-18 23:56:52 +00001071void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001072 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001073 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
Abramo Bagnara8d16bd42012-11-08 18:41:43 +00001074 E->setSyntacticForm(SyntForm);
John McCall3ce3d232019-12-13 03:37:23 -05001075 E->setLBraceLoc(readSourceLocation());
1076 E->setRBraceLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001077 bool isArrayFiller = Record.readInt();
Craig Toppera13603a2014-05-22 05:54:18 +00001078 Expr *filler = nullptr;
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001079 if (isArrayFiller) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001080 filler = Record.readSubExpr();
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001081 E->ArrayFillerOrUnionFieldInit = filler;
1082 } else
John McCall3ce3d232019-12-13 03:37:23 -05001083 E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001084 E->sawArrayRangeDesignator(Record.readInt());
1085 unsigned NumInits = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001086 E->reserveInits(Record.getContext(), NumInits);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001087 if (isArrayFiller) {
1088 for (unsigned I = 0; I != NumInits; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001089 Expr *init = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001090 E->updateInit(Record.getContext(), I, init ? init : filler);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001091 }
1092 } else {
1093 for (unsigned I = 0; I != NumInits; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001094 E->updateInit(Record.getContext(), I, Record.readSubExpr());
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001095 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001096}
1097
Sebastian Redl70c751d2010-08-18 23:56:52 +00001098void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001099 using Designator = DesignatedInitExpr::Designator;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001100
1101 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001102 unsigned NumSubExprs = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001103 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
1104 for (unsigned I = 0; I != NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001105 E->setSubExpr(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001106 E->setEqualOrColonLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001107 E->setGNUSyntax(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001108
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001109 SmallVector<Designator, 4> Designators;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001110 while (Record.getIdx() < Record.size()) {
1111 switch ((DesignatorTypes)Record.readInt()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00001112 case DESIG_FIELD_DECL: {
John McCall3ce3d232019-12-13 03:37:23 -05001113 auto *Field = readDeclAs<FieldDecl>();
1114 SourceLocation DotLoc = readSourceLocation();
1115 SourceLocation FieldLoc = readSourceLocation();
Mike Stump11289f42009-09-09 15:08:12 +00001116 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001117 FieldLoc));
1118 Designators.back().setField(Field);
1119 break;
1120 }
1121
Sebastian Redl539c5062010-08-18 23:57:32 +00001122 case DESIG_FIELD_NAME: {
John McCall3ce3d232019-12-13 03:37:23 -05001123 const IdentifierInfo *Name = Record.readIdentifier();
1124 SourceLocation DotLoc = readSourceLocation();
1125 SourceLocation FieldLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001126 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
1127 break;
1128 }
Mike Stump11289f42009-09-09 15:08:12 +00001129
Sebastian Redl539c5062010-08-18 23:57:32 +00001130 case DESIG_ARRAY: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001131 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001132 SourceLocation LBracketLoc = readSourceLocation();
1133 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001134 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
1135 break;
1136 }
1137
Sebastian Redl539c5062010-08-18 23:57:32 +00001138 case DESIG_ARRAY_RANGE: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001139 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001140 SourceLocation LBracketLoc = readSourceLocation();
1141 SourceLocation EllipsisLoc = readSourceLocation();
1142 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001143 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
1144 RBracketLoc));
1145 break;
1146 }
1147 }
1148 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001149 E->setDesignators(Record.getContext(),
Douglas Gregor03e8bdc2010-01-06 23:17:19 +00001150 Designators.data(), Designators.size());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001151}
1152
Yunzhong Gaocb779302015-06-10 00:27:52 +00001153void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1154 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001155 E->setBase(Record.readSubExpr());
1156 E->setUpdater(Record.readSubExpr());
Yunzhong Gaocb779302015-06-10 00:27:52 +00001157}
1158
1159void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1160 VisitExpr(E);
1161}
1162
Richard Smith410306b2016-12-12 02:53:20 +00001163void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1164 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001165 E->SubExprs[0] = Record.readSubExpr();
1166 E->SubExprs[1] = Record.readSubExpr();
Richard Smith410306b2016-12-12 02:53:20 +00001167}
1168
1169void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1170 VisitExpr(E);
1171}
1172
Sebastian Redl70c751d2010-08-18 23:56:52 +00001173void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001174 VisitExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001175}
1176
Sebastian Redl70c751d2010-08-18 23:56:52 +00001177void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001178 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001179 E->setSubExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001180 E->setWrittenTypeInfo(readTypeSourceInfo());
1181 E->setBuiltinLoc(readSourceLocation());
1182 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001183 E->setIsMicrosoftABI(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001184}
1185
Eric Fiselier708afb52019-05-16 21:04:15 +00001186void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1187 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001188 E->ParentContext = readDeclAs<DeclContext>();
1189 E->BuiltinLoc = readSourceLocation();
1190 E->RParenLoc = readSourceLocation();
Eric Fiselier708afb52019-05-16 21:04:15 +00001191 E->SourceLocExprBits.Kind =
1192 static_cast<SourceLocExpr::IdentKind>(Record.readInt());
1193}
1194
Sebastian Redl70c751d2010-08-18 23:56:52 +00001195void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001196 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001197 E->setAmpAmpLoc(readSourceLocation());
1198 E->setLabelLoc(readSourceLocation());
1199 E->setLabel(readDeclAs<LabelDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001200}
1201
Sebastian Redl70c751d2010-08-18 23:56:52 +00001202void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001203 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001204 E->setLParenLoc(readSourceLocation());
1205 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001206 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
Richard Smith5c845c12020-03-09 17:34:33 -07001207 E->StmtExprBits.TemplateDepth = Record.readInt();
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());
Akira Hatanaka40568fe2020-03-10 14:06:25 -07001822 for (unsigned i = 0; i != NumObjects; ++i) {
1823 unsigned CleanupKind = Record.readInt();
1824 ExprWithCleanups::CleanupObject Obj;
1825 if (CleanupKind == COK_Block)
1826 Obj = readDeclAs<BlockDecl>();
1827 else if (CleanupKind == COK_CompoundLiteral)
1828 Obj = cast<CompoundLiteralExpr>(Record.readSubExpr());
1829 else
1830 llvm_unreachable("unexpected cleanup object type");
1831 E->getTrailingObjects<ExprWithCleanups::CleanupObject>()[i] = Obj;
1832 }
John McCall28fc7092011-11-10 05:35:25 +00001833
David L. Jonesbe1557a2016-12-21 00:17:49 +00001834 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001835 E->SubExpr = Record.readSubExpr();
Chris Lattnere2437f42010-05-09 06:40:08 +00001836}
1837
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001838void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1839 CXXDependentScopeMemberExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001840 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001841
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001842 bool HasTemplateKWAndArgsInfo = Record.readInt();
1843 unsigned NumTemplateArgs = Record.readInt();
1844 bool HasFirstQualifierFoundInScope = Record.readInt();
1845
1846 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
1847 "Wrong HasTemplateKWAndArgsInfo!");
1848 assert(
1849 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
1850 "Wrong HasFirstQualifierFoundInScope!");
1851
1852 if (HasTemplateKWAndArgsInfo)
James Y Knighte7d82282015-12-29 18:15:14 +00001853 ReadTemplateKWAndArgsInfo(
1854 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001855 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001856
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001857 assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
1858 "Wrong NumTemplateArgs!");
1859
1860 E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001861 E->CXXDependentScopeMemberExprBits.OperatorLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001862 E->BaseType = Record.readType();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001863 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001864 E->Base = Record.readSubExpr();
1865
1866 if (HasFirstQualifierFoundInScope)
John McCall3ce3d232019-12-13 03:37:23 -05001867 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001868
John McCall3ce3d232019-12-13 03:37:23 -05001869 E->MemberNameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001870}
1871
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001872void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001873ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001874 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001875
David L. Jonesbe1557a2016-12-21 00:17:49 +00001876 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001877 ReadTemplateKWAndArgsInfo(
1878 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1879 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001880 /*NumTemplateArgs=*/Record.readInt());
Douglas Gregor3a43fd62011-02-25 20:49:16 +00001881
David L. Jonesb6a8f022016-12-21 04:34:52 +00001882 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001883 E->NameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001884}
1885
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001886void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001887ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001888 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001889 assert(Record.peekInt() == E->arg_size() &&
1890 "Read wrong record during creation ?");
1891 Record.skipInts(1);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001892 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001893 E->setArg(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001894 E->TSI = readTypeSourceInfo();
1895 E->setLParenLoc(readSourceLocation());
1896 E->setRParenLoc(readSourceLocation());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001897}
1898
Sebastian Redl70c751d2010-08-18 23:56:52 +00001899void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001900 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001901
Bruno Riccid7628d92019-01-09 15:43:19 +00001902 unsigned NumResults = Record.readInt();
1903 bool HasTemplateKWAndArgsInfo = Record.readInt();
1904 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
1905 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
1906 "Wrong HasTemplateKWAndArgsInfo!");
1907
1908 if (HasTemplateKWAndArgsInfo) {
1909 unsigned NumTemplateArgs = Record.readInt();
James Y Knighte7d82282015-12-29 18:15:14 +00001910 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1911 E->getTrailingTemplateArgumentLoc(),
Bruno Riccid7628d92019-01-09 15:43:19 +00001912 NumTemplateArgs);
1913 assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
1914 "Wrong NumTemplateArgs!");
1915 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001916
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001917 UnresolvedSet<8> Decls;
Bruno Riccid7628d92019-01-09 15:43:19 +00001918 for (unsigned I = 0; I != NumResults; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -05001919 auto *D = readDeclAs<NamedDecl>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001920 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001921 Decls.addDecl(D, AS);
1922 }
Bruno Riccid7628d92019-01-09 15:43:19 +00001923
1924 DeclAccessPair *Results = E->getTrailingResults();
1925 UnresolvedSetIterator Iter = Decls.begin();
1926 for (unsigned I = 0; I != NumResults; ++I) {
1927 Results[I] = (Iter + I).getPair();
1928 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001929
John McCall3ce3d232019-12-13 03:37:23 -05001930 E->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001931 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001932}
1933
Sebastian Redl70c751d2010-08-18 23:56:52 +00001934void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001935 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00001936 E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
1937 E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001938 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001939 E->BaseType = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001940 E->OperatorLoc = readSourceLocation();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001941}
1942
Sebastian Redl70c751d2010-08-18 23:56:52 +00001943void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001944 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00001945 E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
1946 E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001947 E->NamingClass = readDeclAs<CXXRecordDecl>();
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00001948}
1949
Douglas Gregor29c42f22012-02-24 07:38:34 +00001950void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1951 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001952 E->TypeTraitExprBits.NumArgs = Record.readInt();
1953 E->TypeTraitExprBits.Kind = Record.readInt();
1954 E->TypeTraitExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001955 SourceRange Range = readSourceRange();
Jordan Rose99e80c12013-12-20 01:26:47 +00001956 E->Loc = Range.getBegin();
1957 E->RParenLoc = Range.getEnd();
1958
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001959 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001960 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001961 Args[I] = readTypeSourceInfo();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001962}
1963
John Wiegley6242b6a2011-04-28 00:16:57 +00001964void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1965 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001966 E->ATT = (ArrayTypeTrait)Record.readInt();
1967 E->Value = (unsigned int)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001968 SourceRange Range = readSourceRange();
John Wiegley6242b6a2011-04-28 00:16:57 +00001969 E->Loc = Range.getBegin();
1970 E->RParen = Range.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05001971 E->QueriedType = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001972 E->Dimension = Record.readSubExpr();
John Wiegley6242b6a2011-04-28 00:16:57 +00001973}
1974
John Wiegleyf9f65842011-04-25 06:54:41 +00001975void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1976 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001977 E->ET = (ExpressionTrait)Record.readInt();
1978 E->Value = (bool)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001979 SourceRange Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001980 E->QueriedExpression = Record.readSubExpr();
John Wiegleyf9f65842011-04-25 06:54:41 +00001981 E->Loc = Range.getBegin();
1982 E->RParen = Range.getEnd();
1983}
1984
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001985void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1986 VisitExpr(E);
Bruno Riccid56edfe2019-01-08 14:44:34 +00001987 E->CXXNoexceptExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001988 E->Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001989 E->Operand = Record.readSubExpr();
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001990}
1991
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001992void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1993 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001994 E->EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001995 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001996 E->Pattern = Record.readSubExpr();
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001997}
1998
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001999void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2000 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002001 unsigned NumPartialArgs = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002002 E->OperatorLoc = readSourceLocation();
2003 E->PackLoc = readSourceLocation();
2004 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002005 E->Pack = Record.readDeclAs<NamedDecl>();
Richard Smithd784e682015-09-23 21:41:42 +00002006 if (E->isPartiallySubstituted()) {
2007 assert(E->Length == NumPartialArgs);
James Y Knighte00a67e2015-12-31 04:18:25 +00002008 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
Richard Smithd784e682015-09-23 21:41:42 +00002009 *E = I + NumPartialArgs;
2010 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002011 new (I) TemplateArgument(Record.readTemplateArgument());
Richard Smithd784e682015-09-23 21:41:42 +00002012 } else if (!E->isValueDependent()) {
David L. Jonesbe1557a2016-12-21 00:17:49 +00002013 E->Length = Record.readInt();
Richard Smithd784e682015-09-23 21:41:42 +00002014 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00002015}
2016
John McCallfa194042011-07-15 07:00:14 +00002017void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
2018 SubstNonTypeTemplateParmExpr *E) {
2019 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002020 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
2021 E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002022 E->Replacement = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002023}
2024
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002025void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
2026 SubstNonTypeTemplateParmPackExpr *E) {
2027 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002028 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002029 TemplateArgument ArgPack = Record.readTemplateArgument();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002030 if (ArgPack.getKind() != TemplateArgument::Pack)
2031 return;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002032
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002033 E->Arguments = ArgPack.pack_begin();
2034 E->NumArguments = ArgPack.pack_size();
John McCall3ce3d232019-12-13 03:37:23 -05002035 E->NameLoc = readSourceLocation();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002036}
2037
Richard Smithb15fe3a2012-09-12 00:56:43 +00002038void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2039 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002040 E->NumParameters = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002041 E->ParamPack = readDeclAs<ParmVarDecl>();
2042 E->NameLoc = readSourceLocation();
Richard Smithb2997f52019-05-21 20:10:50 +00002043 auto **Parms = E->getTrailingObjects<VarDecl *>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00002044 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
John McCall3ce3d232019-12-13 03:37:23 -05002045 Parms[i] = readDeclAs<VarDecl>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00002046}
2047
Douglas Gregorfe314812011-06-21 17:03:29 +00002048void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
2049 VisitExpr(E);
Tykerb0561b32019-11-17 11:41:55 +01002050 bool HasMaterialzedDecl = Record.readInt();
2051 if (HasMaterialzedDecl)
2052 E->State = cast<LifetimeExtendedTemporaryDecl>(Record.readDecl());
2053 else
2054 E->State = Record.readSubExpr();
Douglas Gregorfe314812011-06-21 17:03:29 +00002055}
2056
Richard Smith0f0af192014-11-08 05:07:16 +00002057void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
2058 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002059 E->LParenLoc = readSourceLocation();
2060 E->EllipsisLoc = readSourceLocation();
2061 E->RParenLoc = readSourceLocation();
Richard Smithc7214f62019-05-13 08:31:14 +00002062 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002063 E->SubExprs[0] = Record.readSubExpr();
2064 E->SubExprs[1] = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002065 E->Opcode = (BinaryOperatorKind)Record.readInt();
Richard Smith0f0af192014-11-08 05:07:16 +00002066}
2067
John McCall8d69a212010-11-15 23:31:06 +00002068void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
2069 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002070 E->SourceExpr = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05002071 E->OpaqueValueExprBits.Loc = readSourceLocation();
Akira Hatanaka797afe32018-03-20 01:47:58 +00002072 E->setIsUnique(Record.readInt());
John McCall8d69a212010-11-15 23:31:06 +00002073}
2074
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00002075void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
2076 llvm_unreachable("Cannot read TypoExpr nodes");
2077}
2078
Peter Collingbourne41f85462011-02-09 21:07:24 +00002079//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002080// Microsoft Expressions and Statements
2081//===----------------------------------------------------------------------===//
John McCall5e77d762013-04-16 07:28:30 +00002082void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
2083 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002084 E->IsArrow = (Record.readInt() != 0);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002085 E->BaseExpr = Record.readSubExpr();
2086 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05002087 E->MemberLoc = readSourceLocation();
2088 E->TheDecl = readDeclAs<MSPropertyDecl>();
John McCall5e77d762013-04-16 07:28:30 +00002089}
2090
Alexey Bataevf7630272015-11-25 12:01:00 +00002091void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
2092 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002093 E->setBase(Record.readSubExpr());
2094 E->setIdx(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05002095 E->setRBracketLoc(readSourceLocation());
Alexey Bataevf7630272015-11-25 12:01:00 +00002096}
2097
John McCallfa194042011-07-15 07:00:14 +00002098void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
2099 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002100 E->setSourceRange(readSourceRange());
2101 std::string UuidStr = readString();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002102 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
John McCallfa194042011-07-15 07:00:14 +00002103 if (E->isTypeOperand()) { // __uuidof(ComType)
2104 E->setTypeOperandSourceInfo(
John McCall3ce3d232019-12-13 03:37:23 -05002105 readTypeSourceInfo());
John McCallfa194042011-07-15 07:00:14 +00002106 return;
2107 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002108
John McCallfa194042011-07-15 07:00:14 +00002109 // __uuidof(expr)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002110 E->setExprOperand(Record.readSubExpr());
John McCallfa194042011-07-15 07:00:14 +00002111}
2112
Nico Weber9b982072014-07-07 00:12:30 +00002113void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
2114 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002115 S->setLeaveLoc(readSourceLocation());
Nico Weber9b982072014-07-07 00:12:30 +00002116}
2117
John McCallfa194042011-07-15 07:00:14 +00002118void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
2119 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002120 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002121 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
2122 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002123}
2124
2125void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
2126 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002127 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002128 S->Block = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002129}
2130
2131void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
2132 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002133 S->IsCXXTry = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002134 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002135 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
2136 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002137}
2138
2139//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00002140// CUDA Expressions and Statements
2141//===----------------------------------------------------------------------===//
2142
2143void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2144 VisitCallExpr(E);
Richard Smithfd420792019-05-24 23:26:07 +00002145 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
Peter Collingbourne41f85462011-02-09 21:07:24 +00002146}
2147
John McCallfa194042011-07-15 07:00:14 +00002148//===----------------------------------------------------------------------===//
2149// OpenCL Expressions and Statements.
2150//===----------------------------------------------------------------------===//
2151void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2152 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002153 E->BuiltinLoc = readSourceLocation();
2154 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002155 E->SrcExpr = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002156}
2157
2158//===----------------------------------------------------------------------===//
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002159// OpenMP Directives.
2160//===----------------------------------------------------------------------===//
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002161
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002162void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
John McCall3ce3d232019-12-13 03:37:23 -05002163 E->setLocStart(readSourceLocation());
2164 E->setLocEnd(readSourceLocation());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002165 SmallVector<OMPClause *, 5> Clauses;
2166 for (unsigned i = 0; i < E->getNumClauses(); ++i)
John McCallc2f18312019-12-14 03:01:28 -05002167 Clauses.push_back(Record.readOMPClause());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002168 E->setClauses(Clauses);
Alexey Bataev68446b72014-07-18 07:47:19 +00002169 if (E->hasAssociatedStmt())
David L. Jonesb6a8f022016-12-21 04:34:52 +00002170 E->setAssociatedStmt(Record.readSubStmt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002171}
2172
Alexander Musman3aaab662014-08-19 11:27:13 +00002173void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2174 VisitStmt(D);
2175 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002176 Record.skipInts(2);
Alexander Musman3aaab662014-08-19 11:27:13 +00002177 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002178 D->setIterationVariable(Record.readSubExpr());
2179 D->setLastIteration(Record.readSubExpr());
2180 D->setCalcLastIteration(Record.readSubExpr());
2181 D->setPreCond(Record.readSubExpr());
2182 D->setCond(Record.readSubExpr());
2183 D->setInit(Record.readSubExpr());
2184 D->setInc(Record.readSubExpr());
2185 D->setPreInits(Record.readSubStmt());
Alexey Bataev3392d762016-02-16 11:18:12 +00002186 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
Carlo Bertollifc35ad22016-03-07 16:04:49 +00002187 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2188 isOpenMPDistributeDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002189 D->setIsLastIterVariable(Record.readSubExpr());
2190 D->setLowerBoundVariable(Record.readSubExpr());
2191 D->setUpperBoundVariable(Record.readSubExpr());
2192 D->setStrideVariable(Record.readSubExpr());
2193 D->setEnsureUpperBound(Record.readSubExpr());
2194 D->setNextLowerBound(Record.readSubExpr());
2195 D->setNextUpperBound(Record.readSubExpr());
2196 D->setNumIterations(Record.readSubExpr());
Alexander Musmanc6388682014-12-15 07:07:06 +00002197 }
Carlo Bertolli9925f152016-06-27 14:55:37 +00002198 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002199 D->setPrevLowerBoundVariable(Record.readSubExpr());
2200 D->setPrevUpperBoundVariable(Record.readSubExpr());
Carlo Bertolli8429d812017-02-17 21:29:13 +00002201 D->setDistInc(Record.readSubExpr());
2202 D->setPrevEnsureUpperBound(Record.readSubExpr());
Carlo Bertolliffafe102017-04-20 00:39:39 +00002203 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2204 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2205 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2206 D->setCombinedInit(Record.readSubExpr());
2207 D->setCombinedCond(Record.readSubExpr());
2208 D->setCombinedNextLowerBound(Record.readSubExpr());
2209 D->setCombinedNextUpperBound(Record.readSubExpr());
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00002210 D->setCombinedDistCond(Record.readSubExpr());
2211 D->setCombinedParForInDistCond(Record.readSubExpr());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002212 }
Alexander Musmana5f070a2014-10-01 06:03:56 +00002213 SmallVector<Expr *, 4> Sub;
2214 unsigned CollapsedNum = D->getCollapsedNumber();
2215 Sub.reserve(CollapsedNum);
2216 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002217 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002218 D->setCounters(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());
Alexey Bataeva8899172015-08-06 12:30:57 +00002222 D->setPrivateCounters(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());
Alexey Bataevb08f89f2015-08-14 12:25:37 +00002226 D->setInits(Sub);
2227 Sub.clear();
2228 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002229 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002230 D->setUpdates(Sub);
2231 Sub.clear();
2232 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002233 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002234 D->setFinals(Sub);
Alexey Bataevf8be4762019-08-14 19:30:06 +00002235 Sub.clear();
2236 for (unsigned i = 0; i < CollapsedNum; ++i)
2237 Sub.push_back(Record.readSubExpr());
2238 D->setDependentCounters(Sub);
2239 Sub.clear();
2240 for (unsigned i = 0; i < CollapsedNum; ++i)
2241 Sub.push_back(Record.readSubExpr());
2242 D->setDependentInits(Sub);
2243 Sub.clear();
2244 for (unsigned i = 0; i < CollapsedNum; ++i)
2245 Sub.push_back(Record.readSubExpr());
2246 D->setFinalsConditions(Sub);
Alexander Musman3aaab662014-08-19 11:27:13 +00002247}
2248
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002249void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002250 VisitStmt(D);
2251 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002252 Record.skipInts(1);
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002253 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002254 D->setHasCancel(Record.readInt());
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002255}
2256
2257void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002258 VisitOMPLoopDirective(D);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002259}
2260
Alexey Bataevf29276e2014-06-18 04:14:57 +00002261void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002262 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002263 D->setHasCancel(Record.readInt());
Alexey Bataevf29276e2014-06-18 04:14:57 +00002264}
2265
Alexander Musmanf82886e2014-09-18 05:12:34 +00002266void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2267 VisitOMPLoopDirective(D);
2268}
2269
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002270void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2271 VisitStmt(D);
2272 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002273 Record.skipInts(1);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002274 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002275 D->setHasCancel(Record.readInt());
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002276}
2277
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002278void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2279 VisitStmt(D);
2280 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002281 D->setHasCancel(Record.readInt());
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002282}
2283
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002284void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2285 VisitStmt(D);
2286 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002287 Record.skipInts(1);
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002288 VisitOMPExecutableDirective(D);
2289}
2290
Alexander Musman80c22892014-07-17 08:54:58 +00002291void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2292 VisitStmt(D);
2293 VisitOMPExecutableDirective(D);
2294}
2295
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002296void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2297 VisitStmt(D);
Alexey Bataev28c75412015-12-15 08:19:24 +00002298 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002299 Record.skipInts(1);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002300 VisitOMPExecutableDirective(D);
John McCall3ce3d232019-12-13 03:37:23 -05002301 D->DirName = Record.readDeclarationNameInfo();
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002302}
2303
Alexey Bataev4acb8592014-07-07 13:01:15 +00002304void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002305 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002306 D->setHasCancel(Record.readInt());
Alexey Bataev4acb8592014-07-07 13:01:15 +00002307}
2308
Alexander Musmane4e893b2014-09-23 09:33:00 +00002309void ASTStmtReader::VisitOMPParallelForSimdDirective(
2310 OMPParallelForSimdDirective *D) {
2311 VisitOMPLoopDirective(D);
2312}
2313
cchen47d60942019-12-05 13:43:48 -05002314void ASTStmtReader::VisitOMPParallelMasterDirective(
2315 OMPParallelMasterDirective *D) {
2316 VisitStmt(D);
2317 // The NumClauses field was read in ReadStmtFromStream.
2318 Record.skipInts(1);
2319 VisitOMPExecutableDirective(D);
2320}
2321
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002322void ASTStmtReader::VisitOMPParallelSectionsDirective(
2323 OMPParallelSectionsDirective *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 Bataev84d0b3e2014-07-08 08:12:03 +00002327 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002328 D->setHasCancel(Record.readInt());
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002329}
2330
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002331void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2332 VisitStmt(D);
2333 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002334 Record.skipInts(1);
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002335 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002336 D->setHasCancel(Record.readInt());
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002337}
2338
Alexey Bataev68446b72014-07-18 07:47:19 +00002339void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2340 VisitStmt(D);
2341 VisitOMPExecutableDirective(D);
2342}
2343
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002344void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2345 VisitStmt(D);
2346 VisitOMPExecutableDirective(D);
2347}
2348
Alexey Bataev2df347a2014-07-18 10:17:07 +00002349void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2350 VisitStmt(D);
2351 VisitOMPExecutableDirective(D);
2352}
2353
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002354void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2355 VisitStmt(D);
Alexey Bataev169d96a2017-07-18 20:17:46 +00002356 // The NumClauses field was read in ReadStmtFromStream.
2357 Record.skipInts(1);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002358 VisitOMPExecutableDirective(D);
Alexey Bataev3b1b8952017-07-25 15:53:26 +00002359 D->setReductionRef(Record.readSubExpr());
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002360}
2361
Alexey Bataev6125da92014-07-21 11:26:11 +00002362void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2363 VisitStmt(D);
2364 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002365 Record.skipInts(1);
Alexey Bataev6125da92014-07-21 11:26:11 +00002366 VisitOMPExecutableDirective(D);
2367}
2368
Alexey Bataevc112e942020-02-28 09:52:15 -05002369void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective *D) {
2370 VisitStmt(D);
2371 // The NumClauses field was read in ReadStmtFromStream.
2372 Record.skipInts(1);
2373 VisitOMPExecutableDirective(D);
2374}
2375
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002376void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2377 VisitStmt(D);
Alexey Bataev346265e2015-09-25 10:37:12 +00002378 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002379 Record.skipInts(1);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002380 VisitOMPExecutableDirective(D);
2381}
2382
Alexey Bataev0162e452014-07-22 10:10:35 +00002383void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2384 VisitStmt(D);
2385 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002386 Record.skipInts(1);
Alexey Bataev0162e452014-07-22 10:10:35 +00002387 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002388 D->setX(Record.readSubExpr());
2389 D->setV(Record.readSubExpr());
2390 D->setExpr(Record.readSubExpr());
2391 D->setUpdateExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002392 D->IsXLHSInRHSPart = Record.readInt() != 0;
2393 D->IsPostfixUpdate = Record.readInt() != 0;
Alexey Bataev0162e452014-07-22 10:10:35 +00002394}
2395
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002396void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2397 VisitStmt(D);
2398 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002399 Record.skipInts(1);
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002400 VisitOMPExecutableDirective(D);
2401}
2402
Michael Wong65f367f2015-07-21 13:44:28 +00002403void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2404 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002405 Record.skipInts(1);
Michael Wong65f367f2015-07-21 13:44:28 +00002406 VisitOMPExecutableDirective(D);
2407}
2408
Samuel Antaodf67fc42016-01-19 19:15:56 +00002409void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2410 OMPTargetEnterDataDirective *D) {
2411 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002412 Record.skipInts(1);
Samuel Antaodf67fc42016-01-19 19:15:56 +00002413 VisitOMPExecutableDirective(D);
2414}
2415
Samuel Antao72590762016-01-19 20:04:50 +00002416void ASTStmtReader::VisitOMPTargetExitDataDirective(
2417 OMPTargetExitDataDirective *D) {
2418 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002419 Record.skipInts(1);
Samuel Antao72590762016-01-19 20:04:50 +00002420 VisitOMPExecutableDirective(D);
2421}
2422
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002423void ASTStmtReader::VisitOMPTargetParallelDirective(
2424 OMPTargetParallelDirective *D) {
2425 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002426 Record.skipInts(1);
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002427 VisitOMPExecutableDirective(D);
2428}
2429
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002430void ASTStmtReader::VisitOMPTargetParallelForDirective(
2431 OMPTargetParallelForDirective *D) {
2432 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002433 D->setHasCancel(Record.readInt());
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002434}
2435
Alexey Bataev13314bf2014-10-09 04:18:56 +00002436void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2437 VisitStmt(D);
2438 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002439 Record.skipInts(1);
Alexey Bataev13314bf2014-10-09 04:18:56 +00002440 VisitOMPExecutableDirective(D);
2441}
2442
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002443void ASTStmtReader::VisitOMPCancellationPointDirective(
2444 OMPCancellationPointDirective *D) {
2445 VisitStmt(D);
2446 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002447 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002448}
2449
Alexey Bataev80909872015-07-02 11:25:17 +00002450void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2451 VisitStmt(D);
Alexey Bataev87933c72015-09-18 08:07:34 +00002452 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002453 Record.skipInts(1);
Alexey Bataev80909872015-07-02 11:25:17 +00002454 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002455 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev80909872015-07-02 11:25:17 +00002456}
2457
Alexey Bataev49f6e782015-12-01 04:18:41 +00002458void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2459 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002460 D->setHasCancel(Record.readInt());
Alexey Bataev49f6e782015-12-01 04:18:41 +00002461}
2462
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002463void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2464 VisitOMPLoopDirective(D);
2465}
2466
Alexey Bataev60e51c42019-10-10 20:13:02 +00002467void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2468 OMPMasterTaskLoopDirective *D) {
2469 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002470 D->setHasCancel(Record.readInt());
Alexey Bataev60e51c42019-10-10 20:13:02 +00002471}
2472
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002473void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2474 OMPMasterTaskLoopSimdDirective *D) {
2475 VisitOMPLoopDirective(D);
2476}
2477
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002478void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2479 OMPParallelMasterTaskLoopDirective *D) {
2480 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002481 D->setHasCancel(Record.readInt());
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002482}
2483
Alexey Bataev14a388f2019-10-25 10:27:13 -04002484void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2485 OMPParallelMasterTaskLoopSimdDirective *D) {
2486 VisitOMPLoopDirective(D);
2487}
2488
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002489void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2490 VisitOMPLoopDirective(D);
2491}
2492
Samuel Antao686c70c2016-05-26 17:30:50 +00002493void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2494 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002495 Record.skipInts(1);
Samuel Antao686c70c2016-05-26 17:30:50 +00002496 VisitOMPExecutableDirective(D);
2497}
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002498
Carlo Bertolli9925f152016-06-27 14:55:37 +00002499void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2500 OMPDistributeParallelForDirective *D) {
2501 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002502 D->setHasCancel(Record.readInt());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002503}
Samuel Antao686c70c2016-05-26 17:30:50 +00002504
Kelvin Li4a39add2016-07-05 05:00:15 +00002505void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2506 OMPDistributeParallelForSimdDirective *D) {
2507 VisitOMPLoopDirective(D);
2508}
2509
Kelvin Li787f3fc2016-07-06 04:45:38 +00002510void ASTStmtReader::VisitOMPDistributeSimdDirective(
2511 OMPDistributeSimdDirective *D) {
2512 VisitOMPLoopDirective(D);
2513}
2514
Kelvin Lia579b912016-07-14 02:54:56 +00002515void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2516 OMPTargetParallelForSimdDirective *D) {
2517 VisitOMPLoopDirective(D);
2518}
2519
Kelvin Li986330c2016-07-20 22:57:10 +00002520void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2521 VisitOMPLoopDirective(D);
2522}
2523
Kelvin Li02532872016-08-05 14:37:37 +00002524void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2525 OMPTeamsDistributeDirective *D) {
2526 VisitOMPLoopDirective(D);
2527}
2528
Kelvin Li4e325f72016-10-25 12:50:55 +00002529void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2530 OMPTeamsDistributeSimdDirective *D) {
2531 VisitOMPLoopDirective(D);
2532}
2533
Kelvin Li579e41c2016-11-30 23:51:03 +00002534void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2535 OMPTeamsDistributeParallelForSimdDirective *D) {
2536 VisitOMPLoopDirective(D);
2537}
2538
Kelvin Li7ade93f2016-12-09 03:24:30 +00002539void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2540 OMPTeamsDistributeParallelForDirective *D) {
2541 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002542 D->setHasCancel(Record.readInt());
Kelvin Li7ade93f2016-12-09 03:24:30 +00002543}
2544
Kelvin Libf594a52016-12-17 05:48:59 +00002545void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2546 VisitStmt(D);
2547 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002548 Record.skipInts(1);
Kelvin Libf594a52016-12-17 05:48:59 +00002549 VisitOMPExecutableDirective(D);
2550}
2551
Kelvin Li83c451e2016-12-25 04:52:54 +00002552void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2553 OMPTargetTeamsDistributeDirective *D) {
2554 VisitOMPLoopDirective(D);
2555}
2556
Kelvin Li80e8f562016-12-29 22:16:30 +00002557void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2558 OMPTargetTeamsDistributeParallelForDirective *D) {
2559 VisitOMPLoopDirective(D);
Alexey Bataev16e79882017-11-22 21:12:03 +00002560 D->setHasCancel(Record.readInt());
Kelvin Li80e8f562016-12-29 22:16:30 +00002561}
2562
Kelvin Li1851df52017-01-03 05:23:48 +00002563void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2564 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2565 VisitOMPLoopDirective(D);
2566}
2567
Kelvin Lida681182017-01-10 18:08:18 +00002568void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2569 OMPTargetTeamsDistributeSimdDirective *D) {
2570 VisitOMPLoopDirective(D);
2571}
2572
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002573//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002574// ASTReader Implementation
2575//===----------------------------------------------------------------------===//
2576
Douglas Gregorde3ef502011-11-30 23:21:26 +00002577Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002578 switch (ReadingKind) {
Richard Smith629ff362013-07-31 00:26:46 +00002579 case Read_None:
2580 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002581 case Read_Decl:
2582 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00002583 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002584 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002585 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002586 }
2587
2588 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002589}
2590
Douglas Gregorde3ef502011-11-30 23:21:26 +00002591Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00002592 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002593}
Chris Lattnere2437f42010-05-09 06:40:08 +00002594
Sebastian Redl2c499f62010-08-18 23:56:43 +00002595Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002596 return cast_or_null<Expr>(ReadSubStmt());
2597}
2598
Chris Lattnerf4262532009-04-27 05:41:06 +00002599// Within the bitstream, expressions are stored in Reverse Polish
2600// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002601// expression they are stored in. Subexpressions are stored from last to first.
2602// To evaluate expressions, we continue reading expressions and placing them on
2603// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00002604// stack. Evaluation terminates when we see a STMT_STOP record, and
2605// the single remaining expression on the stack is our result.
Douglas Gregorde3ef502011-11-30 23:21:26 +00002606Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002607 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00002608 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002609
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002610 // Map of offset to previously deserialized stmt. The offset points
George Burgess IV758cf9d2017-02-14 05:52:57 +00002611 // just after the stmt record.
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002612 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00002613
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002614#ifndef NDEBUG
2615 unsigned PrevNumStmts = StmtStack.size();
2616#endif
2617
David L. Jonesbe1557a2016-12-21 00:17:49 +00002618 ASTRecordReader Record(*this, F);
2619 ASTStmtReader Reader(Record, Cursor);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002620 Stmt::EmptyShell Empty;
2621
2622 while (true) {
JF Bastien0e828952019-06-26 19:50:12 +00002623 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2624 Cursor.advanceSkippingSubblocks();
2625 if (!MaybeEntry) {
2626 Error(toString(MaybeEntry.takeError()));
2627 return nullptr;
2628 }
2629 llvm::BitstreamEntry Entry = MaybeEntry.get();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002630
Chris Lattner0e6c9402013-01-20 02:38:54 +00002631 switch (Entry.Kind) {
2632 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2633 case llvm::BitstreamEntry::Error:
2634 Error("malformed block record in AST file");
Craig Toppera13603a2014-05-22 05:54:18 +00002635 return nullptr;
Chris Lattner0e6c9402013-01-20 02:38:54 +00002636 case llvm::BitstreamEntry::EndBlock:
2637 goto Done;
2638 case llvm::BitstreamEntry::Record:
2639 // The interesting case.
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002640 break;
2641 }
2642
Richard Smithdbafb6c2017-06-29 23:23:46 +00002643 ASTContext &Context = getContext();
Craig Toppera13603a2014-05-22 05:54:18 +00002644 Stmt *S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002645 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002646 bool IsStmtReference = false;
JF Bastien0e828952019-06-26 19:50:12 +00002647 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2648 if (!MaybeStmtCode) {
2649 Error(toString(MaybeStmtCode.takeError()));
2650 return nullptr;
2651 }
2652 switch ((StmtCode)MaybeStmtCode.get()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00002653 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002654 Finished = true;
2655 break;
2656
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002657 case STMT_REF_PTR:
2658 IsStmtReference = true;
2659 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2660 "No stmt was recorded for this offset reference!");
David L. Jonesbe1557a2016-12-21 00:17:49 +00002661 S = StmtEntries[Record.readInt()];
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002662 break;
2663
Sebastian Redl539c5062010-08-18 23:57:32 +00002664 case STMT_NULL_PTR:
Craig Toppera13603a2014-05-22 05:54:18 +00002665 S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002666 break;
2667
Sebastian Redl539c5062010-08-18 23:57:32 +00002668 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002669 S = new (Context) NullStmt(Empty);
2670 break;
2671
Sebastian Redl539c5062010-08-18 23:57:32 +00002672 case STMT_COMPOUND:
Benjamin Kramer07420902017-12-24 16:24:20 +00002673 S = CompoundStmt::CreateEmpty(
2674 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002675 break;
2676
Sebastian Redl539c5062010-08-18 23:57:32 +00002677 case STMT_CASE:
Bruno Ricci5b30571752018-10-28 12:30:53 +00002678 S = CaseStmt::CreateEmpty(
2679 Context,
2680 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002681 break;
2682
Sebastian Redl539c5062010-08-18 23:57:32 +00002683 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002684 S = new (Context) DefaultStmt(Empty);
2685 break;
2686
Sebastian Redl539c5062010-08-18 23:57:32 +00002687 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002688 S = new (Context) LabelStmt(Empty);
2689 break;
2690
Richard Smithc202b282012-04-14 00:33:13 +00002691 case STMT_ATTRIBUTED:
Alexander Kornienko20f6fc62012-07-09 10:04:07 +00002692 S = AttributedStmt::CreateEmpty(
2693 Context,
2694 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smithc202b282012-04-14 00:33:13 +00002695 break;
2696
Sebastian Redl539c5062010-08-18 23:57:32 +00002697 case STMT_IF:
Bruno Riccib1cc94b2018-10-27 21:12:20 +00002698 S = IfStmt::CreateEmpty(
2699 Context,
2700 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2701 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2702 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002703 break;
2704
Sebastian Redl539c5062010-08-18 23:57:32 +00002705 case STMT_SWITCH:
Bruno Riccie2806f82018-10-29 16:12:37 +00002706 S = SwitchStmt::CreateEmpty(
2707 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002708 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
Bruno Riccie2806f82018-10-29 16:12:37 +00002709 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002710 break;
2711
Sebastian Redl539c5062010-08-18 23:57:32 +00002712 case STMT_WHILE:
Bruno Riccibacf7512018-10-30 13:42:41 +00002713 S = WhileStmt::CreateEmpty(
2714 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002715 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002716 break;
2717
Sebastian Redl539c5062010-08-18 23:57:32 +00002718 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002719 S = new (Context) DoStmt(Empty);
2720 break;
Mike Stump11289f42009-09-09 15:08:12 +00002721
Sebastian Redl539c5062010-08-18 23:57:32 +00002722 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002723 S = new (Context) ForStmt(Empty);
2724 break;
2725
Sebastian Redl539c5062010-08-18 23:57:32 +00002726 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002727 S = new (Context) GotoStmt(Empty);
2728 break;
Mike Stump11289f42009-09-09 15:08:12 +00002729
Sebastian Redl539c5062010-08-18 23:57:32 +00002730 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002731 S = new (Context) IndirectGotoStmt(Empty);
2732 break;
2733
Sebastian Redl539c5062010-08-18 23:57:32 +00002734 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002735 S = new (Context) ContinueStmt(Empty);
2736 break;
2737
Sebastian Redl539c5062010-08-18 23:57:32 +00002738 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002739 S = new (Context) BreakStmt(Empty);
2740 break;
2741
Sebastian Redl539c5062010-08-18 23:57:32 +00002742 case STMT_RETURN:
Bruno Ricci023b1d12018-10-30 14:40:49 +00002743 S = ReturnStmt::CreateEmpty(
2744 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002745 break;
2746
Sebastian Redl539c5062010-08-18 23:57:32 +00002747 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002748 S = new (Context) DeclStmt(Empty);
2749 break;
2750
Chad Rosierde70e0e2012-08-25 00:11:56 +00002751 case STMT_GCCASM:
2752 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002753 break;
2754
Chad Rosiere30d4992012-08-24 23:51:02 +00002755 case STMT_MSASM:
2756 S = new (Context) MSAsmStmt(Empty);
2757 break;
2758
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002759 case STMT_CAPTURED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002760 S = CapturedStmt::CreateDeserialized(
2761 Context, Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002762 break;
2763
Bill Wendling7c44da22018-10-31 03:48:47 +00002764 case EXPR_CONSTANT:
Gauthier Harnisch83c7b612019-06-15 10:24:47 +00002765 S = ConstantExpr::CreateEmpty(
2766 Context,
2767 static_cast<ConstantExpr::ResultStorageKind>(
2768 Record[ASTStmtReader::NumExprFields]),
2769 Empty);
Bill Wendling7c44da22018-10-31 03:48:47 +00002770 break;
2771
Sebastian Redl539c5062010-08-18 23:57:32 +00002772 case EXPR_PREDEFINED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002773 S = PredefinedExpr::CreateEmpty(
2774 Context,
2775 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002776 break;
Mike Stump11289f42009-09-09 15:08:12 +00002777
Sebastian Redl539c5062010-08-18 23:57:32 +00002778 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002779 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00002780 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002781 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2782 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnara7945c982012-01-27 09:46:47 +00002783 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002784 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Richard Smith715f7a12019-06-11 17:50:32 +00002785 Record[ASTStmtReader::NumExprFields + 6] : 0);
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_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002789 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002790 break;
Mike Stump11289f42009-09-09 15:08:12 +00002791
Sebastian Redl539c5062010-08-18 23:57:32 +00002792 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002793 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002794 break;
Mike Stump11289f42009-09-09 15:08:12 +00002795
Sebastian Redl539c5062010-08-18 23:57:32 +00002796 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002797 S = new (Context) ImaginaryLiteral(Empty);
2798 break;
2799
Sebastian Redl539c5062010-08-18 23:57:32 +00002800 case EXPR_STRING_LITERAL:
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002801 S = StringLiteral::CreateEmpty(
2802 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002803 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002804 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2805 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002806 break;
2807
Sebastian Redl539c5062010-08-18 23:57:32 +00002808 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002809 S = new (Context) CharacterLiteral(Empty);
2810 break;
2811
Sebastian Redl539c5062010-08-18 23:57:32 +00002812 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002813 S = new (Context) ParenExpr(Empty);
2814 break;
2815
Sebastian Redl539c5062010-08-18 23:57:32 +00002816 case EXPR_PAREN_LIST:
Bruno Riccif49e1ca2018-11-20 16:20:40 +00002817 S = ParenListExpr::CreateEmpty(
2818 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002819 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00002820 break;
2821
Sebastian Redl539c5062010-08-18 23:57:32 +00002822 case EXPR_UNARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002823 S = new (Context) UnaryOperator(Empty);
2824 break;
2825
Sebastian Redl539c5062010-08-18 23:57:32 +00002826 case EXPR_OFFSETOF:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002827 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002828 Record[ASTStmtReader::NumExprFields],
2829 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00002830 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002831
Sebastian Redl539c5062010-08-18 23:57:32 +00002832 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00002833 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002834 break;
2835
Sebastian Redl539c5062010-08-18 23:57:32 +00002836 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002837 S = new (Context) ArraySubscriptExpr(Empty);
2838 break;
2839
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002840 case EXPR_OMP_ARRAY_SECTION:
2841 S = new (Context) OMPArraySectionExpr(Empty);
2842 break;
2843
Sebastian Redl539c5062010-08-18 23:57:32 +00002844 case EXPR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00002845 S = CallExpr::CreateEmpty(
2846 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002847 break;
2848
Richard Smithdcf17de2019-06-06 23:24:15 +00002849 case EXPR_MEMBER:
2850 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
2851 Record[ASTStmtReader::NumExprFields + 1],
2852 Record[ASTStmtReader::NumExprFields + 2],
2853 Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002854 break;
2855
Sebastian Redl539c5062010-08-18 23:57:32 +00002856 case EXPR_BINARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002857 S = new (Context) BinaryOperator(Empty);
2858 break;
2859
Sebastian Redl539c5062010-08-18 23:57:32 +00002860 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002861 S = new (Context) CompoundAssignOperator(Empty);
2862 break;
2863
Sebastian Redl539c5062010-08-18 23:57:32 +00002864 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002865 S = new (Context) ConditionalOperator(Empty);
2866 break;
2867
John McCallc07a0c72011-02-17 10:25:35 +00002868 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2869 S = new (Context) BinaryConditionalOperator(Empty);
2870 break;
2871
Sebastian Redl539c5062010-08-18 23:57:32 +00002872 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002873 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002874 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002875 break;
2876
Sebastian Redl539c5062010-08-18 23:57:32 +00002877 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002878 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002879 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002880 break;
2881
Sebastian Redl539c5062010-08-18 23:57:32 +00002882 case EXPR_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002883 S = new (Context) CompoundLiteralExpr(Empty);
2884 break;
2885
Sebastian Redl539c5062010-08-18 23:57:32 +00002886 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002887 S = new (Context) ExtVectorElementExpr(Empty);
2888 break;
2889
Sebastian Redl539c5062010-08-18 23:57:32 +00002890 case EXPR_INIT_LIST:
Argyrios Kyrtzidis0f05fb92012-11-28 03:56:16 +00002891 S = new (Context) InitListExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002892 break;
2893
Sebastian Redl539c5062010-08-18 23:57:32 +00002894 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002895 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002896 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00002897
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002898 break;
2899
Yunzhong Gaocb779302015-06-10 00:27:52 +00002900 case EXPR_DESIGNATED_INIT_UPDATE:
2901 S = new (Context) DesignatedInitUpdateExpr(Empty);
2902 break;
2903
Sebastian Redl539c5062010-08-18 23:57:32 +00002904 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002905 S = new (Context) ImplicitValueInitExpr(Empty);
2906 break;
2907
Yunzhong Gaocb779302015-06-10 00:27:52 +00002908 case EXPR_NO_INIT:
2909 S = new (Context) NoInitExpr(Empty);
2910 break;
2911
Richard Smith410306b2016-12-12 02:53:20 +00002912 case EXPR_ARRAY_INIT_LOOP:
2913 S = new (Context) ArrayInitLoopExpr(Empty);
2914 break;
2915
2916 case EXPR_ARRAY_INIT_INDEX:
2917 S = new (Context) ArrayInitIndexExpr(Empty);
2918 break;
2919
Sebastian Redl539c5062010-08-18 23:57:32 +00002920 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002921 S = new (Context) VAArgExpr(Empty);
2922 break;
2923
Eric Fiselier708afb52019-05-16 21:04:15 +00002924 case EXPR_SOURCE_LOC:
2925 S = new (Context) SourceLocExpr(Empty);
2926 break;
2927
Sebastian Redl539c5062010-08-18 23:57:32 +00002928 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002929 S = new (Context) AddrLabelExpr(Empty);
2930 break;
2931
Sebastian Redl539c5062010-08-18 23:57:32 +00002932 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002933 S = new (Context) StmtExpr(Empty);
2934 break;
2935
Sebastian Redl539c5062010-08-18 23:57:32 +00002936 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002937 S = new (Context) ChooseExpr(Empty);
2938 break;
2939
Sebastian Redl539c5062010-08-18 23:57:32 +00002940 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002941 S = new (Context) GNUNullExpr(Empty);
2942 break;
2943
Sebastian Redl539c5062010-08-18 23:57:32 +00002944 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002945 S = new (Context) ShuffleVectorExpr(Empty);
2946 break;
Mike Stump11289f42009-09-09 15:08:12 +00002947
Hal Finkelc4d7c822013-09-18 03:29:45 +00002948 case EXPR_CONVERT_VECTOR:
2949 S = new (Context) ConvertVectorExpr(Empty);
2950 break;
2951
Sebastian Redl539c5062010-08-18 23:57:32 +00002952 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002953 S = new (Context) BlockExpr(Empty);
2954 break;
2955
Peter Collingbourne91147592011-04-15 00:35:48 +00002956 case EXPR_GENERIC_SELECTION:
Bruno Riccidb076832019-01-26 14:15:10 +00002957 S = GenericSelectionExpr::CreateEmpty(
2958 Context,
2959 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
Peter Collingbourne91147592011-04-15 00:35:48 +00002960 break;
2961
Sebastian Redl539c5062010-08-18 23:57:32 +00002962 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002963 S = new (Context) ObjCStringLiteral(Empty);
2964 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002965
Patrick Beard0caa3942012-04-19 00:25:12 +00002966 case EXPR_OBJC_BOXED_EXPRESSION:
2967 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremeneke65b0862012-03-06 20:05:56 +00002968 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002969
Ted Kremeneke65b0862012-03-06 20:05:56 +00002970 case EXPR_OBJC_ARRAY_LITERAL:
2971 S = ObjCArrayLiteral::CreateEmpty(Context,
2972 Record[ASTStmtReader::NumExprFields]);
2973 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002974
Ted Kremeneke65b0862012-03-06 20:05:56 +00002975 case EXPR_OBJC_DICTIONARY_LITERAL:
2976 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2977 Record[ASTStmtReader::NumExprFields],
2978 Record[ASTStmtReader::NumExprFields + 1]);
2979 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002980
Sebastian Redl539c5062010-08-18 23:57:32 +00002981 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002982 S = new (Context) ObjCEncodeExpr(Empty);
2983 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002984
Sebastian Redl539c5062010-08-18 23:57:32 +00002985 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002986 S = new (Context) ObjCSelectorExpr(Empty);
2987 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002988
Sebastian Redl539c5062010-08-18 23:57:32 +00002989 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002990 S = new (Context) ObjCProtocolExpr(Empty);
2991 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002992
Sebastian Redl539c5062010-08-18 23:57:32 +00002993 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002994 S = new (Context) ObjCIvarRefExpr(Empty);
2995 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002996
Sebastian Redl539c5062010-08-18 23:57:32 +00002997 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002998 S = new (Context) ObjCPropertyRefExpr(Empty);
2999 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003000
Ted Kremeneke65b0862012-03-06 20:05:56 +00003001 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
3002 S = new (Context) ObjCSubscriptRefExpr(Empty);
3003 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003004
Sebastian Redl539c5062010-08-18 23:57:32 +00003005 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00003006 llvm_unreachable("mismatching AST file");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003007
Sebastian Redl539c5062010-08-18 23:57:32 +00003008 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003009 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00003010 Record[ASTStmtReader::NumExprFields],
3011 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003012 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003013
Sebastian Redl539c5062010-08-18 23:57:32 +00003014 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00003015 S = new (Context) ObjCIsaExpr(Empty);
3016 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003017
John McCall31168b02011-06-15 23:02:42 +00003018 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
3019 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
3020 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003021
John McCall31168b02011-06-15 23:02:42 +00003022 case EXPR_OBJC_BRIDGED_CAST:
3023 S = new (Context) ObjCBridgedCastExpr(Empty);
3024 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003025
Sebastian Redl539c5062010-08-18 23:57:32 +00003026 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003027 S = new (Context) ObjCForCollectionStmt(Empty);
3028 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003029
Sebastian Redl539c5062010-08-18 23:57:32 +00003030 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003031 S = new (Context) ObjCAtCatchStmt(Empty);
3032 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003033
Sebastian Redl539c5062010-08-18 23:57:32 +00003034 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003035 S = new (Context) ObjCAtFinallyStmt(Empty);
3036 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003037
Sebastian Redl539c5062010-08-18 23:57:32 +00003038 case STMT_OBJC_AT_TRY:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003039 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003040 Record[ASTStmtReader::NumStmtFields],
3041 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003042 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003043
Sebastian Redl539c5062010-08-18 23:57:32 +00003044 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003045 S = new (Context) ObjCAtSynchronizedStmt(Empty);
3046 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003047
Sebastian Redl539c5062010-08-18 23:57:32 +00003048 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003049 S = new (Context) ObjCAtThrowStmt(Empty);
3050 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003051
John McCall31168b02011-06-15 23:02:42 +00003052 case STMT_OBJC_AUTORELEASE_POOL:
3053 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3054 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003055
Ted Kremeneke65b0862012-03-06 20:05:56 +00003056 case EXPR_OBJC_BOOL_LITERAL:
3057 S = new (Context) ObjCBoolLiteralExpr(Empty);
3058 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003059
Erik Pilkington29099de2016-07-16 00:35:23 +00003060 case EXPR_OBJC_AVAILABILITY_CHECK:
3061 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3062 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003063
Nico Weber9b982072014-07-07 00:12:30 +00003064 case STMT_SEH_LEAVE:
3065 S = new (Context) SEHLeaveStmt(Empty);
3066 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003067
John McCallfa194042011-07-15 07:00:14 +00003068 case STMT_SEH_EXCEPT:
3069 S = new (Context) SEHExceptStmt(Empty);
3070 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003071
John McCallfa194042011-07-15 07:00:14 +00003072 case STMT_SEH_FINALLY:
3073 S = new (Context) SEHFinallyStmt(Empty);
3074 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003075
John McCallfa194042011-07-15 07:00:14 +00003076 case STMT_SEH_TRY:
3077 S = new (Context) SEHTryStmt(Empty);
3078 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003079
Sebastian Redl539c5062010-08-18 23:57:32 +00003080 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003081 S = new (Context) CXXCatchStmt(Empty);
3082 break;
3083
Sebastian Redl539c5062010-08-18 23:57:32 +00003084 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003085 S = CXXTryStmt::Create(Context, Empty,
Rui Ueyama49a3ad22019-07-16 04:46:31 +00003086 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003087 break;
3088
Richard Smith02e85f32011-04-14 22:09:26 +00003089 case STMT_CXX_FOR_RANGE:
3090 S = new (Context) CXXForRangeStmt(Empty);
3091 break;
3092
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003093 case STMT_MS_DEPENDENT_EXISTS:
3094 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3095 NestedNameSpecifierLoc(),
3096 DeclarationNameInfo(),
Craig Toppera13603a2014-05-22 05:54:18 +00003097 nullptr);
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003098 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003099
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00003100 case STMT_OMP_PARALLEL_DIRECTIVE:
3101 S =
3102 OMPParallelDirective::CreateEmpty(Context,
3103 Record[ASTStmtReader::NumStmtFields],
3104 Empty);
3105 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003106
3107 case STMT_OMP_SIMD_DIRECTIVE: {
3108 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3109 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3110 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3111 CollapsedNum, Empty);
3112 break;
3113 }
3114
Alexey Bataevf29276e2014-06-18 04:14:57 +00003115 case STMT_OMP_FOR_DIRECTIVE: {
3116 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3117 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3118 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3119 Empty);
3120 break;
3121 }
3122
Alexander Musmanf82886e2014-09-18 05:12:34 +00003123 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3124 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3125 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3126 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3127 Empty);
3128 break;
3129 }
3130
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00003131 case STMT_OMP_SECTIONS_DIRECTIVE:
3132 S = OMPSectionsDirective::CreateEmpty(
3133 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3134 break;
3135
Alexey Bataev1e0498a2014-06-26 08:21:58 +00003136 case STMT_OMP_SECTION_DIRECTIVE:
3137 S = OMPSectionDirective::CreateEmpty(Context, Empty);
3138 break;
3139
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00003140 case STMT_OMP_SINGLE_DIRECTIVE:
3141 S = OMPSingleDirective::CreateEmpty(
3142 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3143 break;
3144
Alexander Musman80c22892014-07-17 08:54:58 +00003145 case STMT_OMP_MASTER_DIRECTIVE:
3146 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3147 break;
3148
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003149 case STMT_OMP_CRITICAL_DIRECTIVE:
Alexey Bataev28c75412015-12-15 08:19:24 +00003150 S = OMPCriticalDirective::CreateEmpty(
3151 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003152 break;
3153
Alexey Bataev4acb8592014-07-07 13:01:15 +00003154 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3155 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3156 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3157 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3158 CollapsedNum, Empty);
3159 break;
3160 }
3161
Alexander Musmane4e893b2014-09-23 09:33:00 +00003162 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3163 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3164 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3165 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3166 CollapsedNum, Empty);
3167 break;
3168 }
3169
cchen47d60942019-12-05 13:43:48 -05003170 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3171 S = OMPParallelMasterDirective::CreateEmpty(
3172 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3173 break;
3174
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00003175 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3176 S = OMPParallelSectionsDirective::CreateEmpty(
3177 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3178 break;
3179
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00003180 case STMT_OMP_TASK_DIRECTIVE:
3181 S = OMPTaskDirective::CreateEmpty(
3182 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3183 break;
3184
Alexey Bataev68446b72014-07-18 07:47:19 +00003185 case STMT_OMP_TASKYIELD_DIRECTIVE:
3186 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3187 break;
3188
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00003189 case STMT_OMP_BARRIER_DIRECTIVE:
3190 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3191 break;
3192
Alexey Bataev2df347a2014-07-18 10:17:07 +00003193 case STMT_OMP_TASKWAIT_DIRECTIVE:
3194 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3195 break;
3196
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003197 case STMT_OMP_TASKGROUP_DIRECTIVE:
Alexey Bataev169d96a2017-07-18 20:17:46 +00003198 S = OMPTaskgroupDirective::CreateEmpty(
3199 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003200 break;
3201
Alexey Bataev6125da92014-07-21 11:26:11 +00003202 case STMT_OMP_FLUSH_DIRECTIVE:
3203 S = OMPFlushDirective::CreateEmpty(
3204 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3205 break;
3206
Alexey Bataevc112e942020-02-28 09:52:15 -05003207 case STMT_OMP_DEPOBJ_DIRECTIVE:
3208 S = OMPDepobjDirective::CreateEmpty(
3209 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3210 break;
3211
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003212 case STMT_OMP_ORDERED_DIRECTIVE:
Alexey Bataev346265e2015-09-25 10:37:12 +00003213 S = OMPOrderedDirective::CreateEmpty(
3214 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003215 break;
3216
Alexey Bataev0162e452014-07-22 10:10:35 +00003217 case STMT_OMP_ATOMIC_DIRECTIVE:
3218 S = OMPAtomicDirective::CreateEmpty(
3219 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3220 break;
3221
Alexey Bataev0bd520b2014-09-19 08:19:49 +00003222 case STMT_OMP_TARGET_DIRECTIVE:
3223 S = OMPTargetDirective::CreateEmpty(
3224 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3225 break;
3226
Michael Wong65f367f2015-07-21 13:44:28 +00003227 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3228 S = OMPTargetDataDirective::CreateEmpty(
3229 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3230 break;
3231
Samuel Antaodf67fc42016-01-19 19:15:56 +00003232 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3233 S = OMPTargetEnterDataDirective::CreateEmpty(
3234 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3235 break;
3236
Samuel Antao72590762016-01-19 20:04:50 +00003237 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3238 S = OMPTargetExitDataDirective::CreateEmpty(
3239 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3240 break;
3241
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00003242 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3243 S = OMPTargetParallelDirective::CreateEmpty(
3244 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3245 break;
3246
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00003247 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3248 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3249 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3250 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3251 CollapsedNum, Empty);
3252 break;
3253 }
3254
Samuel Antao686c70c2016-05-26 17:30:50 +00003255 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3256 S = OMPTargetUpdateDirective::CreateEmpty(
3257 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3258 break;
3259
Alexey Bataev13314bf2014-10-09 04:18:56 +00003260 case STMT_OMP_TEAMS_DIRECTIVE:
3261 S = OMPTeamsDirective::CreateEmpty(
3262 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3263 break;
3264
Alexey Bataev6d4ed052015-07-01 06:57:41 +00003265 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3266 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3267 break;
3268
Alexey Bataev80909872015-07-02 11:25:17 +00003269 case STMT_OMP_CANCEL_DIRECTIVE:
Alexey Bataev87933c72015-09-18 08:07:34 +00003270 S = OMPCancelDirective::CreateEmpty(
3271 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev80909872015-07-02 11:25:17 +00003272 break;
3273
Alexey Bataev49f6e782015-12-01 04:18:41 +00003274 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3275 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3276 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3277 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3278 Empty);
3279 break;
3280 }
3281
Alexey Bataev0a6ed842015-12-03 09:40:15 +00003282 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3283 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3284 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3285 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3286 CollapsedNum, Empty);
3287 break;
3288 }
3289
Alexey Bataev60e51c42019-10-10 20:13:02 +00003290 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3291 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3292 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3293 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3294 CollapsedNum, Empty);
3295 break;
3296 }
3297
Alexey Bataevb8552ab2019-10-18 16:47:35 +00003298 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3299 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3300 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3301 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3302 CollapsedNum, Empty);
3303 break;
3304 }
3305
Alexey Bataev5bbcead2019-10-14 17:17:41 +00003306 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3307 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3308 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3309 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3310 CollapsedNum, Empty);
3311 break;
3312 }
3313
Alexey Bataev14a388f2019-10-25 10:27:13 -04003314 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3315 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3316 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3317 S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3318 Context, NumClauses, CollapsedNum, Empty);
3319 break;
3320 }
3321
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00003322 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3323 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3324 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3325 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3326 Empty);
3327 break;
3328 }
3329
Carlo Bertolli9925f152016-06-27 14:55:37 +00003330 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3331 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3332 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3333 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3334 CollapsedNum, Empty);
3335 break;
3336 }
3337
Kelvin Li4a39add2016-07-05 05:00:15 +00003338 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3339 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3340 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3341 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3342 CollapsedNum,
3343 Empty);
3344 break;
3345 }
3346
Kelvin Li787f3fc2016-07-06 04:45:38 +00003347 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3348 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3349 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3350 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3351 CollapsedNum, Empty);
3352 break;
3353 }
3354
Kelvin Lia579b912016-07-14 02:54:56 +00003355 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3356 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3357 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3358 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3359 CollapsedNum, Empty);
3360 break;
3361 }
3362
Kelvin Li986330c2016-07-20 22:57:10 +00003363 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3364 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3365 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3366 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3367 Empty);
3368 break;
3369 }
3370
Kelvin Li83c451e2016-12-25 04:52:54 +00003371 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
Kelvin Li02532872016-08-05 14:37:37 +00003372 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3373 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3374 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3375 CollapsedNum, Empty);
3376 break;
3377 }
3378
Kelvin Li4e325f72016-10-25 12:50:55 +00003379 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3380 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3381 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3382 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3383 CollapsedNum, Empty);
3384 break;
3385 }
3386
Kelvin Li579e41c2016-11-30 23:51:03 +00003387 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3388 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3389 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3390 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3391 Context, NumClauses, CollapsedNum, Empty);
3392 break;
3393 }
3394
Kelvin Li7ade93f2016-12-09 03:24:30 +00003395 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3396 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3397 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3398 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3399 Context, NumClauses, CollapsedNum, Empty);
3400 break;
3401 }
3402
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003403 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
Kelvin Libf594a52016-12-17 05:48:59 +00003404 S = OMPTargetTeamsDirective::CreateEmpty(
3405 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3406 break;
Kelvin Li83c451e2016-12-25 04:52:54 +00003407
3408 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3409 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3410 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3411 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3412 CollapsedNum, Empty);
3413 break;
3414 }
3415
Kelvin Li80e8f562016-12-29 22:16:30 +00003416 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3417 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3418 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3419 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3420 Context, NumClauses, CollapsedNum, Empty);
3421 break;
3422 }
3423
Kelvin Li1851df52017-01-03 05:23:48 +00003424 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3425 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3426 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3427 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3428 Context, NumClauses, CollapsedNum, Empty);
3429 break;
3430 }
3431
Kelvin Lida681182017-01-10 18:08:18 +00003432 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3433 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3434 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3435 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3436 Context, NumClauses, CollapsedNum, Empty);
3437 break;
3438 }
3439
Sebastian Redl539c5062010-08-18 23:57:32 +00003440 case EXPR_CXX_OPERATOR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003441 S = CXXOperatorCallExpr::CreateEmpty(
3442 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00003443 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003444
Sebastian Redl539c5062010-08-18 23:57:32 +00003445 case EXPR_CXX_MEMBER_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003446 S = CXXMemberCallExpr::CreateEmpty(
3447 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003448 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003449
Richard Smith778dc0f2019-10-19 00:04:38 +00003450 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3451 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3452 break;
3453
Sebastian Redl539c5062010-08-18 23:57:32 +00003454 case EXPR_CXX_CONSTRUCT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003455 S = CXXConstructExpr::CreateEmpty(
3456 Context,
3457 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003458 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003459
Richard Smith5179eb72016-06-28 19:03:57 +00003460 case EXPR_CXX_INHERITED_CTOR_INIT:
3461 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3462 break;
3463
Sebastian Redl539c5062010-08-18 23:57:32 +00003464 case EXPR_CXX_TEMPORARY_OBJECT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003465 S = CXXTemporaryObjectExpr::CreateEmpty(
3466 Context,
3467 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00003468 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003469
Sebastian Redl539c5062010-08-18 23:57:32 +00003470 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003471 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003472 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003473 break;
3474
Sebastian Redl539c5062010-08-18 23:57:32 +00003475 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003476 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003477 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003478 break;
3479
Sebastian Redl539c5062010-08-18 23:57:32 +00003480 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003481 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003482 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003483 break;
3484
Sebastian Redl539c5062010-08-18 23:57:32 +00003485 case EXPR_CXX_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003486 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00003487 break;
3488
Sebastian Redl539c5062010-08-18 23:57:32 +00003489 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003490 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003491 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003492 break;
3493
Richard Smithc67fdd42012-03-07 08:35:16 +00003494 case EXPR_USER_DEFINED_LITERAL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003495 S = UserDefinedLiteral::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003496 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Richard Smithc67fdd42012-03-07 08:35:16 +00003497 break;
3498
Richard Smithcc1b96d2013-06-12 22:31:48 +00003499 case EXPR_CXX_STD_INITIALIZER_LIST:
3500 S = new (Context) CXXStdInitializerListExpr(Empty);
3501 break;
3502
Sebastian Redl539c5062010-08-18 23:57:32 +00003503 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003504 S = new (Context) CXXBoolLiteralExpr(Empty);
3505 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003506
Sebastian Redl539c5062010-08-18 23:57:32 +00003507 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003508 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3509 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003510
Sebastian Redl539c5062010-08-18 23:57:32 +00003511 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003512 S = new (Context) CXXTypeidExpr(Empty, true);
3513 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003514
Sebastian Redl539c5062010-08-18 23:57:32 +00003515 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003516 S = new (Context) CXXTypeidExpr(Empty, false);
3517 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003518
Francois Pichet9f4f2072010-09-08 12:20:18 +00003519 case EXPR_CXX_UUIDOF_EXPR:
3520 S = new (Context) CXXUuidofExpr(Empty, true);
3521 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003522
John McCall5e77d762013-04-16 07:28:30 +00003523 case EXPR_CXX_PROPERTY_REF_EXPR:
3524 S = new (Context) MSPropertyRefExpr(Empty);
3525 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003526
Alexey Bataevf7630272015-11-25 12:01:00 +00003527 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3528 S = new (Context) MSPropertySubscriptExpr(Empty);
3529 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003530
Francois Pichet9f4f2072010-09-08 12:20:18 +00003531 case EXPR_CXX_UUIDOF_TYPE:
3532 S = new (Context) CXXUuidofExpr(Empty, false);
3533 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003534
Sebastian Redl539c5062010-08-18 23:57:32 +00003535 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00003536 S = new (Context) CXXThisExpr(Empty);
3537 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003538
Sebastian Redl539c5062010-08-18 23:57:32 +00003539 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00003540 S = new (Context) CXXThrowExpr(Empty);
3541 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003542
John McCall32791cc2016-01-06 22:34:54 +00003543 case EXPR_CXX_DEFAULT_ARG:
3544 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00003545 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003546
Richard Smith852c9db2013-04-20 22:23:05 +00003547 case EXPR_CXX_DEFAULT_INIT:
3548 S = new (Context) CXXDefaultInitExpr(Empty);
3549 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003550
Sebastian Redl539c5062010-08-18 23:57:32 +00003551 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00003552 S = new (Context) CXXBindTemporaryExpr(Empty);
3553 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003554
Sebastian Redl539c5062010-08-18 23:57:32 +00003555 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00003556 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003557 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003558
Sebastian Redl539c5062010-08-18 23:57:32 +00003559 case EXPR_CXX_NEW:
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00003560 S = CXXNewExpr::CreateEmpty(
3561 Context,
3562 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3563 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3564 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3565 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003566 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003567
Sebastian Redl539c5062010-08-18 23:57:32 +00003568 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00003569 S = new (Context) CXXDeleteExpr(Empty);
3570 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003571
Sebastian Redl539c5062010-08-18 23:57:32 +00003572 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00003573 S = new (Context) CXXPseudoDestructorExpr(Empty);
3574 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003575
John McCall5d413782010-12-06 08:20:24 +00003576 case EXPR_EXPR_WITH_CLEANUPS:
John McCall28fc7092011-11-10 05:35:25 +00003577 S = ExprWithCleanups::Create(Context, Empty,
3578 Record[ASTStmtReader::NumExprFields]);
Chris Lattnercba86142010-05-10 00:25:06 +00003579 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003580
Sebastian Redl539c5062010-08-18 23:57:32 +00003581 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Bruno Ricci2e6dc532019-01-08 14:17:00 +00003582 S = CXXDependentScopeMemberExpr::CreateEmpty(
3583 Context,
3584 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3585 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3586 /*HasFirstQualifierFoundInScope=*/
3587 Record[ASTStmtReader::NumExprFields + 2]);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003588 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003589
Sebastian Redl539c5062010-08-18 23:57:32 +00003590 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003591 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003592 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003593 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003594 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003595 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00003596 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003597
Sebastian Redl539c5062010-08-18 23:57:32 +00003598 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003599 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003600 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00003601 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003602
Sebastian Redl539c5062010-08-18 23:57:32 +00003603 case EXPR_CXX_UNRESOLVED_MEMBER:
Bruno Riccid7628d92019-01-09 15:43:19 +00003604 S = UnresolvedMemberExpr::CreateEmpty(
3605 Context,
3606 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3607 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3608 /*NumTemplateArgs=*/
3609 Record[ASTStmtReader::NumExprFields + 1]
3610 ? Record[ASTStmtReader::NumExprFields + 2]
3611 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003612 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003613
Sebastian Redl539c5062010-08-18 23:57:32 +00003614 case EXPR_CXX_UNRESOLVED_LOOKUP:
Bruno Riccid7628d92019-01-09 15:43:19 +00003615 S = UnresolvedLookupExpr::CreateEmpty(
3616 Context,
3617 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3618 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3619 /*NumTemplateArgs=*/
3620 Record[ASTStmtReader::NumExprFields + 1]
3621 ? Record[ASTStmtReader::NumExprFields + 2]
3622 : 0);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00003623 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003624
Douglas Gregor29c42f22012-02-24 07:38:34 +00003625 case EXPR_TYPE_TRAIT:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003626 S = TypeTraitExpr::CreateDeserialized(Context,
Douglas Gregor29c42f22012-02-24 07:38:34 +00003627 Record[ASTStmtReader::NumExprFields]);
3628 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003629
John Wiegley6242b6a2011-04-28 00:16:57 +00003630 case EXPR_ARRAY_TYPE_TRAIT:
3631 S = new (Context) ArrayTypeTraitExpr(Empty);
3632 break;
3633
John Wiegleyf9f65842011-04-25 06:54:41 +00003634 case EXPR_CXX_EXPRESSION_TRAIT:
3635 S = new (Context) ExpressionTraitExpr(Empty);
3636 break;
3637
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003638 case EXPR_CXX_NOEXCEPT:
3639 S = new (Context) CXXNoexceptExpr(Empty);
3640 break;
John McCall8d69a212010-11-15 23:31:06 +00003641
Douglas Gregore8e9dd62011-01-03 17:17:50 +00003642 case EXPR_PACK_EXPANSION:
3643 S = new (Context) PackExpansionExpr(Empty);
3644 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003645
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003646 case EXPR_SIZEOF_PACK:
Richard Smithd784e682015-09-23 21:41:42 +00003647 S = SizeOfPackExpr::CreateDeserialized(
3648 Context,
3649 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003650 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003651
John McCallfa194042011-07-15 07:00:14 +00003652 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3653 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3654 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003655
Douglas Gregorcdbc5392011-01-15 01:15:58 +00003656 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3657 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3658 break;
Richard Smithb15fe3a2012-09-12 00:56:43 +00003659
3660 case EXPR_FUNCTION_PARM_PACK:
3661 S = FunctionParmPackExpr::CreateEmpty(Context,
3662 Record[ASTStmtReader::NumExprFields]);
3663 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003664
Douglas Gregorfe314812011-06-21 17:03:29 +00003665 case EXPR_MATERIALIZE_TEMPORARY:
3666 S = new (Context) MaterializeTemporaryExpr(Empty);
3667 break;
Richard Smith0f0af192014-11-08 05:07:16 +00003668
3669 case EXPR_CXX_FOLD:
3670 S = new (Context) CXXFoldExpr(Empty);
3671 break;
3672
Argyrios Kyrtzidisb2b07952011-12-03 03:49:52 +00003673 case EXPR_OPAQUE_VALUE:
3674 S = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00003675 break;
Peter Collingbourne41f85462011-02-09 21:07:24 +00003676
3677 case EXPR_CUDA_KERNEL_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003678 S = CUDAKernelCallExpr::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003679 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00003680 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003681
Tanya Lattner55808c12011-06-04 00:47:47 +00003682 case EXPR_ASTYPE:
3683 S = new (Context) AsTypeExpr(Empty);
3684 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003685
John McCallfe96e0b2011-11-06 09:01:30 +00003686 case EXPR_PSEUDO_OBJECT: {
3687 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3688 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3689 break;
3690 }
3691
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003692 case EXPR_ATOMIC:
3693 S = new (Context) AtomicExpr(Empty);
3694 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003695
Douglas Gregor99ae8062012-02-14 17:54:36 +00003696 case EXPR_LAMBDA: {
3697 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
Richard Smith30e304e2016-12-14 00:03:17 +00003698 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
Douglas Gregor99ae8062012-02-14 17:54:36 +00003699 break;
3700 }
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +00003701
3702 case STMT_COROUTINE_BODY: {
3703 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3704 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3705 break;
3706 }
3707
3708 case STMT_CORETURN:
3709 S = new (Context) CoreturnStmt(Empty);
3710 break;
3711
3712 case EXPR_COAWAIT:
3713 S = new (Context) CoawaitExpr(Empty);
3714 break;
3715
3716 case EXPR_COYIELD:
3717 S = new (Context) CoyieldExpr(Empty);
3718 break;
3719
3720 case EXPR_DEPENDENT_COAWAIT:
3721 S = new (Context) DependentCoawaitExpr(Empty);
3722 break;
Saar Raz5d98ba62019-10-15 15:24:26 +00003723
Saar Raza0f50d72020-01-18 09:11:43 +02003724 case EXPR_CONCEPT_SPECIALIZATION: {
Saar Raz5d98ba62019-10-15 15:24:26 +00003725 unsigned numTemplateArgs = Record[ASTStmtReader::NumExprFields];
3726 S = ConceptSpecializationExpr::Create(Context, Empty, numTemplateArgs);
3727 break;
Saar Raza0f50d72020-01-18 09:11:43 +02003728 }
3729
3730 case EXPR_REQUIRES:
3731 unsigned numLocalParameters = Record[ASTStmtReader::NumExprFields];
3732 unsigned numRequirement = Record[ASTStmtReader::NumExprFields + 1];
3733 S = RequiresExpr::Create(Context, Empty, numLocalParameters,
3734 numRequirement);
3735 break;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003736 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003737
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003738 // We hit a STMT_STOP, so we're done with this expression.
3739 if (Finished)
3740 break;
3741
3742 ++NumStatementsRead;
3743
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003744 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003745 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003746 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3747 }
3748
David L. Jonesbe1557a2016-12-21 00:17:49 +00003749 assert(Record.getIdx() == Record.size() &&
3750 "Invalid deserialization of statement");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003751 StmtStack.push_back(S);
3752 }
Chris Lattner0e6c9402013-01-20 02:38:54 +00003753Done:
Alp Toker028ed912013-12-06 17:56:43 +00003754 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003755 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003756 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003757}