blob: 3c63fe1143d2398500224177abc25157ae2f7534 [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);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000273 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
Douglas Gregor7fb09192011-07-21 22:35:25 +0000274
David L. Jonesb6a8f022016-12-21 04:34:52 +0000275 S->setCond(Record.readSubExpr());
276 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000277 S->setWhileLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000278}
279
Sebastian Redl70c751d2010-08-18 23:56:52 +0000280void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000281 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000282 S->setCond(Record.readSubExpr());
283 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000284 S->setDoLoc(ReadSourceLocation());
285 S->setWhileLoc(ReadSourceLocation());
286 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000287}
288
Sebastian Redl70c751d2010-08-18 23:56:52 +0000289void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000290 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000291 S->setInit(Record.readSubStmt());
292 S->setCond(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000293 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000294 S->setInc(Record.readSubExpr());
295 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000296 S->setForLoc(ReadSourceLocation());
297 S->setLParenLoc(ReadSourceLocation());
298 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000299}
300
Sebastian Redl70c751d2010-08-18 23:56:52 +0000301void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000302 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000303 S->setLabel(ReadDeclAs<LabelDecl>());
304 S->setGotoLoc(ReadSourceLocation());
305 S->setLabelLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000306}
307
Sebastian Redl70c751d2010-08-18 23:56:52 +0000308void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000309 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000310 S->setGotoLoc(ReadSourceLocation());
311 S->setStarLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000312 S->setTarget(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000313}
314
Sebastian Redl70c751d2010-08-18 23:56:52 +0000315void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000316 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000317 S->setContinueLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000318}
319
Sebastian Redl70c751d2010-08-18 23:56:52 +0000320void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000321 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000322 S->setBreakLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000323}
324
Sebastian Redl70c751d2010-08-18 23:56:52 +0000325void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000326 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000327 S->setRetValue(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000328 S->setReturnLoc(ReadSourceLocation());
329 S->setNRVOCandidate(ReadDeclAs<VarDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000330}
331
Sebastian Redl70c751d2010-08-18 23:56:52 +0000332void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000333 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000334 S->setStartLoc(ReadSourceLocation());
335 S->setEndLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000336
David L. Jonesbe1557a2016-12-21 00:17:49 +0000337 if (Record.size() - Record.getIdx() == 1) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000338 // Single declaration
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000339 S->setDeclGroup(DeclGroupRef(ReadDecl()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000340 } else {
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000341 SmallVector<Decl *, 16> Decls;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000342 int N = Record.size() - Record.getIdx();
343 Decls.reserve(N);
344 for (int I = 0; I < N; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000345 Decls.push_back(ReadDecl());
346 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
Douglas Gregor038c3382009-05-22 22:45:36 +0000347 Decls.data(),
348 Decls.size())));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000349 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000350}
351
John McCallf413f5e2013-05-03 00:10:13 +0000352void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000353 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000354 S->NumOutputs = Record.readInt();
355 S->NumInputs = Record.readInt();
356 S->NumClobbers = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000357 S->setAsmLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000358 S->setVolatile(Record.readInt());
359 S->setSimple(Record.readInt());
John McCallf413f5e2013-05-03 00:10:13 +0000360}
Mike Stump11289f42009-09-09 15:08:12 +0000361
John McCallf413f5e2013-05-03 00:10:13 +0000362void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
363 VisitAsmStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000364 S->setRParenLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000365 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000366
John McCallf413f5e2013-05-03 00:10:13 +0000367 unsigned NumOutputs = S->getNumOutputs();
368 unsigned NumInputs = S->getNumInputs();
369 unsigned NumClobbers = S->getNumClobbers();
370
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000371 // Outputs and inputs
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000372 SmallVector<IdentifierInfo *, 16> Names;
373 SmallVector<StringLiteral*, 16> Constraints;
374 SmallVector<Stmt*, 16> Exprs;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000375 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000376 Names.push_back(Record.getIdentifierInfo());
377 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
378 Exprs.push_back(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000379 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000380
381 // Constraints
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000382 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000383 for (unsigned I = 0; I != NumClobbers; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000384 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000385
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000386 S->setOutputsAndInputsAndClobbers(Record.getContext(),
387 Names.data(), Constraints.data(),
388 Exprs.data(), NumOutputs, NumInputs,
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000389 Clobbers.data(), NumClobbers);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000390}
391
Chad Rosier32503022012-06-11 20:47:18 +0000392void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
John McCallf413f5e2013-05-03 00:10:13 +0000393 VisitAsmStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000394 S->LBraceLoc = ReadSourceLocation();
395 S->EndLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000396 S->NumAsmToks = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000397 std::string AsmStr = ReadString();
John McCallf413f5e2013-05-03 00:10:13 +0000398
399 // Read the tokens.
400 SmallVector<Token, 16> AsmToks;
401 AsmToks.reserve(S->NumAsmToks);
402 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000403 AsmToks.push_back(Record.readToken());
John McCallf413f5e2013-05-03 00:10:13 +0000404 }
405
406 // The calls to reserve() for the FooData vectors are mandatory to
407 // prevent dead StringRefs in the Foo vectors.
408
409 // Read the clobbers.
410 SmallVector<std::string, 16> ClobbersData;
411 SmallVector<StringRef, 16> Clobbers;
412 ClobbersData.reserve(S->NumClobbers);
413 Clobbers.reserve(S->NumClobbers);
414 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000415 ClobbersData.push_back(ReadString());
John McCallf413f5e2013-05-03 00:10:13 +0000416 Clobbers.push_back(ClobbersData.back());
417 }
418
419 // Read the operands.
420 unsigned NumOperands = S->NumOutputs + S->NumInputs;
421 SmallVector<Expr*, 16> Exprs;
422 SmallVector<std::string, 16> ConstraintsData;
423 SmallVector<StringRef, 16> Constraints;
424 Exprs.reserve(NumOperands);
425 ConstraintsData.reserve(NumOperands);
426 Constraints.reserve(NumOperands);
427 for (unsigned i = 0; i != NumOperands; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000428 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000429 ConstraintsData.push_back(ReadString());
John McCallf413f5e2013-05-03 00:10:13 +0000430 Constraints.push_back(ConstraintsData.back());
431 }
432
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000433 S->initialize(Record.getContext(), AsmStr, AsmToks,
John McCallf413f5e2013-05-03 00:10:13 +0000434 Constraints, Exprs, Clobbers);
Chad Rosier32503022012-06-11 20:47:18 +0000435}
436
Richard Smith9f690bd2015-10-27 06:02:45 +0000437void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000438 VisitStmt(S);
439 assert(Record.peekInt() == S->NumParams);
440 Record.skipInts(1);
441 auto *StoredStmts = S->getStoredStmts();
442 for (unsigned i = 0;
443 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
444 StoredStmts[i] = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000445}
446
447void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000448 VisitStmt(S);
449 S->CoreturnLoc = Record.readSourceLocation();
450 for (auto &SubStmt: S->SubStmts)
451 SubStmt = Record.readSubStmt();
452 S->IsImplicit = Record.readInt() != 0;
Richard Smith9f690bd2015-10-27 06:02:45 +0000453}
454
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000455void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
456 VisitExpr(E);
457 E->KeywordLoc = ReadSourceLocation();
458 for (auto &SubExpr: E->SubExprs)
459 SubExpr = Record.readSubStmt();
460 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
461 E->setIsImplicit(Record.readInt() != 0);
Richard Smith9f690bd2015-10-27 06:02:45 +0000462}
463
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000464void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *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());
Eric Fiselier20f25cb2017-03-06 23:38:15 +0000470}
471
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000472void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
473 VisitExpr(E);
474 E->KeywordLoc = ReadSourceLocation();
475 for (auto &SubExpr: E->SubExprs)
476 SubExpr = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000477}
478
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000479void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
Ben Langmuirce914fc2013-05-03 19:20:19 +0000480 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000481 Record.skipInts(1);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000482 S->setCapturedDecl(ReadDeclAs<CapturedDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000483 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000484 S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000485
486 // Capture inits
487 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
488 E = S->capture_init_end();
489 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000490 *I = Record.readSubExpr();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000491
492 // Body
David L. Jonesb6a8f022016-12-21 04:34:52 +0000493 S->setCapturedStmt(Record.readSubStmt());
Wei Pan17fbf6e2013-05-04 03:59:06 +0000494 S->getCapturedDecl()->setBody(S->getCapturedStmt());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000495
496 // Captures
Aaron Ballmanc656303a2014-03-14 18:08:33 +0000497 for (auto &I : S->captures()) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000498 I.VarAndKind.setPointer(ReadDeclAs<VarDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000499 I.VarAndKind.setInt(
500 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000501 I.Loc = ReadSourceLocation();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000502 }
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000503}
504
Sebastian Redl70c751d2010-08-18 23:56:52 +0000505void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000506 VisitStmt(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000507 E->setType(Record.readType());
508 E->setTypeDependent(Record.readInt());
509 E->setValueDependent(Record.readInt());
510 E->setInstantiationDependent(Record.readInt());
511 E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
512 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
513 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
514 assert(Record.getIdx() == NumExprFields &&
515 "Incorrect expression field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000516}
517
Sebastian Redl70c751d2010-08-18 23:56:52 +0000518void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000519 VisitExpr(E);
Bruno Ricci17ff0262018-10-27 19:21:19 +0000520 bool HasFunctionName = Record.readInt();
521 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
522 E->PredefinedExprBits.Kind = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000523 E->setLocation(ReadSourceLocation());
Bruno Ricci17ff0262018-10-27 19:21:19 +0000524 if (HasFunctionName)
525 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000526}
527
Sebastian Redl70c751d2010-08-18 23:56:52 +0000528void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000529 VisitExpr(E);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000530
David L. Jonesbe1557a2016-12-21 00:17:49 +0000531 E->DeclRefExprBits.HasQualifier = Record.readInt();
532 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
533 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
534 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
535 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000536 unsigned NumTemplateArgs = 0;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000537 if (E->hasTemplateKWAndArgsInfo())
David L. Jonesbe1557a2016-12-21 00:17:49 +0000538 NumTemplateArgs = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000539
Chandler Carruth0e439962011-05-01 21:29:53 +0000540 if (E->hasQualifier())
James Y Knighte7d82282015-12-29 18:15:14 +0000541 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
David L. Jonesb6a8f022016-12-21 04:34:52 +0000542 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000543
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000544 if (E->hasFoundDecl())
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000545 *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000546
Abramo Bagnara7945c982012-01-27 09:46:47 +0000547 if (E->hasTemplateKWAndArgsInfo())
James Y Knighte7d82282015-12-29 18:15:14 +0000548 ReadTemplateKWAndArgsInfo(
549 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
550 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000551
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000552 E->setDecl(ReadDeclAs<ValueDecl>());
553 E->setLocation(ReadSourceLocation());
554 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000555}
556
Sebastian Redl70c751d2010-08-18 23:56:52 +0000557void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000558 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000559 E->setLocation(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000560 E->setValue(Record.getContext(), Record.readAPInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000561}
562
Leonard Chandb01c3a2018-06-20 17:19:40 +0000563void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
564 VisitExpr(E);
565 E->setLocation(ReadSourceLocation());
566 E->setValue(Record.getContext(), Record.readAPInt());
567}
568
Sebastian Redl70c751d2010-08-18 23:56:52 +0000569void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000570 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000571 E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record.readInt()));
572 E->setExact(Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000573 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000574 E->setLocation(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000575}
576
Sebastian Redl70c751d2010-08-18 23:56:52 +0000577void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000578 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000579 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000580}
581
Sebastian Redl70c751d2010-08-18 23:56:52 +0000582void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000583 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000584 unsigned Len = Record.readInt();
585 assert(Record.peekInt() == E->getNumConcatenated() &&
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000586 "Wrong number of concatenated tokens!");
David L. Jonesbe1557a2016-12-21 00:17:49 +0000587 Record.skipInts(1);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000588 auto kind = static_cast<StringLiteral::StringKind>(Record.readInt());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000589 bool isPascal = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000590
Mike Stump11289f42009-09-09 15:08:12 +0000591 // Read string data
David L. Jonesbe1557a2016-12-21 00:17:49 +0000592 auto B = &Record.peekInt();
593 SmallString<16> Str(B, B + Len);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000594 E->setString(Record.getContext(), Str, kind, isPascal);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000595 Record.skipInts(Len);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000596
597 // Read source locations
598 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000599 E->setStrTokenLoc(I, ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000600}
601
Sebastian Redl70c751d2010-08-18 23:56:52 +0000602void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000603 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000604 E->setValue(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000605 E->setLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000606 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000607}
608
Sebastian Redl70c751d2010-08-18 23:56:52 +0000609void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000610 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000611 E->setLParen(ReadSourceLocation());
612 E->setRParen(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000613 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000614}
615
Sebastian Redl70c751d2010-08-18 23:56:52 +0000616void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000617 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000618 unsigned NumExprs = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000619 E->Exprs = new (Record.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000620 for (unsigned i = 0; i != NumExprs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000621 E->Exprs[i] = Record.readSubStmt();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000622 E->NumExprs = NumExprs;
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000623 E->LParenLoc = ReadSourceLocation();
624 E->RParenLoc = ReadSourceLocation();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000625}
626
Sebastian Redl70c751d2010-08-18 23:56:52 +0000627void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000628 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000629 E->setSubExpr(Record.readSubExpr());
630 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
631 E->setOperatorLoc(ReadSourceLocation());
632 E->setCanOverflow(Record.readInt());
633}
634
635void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000636 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000637 assert(E->getNumComponents() == Record.peekInt());
638 Record.skipInts(1);
639 assert(E->getNumExpressions() == Record.peekInt());
640 Record.skipInts(1);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000641 E->setOperatorLoc(ReadSourceLocation());
642 E->setRParenLoc(ReadSourceLocation());
643 E->setTypeSourceInfo(GetTypeSourceInfo());
Douglas Gregor882211c2010-04-28 22:16:22 +0000644 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000645 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000646 SourceLocation Start = ReadSourceLocation();
647 SourceLocation End = ReadSourceLocation();
Douglas Gregor882211c2010-04-28 22:16:22 +0000648 switch (Kind) {
James Y Knight7281c352015-12-29 22:31:18 +0000649 case OffsetOfNode::Array:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000650 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000651 break;
652
James Y Knight7281c352015-12-29 22:31:18 +0000653 case OffsetOfNode::Field:
654 E->setComponent(
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000655 I, OffsetOfNode(Start, ReadDeclAs<FieldDecl>(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000656 break;
James Y Knight7281c352015-12-29 22:31:18 +0000657
658 case OffsetOfNode::Identifier:
659 E->setComponent(
660 I,
David L. Jonesb6a8f022016-12-21 04:34:52 +0000661 OffsetOfNode(Start, Record.getIdentifierInfo(), End));
James Y Knight7281c352015-12-29 22:31:18 +0000662 break;
663
664 case OffsetOfNode::Base: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000665 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000666 *Base = Record.readCXXBaseSpecifier();
James Y Knight7281c352015-12-29 22:31:18 +0000667 E->setComponent(I, OffsetOfNode(Base));
Douglas Gregord1702062010-04-29 00:18:15 +0000668 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000669 }
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000670 }
Douglas Gregor882211c2010-04-28 22:16:22 +0000671 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000672
Douglas Gregor882211c2010-04-28 22:16:22 +0000673 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000674 E->setIndexExpr(I, Record.readSubExpr());
Douglas Gregor882211c2010-04-28 22:16:22 +0000675}
676
Peter Collingbournee190dee2011-03-11 19:24:49 +0000677void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000678 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000679 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
680 if (Record.peekInt() == 0) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000681 E->setArgument(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000682 Record.skipInts(1);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000683 } else {
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000684 E->setArgument(GetTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000685 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000686 E->setOperatorLoc(ReadSourceLocation());
687 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000688}
689
Sebastian Redl70c751d2010-08-18 23:56:52 +0000690void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000691 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000692 E->setLHS(Record.readSubExpr());
693 E->setRHS(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000694 E->setRBracketLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000695}
696
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000697void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
698 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000699 E->setBase(Record.readSubExpr());
700 E->setLowerBound(Record.readSubExpr());
701 E->setLength(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000702 E->setColonLoc(ReadSourceLocation());
703 E->setRBracketLoc(ReadSourceLocation());
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000704}
705
Sebastian Redl70c751d2010-08-18 23:56:52 +0000706void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000707 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000708 E->setNumArgs(Record.getContext(), Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000709 E->setRParenLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000710 E->setCallee(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000711 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000712 E->setArg(I, Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000713}
714
John McCallfa194042011-07-15 07:00:14 +0000715void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
716 VisitCallExpr(E);
717}
718
Sebastian Redl70c751d2010-08-18 23:56:52 +0000719void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000720 // Don't call VisitExpr, this is fully initialized at creation.
721 assert(E->getStmtClass() == Stmt::MemberExprClass &&
722 "It's a subclass, we must advance Idx!");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000723}
724
Sebastian Redl70c751d2010-08-18 23:56:52 +0000725void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Naroffe87026a2009-07-24 17:54:45 +0000726 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000727 E->setBase(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000728 E->setIsaMemberLoc(ReadSourceLocation());
729 E->setOpLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000730 E->setArrow(Record.readInt());
Steve Naroffe87026a2009-07-24 17:54:45 +0000731}
732
John McCall31168b02011-06-15 23:02:42 +0000733void ASTStmtReader::
734VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
735 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000736 E->Operand = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000737 E->setShouldCopy(Record.readInt());
John McCall31168b02011-06-15 23:02:42 +0000738}
739
740void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
741 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000742 E->LParenLoc = ReadSourceLocation();
743 E->BridgeKeywordLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000744 E->Kind = Record.readInt();
John McCall31168b02011-06-15 23:02:42 +0000745}
746
Sebastian Redl70c751d2010-08-18 23:56:52 +0000747void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000748 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000749 unsigned NumBaseSpecs = Record.readInt();
John McCallcf142162010-08-07 06:22:56 +0000750 assert(NumBaseSpecs == E->path_size());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000751 E->setSubExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000752 E->setCastKind((CastKind)Record.readInt());
John McCallcf142162010-08-07 06:22:56 +0000753 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000754 while (NumBaseSpecs--) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000755 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000756 *BaseSpec = Record.readCXXBaseSpecifier();
John McCallcf142162010-08-07 06:22:56 +0000757 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000758 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000759}
760
Sebastian Redl70c751d2010-08-18 23:56:52 +0000761void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000762 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000763 E->setLHS(Record.readSubExpr());
764 E->setRHS(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000765 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000766 E->setOperatorLoc(ReadSourceLocation());
Adam Nemet484aa452017-03-27 19:17:25 +0000767 E->setFPFeatures(FPOptions(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000768}
769
Sebastian Redl70c751d2010-08-18 23:56:52 +0000770void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000771 VisitBinaryOperator(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000772 E->setComputationLHSType(Record.readType());
773 E->setComputationResultType(Record.readType());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000774}
775
Sebastian Redl70c751d2010-08-18 23:56:52 +0000776void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000777 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000778 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
779 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
780 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000781 E->QuestionLoc = ReadSourceLocation();
782 E->ColonLoc = ReadSourceLocation();
John McCallc07a0c72011-02-17 10:25:35 +0000783}
784
785void
786ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
787 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000788 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
789 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
790 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
791 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
792 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000793 E->QuestionLoc = ReadSourceLocation();
794 E->ColonLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000795}
796
Sebastian Redl70c751d2010-08-18 23:56:52 +0000797void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000798 VisitCastExpr(E);
Roman Lebedev12216f12018-07-27 07:27:14 +0000799 E->setIsPartOfExplicitCast(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000800}
801
Sebastian Redl70c751d2010-08-18 23:56:52 +0000802void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000803 VisitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000804 E->setTypeInfoAsWritten(GetTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000805}
806
Sebastian Redl70c751d2010-08-18 23:56:52 +0000807void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000808 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000809 E->setLParenLoc(ReadSourceLocation());
810 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000811}
812
Sebastian Redl70c751d2010-08-18 23:56:52 +0000813void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000814 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000815 E->setLParenLoc(ReadSourceLocation());
816 E->setTypeSourceInfo(GetTypeSourceInfo());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000817 E->setInitializer(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000818 E->setFileScope(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000819}
820
Sebastian Redl70c751d2010-08-18 23:56:52 +0000821void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000822 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000823 E->setBase(Record.readSubExpr());
824 E->setAccessor(Record.getIdentifierInfo());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000825 E->setAccessorLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000826}
827
Sebastian Redl70c751d2010-08-18 23:56:52 +0000828void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000829 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000830 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
Abramo Bagnara8d16bd42012-11-08 18:41:43 +0000831 E->setSyntacticForm(SyntForm);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000832 E->setLBraceLoc(ReadSourceLocation());
833 E->setRBraceLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000834 bool isArrayFiller = Record.readInt();
Craig Toppera13603a2014-05-22 05:54:18 +0000835 Expr *filler = nullptr;
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000836 if (isArrayFiller) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000837 filler = Record.readSubExpr();
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000838 E->ArrayFillerOrUnionFieldInit = filler;
839 } else
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000840 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000841 E->sawArrayRangeDesignator(Record.readInt());
842 unsigned NumInits = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000843 E->reserveInits(Record.getContext(), NumInits);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000844 if (isArrayFiller) {
845 for (unsigned I = 0; I != NumInits; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000846 Expr *init = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000847 E->updateInit(Record.getContext(), I, init ? init : filler);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000848 }
849 } else {
850 for (unsigned I = 0; I != NumInits; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000851 E->updateInit(Record.getContext(), I, Record.readSubExpr());
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000852 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000853}
854
Sebastian Redl70c751d2010-08-18 23:56:52 +0000855void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000856 using Designator = DesignatedInitExpr::Designator;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000857
858 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000859 unsigned NumSubExprs = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000860 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
861 for (unsigned I = 0; I != NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000862 E->setSubExpr(I, Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000863 E->setEqualOrColonLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000864 E->setGNUSyntax(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000865
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000866 SmallVector<Designator, 4> Designators;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000867 while (Record.getIdx() < Record.size()) {
868 switch ((DesignatorTypes)Record.readInt()) {
Sebastian Redl539c5062010-08-18 23:57:32 +0000869 case DESIG_FIELD_DECL: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000870 auto *Field = ReadDeclAs<FieldDecl>();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000871 SourceLocation DotLoc = ReadSourceLocation();
872 SourceLocation FieldLoc = ReadSourceLocation();
Mike Stump11289f42009-09-09 15:08:12 +0000873 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000874 FieldLoc));
875 Designators.back().setField(Field);
876 break;
877 }
878
Sebastian Redl539c5062010-08-18 23:57:32 +0000879 case DESIG_FIELD_NAME: {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000880 const IdentifierInfo *Name = Record.getIdentifierInfo();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000881 SourceLocation DotLoc = ReadSourceLocation();
882 SourceLocation FieldLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000883 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
884 break;
885 }
Mike Stump11289f42009-09-09 15:08:12 +0000886
Sebastian Redl539c5062010-08-18 23:57:32 +0000887 case DESIG_ARRAY: {
David L. Jonesbe1557a2016-12-21 00:17:49 +0000888 unsigned Index = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000889 SourceLocation LBracketLoc = ReadSourceLocation();
890 SourceLocation RBracketLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000891 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
892 break;
893 }
894
Sebastian Redl539c5062010-08-18 23:57:32 +0000895 case DESIG_ARRAY_RANGE: {
David L. Jonesbe1557a2016-12-21 00:17:49 +0000896 unsigned Index = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000897 SourceLocation LBracketLoc = ReadSourceLocation();
898 SourceLocation EllipsisLoc = ReadSourceLocation();
899 SourceLocation RBracketLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000900 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
901 RBracketLoc));
902 break;
903 }
904 }
905 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000906 E->setDesignators(Record.getContext(),
Douglas Gregor03e8bdc2010-01-06 23:17:19 +0000907 Designators.data(), Designators.size());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000908}
909
Yunzhong Gaocb779302015-06-10 00:27:52 +0000910void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
911 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000912 E->setBase(Record.readSubExpr());
913 E->setUpdater(Record.readSubExpr());
Yunzhong Gaocb779302015-06-10 00:27:52 +0000914}
915
916void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
917 VisitExpr(E);
918}
919
Richard Smith410306b2016-12-12 02:53:20 +0000920void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
921 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000922 E->SubExprs[0] = Record.readSubExpr();
923 E->SubExprs[1] = Record.readSubExpr();
Richard Smith410306b2016-12-12 02:53:20 +0000924}
925
926void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
927 VisitExpr(E);
928}
929
Sebastian Redl70c751d2010-08-18 23:56:52 +0000930void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000931 VisitExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000932}
933
Sebastian Redl70c751d2010-08-18 23:56:52 +0000934void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000935 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000936 E->setSubExpr(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000937 E->setWrittenTypeInfo(GetTypeSourceInfo());
938 E->setBuiltinLoc(ReadSourceLocation());
939 E->setRParenLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000940 E->setIsMicrosoftABI(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000941}
942
Sebastian Redl70c751d2010-08-18 23:56:52 +0000943void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000944 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000945 E->setAmpAmpLoc(ReadSourceLocation());
946 E->setLabelLoc(ReadSourceLocation());
947 E->setLabel(ReadDeclAs<LabelDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000948}
949
Sebastian Redl70c751d2010-08-18 23:56:52 +0000950void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000951 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000952 E->setLParenLoc(ReadSourceLocation());
953 E->setRParenLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000954 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000955}
956
Sebastian Redl70c751d2010-08-18 23:56:52 +0000957void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000958 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000959 E->setCond(Record.readSubExpr());
960 E->setLHS(Record.readSubExpr());
961 E->setRHS(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000962 E->setBuiltinLoc(ReadSourceLocation());
963 E->setRParenLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000964 E->setIsConditionTrue(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000965}
966
Sebastian Redl70c751d2010-08-18 23:56:52 +0000967void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000968 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000969 E->setTokenLocation(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000970}
971
Sebastian Redl70c751d2010-08-18 23:56:52 +0000972void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000973 VisitExpr(E);
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000974 SmallVector<Expr *, 16> Exprs;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000975 unsigned NumExprs = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000976 while (NumExprs--)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000977 Exprs.push_back(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000978 E->setExprs(Record.getContext(), Exprs);
979 E->setBuiltinLoc(ReadSourceLocation());
980 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000981}
982
Hal Finkelc4d7c822013-09-18 03:29:45 +0000983void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
984 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000985 E->BuiltinLoc = ReadSourceLocation();
986 E->RParenLoc = ReadSourceLocation();
987 E->TInfo = GetTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000988 E->SrcExpr = Record.readSubExpr();
Hal Finkelc4d7c822013-09-18 03:29:45 +0000989}
990
Sebastian Redl70c751d2010-08-18 23:56:52 +0000991void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000992 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000993 E->setBlockDecl(ReadDeclAs<BlockDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000994}
995
Peter Collingbourne91147592011-04-15 00:35:48 +0000996void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
997 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000998 E->NumAssocs = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000999 E->AssocTypes = new (Record.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbourne91147592011-04-15 00:35:48 +00001000 E->SubExprs =
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001001 new(Record.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbourne91147592011-04-15 00:35:48 +00001002
David L. Jonesb6a8f022016-12-21 04:34:52 +00001003 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Record.readSubExpr();
Peter Collingbourne91147592011-04-15 00:35:48 +00001004 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001005 E->AssocTypes[I] = GetTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001006 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Record.readSubExpr();
Peter Collingbourne91147592011-04-15 00:35:48 +00001007 }
David L. Jonesbe1557a2016-12-21 00:17:49 +00001008 E->ResultIndex = Record.readInt();
Peter Collingbourne91147592011-04-15 00:35:48 +00001009
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001010 E->GenericLoc = ReadSourceLocation();
1011 E->DefaultLoc = ReadSourceLocation();
1012 E->RParenLoc = ReadSourceLocation();
Peter Collingbourne91147592011-04-15 00:35:48 +00001013}
1014
John McCallfe96e0b2011-11-06 09:01:30 +00001015void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1016 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001017 unsigned numSemanticExprs = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001018 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001019 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001020
1021 // Read the syntactic expression.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001022 E->getSubExprsBuffer()[0] = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001023
1024 // Read all the semantic expressions.
1025 for (unsigned i = 0; i != numSemanticExprs; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001026 Expr *subExpr = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001027 E->getSubExprsBuffer()[i+1] = subExpr;
1028 }
1029}
1030
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001031void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1032 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001033 E->Op = AtomicExpr::AtomicOp(Record.readInt());
Richard Smithaa22a8c2012-04-10 22:49:28 +00001034 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1035 for (unsigned I = 0; I != E->NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001036 E->SubExprs[I] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001037 E->BuiltinLoc = ReadSourceLocation();
1038 E->RParenLoc = ReadSourceLocation();
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001039}
1040
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001041//===----------------------------------------------------------------------===//
1042// Objective-C Expressions and Statements
1043
Sebastian Redl70c751d2010-08-18 23:56:52 +00001044void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001045 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001046 E->setString(cast<StringLiteral>(Record.readSubStmt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001047 E->setAtLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001048}
1049
Patrick Beard0caa3942012-04-19 00:25:12 +00001050void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001051 VisitExpr(E);
1052 // could be one of several IntegerLiteral, FloatLiteral, etc.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001053 E->SubExpr = Record.readSubStmt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001054 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>();
1055 E->Range = ReadSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001056}
1057
1058void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1059 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001060 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001061 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1062 Expr **Elements = E->getElements();
1063 for (unsigned I = 0, N = NumElements; I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001064 Elements[I] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001065 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1066 E->Range = ReadSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001067}
1068
1069void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1070 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001071 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001072 assert(NumElements == E->getNumElements() && "Wrong number of elements");
David L. Jonesbe1557a2016-12-21 00:17:49 +00001073 bool HasPackExpansions = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001074 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001075 auto *KeyValues =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001076 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001077 auto *Expansions =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001078 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001079 for (unsigned I = 0; I != NumElements; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001080 KeyValues[I].Key = Record.readSubExpr();
1081 KeyValues[I].Value = Record.readSubExpr();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001082 if (HasPackExpansions) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001083 Expansions[I].EllipsisLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001084 Expansions[I].NumExpansionsPlusOne = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001085 }
1086 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001087 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1088 E->Range = ReadSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001089}
1090
Sebastian Redl70c751d2010-08-18 23:56:52 +00001091void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001092 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001093 E->setEncodedTypeSourceInfo(GetTypeSourceInfo());
1094 E->setAtLoc(ReadSourceLocation());
1095 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001096}
1097
Sebastian Redl70c751d2010-08-18 23:56:52 +00001098void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001099 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001100 E->setSelector(Record.readSelector());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001101 E->setAtLoc(ReadSourceLocation());
1102 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001103}
1104
Sebastian Redl70c751d2010-08-18 23:56:52 +00001105void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001106 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001107 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>());
1108 E->setAtLoc(ReadSourceLocation());
1109 E->ProtoLoc = ReadSourceLocation();
1110 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001111}
1112
Sebastian Redl70c751d2010-08-18 23:56:52 +00001113void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001114 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001115 E->setDecl(ReadDeclAs<ObjCIvarDecl>());
1116 E->setLocation(ReadSourceLocation());
1117 E->setOpLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001118 E->setBase(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001119 E->setIsArrow(Record.readInt());
1120 E->setIsFreeIvar(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001121}
1122
Sebastian Redl70c751d2010-08-18 23:56:52 +00001123void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001124 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001125 unsigned MethodRefFlags = Record.readInt();
1126 bool Implicit = Record.readInt() != 0;
John McCallb7bd14f2010-12-02 01:19:52 +00001127 if (Implicit) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001128 auto *Getter = ReadDeclAs<ObjCMethodDecl>();
1129 auto *Setter = ReadDeclAs<ObjCMethodDecl>();
Argyrios Kyrtzidisab468b02012-03-30 00:19:18 +00001130 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCallb7bd14f2010-12-02 01:19:52 +00001131 } else {
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001132 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001133 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001134 E->setLocation(ReadSourceLocation());
1135 E->setReceiverLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001136 switch (Record.readInt()) {
John McCallb7bd14f2010-12-02 01:19:52 +00001137 case 0:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001138 E->setBase(Record.readSubExpr());
John McCallb7bd14f2010-12-02 01:19:52 +00001139 break;
1140 case 1:
David L. Jonesbe1557a2016-12-21 00:17:49 +00001141 E->setSuperReceiver(Record.readType());
John McCallb7bd14f2010-12-02 01:19:52 +00001142 break;
1143 case 2:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001144 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>());
John McCallb7bd14f2010-12-02 01:19:52 +00001145 break;
1146 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001147}
1148
Ted Kremeneke65b0862012-03-06 20:05:56 +00001149void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1150 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001151 E->setRBracket(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001152 E->setBaseExpr(Record.readSubExpr());
1153 E->setKeyExpr(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001154 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1155 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001156}
1157
Sebastian Redl70c751d2010-08-18 23:56:52 +00001158void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001159 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001160 assert(Record.peekInt() == E->getNumArgs());
1161 Record.skipInts(1);
1162 unsigned NumStoredSelLocs = Record.readInt();
1163 E->SelLocsKind = Record.readInt();
1164 E->setDelegateInitCall(Record.readInt());
1165 E->IsImplicit = Record.readInt();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001166 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
Douglas Gregor9a129192010-04-21 00:45:42 +00001167 switch (Kind) {
1168 case ObjCMessageExpr::Instance:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001169 E->setInstanceReceiver(Record.readSubExpr());
Douglas Gregor9a129192010-04-21 00:45:42 +00001170 break;
1171
1172 case ObjCMessageExpr::Class:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001173 E->setClassReceiver(GetTypeSourceInfo());
Douglas Gregor9a129192010-04-21 00:45:42 +00001174 break;
1175
1176 case ObjCMessageExpr::SuperClass:
1177 case ObjCMessageExpr::SuperInstance: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001178 QualType T = Record.readType();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001179 SourceLocation SuperLoc = ReadSourceLocation();
Douglas Gregor9a129192010-04-21 00:45:42 +00001180 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1181 break;
1182 }
1183 }
1184
1185 assert(Kind == E->getReceiverKind());
1186
David L. Jonesbe1557a2016-12-21 00:17:49 +00001187 if (Record.readInt())
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001188 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>());
Douglas Gregor9a129192010-04-21 00:45:42 +00001189 else
David L. Jonesb6a8f022016-12-21 04:34:52 +00001190 E->setSelector(Record.readSelector());
Douglas Gregor9a129192010-04-21 00:45:42 +00001191
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001192 E->LBracLoc = ReadSourceLocation();
1193 E->RBracLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001194
1195 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001196 E->setArg(I, Record.readSubExpr());
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00001197
1198 SourceLocation *Locs = E->getStoredSelLocs();
1199 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001200 Locs[I] = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001201}
1202
Sebastian Redl70c751d2010-08-18 23:56:52 +00001203void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001204 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001205 S->setElement(Record.readSubStmt());
1206 S->setCollection(Record.readSubExpr());
1207 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001208 S->setForLoc(ReadSourceLocation());
1209 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001210}
1211
Sebastian Redl70c751d2010-08-18 23:56:52 +00001212void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001213 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001214 S->setCatchBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001215 S->setCatchParamDecl(ReadDeclAs<VarDecl>());
1216 S->setAtCatchLoc(ReadSourceLocation());
1217 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001218}
1219
Sebastian Redl70c751d2010-08-18 23:56:52 +00001220void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001221 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001222 S->setFinallyBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001223 S->setAtFinallyLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001224}
1225
John McCall31168b02011-06-15 23:02:42 +00001226void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1227 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001228 S->setSubStmt(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001229 S->setAtLoc(ReadSourceLocation());
John McCall31168b02011-06-15 23:02:42 +00001230}
1231
Sebastian Redl70c751d2010-08-18 23:56:52 +00001232void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001233 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001234 assert(Record.peekInt() == S->getNumCatchStmts());
1235 Record.skipInts(1);
1236 bool HasFinally = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001237 S->setTryBody(Record.readSubStmt());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001238 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001239 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
Douglas Gregor96c79492010-04-23 22:50:49 +00001240
Douglas Gregor96c79492010-04-23 22:50:49 +00001241 if (HasFinally)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001242 S->setFinallyStmt(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001243 S->setAtTryLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001244}
1245
Sebastian Redl70c751d2010-08-18 23:56:52 +00001246void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001247 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001248 S->setSynchExpr(Record.readSubStmt());
1249 S->setSynchBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001250 S->setAtSynchronizedLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001251}
1252
Sebastian Redl70c751d2010-08-18 23:56:52 +00001253void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001254 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001255 S->setThrowExpr(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001256 S->setThrowLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001257}
1258
Ted Kremeneke65b0862012-03-06 20:05:56 +00001259void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1260 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001261 E->setValue(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001262 E->setLocation(ReadSourceLocation());
Ted Kremeneke65b0862012-03-06 20:05:56 +00001263}
1264
Erik Pilkington29099de2016-07-16 00:35:23 +00001265void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1266 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001267 SourceRange R = Record.readSourceRange();
Erik Pilkington29099de2016-07-16 00:35:23 +00001268 E->AtLoc = R.getBegin();
1269 E->RParen = R.getEnd();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001270 E->VersionToCheck = Record.readVersionTuple();
Erik Pilkington29099de2016-07-16 00:35:23 +00001271}
1272
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001273//===----------------------------------------------------------------------===//
1274// C++ Expressions and Statements
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001275//===----------------------------------------------------------------------===//
1276
Sebastian Redl70c751d2010-08-18 23:56:52 +00001277void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001278 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001279 S->CatchLoc = ReadSourceLocation();
1280 S->ExceptionDecl = ReadDeclAs<VarDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001281 S->HandlerBlock = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001282}
1283
Sebastian Redl70c751d2010-08-18 23:56:52 +00001284void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001285 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001286 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1287 Record.skipInts(1);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001288 S->TryLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001289 S->getStmts()[0] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001290 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001291 S->getStmts()[i + 1] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001292}
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001293
Richard Smith02e85f32011-04-14 22:09:26 +00001294void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1295 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001296 S->ForLoc = ReadSourceLocation();
1297 S->CoawaitLoc = ReadSourceLocation();
1298 S->ColonLoc = ReadSourceLocation();
1299 S->RParenLoc = ReadSourceLocation();
Richard Smith8baa5002018-09-28 18:44:09 +00001300 S->setInit(Record.readSubStmt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001301 S->setRangeStmt(Record.readSubStmt());
1302 S->setBeginStmt(Record.readSubStmt());
1303 S->setEndStmt(Record.readSubStmt());
1304 S->setCond(Record.readSubExpr());
1305 S->setInc(Record.readSubExpr());
1306 S->setLoopVarStmt(Record.readSubStmt());
1307 S->setBody(Record.readSubStmt());
Richard Smith02e85f32011-04-14 22:09:26 +00001308}
1309
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001310void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1311 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001312 S->KeywordLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001313 S->IsIfExists = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001314 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001315 ReadDeclarationNameInfo(S->NameInfo);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001316 S->SubStmt = Record.readSubStmt();
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001317}
1318
Sebastian Redl70c751d2010-08-18 23:56:52 +00001319void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001320 VisitCallExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001321 E->Operator = (OverloadedOperatorKind)Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001322 E->Range = Record.readSourceRange();
Adam Nemet484aa452017-03-27 19:17:25 +00001323 E->setFPFeatures(FPOptions(Record.readInt()));
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001324}
1325
Sebastian Redl70c751d2010-08-18 23:56:52 +00001326void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001327 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001328 E->NumArgs = Record.readInt();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001329 if (E->NumArgs)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001330 E->Args = new (Record.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis30d98f32010-06-24 08:57:09 +00001331 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001332 E->setArg(I, Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001333 E->setConstructor(ReadDeclAs<CXXConstructorDecl>());
1334 E->setLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001335 E->setElidable(Record.readInt());
1336 E->setHadMultipleCandidates(Record.readInt());
1337 E->setListInitialization(Record.readInt());
1338 E->setStdInitListInitialization(Record.readInt());
1339 E->setRequiresZeroInitialization(Record.readInt());
1340 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001341 E->ParenOrBraceRange = ReadSourceRange();
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001342}
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001343
Richard Smith5179eb72016-06-28 19:03:57 +00001344void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1345 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001346 E->Constructor = ReadDeclAs<CXXConstructorDecl>();
1347 E->Loc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001348 E->ConstructsVirtualBase = Record.readInt();
1349 E->InheritedFromVirtualBase = Record.readInt();
Richard Smith5179eb72016-06-28 19:03:57 +00001350}
1351
Sebastian Redl70c751d2010-08-18 23:56:52 +00001352void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001353 VisitCXXConstructExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001354 E->Type = GetTypeSourceInfo();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001355}
1356
Douglas Gregore31e6062012-02-07 10:09:13 +00001357void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1358 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001359 unsigned NumCaptures = Record.readInt();
Douglas Gregor99ae8062012-02-14 17:54:36 +00001360 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001361 E->IntroducerRange = ReadSourceRange();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001362 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001363 E->CaptureDefaultLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001364 E->ExplicitParams = Record.readInt();
1365 E->ExplicitResultType = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001366 E->ClosingBrace = ReadSourceLocation();
1367
Douglas Gregor99ae8062012-02-14 17:54:36 +00001368 // Read capture initializers.
1369 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1370 CEnd = E->capture_init_end();
1371 C != CEnd; ++C)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001372 *C = Record.readSubExpr();
Douglas Gregore31e6062012-02-07 10:09:13 +00001373}
1374
Richard Smithcc1b96d2013-06-12 22:31:48 +00001375void
1376ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1377 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001378 E->SubExpr = Record.readSubExpr();
Richard Smithcc1b96d2013-06-12 22:31:48 +00001379}
1380
Sebastian Redl70c751d2010-08-18 23:56:52 +00001381void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001382 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001383 SourceRange R = ReadSourceRange();
Douglas Gregor4478f852011-01-12 22:41:29 +00001384 E->Loc = R.getBegin();
1385 E->RParenLoc = R.getEnd();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001386 R = ReadSourceRange();
Fariborz Jahanianf0738712013-02-22 22:02:53 +00001387 E->AngleBrackets = R;
Sam Weinigd01101e2010-01-16 21:21:01 +00001388}
1389
Sebastian Redl70c751d2010-08-18 23:56:52 +00001390void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001391 return VisitCXXNamedCastExpr(E);
1392}
1393
Sebastian Redl70c751d2010-08-18 23:56:52 +00001394void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001395 return VisitCXXNamedCastExpr(E);
1396}
1397
Sebastian Redl70c751d2010-08-18 23:56:52 +00001398void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001399 return VisitCXXNamedCastExpr(E);
1400}
1401
Sebastian Redl70c751d2010-08-18 23:56:52 +00001402void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001403 return VisitCXXNamedCastExpr(E);
1404}
1405
Sebastian Redl70c751d2010-08-18 23:56:52 +00001406void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001407 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001408 E->setLParenLoc(ReadSourceLocation());
1409 E->setRParenLoc(ReadSourceLocation());
Sam Weinigd01101e2010-01-16 21:21:01 +00001410}
1411
Richard Smithc67fdd42012-03-07 08:35:16 +00001412void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1413 VisitCallExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001414 E->UDSuffixLoc = ReadSourceLocation();
Richard Smithc67fdd42012-03-07 08:35:16 +00001415}
1416
Sebastian Redl70c751d2010-08-18 23:56:52 +00001417void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001418 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001419 E->setValue(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001420 E->setLocation(ReadSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001421}
1422
Sebastian Redl70c751d2010-08-18 23:56:52 +00001423void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001424 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001425 E->setLocation(ReadSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001426}
1427
Sebastian Redl70c751d2010-08-18 23:56:52 +00001428void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001429 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001430 E->setSourceRange(ReadSourceRange());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001431 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redlc67764e2010-07-22 22:43:28 +00001432 E->setTypeOperandSourceInfo(
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001433 GetTypeSourceInfo());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001434 return;
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001435 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001436
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001437 // typeid(42+2)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001438 E->setExprOperand(Record.readSubExpr());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001439}
1440
Sebastian Redl70c751d2010-08-18 23:56:52 +00001441void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001442 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001443 E->setLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001444 E->setImplicit(Record.readInt());
Chris Lattner98267332010-05-09 06:15:05 +00001445}
1446
Sebastian Redl70c751d2010-08-18 23:56:52 +00001447void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001448 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001449 E->ThrowLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001450 E->Op = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001451 E->IsThrownVariableInScope = Record.readInt();
Chris Lattner98267332010-05-09 06:15:05 +00001452}
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001453
Sebastian Redl70c751d2010-08-18 23:56:52 +00001454void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattnere2437f42010-05-09 06:40:08 +00001455 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001456 E->Param = ReadDeclAs<ParmVarDecl>();
1457 E->Loc = ReadSourceLocation();
Chris Lattnercba86142010-05-10 00:25:06 +00001458}
1459
Richard Smith852c9db2013-04-20 22:23:05 +00001460void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1461 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001462 E->Field = ReadDeclAs<FieldDecl>();
1463 E->Loc = ReadSourceLocation();
Richard Smith852c9db2013-04-20 22:23:05 +00001464}
1465
Sebastian Redl70c751d2010-08-18 23:56:52 +00001466void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001467 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001468 E->setTemporary(Record.readCXXTemporary());
1469 E->setSubExpr(Record.readSubExpr());
Chris Lattnercba86142010-05-10 00:25:06 +00001470}
1471
Sebastian Redl70c751d2010-08-18 23:56:52 +00001472void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001473 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001474 E->TypeInfo = GetTypeSourceInfo();
1475 E->RParenLoc = ReadSourceLocation();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001476}
1477
Sebastian Redl70c751d2010-08-18 23:56:52 +00001478void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001479 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001480 E->GlobalNew = Record.readInt();
1481 bool isArray = Record.readInt();
1482 E->PassAlignment = Record.readInt();
1483 E->UsualArrayDeleteWantsSize = Record.readInt();
1484 unsigned NumPlacementArgs = Record.readInt();
1485 E->StoredInitializationStyle = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001486 E->setOperatorNew(ReadDeclAs<FunctionDecl>());
1487 E->setOperatorDelete(ReadDeclAs<FunctionDecl>());
1488 E->AllocatedTypeInfo = GetTypeSourceInfo();
1489 E->TypeIdParens = ReadSourceRange();
1490 E->Range = ReadSourceRange();
1491 E->DirectInitRange = ReadSourceRange();
Chandler Carruth01718152010-10-25 08:47:36 +00001492
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001493 E->AllocateArgsArray(Record.getContext(), isArray, NumPlacementArgs,
Sebastian Redl6047f072012-02-16 12:22:20 +00001494 E->StoredInitializationStyle != 0);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001495
1496 // Install all the subexpressions.
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001497 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1498 I != e; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001499 *I = Record.readSubStmt();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001500}
1501
Sebastian Redl70c751d2010-08-18 23:56:52 +00001502void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001503 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001504 E->GlobalDelete = Record.readInt();
1505 E->ArrayForm = Record.readInt();
1506 E->ArrayFormAsWritten = Record.readInt();
1507 E->UsualArrayDeleteWantsSize = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001508 E->OperatorDelete = ReadDeclAs<FunctionDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001509 E->Argument = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001510 E->Loc = ReadSourceLocation();
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001511}
Chris Lattnercba86142010-05-10 00:25:06 +00001512
Sebastian Redl70c751d2010-08-18 23:56:52 +00001513void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001514 VisitExpr(E);
1515
David L. Jonesb6a8f022016-12-21 04:34:52 +00001516 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001517 E->IsArrow = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001518 E->OperatorLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001519 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001520 E->ScopeType = GetTypeSourceInfo();
1521 E->ColonColonLoc = ReadSourceLocation();
1522 E->TildeLoc = ReadSourceLocation();
1523
David L. Jonesb6a8f022016-12-21 04:34:52 +00001524 IdentifierInfo *II = Record.getIdentifierInfo();
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001525 if (II)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001526 E->setDestroyedType(II, ReadSourceLocation());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001527 else
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001528 E->setDestroyedType(GetTypeSourceInfo());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001529}
1530
John McCall5d413782010-12-06 08:20:24 +00001531void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001532 VisitExpr(E);
John McCall28fc7092011-11-10 05:35:25 +00001533
David L. Jonesbe1557a2016-12-21 00:17:49 +00001534 unsigned NumObjects = Record.readInt();
John McCall28fc7092011-11-10 05:35:25 +00001535 assert(NumObjects == E->getNumObjects());
1536 for (unsigned i = 0; i != NumObjects; ++i)
James Y Knighte00a67e2015-12-31 04:18:25 +00001537 E->getTrailingObjects<BlockDecl *>()[i] =
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001538 ReadDeclAs<BlockDecl>();
John McCall28fc7092011-11-10 05:35:25 +00001539
David L. Jonesbe1557a2016-12-21 00:17:49 +00001540 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001541 E->SubExpr = Record.readSubExpr();
Chris Lattnere2437f42010-05-09 06:40:08 +00001542}
1543
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001544void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001545ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001546 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001547
David L. Jonesbe1557a2016-12-21 00:17:49 +00001548 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001549 ReadTemplateKWAndArgsInfo(
1550 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1551 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001552 /*NumTemplateArgs=*/Record.readInt());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001553
David L. Jonesb6a8f022016-12-21 04:34:52 +00001554 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001555 E->BaseType = Record.readType();
1556 E->IsArrow = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001557 E->OperatorLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001558 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001559 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>();
1560 ReadDeclarationNameInfo(E->MemberNameInfo);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001561}
1562
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001563void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001564ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001565 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001566
David L. Jonesbe1557a2016-12-21 00:17:49 +00001567 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001568 ReadTemplateKWAndArgsInfo(
1569 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1570 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001571 /*NumTemplateArgs=*/Record.readInt());
Douglas Gregor3a43fd62011-02-25 20:49:16 +00001572
David L. Jonesb6a8f022016-12-21 04:34:52 +00001573 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001574 ReadDeclarationNameInfo(E->NameInfo);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001575}
1576
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001577void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001578ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001579 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001580 assert(Record.peekInt() == E->arg_size() &&
1581 "Read wrong record during creation ?");
1582 Record.skipInts(1);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001583 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001584 E->setArg(I, Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001585 E->Type = GetTypeSourceInfo();
1586 E->setLParenLoc(ReadSourceLocation());
1587 E->setRParenLoc(ReadSourceLocation());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001588}
1589
Sebastian Redl70c751d2010-08-18 23:56:52 +00001590void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001591 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001592
David L. Jonesbe1557a2016-12-21 00:17:49 +00001593 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001594 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1595 E->getTrailingTemplateArgumentLoc(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001596 /*NumTemplateArgs=*/Record.readInt());
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001597
David L. Jonesbe1557a2016-12-21 00:17:49 +00001598 unsigned NumDecls = Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001599 UnresolvedSet<8> Decls;
1600 for (unsigned i = 0; i != NumDecls; ++i) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001601 auto *D = ReadDeclAs<NamedDecl>();
1602 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001603 Decls.addDecl(D, AS);
1604 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001605 E->initializeResults(Record.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001606
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001607 ReadDeclarationNameInfo(E->NameInfo);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001608 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001609}
1610
Sebastian Redl70c751d2010-08-18 23:56:52 +00001611void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001612 VisitOverloadExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001613 E->IsArrow = Record.readInt();
1614 E->HasUnresolvedUsing = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001615 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001616 E->BaseType = Record.readType();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001617 E->OperatorLoc = ReadSourceLocation();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001618}
1619
Sebastian Redl70c751d2010-08-18 23:56:52 +00001620void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001621 VisitOverloadExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001622 E->RequiresADL = Record.readInt();
1623 E->Overloaded = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001624 E->NamingClass = ReadDeclAs<CXXRecordDecl>();
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00001625}
1626
Douglas Gregor29c42f22012-02-24 07:38:34 +00001627void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1628 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001629 E->TypeTraitExprBits.NumArgs = Record.readInt();
1630 E->TypeTraitExprBits.Kind = Record.readInt();
1631 E->TypeTraitExprBits.Value = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001632 SourceRange Range = ReadSourceRange();
Jordan Rose99e80c12013-12-20 01:26:47 +00001633 E->Loc = Range.getBegin();
1634 E->RParenLoc = Range.getEnd();
1635
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001636 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001637 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001638 Args[I] = GetTypeSourceInfo();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001639}
1640
John Wiegley6242b6a2011-04-28 00:16:57 +00001641void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1642 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001643 E->ATT = (ArrayTypeTrait)Record.readInt();
1644 E->Value = (unsigned int)Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001645 SourceRange Range = ReadSourceRange();
John Wiegley6242b6a2011-04-28 00:16:57 +00001646 E->Loc = Range.getBegin();
1647 E->RParen = Range.getEnd();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001648 E->QueriedType = GetTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001649 E->Dimension = Record.readSubExpr();
John Wiegley6242b6a2011-04-28 00:16:57 +00001650}
1651
John Wiegleyf9f65842011-04-25 06:54:41 +00001652void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1653 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001654 E->ET = (ExpressionTrait)Record.readInt();
1655 E->Value = (bool)Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001656 SourceRange Range = ReadSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001657 E->QueriedExpression = Record.readSubExpr();
John Wiegleyf9f65842011-04-25 06:54:41 +00001658 E->Loc = Range.getBegin();
1659 E->RParen = Range.getEnd();
1660}
1661
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001662void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1663 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001664 E->Value = (bool)Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001665 E->Range = ReadSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001666 E->Operand = Record.readSubExpr();
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001667}
1668
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001669void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1670 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001671 E->EllipsisLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001672 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001673 E->Pattern = Record.readSubExpr();
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001674}
1675
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001676void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1677 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001678 unsigned NumPartialArgs = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001679 E->OperatorLoc = ReadSourceLocation();
1680 E->PackLoc = ReadSourceLocation();
1681 E->RParenLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001682 E->Pack = Record.readDeclAs<NamedDecl>();
Richard Smithd784e682015-09-23 21:41:42 +00001683 if (E->isPartiallySubstituted()) {
1684 assert(E->Length == NumPartialArgs);
James Y Knighte00a67e2015-12-31 04:18:25 +00001685 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
Richard Smithd784e682015-09-23 21:41:42 +00001686 *E = I + NumPartialArgs;
1687 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001688 new (I) TemplateArgument(Record.readTemplateArgument());
Richard Smithd784e682015-09-23 21:41:42 +00001689 } else if (!E->isValueDependent()) {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001690 E->Length = Record.readInt();
Richard Smithd784e682015-09-23 21:41:42 +00001691 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001692}
1693
John McCallfa194042011-07-15 07:00:14 +00001694void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1695 SubstNonTypeTemplateParmExpr *E) {
1696 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001697 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1698 E->NameLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001699 E->Replacement = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00001700}
1701
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001702void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1703 SubstNonTypeTemplateParmPackExpr *E) {
1704 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001705 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001706 TemplateArgument ArgPack = Record.readTemplateArgument();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001707 if (ArgPack.getKind() != TemplateArgument::Pack)
1708 return;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001709
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001710 E->Arguments = ArgPack.pack_begin();
1711 E->NumArguments = ArgPack.pack_size();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001712 E->NameLoc = ReadSourceLocation();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001713}
1714
Richard Smithb15fe3a2012-09-12 00:56:43 +00001715void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1716 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001717 E->NumParameters = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001718 E->ParamPack = ReadDeclAs<ParmVarDecl>();
1719 E->NameLoc = ReadSourceLocation();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001720 auto **Parms = E->getTrailingObjects<ParmVarDecl *>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00001721 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001722 Parms[i] = ReadDeclAs<ParmVarDecl>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00001723}
1724
Douglas Gregorfe314812011-06-21 17:03:29 +00001725void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1726 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001727 E->State = Record.readSubExpr();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001728 auto *VD = ReadDeclAs<ValueDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001729 unsigned ManglingNumber = Record.readInt();
David Majnemerdaff3702014-05-01 17:50:17 +00001730 E->setExtendingDecl(VD, ManglingNumber);
Douglas Gregorfe314812011-06-21 17:03:29 +00001731}
1732
Richard Smith0f0af192014-11-08 05:07:16 +00001733void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
1734 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001735 E->LParenLoc = ReadSourceLocation();
1736 E->EllipsisLoc = ReadSourceLocation();
1737 E->RParenLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001738 E->SubExprs[0] = Record.readSubExpr();
1739 E->SubExprs[1] = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001740 E->Opcode = (BinaryOperatorKind)Record.readInt();
Richard Smith0f0af192014-11-08 05:07:16 +00001741}
1742
John McCall8d69a212010-11-15 23:31:06 +00001743void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1744 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001745 E->SourceExpr = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001746 E->Loc = ReadSourceLocation();
Akira Hatanaka797afe32018-03-20 01:47:58 +00001747 E->setIsUnique(Record.readInt());
John McCall8d69a212010-11-15 23:31:06 +00001748}
1749
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001750void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
1751 llvm_unreachable("Cannot read TypoExpr nodes");
1752}
1753
Peter Collingbourne41f85462011-02-09 21:07:24 +00001754//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00001755// Microsoft Expressions and Statements
1756//===----------------------------------------------------------------------===//
John McCall5e77d762013-04-16 07:28:30 +00001757void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1758 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001759 E->IsArrow = (Record.readInt() != 0);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001760 E->BaseExpr = Record.readSubExpr();
1761 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001762 E->MemberLoc = ReadSourceLocation();
1763 E->TheDecl = ReadDeclAs<MSPropertyDecl>();
John McCall5e77d762013-04-16 07:28:30 +00001764}
1765
Alexey Bataevf7630272015-11-25 12:01:00 +00001766void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
1767 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001768 E->setBase(Record.readSubExpr());
1769 E->setIdx(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001770 E->setRBracketLoc(ReadSourceLocation());
Alexey Bataevf7630272015-11-25 12:01:00 +00001771}
1772
John McCallfa194042011-07-15 07:00:14 +00001773void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1774 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001775 E->setSourceRange(ReadSourceRange());
1776 std::string UuidStr = ReadString();
1777 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
John McCallfa194042011-07-15 07:00:14 +00001778 if (E->isTypeOperand()) { // __uuidof(ComType)
1779 E->setTypeOperandSourceInfo(
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001780 GetTypeSourceInfo());
John McCallfa194042011-07-15 07:00:14 +00001781 return;
1782 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001783
John McCallfa194042011-07-15 07:00:14 +00001784 // __uuidof(expr)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001785 E->setExprOperand(Record.readSubExpr());
John McCallfa194042011-07-15 07:00:14 +00001786}
1787
Nico Weber9b982072014-07-07 00:12:30 +00001788void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1789 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001790 S->setLeaveLoc(ReadSourceLocation());
Nico Weber9b982072014-07-07 00:12:30 +00001791}
1792
John McCallfa194042011-07-15 07:00:14 +00001793void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1794 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001795 S->Loc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001796 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
1797 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001798}
1799
1800void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1801 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001802 S->Loc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001803 S->Block = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001804}
1805
1806void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1807 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001808 S->IsCXXTry = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001809 S->TryLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001810 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
1811 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001812}
1813
1814//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00001815// CUDA Expressions and Statements
1816//===----------------------------------------------------------------------===//
1817
1818void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1819 VisitCallExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001820 E->setConfig(cast<CallExpr>(Record.readSubExpr()));
Peter Collingbourne41f85462011-02-09 21:07:24 +00001821}
1822
John McCallfa194042011-07-15 07:00:14 +00001823//===----------------------------------------------------------------------===//
1824// OpenCL Expressions and Statements.
1825//===----------------------------------------------------------------------===//
1826void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1827 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001828 E->BuiltinLoc = ReadSourceLocation();
1829 E->RParenLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001830 E->SrcExpr = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00001831}
1832
1833//===----------------------------------------------------------------------===//
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001834// OpenMP Directives.
1835//===----------------------------------------------------------------------===//
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001836
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001837void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001838 E->setLocStart(ReadSourceLocation());
1839 E->setLocEnd(ReadSourceLocation());
Kelvin Libe286f52018-09-15 13:54:15 +00001840 OMPClauseReader ClauseReader(Record);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001841 SmallVector<OMPClause *, 5> Clauses;
1842 for (unsigned i = 0; i < E->getNumClauses(); ++i)
1843 Clauses.push_back(ClauseReader.readClause());
1844 E->setClauses(Clauses);
Alexey Bataev68446b72014-07-18 07:47:19 +00001845 if (E->hasAssociatedStmt())
David L. Jonesb6a8f022016-12-21 04:34:52 +00001846 E->setAssociatedStmt(Record.readSubStmt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001847}
1848
Alexander Musman3aaab662014-08-19 11:27:13 +00001849void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
1850 VisitStmt(D);
1851 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001852 Record.skipInts(2);
Alexander Musman3aaab662014-08-19 11:27:13 +00001853 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001854 D->setIterationVariable(Record.readSubExpr());
1855 D->setLastIteration(Record.readSubExpr());
1856 D->setCalcLastIteration(Record.readSubExpr());
1857 D->setPreCond(Record.readSubExpr());
1858 D->setCond(Record.readSubExpr());
1859 D->setInit(Record.readSubExpr());
1860 D->setInc(Record.readSubExpr());
1861 D->setPreInits(Record.readSubStmt());
Alexey Bataev3392d762016-02-16 11:18:12 +00001862 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
Carlo Bertollifc35ad22016-03-07 16:04:49 +00001863 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
1864 isOpenMPDistributeDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001865 D->setIsLastIterVariable(Record.readSubExpr());
1866 D->setLowerBoundVariable(Record.readSubExpr());
1867 D->setUpperBoundVariable(Record.readSubExpr());
1868 D->setStrideVariable(Record.readSubExpr());
1869 D->setEnsureUpperBound(Record.readSubExpr());
1870 D->setNextLowerBound(Record.readSubExpr());
1871 D->setNextUpperBound(Record.readSubExpr());
1872 D->setNumIterations(Record.readSubExpr());
Alexander Musmanc6388682014-12-15 07:07:06 +00001873 }
Carlo Bertolli9925f152016-06-27 14:55:37 +00001874 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001875 D->setPrevLowerBoundVariable(Record.readSubExpr());
1876 D->setPrevUpperBoundVariable(Record.readSubExpr());
Carlo Bertolli8429d812017-02-17 21:29:13 +00001877 D->setDistInc(Record.readSubExpr());
1878 D->setPrevEnsureUpperBound(Record.readSubExpr());
Carlo Bertolliffafe102017-04-20 00:39:39 +00001879 D->setCombinedLowerBoundVariable(Record.readSubExpr());
1880 D->setCombinedUpperBoundVariable(Record.readSubExpr());
1881 D->setCombinedEnsureUpperBound(Record.readSubExpr());
1882 D->setCombinedInit(Record.readSubExpr());
1883 D->setCombinedCond(Record.readSubExpr());
1884 D->setCombinedNextLowerBound(Record.readSubExpr());
1885 D->setCombinedNextUpperBound(Record.readSubExpr());
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001886 D->setCombinedDistCond(Record.readSubExpr());
1887 D->setCombinedParForInDistCond(Record.readSubExpr());
Carlo Bertolli9925f152016-06-27 14:55:37 +00001888 }
Alexander Musmana5f070a2014-10-01 06:03:56 +00001889 SmallVector<Expr *, 4> Sub;
1890 unsigned CollapsedNum = D->getCollapsedNumber();
1891 Sub.reserve(CollapsedNum);
1892 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001893 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00001894 D->setCounters(Sub);
1895 Sub.clear();
1896 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001897 Sub.push_back(Record.readSubExpr());
Alexey Bataeva8899172015-08-06 12:30:57 +00001898 D->setPrivateCounters(Sub);
1899 Sub.clear();
1900 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001901 Sub.push_back(Record.readSubExpr());
Alexey Bataevb08f89f2015-08-14 12:25:37 +00001902 D->setInits(Sub);
1903 Sub.clear();
1904 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001905 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00001906 D->setUpdates(Sub);
1907 Sub.clear();
1908 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001909 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00001910 D->setFinals(Sub);
Alexander Musman3aaab662014-08-19 11:27:13 +00001911}
1912
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001913void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
Alexey Bataev1b59ab52014-02-27 08:29:12 +00001914 VisitStmt(D);
1915 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001916 Record.skipInts(1);
Alexey Bataev1b59ab52014-02-27 08:29:12 +00001917 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001918 D->setHasCancel(Record.readInt());
Alexey Bataev1b59ab52014-02-27 08:29:12 +00001919}
1920
1921void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00001922 VisitOMPLoopDirective(D);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001923}
1924
Alexey Bataevf29276e2014-06-18 04:14:57 +00001925void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00001926 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001927 D->setHasCancel(Record.readInt());
Alexey Bataevf29276e2014-06-18 04:14:57 +00001928}
1929
Alexander Musmanf82886e2014-09-18 05:12:34 +00001930void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
1931 VisitOMPLoopDirective(D);
1932}
1933
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00001934void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
1935 VisitStmt(D);
1936 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001937 Record.skipInts(1);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00001938 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001939 D->setHasCancel(Record.readInt());
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00001940}
1941
Alexey Bataev1e0498a2014-06-26 08:21:58 +00001942void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
1943 VisitStmt(D);
1944 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001945 D->setHasCancel(Record.readInt());
Alexey Bataev1e0498a2014-06-26 08:21:58 +00001946}
1947
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00001948void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *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 Bataevd1e40fb2014-06-26 12:05:45 +00001952 VisitOMPExecutableDirective(D);
1953}
1954
Alexander Musman80c22892014-07-17 08:54:58 +00001955void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
1956 VisitStmt(D);
1957 VisitOMPExecutableDirective(D);
1958}
1959
Alexander Musmand9ed09f2014-07-21 09:42:05 +00001960void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
1961 VisitStmt(D);
Alexey Bataev28c75412015-12-15 08:19:24 +00001962 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001963 Record.skipInts(1);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00001964 VisitOMPExecutableDirective(D);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001965 ReadDeclarationNameInfo(D->DirName);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00001966}
1967
Alexey Bataev4acb8592014-07-07 13:01:15 +00001968void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00001969 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001970 D->setHasCancel(Record.readInt());
Alexey Bataev4acb8592014-07-07 13:01:15 +00001971}
1972
Alexander Musmane4e893b2014-09-23 09:33:00 +00001973void ASTStmtReader::VisitOMPParallelForSimdDirective(
1974 OMPParallelForSimdDirective *D) {
1975 VisitOMPLoopDirective(D);
1976}
1977
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00001978void ASTStmtReader::VisitOMPParallelSectionsDirective(
1979 OMPParallelSectionsDirective *D) {
1980 VisitStmt(D);
1981 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001982 Record.skipInts(1);
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00001983 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001984 D->setHasCancel(Record.readInt());
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00001985}
1986
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00001987void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
1988 VisitStmt(D);
1989 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001990 Record.skipInts(1);
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00001991 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001992 D->setHasCancel(Record.readInt());
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00001993}
1994
Alexey Bataev68446b72014-07-18 07:47:19 +00001995void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
1996 VisitStmt(D);
1997 VisitOMPExecutableDirective(D);
1998}
1999
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002000void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2001 VisitStmt(D);
2002 VisitOMPExecutableDirective(D);
2003}
2004
Alexey Bataev2df347a2014-07-18 10:17:07 +00002005void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2006 VisitStmt(D);
2007 VisitOMPExecutableDirective(D);
2008}
2009
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002010void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2011 VisitStmt(D);
Alexey Bataev169d96a2017-07-18 20:17:46 +00002012 // The NumClauses field was read in ReadStmtFromStream.
2013 Record.skipInts(1);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002014 VisitOMPExecutableDirective(D);
Alexey Bataev3b1b8952017-07-25 15:53:26 +00002015 D->setReductionRef(Record.readSubExpr());
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002016}
2017
Alexey Bataev6125da92014-07-21 11:26:11 +00002018void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2019 VisitStmt(D);
2020 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002021 Record.skipInts(1);
Alexey Bataev6125da92014-07-21 11:26:11 +00002022 VisitOMPExecutableDirective(D);
2023}
2024
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002025void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2026 VisitStmt(D);
Alexey Bataev346265e2015-09-25 10:37:12 +00002027 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002028 Record.skipInts(1);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002029 VisitOMPExecutableDirective(D);
2030}
2031
Alexey Bataev0162e452014-07-22 10:10:35 +00002032void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *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 Bataev0162e452014-07-22 10:10:35 +00002036 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002037 D->setX(Record.readSubExpr());
2038 D->setV(Record.readSubExpr());
2039 D->setExpr(Record.readSubExpr());
2040 D->setUpdateExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002041 D->IsXLHSInRHSPart = Record.readInt() != 0;
2042 D->IsPostfixUpdate = Record.readInt() != 0;
Alexey Bataev0162e452014-07-22 10:10:35 +00002043}
2044
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002045void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2046 VisitStmt(D);
2047 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002048 Record.skipInts(1);
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002049 VisitOMPExecutableDirective(D);
2050}
2051
Michael Wong65f367f2015-07-21 13:44:28 +00002052void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2053 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002054 Record.skipInts(1);
Michael Wong65f367f2015-07-21 13:44:28 +00002055 VisitOMPExecutableDirective(D);
2056}
2057
Samuel Antaodf67fc42016-01-19 19:15:56 +00002058void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2059 OMPTargetEnterDataDirective *D) {
2060 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002061 Record.skipInts(1);
Samuel Antaodf67fc42016-01-19 19:15:56 +00002062 VisitOMPExecutableDirective(D);
2063}
2064
Samuel Antao72590762016-01-19 20:04:50 +00002065void ASTStmtReader::VisitOMPTargetExitDataDirective(
2066 OMPTargetExitDataDirective *D) {
2067 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002068 Record.skipInts(1);
Samuel Antao72590762016-01-19 20:04:50 +00002069 VisitOMPExecutableDirective(D);
2070}
2071
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002072void ASTStmtReader::VisitOMPTargetParallelDirective(
2073 OMPTargetParallelDirective *D) {
2074 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002075 Record.skipInts(1);
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002076 VisitOMPExecutableDirective(D);
2077}
2078
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002079void ASTStmtReader::VisitOMPTargetParallelForDirective(
2080 OMPTargetParallelForDirective *D) {
2081 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002082 D->setHasCancel(Record.readInt());
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002083}
2084
Alexey Bataev13314bf2014-10-09 04:18:56 +00002085void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2086 VisitStmt(D);
2087 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002088 Record.skipInts(1);
Alexey Bataev13314bf2014-10-09 04:18:56 +00002089 VisitOMPExecutableDirective(D);
2090}
2091
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002092void ASTStmtReader::VisitOMPCancellationPointDirective(
2093 OMPCancellationPointDirective *D) {
2094 VisitStmt(D);
2095 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002096 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002097}
2098
Alexey Bataev80909872015-07-02 11:25:17 +00002099void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2100 VisitStmt(D);
Alexey Bataev87933c72015-09-18 08:07:34 +00002101 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002102 Record.skipInts(1);
Alexey Bataev80909872015-07-02 11:25:17 +00002103 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002104 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev80909872015-07-02 11:25:17 +00002105}
2106
Alexey Bataev49f6e782015-12-01 04:18:41 +00002107void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2108 VisitOMPLoopDirective(D);
2109}
2110
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002111void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2112 VisitOMPLoopDirective(D);
2113}
2114
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002115void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2116 VisitOMPLoopDirective(D);
2117}
2118
Samuel Antao686c70c2016-05-26 17:30:50 +00002119void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2120 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002121 Record.skipInts(1);
Samuel Antao686c70c2016-05-26 17:30:50 +00002122 VisitOMPExecutableDirective(D);
2123}
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002124
Carlo Bertolli9925f152016-06-27 14:55:37 +00002125void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2126 OMPDistributeParallelForDirective *D) {
2127 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002128 D->setHasCancel(Record.readInt());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002129}
Samuel Antao686c70c2016-05-26 17:30:50 +00002130
Kelvin Li4a39add2016-07-05 05:00:15 +00002131void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2132 OMPDistributeParallelForSimdDirective *D) {
2133 VisitOMPLoopDirective(D);
2134}
2135
Kelvin Li787f3fc2016-07-06 04:45:38 +00002136void ASTStmtReader::VisitOMPDistributeSimdDirective(
2137 OMPDistributeSimdDirective *D) {
2138 VisitOMPLoopDirective(D);
2139}
2140
Kelvin Lia579b912016-07-14 02:54:56 +00002141void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2142 OMPTargetParallelForSimdDirective *D) {
2143 VisitOMPLoopDirective(D);
2144}
2145
Kelvin Li986330c2016-07-20 22:57:10 +00002146void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2147 VisitOMPLoopDirective(D);
2148}
2149
Kelvin Li02532872016-08-05 14:37:37 +00002150void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2151 OMPTeamsDistributeDirective *D) {
2152 VisitOMPLoopDirective(D);
2153}
2154
Kelvin Li4e325f72016-10-25 12:50:55 +00002155void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2156 OMPTeamsDistributeSimdDirective *D) {
2157 VisitOMPLoopDirective(D);
2158}
2159
Kelvin Li579e41c2016-11-30 23:51:03 +00002160void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2161 OMPTeamsDistributeParallelForSimdDirective *D) {
2162 VisitOMPLoopDirective(D);
2163}
2164
Kelvin Li7ade93f2016-12-09 03:24:30 +00002165void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2166 OMPTeamsDistributeParallelForDirective *D) {
2167 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002168 D->setHasCancel(Record.readInt());
Kelvin Li7ade93f2016-12-09 03:24:30 +00002169}
2170
Kelvin Libf594a52016-12-17 05:48:59 +00002171void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2172 VisitStmt(D);
2173 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002174 Record.skipInts(1);
Kelvin Libf594a52016-12-17 05:48:59 +00002175 VisitOMPExecutableDirective(D);
2176}
2177
Kelvin Li83c451e2016-12-25 04:52:54 +00002178void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2179 OMPTargetTeamsDistributeDirective *D) {
2180 VisitOMPLoopDirective(D);
2181}
2182
Kelvin Li80e8f562016-12-29 22:16:30 +00002183void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2184 OMPTargetTeamsDistributeParallelForDirective *D) {
2185 VisitOMPLoopDirective(D);
Alexey Bataev16e79882017-11-22 21:12:03 +00002186 D->setHasCancel(Record.readInt());
Kelvin Li80e8f562016-12-29 22:16:30 +00002187}
2188
Kelvin Li1851df52017-01-03 05:23:48 +00002189void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2190 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2191 VisitOMPLoopDirective(D);
2192}
2193
Kelvin Lida681182017-01-10 18:08:18 +00002194void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2195 OMPTargetTeamsDistributeSimdDirective *D) {
2196 VisitOMPLoopDirective(D);
2197}
2198
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002199//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002200// ASTReader Implementation
2201//===----------------------------------------------------------------------===//
2202
Douglas Gregorde3ef502011-11-30 23:21:26 +00002203Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002204 switch (ReadingKind) {
Richard Smith629ff362013-07-31 00:26:46 +00002205 case Read_None:
2206 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002207 case Read_Decl:
2208 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00002209 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002210 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002211 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002212 }
2213
2214 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002215}
2216
Douglas Gregorde3ef502011-11-30 23:21:26 +00002217Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00002218 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002219}
Chris Lattnere2437f42010-05-09 06:40:08 +00002220
Sebastian Redl2c499f62010-08-18 23:56:43 +00002221Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002222 return cast_or_null<Expr>(ReadSubStmt());
2223}
2224
Chris Lattnerf4262532009-04-27 05:41:06 +00002225// Within the bitstream, expressions are stored in Reverse Polish
2226// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002227// expression they are stored in. Subexpressions are stored from last to first.
2228// To evaluate expressions, we continue reading expressions and placing them on
2229// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00002230// stack. Evaluation terminates when we see a STMT_STOP record, and
2231// the single remaining expression on the stack is our result.
Douglas Gregorde3ef502011-11-30 23:21:26 +00002232Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002233 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00002234 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002235
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002236 // Map of offset to previously deserialized stmt. The offset points
George Burgess IV758cf9d2017-02-14 05:52:57 +00002237 // just after the stmt record.
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002238 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00002239
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002240#ifndef NDEBUG
2241 unsigned PrevNumStmts = StmtStack.size();
2242#endif
2243
David L. Jonesbe1557a2016-12-21 00:17:49 +00002244 ASTRecordReader Record(*this, F);
2245 ASTStmtReader Reader(Record, Cursor);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002246 Stmt::EmptyShell Empty;
2247
2248 while (true) {
Chris Lattner0e6c9402013-01-20 02:38:54 +00002249 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002250
Chris Lattner0e6c9402013-01-20 02:38:54 +00002251 switch (Entry.Kind) {
2252 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2253 case llvm::BitstreamEntry::Error:
2254 Error("malformed block record in AST file");
Craig Toppera13603a2014-05-22 05:54:18 +00002255 return nullptr;
Chris Lattner0e6c9402013-01-20 02:38:54 +00002256 case llvm::BitstreamEntry::EndBlock:
2257 goto Done;
2258 case llvm::BitstreamEntry::Record:
2259 // The interesting case.
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002260 break;
2261 }
2262
Richard Smithdbafb6c2017-06-29 23:23:46 +00002263 ASTContext &Context = getContext();
Craig Toppera13603a2014-05-22 05:54:18 +00002264 Stmt *S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002265 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002266 bool IsStmtReference = false;
David L. Jonesbe1557a2016-12-21 00:17:49 +00002267 switch ((StmtCode)Record.readRecord(Cursor, Entry.ID)) {
Sebastian Redl539c5062010-08-18 23:57:32 +00002268 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002269 Finished = true;
2270 break;
2271
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002272 case STMT_REF_PTR:
2273 IsStmtReference = true;
2274 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2275 "No stmt was recorded for this offset reference!");
David L. Jonesbe1557a2016-12-21 00:17:49 +00002276 S = StmtEntries[Record.readInt()];
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002277 break;
2278
Sebastian Redl539c5062010-08-18 23:57:32 +00002279 case STMT_NULL_PTR:
Craig Toppera13603a2014-05-22 05:54:18 +00002280 S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002281 break;
2282
Sebastian Redl539c5062010-08-18 23:57:32 +00002283 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002284 S = new (Context) NullStmt(Empty);
2285 break;
2286
Sebastian Redl539c5062010-08-18 23:57:32 +00002287 case STMT_COMPOUND:
Benjamin Kramer07420902017-12-24 16:24:20 +00002288 S = CompoundStmt::CreateEmpty(
2289 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002290 break;
2291
Sebastian Redl539c5062010-08-18 23:57:32 +00002292 case STMT_CASE:
Bruno Ricci5b30571752018-10-28 12:30:53 +00002293 S = CaseStmt::CreateEmpty(
2294 Context,
2295 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002296 break;
2297
Sebastian Redl539c5062010-08-18 23:57:32 +00002298 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002299 S = new (Context) DefaultStmt(Empty);
2300 break;
2301
Sebastian Redl539c5062010-08-18 23:57:32 +00002302 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002303 S = new (Context) LabelStmt(Empty);
2304 break;
2305
Richard Smithc202b282012-04-14 00:33:13 +00002306 case STMT_ATTRIBUTED:
Alexander Kornienko20f6fc62012-07-09 10:04:07 +00002307 S = AttributedStmt::CreateEmpty(
2308 Context,
2309 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smithc202b282012-04-14 00:33:13 +00002310 break;
2311
Sebastian Redl539c5062010-08-18 23:57:32 +00002312 case STMT_IF:
Bruno Riccib1cc94b2018-10-27 21:12:20 +00002313 S = IfStmt::CreateEmpty(
2314 Context,
2315 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2316 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2317 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002318 break;
2319
Sebastian Redl539c5062010-08-18 23:57:32 +00002320 case STMT_SWITCH:
Bruno Riccie2806f82018-10-29 16:12:37 +00002321 S = SwitchStmt::CreateEmpty(
2322 Context,
2323 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 0],
2324 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002325 break;
2326
Sebastian Redl539c5062010-08-18 23:57:32 +00002327 case STMT_WHILE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002328 S = new (Context) WhileStmt(Empty);
2329 break;
2330
Sebastian Redl539c5062010-08-18 23:57:32 +00002331 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002332 S = new (Context) DoStmt(Empty);
2333 break;
Mike Stump11289f42009-09-09 15:08:12 +00002334
Sebastian Redl539c5062010-08-18 23:57:32 +00002335 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002336 S = new (Context) ForStmt(Empty);
2337 break;
2338
Sebastian Redl539c5062010-08-18 23:57:32 +00002339 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002340 S = new (Context) GotoStmt(Empty);
2341 break;
Mike Stump11289f42009-09-09 15:08:12 +00002342
Sebastian Redl539c5062010-08-18 23:57:32 +00002343 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002344 S = new (Context) IndirectGotoStmt(Empty);
2345 break;
2346
Sebastian Redl539c5062010-08-18 23:57:32 +00002347 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002348 S = new (Context) ContinueStmt(Empty);
2349 break;
2350
Sebastian Redl539c5062010-08-18 23:57:32 +00002351 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002352 S = new (Context) BreakStmt(Empty);
2353 break;
2354
Sebastian Redl539c5062010-08-18 23:57:32 +00002355 case STMT_RETURN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002356 S = new (Context) ReturnStmt(Empty);
2357 break;
2358
Sebastian Redl539c5062010-08-18 23:57:32 +00002359 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002360 S = new (Context) DeclStmt(Empty);
2361 break;
2362
Chad Rosierde70e0e2012-08-25 00:11:56 +00002363 case STMT_GCCASM:
2364 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002365 break;
2366
Chad Rosiere30d4992012-08-24 23:51:02 +00002367 case STMT_MSASM:
2368 S = new (Context) MSAsmStmt(Empty);
2369 break;
2370
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002371 case STMT_CAPTURED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002372 S = CapturedStmt::CreateDeserialized(
2373 Context, Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002374 break;
2375
Sebastian Redl539c5062010-08-18 23:57:32 +00002376 case EXPR_PREDEFINED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002377 S = PredefinedExpr::CreateEmpty(
2378 Context,
2379 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002380 break;
Mike Stump11289f42009-09-09 15:08:12 +00002381
Sebastian Redl539c5062010-08-18 23:57:32 +00002382 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002383 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00002384 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002385 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2386 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnara7945c982012-01-27 09:46:47 +00002387 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002388 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
John McCall113bee02012-03-10 09:33:50 +00002389 Record[ASTStmtReader::NumExprFields + 5] : 0);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002390 break;
Mike Stump11289f42009-09-09 15:08:12 +00002391
Sebastian Redl539c5062010-08-18 23:57:32 +00002392 case EXPR_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002393 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002394 break;
Mike Stump11289f42009-09-09 15:08:12 +00002395
Sebastian Redl539c5062010-08-18 23:57:32 +00002396 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002397 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002398 break;
Mike Stump11289f42009-09-09 15:08:12 +00002399
Sebastian Redl539c5062010-08-18 23:57:32 +00002400 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002401 S = new (Context) ImaginaryLiteral(Empty);
2402 break;
2403
Sebastian Redl539c5062010-08-18 23:57:32 +00002404 case EXPR_STRING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002405 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002406 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002407 break;
2408
Sebastian Redl539c5062010-08-18 23:57:32 +00002409 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002410 S = new (Context) CharacterLiteral(Empty);
2411 break;
2412
Sebastian Redl539c5062010-08-18 23:57:32 +00002413 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002414 S = new (Context) ParenExpr(Empty);
2415 break;
2416
Sebastian Redl539c5062010-08-18 23:57:32 +00002417 case EXPR_PAREN_LIST:
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00002418 S = new (Context) ParenListExpr(Empty);
2419 break;
2420
Sebastian Redl539c5062010-08-18 23:57:32 +00002421 case EXPR_UNARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002422 S = new (Context) UnaryOperator(Empty);
2423 break;
2424
Sebastian Redl539c5062010-08-18 23:57:32 +00002425 case EXPR_OFFSETOF:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002426 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002427 Record[ASTStmtReader::NumExprFields],
2428 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00002429 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002430
Sebastian Redl539c5062010-08-18 23:57:32 +00002431 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00002432 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002433 break;
2434
Sebastian Redl539c5062010-08-18 23:57:32 +00002435 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002436 S = new (Context) ArraySubscriptExpr(Empty);
2437 break;
2438
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002439 case EXPR_OMP_ARRAY_SECTION:
2440 S = new (Context) OMPArraySectionExpr(Empty);
2441 break;
2442
Sebastian Redl539c5062010-08-18 23:57:32 +00002443 case EXPR_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002444 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002445 break;
2446
Sebastian Redl539c5062010-08-18 23:57:32 +00002447 case EXPR_MEMBER: {
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002448 // We load everything here and fully initialize it at creation.
2449 // That way we can use MemberExpr::Create and don't have to duplicate its
2450 // logic with a MemberExpr::CreateEmpty.
2451
David L. Jonesbe1557a2016-12-21 00:17:49 +00002452 assert(Record.getIdx() == 0);
Douglas Gregorea972d32011-02-28 21:54:11 +00002453 NestedNameSpecifierLoc QualifierLoc;
David L. Jonesbe1557a2016-12-21 00:17:49 +00002454 if (Record.readInt()) { // HasQualifier.
David L. Jonesb6a8f022016-12-21 04:34:52 +00002455 QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002456 }
2457
Abramo Bagnara7945c982012-01-27 09:46:47 +00002458 SourceLocation TemplateKWLoc;
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002459 TemplateArgumentListInfo ArgInfo;
David L. Jonesbe1557a2016-12-21 00:17:49 +00002460 bool HasTemplateKWAndArgsInfo = Record.readInt();
Abramo Bagnara7945c982012-01-27 09:46:47 +00002461 if (HasTemplateKWAndArgsInfo) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002462 TemplateKWLoc = Record.readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002463 unsigned NumTemplateArgs = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002464 ArgInfo.setLAngleLoc(Record.readSourceLocation());
2465 ArgInfo.setRAngleLoc(Record.readSourceLocation());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002466 for (unsigned i = 0; i != NumTemplateArgs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002467 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002468 }
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00002469
David L. Jonesbe1557a2016-12-21 00:17:49 +00002470 bool HadMultipleCandidates = Record.readInt();
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00002471
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002472 auto *FoundD = Record.readDeclAs<NamedDecl>();
2473 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002474 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
2475
David L. Jonesbe1557a2016-12-21 00:17:49 +00002476 QualType T = Record.readType();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002477 auto VK = static_cast<ExprValueKind>(Record.readInt());
2478 auto OK = static_cast<ExprObjectKind>(Record.readInt());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002479 Expr *Base = ReadSubExpr();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002480 auto *MemberD = Record.readDeclAs<ValueDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002481 SourceLocation MemberLoc = Record.readSourceLocation();
Yunzhong Gaoeba323a2015-05-01 02:04:32 +00002482 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002483 bool IsArrow = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002484 SourceLocation OperatorLoc = Record.readSourceLocation();
Yunzhong Gaoeba323a2015-05-01 02:04:32 +00002485
2486 S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc,
2487 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
2488 HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T,
2489 VK, OK);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002490 Record.readDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc,
David L. Jonesbe1557a2016-12-21 00:17:49 +00002491 MemberD->getDeclName());
Yunzhong Gaoeba323a2015-05-01 02:04:32 +00002492 if (HadMultipleCandidates)
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00002493 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002494 break;
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002495 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002496
Sebastian Redl539c5062010-08-18 23:57:32 +00002497 case EXPR_BINARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002498 S = new (Context) BinaryOperator(Empty);
2499 break;
2500
Sebastian Redl539c5062010-08-18 23:57:32 +00002501 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002502 S = new (Context) CompoundAssignOperator(Empty);
2503 break;
2504
Sebastian Redl539c5062010-08-18 23:57:32 +00002505 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002506 S = new (Context) ConditionalOperator(Empty);
2507 break;
2508
John McCallc07a0c72011-02-17 10:25:35 +00002509 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2510 S = new (Context) BinaryConditionalOperator(Empty);
2511 break;
2512
Sebastian Redl539c5062010-08-18 23:57:32 +00002513 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002514 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002515 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002516 break;
2517
Sebastian Redl539c5062010-08-18 23:57:32 +00002518 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002519 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002520 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002521 break;
2522
Sebastian Redl539c5062010-08-18 23:57:32 +00002523 case EXPR_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002524 S = new (Context) CompoundLiteralExpr(Empty);
2525 break;
2526
Sebastian Redl539c5062010-08-18 23:57:32 +00002527 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002528 S = new (Context) ExtVectorElementExpr(Empty);
2529 break;
2530
Sebastian Redl539c5062010-08-18 23:57:32 +00002531 case EXPR_INIT_LIST:
Argyrios Kyrtzidis0f05fb92012-11-28 03:56:16 +00002532 S = new (Context) InitListExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002533 break;
2534
Sebastian Redl539c5062010-08-18 23:57:32 +00002535 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002536 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002537 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00002538
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002539 break;
2540
Yunzhong Gaocb779302015-06-10 00:27:52 +00002541 case EXPR_DESIGNATED_INIT_UPDATE:
2542 S = new (Context) DesignatedInitUpdateExpr(Empty);
2543 break;
2544
Sebastian Redl539c5062010-08-18 23:57:32 +00002545 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002546 S = new (Context) ImplicitValueInitExpr(Empty);
2547 break;
2548
Yunzhong Gaocb779302015-06-10 00:27:52 +00002549 case EXPR_NO_INIT:
2550 S = new (Context) NoInitExpr(Empty);
2551 break;
2552
Richard Smith410306b2016-12-12 02:53:20 +00002553 case EXPR_ARRAY_INIT_LOOP:
2554 S = new (Context) ArrayInitLoopExpr(Empty);
2555 break;
2556
2557 case EXPR_ARRAY_INIT_INDEX:
2558 S = new (Context) ArrayInitIndexExpr(Empty);
2559 break;
2560
Sebastian Redl539c5062010-08-18 23:57:32 +00002561 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002562 S = new (Context) VAArgExpr(Empty);
2563 break;
2564
Sebastian Redl539c5062010-08-18 23:57:32 +00002565 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002566 S = new (Context) AddrLabelExpr(Empty);
2567 break;
2568
Sebastian Redl539c5062010-08-18 23:57:32 +00002569 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002570 S = new (Context) StmtExpr(Empty);
2571 break;
2572
Sebastian Redl539c5062010-08-18 23:57:32 +00002573 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002574 S = new (Context) ChooseExpr(Empty);
2575 break;
2576
Sebastian Redl539c5062010-08-18 23:57:32 +00002577 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002578 S = new (Context) GNUNullExpr(Empty);
2579 break;
2580
Sebastian Redl539c5062010-08-18 23:57:32 +00002581 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002582 S = new (Context) ShuffleVectorExpr(Empty);
2583 break;
Mike Stump11289f42009-09-09 15:08:12 +00002584
Hal Finkelc4d7c822013-09-18 03:29:45 +00002585 case EXPR_CONVERT_VECTOR:
2586 S = new (Context) ConvertVectorExpr(Empty);
2587 break;
2588
Sebastian Redl539c5062010-08-18 23:57:32 +00002589 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002590 S = new (Context) BlockExpr(Empty);
2591 break;
2592
Peter Collingbourne91147592011-04-15 00:35:48 +00002593 case EXPR_GENERIC_SELECTION:
2594 S = new (Context) GenericSelectionExpr(Empty);
2595 break;
2596
Sebastian Redl539c5062010-08-18 23:57:32 +00002597 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002598 S = new (Context) ObjCStringLiteral(Empty);
2599 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002600
Patrick Beard0caa3942012-04-19 00:25:12 +00002601 case EXPR_OBJC_BOXED_EXPRESSION:
2602 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremeneke65b0862012-03-06 20:05:56 +00002603 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002604
Ted Kremeneke65b0862012-03-06 20:05:56 +00002605 case EXPR_OBJC_ARRAY_LITERAL:
2606 S = ObjCArrayLiteral::CreateEmpty(Context,
2607 Record[ASTStmtReader::NumExprFields]);
2608 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002609
Ted Kremeneke65b0862012-03-06 20:05:56 +00002610 case EXPR_OBJC_DICTIONARY_LITERAL:
2611 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2612 Record[ASTStmtReader::NumExprFields],
2613 Record[ASTStmtReader::NumExprFields + 1]);
2614 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002615
Sebastian Redl539c5062010-08-18 23:57:32 +00002616 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002617 S = new (Context) ObjCEncodeExpr(Empty);
2618 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002619
Sebastian Redl539c5062010-08-18 23:57:32 +00002620 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002621 S = new (Context) ObjCSelectorExpr(Empty);
2622 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002623
Sebastian Redl539c5062010-08-18 23:57:32 +00002624 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002625 S = new (Context) ObjCProtocolExpr(Empty);
2626 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002627
Sebastian Redl539c5062010-08-18 23:57:32 +00002628 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002629 S = new (Context) ObjCIvarRefExpr(Empty);
2630 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002631
Sebastian Redl539c5062010-08-18 23:57:32 +00002632 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002633 S = new (Context) ObjCPropertyRefExpr(Empty);
2634 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002635
Ted Kremeneke65b0862012-03-06 20:05:56 +00002636 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2637 S = new (Context) ObjCSubscriptRefExpr(Empty);
2638 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002639
Sebastian Redl539c5062010-08-18 23:57:32 +00002640 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00002641 llvm_unreachable("mismatching AST file");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002642
Sebastian Redl539c5062010-08-18 23:57:32 +00002643 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002644 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00002645 Record[ASTStmtReader::NumExprFields],
2646 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002647 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002648
Sebastian Redl539c5062010-08-18 23:57:32 +00002649 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00002650 S = new (Context) ObjCIsaExpr(Empty);
2651 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002652
John McCall31168b02011-06-15 23:02:42 +00002653 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2654 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2655 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002656
John McCall31168b02011-06-15 23:02:42 +00002657 case EXPR_OBJC_BRIDGED_CAST:
2658 S = new (Context) ObjCBridgedCastExpr(Empty);
2659 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002660
Sebastian Redl539c5062010-08-18 23:57:32 +00002661 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002662 S = new (Context) ObjCForCollectionStmt(Empty);
2663 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002664
Sebastian Redl539c5062010-08-18 23:57:32 +00002665 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002666 S = new (Context) ObjCAtCatchStmt(Empty);
2667 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002668
Sebastian Redl539c5062010-08-18 23:57:32 +00002669 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002670 S = new (Context) ObjCAtFinallyStmt(Empty);
2671 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002672
Sebastian Redl539c5062010-08-18 23:57:32 +00002673 case STMT_OBJC_AT_TRY:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002674 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002675 Record[ASTStmtReader::NumStmtFields],
2676 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002677 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002678
Sebastian Redl539c5062010-08-18 23:57:32 +00002679 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002680 S = new (Context) ObjCAtSynchronizedStmt(Empty);
2681 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002682
Sebastian Redl539c5062010-08-18 23:57:32 +00002683 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002684 S = new (Context) ObjCAtThrowStmt(Empty);
2685 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002686
John McCall31168b02011-06-15 23:02:42 +00002687 case STMT_OBJC_AUTORELEASE_POOL:
2688 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2689 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002690
Ted Kremeneke65b0862012-03-06 20:05:56 +00002691 case EXPR_OBJC_BOOL_LITERAL:
2692 S = new (Context) ObjCBoolLiteralExpr(Empty);
2693 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002694
Erik Pilkington29099de2016-07-16 00:35:23 +00002695 case EXPR_OBJC_AVAILABILITY_CHECK:
2696 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
2697 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002698
Nico Weber9b982072014-07-07 00:12:30 +00002699 case STMT_SEH_LEAVE:
2700 S = new (Context) SEHLeaveStmt(Empty);
2701 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002702
John McCallfa194042011-07-15 07:00:14 +00002703 case STMT_SEH_EXCEPT:
2704 S = new (Context) SEHExceptStmt(Empty);
2705 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002706
John McCallfa194042011-07-15 07:00:14 +00002707 case STMT_SEH_FINALLY:
2708 S = new (Context) SEHFinallyStmt(Empty);
2709 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002710
John McCallfa194042011-07-15 07:00:14 +00002711 case STMT_SEH_TRY:
2712 S = new (Context) SEHTryStmt(Empty);
2713 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002714
Sebastian Redl539c5062010-08-18 23:57:32 +00002715 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00002716 S = new (Context) CXXCatchStmt(Empty);
2717 break;
2718
Sebastian Redl539c5062010-08-18 23:57:32 +00002719 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002720 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002721 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00002722 break;
2723
Richard Smith02e85f32011-04-14 22:09:26 +00002724 case STMT_CXX_FOR_RANGE:
2725 S = new (Context) CXXForRangeStmt(Empty);
2726 break;
2727
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00002728 case STMT_MS_DEPENDENT_EXISTS:
2729 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2730 NestedNameSpecifierLoc(),
2731 DeclarationNameInfo(),
Craig Toppera13603a2014-05-22 05:54:18 +00002732 nullptr);
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00002733 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002734
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002735 case STMT_OMP_PARALLEL_DIRECTIVE:
2736 S =
2737 OMPParallelDirective::CreateEmpty(Context,
2738 Record[ASTStmtReader::NumStmtFields],
2739 Empty);
2740 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002741
2742 case STMT_OMP_SIMD_DIRECTIVE: {
2743 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2744 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2745 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
2746 CollapsedNum, Empty);
2747 break;
2748 }
2749
Alexey Bataevf29276e2014-06-18 04:14:57 +00002750 case STMT_OMP_FOR_DIRECTIVE: {
2751 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2752 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2753 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2754 Empty);
2755 break;
2756 }
2757
Alexander Musmanf82886e2014-09-18 05:12:34 +00002758 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
2759 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2760 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2761 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2762 Empty);
2763 break;
2764 }
2765
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002766 case STMT_OMP_SECTIONS_DIRECTIVE:
2767 S = OMPSectionsDirective::CreateEmpty(
2768 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2769 break;
2770
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002771 case STMT_OMP_SECTION_DIRECTIVE:
2772 S = OMPSectionDirective::CreateEmpty(Context, Empty);
2773 break;
2774
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002775 case STMT_OMP_SINGLE_DIRECTIVE:
2776 S = OMPSingleDirective::CreateEmpty(
2777 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2778 break;
2779
Alexander Musman80c22892014-07-17 08:54:58 +00002780 case STMT_OMP_MASTER_DIRECTIVE:
2781 S = OMPMasterDirective::CreateEmpty(Context, Empty);
2782 break;
2783
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002784 case STMT_OMP_CRITICAL_DIRECTIVE:
Alexey Bataev28c75412015-12-15 08:19:24 +00002785 S = OMPCriticalDirective::CreateEmpty(
2786 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002787 break;
2788
Alexey Bataev4acb8592014-07-07 13:01:15 +00002789 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
2790 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2791 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2792 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
2793 CollapsedNum, Empty);
2794 break;
2795 }
2796
Alexander Musmane4e893b2014-09-23 09:33:00 +00002797 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
2798 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2799 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2800 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2801 CollapsedNum, Empty);
2802 break;
2803 }
2804
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002805 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
2806 S = OMPParallelSectionsDirective::CreateEmpty(
2807 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2808 break;
2809
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002810 case STMT_OMP_TASK_DIRECTIVE:
2811 S = OMPTaskDirective::CreateEmpty(
2812 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2813 break;
2814
Alexey Bataev68446b72014-07-18 07:47:19 +00002815 case STMT_OMP_TASKYIELD_DIRECTIVE:
2816 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
2817 break;
2818
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002819 case STMT_OMP_BARRIER_DIRECTIVE:
2820 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
2821 break;
2822
Alexey Bataev2df347a2014-07-18 10:17:07 +00002823 case STMT_OMP_TASKWAIT_DIRECTIVE:
2824 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
2825 break;
2826
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002827 case STMT_OMP_TASKGROUP_DIRECTIVE:
Alexey Bataev169d96a2017-07-18 20:17:46 +00002828 S = OMPTaskgroupDirective::CreateEmpty(
2829 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002830 break;
2831
Alexey Bataev6125da92014-07-21 11:26:11 +00002832 case STMT_OMP_FLUSH_DIRECTIVE:
2833 S = OMPFlushDirective::CreateEmpty(
2834 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2835 break;
2836
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002837 case STMT_OMP_ORDERED_DIRECTIVE:
Alexey Bataev346265e2015-09-25 10:37:12 +00002838 S = OMPOrderedDirective::CreateEmpty(
2839 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002840 break;
2841
Alexey Bataev0162e452014-07-22 10:10:35 +00002842 case STMT_OMP_ATOMIC_DIRECTIVE:
2843 S = OMPAtomicDirective::CreateEmpty(
2844 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2845 break;
2846
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002847 case STMT_OMP_TARGET_DIRECTIVE:
2848 S = OMPTargetDirective::CreateEmpty(
2849 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2850 break;
2851
Michael Wong65f367f2015-07-21 13:44:28 +00002852 case STMT_OMP_TARGET_DATA_DIRECTIVE:
2853 S = OMPTargetDataDirective::CreateEmpty(
2854 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2855 break;
2856
Samuel Antaodf67fc42016-01-19 19:15:56 +00002857 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
2858 S = OMPTargetEnterDataDirective::CreateEmpty(
2859 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2860 break;
2861
Samuel Antao72590762016-01-19 20:04:50 +00002862 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
2863 S = OMPTargetExitDataDirective::CreateEmpty(
2864 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2865 break;
2866
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002867 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
2868 S = OMPTargetParallelDirective::CreateEmpty(
2869 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2870 break;
2871
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002872 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
2873 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2874 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2875 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
2876 CollapsedNum, Empty);
2877 break;
2878 }
2879
Samuel Antao686c70c2016-05-26 17:30:50 +00002880 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
2881 S = OMPTargetUpdateDirective::CreateEmpty(
2882 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2883 break;
2884
Alexey Bataev13314bf2014-10-09 04:18:56 +00002885 case STMT_OMP_TEAMS_DIRECTIVE:
2886 S = OMPTeamsDirective::CreateEmpty(
2887 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2888 break;
2889
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002890 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
2891 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
2892 break;
2893
Alexey Bataev80909872015-07-02 11:25:17 +00002894 case STMT_OMP_CANCEL_DIRECTIVE:
Alexey Bataev87933c72015-09-18 08:07:34 +00002895 S = OMPCancelDirective::CreateEmpty(
2896 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev80909872015-07-02 11:25:17 +00002897 break;
2898
Alexey Bataev49f6e782015-12-01 04:18:41 +00002899 case STMT_OMP_TASKLOOP_DIRECTIVE: {
2900 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2901 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2902 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2903 Empty);
2904 break;
2905 }
2906
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002907 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
2908 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2909 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2910 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
2911 CollapsedNum, Empty);
2912 break;
2913 }
2914
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002915 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
2916 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2917 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2918 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2919 Empty);
2920 break;
2921 }
2922
Carlo Bertolli9925f152016-06-27 14:55:37 +00002923 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
2924 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2925 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2926 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
2927 CollapsedNum, Empty);
2928 break;
2929 }
2930
Kelvin Li4a39add2016-07-05 05:00:15 +00002931 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
2932 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2933 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2934 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2935 CollapsedNum,
2936 Empty);
2937 break;
2938 }
2939
Kelvin Li787f3fc2016-07-06 04:45:38 +00002940 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
2941 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2942 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2943 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
2944 CollapsedNum, Empty);
2945 break;
2946 }
2947
Kelvin Lia579b912016-07-14 02:54:56 +00002948 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
2949 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2950 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2951 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2952 CollapsedNum, Empty);
2953 break;
2954 }
2955
Kelvin Li986330c2016-07-20 22:57:10 +00002956 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
2957 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2958 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2959 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2960 Empty);
2961 break;
2962 }
2963
Kelvin Li83c451e2016-12-25 04:52:54 +00002964 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
Kelvin Li02532872016-08-05 14:37:37 +00002965 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2966 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2967 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
2968 CollapsedNum, Empty);
2969 break;
2970 }
2971
Kelvin Li4e325f72016-10-25 12:50:55 +00002972 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
2973 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2974 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2975 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
2976 CollapsedNum, Empty);
2977 break;
2978 }
2979
Kelvin Li579e41c2016-11-30 23:51:03 +00002980 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
2981 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2982 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2983 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
2984 Context, NumClauses, CollapsedNum, Empty);
2985 break;
2986 }
2987
Kelvin Li7ade93f2016-12-09 03:24:30 +00002988 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
2989 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2990 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2991 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
2992 Context, NumClauses, CollapsedNum, Empty);
2993 break;
2994 }
2995
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002996 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
Kelvin Libf594a52016-12-17 05:48:59 +00002997 S = OMPTargetTeamsDirective::CreateEmpty(
2998 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2999 break;
Kelvin Li83c451e2016-12-25 04:52:54 +00003000
3001 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3002 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3003 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3004 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3005 CollapsedNum, Empty);
3006 break;
3007 }
3008
Kelvin Li80e8f562016-12-29 22:16:30 +00003009 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3010 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3011 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3012 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3013 Context, NumClauses, CollapsedNum, Empty);
3014 break;
3015 }
3016
Kelvin Li1851df52017-01-03 05:23:48 +00003017 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3018 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3019 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3020 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3021 Context, NumClauses, CollapsedNum, Empty);
3022 break;
3023 }
3024
Kelvin Lida681182017-01-10 18:08:18 +00003025 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3026 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3027 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3028 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3029 Context, NumClauses, CollapsedNum, Empty);
3030 break;
3031 }
3032
Sebastian Redl539c5062010-08-18 23:57:32 +00003033 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003034 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00003035 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003036
Sebastian Redl539c5062010-08-18 23:57:32 +00003037 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003038 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003039 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003040
Sebastian Redl539c5062010-08-18 23:57:32 +00003041 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003042 S = new (Context) CXXConstructExpr(Empty);
3043 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003044
Richard Smith5179eb72016-06-28 19:03:57 +00003045 case EXPR_CXX_INHERITED_CTOR_INIT:
3046 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3047 break;
3048
Sebastian Redl539c5062010-08-18 23:57:32 +00003049 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003050 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00003051 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003052
Sebastian Redl539c5062010-08-18 23:57:32 +00003053 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003054 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003055 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003056 break;
3057
Sebastian Redl539c5062010-08-18 23:57:32 +00003058 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003059 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003060 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003061 break;
3062
Sebastian Redl539c5062010-08-18 23:57:32 +00003063 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003064 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003065 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003066 break;
3067
Sebastian Redl539c5062010-08-18 23:57:32 +00003068 case EXPR_CXX_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003069 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00003070 break;
3071
Sebastian Redl539c5062010-08-18 23:57:32 +00003072 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003073 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003074 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003075 break;
3076
Richard Smithc67fdd42012-03-07 08:35:16 +00003077 case EXPR_USER_DEFINED_LITERAL:
3078 S = new (Context) UserDefinedLiteral(Context, Empty);
3079 break;
3080
Richard Smithcc1b96d2013-06-12 22:31:48 +00003081 case EXPR_CXX_STD_INITIALIZER_LIST:
3082 S = new (Context) CXXStdInitializerListExpr(Empty);
3083 break;
3084
Sebastian Redl539c5062010-08-18 23:57:32 +00003085 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003086 S = new (Context) CXXBoolLiteralExpr(Empty);
3087 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003088
Sebastian Redl539c5062010-08-18 23:57:32 +00003089 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003090 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3091 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003092
Sebastian Redl539c5062010-08-18 23:57:32 +00003093 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003094 S = new (Context) CXXTypeidExpr(Empty, true);
3095 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003096
Sebastian Redl539c5062010-08-18 23:57:32 +00003097 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003098 S = new (Context) CXXTypeidExpr(Empty, false);
3099 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003100
Francois Pichet9f4f2072010-09-08 12:20:18 +00003101 case EXPR_CXX_UUIDOF_EXPR:
3102 S = new (Context) CXXUuidofExpr(Empty, true);
3103 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003104
John McCall5e77d762013-04-16 07:28:30 +00003105 case EXPR_CXX_PROPERTY_REF_EXPR:
3106 S = new (Context) MSPropertyRefExpr(Empty);
3107 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003108
Alexey Bataevf7630272015-11-25 12:01:00 +00003109 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3110 S = new (Context) MSPropertySubscriptExpr(Empty);
3111 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003112
Francois Pichet9f4f2072010-09-08 12:20:18 +00003113 case EXPR_CXX_UUIDOF_TYPE:
3114 S = new (Context) CXXUuidofExpr(Empty, false);
3115 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003116
Sebastian Redl539c5062010-08-18 23:57:32 +00003117 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00003118 S = new (Context) CXXThisExpr(Empty);
3119 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003120
Sebastian Redl539c5062010-08-18 23:57:32 +00003121 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00003122 S = new (Context) CXXThrowExpr(Empty);
3123 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003124
John McCall32791cc2016-01-06 22:34:54 +00003125 case EXPR_CXX_DEFAULT_ARG:
3126 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00003127 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003128
Richard Smith852c9db2013-04-20 22:23:05 +00003129 case EXPR_CXX_DEFAULT_INIT:
3130 S = new (Context) CXXDefaultInitExpr(Empty);
3131 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003132
Sebastian Redl539c5062010-08-18 23:57:32 +00003133 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00003134 S = new (Context) CXXBindTemporaryExpr(Empty);
3135 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003136
Sebastian Redl539c5062010-08-18 23:57:32 +00003137 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00003138 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003139 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003140
Sebastian Redl539c5062010-08-18 23:57:32 +00003141 case EXPR_CXX_NEW:
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003142 S = new (Context) CXXNewExpr(Empty);
3143 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003144
Sebastian Redl539c5062010-08-18 23:57:32 +00003145 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00003146 S = new (Context) CXXDeleteExpr(Empty);
3147 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003148
Sebastian Redl539c5062010-08-18 23:57:32 +00003149 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00003150 S = new (Context) CXXPseudoDestructorExpr(Empty);
3151 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003152
John McCall5d413782010-12-06 08:20:24 +00003153 case EXPR_EXPR_WITH_CLEANUPS:
John McCall28fc7092011-11-10 05:35:25 +00003154 S = ExprWithCleanups::Create(Context, Empty,
3155 Record[ASTStmtReader::NumExprFields]);
Chris Lattnercba86142010-05-10 00:25:06 +00003156 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003157
Sebastian Redl539c5062010-08-18 23:57:32 +00003158 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003159 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003160 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003161 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003162 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003163 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003164 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003165
Sebastian Redl539c5062010-08-18 23:57:32 +00003166 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003167 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003168 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003169 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003170 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003171 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00003172 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003173
Sebastian Redl539c5062010-08-18 23:57:32 +00003174 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003175 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003176 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00003177 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003178
Sebastian Redl539c5062010-08-18 23:57:32 +00003179 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003180 S = UnresolvedMemberExpr::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_UNRESOLVED_LOOKUP:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003188 S = UnresolvedLookupExpr::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 Kyrtzidis58e01ad2010-06-25 09:03:34 +00003193 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003194
Douglas Gregor29c42f22012-02-24 07:38:34 +00003195 case EXPR_TYPE_TRAIT:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003196 S = TypeTraitExpr::CreateDeserialized(Context,
Douglas Gregor29c42f22012-02-24 07:38:34 +00003197 Record[ASTStmtReader::NumExprFields]);
3198 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003199
John Wiegley6242b6a2011-04-28 00:16:57 +00003200 case EXPR_ARRAY_TYPE_TRAIT:
3201 S = new (Context) ArrayTypeTraitExpr(Empty);
3202 break;
3203
John Wiegleyf9f65842011-04-25 06:54:41 +00003204 case EXPR_CXX_EXPRESSION_TRAIT:
3205 S = new (Context) ExpressionTraitExpr(Empty);
3206 break;
3207
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003208 case EXPR_CXX_NOEXCEPT:
3209 S = new (Context) CXXNoexceptExpr(Empty);
3210 break;
John McCall8d69a212010-11-15 23:31:06 +00003211
Douglas Gregore8e9dd62011-01-03 17:17:50 +00003212 case EXPR_PACK_EXPANSION:
3213 S = new (Context) PackExpansionExpr(Empty);
3214 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003215
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003216 case EXPR_SIZEOF_PACK:
Richard Smithd784e682015-09-23 21:41:42 +00003217 S = SizeOfPackExpr::CreateDeserialized(
3218 Context,
3219 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003220 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003221
John McCallfa194042011-07-15 07:00:14 +00003222 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3223 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3224 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003225
Douglas Gregorcdbc5392011-01-15 01:15:58 +00003226 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3227 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3228 break;
Richard Smithb15fe3a2012-09-12 00:56:43 +00003229
3230 case EXPR_FUNCTION_PARM_PACK:
3231 S = FunctionParmPackExpr::CreateEmpty(Context,
3232 Record[ASTStmtReader::NumExprFields]);
3233 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003234
Douglas Gregorfe314812011-06-21 17:03:29 +00003235 case EXPR_MATERIALIZE_TEMPORARY:
3236 S = new (Context) MaterializeTemporaryExpr(Empty);
3237 break;
Richard Smith0f0af192014-11-08 05:07:16 +00003238
3239 case EXPR_CXX_FOLD:
3240 S = new (Context) CXXFoldExpr(Empty);
3241 break;
3242
Argyrios Kyrtzidisb2b07952011-12-03 03:49:52 +00003243 case EXPR_OPAQUE_VALUE:
3244 S = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00003245 break;
Peter Collingbourne41f85462011-02-09 21:07:24 +00003246
3247 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003248 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00003249 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003250
Tanya Lattner55808c12011-06-04 00:47:47 +00003251 case EXPR_ASTYPE:
3252 S = new (Context) AsTypeExpr(Empty);
3253 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003254
John McCallfe96e0b2011-11-06 09:01:30 +00003255 case EXPR_PSEUDO_OBJECT: {
3256 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3257 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3258 break;
3259 }
3260
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003261 case EXPR_ATOMIC:
3262 S = new (Context) AtomicExpr(Empty);
3263 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003264
Douglas Gregor99ae8062012-02-14 17:54:36 +00003265 case EXPR_LAMBDA: {
3266 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
Richard Smith30e304e2016-12-14 00:03:17 +00003267 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
Douglas Gregor99ae8062012-02-14 17:54:36 +00003268 break;
3269 }
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +00003270
3271 case STMT_COROUTINE_BODY: {
3272 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3273 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3274 break;
3275 }
3276
3277 case STMT_CORETURN:
3278 S = new (Context) CoreturnStmt(Empty);
3279 break;
3280
3281 case EXPR_COAWAIT:
3282 S = new (Context) CoawaitExpr(Empty);
3283 break;
3284
3285 case EXPR_COYIELD:
3286 S = new (Context) CoyieldExpr(Empty);
3287 break;
3288
3289 case EXPR_DEPENDENT_COAWAIT:
3290 S = new (Context) DependentCoawaitExpr(Empty);
3291 break;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003292 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003293
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003294 // We hit a STMT_STOP, so we're done with this expression.
3295 if (Finished)
3296 break;
3297
3298 ++NumStatementsRead;
3299
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003300 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003301 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003302 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3303 }
3304
David L. Jonesbe1557a2016-12-21 00:17:49 +00003305 assert(Record.getIdx() == Record.size() &&
3306 "Invalid deserialization of statement");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003307 StmtStack.push_back(S);
3308 }
Chris Lattner0e6c9402013-01-20 02:38:54 +00003309Done:
Alp Toker028ed912013-12-06 17:56:43 +00003310 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003311 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003312 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003313}