blob: ef370260c540ac26cc4473f57406c5e9d80c46b3 [file] [log] [blame]
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001//===- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------------------===//
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Statement/expression deserialization. This implements the
Sebastian Redl2c499f62010-08-18 23:56:43 +000011// ASTReader::ReadStmt method.
Chris Lattner92ba5ff2009-04-27 05:14:47 +000012//
13//===----------------------------------------------------------------------===//
14
Sebastian Redlf5b13462010-08-18 23:57:17 +000015#include "clang/Serialization/ASTReader.h"
Benjamin Kramer4ab984e2012-07-04 20:19:54 +000016#include "clang/AST/ASTContext.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000017#include "clang/AST/AttrIterator.h"
18#include "clang/AST/Decl.h"
19#include "clang/AST/DeclAccessPair.h"
Douglas Gregor5d3507d2009-09-09 23:08:42 +000020#include "clang/AST/DeclCXX.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000021#include "clang/AST/DeclGroup.h"
22#include "clang/AST/DeclObjC.h"
Douglas Gregorcdbc5392011-01-15 01:15:58 +000023#include "clang/AST/DeclTemplate.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000024#include "clang/AST/DeclarationName.h"
25#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"
52#include "llvm/ADT/DenseMap.h"
Benjamin Kramer49038022012-02-04 13:45:25 +000053#include "llvm/ADT/SmallString.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000054#include "llvm/ADT/SmallVector.h"
55#include "llvm/ADT/StringRef.h"
56#include "llvm/Bitcode/BitstreamReader.h"
57#include "llvm/Support/Casting.h"
58#include "llvm/Support/ErrorHandling.h"
59#include <algorithm>
60#include <cassert>
61#include <cstdint>
62#include <string>
63
Chris Lattner92ba5ff2009-04-27 05:14:47 +000064using namespace clang;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000065using namespace serialization;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000066
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +000067namespace clang {
Argyrios Kyrtzidisddf5f212010-06-28 09:31:42 +000068
Sebastian Redl70c751d2010-08-18 23:56:52 +000069 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
Alexey Bataev5ec3eb12013-07-19 03:13:43 +000070 friend class OMPClauseReader;
David L. Jonesc4808b9e2016-12-15 20:53:26 +000071
David L. Jonesbe1557a2016-12-21 00:17:49 +000072 ASTRecordReader &Record;
Sebastian Redlc67764e2010-07-22 22:43:28 +000073 llvm::BitstreamCursor &DeclsCursor;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000074
David L. Jonesc4808b9e2016-12-15 20:53:26 +000075 SourceLocation ReadSourceLocation() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000076 return Record.readSourceLocation();
John McCallf413f5e2013-05-03 00:10:13 +000077 }
78
David L. Jonesc4808b9e2016-12-15 20:53:26 +000079 SourceRange ReadSourceRange() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000080 return Record.readSourceRange();
Sebastian Redl2c373b92010-10-05 15:59:54 +000081 }
John McCallf413f5e2013-05-03 00:10:13 +000082
David L. Jonesc4808b9e2016-12-15 20:53:26 +000083 std::string ReadString() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000084 return Record.readString();
Sebastian Redl2c373b92010-10-05 15:59:54 +000085 }
John McCallf413f5e2013-05-03 00:10:13 +000086
David L. Jonesc4808b9e2016-12-15 20:53:26 +000087 TypeSourceInfo *GetTypeSourceInfo() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000088 return Record.getTypeSourceInfo();
John McCallf413f5e2013-05-03 00:10:13 +000089 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000090
91 Decl *ReadDecl() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000092 return Record.readDecl();
Sebastian Redl2c373b92010-10-05 15:59:54 +000093 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000094
Douglas Gregor7fb09192011-07-21 22:35:25 +000095 template<typename T>
David L. Jonesc4808b9e2016-12-15 20:53:26 +000096 T *ReadDeclAs() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000097 return Record.readDeclAs<T>();
Douglas Gregor7fb09192011-07-21 22:35:25 +000098 }
99
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000100 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc,
101 DeclarationName Name) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000102 Record.readDeclarationNameLoc(DNLoc, Name);
Argyrios Kyrtzidis434383d2010-10-15 18:21:24 +0000103 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000104
105 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000106 Record.readDeclarationNameInfo(NameInfo);
Argyrios Kyrtzidis434383d2010-10-15 18:21:24 +0000107 }
Sebastian Redl2c373b92010-10-05 15:59:54 +0000108
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000109 public:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000110 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
111 : Record(Record), DeclsCursor(Cursor) {}
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000112
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000113 /// The number of record fields required for the Stmt class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000114 /// itself.
115 static const unsigned NumStmtFields = 0;
116
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000117 /// The number of record fields required for the Expr class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000118 /// itself.
Douglas Gregor678d76c2011-07-01 01:22:09 +0000119 static const unsigned NumExprFields = NumStmtFields + 7;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000120
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000121 /// Read and initialize a ExplicitTemplateArgumentList structure.
Abramo Bagnara7945c982012-01-27 09:46:47 +0000122 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
James Y Knighte7d82282015-12-29 18:15:14 +0000123 TemplateArgumentLoc *ArgsLocArray,
Abramo Bagnara7945c982012-01-27 09:46:47 +0000124 unsigned NumTemplateArgs);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000125
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000126 /// Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisde6aa082011-09-22 20:07:03 +0000127 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000128 unsigned NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000129
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000130 void VisitStmt(Stmt *S);
John McCallfa194042011-07-15 07:00:14 +0000131#define STMT(Type, Base) \
132 void Visit##Type(Type *);
133#include "clang/AST/StmtNodes.inc"
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000134 };
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000135
136} // namespace clang
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000137
James Y Knighte7d82282015-12-29 18:15:14 +0000138void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
139 TemplateArgumentLoc *ArgsLocArray,
140 unsigned NumTemplateArgs) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000141 SourceLocation TemplateKWLoc = ReadSourceLocation();
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000142 TemplateArgumentListInfo ArgInfo;
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000143 ArgInfo.setLAngleLoc(ReadSourceLocation());
144 ArgInfo.setRAngleLoc(ReadSourceLocation());
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000145 for (unsigned i = 0; i != NumTemplateArgs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000146 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
James Y Knighte7d82282015-12-29 18:15:14 +0000147 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000148}
149
Sebastian Redl70c751d2010-08-18 23:56:52 +0000150void ASTStmtReader::VisitStmt(Stmt *S) {
David L. Jonesbe1557a2016-12-21 00:17:49 +0000151 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000152}
153
Sebastian Redl70c751d2010-08-18 23:56:52 +0000154void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000155 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000156 S->setSemiLoc(ReadSourceLocation());
Bruno Ricci41d11c02018-10-27 18:43:27 +0000157 S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000158}
159
Sebastian Redl70c751d2010-08-18 23:56:52 +0000160void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000161 VisitStmt(S);
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000162 SmallVector<Stmt *, 16> Stmts;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000163 unsigned NumStmts = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000164 while (NumStmts--)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000165 Stmts.push_back(Record.readSubStmt());
Benjamin Kramer07420902017-12-24 16:24:20 +0000166 S->setStmts(Stmts);
Bruno Ricci41d11c02018-10-27 18:43:27 +0000167 S->CompoundStmtBits.LBraceLoc = ReadSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000168 S->RBraceLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000169}
170
Sebastian Redl70c751d2010-08-18 23:56:52 +0000171void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000172 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000173 Record.recordSwitchCaseID(S, Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000174 S->setKeywordLoc(ReadSourceLocation());
175 S->setColonLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000176}
177
Sebastian Redl70c751d2010-08-18 23:56:52 +0000178void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000179 VisitSwitchCase(S);
Bruno Ricci5b30571752018-10-28 12:30:53 +0000180 bool CaseStmtIsGNURange = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000181 S->setLHS(Record.readSubExpr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000182 S->setSubStmt(Record.readSubStmt());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000183 if (CaseStmtIsGNURange) {
184 S->setRHS(Record.readSubExpr());
185 S->setEllipsisLoc(ReadSourceLocation());
186 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000187}
188
Sebastian Redl70c751d2010-08-18 23:56:52 +0000189void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000190 VisitSwitchCase(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000191 S->setSubStmt(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000192}
193
Sebastian Redl70c751d2010-08-18 23:56:52 +0000194void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000195 VisitStmt(S);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000196 auto *LD = ReadDeclAs<LabelDecl>();
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000197 LD->setStmt(S);
198 S->setDecl(LD);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000199 S->setSubStmt(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000200 S->setIdentLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000201}
202
Richard Smithc202b282012-04-14 00:33:13 +0000203void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
204 VisitStmt(S);
Bruno Ricci41d11c02018-10-27 18:43:27 +0000205 // NumAttrs in AttributedStmt is set when creating an empty
206 // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
207 // to allocate the right amount of space for the trailing Attr *.
David L. Jonesbe1557a2016-12-21 00:17:49 +0000208 uint64_t NumAttrs = Record.readInt();
Richard Smithc202b282012-04-14 00:33:13 +0000209 AttrVec Attrs;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000210 Record.readAttributes(Attrs);
Matt Beaumont-Gayad0bb8e2012-07-09 18:55:31 +0000211 (void)NumAttrs;
Bruno Ricci41d11c02018-10-27 18:43:27 +0000212 assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
Alexander Kornienko20f6fc62012-07-09 10:04:07 +0000213 assert(NumAttrs == Attrs.size());
Aaron Ballmanf3d9b092014-05-13 14:55:01 +0000214 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000215 S->SubStmt = Record.readSubStmt();
Bruno Ricci41d11c02018-10-27 18:43:27 +0000216 S->AttributedStmtBits.AttrLoc = ReadSourceLocation();
Richard Smithc202b282012-04-14 00:33:13 +0000217}
218
Sebastian Redl70c751d2010-08-18 23:56:52 +0000219void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000220 VisitStmt(S);
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000221
David L. Jonesbe1557a2016-12-21 00:17:49 +0000222 S->setConstexpr(Record.readInt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000223 bool HasElse = Record.readInt();
224 bool HasVar = Record.readInt();
225 bool HasInit = Record.readInt();
226
David L. Jonesb6a8f022016-12-21 04:34:52 +0000227 S->setCond(Record.readSubExpr());
228 S->setThen(Record.readSubStmt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000229 if (HasElse)
230 S->setElse(Record.readSubStmt());
231 if (HasVar)
232 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
233 if (HasInit)
234 S->setInit(Record.readSubStmt());
235
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000236 S->setIfLoc(ReadSourceLocation());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000237 if (HasElse)
238 S->setElseLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000239}
240
Sebastian Redl70c751d2010-08-18 23:56:52 +0000241void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000242 VisitStmt(S);
Bruno Riccie2806f82018-10-29 16:12:37 +0000243
244 bool HasInit = Record.readInt();
245 bool HasVar = Record.readInt();
246 bool AllEnumCasesCovered = Record.readInt();
247 if (AllEnumCasesCovered)
248 S->setAllEnumCasesCovered();
249
David L. Jonesb6a8f022016-12-21 04:34:52 +0000250 S->setCond(Record.readSubExpr());
251 S->setBody(Record.readSubStmt());
Bruno Riccie2806f82018-10-29 16:12:37 +0000252 if (HasInit)
253 S->setInit(Record.readSubStmt());
254 if (HasVar)
255 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
256
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000257 S->setSwitchLoc(ReadSourceLocation());
Ted Kremenekc42f3452010-09-09 00:05:53 +0000258
Craig Toppera13603a2014-05-22 05:54:18 +0000259 SwitchCase *PrevSC = nullptr;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000260 for (auto E = Record.size(); Record.getIdx() != E; ) {
261 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000262 if (PrevSC)
263 PrevSC->setNextSwitchCase(SC);
264 else
265 S->setSwitchCaseList(SC);
Mike Stump11289f42009-09-09 15:08:12 +0000266
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000267 PrevSC = SC;
268 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000269}
270
Sebastian Redl70c751d2010-08-18 23:56:52 +0000271void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000272 VisitStmt(S);
Bruno Riccibacf7512018-10-30 13:42:41 +0000273
274 bool HasVar = Record.readInt();
Douglas Gregor7fb09192011-07-21 22:35:25 +0000275
David L. Jonesb6a8f022016-12-21 04:34:52 +0000276 S->setCond(Record.readSubExpr());
277 S->setBody(Record.readSubStmt());
Bruno Riccibacf7512018-10-30 13:42:41 +0000278 if (HasVar)
279 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
280
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000281 S->setWhileLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000282}
283
Sebastian Redl70c751d2010-08-18 23:56:52 +0000284void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000285 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000286 S->setCond(Record.readSubExpr());
287 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000288 S->setDoLoc(ReadSourceLocation());
289 S->setWhileLoc(ReadSourceLocation());
290 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000291}
292
Sebastian Redl70c751d2010-08-18 23:56:52 +0000293void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000294 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000295 S->setInit(Record.readSubStmt());
296 S->setCond(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000297 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000298 S->setInc(Record.readSubExpr());
299 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000300 S->setForLoc(ReadSourceLocation());
301 S->setLParenLoc(ReadSourceLocation());
302 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000303}
304
Sebastian Redl70c751d2010-08-18 23:56:52 +0000305void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000306 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000307 S->setLabel(ReadDeclAs<LabelDecl>());
308 S->setGotoLoc(ReadSourceLocation());
309 S->setLabelLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000310}
311
Sebastian Redl70c751d2010-08-18 23:56:52 +0000312void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000313 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000314 S->setGotoLoc(ReadSourceLocation());
315 S->setStarLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000316 S->setTarget(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000317}
318
Sebastian Redl70c751d2010-08-18 23:56:52 +0000319void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000320 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000321 S->setContinueLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000322}
323
Sebastian Redl70c751d2010-08-18 23:56:52 +0000324void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000325 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000326 S->setBreakLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000327}
328
Sebastian Redl70c751d2010-08-18 23:56:52 +0000329void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000330 VisitStmt(S);
Bruno Ricci023b1d12018-10-30 14:40:49 +0000331
332 bool HasNRVOCandidate = Record.readInt();
333
David L. Jonesb6a8f022016-12-21 04:34:52 +0000334 S->setRetValue(Record.readSubExpr());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000335 if (HasNRVOCandidate)
336 S->setNRVOCandidate(ReadDeclAs<VarDecl>());
337
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000338 S->setReturnLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000339}
340
Sebastian Redl70c751d2010-08-18 23:56:52 +0000341void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000342 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000343 S->setStartLoc(ReadSourceLocation());
344 S->setEndLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000345
David L. Jonesbe1557a2016-12-21 00:17:49 +0000346 if (Record.size() - Record.getIdx() == 1) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000347 // Single declaration
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000348 S->setDeclGroup(DeclGroupRef(ReadDecl()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000349 } else {
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000350 SmallVector<Decl *, 16> Decls;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000351 int N = Record.size() - Record.getIdx();
352 Decls.reserve(N);
353 for (int I = 0; I < N; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000354 Decls.push_back(ReadDecl());
355 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
Douglas Gregor038c3382009-05-22 22:45:36 +0000356 Decls.data(),
357 Decls.size())));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000358 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000359}
360
John McCallf413f5e2013-05-03 00:10:13 +0000361void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000362 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000363 S->NumOutputs = Record.readInt();
364 S->NumInputs = Record.readInt();
365 S->NumClobbers = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000366 S->setAsmLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000367 S->setVolatile(Record.readInt());
368 S->setSimple(Record.readInt());
John McCallf413f5e2013-05-03 00:10:13 +0000369}
Mike Stump11289f42009-09-09 15:08:12 +0000370
John McCallf413f5e2013-05-03 00:10:13 +0000371void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
372 VisitAsmStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000373 S->setRParenLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000374 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000375
John McCallf413f5e2013-05-03 00:10:13 +0000376 unsigned NumOutputs = S->getNumOutputs();
377 unsigned NumInputs = S->getNumInputs();
378 unsigned NumClobbers = S->getNumClobbers();
379
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000380 // Outputs and inputs
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000381 SmallVector<IdentifierInfo *, 16> Names;
382 SmallVector<StringLiteral*, 16> Constraints;
383 SmallVector<Stmt*, 16> Exprs;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000384 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000385 Names.push_back(Record.getIdentifierInfo());
386 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
387 Exprs.push_back(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000388 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000389
390 // Constraints
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000391 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000392 for (unsigned I = 0; I != NumClobbers; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000393 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000394
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000395 S->setOutputsAndInputsAndClobbers(Record.getContext(),
396 Names.data(), Constraints.data(),
397 Exprs.data(), NumOutputs, NumInputs,
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000398 Clobbers.data(), NumClobbers);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000399}
400
Chad Rosier32503022012-06-11 20:47:18 +0000401void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
John McCallf413f5e2013-05-03 00:10:13 +0000402 VisitAsmStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000403 S->LBraceLoc = ReadSourceLocation();
404 S->EndLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000405 S->NumAsmToks = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000406 std::string AsmStr = ReadString();
John McCallf413f5e2013-05-03 00:10:13 +0000407
408 // Read the tokens.
409 SmallVector<Token, 16> AsmToks;
410 AsmToks.reserve(S->NumAsmToks);
411 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000412 AsmToks.push_back(Record.readToken());
John McCallf413f5e2013-05-03 00:10:13 +0000413 }
414
415 // The calls to reserve() for the FooData vectors are mandatory to
416 // prevent dead StringRefs in the Foo vectors.
417
418 // Read the clobbers.
419 SmallVector<std::string, 16> ClobbersData;
420 SmallVector<StringRef, 16> Clobbers;
421 ClobbersData.reserve(S->NumClobbers);
422 Clobbers.reserve(S->NumClobbers);
423 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000424 ClobbersData.push_back(ReadString());
John McCallf413f5e2013-05-03 00:10:13 +0000425 Clobbers.push_back(ClobbersData.back());
426 }
427
428 // Read the operands.
429 unsigned NumOperands = S->NumOutputs + S->NumInputs;
430 SmallVector<Expr*, 16> Exprs;
431 SmallVector<std::string, 16> ConstraintsData;
432 SmallVector<StringRef, 16> Constraints;
433 Exprs.reserve(NumOperands);
434 ConstraintsData.reserve(NumOperands);
435 Constraints.reserve(NumOperands);
436 for (unsigned i = 0; i != NumOperands; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000437 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000438 ConstraintsData.push_back(ReadString());
John McCallf413f5e2013-05-03 00:10:13 +0000439 Constraints.push_back(ConstraintsData.back());
440 }
441
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000442 S->initialize(Record.getContext(), AsmStr, AsmToks,
John McCallf413f5e2013-05-03 00:10:13 +0000443 Constraints, Exprs, Clobbers);
Chad Rosier32503022012-06-11 20:47:18 +0000444}
445
Richard Smith9f690bd2015-10-27 06:02:45 +0000446void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000447 VisitStmt(S);
448 assert(Record.peekInt() == S->NumParams);
449 Record.skipInts(1);
450 auto *StoredStmts = S->getStoredStmts();
451 for (unsigned i = 0;
452 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
453 StoredStmts[i] = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000454}
455
456void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000457 VisitStmt(S);
458 S->CoreturnLoc = Record.readSourceLocation();
459 for (auto &SubStmt: S->SubStmts)
460 SubStmt = Record.readSubStmt();
461 S->IsImplicit = Record.readInt() != 0;
Richard Smith9f690bd2015-10-27 06:02:45 +0000462}
463
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000464void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
465 VisitExpr(E);
466 E->KeywordLoc = ReadSourceLocation();
467 for (auto &SubExpr: E->SubExprs)
468 SubExpr = Record.readSubStmt();
469 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
470 E->setIsImplicit(Record.readInt() != 0);
Richard Smith9f690bd2015-10-27 06:02:45 +0000471}
472
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000473void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
474 VisitExpr(E);
475 E->KeywordLoc = ReadSourceLocation();
476 for (auto &SubExpr: E->SubExprs)
477 SubExpr = Record.readSubStmt();
478 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
Eric Fiselier20f25cb2017-03-06 23:38:15 +0000479}
480
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000481void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
482 VisitExpr(E);
483 E->KeywordLoc = ReadSourceLocation();
484 for (auto &SubExpr: E->SubExprs)
485 SubExpr = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000486}
487
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000488void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
Ben Langmuirce914fc2013-05-03 19:20:19 +0000489 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000490 Record.skipInts(1);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000491 S->setCapturedDecl(ReadDeclAs<CapturedDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000492 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000493 S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000494
495 // Capture inits
496 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
497 E = S->capture_init_end();
498 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000499 *I = Record.readSubExpr();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000500
501 // Body
David L. Jonesb6a8f022016-12-21 04:34:52 +0000502 S->setCapturedStmt(Record.readSubStmt());
Wei Pan17fbf6e2013-05-04 03:59:06 +0000503 S->getCapturedDecl()->setBody(S->getCapturedStmt());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000504
505 // Captures
Aaron Ballmanc656303a2014-03-14 18:08:33 +0000506 for (auto &I : S->captures()) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000507 I.VarAndKind.setPointer(ReadDeclAs<VarDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000508 I.VarAndKind.setInt(
509 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000510 I.Loc = ReadSourceLocation();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000511 }
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000512}
513
Sebastian Redl70c751d2010-08-18 23:56:52 +0000514void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000515 VisitStmt(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000516 E->setType(Record.readType());
517 E->setTypeDependent(Record.readInt());
518 E->setValueDependent(Record.readInt());
519 E->setInstantiationDependent(Record.readInt());
520 E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
521 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
522 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
523 assert(Record.getIdx() == NumExprFields &&
524 "Incorrect expression field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000525}
526
Bill Wendling7c44da22018-10-31 03:48:47 +0000527void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
528 VisitExpr(E);
529 E->setSubExpr(Record.readSubExpr());
530}
531
Sebastian Redl70c751d2010-08-18 23:56:52 +0000532void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000533 VisitExpr(E);
Bruno Ricci17ff0262018-10-27 19:21:19 +0000534 bool HasFunctionName = Record.readInt();
535 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
536 E->PredefinedExprBits.Kind = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000537 E->setLocation(ReadSourceLocation());
Bruno Ricci17ff0262018-10-27 19:21:19 +0000538 if (HasFunctionName)
539 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000540}
541
Sebastian Redl70c751d2010-08-18 23:56:52 +0000542void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000543 VisitExpr(E);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000544
David L. Jonesbe1557a2016-12-21 00:17:49 +0000545 E->DeclRefExprBits.HasQualifier = Record.readInt();
546 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
547 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
548 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
549 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000550 unsigned NumTemplateArgs = 0;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000551 if (E->hasTemplateKWAndArgsInfo())
David L. Jonesbe1557a2016-12-21 00:17:49 +0000552 NumTemplateArgs = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000553
Chandler Carruth0e439962011-05-01 21:29:53 +0000554 if (E->hasQualifier())
James Y Knighte7d82282015-12-29 18:15:14 +0000555 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
David L. Jonesb6a8f022016-12-21 04:34:52 +0000556 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000557
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000558 if (E->hasFoundDecl())
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000559 *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000560
Abramo Bagnara7945c982012-01-27 09:46:47 +0000561 if (E->hasTemplateKWAndArgsInfo())
James Y Knighte7d82282015-12-29 18:15:14 +0000562 ReadTemplateKWAndArgsInfo(
563 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
564 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000565
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000566 E->setDecl(ReadDeclAs<ValueDecl>());
567 E->setLocation(ReadSourceLocation());
568 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000569}
570
Sebastian Redl70c751d2010-08-18 23:56:52 +0000571void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000572 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000573 E->setLocation(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000574 E->setValue(Record.getContext(), Record.readAPInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000575}
576
Leonard Chandb01c3a2018-06-20 17:19:40 +0000577void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
578 VisitExpr(E);
579 E->setLocation(ReadSourceLocation());
580 E->setValue(Record.getContext(), Record.readAPInt());
581}
582
Sebastian Redl70c751d2010-08-18 23:56:52 +0000583void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000584 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000585 E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record.readInt()));
586 E->setExact(Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000587 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000588 E->setLocation(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000589}
590
Sebastian Redl70c751d2010-08-18 23:56:52 +0000591void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000592 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000593 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000594}
595
Sebastian Redl70c751d2010-08-18 23:56:52 +0000596void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000597 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000598 unsigned Len = Record.readInt();
599 assert(Record.peekInt() == E->getNumConcatenated() &&
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000600 "Wrong number of concatenated tokens!");
David L. Jonesbe1557a2016-12-21 00:17:49 +0000601 Record.skipInts(1);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000602 auto kind = static_cast<StringLiteral::StringKind>(Record.readInt());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000603 bool isPascal = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000604
Mike Stump11289f42009-09-09 15:08:12 +0000605 // Read string data
David L. Jonesbe1557a2016-12-21 00:17:49 +0000606 auto B = &Record.peekInt();
607 SmallString<16> Str(B, B + Len);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000608 E->setString(Record.getContext(), Str, kind, isPascal);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000609 Record.skipInts(Len);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000610
611 // Read source locations
612 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000613 E->setStrTokenLoc(I, ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000614}
615
Sebastian Redl70c751d2010-08-18 23:56:52 +0000616void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000617 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000618 E->setValue(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000619 E->setLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000620 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000621}
622
Sebastian Redl70c751d2010-08-18 23:56:52 +0000623void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000624 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000625 E->setLParen(ReadSourceLocation());
626 E->setRParen(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000627 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000628}
629
Sebastian Redl70c751d2010-08-18 23:56:52 +0000630void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000631 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000632 unsigned NumExprs = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000633 E->Exprs = new (Record.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000634 for (unsigned i = 0; i != NumExprs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000635 E->Exprs[i] = Record.readSubStmt();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000636 E->NumExprs = NumExprs;
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000637 E->LParenLoc = ReadSourceLocation();
638 E->RParenLoc = ReadSourceLocation();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000639}
640
Sebastian Redl70c751d2010-08-18 23:56:52 +0000641void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000642 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000643 E->setSubExpr(Record.readSubExpr());
644 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
645 E->setOperatorLoc(ReadSourceLocation());
646 E->setCanOverflow(Record.readInt());
647}
648
649void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000650 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000651 assert(E->getNumComponents() == Record.peekInt());
652 Record.skipInts(1);
653 assert(E->getNumExpressions() == Record.peekInt());
654 Record.skipInts(1);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000655 E->setOperatorLoc(ReadSourceLocation());
656 E->setRParenLoc(ReadSourceLocation());
657 E->setTypeSourceInfo(GetTypeSourceInfo());
Douglas Gregor882211c2010-04-28 22:16:22 +0000658 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000659 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000660 SourceLocation Start = ReadSourceLocation();
661 SourceLocation End = ReadSourceLocation();
Douglas Gregor882211c2010-04-28 22:16:22 +0000662 switch (Kind) {
James Y Knight7281c352015-12-29 22:31:18 +0000663 case OffsetOfNode::Array:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000664 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000665 break;
666
James Y Knight7281c352015-12-29 22:31:18 +0000667 case OffsetOfNode::Field:
668 E->setComponent(
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000669 I, OffsetOfNode(Start, ReadDeclAs<FieldDecl>(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000670 break;
James Y Knight7281c352015-12-29 22:31:18 +0000671
672 case OffsetOfNode::Identifier:
673 E->setComponent(
674 I,
David L. Jonesb6a8f022016-12-21 04:34:52 +0000675 OffsetOfNode(Start, Record.getIdentifierInfo(), End));
James Y Knight7281c352015-12-29 22:31:18 +0000676 break;
677
678 case OffsetOfNode::Base: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000679 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000680 *Base = Record.readCXXBaseSpecifier();
James Y Knight7281c352015-12-29 22:31:18 +0000681 E->setComponent(I, OffsetOfNode(Base));
Douglas Gregord1702062010-04-29 00:18:15 +0000682 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000683 }
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000684 }
Douglas Gregor882211c2010-04-28 22:16:22 +0000685 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000686
Douglas Gregor882211c2010-04-28 22:16:22 +0000687 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000688 E->setIndexExpr(I, Record.readSubExpr());
Douglas Gregor882211c2010-04-28 22:16:22 +0000689}
690
Peter Collingbournee190dee2011-03-11 19:24:49 +0000691void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000692 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000693 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
694 if (Record.peekInt() == 0) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000695 E->setArgument(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000696 Record.skipInts(1);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000697 } else {
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000698 E->setArgument(GetTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000699 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000700 E->setOperatorLoc(ReadSourceLocation());
701 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000702}
703
Sebastian Redl70c751d2010-08-18 23:56:52 +0000704void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000705 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000706 E->setLHS(Record.readSubExpr());
707 E->setRHS(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000708 E->setRBracketLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000709}
710
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000711void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
712 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000713 E->setBase(Record.readSubExpr());
714 E->setLowerBound(Record.readSubExpr());
715 E->setLength(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000716 E->setColonLoc(ReadSourceLocation());
717 E->setRBracketLoc(ReadSourceLocation());
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000718}
719
Sebastian Redl70c751d2010-08-18 23:56:52 +0000720void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000721 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000722 E->setNumArgs(Record.getContext(), Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000723 E->setRParenLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000724 E->setCallee(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000725 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000726 E->setArg(I, Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000727}
728
John McCallfa194042011-07-15 07:00:14 +0000729void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
730 VisitCallExpr(E);
731}
732
Sebastian Redl70c751d2010-08-18 23:56:52 +0000733void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000734 // Don't call VisitExpr, this is fully initialized at creation.
735 assert(E->getStmtClass() == Stmt::MemberExprClass &&
736 "It's a subclass, we must advance Idx!");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000737}
738
Sebastian Redl70c751d2010-08-18 23:56:52 +0000739void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Naroffe87026a2009-07-24 17:54:45 +0000740 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000741 E->setBase(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000742 E->setIsaMemberLoc(ReadSourceLocation());
743 E->setOpLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000744 E->setArrow(Record.readInt());
Steve Naroffe87026a2009-07-24 17:54:45 +0000745}
746
John McCall31168b02011-06-15 23:02:42 +0000747void ASTStmtReader::
748VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
749 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000750 E->Operand = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000751 E->setShouldCopy(Record.readInt());
John McCall31168b02011-06-15 23:02:42 +0000752}
753
754void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
755 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000756 E->LParenLoc = ReadSourceLocation();
757 E->BridgeKeywordLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000758 E->Kind = Record.readInt();
John McCall31168b02011-06-15 23:02:42 +0000759}
760
Sebastian Redl70c751d2010-08-18 23:56:52 +0000761void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000762 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000763 unsigned NumBaseSpecs = Record.readInt();
John McCallcf142162010-08-07 06:22:56 +0000764 assert(NumBaseSpecs == E->path_size());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000765 E->setSubExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000766 E->setCastKind((CastKind)Record.readInt());
John McCallcf142162010-08-07 06:22:56 +0000767 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000768 while (NumBaseSpecs--) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000769 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000770 *BaseSpec = Record.readCXXBaseSpecifier();
John McCallcf142162010-08-07 06:22:56 +0000771 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000772 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000773}
774
Sebastian Redl70c751d2010-08-18 23:56:52 +0000775void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000776 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000777 E->setLHS(Record.readSubExpr());
778 E->setRHS(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000779 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000780 E->setOperatorLoc(ReadSourceLocation());
Adam Nemet484aa452017-03-27 19:17:25 +0000781 E->setFPFeatures(FPOptions(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000782}
783
Sebastian Redl70c751d2010-08-18 23:56:52 +0000784void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000785 VisitBinaryOperator(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000786 E->setComputationLHSType(Record.readType());
787 E->setComputationResultType(Record.readType());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000788}
789
Sebastian Redl70c751d2010-08-18 23:56:52 +0000790void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000791 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000792 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
793 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
794 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000795 E->QuestionLoc = ReadSourceLocation();
796 E->ColonLoc = ReadSourceLocation();
John McCallc07a0c72011-02-17 10:25:35 +0000797}
798
799void
800ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
801 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000802 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
803 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
804 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
805 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
806 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000807 E->QuestionLoc = ReadSourceLocation();
808 E->ColonLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000809}
810
Sebastian Redl70c751d2010-08-18 23:56:52 +0000811void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000812 VisitCastExpr(E);
Roman Lebedev12216f12018-07-27 07:27:14 +0000813 E->setIsPartOfExplicitCast(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000814}
815
Sebastian Redl70c751d2010-08-18 23:56:52 +0000816void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000817 VisitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000818 E->setTypeInfoAsWritten(GetTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000819}
820
Sebastian Redl70c751d2010-08-18 23:56:52 +0000821void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000822 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000823 E->setLParenLoc(ReadSourceLocation());
824 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000825}
826
Sebastian Redl70c751d2010-08-18 23:56:52 +0000827void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000828 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000829 E->setLParenLoc(ReadSourceLocation());
830 E->setTypeSourceInfo(GetTypeSourceInfo());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000831 E->setInitializer(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000832 E->setFileScope(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000833}
834
Sebastian Redl70c751d2010-08-18 23:56:52 +0000835void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000836 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000837 E->setBase(Record.readSubExpr());
838 E->setAccessor(Record.getIdentifierInfo());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000839 E->setAccessorLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000840}
841
Sebastian Redl70c751d2010-08-18 23:56:52 +0000842void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000843 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000844 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
Abramo Bagnara8d16bd42012-11-08 18:41:43 +0000845 E->setSyntacticForm(SyntForm);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000846 E->setLBraceLoc(ReadSourceLocation());
847 E->setRBraceLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000848 bool isArrayFiller = Record.readInt();
Craig Toppera13603a2014-05-22 05:54:18 +0000849 Expr *filler = nullptr;
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000850 if (isArrayFiller) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000851 filler = Record.readSubExpr();
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000852 E->ArrayFillerOrUnionFieldInit = filler;
853 } else
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000854 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000855 E->sawArrayRangeDesignator(Record.readInt());
856 unsigned NumInits = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000857 E->reserveInits(Record.getContext(), NumInits);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000858 if (isArrayFiller) {
859 for (unsigned I = 0; I != NumInits; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000860 Expr *init = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000861 E->updateInit(Record.getContext(), I, init ? init : filler);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000862 }
863 } else {
864 for (unsigned I = 0; I != NumInits; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000865 E->updateInit(Record.getContext(), I, Record.readSubExpr());
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000866 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000867}
868
Sebastian Redl70c751d2010-08-18 23:56:52 +0000869void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000870 using Designator = DesignatedInitExpr::Designator;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000871
872 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000873 unsigned NumSubExprs = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000874 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
875 for (unsigned I = 0; I != NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000876 E->setSubExpr(I, Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000877 E->setEqualOrColonLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000878 E->setGNUSyntax(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000879
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000880 SmallVector<Designator, 4> Designators;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000881 while (Record.getIdx() < Record.size()) {
882 switch ((DesignatorTypes)Record.readInt()) {
Sebastian Redl539c5062010-08-18 23:57:32 +0000883 case DESIG_FIELD_DECL: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000884 auto *Field = ReadDeclAs<FieldDecl>();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000885 SourceLocation DotLoc = ReadSourceLocation();
886 SourceLocation FieldLoc = ReadSourceLocation();
Mike Stump11289f42009-09-09 15:08:12 +0000887 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000888 FieldLoc));
889 Designators.back().setField(Field);
890 break;
891 }
892
Sebastian Redl539c5062010-08-18 23:57:32 +0000893 case DESIG_FIELD_NAME: {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000894 const IdentifierInfo *Name = Record.getIdentifierInfo();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000895 SourceLocation DotLoc = ReadSourceLocation();
896 SourceLocation FieldLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000897 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
898 break;
899 }
Mike Stump11289f42009-09-09 15:08:12 +0000900
Sebastian Redl539c5062010-08-18 23:57:32 +0000901 case DESIG_ARRAY: {
David L. Jonesbe1557a2016-12-21 00:17:49 +0000902 unsigned Index = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000903 SourceLocation LBracketLoc = ReadSourceLocation();
904 SourceLocation RBracketLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000905 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
906 break;
907 }
908
Sebastian Redl539c5062010-08-18 23:57:32 +0000909 case DESIG_ARRAY_RANGE: {
David L. Jonesbe1557a2016-12-21 00:17:49 +0000910 unsigned Index = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000911 SourceLocation LBracketLoc = ReadSourceLocation();
912 SourceLocation EllipsisLoc = ReadSourceLocation();
913 SourceLocation RBracketLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000914 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
915 RBracketLoc));
916 break;
917 }
918 }
919 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000920 E->setDesignators(Record.getContext(),
Douglas Gregor03e8bdc2010-01-06 23:17:19 +0000921 Designators.data(), Designators.size());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000922}
923
Yunzhong Gaocb779302015-06-10 00:27:52 +0000924void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
925 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000926 E->setBase(Record.readSubExpr());
927 E->setUpdater(Record.readSubExpr());
Yunzhong Gaocb779302015-06-10 00:27:52 +0000928}
929
930void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
931 VisitExpr(E);
932}
933
Richard Smith410306b2016-12-12 02:53:20 +0000934void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
935 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000936 E->SubExprs[0] = Record.readSubExpr();
937 E->SubExprs[1] = Record.readSubExpr();
Richard Smith410306b2016-12-12 02:53:20 +0000938}
939
940void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
941 VisitExpr(E);
942}
943
Sebastian Redl70c751d2010-08-18 23:56:52 +0000944void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000945 VisitExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000946}
947
Sebastian Redl70c751d2010-08-18 23:56:52 +0000948void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000949 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000950 E->setSubExpr(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000951 E->setWrittenTypeInfo(GetTypeSourceInfo());
952 E->setBuiltinLoc(ReadSourceLocation());
953 E->setRParenLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000954 E->setIsMicrosoftABI(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000955}
956
Sebastian Redl70c751d2010-08-18 23:56:52 +0000957void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000958 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000959 E->setAmpAmpLoc(ReadSourceLocation());
960 E->setLabelLoc(ReadSourceLocation());
961 E->setLabel(ReadDeclAs<LabelDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000962}
963
Sebastian Redl70c751d2010-08-18 23:56:52 +0000964void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000965 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000966 E->setLParenLoc(ReadSourceLocation());
967 E->setRParenLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000968 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000969}
970
Sebastian Redl70c751d2010-08-18 23:56:52 +0000971void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000972 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000973 E->setCond(Record.readSubExpr());
974 E->setLHS(Record.readSubExpr());
975 E->setRHS(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000976 E->setBuiltinLoc(ReadSourceLocation());
977 E->setRParenLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000978 E->setIsConditionTrue(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000979}
980
Sebastian Redl70c751d2010-08-18 23:56:52 +0000981void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000982 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000983 E->setTokenLocation(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000984}
985
Sebastian Redl70c751d2010-08-18 23:56:52 +0000986void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000987 VisitExpr(E);
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000988 SmallVector<Expr *, 16> Exprs;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000989 unsigned NumExprs = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000990 while (NumExprs--)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000991 Exprs.push_back(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000992 E->setExprs(Record.getContext(), Exprs);
993 E->setBuiltinLoc(ReadSourceLocation());
994 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000995}
996
Hal Finkelc4d7c822013-09-18 03:29:45 +0000997void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
998 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000999 E->BuiltinLoc = ReadSourceLocation();
1000 E->RParenLoc = ReadSourceLocation();
1001 E->TInfo = GetTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001002 E->SrcExpr = Record.readSubExpr();
Hal Finkelc4d7c822013-09-18 03:29:45 +00001003}
1004
Sebastian Redl70c751d2010-08-18 23:56:52 +00001005void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001006 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001007 E->setBlockDecl(ReadDeclAs<BlockDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001008}
1009
Peter Collingbourne91147592011-04-15 00:35:48 +00001010void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1011 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001012 E->NumAssocs = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001013 E->AssocTypes = new (Record.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbourne91147592011-04-15 00:35:48 +00001014 E->SubExprs =
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001015 new(Record.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbourne91147592011-04-15 00:35:48 +00001016
David L. Jonesb6a8f022016-12-21 04:34:52 +00001017 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Record.readSubExpr();
Peter Collingbourne91147592011-04-15 00:35:48 +00001018 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001019 E->AssocTypes[I] = GetTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001020 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Record.readSubExpr();
Peter Collingbourne91147592011-04-15 00:35:48 +00001021 }
David L. Jonesbe1557a2016-12-21 00:17:49 +00001022 E->ResultIndex = Record.readInt();
Peter Collingbourne91147592011-04-15 00:35:48 +00001023
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001024 E->GenericLoc = ReadSourceLocation();
1025 E->DefaultLoc = ReadSourceLocation();
1026 E->RParenLoc = ReadSourceLocation();
Peter Collingbourne91147592011-04-15 00:35:48 +00001027}
1028
John McCallfe96e0b2011-11-06 09:01:30 +00001029void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1030 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001031 unsigned numSemanticExprs = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001032 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001033 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001034
1035 // Read the syntactic expression.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001036 E->getSubExprsBuffer()[0] = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001037
1038 // Read all the semantic expressions.
1039 for (unsigned i = 0; i != numSemanticExprs; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001040 Expr *subExpr = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001041 E->getSubExprsBuffer()[i+1] = subExpr;
1042 }
1043}
1044
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001045void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1046 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001047 E->Op = AtomicExpr::AtomicOp(Record.readInt());
Richard Smithaa22a8c2012-04-10 22:49:28 +00001048 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1049 for (unsigned I = 0; I != E->NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001050 E->SubExprs[I] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001051 E->BuiltinLoc = ReadSourceLocation();
1052 E->RParenLoc = ReadSourceLocation();
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001053}
1054
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001055//===----------------------------------------------------------------------===//
1056// Objective-C Expressions and Statements
1057
Sebastian Redl70c751d2010-08-18 23:56:52 +00001058void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001059 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001060 E->setString(cast<StringLiteral>(Record.readSubStmt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001061 E->setAtLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001062}
1063
Patrick Beard0caa3942012-04-19 00:25:12 +00001064void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001065 VisitExpr(E);
1066 // could be one of several IntegerLiteral, FloatLiteral, etc.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001067 E->SubExpr = Record.readSubStmt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001068 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>();
1069 E->Range = ReadSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001070}
1071
1072void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1073 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001074 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001075 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1076 Expr **Elements = E->getElements();
1077 for (unsigned I = 0, N = NumElements; I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001078 Elements[I] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001079 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1080 E->Range = ReadSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001081}
1082
1083void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1084 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001085 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001086 assert(NumElements == E->getNumElements() && "Wrong number of elements");
David L. Jonesbe1557a2016-12-21 00:17:49 +00001087 bool HasPackExpansions = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001088 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001089 auto *KeyValues =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001090 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001091 auto *Expansions =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001092 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001093 for (unsigned I = 0; I != NumElements; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001094 KeyValues[I].Key = Record.readSubExpr();
1095 KeyValues[I].Value = Record.readSubExpr();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001096 if (HasPackExpansions) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001097 Expansions[I].EllipsisLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001098 Expansions[I].NumExpansionsPlusOne = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001099 }
1100 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001101 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1102 E->Range = ReadSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001103}
1104
Sebastian Redl70c751d2010-08-18 23:56:52 +00001105void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001106 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001107 E->setEncodedTypeSourceInfo(GetTypeSourceInfo());
1108 E->setAtLoc(ReadSourceLocation());
1109 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001110}
1111
Sebastian Redl70c751d2010-08-18 23:56:52 +00001112void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001113 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001114 E->setSelector(Record.readSelector());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001115 E->setAtLoc(ReadSourceLocation());
1116 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001117}
1118
Sebastian Redl70c751d2010-08-18 23:56:52 +00001119void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001120 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001121 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>());
1122 E->setAtLoc(ReadSourceLocation());
1123 E->ProtoLoc = ReadSourceLocation();
1124 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001125}
1126
Sebastian Redl70c751d2010-08-18 23:56:52 +00001127void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001128 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001129 E->setDecl(ReadDeclAs<ObjCIvarDecl>());
1130 E->setLocation(ReadSourceLocation());
1131 E->setOpLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001132 E->setBase(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001133 E->setIsArrow(Record.readInt());
1134 E->setIsFreeIvar(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001135}
1136
Sebastian Redl70c751d2010-08-18 23:56:52 +00001137void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001138 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001139 unsigned MethodRefFlags = Record.readInt();
1140 bool Implicit = Record.readInt() != 0;
John McCallb7bd14f2010-12-02 01:19:52 +00001141 if (Implicit) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001142 auto *Getter = ReadDeclAs<ObjCMethodDecl>();
1143 auto *Setter = ReadDeclAs<ObjCMethodDecl>();
Argyrios Kyrtzidisab468b02012-03-30 00:19:18 +00001144 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCallb7bd14f2010-12-02 01:19:52 +00001145 } else {
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001146 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001147 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001148 E->setLocation(ReadSourceLocation());
1149 E->setReceiverLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001150 switch (Record.readInt()) {
John McCallb7bd14f2010-12-02 01:19:52 +00001151 case 0:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001152 E->setBase(Record.readSubExpr());
John McCallb7bd14f2010-12-02 01:19:52 +00001153 break;
1154 case 1:
David L. Jonesbe1557a2016-12-21 00:17:49 +00001155 E->setSuperReceiver(Record.readType());
John McCallb7bd14f2010-12-02 01:19:52 +00001156 break;
1157 case 2:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001158 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>());
John McCallb7bd14f2010-12-02 01:19:52 +00001159 break;
1160 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001161}
1162
Ted Kremeneke65b0862012-03-06 20:05:56 +00001163void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1164 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001165 E->setRBracket(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001166 E->setBaseExpr(Record.readSubExpr());
1167 E->setKeyExpr(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001168 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1169 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001170}
1171
Sebastian Redl70c751d2010-08-18 23:56:52 +00001172void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001173 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001174 assert(Record.peekInt() == E->getNumArgs());
1175 Record.skipInts(1);
1176 unsigned NumStoredSelLocs = Record.readInt();
1177 E->SelLocsKind = Record.readInt();
1178 E->setDelegateInitCall(Record.readInt());
1179 E->IsImplicit = Record.readInt();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001180 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
Douglas Gregor9a129192010-04-21 00:45:42 +00001181 switch (Kind) {
1182 case ObjCMessageExpr::Instance:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001183 E->setInstanceReceiver(Record.readSubExpr());
Douglas Gregor9a129192010-04-21 00:45:42 +00001184 break;
1185
1186 case ObjCMessageExpr::Class:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001187 E->setClassReceiver(GetTypeSourceInfo());
Douglas Gregor9a129192010-04-21 00:45:42 +00001188 break;
1189
1190 case ObjCMessageExpr::SuperClass:
1191 case ObjCMessageExpr::SuperInstance: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001192 QualType T = Record.readType();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001193 SourceLocation SuperLoc = ReadSourceLocation();
Douglas Gregor9a129192010-04-21 00:45:42 +00001194 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1195 break;
1196 }
1197 }
1198
1199 assert(Kind == E->getReceiverKind());
1200
David L. Jonesbe1557a2016-12-21 00:17:49 +00001201 if (Record.readInt())
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001202 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>());
Douglas Gregor9a129192010-04-21 00:45:42 +00001203 else
David L. Jonesb6a8f022016-12-21 04:34:52 +00001204 E->setSelector(Record.readSelector());
Douglas Gregor9a129192010-04-21 00:45:42 +00001205
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001206 E->LBracLoc = ReadSourceLocation();
1207 E->RBracLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001208
1209 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001210 E->setArg(I, Record.readSubExpr());
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00001211
1212 SourceLocation *Locs = E->getStoredSelLocs();
1213 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001214 Locs[I] = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001215}
1216
Sebastian Redl70c751d2010-08-18 23:56:52 +00001217void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001218 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001219 S->setElement(Record.readSubStmt());
1220 S->setCollection(Record.readSubExpr());
1221 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001222 S->setForLoc(ReadSourceLocation());
1223 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001224}
1225
Sebastian Redl70c751d2010-08-18 23:56:52 +00001226void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001227 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001228 S->setCatchBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001229 S->setCatchParamDecl(ReadDeclAs<VarDecl>());
1230 S->setAtCatchLoc(ReadSourceLocation());
1231 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001232}
1233
Sebastian Redl70c751d2010-08-18 23:56:52 +00001234void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001235 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001236 S->setFinallyBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001237 S->setAtFinallyLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001238}
1239
John McCall31168b02011-06-15 23:02:42 +00001240void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1241 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001242 S->setSubStmt(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001243 S->setAtLoc(ReadSourceLocation());
John McCall31168b02011-06-15 23:02:42 +00001244}
1245
Sebastian Redl70c751d2010-08-18 23:56:52 +00001246void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001247 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001248 assert(Record.peekInt() == S->getNumCatchStmts());
1249 Record.skipInts(1);
1250 bool HasFinally = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001251 S->setTryBody(Record.readSubStmt());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001252 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001253 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
Douglas Gregor96c79492010-04-23 22:50:49 +00001254
Douglas Gregor96c79492010-04-23 22:50:49 +00001255 if (HasFinally)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001256 S->setFinallyStmt(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001257 S->setAtTryLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001258}
1259
Sebastian Redl70c751d2010-08-18 23:56:52 +00001260void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001261 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001262 S->setSynchExpr(Record.readSubStmt());
1263 S->setSynchBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001264 S->setAtSynchronizedLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001265}
1266
Sebastian Redl70c751d2010-08-18 23:56:52 +00001267void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001268 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001269 S->setThrowExpr(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001270 S->setThrowLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001271}
1272
Ted Kremeneke65b0862012-03-06 20:05:56 +00001273void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1274 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001275 E->setValue(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001276 E->setLocation(ReadSourceLocation());
Ted Kremeneke65b0862012-03-06 20:05:56 +00001277}
1278
Erik Pilkington29099de2016-07-16 00:35:23 +00001279void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1280 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001281 SourceRange R = Record.readSourceRange();
Erik Pilkington29099de2016-07-16 00:35:23 +00001282 E->AtLoc = R.getBegin();
1283 E->RParen = R.getEnd();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001284 E->VersionToCheck = Record.readVersionTuple();
Erik Pilkington29099de2016-07-16 00:35:23 +00001285}
1286
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001287//===----------------------------------------------------------------------===//
1288// C++ Expressions and Statements
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001289//===----------------------------------------------------------------------===//
1290
Sebastian Redl70c751d2010-08-18 23:56:52 +00001291void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001292 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001293 S->CatchLoc = ReadSourceLocation();
1294 S->ExceptionDecl = ReadDeclAs<VarDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001295 S->HandlerBlock = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001296}
1297
Sebastian Redl70c751d2010-08-18 23:56:52 +00001298void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001299 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001300 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1301 Record.skipInts(1);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001302 S->TryLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001303 S->getStmts()[0] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001304 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001305 S->getStmts()[i + 1] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001306}
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001307
Richard Smith02e85f32011-04-14 22:09:26 +00001308void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1309 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001310 S->ForLoc = ReadSourceLocation();
1311 S->CoawaitLoc = ReadSourceLocation();
1312 S->ColonLoc = ReadSourceLocation();
1313 S->RParenLoc = ReadSourceLocation();
Richard Smith8baa5002018-09-28 18:44:09 +00001314 S->setInit(Record.readSubStmt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001315 S->setRangeStmt(Record.readSubStmt());
1316 S->setBeginStmt(Record.readSubStmt());
1317 S->setEndStmt(Record.readSubStmt());
1318 S->setCond(Record.readSubExpr());
1319 S->setInc(Record.readSubExpr());
1320 S->setLoopVarStmt(Record.readSubStmt());
1321 S->setBody(Record.readSubStmt());
Richard Smith02e85f32011-04-14 22:09:26 +00001322}
1323
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001324void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1325 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001326 S->KeywordLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001327 S->IsIfExists = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001328 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001329 ReadDeclarationNameInfo(S->NameInfo);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001330 S->SubStmt = Record.readSubStmt();
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001331}
1332
Sebastian Redl70c751d2010-08-18 23:56:52 +00001333void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001334 VisitCallExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001335 E->Operator = (OverloadedOperatorKind)Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001336 E->Range = Record.readSourceRange();
Adam Nemet484aa452017-03-27 19:17:25 +00001337 E->setFPFeatures(FPOptions(Record.readInt()));
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001338}
1339
Sebastian Redl70c751d2010-08-18 23:56:52 +00001340void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001341 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001342 E->NumArgs = Record.readInt();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001343 if (E->NumArgs)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001344 E->Args = new (Record.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis30d98f32010-06-24 08:57:09 +00001345 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001346 E->setArg(I, Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001347 E->setConstructor(ReadDeclAs<CXXConstructorDecl>());
1348 E->setLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001349 E->setElidable(Record.readInt());
1350 E->setHadMultipleCandidates(Record.readInt());
1351 E->setListInitialization(Record.readInt());
1352 E->setStdInitListInitialization(Record.readInt());
1353 E->setRequiresZeroInitialization(Record.readInt());
1354 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001355 E->ParenOrBraceRange = ReadSourceRange();
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001356}
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001357
Richard Smith5179eb72016-06-28 19:03:57 +00001358void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1359 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001360 E->Constructor = ReadDeclAs<CXXConstructorDecl>();
1361 E->Loc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001362 E->ConstructsVirtualBase = Record.readInt();
1363 E->InheritedFromVirtualBase = Record.readInt();
Richard Smith5179eb72016-06-28 19:03:57 +00001364}
1365
Sebastian Redl70c751d2010-08-18 23:56:52 +00001366void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001367 VisitCXXConstructExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001368 E->Type = GetTypeSourceInfo();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001369}
1370
Douglas Gregore31e6062012-02-07 10:09:13 +00001371void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1372 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001373 unsigned NumCaptures = Record.readInt();
Douglas Gregor99ae8062012-02-14 17:54:36 +00001374 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001375 E->IntroducerRange = ReadSourceRange();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001376 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001377 E->CaptureDefaultLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001378 E->ExplicitParams = Record.readInt();
1379 E->ExplicitResultType = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001380 E->ClosingBrace = ReadSourceLocation();
1381
Douglas Gregor99ae8062012-02-14 17:54:36 +00001382 // Read capture initializers.
1383 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1384 CEnd = E->capture_init_end();
1385 C != CEnd; ++C)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001386 *C = Record.readSubExpr();
Douglas Gregore31e6062012-02-07 10:09:13 +00001387}
1388
Richard Smithcc1b96d2013-06-12 22:31:48 +00001389void
1390ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1391 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001392 E->SubExpr = Record.readSubExpr();
Richard Smithcc1b96d2013-06-12 22:31:48 +00001393}
1394
Sebastian Redl70c751d2010-08-18 23:56:52 +00001395void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001396 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001397 SourceRange R = ReadSourceRange();
Douglas Gregor4478f852011-01-12 22:41:29 +00001398 E->Loc = R.getBegin();
1399 E->RParenLoc = R.getEnd();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001400 R = ReadSourceRange();
Fariborz Jahanianf0738712013-02-22 22:02:53 +00001401 E->AngleBrackets = R;
Sam Weinigd01101e2010-01-16 21:21:01 +00001402}
1403
Sebastian Redl70c751d2010-08-18 23:56:52 +00001404void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001405 return VisitCXXNamedCastExpr(E);
1406}
1407
Sebastian Redl70c751d2010-08-18 23:56:52 +00001408void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001409 return VisitCXXNamedCastExpr(E);
1410}
1411
Sebastian Redl70c751d2010-08-18 23:56:52 +00001412void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001413 return VisitCXXNamedCastExpr(E);
1414}
1415
Sebastian Redl70c751d2010-08-18 23:56:52 +00001416void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001417 return VisitCXXNamedCastExpr(E);
1418}
1419
Sebastian Redl70c751d2010-08-18 23:56:52 +00001420void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001421 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001422 E->setLParenLoc(ReadSourceLocation());
1423 E->setRParenLoc(ReadSourceLocation());
Sam Weinigd01101e2010-01-16 21:21:01 +00001424}
1425
Richard Smithc67fdd42012-03-07 08:35:16 +00001426void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1427 VisitCallExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001428 E->UDSuffixLoc = ReadSourceLocation();
Richard Smithc67fdd42012-03-07 08:35:16 +00001429}
1430
Sebastian Redl70c751d2010-08-18 23:56:52 +00001431void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001432 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001433 E->setValue(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001434 E->setLocation(ReadSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001435}
1436
Sebastian Redl70c751d2010-08-18 23:56:52 +00001437void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001438 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001439 E->setLocation(ReadSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001440}
1441
Sebastian Redl70c751d2010-08-18 23:56:52 +00001442void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001443 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001444 E->setSourceRange(ReadSourceRange());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001445 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redlc67764e2010-07-22 22:43:28 +00001446 E->setTypeOperandSourceInfo(
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001447 GetTypeSourceInfo());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001448 return;
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001449 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001450
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001451 // typeid(42+2)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001452 E->setExprOperand(Record.readSubExpr());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001453}
1454
Sebastian Redl70c751d2010-08-18 23:56:52 +00001455void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001456 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001457 E->setLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001458 E->setImplicit(Record.readInt());
Chris Lattner98267332010-05-09 06:15:05 +00001459}
1460
Sebastian Redl70c751d2010-08-18 23:56:52 +00001461void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001462 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001463 E->ThrowLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001464 E->Op = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001465 E->IsThrownVariableInScope = Record.readInt();
Chris Lattner98267332010-05-09 06:15:05 +00001466}
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001467
Sebastian Redl70c751d2010-08-18 23:56:52 +00001468void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattnere2437f42010-05-09 06:40:08 +00001469 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001470 E->Param = ReadDeclAs<ParmVarDecl>();
1471 E->Loc = ReadSourceLocation();
Chris Lattnercba86142010-05-10 00:25:06 +00001472}
1473
Richard Smith852c9db2013-04-20 22:23:05 +00001474void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1475 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001476 E->Field = ReadDeclAs<FieldDecl>();
1477 E->Loc = ReadSourceLocation();
Richard Smith852c9db2013-04-20 22:23:05 +00001478}
1479
Sebastian Redl70c751d2010-08-18 23:56:52 +00001480void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001481 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001482 E->setTemporary(Record.readCXXTemporary());
1483 E->setSubExpr(Record.readSubExpr());
Chris Lattnercba86142010-05-10 00:25:06 +00001484}
1485
Sebastian Redl70c751d2010-08-18 23:56:52 +00001486void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001487 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001488 E->TypeInfo = GetTypeSourceInfo();
1489 E->RParenLoc = ReadSourceLocation();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001490}
1491
Sebastian Redl70c751d2010-08-18 23:56:52 +00001492void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001493 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001494 E->GlobalNew = Record.readInt();
1495 bool isArray = Record.readInt();
1496 E->PassAlignment = Record.readInt();
1497 E->UsualArrayDeleteWantsSize = Record.readInt();
1498 unsigned NumPlacementArgs = Record.readInt();
1499 E->StoredInitializationStyle = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001500 E->setOperatorNew(ReadDeclAs<FunctionDecl>());
1501 E->setOperatorDelete(ReadDeclAs<FunctionDecl>());
1502 E->AllocatedTypeInfo = GetTypeSourceInfo();
1503 E->TypeIdParens = ReadSourceRange();
1504 E->Range = ReadSourceRange();
1505 E->DirectInitRange = ReadSourceRange();
Chandler Carruth01718152010-10-25 08:47:36 +00001506
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001507 E->AllocateArgsArray(Record.getContext(), isArray, NumPlacementArgs,
Sebastian Redl6047f072012-02-16 12:22:20 +00001508 E->StoredInitializationStyle != 0);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001509
1510 // Install all the subexpressions.
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001511 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1512 I != e; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001513 *I = Record.readSubStmt();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001514}
1515
Sebastian Redl70c751d2010-08-18 23:56:52 +00001516void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001517 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001518 E->GlobalDelete = Record.readInt();
1519 E->ArrayForm = Record.readInt();
1520 E->ArrayFormAsWritten = Record.readInt();
1521 E->UsualArrayDeleteWantsSize = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001522 E->OperatorDelete = ReadDeclAs<FunctionDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001523 E->Argument = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001524 E->Loc = ReadSourceLocation();
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001525}
Chris Lattnercba86142010-05-10 00:25:06 +00001526
Sebastian Redl70c751d2010-08-18 23:56:52 +00001527void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001528 VisitExpr(E);
1529
David L. Jonesb6a8f022016-12-21 04:34:52 +00001530 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001531 E->IsArrow = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001532 E->OperatorLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001533 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001534 E->ScopeType = GetTypeSourceInfo();
1535 E->ColonColonLoc = ReadSourceLocation();
1536 E->TildeLoc = ReadSourceLocation();
1537
David L. Jonesb6a8f022016-12-21 04:34:52 +00001538 IdentifierInfo *II = Record.getIdentifierInfo();
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001539 if (II)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001540 E->setDestroyedType(II, ReadSourceLocation());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001541 else
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001542 E->setDestroyedType(GetTypeSourceInfo());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001543}
1544
John McCall5d413782010-12-06 08:20:24 +00001545void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001546 VisitExpr(E);
John McCall28fc7092011-11-10 05:35:25 +00001547
David L. Jonesbe1557a2016-12-21 00:17:49 +00001548 unsigned NumObjects = Record.readInt();
John McCall28fc7092011-11-10 05:35:25 +00001549 assert(NumObjects == E->getNumObjects());
1550 for (unsigned i = 0; i != NumObjects; ++i)
James Y Knighte00a67e2015-12-31 04:18:25 +00001551 E->getTrailingObjects<BlockDecl *>()[i] =
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001552 ReadDeclAs<BlockDecl>();
John McCall28fc7092011-11-10 05:35:25 +00001553
David L. Jonesbe1557a2016-12-21 00:17:49 +00001554 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001555 E->SubExpr = Record.readSubExpr();
Chris Lattnere2437f42010-05-09 06:40:08 +00001556}
1557
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001558void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001559ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001560 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001561
David L. Jonesbe1557a2016-12-21 00:17:49 +00001562 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001563 ReadTemplateKWAndArgsInfo(
1564 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1565 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001566 /*NumTemplateArgs=*/Record.readInt());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001567
David L. Jonesb6a8f022016-12-21 04:34:52 +00001568 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001569 E->BaseType = Record.readType();
1570 E->IsArrow = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001571 E->OperatorLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001572 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001573 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>();
1574 ReadDeclarationNameInfo(E->MemberNameInfo);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001575}
1576
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001577void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001578ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001579 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001580
David L. Jonesbe1557a2016-12-21 00:17:49 +00001581 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001582 ReadTemplateKWAndArgsInfo(
1583 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1584 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001585 /*NumTemplateArgs=*/Record.readInt());
Douglas Gregor3a43fd62011-02-25 20:49:16 +00001586
David L. Jonesb6a8f022016-12-21 04:34:52 +00001587 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001588 ReadDeclarationNameInfo(E->NameInfo);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001589}
1590
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001591void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001592ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001593 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001594 assert(Record.peekInt() == E->arg_size() &&
1595 "Read wrong record during creation ?");
1596 Record.skipInts(1);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001597 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001598 E->setArg(I, Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001599 E->Type = GetTypeSourceInfo();
1600 E->setLParenLoc(ReadSourceLocation());
1601 E->setRParenLoc(ReadSourceLocation());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001602}
1603
Sebastian Redl70c751d2010-08-18 23:56:52 +00001604void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001605 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001606
David L. Jonesbe1557a2016-12-21 00:17:49 +00001607 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001608 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1609 E->getTrailingTemplateArgumentLoc(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001610 /*NumTemplateArgs=*/Record.readInt());
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001611
David L. Jonesbe1557a2016-12-21 00:17:49 +00001612 unsigned NumDecls = Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001613 UnresolvedSet<8> Decls;
1614 for (unsigned i = 0; i != NumDecls; ++i) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001615 auto *D = ReadDeclAs<NamedDecl>();
1616 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001617 Decls.addDecl(D, AS);
1618 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001619 E->initializeResults(Record.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001620
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001621 ReadDeclarationNameInfo(E->NameInfo);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001622 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001623}
1624
Sebastian Redl70c751d2010-08-18 23:56:52 +00001625void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001626 VisitOverloadExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001627 E->IsArrow = Record.readInt();
1628 E->HasUnresolvedUsing = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001629 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001630 E->BaseType = Record.readType();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001631 E->OperatorLoc = ReadSourceLocation();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001632}
1633
Sebastian Redl70c751d2010-08-18 23:56:52 +00001634void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001635 VisitOverloadExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001636 E->RequiresADL = Record.readInt();
1637 E->Overloaded = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001638 E->NamingClass = ReadDeclAs<CXXRecordDecl>();
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00001639}
1640
Douglas Gregor29c42f22012-02-24 07:38:34 +00001641void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1642 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001643 E->TypeTraitExprBits.NumArgs = Record.readInt();
1644 E->TypeTraitExprBits.Kind = Record.readInt();
1645 E->TypeTraitExprBits.Value = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001646 SourceRange Range = ReadSourceRange();
Jordan Rose99e80c12013-12-20 01:26:47 +00001647 E->Loc = Range.getBegin();
1648 E->RParenLoc = Range.getEnd();
1649
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001650 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001651 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001652 Args[I] = GetTypeSourceInfo();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001653}
1654
John Wiegley6242b6a2011-04-28 00:16:57 +00001655void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1656 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001657 E->ATT = (ArrayTypeTrait)Record.readInt();
1658 E->Value = (unsigned int)Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001659 SourceRange Range = ReadSourceRange();
John Wiegley6242b6a2011-04-28 00:16:57 +00001660 E->Loc = Range.getBegin();
1661 E->RParen = Range.getEnd();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001662 E->QueriedType = GetTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001663 E->Dimension = Record.readSubExpr();
John Wiegley6242b6a2011-04-28 00:16:57 +00001664}
1665
John Wiegleyf9f65842011-04-25 06:54:41 +00001666void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1667 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001668 E->ET = (ExpressionTrait)Record.readInt();
1669 E->Value = (bool)Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001670 SourceRange Range = ReadSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001671 E->QueriedExpression = Record.readSubExpr();
John Wiegleyf9f65842011-04-25 06:54:41 +00001672 E->Loc = Range.getBegin();
1673 E->RParen = Range.getEnd();
1674}
1675
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001676void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1677 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001678 E->Value = (bool)Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001679 E->Range = ReadSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001680 E->Operand = Record.readSubExpr();
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001681}
1682
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001683void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1684 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001685 E->EllipsisLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001686 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001687 E->Pattern = Record.readSubExpr();
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001688}
1689
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001690void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1691 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001692 unsigned NumPartialArgs = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001693 E->OperatorLoc = ReadSourceLocation();
1694 E->PackLoc = ReadSourceLocation();
1695 E->RParenLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001696 E->Pack = Record.readDeclAs<NamedDecl>();
Richard Smithd784e682015-09-23 21:41:42 +00001697 if (E->isPartiallySubstituted()) {
1698 assert(E->Length == NumPartialArgs);
James Y Knighte00a67e2015-12-31 04:18:25 +00001699 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
Richard Smithd784e682015-09-23 21:41:42 +00001700 *E = I + NumPartialArgs;
1701 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001702 new (I) TemplateArgument(Record.readTemplateArgument());
Richard Smithd784e682015-09-23 21:41:42 +00001703 } else if (!E->isValueDependent()) {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001704 E->Length = Record.readInt();
Richard Smithd784e682015-09-23 21:41:42 +00001705 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001706}
1707
John McCallfa194042011-07-15 07:00:14 +00001708void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1709 SubstNonTypeTemplateParmExpr *E) {
1710 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001711 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1712 E->NameLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001713 E->Replacement = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00001714}
1715
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001716void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1717 SubstNonTypeTemplateParmPackExpr *E) {
1718 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001719 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001720 TemplateArgument ArgPack = Record.readTemplateArgument();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001721 if (ArgPack.getKind() != TemplateArgument::Pack)
1722 return;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001723
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001724 E->Arguments = ArgPack.pack_begin();
1725 E->NumArguments = ArgPack.pack_size();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001726 E->NameLoc = ReadSourceLocation();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001727}
1728
Richard Smithb15fe3a2012-09-12 00:56:43 +00001729void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1730 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001731 E->NumParameters = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001732 E->ParamPack = ReadDeclAs<ParmVarDecl>();
1733 E->NameLoc = ReadSourceLocation();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001734 auto **Parms = E->getTrailingObjects<ParmVarDecl *>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00001735 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001736 Parms[i] = ReadDeclAs<ParmVarDecl>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00001737}
1738
Douglas Gregorfe314812011-06-21 17:03:29 +00001739void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1740 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001741 E->State = Record.readSubExpr();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001742 auto *VD = ReadDeclAs<ValueDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001743 unsigned ManglingNumber = Record.readInt();
David Majnemerdaff3702014-05-01 17:50:17 +00001744 E->setExtendingDecl(VD, ManglingNumber);
Douglas Gregorfe314812011-06-21 17:03:29 +00001745}
1746
Richard Smith0f0af192014-11-08 05:07:16 +00001747void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
1748 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001749 E->LParenLoc = ReadSourceLocation();
1750 E->EllipsisLoc = ReadSourceLocation();
1751 E->RParenLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001752 E->SubExprs[0] = Record.readSubExpr();
1753 E->SubExprs[1] = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001754 E->Opcode = (BinaryOperatorKind)Record.readInt();
Richard Smith0f0af192014-11-08 05:07:16 +00001755}
1756
John McCall8d69a212010-11-15 23:31:06 +00001757void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1758 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001759 E->SourceExpr = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001760 E->Loc = ReadSourceLocation();
Akira Hatanaka797afe32018-03-20 01:47:58 +00001761 E->setIsUnique(Record.readInt());
John McCall8d69a212010-11-15 23:31:06 +00001762}
1763
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001764void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
1765 llvm_unreachable("Cannot read TypoExpr nodes");
1766}
1767
Peter Collingbourne41f85462011-02-09 21:07:24 +00001768//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00001769// Microsoft Expressions and Statements
1770//===----------------------------------------------------------------------===//
John McCall5e77d762013-04-16 07:28:30 +00001771void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1772 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001773 E->IsArrow = (Record.readInt() != 0);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001774 E->BaseExpr = Record.readSubExpr();
1775 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001776 E->MemberLoc = ReadSourceLocation();
1777 E->TheDecl = ReadDeclAs<MSPropertyDecl>();
John McCall5e77d762013-04-16 07:28:30 +00001778}
1779
Alexey Bataevf7630272015-11-25 12:01:00 +00001780void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
1781 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001782 E->setBase(Record.readSubExpr());
1783 E->setIdx(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001784 E->setRBracketLoc(ReadSourceLocation());
Alexey Bataevf7630272015-11-25 12:01:00 +00001785}
1786
John McCallfa194042011-07-15 07:00:14 +00001787void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1788 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001789 E->setSourceRange(ReadSourceRange());
1790 std::string UuidStr = ReadString();
1791 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
John McCallfa194042011-07-15 07:00:14 +00001792 if (E->isTypeOperand()) { // __uuidof(ComType)
1793 E->setTypeOperandSourceInfo(
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001794 GetTypeSourceInfo());
John McCallfa194042011-07-15 07:00:14 +00001795 return;
1796 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001797
John McCallfa194042011-07-15 07:00:14 +00001798 // __uuidof(expr)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001799 E->setExprOperand(Record.readSubExpr());
John McCallfa194042011-07-15 07:00:14 +00001800}
1801
Nico Weber9b982072014-07-07 00:12:30 +00001802void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1803 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001804 S->setLeaveLoc(ReadSourceLocation());
Nico Weber9b982072014-07-07 00:12:30 +00001805}
1806
John McCallfa194042011-07-15 07:00:14 +00001807void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1808 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001809 S->Loc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001810 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
1811 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001812}
1813
1814void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1815 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001816 S->Loc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001817 S->Block = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001818}
1819
1820void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1821 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001822 S->IsCXXTry = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001823 S->TryLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001824 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
1825 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001826}
1827
1828//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00001829// CUDA Expressions and Statements
1830//===----------------------------------------------------------------------===//
1831
1832void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1833 VisitCallExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001834 E->setConfig(cast<CallExpr>(Record.readSubExpr()));
Peter Collingbourne41f85462011-02-09 21:07:24 +00001835}
1836
John McCallfa194042011-07-15 07:00:14 +00001837//===----------------------------------------------------------------------===//
1838// OpenCL Expressions and Statements.
1839//===----------------------------------------------------------------------===//
1840void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1841 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001842 E->BuiltinLoc = ReadSourceLocation();
1843 E->RParenLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001844 E->SrcExpr = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00001845}
1846
1847//===----------------------------------------------------------------------===//
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001848// OpenMP Directives.
1849//===----------------------------------------------------------------------===//
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001850
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001851void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001852 E->setLocStart(ReadSourceLocation());
1853 E->setLocEnd(ReadSourceLocation());
Kelvin Libe286f52018-09-15 13:54:15 +00001854 OMPClauseReader ClauseReader(Record);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001855 SmallVector<OMPClause *, 5> Clauses;
1856 for (unsigned i = 0; i < E->getNumClauses(); ++i)
1857 Clauses.push_back(ClauseReader.readClause());
1858 E->setClauses(Clauses);
Alexey Bataev68446b72014-07-18 07:47:19 +00001859 if (E->hasAssociatedStmt())
David L. Jonesb6a8f022016-12-21 04:34:52 +00001860 E->setAssociatedStmt(Record.readSubStmt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001861}
1862
Alexander Musman3aaab662014-08-19 11:27:13 +00001863void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
1864 VisitStmt(D);
1865 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001866 Record.skipInts(2);
Alexander Musman3aaab662014-08-19 11:27:13 +00001867 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001868 D->setIterationVariable(Record.readSubExpr());
1869 D->setLastIteration(Record.readSubExpr());
1870 D->setCalcLastIteration(Record.readSubExpr());
1871 D->setPreCond(Record.readSubExpr());
1872 D->setCond(Record.readSubExpr());
1873 D->setInit(Record.readSubExpr());
1874 D->setInc(Record.readSubExpr());
1875 D->setPreInits(Record.readSubStmt());
Alexey Bataev3392d762016-02-16 11:18:12 +00001876 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
Carlo Bertollifc35ad22016-03-07 16:04:49 +00001877 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
1878 isOpenMPDistributeDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001879 D->setIsLastIterVariable(Record.readSubExpr());
1880 D->setLowerBoundVariable(Record.readSubExpr());
1881 D->setUpperBoundVariable(Record.readSubExpr());
1882 D->setStrideVariable(Record.readSubExpr());
1883 D->setEnsureUpperBound(Record.readSubExpr());
1884 D->setNextLowerBound(Record.readSubExpr());
1885 D->setNextUpperBound(Record.readSubExpr());
1886 D->setNumIterations(Record.readSubExpr());
Alexander Musmanc6388682014-12-15 07:07:06 +00001887 }
Carlo Bertolli9925f152016-06-27 14:55:37 +00001888 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001889 D->setPrevLowerBoundVariable(Record.readSubExpr());
1890 D->setPrevUpperBoundVariable(Record.readSubExpr());
Carlo Bertolli8429d812017-02-17 21:29:13 +00001891 D->setDistInc(Record.readSubExpr());
1892 D->setPrevEnsureUpperBound(Record.readSubExpr());
Carlo Bertolliffafe102017-04-20 00:39:39 +00001893 D->setCombinedLowerBoundVariable(Record.readSubExpr());
1894 D->setCombinedUpperBoundVariable(Record.readSubExpr());
1895 D->setCombinedEnsureUpperBound(Record.readSubExpr());
1896 D->setCombinedInit(Record.readSubExpr());
1897 D->setCombinedCond(Record.readSubExpr());
1898 D->setCombinedNextLowerBound(Record.readSubExpr());
1899 D->setCombinedNextUpperBound(Record.readSubExpr());
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001900 D->setCombinedDistCond(Record.readSubExpr());
1901 D->setCombinedParForInDistCond(Record.readSubExpr());
Carlo Bertolli9925f152016-06-27 14:55:37 +00001902 }
Alexander Musmana5f070a2014-10-01 06:03:56 +00001903 SmallVector<Expr *, 4> Sub;
1904 unsigned CollapsedNum = D->getCollapsedNumber();
1905 Sub.reserve(CollapsedNum);
1906 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001907 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00001908 D->setCounters(Sub);
1909 Sub.clear();
1910 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001911 Sub.push_back(Record.readSubExpr());
Alexey Bataeva8899172015-08-06 12:30:57 +00001912 D->setPrivateCounters(Sub);
1913 Sub.clear();
1914 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001915 Sub.push_back(Record.readSubExpr());
Alexey Bataevb08f89f2015-08-14 12:25:37 +00001916 D->setInits(Sub);
1917 Sub.clear();
1918 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001919 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00001920 D->setUpdates(Sub);
1921 Sub.clear();
1922 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001923 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00001924 D->setFinals(Sub);
Alexander Musman3aaab662014-08-19 11:27:13 +00001925}
1926
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001927void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
Alexey Bataev1b59ab52014-02-27 08:29:12 +00001928 VisitStmt(D);
1929 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001930 Record.skipInts(1);
Alexey Bataev1b59ab52014-02-27 08:29:12 +00001931 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001932 D->setHasCancel(Record.readInt());
Alexey Bataev1b59ab52014-02-27 08:29:12 +00001933}
1934
1935void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00001936 VisitOMPLoopDirective(D);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001937}
1938
Alexey Bataevf29276e2014-06-18 04:14:57 +00001939void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00001940 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001941 D->setHasCancel(Record.readInt());
Alexey Bataevf29276e2014-06-18 04:14:57 +00001942}
1943
Alexander Musmanf82886e2014-09-18 05:12:34 +00001944void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
1945 VisitOMPLoopDirective(D);
1946}
1947
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00001948void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
1949 VisitStmt(D);
1950 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001951 Record.skipInts(1);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00001952 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001953 D->setHasCancel(Record.readInt());
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00001954}
1955
Alexey Bataev1e0498a2014-06-26 08:21:58 +00001956void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
1957 VisitStmt(D);
1958 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001959 D->setHasCancel(Record.readInt());
Alexey Bataev1e0498a2014-06-26 08:21:58 +00001960}
1961
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00001962void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
1963 VisitStmt(D);
1964 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001965 Record.skipInts(1);
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00001966 VisitOMPExecutableDirective(D);
1967}
1968
Alexander Musman80c22892014-07-17 08:54:58 +00001969void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
1970 VisitStmt(D);
1971 VisitOMPExecutableDirective(D);
1972}
1973
Alexander Musmand9ed09f2014-07-21 09:42:05 +00001974void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
1975 VisitStmt(D);
Alexey Bataev28c75412015-12-15 08:19:24 +00001976 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001977 Record.skipInts(1);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00001978 VisitOMPExecutableDirective(D);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001979 ReadDeclarationNameInfo(D->DirName);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00001980}
1981
Alexey Bataev4acb8592014-07-07 13:01:15 +00001982void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00001983 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001984 D->setHasCancel(Record.readInt());
Alexey Bataev4acb8592014-07-07 13:01:15 +00001985}
1986
Alexander Musmane4e893b2014-09-23 09:33:00 +00001987void ASTStmtReader::VisitOMPParallelForSimdDirective(
1988 OMPParallelForSimdDirective *D) {
1989 VisitOMPLoopDirective(D);
1990}
1991
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00001992void ASTStmtReader::VisitOMPParallelSectionsDirective(
1993 OMPParallelSectionsDirective *D) {
1994 VisitStmt(D);
1995 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001996 Record.skipInts(1);
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00001997 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001998 D->setHasCancel(Record.readInt());
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00001999}
2000
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002001void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2002 VisitStmt(D);
2003 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002004 Record.skipInts(1);
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002005 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002006 D->setHasCancel(Record.readInt());
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002007}
2008
Alexey Bataev68446b72014-07-18 07:47:19 +00002009void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2010 VisitStmt(D);
2011 VisitOMPExecutableDirective(D);
2012}
2013
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002014void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2015 VisitStmt(D);
2016 VisitOMPExecutableDirective(D);
2017}
2018
Alexey Bataev2df347a2014-07-18 10:17:07 +00002019void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2020 VisitStmt(D);
2021 VisitOMPExecutableDirective(D);
2022}
2023
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002024void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2025 VisitStmt(D);
Alexey Bataev169d96a2017-07-18 20:17:46 +00002026 // The NumClauses field was read in ReadStmtFromStream.
2027 Record.skipInts(1);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002028 VisitOMPExecutableDirective(D);
Alexey Bataev3b1b8952017-07-25 15:53:26 +00002029 D->setReductionRef(Record.readSubExpr());
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002030}
2031
Alexey Bataev6125da92014-07-21 11:26:11 +00002032void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2033 VisitStmt(D);
2034 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002035 Record.skipInts(1);
Alexey Bataev6125da92014-07-21 11:26:11 +00002036 VisitOMPExecutableDirective(D);
2037}
2038
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002039void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2040 VisitStmt(D);
Alexey Bataev346265e2015-09-25 10:37:12 +00002041 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002042 Record.skipInts(1);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002043 VisitOMPExecutableDirective(D);
2044}
2045
Alexey Bataev0162e452014-07-22 10:10:35 +00002046void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2047 VisitStmt(D);
2048 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002049 Record.skipInts(1);
Alexey Bataev0162e452014-07-22 10:10:35 +00002050 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002051 D->setX(Record.readSubExpr());
2052 D->setV(Record.readSubExpr());
2053 D->setExpr(Record.readSubExpr());
2054 D->setUpdateExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002055 D->IsXLHSInRHSPart = Record.readInt() != 0;
2056 D->IsPostfixUpdate = Record.readInt() != 0;
Alexey Bataev0162e452014-07-22 10:10:35 +00002057}
2058
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002059void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2060 VisitStmt(D);
2061 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002062 Record.skipInts(1);
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002063 VisitOMPExecutableDirective(D);
2064}
2065
Michael Wong65f367f2015-07-21 13:44:28 +00002066void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2067 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002068 Record.skipInts(1);
Michael Wong65f367f2015-07-21 13:44:28 +00002069 VisitOMPExecutableDirective(D);
2070}
2071
Samuel Antaodf67fc42016-01-19 19:15:56 +00002072void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2073 OMPTargetEnterDataDirective *D) {
2074 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002075 Record.skipInts(1);
Samuel Antaodf67fc42016-01-19 19:15:56 +00002076 VisitOMPExecutableDirective(D);
2077}
2078
Samuel Antao72590762016-01-19 20:04:50 +00002079void ASTStmtReader::VisitOMPTargetExitDataDirective(
2080 OMPTargetExitDataDirective *D) {
2081 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002082 Record.skipInts(1);
Samuel Antao72590762016-01-19 20:04:50 +00002083 VisitOMPExecutableDirective(D);
2084}
2085
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002086void ASTStmtReader::VisitOMPTargetParallelDirective(
2087 OMPTargetParallelDirective *D) {
2088 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002089 Record.skipInts(1);
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002090 VisitOMPExecutableDirective(D);
2091}
2092
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002093void ASTStmtReader::VisitOMPTargetParallelForDirective(
2094 OMPTargetParallelForDirective *D) {
2095 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002096 D->setHasCancel(Record.readInt());
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002097}
2098
Alexey Bataev13314bf2014-10-09 04:18:56 +00002099void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2100 VisitStmt(D);
2101 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002102 Record.skipInts(1);
Alexey Bataev13314bf2014-10-09 04:18:56 +00002103 VisitOMPExecutableDirective(D);
2104}
2105
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002106void ASTStmtReader::VisitOMPCancellationPointDirective(
2107 OMPCancellationPointDirective *D) {
2108 VisitStmt(D);
2109 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002110 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002111}
2112
Alexey Bataev80909872015-07-02 11:25:17 +00002113void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2114 VisitStmt(D);
Alexey Bataev87933c72015-09-18 08:07:34 +00002115 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002116 Record.skipInts(1);
Alexey Bataev80909872015-07-02 11:25:17 +00002117 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002118 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev80909872015-07-02 11:25:17 +00002119}
2120
Alexey Bataev49f6e782015-12-01 04:18:41 +00002121void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2122 VisitOMPLoopDirective(D);
2123}
2124
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002125void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2126 VisitOMPLoopDirective(D);
2127}
2128
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002129void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2130 VisitOMPLoopDirective(D);
2131}
2132
Samuel Antao686c70c2016-05-26 17:30:50 +00002133void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2134 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002135 Record.skipInts(1);
Samuel Antao686c70c2016-05-26 17:30:50 +00002136 VisitOMPExecutableDirective(D);
2137}
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002138
Carlo Bertolli9925f152016-06-27 14:55:37 +00002139void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2140 OMPDistributeParallelForDirective *D) {
2141 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002142 D->setHasCancel(Record.readInt());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002143}
Samuel Antao686c70c2016-05-26 17:30:50 +00002144
Kelvin Li4a39add2016-07-05 05:00:15 +00002145void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2146 OMPDistributeParallelForSimdDirective *D) {
2147 VisitOMPLoopDirective(D);
2148}
2149
Kelvin Li787f3fc2016-07-06 04:45:38 +00002150void ASTStmtReader::VisitOMPDistributeSimdDirective(
2151 OMPDistributeSimdDirective *D) {
2152 VisitOMPLoopDirective(D);
2153}
2154
Kelvin Lia579b912016-07-14 02:54:56 +00002155void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2156 OMPTargetParallelForSimdDirective *D) {
2157 VisitOMPLoopDirective(D);
2158}
2159
Kelvin Li986330c2016-07-20 22:57:10 +00002160void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2161 VisitOMPLoopDirective(D);
2162}
2163
Kelvin Li02532872016-08-05 14:37:37 +00002164void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2165 OMPTeamsDistributeDirective *D) {
2166 VisitOMPLoopDirective(D);
2167}
2168
Kelvin Li4e325f72016-10-25 12:50:55 +00002169void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2170 OMPTeamsDistributeSimdDirective *D) {
2171 VisitOMPLoopDirective(D);
2172}
2173
Kelvin Li579e41c2016-11-30 23:51:03 +00002174void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2175 OMPTeamsDistributeParallelForSimdDirective *D) {
2176 VisitOMPLoopDirective(D);
2177}
2178
Kelvin Li7ade93f2016-12-09 03:24:30 +00002179void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2180 OMPTeamsDistributeParallelForDirective *D) {
2181 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002182 D->setHasCancel(Record.readInt());
Kelvin Li7ade93f2016-12-09 03:24:30 +00002183}
2184
Kelvin Libf594a52016-12-17 05:48:59 +00002185void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2186 VisitStmt(D);
2187 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002188 Record.skipInts(1);
Kelvin Libf594a52016-12-17 05:48:59 +00002189 VisitOMPExecutableDirective(D);
2190}
2191
Kelvin Li83c451e2016-12-25 04:52:54 +00002192void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2193 OMPTargetTeamsDistributeDirective *D) {
2194 VisitOMPLoopDirective(D);
2195}
2196
Kelvin Li80e8f562016-12-29 22:16:30 +00002197void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2198 OMPTargetTeamsDistributeParallelForDirective *D) {
2199 VisitOMPLoopDirective(D);
Alexey Bataev16e79882017-11-22 21:12:03 +00002200 D->setHasCancel(Record.readInt());
Kelvin Li80e8f562016-12-29 22:16:30 +00002201}
2202
Kelvin Li1851df52017-01-03 05:23:48 +00002203void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2204 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2205 VisitOMPLoopDirective(D);
2206}
2207
Kelvin Lida681182017-01-10 18:08:18 +00002208void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2209 OMPTargetTeamsDistributeSimdDirective *D) {
2210 VisitOMPLoopDirective(D);
2211}
2212
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002213//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002214// ASTReader Implementation
2215//===----------------------------------------------------------------------===//
2216
Douglas Gregorde3ef502011-11-30 23:21:26 +00002217Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002218 switch (ReadingKind) {
Richard Smith629ff362013-07-31 00:26:46 +00002219 case Read_None:
2220 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002221 case Read_Decl:
2222 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00002223 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002224 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002225 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002226 }
2227
2228 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002229}
2230
Douglas Gregorde3ef502011-11-30 23:21:26 +00002231Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00002232 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002233}
Chris Lattnere2437f42010-05-09 06:40:08 +00002234
Sebastian Redl2c499f62010-08-18 23:56:43 +00002235Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002236 return cast_or_null<Expr>(ReadSubStmt());
2237}
2238
Chris Lattnerf4262532009-04-27 05:41:06 +00002239// Within the bitstream, expressions are stored in Reverse Polish
2240// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002241// expression they are stored in. Subexpressions are stored from last to first.
2242// To evaluate expressions, we continue reading expressions and placing them on
2243// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00002244// stack. Evaluation terminates when we see a STMT_STOP record, and
2245// the single remaining expression on the stack is our result.
Douglas Gregorde3ef502011-11-30 23:21:26 +00002246Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002247 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00002248 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002249
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002250 // Map of offset to previously deserialized stmt. The offset points
George Burgess IV758cf9d2017-02-14 05:52:57 +00002251 // just after the stmt record.
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002252 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00002253
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002254#ifndef NDEBUG
2255 unsigned PrevNumStmts = StmtStack.size();
2256#endif
2257
David L. Jonesbe1557a2016-12-21 00:17:49 +00002258 ASTRecordReader Record(*this, F);
2259 ASTStmtReader Reader(Record, Cursor);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002260 Stmt::EmptyShell Empty;
2261
2262 while (true) {
Chris Lattner0e6c9402013-01-20 02:38:54 +00002263 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002264
Chris Lattner0e6c9402013-01-20 02:38:54 +00002265 switch (Entry.Kind) {
2266 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2267 case llvm::BitstreamEntry::Error:
2268 Error("malformed block record in AST file");
Craig Toppera13603a2014-05-22 05:54:18 +00002269 return nullptr;
Chris Lattner0e6c9402013-01-20 02:38:54 +00002270 case llvm::BitstreamEntry::EndBlock:
2271 goto Done;
2272 case llvm::BitstreamEntry::Record:
2273 // The interesting case.
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002274 break;
2275 }
2276
Richard Smithdbafb6c2017-06-29 23:23:46 +00002277 ASTContext &Context = getContext();
Craig Toppera13603a2014-05-22 05:54:18 +00002278 Stmt *S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002279 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002280 bool IsStmtReference = false;
David L. Jonesbe1557a2016-12-21 00:17:49 +00002281 switch ((StmtCode)Record.readRecord(Cursor, Entry.ID)) {
Sebastian Redl539c5062010-08-18 23:57:32 +00002282 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002283 Finished = true;
2284 break;
2285
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002286 case STMT_REF_PTR:
2287 IsStmtReference = true;
2288 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2289 "No stmt was recorded for this offset reference!");
David L. Jonesbe1557a2016-12-21 00:17:49 +00002290 S = StmtEntries[Record.readInt()];
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002291 break;
2292
Sebastian Redl539c5062010-08-18 23:57:32 +00002293 case STMT_NULL_PTR:
Craig Toppera13603a2014-05-22 05:54:18 +00002294 S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002295 break;
2296
Sebastian Redl539c5062010-08-18 23:57:32 +00002297 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002298 S = new (Context) NullStmt(Empty);
2299 break;
2300
Sebastian Redl539c5062010-08-18 23:57:32 +00002301 case STMT_COMPOUND:
Benjamin Kramer07420902017-12-24 16:24:20 +00002302 S = CompoundStmt::CreateEmpty(
2303 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002304 break;
2305
Sebastian Redl539c5062010-08-18 23:57:32 +00002306 case STMT_CASE:
Bruno Ricci5b30571752018-10-28 12:30:53 +00002307 S = CaseStmt::CreateEmpty(
2308 Context,
2309 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002310 break;
2311
Sebastian Redl539c5062010-08-18 23:57:32 +00002312 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002313 S = new (Context) DefaultStmt(Empty);
2314 break;
2315
Sebastian Redl539c5062010-08-18 23:57:32 +00002316 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002317 S = new (Context) LabelStmt(Empty);
2318 break;
2319
Richard Smithc202b282012-04-14 00:33:13 +00002320 case STMT_ATTRIBUTED:
Alexander Kornienko20f6fc62012-07-09 10:04:07 +00002321 S = AttributedStmt::CreateEmpty(
2322 Context,
2323 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smithc202b282012-04-14 00:33:13 +00002324 break;
2325
Sebastian Redl539c5062010-08-18 23:57:32 +00002326 case STMT_IF:
Bruno Riccib1cc94b2018-10-27 21:12:20 +00002327 S = IfStmt::CreateEmpty(
2328 Context,
2329 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2330 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2331 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002332 break;
2333
Sebastian Redl539c5062010-08-18 23:57:32 +00002334 case STMT_SWITCH:
Bruno Riccie2806f82018-10-29 16:12:37 +00002335 S = SwitchStmt::CreateEmpty(
2336 Context,
2337 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 0],
2338 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002339 break;
2340
Sebastian Redl539c5062010-08-18 23:57:32 +00002341 case STMT_WHILE:
Bruno Riccibacf7512018-10-30 13:42:41 +00002342 S = WhileStmt::CreateEmpty(
2343 Context,
2344 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 0]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002345 break;
2346
Sebastian Redl539c5062010-08-18 23:57:32 +00002347 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002348 S = new (Context) DoStmt(Empty);
2349 break;
Mike Stump11289f42009-09-09 15:08:12 +00002350
Sebastian Redl539c5062010-08-18 23:57:32 +00002351 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002352 S = new (Context) ForStmt(Empty);
2353 break;
2354
Sebastian Redl539c5062010-08-18 23:57:32 +00002355 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002356 S = new (Context) GotoStmt(Empty);
2357 break;
Mike Stump11289f42009-09-09 15:08:12 +00002358
Sebastian Redl539c5062010-08-18 23:57:32 +00002359 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002360 S = new (Context) IndirectGotoStmt(Empty);
2361 break;
2362
Sebastian Redl539c5062010-08-18 23:57:32 +00002363 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002364 S = new (Context) ContinueStmt(Empty);
2365 break;
2366
Sebastian Redl539c5062010-08-18 23:57:32 +00002367 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002368 S = new (Context) BreakStmt(Empty);
2369 break;
2370
Sebastian Redl539c5062010-08-18 23:57:32 +00002371 case STMT_RETURN:
Bruno Ricci023b1d12018-10-30 14:40:49 +00002372 S = ReturnStmt::CreateEmpty(
2373 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002374 break;
2375
Sebastian Redl539c5062010-08-18 23:57:32 +00002376 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002377 S = new (Context) DeclStmt(Empty);
2378 break;
2379
Chad Rosierde70e0e2012-08-25 00:11:56 +00002380 case STMT_GCCASM:
2381 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002382 break;
2383
Chad Rosiere30d4992012-08-24 23:51:02 +00002384 case STMT_MSASM:
2385 S = new (Context) MSAsmStmt(Empty);
2386 break;
2387
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002388 case STMT_CAPTURED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002389 S = CapturedStmt::CreateDeserialized(
2390 Context, Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002391 break;
2392
Bill Wendling7c44da22018-10-31 03:48:47 +00002393 case EXPR_CONSTANT:
2394 S = new (Context) ConstantExpr(Empty);
2395 break;
2396
Sebastian Redl539c5062010-08-18 23:57:32 +00002397 case EXPR_PREDEFINED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002398 S = PredefinedExpr::CreateEmpty(
2399 Context,
2400 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002401 break;
Mike Stump11289f42009-09-09 15:08:12 +00002402
Sebastian Redl539c5062010-08-18 23:57:32 +00002403 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002404 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00002405 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002406 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2407 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnara7945c982012-01-27 09:46:47 +00002408 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002409 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
John McCall113bee02012-03-10 09:33:50 +00002410 Record[ASTStmtReader::NumExprFields + 5] : 0);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002411 break;
Mike Stump11289f42009-09-09 15:08:12 +00002412
Sebastian Redl539c5062010-08-18 23:57:32 +00002413 case EXPR_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002414 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002415 break;
Mike Stump11289f42009-09-09 15:08:12 +00002416
Sebastian Redl539c5062010-08-18 23:57:32 +00002417 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002418 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002419 break;
Mike Stump11289f42009-09-09 15:08:12 +00002420
Sebastian Redl539c5062010-08-18 23:57:32 +00002421 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002422 S = new (Context) ImaginaryLiteral(Empty);
2423 break;
2424
Sebastian Redl539c5062010-08-18 23:57:32 +00002425 case EXPR_STRING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002426 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002427 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002428 break;
2429
Sebastian Redl539c5062010-08-18 23:57:32 +00002430 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002431 S = new (Context) CharacterLiteral(Empty);
2432 break;
2433
Sebastian Redl539c5062010-08-18 23:57:32 +00002434 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002435 S = new (Context) ParenExpr(Empty);
2436 break;
2437
Sebastian Redl539c5062010-08-18 23:57:32 +00002438 case EXPR_PAREN_LIST:
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00002439 S = new (Context) ParenListExpr(Empty);
2440 break;
2441
Sebastian Redl539c5062010-08-18 23:57:32 +00002442 case EXPR_UNARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002443 S = new (Context) UnaryOperator(Empty);
2444 break;
2445
Sebastian Redl539c5062010-08-18 23:57:32 +00002446 case EXPR_OFFSETOF:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002447 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002448 Record[ASTStmtReader::NumExprFields],
2449 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00002450 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002451
Sebastian Redl539c5062010-08-18 23:57:32 +00002452 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00002453 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002454 break;
2455
Sebastian Redl539c5062010-08-18 23:57:32 +00002456 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002457 S = new (Context) ArraySubscriptExpr(Empty);
2458 break;
2459
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002460 case EXPR_OMP_ARRAY_SECTION:
2461 S = new (Context) OMPArraySectionExpr(Empty);
2462 break;
2463
Sebastian Redl539c5062010-08-18 23:57:32 +00002464 case EXPR_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002465 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002466 break;
2467
Sebastian Redl539c5062010-08-18 23:57:32 +00002468 case EXPR_MEMBER: {
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002469 // We load everything here and fully initialize it at creation.
2470 // That way we can use MemberExpr::Create and don't have to duplicate its
2471 // logic with a MemberExpr::CreateEmpty.
2472
David L. Jonesbe1557a2016-12-21 00:17:49 +00002473 assert(Record.getIdx() == 0);
Douglas Gregorea972d32011-02-28 21:54:11 +00002474 NestedNameSpecifierLoc QualifierLoc;
David L. Jonesbe1557a2016-12-21 00:17:49 +00002475 if (Record.readInt()) { // HasQualifier.
David L. Jonesb6a8f022016-12-21 04:34:52 +00002476 QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002477 }
2478
Abramo Bagnara7945c982012-01-27 09:46:47 +00002479 SourceLocation TemplateKWLoc;
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002480 TemplateArgumentListInfo ArgInfo;
David L. Jonesbe1557a2016-12-21 00:17:49 +00002481 bool HasTemplateKWAndArgsInfo = Record.readInt();
Abramo Bagnara7945c982012-01-27 09:46:47 +00002482 if (HasTemplateKWAndArgsInfo) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002483 TemplateKWLoc = Record.readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002484 unsigned NumTemplateArgs = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002485 ArgInfo.setLAngleLoc(Record.readSourceLocation());
2486 ArgInfo.setRAngleLoc(Record.readSourceLocation());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002487 for (unsigned i = 0; i != NumTemplateArgs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002488 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002489 }
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00002490
David L. Jonesbe1557a2016-12-21 00:17:49 +00002491 bool HadMultipleCandidates = Record.readInt();
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00002492
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002493 auto *FoundD = Record.readDeclAs<NamedDecl>();
2494 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002495 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
2496
David L. Jonesbe1557a2016-12-21 00:17:49 +00002497 QualType T = Record.readType();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002498 auto VK = static_cast<ExprValueKind>(Record.readInt());
2499 auto OK = static_cast<ExprObjectKind>(Record.readInt());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002500 Expr *Base = ReadSubExpr();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002501 auto *MemberD = Record.readDeclAs<ValueDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002502 SourceLocation MemberLoc = Record.readSourceLocation();
Yunzhong Gaoeba323a2015-05-01 02:04:32 +00002503 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002504 bool IsArrow = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002505 SourceLocation OperatorLoc = Record.readSourceLocation();
Yunzhong Gaoeba323a2015-05-01 02:04:32 +00002506
2507 S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc,
2508 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
2509 HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T,
2510 VK, OK);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002511 Record.readDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc,
David L. Jonesbe1557a2016-12-21 00:17:49 +00002512 MemberD->getDeclName());
Yunzhong Gaoeba323a2015-05-01 02:04:32 +00002513 if (HadMultipleCandidates)
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00002514 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002515 break;
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002516 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002517
Sebastian Redl539c5062010-08-18 23:57:32 +00002518 case EXPR_BINARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002519 S = new (Context) BinaryOperator(Empty);
2520 break;
2521
Sebastian Redl539c5062010-08-18 23:57:32 +00002522 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002523 S = new (Context) CompoundAssignOperator(Empty);
2524 break;
2525
Sebastian Redl539c5062010-08-18 23:57:32 +00002526 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002527 S = new (Context) ConditionalOperator(Empty);
2528 break;
2529
John McCallc07a0c72011-02-17 10:25:35 +00002530 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2531 S = new (Context) BinaryConditionalOperator(Empty);
2532 break;
2533
Sebastian Redl539c5062010-08-18 23:57:32 +00002534 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002535 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002536 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002537 break;
2538
Sebastian Redl539c5062010-08-18 23:57:32 +00002539 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002540 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002541 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002542 break;
2543
Sebastian Redl539c5062010-08-18 23:57:32 +00002544 case EXPR_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002545 S = new (Context) CompoundLiteralExpr(Empty);
2546 break;
2547
Sebastian Redl539c5062010-08-18 23:57:32 +00002548 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002549 S = new (Context) ExtVectorElementExpr(Empty);
2550 break;
2551
Sebastian Redl539c5062010-08-18 23:57:32 +00002552 case EXPR_INIT_LIST:
Argyrios Kyrtzidis0f05fb92012-11-28 03:56:16 +00002553 S = new (Context) InitListExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002554 break;
2555
Sebastian Redl539c5062010-08-18 23:57:32 +00002556 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002557 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002558 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00002559
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002560 break;
2561
Yunzhong Gaocb779302015-06-10 00:27:52 +00002562 case EXPR_DESIGNATED_INIT_UPDATE:
2563 S = new (Context) DesignatedInitUpdateExpr(Empty);
2564 break;
2565
Sebastian Redl539c5062010-08-18 23:57:32 +00002566 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002567 S = new (Context) ImplicitValueInitExpr(Empty);
2568 break;
2569
Yunzhong Gaocb779302015-06-10 00:27:52 +00002570 case EXPR_NO_INIT:
2571 S = new (Context) NoInitExpr(Empty);
2572 break;
2573
Richard Smith410306b2016-12-12 02:53:20 +00002574 case EXPR_ARRAY_INIT_LOOP:
2575 S = new (Context) ArrayInitLoopExpr(Empty);
2576 break;
2577
2578 case EXPR_ARRAY_INIT_INDEX:
2579 S = new (Context) ArrayInitIndexExpr(Empty);
2580 break;
2581
Sebastian Redl539c5062010-08-18 23:57:32 +00002582 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002583 S = new (Context) VAArgExpr(Empty);
2584 break;
2585
Sebastian Redl539c5062010-08-18 23:57:32 +00002586 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002587 S = new (Context) AddrLabelExpr(Empty);
2588 break;
2589
Sebastian Redl539c5062010-08-18 23:57:32 +00002590 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002591 S = new (Context) StmtExpr(Empty);
2592 break;
2593
Sebastian Redl539c5062010-08-18 23:57:32 +00002594 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002595 S = new (Context) ChooseExpr(Empty);
2596 break;
2597
Sebastian Redl539c5062010-08-18 23:57:32 +00002598 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002599 S = new (Context) GNUNullExpr(Empty);
2600 break;
2601
Sebastian Redl539c5062010-08-18 23:57:32 +00002602 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002603 S = new (Context) ShuffleVectorExpr(Empty);
2604 break;
Mike Stump11289f42009-09-09 15:08:12 +00002605
Hal Finkelc4d7c822013-09-18 03:29:45 +00002606 case EXPR_CONVERT_VECTOR:
2607 S = new (Context) ConvertVectorExpr(Empty);
2608 break;
2609
Sebastian Redl539c5062010-08-18 23:57:32 +00002610 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002611 S = new (Context) BlockExpr(Empty);
2612 break;
2613
Peter Collingbourne91147592011-04-15 00:35:48 +00002614 case EXPR_GENERIC_SELECTION:
2615 S = new (Context) GenericSelectionExpr(Empty);
2616 break;
2617
Sebastian Redl539c5062010-08-18 23:57:32 +00002618 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002619 S = new (Context) ObjCStringLiteral(Empty);
2620 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002621
Patrick Beard0caa3942012-04-19 00:25:12 +00002622 case EXPR_OBJC_BOXED_EXPRESSION:
2623 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremeneke65b0862012-03-06 20:05:56 +00002624 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002625
Ted Kremeneke65b0862012-03-06 20:05:56 +00002626 case EXPR_OBJC_ARRAY_LITERAL:
2627 S = ObjCArrayLiteral::CreateEmpty(Context,
2628 Record[ASTStmtReader::NumExprFields]);
2629 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002630
Ted Kremeneke65b0862012-03-06 20:05:56 +00002631 case EXPR_OBJC_DICTIONARY_LITERAL:
2632 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2633 Record[ASTStmtReader::NumExprFields],
2634 Record[ASTStmtReader::NumExprFields + 1]);
2635 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002636
Sebastian Redl539c5062010-08-18 23:57:32 +00002637 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002638 S = new (Context) ObjCEncodeExpr(Empty);
2639 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002640
Sebastian Redl539c5062010-08-18 23:57:32 +00002641 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002642 S = new (Context) ObjCSelectorExpr(Empty);
2643 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002644
Sebastian Redl539c5062010-08-18 23:57:32 +00002645 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002646 S = new (Context) ObjCProtocolExpr(Empty);
2647 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002648
Sebastian Redl539c5062010-08-18 23:57:32 +00002649 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002650 S = new (Context) ObjCIvarRefExpr(Empty);
2651 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002652
Sebastian Redl539c5062010-08-18 23:57:32 +00002653 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002654 S = new (Context) ObjCPropertyRefExpr(Empty);
2655 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002656
Ted Kremeneke65b0862012-03-06 20:05:56 +00002657 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2658 S = new (Context) ObjCSubscriptRefExpr(Empty);
2659 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002660
Sebastian Redl539c5062010-08-18 23:57:32 +00002661 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00002662 llvm_unreachable("mismatching AST file");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002663
Sebastian Redl539c5062010-08-18 23:57:32 +00002664 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002665 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00002666 Record[ASTStmtReader::NumExprFields],
2667 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002668 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002669
Sebastian Redl539c5062010-08-18 23:57:32 +00002670 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00002671 S = new (Context) ObjCIsaExpr(Empty);
2672 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002673
John McCall31168b02011-06-15 23:02:42 +00002674 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2675 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2676 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002677
John McCall31168b02011-06-15 23:02:42 +00002678 case EXPR_OBJC_BRIDGED_CAST:
2679 S = new (Context) ObjCBridgedCastExpr(Empty);
2680 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002681
Sebastian Redl539c5062010-08-18 23:57:32 +00002682 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002683 S = new (Context) ObjCForCollectionStmt(Empty);
2684 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002685
Sebastian Redl539c5062010-08-18 23:57:32 +00002686 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002687 S = new (Context) ObjCAtCatchStmt(Empty);
2688 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002689
Sebastian Redl539c5062010-08-18 23:57:32 +00002690 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002691 S = new (Context) ObjCAtFinallyStmt(Empty);
2692 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002693
Sebastian Redl539c5062010-08-18 23:57:32 +00002694 case STMT_OBJC_AT_TRY:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002695 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002696 Record[ASTStmtReader::NumStmtFields],
2697 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002698 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002699
Sebastian Redl539c5062010-08-18 23:57:32 +00002700 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002701 S = new (Context) ObjCAtSynchronizedStmt(Empty);
2702 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002703
Sebastian Redl539c5062010-08-18 23:57:32 +00002704 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002705 S = new (Context) ObjCAtThrowStmt(Empty);
2706 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002707
John McCall31168b02011-06-15 23:02:42 +00002708 case STMT_OBJC_AUTORELEASE_POOL:
2709 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2710 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002711
Ted Kremeneke65b0862012-03-06 20:05:56 +00002712 case EXPR_OBJC_BOOL_LITERAL:
2713 S = new (Context) ObjCBoolLiteralExpr(Empty);
2714 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002715
Erik Pilkington29099de2016-07-16 00:35:23 +00002716 case EXPR_OBJC_AVAILABILITY_CHECK:
2717 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
2718 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002719
Nico Weber9b982072014-07-07 00:12:30 +00002720 case STMT_SEH_LEAVE:
2721 S = new (Context) SEHLeaveStmt(Empty);
2722 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002723
John McCallfa194042011-07-15 07:00:14 +00002724 case STMT_SEH_EXCEPT:
2725 S = new (Context) SEHExceptStmt(Empty);
2726 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002727
John McCallfa194042011-07-15 07:00:14 +00002728 case STMT_SEH_FINALLY:
2729 S = new (Context) SEHFinallyStmt(Empty);
2730 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002731
John McCallfa194042011-07-15 07:00:14 +00002732 case STMT_SEH_TRY:
2733 S = new (Context) SEHTryStmt(Empty);
2734 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002735
Sebastian Redl539c5062010-08-18 23:57:32 +00002736 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00002737 S = new (Context) CXXCatchStmt(Empty);
2738 break;
2739
Sebastian Redl539c5062010-08-18 23:57:32 +00002740 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002741 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002742 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00002743 break;
2744
Richard Smith02e85f32011-04-14 22:09:26 +00002745 case STMT_CXX_FOR_RANGE:
2746 S = new (Context) CXXForRangeStmt(Empty);
2747 break;
2748
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00002749 case STMT_MS_DEPENDENT_EXISTS:
2750 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2751 NestedNameSpecifierLoc(),
2752 DeclarationNameInfo(),
Craig Toppera13603a2014-05-22 05:54:18 +00002753 nullptr);
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00002754 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002755
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002756 case STMT_OMP_PARALLEL_DIRECTIVE:
2757 S =
2758 OMPParallelDirective::CreateEmpty(Context,
2759 Record[ASTStmtReader::NumStmtFields],
2760 Empty);
2761 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002762
2763 case STMT_OMP_SIMD_DIRECTIVE: {
2764 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2765 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2766 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
2767 CollapsedNum, Empty);
2768 break;
2769 }
2770
Alexey Bataevf29276e2014-06-18 04:14:57 +00002771 case STMT_OMP_FOR_DIRECTIVE: {
2772 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2773 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2774 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2775 Empty);
2776 break;
2777 }
2778
Alexander Musmanf82886e2014-09-18 05:12:34 +00002779 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
2780 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2781 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2782 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2783 Empty);
2784 break;
2785 }
2786
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002787 case STMT_OMP_SECTIONS_DIRECTIVE:
2788 S = OMPSectionsDirective::CreateEmpty(
2789 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2790 break;
2791
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002792 case STMT_OMP_SECTION_DIRECTIVE:
2793 S = OMPSectionDirective::CreateEmpty(Context, Empty);
2794 break;
2795
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002796 case STMT_OMP_SINGLE_DIRECTIVE:
2797 S = OMPSingleDirective::CreateEmpty(
2798 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2799 break;
2800
Alexander Musman80c22892014-07-17 08:54:58 +00002801 case STMT_OMP_MASTER_DIRECTIVE:
2802 S = OMPMasterDirective::CreateEmpty(Context, Empty);
2803 break;
2804
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002805 case STMT_OMP_CRITICAL_DIRECTIVE:
Alexey Bataev28c75412015-12-15 08:19:24 +00002806 S = OMPCriticalDirective::CreateEmpty(
2807 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002808 break;
2809
Alexey Bataev4acb8592014-07-07 13:01:15 +00002810 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
2811 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2812 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2813 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
2814 CollapsedNum, Empty);
2815 break;
2816 }
2817
Alexander Musmane4e893b2014-09-23 09:33:00 +00002818 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
2819 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2820 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2821 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2822 CollapsedNum, Empty);
2823 break;
2824 }
2825
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002826 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
2827 S = OMPParallelSectionsDirective::CreateEmpty(
2828 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2829 break;
2830
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002831 case STMT_OMP_TASK_DIRECTIVE:
2832 S = OMPTaskDirective::CreateEmpty(
2833 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2834 break;
2835
Alexey Bataev68446b72014-07-18 07:47:19 +00002836 case STMT_OMP_TASKYIELD_DIRECTIVE:
2837 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
2838 break;
2839
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002840 case STMT_OMP_BARRIER_DIRECTIVE:
2841 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
2842 break;
2843
Alexey Bataev2df347a2014-07-18 10:17:07 +00002844 case STMT_OMP_TASKWAIT_DIRECTIVE:
2845 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
2846 break;
2847
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002848 case STMT_OMP_TASKGROUP_DIRECTIVE:
Alexey Bataev169d96a2017-07-18 20:17:46 +00002849 S = OMPTaskgroupDirective::CreateEmpty(
2850 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002851 break;
2852
Alexey Bataev6125da92014-07-21 11:26:11 +00002853 case STMT_OMP_FLUSH_DIRECTIVE:
2854 S = OMPFlushDirective::CreateEmpty(
2855 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2856 break;
2857
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002858 case STMT_OMP_ORDERED_DIRECTIVE:
Alexey Bataev346265e2015-09-25 10:37:12 +00002859 S = OMPOrderedDirective::CreateEmpty(
2860 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002861 break;
2862
Alexey Bataev0162e452014-07-22 10:10:35 +00002863 case STMT_OMP_ATOMIC_DIRECTIVE:
2864 S = OMPAtomicDirective::CreateEmpty(
2865 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2866 break;
2867
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002868 case STMT_OMP_TARGET_DIRECTIVE:
2869 S = OMPTargetDirective::CreateEmpty(
2870 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2871 break;
2872
Michael Wong65f367f2015-07-21 13:44:28 +00002873 case STMT_OMP_TARGET_DATA_DIRECTIVE:
2874 S = OMPTargetDataDirective::CreateEmpty(
2875 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2876 break;
2877
Samuel Antaodf67fc42016-01-19 19:15:56 +00002878 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
2879 S = OMPTargetEnterDataDirective::CreateEmpty(
2880 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2881 break;
2882
Samuel Antao72590762016-01-19 20:04:50 +00002883 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
2884 S = OMPTargetExitDataDirective::CreateEmpty(
2885 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2886 break;
2887
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002888 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
2889 S = OMPTargetParallelDirective::CreateEmpty(
2890 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2891 break;
2892
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002893 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
2894 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2895 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2896 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
2897 CollapsedNum, Empty);
2898 break;
2899 }
2900
Samuel Antao686c70c2016-05-26 17:30:50 +00002901 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
2902 S = OMPTargetUpdateDirective::CreateEmpty(
2903 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2904 break;
2905
Alexey Bataev13314bf2014-10-09 04:18:56 +00002906 case STMT_OMP_TEAMS_DIRECTIVE:
2907 S = OMPTeamsDirective::CreateEmpty(
2908 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2909 break;
2910
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002911 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
2912 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
2913 break;
2914
Alexey Bataev80909872015-07-02 11:25:17 +00002915 case STMT_OMP_CANCEL_DIRECTIVE:
Alexey Bataev87933c72015-09-18 08:07:34 +00002916 S = OMPCancelDirective::CreateEmpty(
2917 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev80909872015-07-02 11:25:17 +00002918 break;
2919
Alexey Bataev49f6e782015-12-01 04:18:41 +00002920 case STMT_OMP_TASKLOOP_DIRECTIVE: {
2921 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2922 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2923 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2924 Empty);
2925 break;
2926 }
2927
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002928 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
2929 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2930 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2931 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
2932 CollapsedNum, Empty);
2933 break;
2934 }
2935
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002936 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
2937 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2938 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2939 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2940 Empty);
2941 break;
2942 }
2943
Carlo Bertolli9925f152016-06-27 14:55:37 +00002944 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
2945 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2946 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2947 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
2948 CollapsedNum, Empty);
2949 break;
2950 }
2951
Kelvin Li4a39add2016-07-05 05:00:15 +00002952 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
2953 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2954 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2955 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2956 CollapsedNum,
2957 Empty);
2958 break;
2959 }
2960
Kelvin Li787f3fc2016-07-06 04:45:38 +00002961 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
2962 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2963 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2964 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
2965 CollapsedNum, Empty);
2966 break;
2967 }
2968
Kelvin Lia579b912016-07-14 02:54:56 +00002969 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
2970 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2971 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2972 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2973 CollapsedNum, Empty);
2974 break;
2975 }
2976
Kelvin Li986330c2016-07-20 22:57:10 +00002977 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
2978 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2979 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2980 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2981 Empty);
2982 break;
2983 }
2984
Kelvin Li83c451e2016-12-25 04:52:54 +00002985 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
Kelvin Li02532872016-08-05 14:37:37 +00002986 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2987 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2988 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
2989 CollapsedNum, Empty);
2990 break;
2991 }
2992
Kelvin Li4e325f72016-10-25 12:50:55 +00002993 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
2994 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2995 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2996 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
2997 CollapsedNum, Empty);
2998 break;
2999 }
3000
Kelvin Li579e41c2016-11-30 23:51:03 +00003001 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3002 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3003 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3004 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3005 Context, NumClauses, CollapsedNum, Empty);
3006 break;
3007 }
3008
Kelvin Li7ade93f2016-12-09 03:24:30 +00003009 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3010 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3011 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3012 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3013 Context, NumClauses, CollapsedNum, Empty);
3014 break;
3015 }
3016
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003017 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
Kelvin Libf594a52016-12-17 05:48:59 +00003018 S = OMPTargetTeamsDirective::CreateEmpty(
3019 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3020 break;
Kelvin Li83c451e2016-12-25 04:52:54 +00003021
3022 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3023 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3024 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3025 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3026 CollapsedNum, Empty);
3027 break;
3028 }
3029
Kelvin Li80e8f562016-12-29 22:16:30 +00003030 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3031 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3032 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3033 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3034 Context, NumClauses, CollapsedNum, Empty);
3035 break;
3036 }
3037
Kelvin Li1851df52017-01-03 05:23:48 +00003038 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3039 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3040 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3041 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3042 Context, NumClauses, CollapsedNum, Empty);
3043 break;
3044 }
3045
Kelvin Lida681182017-01-10 18:08:18 +00003046 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3047 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3048 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3049 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3050 Context, NumClauses, CollapsedNum, Empty);
3051 break;
3052 }
3053
Sebastian Redl539c5062010-08-18 23:57:32 +00003054 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003055 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00003056 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003057
Sebastian Redl539c5062010-08-18 23:57:32 +00003058 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003059 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003060 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003061
Sebastian Redl539c5062010-08-18 23:57:32 +00003062 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003063 S = new (Context) CXXConstructExpr(Empty);
3064 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003065
Richard Smith5179eb72016-06-28 19:03:57 +00003066 case EXPR_CXX_INHERITED_CTOR_INIT:
3067 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3068 break;
3069
Sebastian Redl539c5062010-08-18 23:57:32 +00003070 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003071 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00003072 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003073
Sebastian Redl539c5062010-08-18 23:57:32 +00003074 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003075 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003076 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003077 break;
3078
Sebastian Redl539c5062010-08-18 23:57:32 +00003079 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003080 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003081 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003082 break;
3083
Sebastian Redl539c5062010-08-18 23:57:32 +00003084 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003085 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003086 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003087 break;
3088
Sebastian Redl539c5062010-08-18 23:57:32 +00003089 case EXPR_CXX_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003090 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00003091 break;
3092
Sebastian Redl539c5062010-08-18 23:57:32 +00003093 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003094 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003095 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003096 break;
3097
Richard Smithc67fdd42012-03-07 08:35:16 +00003098 case EXPR_USER_DEFINED_LITERAL:
3099 S = new (Context) UserDefinedLiteral(Context, Empty);
3100 break;
3101
Richard Smithcc1b96d2013-06-12 22:31:48 +00003102 case EXPR_CXX_STD_INITIALIZER_LIST:
3103 S = new (Context) CXXStdInitializerListExpr(Empty);
3104 break;
3105
Sebastian Redl539c5062010-08-18 23:57:32 +00003106 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003107 S = new (Context) CXXBoolLiteralExpr(Empty);
3108 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003109
Sebastian Redl539c5062010-08-18 23:57:32 +00003110 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003111 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3112 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003113
Sebastian Redl539c5062010-08-18 23:57:32 +00003114 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003115 S = new (Context) CXXTypeidExpr(Empty, true);
3116 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003117
Sebastian Redl539c5062010-08-18 23:57:32 +00003118 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003119 S = new (Context) CXXTypeidExpr(Empty, false);
3120 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003121
Francois Pichet9f4f2072010-09-08 12:20:18 +00003122 case EXPR_CXX_UUIDOF_EXPR:
3123 S = new (Context) CXXUuidofExpr(Empty, true);
3124 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003125
John McCall5e77d762013-04-16 07:28:30 +00003126 case EXPR_CXX_PROPERTY_REF_EXPR:
3127 S = new (Context) MSPropertyRefExpr(Empty);
3128 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003129
Alexey Bataevf7630272015-11-25 12:01:00 +00003130 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3131 S = new (Context) MSPropertySubscriptExpr(Empty);
3132 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003133
Francois Pichet9f4f2072010-09-08 12:20:18 +00003134 case EXPR_CXX_UUIDOF_TYPE:
3135 S = new (Context) CXXUuidofExpr(Empty, false);
3136 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003137
Sebastian Redl539c5062010-08-18 23:57:32 +00003138 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00003139 S = new (Context) CXXThisExpr(Empty);
3140 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003141
Sebastian Redl539c5062010-08-18 23:57:32 +00003142 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00003143 S = new (Context) CXXThrowExpr(Empty);
3144 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003145
John McCall32791cc2016-01-06 22:34:54 +00003146 case EXPR_CXX_DEFAULT_ARG:
3147 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00003148 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003149
Richard Smith852c9db2013-04-20 22:23:05 +00003150 case EXPR_CXX_DEFAULT_INIT:
3151 S = new (Context) CXXDefaultInitExpr(Empty);
3152 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003153
Sebastian Redl539c5062010-08-18 23:57:32 +00003154 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00003155 S = new (Context) CXXBindTemporaryExpr(Empty);
3156 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003157
Sebastian Redl539c5062010-08-18 23:57:32 +00003158 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00003159 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003160 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003161
Sebastian Redl539c5062010-08-18 23:57:32 +00003162 case EXPR_CXX_NEW:
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003163 S = new (Context) CXXNewExpr(Empty);
3164 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003165
Sebastian Redl539c5062010-08-18 23:57:32 +00003166 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00003167 S = new (Context) CXXDeleteExpr(Empty);
3168 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003169
Sebastian Redl539c5062010-08-18 23:57:32 +00003170 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00003171 S = new (Context) CXXPseudoDestructorExpr(Empty);
3172 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003173
John McCall5d413782010-12-06 08:20:24 +00003174 case EXPR_EXPR_WITH_CLEANUPS:
John McCall28fc7092011-11-10 05:35:25 +00003175 S = ExprWithCleanups::Create(Context, Empty,
3176 Record[ASTStmtReader::NumExprFields]);
Chris Lattnercba86142010-05-10 00:25:06 +00003177 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003178
Sebastian Redl539c5062010-08-18 23:57:32 +00003179 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003180 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003181 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003182 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003183 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003184 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003185 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003186
Sebastian Redl539c5062010-08-18 23:57:32 +00003187 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003188 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003189 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003190 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003191 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003192 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00003193 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003194
Sebastian Redl539c5062010-08-18 23:57:32 +00003195 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003196 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003197 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00003198 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003199
Sebastian Redl539c5062010-08-18 23:57:32 +00003200 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003201 S = UnresolvedMemberExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003202 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003203 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003204 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003205 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003206 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003207
Sebastian Redl539c5062010-08-18 23:57:32 +00003208 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003209 S = UnresolvedLookupExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003210 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003211 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003212 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003213 : 0);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00003214 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003215
Douglas Gregor29c42f22012-02-24 07:38:34 +00003216 case EXPR_TYPE_TRAIT:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003217 S = TypeTraitExpr::CreateDeserialized(Context,
Douglas Gregor29c42f22012-02-24 07:38:34 +00003218 Record[ASTStmtReader::NumExprFields]);
3219 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003220
John Wiegley6242b6a2011-04-28 00:16:57 +00003221 case EXPR_ARRAY_TYPE_TRAIT:
3222 S = new (Context) ArrayTypeTraitExpr(Empty);
3223 break;
3224
John Wiegleyf9f65842011-04-25 06:54:41 +00003225 case EXPR_CXX_EXPRESSION_TRAIT:
3226 S = new (Context) ExpressionTraitExpr(Empty);
3227 break;
3228
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003229 case EXPR_CXX_NOEXCEPT:
3230 S = new (Context) CXXNoexceptExpr(Empty);
3231 break;
John McCall8d69a212010-11-15 23:31:06 +00003232
Douglas Gregore8e9dd62011-01-03 17:17:50 +00003233 case EXPR_PACK_EXPANSION:
3234 S = new (Context) PackExpansionExpr(Empty);
3235 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003236
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003237 case EXPR_SIZEOF_PACK:
Richard Smithd784e682015-09-23 21:41:42 +00003238 S = SizeOfPackExpr::CreateDeserialized(
3239 Context,
3240 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003241 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003242
John McCallfa194042011-07-15 07:00:14 +00003243 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3244 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3245 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003246
Douglas Gregorcdbc5392011-01-15 01:15:58 +00003247 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3248 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3249 break;
Richard Smithb15fe3a2012-09-12 00:56:43 +00003250
3251 case EXPR_FUNCTION_PARM_PACK:
3252 S = FunctionParmPackExpr::CreateEmpty(Context,
3253 Record[ASTStmtReader::NumExprFields]);
3254 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003255
Douglas Gregorfe314812011-06-21 17:03:29 +00003256 case EXPR_MATERIALIZE_TEMPORARY:
3257 S = new (Context) MaterializeTemporaryExpr(Empty);
3258 break;
Richard Smith0f0af192014-11-08 05:07:16 +00003259
3260 case EXPR_CXX_FOLD:
3261 S = new (Context) CXXFoldExpr(Empty);
3262 break;
3263
Argyrios Kyrtzidisb2b07952011-12-03 03:49:52 +00003264 case EXPR_OPAQUE_VALUE:
3265 S = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00003266 break;
Peter Collingbourne41f85462011-02-09 21:07:24 +00003267
3268 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003269 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00003270 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003271
Tanya Lattner55808c12011-06-04 00:47:47 +00003272 case EXPR_ASTYPE:
3273 S = new (Context) AsTypeExpr(Empty);
3274 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003275
John McCallfe96e0b2011-11-06 09:01:30 +00003276 case EXPR_PSEUDO_OBJECT: {
3277 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3278 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3279 break;
3280 }
3281
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003282 case EXPR_ATOMIC:
3283 S = new (Context) AtomicExpr(Empty);
3284 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003285
Douglas Gregor99ae8062012-02-14 17:54:36 +00003286 case EXPR_LAMBDA: {
3287 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
Richard Smith30e304e2016-12-14 00:03:17 +00003288 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
Douglas Gregor99ae8062012-02-14 17:54:36 +00003289 break;
3290 }
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +00003291
3292 case STMT_COROUTINE_BODY: {
3293 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3294 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3295 break;
3296 }
3297
3298 case STMT_CORETURN:
3299 S = new (Context) CoreturnStmt(Empty);
3300 break;
3301
3302 case EXPR_COAWAIT:
3303 S = new (Context) CoawaitExpr(Empty);
3304 break;
3305
3306 case EXPR_COYIELD:
3307 S = new (Context) CoyieldExpr(Empty);
3308 break;
3309
3310 case EXPR_DEPENDENT_COAWAIT:
3311 S = new (Context) DependentCoawaitExpr(Empty);
3312 break;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003313 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003314
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003315 // We hit a STMT_STOP, so we're done with this expression.
3316 if (Finished)
3317 break;
3318
3319 ++NumStatementsRead;
3320
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003321 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003322 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003323 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3324 }
3325
David L. Jonesbe1557a2016-12-21 00:17:49 +00003326 assert(Record.getIdx() == Record.size() &&
3327 "Invalid deserialization of statement");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003328 StmtStack.push_back(S);
3329 }
Chris Lattner0e6c9402013-01-20 02:38:54 +00003330Done:
Alp Toker028ed912013-12-06 17:56:43 +00003331 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003332 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003333 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003334}