blob: 1ad33c5dc34d4d737d499179eae702bc25249911 [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);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000243 S->setInit(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000244 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000245 S->setCond(Record.readSubExpr());
246 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000247 S->setSwitchLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000248 if (Record.readInt())
Ted Kremenekc42f3452010-09-09 00:05:53 +0000249 S->setAllEnumCasesCovered();
250
Craig Toppera13603a2014-05-22 05:54:18 +0000251 SwitchCase *PrevSC = nullptr;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000252 for (auto E = Record.size(); Record.getIdx() != E; ) {
253 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000254 if (PrevSC)
255 PrevSC->setNextSwitchCase(SC);
256 else
257 S->setSwitchCaseList(SC);
Mike Stump11289f42009-09-09 15:08:12 +0000258
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000259 PrevSC = SC;
260 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000261}
262
Sebastian Redl70c751d2010-08-18 23:56:52 +0000263void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000264 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000265 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
Douglas Gregor7fb09192011-07-21 22:35:25 +0000266
David L. Jonesb6a8f022016-12-21 04:34:52 +0000267 S->setCond(Record.readSubExpr());
268 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000269 S->setWhileLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000270}
271
Sebastian Redl70c751d2010-08-18 23:56:52 +0000272void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000273 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000274 S->setCond(Record.readSubExpr());
275 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000276 S->setDoLoc(ReadSourceLocation());
277 S->setWhileLoc(ReadSourceLocation());
278 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000279}
280
Sebastian Redl70c751d2010-08-18 23:56:52 +0000281void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000282 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000283 S->setInit(Record.readSubStmt());
284 S->setCond(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000285 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000286 S->setInc(Record.readSubExpr());
287 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000288 S->setForLoc(ReadSourceLocation());
289 S->setLParenLoc(ReadSourceLocation());
290 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000291}
292
Sebastian Redl70c751d2010-08-18 23:56:52 +0000293void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000294 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000295 S->setLabel(ReadDeclAs<LabelDecl>());
296 S->setGotoLoc(ReadSourceLocation());
297 S->setLabelLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000298}
299
Sebastian Redl70c751d2010-08-18 23:56:52 +0000300void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000301 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000302 S->setGotoLoc(ReadSourceLocation());
303 S->setStarLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000304 S->setTarget(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000305}
306
Sebastian Redl70c751d2010-08-18 23:56:52 +0000307void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000308 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000309 S->setContinueLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000310}
311
Sebastian Redl70c751d2010-08-18 23:56:52 +0000312void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000313 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000314 S->setBreakLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000315}
316
Sebastian Redl70c751d2010-08-18 23:56:52 +0000317void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000318 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000319 S->setRetValue(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000320 S->setReturnLoc(ReadSourceLocation());
321 S->setNRVOCandidate(ReadDeclAs<VarDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000322}
323
Sebastian Redl70c751d2010-08-18 23:56:52 +0000324void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000325 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000326 S->setStartLoc(ReadSourceLocation());
327 S->setEndLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000328
David L. Jonesbe1557a2016-12-21 00:17:49 +0000329 if (Record.size() - Record.getIdx() == 1) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000330 // Single declaration
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000331 S->setDeclGroup(DeclGroupRef(ReadDecl()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000332 } else {
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000333 SmallVector<Decl *, 16> Decls;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000334 int N = Record.size() - Record.getIdx();
335 Decls.reserve(N);
336 for (int I = 0; I < N; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000337 Decls.push_back(ReadDecl());
338 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
Douglas Gregor038c3382009-05-22 22:45:36 +0000339 Decls.data(),
340 Decls.size())));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000341 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000342}
343
John McCallf413f5e2013-05-03 00:10:13 +0000344void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000345 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000346 S->NumOutputs = Record.readInt();
347 S->NumInputs = Record.readInt();
348 S->NumClobbers = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000349 S->setAsmLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000350 S->setVolatile(Record.readInt());
351 S->setSimple(Record.readInt());
John McCallf413f5e2013-05-03 00:10:13 +0000352}
Mike Stump11289f42009-09-09 15:08:12 +0000353
John McCallf413f5e2013-05-03 00:10:13 +0000354void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
355 VisitAsmStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000356 S->setRParenLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000357 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000358
John McCallf413f5e2013-05-03 00:10:13 +0000359 unsigned NumOutputs = S->getNumOutputs();
360 unsigned NumInputs = S->getNumInputs();
361 unsigned NumClobbers = S->getNumClobbers();
362
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000363 // Outputs and inputs
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000364 SmallVector<IdentifierInfo *, 16> Names;
365 SmallVector<StringLiteral*, 16> Constraints;
366 SmallVector<Stmt*, 16> Exprs;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000367 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000368 Names.push_back(Record.getIdentifierInfo());
369 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
370 Exprs.push_back(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000371 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000372
373 // Constraints
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000374 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000375 for (unsigned I = 0; I != NumClobbers; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000376 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000377
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000378 S->setOutputsAndInputsAndClobbers(Record.getContext(),
379 Names.data(), Constraints.data(),
380 Exprs.data(), NumOutputs, NumInputs,
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000381 Clobbers.data(), NumClobbers);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000382}
383
Chad Rosier32503022012-06-11 20:47:18 +0000384void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
John McCallf413f5e2013-05-03 00:10:13 +0000385 VisitAsmStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000386 S->LBraceLoc = ReadSourceLocation();
387 S->EndLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000388 S->NumAsmToks = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000389 std::string AsmStr = ReadString();
John McCallf413f5e2013-05-03 00:10:13 +0000390
391 // Read the tokens.
392 SmallVector<Token, 16> AsmToks;
393 AsmToks.reserve(S->NumAsmToks);
394 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000395 AsmToks.push_back(Record.readToken());
John McCallf413f5e2013-05-03 00:10:13 +0000396 }
397
398 // The calls to reserve() for the FooData vectors are mandatory to
399 // prevent dead StringRefs in the Foo vectors.
400
401 // Read the clobbers.
402 SmallVector<std::string, 16> ClobbersData;
403 SmallVector<StringRef, 16> Clobbers;
404 ClobbersData.reserve(S->NumClobbers);
405 Clobbers.reserve(S->NumClobbers);
406 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000407 ClobbersData.push_back(ReadString());
John McCallf413f5e2013-05-03 00:10:13 +0000408 Clobbers.push_back(ClobbersData.back());
409 }
410
411 // Read the operands.
412 unsigned NumOperands = S->NumOutputs + S->NumInputs;
413 SmallVector<Expr*, 16> Exprs;
414 SmallVector<std::string, 16> ConstraintsData;
415 SmallVector<StringRef, 16> Constraints;
416 Exprs.reserve(NumOperands);
417 ConstraintsData.reserve(NumOperands);
418 Constraints.reserve(NumOperands);
419 for (unsigned i = 0; i != NumOperands; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000420 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000421 ConstraintsData.push_back(ReadString());
John McCallf413f5e2013-05-03 00:10:13 +0000422 Constraints.push_back(ConstraintsData.back());
423 }
424
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000425 S->initialize(Record.getContext(), AsmStr, AsmToks,
John McCallf413f5e2013-05-03 00:10:13 +0000426 Constraints, Exprs, Clobbers);
Chad Rosier32503022012-06-11 20:47:18 +0000427}
428
Richard Smith9f690bd2015-10-27 06:02:45 +0000429void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000430 VisitStmt(S);
431 assert(Record.peekInt() == S->NumParams);
432 Record.skipInts(1);
433 auto *StoredStmts = S->getStoredStmts();
434 for (unsigned i = 0;
435 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
436 StoredStmts[i] = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000437}
438
439void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000440 VisitStmt(S);
441 S->CoreturnLoc = Record.readSourceLocation();
442 for (auto &SubStmt: S->SubStmts)
443 SubStmt = Record.readSubStmt();
444 S->IsImplicit = Record.readInt() != 0;
Richard Smith9f690bd2015-10-27 06:02:45 +0000445}
446
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000447void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
448 VisitExpr(E);
449 E->KeywordLoc = ReadSourceLocation();
450 for (auto &SubExpr: E->SubExprs)
451 SubExpr = Record.readSubStmt();
452 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
453 E->setIsImplicit(Record.readInt() != 0);
Richard Smith9f690bd2015-10-27 06:02:45 +0000454}
455
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000456void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
457 VisitExpr(E);
458 E->KeywordLoc = ReadSourceLocation();
459 for (auto &SubExpr: E->SubExprs)
460 SubExpr = Record.readSubStmt();
461 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
Eric Fiselier20f25cb2017-03-06 23:38:15 +0000462}
463
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000464void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
465 VisitExpr(E);
466 E->KeywordLoc = ReadSourceLocation();
467 for (auto &SubExpr: E->SubExprs)
468 SubExpr = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000469}
470
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000471void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
Ben Langmuirce914fc2013-05-03 19:20:19 +0000472 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000473 Record.skipInts(1);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000474 S->setCapturedDecl(ReadDeclAs<CapturedDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000475 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000476 S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000477
478 // Capture inits
479 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
480 E = S->capture_init_end();
481 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000482 *I = Record.readSubExpr();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000483
484 // Body
David L. Jonesb6a8f022016-12-21 04:34:52 +0000485 S->setCapturedStmt(Record.readSubStmt());
Wei Pan17fbf6e2013-05-04 03:59:06 +0000486 S->getCapturedDecl()->setBody(S->getCapturedStmt());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000487
488 // Captures
Aaron Ballmanc656303a2014-03-14 18:08:33 +0000489 for (auto &I : S->captures()) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000490 I.VarAndKind.setPointer(ReadDeclAs<VarDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000491 I.VarAndKind.setInt(
492 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000493 I.Loc = ReadSourceLocation();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000494 }
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000495}
496
Sebastian Redl70c751d2010-08-18 23:56:52 +0000497void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000498 VisitStmt(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000499 E->setType(Record.readType());
500 E->setTypeDependent(Record.readInt());
501 E->setValueDependent(Record.readInt());
502 E->setInstantiationDependent(Record.readInt());
503 E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
504 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
505 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
506 assert(Record.getIdx() == NumExprFields &&
507 "Incorrect expression field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000508}
509
Sebastian Redl70c751d2010-08-18 23:56:52 +0000510void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000511 VisitExpr(E);
Bruno Ricci17ff0262018-10-27 19:21:19 +0000512 bool HasFunctionName = Record.readInt();
513 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
514 E->PredefinedExprBits.Kind = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000515 E->setLocation(ReadSourceLocation());
Bruno Ricci17ff0262018-10-27 19:21:19 +0000516 if (HasFunctionName)
517 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000518}
519
Sebastian Redl70c751d2010-08-18 23:56:52 +0000520void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000521 VisitExpr(E);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000522
David L. Jonesbe1557a2016-12-21 00:17:49 +0000523 E->DeclRefExprBits.HasQualifier = Record.readInt();
524 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
525 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
526 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
527 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000528 unsigned NumTemplateArgs = 0;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000529 if (E->hasTemplateKWAndArgsInfo())
David L. Jonesbe1557a2016-12-21 00:17:49 +0000530 NumTemplateArgs = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000531
Chandler Carruth0e439962011-05-01 21:29:53 +0000532 if (E->hasQualifier())
James Y Knighte7d82282015-12-29 18:15:14 +0000533 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
David L. Jonesb6a8f022016-12-21 04:34:52 +0000534 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000535
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000536 if (E->hasFoundDecl())
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000537 *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000538
Abramo Bagnara7945c982012-01-27 09:46:47 +0000539 if (E->hasTemplateKWAndArgsInfo())
James Y Knighte7d82282015-12-29 18:15:14 +0000540 ReadTemplateKWAndArgsInfo(
541 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
542 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000543
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000544 E->setDecl(ReadDeclAs<ValueDecl>());
545 E->setLocation(ReadSourceLocation());
546 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000547}
548
Sebastian Redl70c751d2010-08-18 23:56:52 +0000549void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000550 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000551 E->setLocation(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000552 E->setValue(Record.getContext(), Record.readAPInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000553}
554
Leonard Chandb01c3a2018-06-20 17:19:40 +0000555void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
556 VisitExpr(E);
557 E->setLocation(ReadSourceLocation());
558 E->setValue(Record.getContext(), Record.readAPInt());
559}
560
Sebastian Redl70c751d2010-08-18 23:56:52 +0000561void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000562 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000563 E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record.readInt()));
564 E->setExact(Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000565 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000566 E->setLocation(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000567}
568
Sebastian Redl70c751d2010-08-18 23:56:52 +0000569void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000570 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000571 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000572}
573
Sebastian Redl70c751d2010-08-18 23:56:52 +0000574void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000575 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000576 unsigned Len = Record.readInt();
577 assert(Record.peekInt() == E->getNumConcatenated() &&
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000578 "Wrong number of concatenated tokens!");
David L. Jonesbe1557a2016-12-21 00:17:49 +0000579 Record.skipInts(1);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000580 auto kind = static_cast<StringLiteral::StringKind>(Record.readInt());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000581 bool isPascal = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000582
Mike Stump11289f42009-09-09 15:08:12 +0000583 // Read string data
David L. Jonesbe1557a2016-12-21 00:17:49 +0000584 auto B = &Record.peekInt();
585 SmallString<16> Str(B, B + Len);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000586 E->setString(Record.getContext(), Str, kind, isPascal);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000587 Record.skipInts(Len);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000588
589 // Read source locations
590 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000591 E->setStrTokenLoc(I, ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000592}
593
Sebastian Redl70c751d2010-08-18 23:56:52 +0000594void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000595 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000596 E->setValue(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000597 E->setLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000598 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000599}
600
Sebastian Redl70c751d2010-08-18 23:56:52 +0000601void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000602 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000603 E->setLParen(ReadSourceLocation());
604 E->setRParen(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000605 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000606}
607
Sebastian Redl70c751d2010-08-18 23:56:52 +0000608void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000609 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000610 unsigned NumExprs = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000611 E->Exprs = new (Record.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000612 for (unsigned i = 0; i != NumExprs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000613 E->Exprs[i] = Record.readSubStmt();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000614 E->NumExprs = NumExprs;
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000615 E->LParenLoc = ReadSourceLocation();
616 E->RParenLoc = ReadSourceLocation();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000617}
618
Sebastian Redl70c751d2010-08-18 23:56:52 +0000619void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000620 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000621 E->setSubExpr(Record.readSubExpr());
622 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
623 E->setOperatorLoc(ReadSourceLocation());
624 E->setCanOverflow(Record.readInt());
625}
626
627void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000628 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000629 assert(E->getNumComponents() == Record.peekInt());
630 Record.skipInts(1);
631 assert(E->getNumExpressions() == Record.peekInt());
632 Record.skipInts(1);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000633 E->setOperatorLoc(ReadSourceLocation());
634 E->setRParenLoc(ReadSourceLocation());
635 E->setTypeSourceInfo(GetTypeSourceInfo());
Douglas Gregor882211c2010-04-28 22:16:22 +0000636 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000637 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000638 SourceLocation Start = ReadSourceLocation();
639 SourceLocation End = ReadSourceLocation();
Douglas Gregor882211c2010-04-28 22:16:22 +0000640 switch (Kind) {
James Y Knight7281c352015-12-29 22:31:18 +0000641 case OffsetOfNode::Array:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000642 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000643 break;
644
James Y Knight7281c352015-12-29 22:31:18 +0000645 case OffsetOfNode::Field:
646 E->setComponent(
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000647 I, OffsetOfNode(Start, ReadDeclAs<FieldDecl>(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000648 break;
James Y Knight7281c352015-12-29 22:31:18 +0000649
650 case OffsetOfNode::Identifier:
651 E->setComponent(
652 I,
David L. Jonesb6a8f022016-12-21 04:34:52 +0000653 OffsetOfNode(Start, Record.getIdentifierInfo(), End));
James Y Knight7281c352015-12-29 22:31:18 +0000654 break;
655
656 case OffsetOfNode::Base: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000657 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000658 *Base = Record.readCXXBaseSpecifier();
James Y Knight7281c352015-12-29 22:31:18 +0000659 E->setComponent(I, OffsetOfNode(Base));
Douglas Gregord1702062010-04-29 00:18:15 +0000660 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000661 }
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000662 }
Douglas Gregor882211c2010-04-28 22:16:22 +0000663 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000664
Douglas Gregor882211c2010-04-28 22:16:22 +0000665 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000666 E->setIndexExpr(I, Record.readSubExpr());
Douglas Gregor882211c2010-04-28 22:16:22 +0000667}
668
Peter Collingbournee190dee2011-03-11 19:24:49 +0000669void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000670 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000671 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
672 if (Record.peekInt() == 0) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000673 E->setArgument(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000674 Record.skipInts(1);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000675 } else {
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000676 E->setArgument(GetTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000677 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000678 E->setOperatorLoc(ReadSourceLocation());
679 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000680}
681
Sebastian Redl70c751d2010-08-18 23:56:52 +0000682void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000683 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000684 E->setLHS(Record.readSubExpr());
685 E->setRHS(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000686 E->setRBracketLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000687}
688
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000689void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
690 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000691 E->setBase(Record.readSubExpr());
692 E->setLowerBound(Record.readSubExpr());
693 E->setLength(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000694 E->setColonLoc(ReadSourceLocation());
695 E->setRBracketLoc(ReadSourceLocation());
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000696}
697
Sebastian Redl70c751d2010-08-18 23:56:52 +0000698void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000699 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000700 E->setNumArgs(Record.getContext(), Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000701 E->setRParenLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000702 E->setCallee(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000703 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000704 E->setArg(I, Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000705}
706
John McCallfa194042011-07-15 07:00:14 +0000707void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
708 VisitCallExpr(E);
709}
710
Sebastian Redl70c751d2010-08-18 23:56:52 +0000711void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000712 // Don't call VisitExpr, this is fully initialized at creation.
713 assert(E->getStmtClass() == Stmt::MemberExprClass &&
714 "It's a subclass, we must advance Idx!");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000715}
716
Sebastian Redl70c751d2010-08-18 23:56:52 +0000717void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Naroffe87026a2009-07-24 17:54:45 +0000718 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000719 E->setBase(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000720 E->setIsaMemberLoc(ReadSourceLocation());
721 E->setOpLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000722 E->setArrow(Record.readInt());
Steve Naroffe87026a2009-07-24 17:54:45 +0000723}
724
John McCall31168b02011-06-15 23:02:42 +0000725void ASTStmtReader::
726VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
727 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000728 E->Operand = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000729 E->setShouldCopy(Record.readInt());
John McCall31168b02011-06-15 23:02:42 +0000730}
731
732void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
733 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000734 E->LParenLoc = ReadSourceLocation();
735 E->BridgeKeywordLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000736 E->Kind = Record.readInt();
John McCall31168b02011-06-15 23:02:42 +0000737}
738
Sebastian Redl70c751d2010-08-18 23:56:52 +0000739void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000740 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000741 unsigned NumBaseSpecs = Record.readInt();
John McCallcf142162010-08-07 06:22:56 +0000742 assert(NumBaseSpecs == E->path_size());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000743 E->setSubExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000744 E->setCastKind((CastKind)Record.readInt());
John McCallcf142162010-08-07 06:22:56 +0000745 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000746 while (NumBaseSpecs--) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000747 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000748 *BaseSpec = Record.readCXXBaseSpecifier();
John McCallcf142162010-08-07 06:22:56 +0000749 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000750 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000751}
752
Sebastian Redl70c751d2010-08-18 23:56:52 +0000753void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000754 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000755 E->setLHS(Record.readSubExpr());
756 E->setRHS(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000757 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000758 E->setOperatorLoc(ReadSourceLocation());
Adam Nemet484aa452017-03-27 19:17:25 +0000759 E->setFPFeatures(FPOptions(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000760}
761
Sebastian Redl70c751d2010-08-18 23:56:52 +0000762void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000763 VisitBinaryOperator(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000764 E->setComputationLHSType(Record.readType());
765 E->setComputationResultType(Record.readType());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000766}
767
Sebastian Redl70c751d2010-08-18 23:56:52 +0000768void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000769 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000770 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
771 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
772 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000773 E->QuestionLoc = ReadSourceLocation();
774 E->ColonLoc = ReadSourceLocation();
John McCallc07a0c72011-02-17 10:25:35 +0000775}
776
777void
778ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
779 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000780 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
781 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
782 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
783 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
784 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000785 E->QuestionLoc = ReadSourceLocation();
786 E->ColonLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000787}
788
Sebastian Redl70c751d2010-08-18 23:56:52 +0000789void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000790 VisitCastExpr(E);
Roman Lebedev12216f12018-07-27 07:27:14 +0000791 E->setIsPartOfExplicitCast(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000792}
793
Sebastian Redl70c751d2010-08-18 23:56:52 +0000794void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000795 VisitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000796 E->setTypeInfoAsWritten(GetTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000797}
798
Sebastian Redl70c751d2010-08-18 23:56:52 +0000799void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000800 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000801 E->setLParenLoc(ReadSourceLocation());
802 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000803}
804
Sebastian Redl70c751d2010-08-18 23:56:52 +0000805void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000806 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000807 E->setLParenLoc(ReadSourceLocation());
808 E->setTypeSourceInfo(GetTypeSourceInfo());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000809 E->setInitializer(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000810 E->setFileScope(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000811}
812
Sebastian Redl70c751d2010-08-18 23:56:52 +0000813void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000814 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000815 E->setBase(Record.readSubExpr());
816 E->setAccessor(Record.getIdentifierInfo());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000817 E->setAccessorLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000818}
819
Sebastian Redl70c751d2010-08-18 23:56:52 +0000820void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000821 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000822 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
Abramo Bagnara8d16bd42012-11-08 18:41:43 +0000823 E->setSyntacticForm(SyntForm);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000824 E->setLBraceLoc(ReadSourceLocation());
825 E->setRBraceLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000826 bool isArrayFiller = Record.readInt();
Craig Toppera13603a2014-05-22 05:54:18 +0000827 Expr *filler = nullptr;
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000828 if (isArrayFiller) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000829 filler = Record.readSubExpr();
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000830 E->ArrayFillerOrUnionFieldInit = filler;
831 } else
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000832 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000833 E->sawArrayRangeDesignator(Record.readInt());
834 unsigned NumInits = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000835 E->reserveInits(Record.getContext(), NumInits);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000836 if (isArrayFiller) {
837 for (unsigned I = 0; I != NumInits; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000838 Expr *init = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000839 E->updateInit(Record.getContext(), I, init ? init : filler);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000840 }
841 } else {
842 for (unsigned I = 0; I != NumInits; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000843 E->updateInit(Record.getContext(), I, Record.readSubExpr());
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000844 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000845}
846
Sebastian Redl70c751d2010-08-18 23:56:52 +0000847void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000848 using Designator = DesignatedInitExpr::Designator;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000849
850 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000851 unsigned NumSubExprs = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000852 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
853 for (unsigned I = 0; I != NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000854 E->setSubExpr(I, Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000855 E->setEqualOrColonLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000856 E->setGNUSyntax(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000857
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000858 SmallVector<Designator, 4> Designators;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000859 while (Record.getIdx() < Record.size()) {
860 switch ((DesignatorTypes)Record.readInt()) {
Sebastian Redl539c5062010-08-18 23:57:32 +0000861 case DESIG_FIELD_DECL: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000862 auto *Field = ReadDeclAs<FieldDecl>();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000863 SourceLocation DotLoc = ReadSourceLocation();
864 SourceLocation FieldLoc = ReadSourceLocation();
Mike Stump11289f42009-09-09 15:08:12 +0000865 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000866 FieldLoc));
867 Designators.back().setField(Field);
868 break;
869 }
870
Sebastian Redl539c5062010-08-18 23:57:32 +0000871 case DESIG_FIELD_NAME: {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000872 const IdentifierInfo *Name = Record.getIdentifierInfo();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000873 SourceLocation DotLoc = ReadSourceLocation();
874 SourceLocation FieldLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000875 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
876 break;
877 }
Mike Stump11289f42009-09-09 15:08:12 +0000878
Sebastian Redl539c5062010-08-18 23:57:32 +0000879 case DESIG_ARRAY: {
David L. Jonesbe1557a2016-12-21 00:17:49 +0000880 unsigned Index = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000881 SourceLocation LBracketLoc = ReadSourceLocation();
882 SourceLocation RBracketLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000883 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
884 break;
885 }
886
Sebastian Redl539c5062010-08-18 23:57:32 +0000887 case DESIG_ARRAY_RANGE: {
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 EllipsisLoc = ReadSourceLocation();
891 SourceLocation RBracketLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000892 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
893 RBracketLoc));
894 break;
895 }
896 }
897 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000898 E->setDesignators(Record.getContext(),
Douglas Gregor03e8bdc2010-01-06 23:17:19 +0000899 Designators.data(), Designators.size());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000900}
901
Yunzhong Gaocb779302015-06-10 00:27:52 +0000902void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
903 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000904 E->setBase(Record.readSubExpr());
905 E->setUpdater(Record.readSubExpr());
Yunzhong Gaocb779302015-06-10 00:27:52 +0000906}
907
908void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
909 VisitExpr(E);
910}
911
Richard Smith410306b2016-12-12 02:53:20 +0000912void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
913 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000914 E->SubExprs[0] = Record.readSubExpr();
915 E->SubExprs[1] = Record.readSubExpr();
Richard Smith410306b2016-12-12 02:53:20 +0000916}
917
918void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
919 VisitExpr(E);
920}
921
Sebastian Redl70c751d2010-08-18 23:56:52 +0000922void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000923 VisitExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000924}
925
Sebastian Redl70c751d2010-08-18 23:56:52 +0000926void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000927 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000928 E->setSubExpr(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000929 E->setWrittenTypeInfo(GetTypeSourceInfo());
930 E->setBuiltinLoc(ReadSourceLocation());
931 E->setRParenLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000932 E->setIsMicrosoftABI(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000933}
934
Sebastian Redl70c751d2010-08-18 23:56:52 +0000935void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000936 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000937 E->setAmpAmpLoc(ReadSourceLocation());
938 E->setLabelLoc(ReadSourceLocation());
939 E->setLabel(ReadDeclAs<LabelDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000940}
941
Sebastian Redl70c751d2010-08-18 23:56:52 +0000942void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000943 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000944 E->setLParenLoc(ReadSourceLocation());
945 E->setRParenLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000946 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000947}
948
Sebastian Redl70c751d2010-08-18 23:56:52 +0000949void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000950 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000951 E->setCond(Record.readSubExpr());
952 E->setLHS(Record.readSubExpr());
953 E->setRHS(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000954 E->setBuiltinLoc(ReadSourceLocation());
955 E->setRParenLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000956 E->setIsConditionTrue(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000957}
958
Sebastian Redl70c751d2010-08-18 23:56:52 +0000959void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000960 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000961 E->setTokenLocation(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000962}
963
Sebastian Redl70c751d2010-08-18 23:56:52 +0000964void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000965 VisitExpr(E);
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000966 SmallVector<Expr *, 16> Exprs;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000967 unsigned NumExprs = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000968 while (NumExprs--)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000969 Exprs.push_back(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000970 E->setExprs(Record.getContext(), Exprs);
971 E->setBuiltinLoc(ReadSourceLocation());
972 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000973}
974
Hal Finkelc4d7c822013-09-18 03:29:45 +0000975void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
976 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000977 E->BuiltinLoc = ReadSourceLocation();
978 E->RParenLoc = ReadSourceLocation();
979 E->TInfo = GetTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000980 E->SrcExpr = Record.readSubExpr();
Hal Finkelc4d7c822013-09-18 03:29:45 +0000981}
982
Sebastian Redl70c751d2010-08-18 23:56:52 +0000983void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000984 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000985 E->setBlockDecl(ReadDeclAs<BlockDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000986}
987
Peter Collingbourne91147592011-04-15 00:35:48 +0000988void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
989 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000990 E->NumAssocs = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000991 E->AssocTypes = new (Record.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbourne91147592011-04-15 00:35:48 +0000992 E->SubExprs =
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000993 new(Record.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbourne91147592011-04-15 00:35:48 +0000994
David L. Jonesb6a8f022016-12-21 04:34:52 +0000995 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Record.readSubExpr();
Peter Collingbourne91147592011-04-15 00:35:48 +0000996 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000997 E->AssocTypes[I] = GetTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000998 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Record.readSubExpr();
Peter Collingbourne91147592011-04-15 00:35:48 +0000999 }
David L. Jonesbe1557a2016-12-21 00:17:49 +00001000 E->ResultIndex = Record.readInt();
Peter Collingbourne91147592011-04-15 00:35:48 +00001001
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001002 E->GenericLoc = ReadSourceLocation();
1003 E->DefaultLoc = ReadSourceLocation();
1004 E->RParenLoc = ReadSourceLocation();
Peter Collingbourne91147592011-04-15 00:35:48 +00001005}
1006
John McCallfe96e0b2011-11-06 09:01:30 +00001007void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1008 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001009 unsigned numSemanticExprs = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001010 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001011 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001012
1013 // Read the syntactic expression.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001014 E->getSubExprsBuffer()[0] = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001015
1016 // Read all the semantic expressions.
1017 for (unsigned i = 0; i != numSemanticExprs; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001018 Expr *subExpr = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001019 E->getSubExprsBuffer()[i+1] = subExpr;
1020 }
1021}
1022
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001023void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1024 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001025 E->Op = AtomicExpr::AtomicOp(Record.readInt());
Richard Smithaa22a8c2012-04-10 22:49:28 +00001026 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1027 for (unsigned I = 0; I != E->NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001028 E->SubExprs[I] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001029 E->BuiltinLoc = ReadSourceLocation();
1030 E->RParenLoc = ReadSourceLocation();
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001031}
1032
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001033//===----------------------------------------------------------------------===//
1034// Objective-C Expressions and Statements
1035
Sebastian Redl70c751d2010-08-18 23:56:52 +00001036void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001037 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001038 E->setString(cast<StringLiteral>(Record.readSubStmt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001039 E->setAtLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001040}
1041
Patrick Beard0caa3942012-04-19 00:25:12 +00001042void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001043 VisitExpr(E);
1044 // could be one of several IntegerLiteral, FloatLiteral, etc.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001045 E->SubExpr = Record.readSubStmt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001046 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>();
1047 E->Range = ReadSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001048}
1049
1050void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1051 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001052 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001053 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1054 Expr **Elements = E->getElements();
1055 for (unsigned I = 0, N = NumElements; I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001056 Elements[I] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001057 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1058 E->Range = ReadSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001059}
1060
1061void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1062 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001063 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001064 assert(NumElements == E->getNumElements() && "Wrong number of elements");
David L. Jonesbe1557a2016-12-21 00:17:49 +00001065 bool HasPackExpansions = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001066 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001067 auto *KeyValues =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001068 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001069 auto *Expansions =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001070 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001071 for (unsigned I = 0; I != NumElements; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001072 KeyValues[I].Key = Record.readSubExpr();
1073 KeyValues[I].Value = Record.readSubExpr();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001074 if (HasPackExpansions) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001075 Expansions[I].EllipsisLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001076 Expansions[I].NumExpansionsPlusOne = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001077 }
1078 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001079 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1080 E->Range = ReadSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001081}
1082
Sebastian Redl70c751d2010-08-18 23:56:52 +00001083void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001084 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001085 E->setEncodedTypeSourceInfo(GetTypeSourceInfo());
1086 E->setAtLoc(ReadSourceLocation());
1087 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001088}
1089
Sebastian Redl70c751d2010-08-18 23:56:52 +00001090void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001091 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001092 E->setSelector(Record.readSelector());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001093 E->setAtLoc(ReadSourceLocation());
1094 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001095}
1096
Sebastian Redl70c751d2010-08-18 23:56:52 +00001097void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001098 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001099 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>());
1100 E->setAtLoc(ReadSourceLocation());
1101 E->ProtoLoc = ReadSourceLocation();
1102 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001103}
1104
Sebastian Redl70c751d2010-08-18 23:56:52 +00001105void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001106 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001107 E->setDecl(ReadDeclAs<ObjCIvarDecl>());
1108 E->setLocation(ReadSourceLocation());
1109 E->setOpLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001110 E->setBase(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001111 E->setIsArrow(Record.readInt());
1112 E->setIsFreeIvar(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001113}
1114
Sebastian Redl70c751d2010-08-18 23:56:52 +00001115void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001116 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001117 unsigned MethodRefFlags = Record.readInt();
1118 bool Implicit = Record.readInt() != 0;
John McCallb7bd14f2010-12-02 01:19:52 +00001119 if (Implicit) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001120 auto *Getter = ReadDeclAs<ObjCMethodDecl>();
1121 auto *Setter = ReadDeclAs<ObjCMethodDecl>();
Argyrios Kyrtzidisab468b02012-03-30 00:19:18 +00001122 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCallb7bd14f2010-12-02 01:19:52 +00001123 } else {
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001124 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001125 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001126 E->setLocation(ReadSourceLocation());
1127 E->setReceiverLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001128 switch (Record.readInt()) {
John McCallb7bd14f2010-12-02 01:19:52 +00001129 case 0:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001130 E->setBase(Record.readSubExpr());
John McCallb7bd14f2010-12-02 01:19:52 +00001131 break;
1132 case 1:
David L. Jonesbe1557a2016-12-21 00:17:49 +00001133 E->setSuperReceiver(Record.readType());
John McCallb7bd14f2010-12-02 01:19:52 +00001134 break;
1135 case 2:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001136 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>());
John McCallb7bd14f2010-12-02 01:19:52 +00001137 break;
1138 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001139}
1140
Ted Kremeneke65b0862012-03-06 20:05:56 +00001141void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1142 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001143 E->setRBracket(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001144 E->setBaseExpr(Record.readSubExpr());
1145 E->setKeyExpr(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001146 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1147 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001148}
1149
Sebastian Redl70c751d2010-08-18 23:56:52 +00001150void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001151 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001152 assert(Record.peekInt() == E->getNumArgs());
1153 Record.skipInts(1);
1154 unsigned NumStoredSelLocs = Record.readInt();
1155 E->SelLocsKind = Record.readInt();
1156 E->setDelegateInitCall(Record.readInt());
1157 E->IsImplicit = Record.readInt();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001158 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
Douglas Gregor9a129192010-04-21 00:45:42 +00001159 switch (Kind) {
1160 case ObjCMessageExpr::Instance:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001161 E->setInstanceReceiver(Record.readSubExpr());
Douglas Gregor9a129192010-04-21 00:45:42 +00001162 break;
1163
1164 case ObjCMessageExpr::Class:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001165 E->setClassReceiver(GetTypeSourceInfo());
Douglas Gregor9a129192010-04-21 00:45:42 +00001166 break;
1167
1168 case ObjCMessageExpr::SuperClass:
1169 case ObjCMessageExpr::SuperInstance: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001170 QualType T = Record.readType();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001171 SourceLocation SuperLoc = ReadSourceLocation();
Douglas Gregor9a129192010-04-21 00:45:42 +00001172 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1173 break;
1174 }
1175 }
1176
1177 assert(Kind == E->getReceiverKind());
1178
David L. Jonesbe1557a2016-12-21 00:17:49 +00001179 if (Record.readInt())
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001180 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>());
Douglas Gregor9a129192010-04-21 00:45:42 +00001181 else
David L. Jonesb6a8f022016-12-21 04:34:52 +00001182 E->setSelector(Record.readSelector());
Douglas Gregor9a129192010-04-21 00:45:42 +00001183
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001184 E->LBracLoc = ReadSourceLocation();
1185 E->RBracLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001186
1187 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001188 E->setArg(I, Record.readSubExpr());
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00001189
1190 SourceLocation *Locs = E->getStoredSelLocs();
1191 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001192 Locs[I] = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001193}
1194
Sebastian Redl70c751d2010-08-18 23:56:52 +00001195void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001196 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001197 S->setElement(Record.readSubStmt());
1198 S->setCollection(Record.readSubExpr());
1199 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001200 S->setForLoc(ReadSourceLocation());
1201 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001202}
1203
Sebastian Redl70c751d2010-08-18 23:56:52 +00001204void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001205 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001206 S->setCatchBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001207 S->setCatchParamDecl(ReadDeclAs<VarDecl>());
1208 S->setAtCatchLoc(ReadSourceLocation());
1209 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001210}
1211
Sebastian Redl70c751d2010-08-18 23:56:52 +00001212void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001213 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001214 S->setFinallyBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001215 S->setAtFinallyLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001216}
1217
John McCall31168b02011-06-15 23:02:42 +00001218void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1219 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001220 S->setSubStmt(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001221 S->setAtLoc(ReadSourceLocation());
John McCall31168b02011-06-15 23:02:42 +00001222}
1223
Sebastian Redl70c751d2010-08-18 23:56:52 +00001224void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001225 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001226 assert(Record.peekInt() == S->getNumCatchStmts());
1227 Record.skipInts(1);
1228 bool HasFinally = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001229 S->setTryBody(Record.readSubStmt());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001230 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001231 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
Douglas Gregor96c79492010-04-23 22:50:49 +00001232
Douglas Gregor96c79492010-04-23 22:50:49 +00001233 if (HasFinally)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001234 S->setFinallyStmt(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001235 S->setAtTryLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001236}
1237
Sebastian Redl70c751d2010-08-18 23:56:52 +00001238void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001239 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001240 S->setSynchExpr(Record.readSubStmt());
1241 S->setSynchBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001242 S->setAtSynchronizedLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001243}
1244
Sebastian Redl70c751d2010-08-18 23:56:52 +00001245void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001246 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001247 S->setThrowExpr(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001248 S->setThrowLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001249}
1250
Ted Kremeneke65b0862012-03-06 20:05:56 +00001251void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1252 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001253 E->setValue(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001254 E->setLocation(ReadSourceLocation());
Ted Kremeneke65b0862012-03-06 20:05:56 +00001255}
1256
Erik Pilkington29099de2016-07-16 00:35:23 +00001257void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1258 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001259 SourceRange R = Record.readSourceRange();
Erik Pilkington29099de2016-07-16 00:35:23 +00001260 E->AtLoc = R.getBegin();
1261 E->RParen = R.getEnd();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001262 E->VersionToCheck = Record.readVersionTuple();
Erik Pilkington29099de2016-07-16 00:35:23 +00001263}
1264
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001265//===----------------------------------------------------------------------===//
1266// C++ Expressions and Statements
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001267//===----------------------------------------------------------------------===//
1268
Sebastian Redl70c751d2010-08-18 23:56:52 +00001269void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001270 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001271 S->CatchLoc = ReadSourceLocation();
1272 S->ExceptionDecl = ReadDeclAs<VarDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001273 S->HandlerBlock = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001274}
1275
Sebastian Redl70c751d2010-08-18 23:56:52 +00001276void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001277 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001278 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1279 Record.skipInts(1);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001280 S->TryLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001281 S->getStmts()[0] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001282 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001283 S->getStmts()[i + 1] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001284}
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001285
Richard Smith02e85f32011-04-14 22:09:26 +00001286void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1287 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001288 S->ForLoc = ReadSourceLocation();
1289 S->CoawaitLoc = ReadSourceLocation();
1290 S->ColonLoc = ReadSourceLocation();
1291 S->RParenLoc = ReadSourceLocation();
Richard Smith8baa5002018-09-28 18:44:09 +00001292 S->setInit(Record.readSubStmt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001293 S->setRangeStmt(Record.readSubStmt());
1294 S->setBeginStmt(Record.readSubStmt());
1295 S->setEndStmt(Record.readSubStmt());
1296 S->setCond(Record.readSubExpr());
1297 S->setInc(Record.readSubExpr());
1298 S->setLoopVarStmt(Record.readSubStmt());
1299 S->setBody(Record.readSubStmt());
Richard Smith02e85f32011-04-14 22:09:26 +00001300}
1301
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001302void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1303 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001304 S->KeywordLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001305 S->IsIfExists = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001306 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001307 ReadDeclarationNameInfo(S->NameInfo);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001308 S->SubStmt = Record.readSubStmt();
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001309}
1310
Sebastian Redl70c751d2010-08-18 23:56:52 +00001311void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001312 VisitCallExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001313 E->Operator = (OverloadedOperatorKind)Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001314 E->Range = Record.readSourceRange();
Adam Nemet484aa452017-03-27 19:17:25 +00001315 E->setFPFeatures(FPOptions(Record.readInt()));
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001316}
1317
Sebastian Redl70c751d2010-08-18 23:56:52 +00001318void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001319 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001320 E->NumArgs = Record.readInt();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001321 if (E->NumArgs)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001322 E->Args = new (Record.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis30d98f32010-06-24 08:57:09 +00001323 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001324 E->setArg(I, Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001325 E->setConstructor(ReadDeclAs<CXXConstructorDecl>());
1326 E->setLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001327 E->setElidable(Record.readInt());
1328 E->setHadMultipleCandidates(Record.readInt());
1329 E->setListInitialization(Record.readInt());
1330 E->setStdInitListInitialization(Record.readInt());
1331 E->setRequiresZeroInitialization(Record.readInt());
1332 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001333 E->ParenOrBraceRange = ReadSourceRange();
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001334}
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001335
Richard Smith5179eb72016-06-28 19:03:57 +00001336void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1337 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001338 E->Constructor = ReadDeclAs<CXXConstructorDecl>();
1339 E->Loc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001340 E->ConstructsVirtualBase = Record.readInt();
1341 E->InheritedFromVirtualBase = Record.readInt();
Richard Smith5179eb72016-06-28 19:03:57 +00001342}
1343
Sebastian Redl70c751d2010-08-18 23:56:52 +00001344void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001345 VisitCXXConstructExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001346 E->Type = GetTypeSourceInfo();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001347}
1348
Douglas Gregore31e6062012-02-07 10:09:13 +00001349void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1350 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001351 unsigned NumCaptures = Record.readInt();
Douglas Gregor99ae8062012-02-14 17:54:36 +00001352 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001353 E->IntroducerRange = ReadSourceRange();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001354 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001355 E->CaptureDefaultLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001356 E->ExplicitParams = Record.readInt();
1357 E->ExplicitResultType = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001358 E->ClosingBrace = ReadSourceLocation();
1359
Douglas Gregor99ae8062012-02-14 17:54:36 +00001360 // Read capture initializers.
1361 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1362 CEnd = E->capture_init_end();
1363 C != CEnd; ++C)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001364 *C = Record.readSubExpr();
Douglas Gregore31e6062012-02-07 10:09:13 +00001365}
1366
Richard Smithcc1b96d2013-06-12 22:31:48 +00001367void
1368ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1369 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001370 E->SubExpr = Record.readSubExpr();
Richard Smithcc1b96d2013-06-12 22:31:48 +00001371}
1372
Sebastian Redl70c751d2010-08-18 23:56:52 +00001373void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001374 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001375 SourceRange R = ReadSourceRange();
Douglas Gregor4478f852011-01-12 22:41:29 +00001376 E->Loc = R.getBegin();
1377 E->RParenLoc = R.getEnd();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001378 R = ReadSourceRange();
Fariborz Jahanianf0738712013-02-22 22:02:53 +00001379 E->AngleBrackets = R;
Sam Weinigd01101e2010-01-16 21:21:01 +00001380}
1381
Sebastian Redl70c751d2010-08-18 23:56:52 +00001382void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001383 return VisitCXXNamedCastExpr(E);
1384}
1385
Sebastian Redl70c751d2010-08-18 23:56:52 +00001386void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001387 return VisitCXXNamedCastExpr(E);
1388}
1389
Sebastian Redl70c751d2010-08-18 23:56:52 +00001390void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001391 return VisitCXXNamedCastExpr(E);
1392}
1393
Sebastian Redl70c751d2010-08-18 23:56:52 +00001394void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001395 return VisitCXXNamedCastExpr(E);
1396}
1397
Sebastian Redl70c751d2010-08-18 23:56:52 +00001398void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001399 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001400 E->setLParenLoc(ReadSourceLocation());
1401 E->setRParenLoc(ReadSourceLocation());
Sam Weinigd01101e2010-01-16 21:21:01 +00001402}
1403
Richard Smithc67fdd42012-03-07 08:35:16 +00001404void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1405 VisitCallExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001406 E->UDSuffixLoc = ReadSourceLocation();
Richard Smithc67fdd42012-03-07 08:35:16 +00001407}
1408
Sebastian Redl70c751d2010-08-18 23:56:52 +00001409void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001410 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001411 E->setValue(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001412 E->setLocation(ReadSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001413}
1414
Sebastian Redl70c751d2010-08-18 23:56:52 +00001415void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001416 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001417 E->setLocation(ReadSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001418}
1419
Sebastian Redl70c751d2010-08-18 23:56:52 +00001420void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001421 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001422 E->setSourceRange(ReadSourceRange());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001423 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redlc67764e2010-07-22 22:43:28 +00001424 E->setTypeOperandSourceInfo(
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001425 GetTypeSourceInfo());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001426 return;
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001427 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001428
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001429 // typeid(42+2)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001430 E->setExprOperand(Record.readSubExpr());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001431}
1432
Sebastian Redl70c751d2010-08-18 23:56:52 +00001433void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001434 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001435 E->setLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001436 E->setImplicit(Record.readInt());
Chris Lattner98267332010-05-09 06:15:05 +00001437}
1438
Sebastian Redl70c751d2010-08-18 23:56:52 +00001439void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001440 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001441 E->ThrowLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001442 E->Op = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001443 E->IsThrownVariableInScope = Record.readInt();
Chris Lattner98267332010-05-09 06:15:05 +00001444}
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001445
Sebastian Redl70c751d2010-08-18 23:56:52 +00001446void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattnere2437f42010-05-09 06:40:08 +00001447 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001448 E->Param = ReadDeclAs<ParmVarDecl>();
1449 E->Loc = ReadSourceLocation();
Chris Lattnercba86142010-05-10 00:25:06 +00001450}
1451
Richard Smith852c9db2013-04-20 22:23:05 +00001452void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1453 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001454 E->Field = ReadDeclAs<FieldDecl>();
1455 E->Loc = ReadSourceLocation();
Richard Smith852c9db2013-04-20 22:23:05 +00001456}
1457
Sebastian Redl70c751d2010-08-18 23:56:52 +00001458void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001459 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001460 E->setTemporary(Record.readCXXTemporary());
1461 E->setSubExpr(Record.readSubExpr());
Chris Lattnercba86142010-05-10 00:25:06 +00001462}
1463
Sebastian Redl70c751d2010-08-18 23:56:52 +00001464void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001465 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001466 E->TypeInfo = GetTypeSourceInfo();
1467 E->RParenLoc = ReadSourceLocation();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001468}
1469
Sebastian Redl70c751d2010-08-18 23:56:52 +00001470void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001471 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001472 E->GlobalNew = Record.readInt();
1473 bool isArray = Record.readInt();
1474 E->PassAlignment = Record.readInt();
1475 E->UsualArrayDeleteWantsSize = Record.readInt();
1476 unsigned NumPlacementArgs = Record.readInt();
1477 E->StoredInitializationStyle = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001478 E->setOperatorNew(ReadDeclAs<FunctionDecl>());
1479 E->setOperatorDelete(ReadDeclAs<FunctionDecl>());
1480 E->AllocatedTypeInfo = GetTypeSourceInfo();
1481 E->TypeIdParens = ReadSourceRange();
1482 E->Range = ReadSourceRange();
1483 E->DirectInitRange = ReadSourceRange();
Chandler Carruth01718152010-10-25 08:47:36 +00001484
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001485 E->AllocateArgsArray(Record.getContext(), isArray, NumPlacementArgs,
Sebastian Redl6047f072012-02-16 12:22:20 +00001486 E->StoredInitializationStyle != 0);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001487
1488 // Install all the subexpressions.
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001489 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1490 I != e; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001491 *I = Record.readSubStmt();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001492}
1493
Sebastian Redl70c751d2010-08-18 23:56:52 +00001494void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001495 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001496 E->GlobalDelete = Record.readInt();
1497 E->ArrayForm = Record.readInt();
1498 E->ArrayFormAsWritten = Record.readInt();
1499 E->UsualArrayDeleteWantsSize = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001500 E->OperatorDelete = ReadDeclAs<FunctionDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001501 E->Argument = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001502 E->Loc = ReadSourceLocation();
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001503}
Chris Lattnercba86142010-05-10 00:25:06 +00001504
Sebastian Redl70c751d2010-08-18 23:56:52 +00001505void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001506 VisitExpr(E);
1507
David L. Jonesb6a8f022016-12-21 04:34:52 +00001508 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001509 E->IsArrow = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001510 E->OperatorLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001511 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001512 E->ScopeType = GetTypeSourceInfo();
1513 E->ColonColonLoc = ReadSourceLocation();
1514 E->TildeLoc = ReadSourceLocation();
1515
David L. Jonesb6a8f022016-12-21 04:34:52 +00001516 IdentifierInfo *II = Record.getIdentifierInfo();
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001517 if (II)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001518 E->setDestroyedType(II, ReadSourceLocation());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001519 else
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001520 E->setDestroyedType(GetTypeSourceInfo());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001521}
1522
John McCall5d413782010-12-06 08:20:24 +00001523void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001524 VisitExpr(E);
John McCall28fc7092011-11-10 05:35:25 +00001525
David L. Jonesbe1557a2016-12-21 00:17:49 +00001526 unsigned NumObjects = Record.readInt();
John McCall28fc7092011-11-10 05:35:25 +00001527 assert(NumObjects == E->getNumObjects());
1528 for (unsigned i = 0; i != NumObjects; ++i)
James Y Knighte00a67e2015-12-31 04:18:25 +00001529 E->getTrailingObjects<BlockDecl *>()[i] =
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001530 ReadDeclAs<BlockDecl>();
John McCall28fc7092011-11-10 05:35:25 +00001531
David L. Jonesbe1557a2016-12-21 00:17:49 +00001532 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001533 E->SubExpr = Record.readSubExpr();
Chris Lattnere2437f42010-05-09 06:40:08 +00001534}
1535
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001536void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001537ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001538 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001539
David L. Jonesbe1557a2016-12-21 00:17:49 +00001540 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001541 ReadTemplateKWAndArgsInfo(
1542 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1543 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001544 /*NumTemplateArgs=*/Record.readInt());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001545
David L. Jonesb6a8f022016-12-21 04:34:52 +00001546 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001547 E->BaseType = Record.readType();
1548 E->IsArrow = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001549 E->OperatorLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001550 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001551 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>();
1552 ReadDeclarationNameInfo(E->MemberNameInfo);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001553}
1554
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001555void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001556ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001557 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001558
David L. Jonesbe1557a2016-12-21 00:17:49 +00001559 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001560 ReadTemplateKWAndArgsInfo(
1561 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1562 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001563 /*NumTemplateArgs=*/Record.readInt());
Douglas Gregor3a43fd62011-02-25 20:49:16 +00001564
David L. Jonesb6a8f022016-12-21 04:34:52 +00001565 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001566 ReadDeclarationNameInfo(E->NameInfo);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001567}
1568
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001569void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001570ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001571 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001572 assert(Record.peekInt() == E->arg_size() &&
1573 "Read wrong record during creation ?");
1574 Record.skipInts(1);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001575 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001576 E->setArg(I, Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001577 E->Type = GetTypeSourceInfo();
1578 E->setLParenLoc(ReadSourceLocation());
1579 E->setRParenLoc(ReadSourceLocation());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001580}
1581
Sebastian Redl70c751d2010-08-18 23:56:52 +00001582void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001583 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001584
David L. Jonesbe1557a2016-12-21 00:17:49 +00001585 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001586 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1587 E->getTrailingTemplateArgumentLoc(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001588 /*NumTemplateArgs=*/Record.readInt());
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001589
David L. Jonesbe1557a2016-12-21 00:17:49 +00001590 unsigned NumDecls = Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001591 UnresolvedSet<8> Decls;
1592 for (unsigned i = 0; i != NumDecls; ++i) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001593 auto *D = ReadDeclAs<NamedDecl>();
1594 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001595 Decls.addDecl(D, AS);
1596 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001597 E->initializeResults(Record.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001598
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001599 ReadDeclarationNameInfo(E->NameInfo);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001600 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001601}
1602
Sebastian Redl70c751d2010-08-18 23:56:52 +00001603void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001604 VisitOverloadExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001605 E->IsArrow = Record.readInt();
1606 E->HasUnresolvedUsing = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001607 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001608 E->BaseType = Record.readType();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001609 E->OperatorLoc = ReadSourceLocation();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001610}
1611
Sebastian Redl70c751d2010-08-18 23:56:52 +00001612void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001613 VisitOverloadExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001614 E->RequiresADL = Record.readInt();
1615 E->Overloaded = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001616 E->NamingClass = ReadDeclAs<CXXRecordDecl>();
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00001617}
1618
Douglas Gregor29c42f22012-02-24 07:38:34 +00001619void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1620 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001621 E->TypeTraitExprBits.NumArgs = Record.readInt();
1622 E->TypeTraitExprBits.Kind = Record.readInt();
1623 E->TypeTraitExprBits.Value = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001624 SourceRange Range = ReadSourceRange();
Jordan Rose99e80c12013-12-20 01:26:47 +00001625 E->Loc = Range.getBegin();
1626 E->RParenLoc = Range.getEnd();
1627
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001628 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001629 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001630 Args[I] = GetTypeSourceInfo();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001631}
1632
John Wiegley6242b6a2011-04-28 00:16:57 +00001633void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1634 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001635 E->ATT = (ArrayTypeTrait)Record.readInt();
1636 E->Value = (unsigned int)Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001637 SourceRange Range = ReadSourceRange();
John Wiegley6242b6a2011-04-28 00:16:57 +00001638 E->Loc = Range.getBegin();
1639 E->RParen = Range.getEnd();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001640 E->QueriedType = GetTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001641 E->Dimension = Record.readSubExpr();
John Wiegley6242b6a2011-04-28 00:16:57 +00001642}
1643
John Wiegleyf9f65842011-04-25 06:54:41 +00001644void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1645 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001646 E->ET = (ExpressionTrait)Record.readInt();
1647 E->Value = (bool)Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001648 SourceRange Range = ReadSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001649 E->QueriedExpression = Record.readSubExpr();
John Wiegleyf9f65842011-04-25 06:54:41 +00001650 E->Loc = Range.getBegin();
1651 E->RParen = Range.getEnd();
1652}
1653
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001654void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1655 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001656 E->Value = (bool)Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001657 E->Range = ReadSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001658 E->Operand = Record.readSubExpr();
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001659}
1660
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001661void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1662 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001663 E->EllipsisLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001664 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001665 E->Pattern = Record.readSubExpr();
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001666}
1667
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001668void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1669 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001670 unsigned NumPartialArgs = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001671 E->OperatorLoc = ReadSourceLocation();
1672 E->PackLoc = ReadSourceLocation();
1673 E->RParenLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001674 E->Pack = Record.readDeclAs<NamedDecl>();
Richard Smithd784e682015-09-23 21:41:42 +00001675 if (E->isPartiallySubstituted()) {
1676 assert(E->Length == NumPartialArgs);
James Y Knighte00a67e2015-12-31 04:18:25 +00001677 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
Richard Smithd784e682015-09-23 21:41:42 +00001678 *E = I + NumPartialArgs;
1679 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001680 new (I) TemplateArgument(Record.readTemplateArgument());
Richard Smithd784e682015-09-23 21:41:42 +00001681 } else if (!E->isValueDependent()) {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001682 E->Length = Record.readInt();
Richard Smithd784e682015-09-23 21:41:42 +00001683 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001684}
1685
John McCallfa194042011-07-15 07:00:14 +00001686void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1687 SubstNonTypeTemplateParmExpr *E) {
1688 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001689 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1690 E->NameLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001691 E->Replacement = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00001692}
1693
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001694void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1695 SubstNonTypeTemplateParmPackExpr *E) {
1696 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001697 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001698 TemplateArgument ArgPack = Record.readTemplateArgument();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001699 if (ArgPack.getKind() != TemplateArgument::Pack)
1700 return;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001701
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001702 E->Arguments = ArgPack.pack_begin();
1703 E->NumArguments = ArgPack.pack_size();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001704 E->NameLoc = ReadSourceLocation();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001705}
1706
Richard Smithb15fe3a2012-09-12 00:56:43 +00001707void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1708 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001709 E->NumParameters = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001710 E->ParamPack = ReadDeclAs<ParmVarDecl>();
1711 E->NameLoc = ReadSourceLocation();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001712 auto **Parms = E->getTrailingObjects<ParmVarDecl *>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00001713 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001714 Parms[i] = ReadDeclAs<ParmVarDecl>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00001715}
1716
Douglas Gregorfe314812011-06-21 17:03:29 +00001717void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1718 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001719 E->State = Record.readSubExpr();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001720 auto *VD = ReadDeclAs<ValueDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001721 unsigned ManglingNumber = Record.readInt();
David Majnemerdaff3702014-05-01 17:50:17 +00001722 E->setExtendingDecl(VD, ManglingNumber);
Douglas Gregorfe314812011-06-21 17:03:29 +00001723}
1724
Richard Smith0f0af192014-11-08 05:07:16 +00001725void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
1726 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001727 E->LParenLoc = ReadSourceLocation();
1728 E->EllipsisLoc = ReadSourceLocation();
1729 E->RParenLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001730 E->SubExprs[0] = Record.readSubExpr();
1731 E->SubExprs[1] = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001732 E->Opcode = (BinaryOperatorKind)Record.readInt();
Richard Smith0f0af192014-11-08 05:07:16 +00001733}
1734
John McCall8d69a212010-11-15 23:31:06 +00001735void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1736 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001737 E->SourceExpr = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001738 E->Loc = ReadSourceLocation();
Akira Hatanaka797afe32018-03-20 01:47:58 +00001739 E->setIsUnique(Record.readInt());
John McCall8d69a212010-11-15 23:31:06 +00001740}
1741
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001742void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
1743 llvm_unreachable("Cannot read TypoExpr nodes");
1744}
1745
Peter Collingbourne41f85462011-02-09 21:07:24 +00001746//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00001747// Microsoft Expressions and Statements
1748//===----------------------------------------------------------------------===//
John McCall5e77d762013-04-16 07:28:30 +00001749void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1750 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001751 E->IsArrow = (Record.readInt() != 0);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001752 E->BaseExpr = Record.readSubExpr();
1753 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001754 E->MemberLoc = ReadSourceLocation();
1755 E->TheDecl = ReadDeclAs<MSPropertyDecl>();
John McCall5e77d762013-04-16 07:28:30 +00001756}
1757
Alexey Bataevf7630272015-11-25 12:01:00 +00001758void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
1759 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001760 E->setBase(Record.readSubExpr());
1761 E->setIdx(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001762 E->setRBracketLoc(ReadSourceLocation());
Alexey Bataevf7630272015-11-25 12:01:00 +00001763}
1764
John McCallfa194042011-07-15 07:00:14 +00001765void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1766 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001767 E->setSourceRange(ReadSourceRange());
1768 std::string UuidStr = ReadString();
1769 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
John McCallfa194042011-07-15 07:00:14 +00001770 if (E->isTypeOperand()) { // __uuidof(ComType)
1771 E->setTypeOperandSourceInfo(
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001772 GetTypeSourceInfo());
John McCallfa194042011-07-15 07:00:14 +00001773 return;
1774 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001775
John McCallfa194042011-07-15 07:00:14 +00001776 // __uuidof(expr)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001777 E->setExprOperand(Record.readSubExpr());
John McCallfa194042011-07-15 07:00:14 +00001778}
1779
Nico Weber9b982072014-07-07 00:12:30 +00001780void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1781 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001782 S->setLeaveLoc(ReadSourceLocation());
Nico Weber9b982072014-07-07 00:12:30 +00001783}
1784
John McCallfa194042011-07-15 07:00:14 +00001785void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1786 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001787 S->Loc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001788 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
1789 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001790}
1791
1792void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1793 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001794 S->Loc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001795 S->Block = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001796}
1797
1798void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1799 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001800 S->IsCXXTry = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001801 S->TryLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001802 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
1803 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001804}
1805
1806//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00001807// CUDA Expressions and Statements
1808//===----------------------------------------------------------------------===//
1809
1810void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1811 VisitCallExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001812 E->setConfig(cast<CallExpr>(Record.readSubExpr()));
Peter Collingbourne41f85462011-02-09 21:07:24 +00001813}
1814
John McCallfa194042011-07-15 07:00:14 +00001815//===----------------------------------------------------------------------===//
1816// OpenCL Expressions and Statements.
1817//===----------------------------------------------------------------------===//
1818void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1819 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001820 E->BuiltinLoc = ReadSourceLocation();
1821 E->RParenLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001822 E->SrcExpr = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00001823}
1824
1825//===----------------------------------------------------------------------===//
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001826// OpenMP Directives.
1827//===----------------------------------------------------------------------===//
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001828
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001829void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001830 E->setLocStart(ReadSourceLocation());
1831 E->setLocEnd(ReadSourceLocation());
Kelvin Libe286f52018-09-15 13:54:15 +00001832 OMPClauseReader ClauseReader(Record);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001833 SmallVector<OMPClause *, 5> Clauses;
1834 for (unsigned i = 0; i < E->getNumClauses(); ++i)
1835 Clauses.push_back(ClauseReader.readClause());
1836 E->setClauses(Clauses);
Alexey Bataev68446b72014-07-18 07:47:19 +00001837 if (E->hasAssociatedStmt())
David L. Jonesb6a8f022016-12-21 04:34:52 +00001838 E->setAssociatedStmt(Record.readSubStmt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001839}
1840
Alexander Musman3aaab662014-08-19 11:27:13 +00001841void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
1842 VisitStmt(D);
1843 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001844 Record.skipInts(2);
Alexander Musman3aaab662014-08-19 11:27:13 +00001845 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001846 D->setIterationVariable(Record.readSubExpr());
1847 D->setLastIteration(Record.readSubExpr());
1848 D->setCalcLastIteration(Record.readSubExpr());
1849 D->setPreCond(Record.readSubExpr());
1850 D->setCond(Record.readSubExpr());
1851 D->setInit(Record.readSubExpr());
1852 D->setInc(Record.readSubExpr());
1853 D->setPreInits(Record.readSubStmt());
Alexey Bataev3392d762016-02-16 11:18:12 +00001854 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
Carlo Bertollifc35ad22016-03-07 16:04:49 +00001855 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
1856 isOpenMPDistributeDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001857 D->setIsLastIterVariable(Record.readSubExpr());
1858 D->setLowerBoundVariable(Record.readSubExpr());
1859 D->setUpperBoundVariable(Record.readSubExpr());
1860 D->setStrideVariable(Record.readSubExpr());
1861 D->setEnsureUpperBound(Record.readSubExpr());
1862 D->setNextLowerBound(Record.readSubExpr());
1863 D->setNextUpperBound(Record.readSubExpr());
1864 D->setNumIterations(Record.readSubExpr());
Alexander Musmanc6388682014-12-15 07:07:06 +00001865 }
Carlo Bertolli9925f152016-06-27 14:55:37 +00001866 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001867 D->setPrevLowerBoundVariable(Record.readSubExpr());
1868 D->setPrevUpperBoundVariable(Record.readSubExpr());
Carlo Bertolli8429d812017-02-17 21:29:13 +00001869 D->setDistInc(Record.readSubExpr());
1870 D->setPrevEnsureUpperBound(Record.readSubExpr());
Carlo Bertolliffafe102017-04-20 00:39:39 +00001871 D->setCombinedLowerBoundVariable(Record.readSubExpr());
1872 D->setCombinedUpperBoundVariable(Record.readSubExpr());
1873 D->setCombinedEnsureUpperBound(Record.readSubExpr());
1874 D->setCombinedInit(Record.readSubExpr());
1875 D->setCombinedCond(Record.readSubExpr());
1876 D->setCombinedNextLowerBound(Record.readSubExpr());
1877 D->setCombinedNextUpperBound(Record.readSubExpr());
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001878 D->setCombinedDistCond(Record.readSubExpr());
1879 D->setCombinedParForInDistCond(Record.readSubExpr());
Carlo Bertolli9925f152016-06-27 14:55:37 +00001880 }
Alexander Musmana5f070a2014-10-01 06:03:56 +00001881 SmallVector<Expr *, 4> Sub;
1882 unsigned CollapsedNum = D->getCollapsedNumber();
1883 Sub.reserve(CollapsedNum);
1884 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001885 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00001886 D->setCounters(Sub);
1887 Sub.clear();
1888 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001889 Sub.push_back(Record.readSubExpr());
Alexey Bataeva8899172015-08-06 12:30:57 +00001890 D->setPrivateCounters(Sub);
1891 Sub.clear();
1892 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001893 Sub.push_back(Record.readSubExpr());
Alexey Bataevb08f89f2015-08-14 12:25:37 +00001894 D->setInits(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());
Alexander Musmana5f070a2014-10-01 06:03:56 +00001898 D->setUpdates(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());
Alexander Musmana5f070a2014-10-01 06:03:56 +00001902 D->setFinals(Sub);
Alexander Musman3aaab662014-08-19 11:27:13 +00001903}
1904
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001905void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
Alexey Bataev1b59ab52014-02-27 08:29:12 +00001906 VisitStmt(D);
1907 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001908 Record.skipInts(1);
Alexey Bataev1b59ab52014-02-27 08:29:12 +00001909 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001910 D->setHasCancel(Record.readInt());
Alexey Bataev1b59ab52014-02-27 08:29:12 +00001911}
1912
1913void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00001914 VisitOMPLoopDirective(D);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001915}
1916
Alexey Bataevf29276e2014-06-18 04:14:57 +00001917void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00001918 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001919 D->setHasCancel(Record.readInt());
Alexey Bataevf29276e2014-06-18 04:14:57 +00001920}
1921
Alexander Musmanf82886e2014-09-18 05:12:34 +00001922void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
1923 VisitOMPLoopDirective(D);
1924}
1925
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00001926void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
1927 VisitStmt(D);
1928 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001929 Record.skipInts(1);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00001930 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001931 D->setHasCancel(Record.readInt());
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00001932}
1933
Alexey Bataev1e0498a2014-06-26 08:21:58 +00001934void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
1935 VisitStmt(D);
1936 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001937 D->setHasCancel(Record.readInt());
Alexey Bataev1e0498a2014-06-26 08:21:58 +00001938}
1939
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00001940void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
1941 VisitStmt(D);
1942 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001943 Record.skipInts(1);
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00001944 VisitOMPExecutableDirective(D);
1945}
1946
Alexander Musman80c22892014-07-17 08:54:58 +00001947void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
1948 VisitStmt(D);
1949 VisitOMPExecutableDirective(D);
1950}
1951
Alexander Musmand9ed09f2014-07-21 09:42:05 +00001952void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
1953 VisitStmt(D);
Alexey Bataev28c75412015-12-15 08:19:24 +00001954 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001955 Record.skipInts(1);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00001956 VisitOMPExecutableDirective(D);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001957 ReadDeclarationNameInfo(D->DirName);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00001958}
1959
Alexey Bataev4acb8592014-07-07 13:01:15 +00001960void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00001961 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001962 D->setHasCancel(Record.readInt());
Alexey Bataev4acb8592014-07-07 13:01:15 +00001963}
1964
Alexander Musmane4e893b2014-09-23 09:33:00 +00001965void ASTStmtReader::VisitOMPParallelForSimdDirective(
1966 OMPParallelForSimdDirective *D) {
1967 VisitOMPLoopDirective(D);
1968}
1969
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00001970void ASTStmtReader::VisitOMPParallelSectionsDirective(
1971 OMPParallelSectionsDirective *D) {
1972 VisitStmt(D);
1973 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001974 Record.skipInts(1);
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00001975 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001976 D->setHasCancel(Record.readInt());
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00001977}
1978
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00001979void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *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 Bataev9c2e8ee2014-07-11 11:25:16 +00001983 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001984 D->setHasCancel(Record.readInt());
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00001985}
1986
Alexey Bataev68446b72014-07-18 07:47:19 +00001987void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
1988 VisitStmt(D);
1989 VisitOMPExecutableDirective(D);
1990}
1991
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00001992void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
1993 VisitStmt(D);
1994 VisitOMPExecutableDirective(D);
1995}
1996
Alexey Bataev2df347a2014-07-18 10:17:07 +00001997void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
1998 VisitStmt(D);
1999 VisitOMPExecutableDirective(D);
2000}
2001
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002002void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2003 VisitStmt(D);
Alexey Bataev169d96a2017-07-18 20:17:46 +00002004 // The NumClauses field was read in ReadStmtFromStream.
2005 Record.skipInts(1);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002006 VisitOMPExecutableDirective(D);
Alexey Bataev3b1b8952017-07-25 15:53:26 +00002007 D->setReductionRef(Record.readSubExpr());
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002008}
2009
Alexey Bataev6125da92014-07-21 11:26:11 +00002010void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2011 VisitStmt(D);
2012 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002013 Record.skipInts(1);
Alexey Bataev6125da92014-07-21 11:26:11 +00002014 VisitOMPExecutableDirective(D);
2015}
2016
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002017void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2018 VisitStmt(D);
Alexey Bataev346265e2015-09-25 10:37:12 +00002019 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002020 Record.skipInts(1);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002021 VisitOMPExecutableDirective(D);
2022}
2023
Alexey Bataev0162e452014-07-22 10:10:35 +00002024void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2025 VisitStmt(D);
2026 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002027 Record.skipInts(1);
Alexey Bataev0162e452014-07-22 10:10:35 +00002028 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002029 D->setX(Record.readSubExpr());
2030 D->setV(Record.readSubExpr());
2031 D->setExpr(Record.readSubExpr());
2032 D->setUpdateExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002033 D->IsXLHSInRHSPart = Record.readInt() != 0;
2034 D->IsPostfixUpdate = Record.readInt() != 0;
Alexey Bataev0162e452014-07-22 10:10:35 +00002035}
2036
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002037void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2038 VisitStmt(D);
2039 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002040 Record.skipInts(1);
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002041 VisitOMPExecutableDirective(D);
2042}
2043
Michael Wong65f367f2015-07-21 13:44:28 +00002044void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2045 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002046 Record.skipInts(1);
Michael Wong65f367f2015-07-21 13:44:28 +00002047 VisitOMPExecutableDirective(D);
2048}
2049
Samuel Antaodf67fc42016-01-19 19:15:56 +00002050void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2051 OMPTargetEnterDataDirective *D) {
2052 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002053 Record.skipInts(1);
Samuel Antaodf67fc42016-01-19 19:15:56 +00002054 VisitOMPExecutableDirective(D);
2055}
2056
Samuel Antao72590762016-01-19 20:04:50 +00002057void ASTStmtReader::VisitOMPTargetExitDataDirective(
2058 OMPTargetExitDataDirective *D) {
2059 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002060 Record.skipInts(1);
Samuel Antao72590762016-01-19 20:04:50 +00002061 VisitOMPExecutableDirective(D);
2062}
2063
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002064void ASTStmtReader::VisitOMPTargetParallelDirective(
2065 OMPTargetParallelDirective *D) {
2066 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002067 Record.skipInts(1);
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002068 VisitOMPExecutableDirective(D);
2069}
2070
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002071void ASTStmtReader::VisitOMPTargetParallelForDirective(
2072 OMPTargetParallelForDirective *D) {
2073 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002074 D->setHasCancel(Record.readInt());
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002075}
2076
Alexey Bataev13314bf2014-10-09 04:18:56 +00002077void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2078 VisitStmt(D);
2079 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002080 Record.skipInts(1);
Alexey Bataev13314bf2014-10-09 04:18:56 +00002081 VisitOMPExecutableDirective(D);
2082}
2083
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002084void ASTStmtReader::VisitOMPCancellationPointDirective(
2085 OMPCancellationPointDirective *D) {
2086 VisitStmt(D);
2087 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002088 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002089}
2090
Alexey Bataev80909872015-07-02 11:25:17 +00002091void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2092 VisitStmt(D);
Alexey Bataev87933c72015-09-18 08:07:34 +00002093 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002094 Record.skipInts(1);
Alexey Bataev80909872015-07-02 11:25:17 +00002095 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002096 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev80909872015-07-02 11:25:17 +00002097}
2098
Alexey Bataev49f6e782015-12-01 04:18:41 +00002099void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2100 VisitOMPLoopDirective(D);
2101}
2102
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002103void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2104 VisitOMPLoopDirective(D);
2105}
2106
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002107void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2108 VisitOMPLoopDirective(D);
2109}
2110
Samuel Antao686c70c2016-05-26 17:30:50 +00002111void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2112 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002113 Record.skipInts(1);
Samuel Antao686c70c2016-05-26 17:30:50 +00002114 VisitOMPExecutableDirective(D);
2115}
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002116
Carlo Bertolli9925f152016-06-27 14:55:37 +00002117void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2118 OMPDistributeParallelForDirective *D) {
2119 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002120 D->setHasCancel(Record.readInt());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002121}
Samuel Antao686c70c2016-05-26 17:30:50 +00002122
Kelvin Li4a39add2016-07-05 05:00:15 +00002123void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2124 OMPDistributeParallelForSimdDirective *D) {
2125 VisitOMPLoopDirective(D);
2126}
2127
Kelvin Li787f3fc2016-07-06 04:45:38 +00002128void ASTStmtReader::VisitOMPDistributeSimdDirective(
2129 OMPDistributeSimdDirective *D) {
2130 VisitOMPLoopDirective(D);
2131}
2132
Kelvin Lia579b912016-07-14 02:54:56 +00002133void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2134 OMPTargetParallelForSimdDirective *D) {
2135 VisitOMPLoopDirective(D);
2136}
2137
Kelvin Li986330c2016-07-20 22:57:10 +00002138void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2139 VisitOMPLoopDirective(D);
2140}
2141
Kelvin Li02532872016-08-05 14:37:37 +00002142void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2143 OMPTeamsDistributeDirective *D) {
2144 VisitOMPLoopDirective(D);
2145}
2146
Kelvin Li4e325f72016-10-25 12:50:55 +00002147void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2148 OMPTeamsDistributeSimdDirective *D) {
2149 VisitOMPLoopDirective(D);
2150}
2151
Kelvin Li579e41c2016-11-30 23:51:03 +00002152void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2153 OMPTeamsDistributeParallelForSimdDirective *D) {
2154 VisitOMPLoopDirective(D);
2155}
2156
Kelvin Li7ade93f2016-12-09 03:24:30 +00002157void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2158 OMPTeamsDistributeParallelForDirective *D) {
2159 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002160 D->setHasCancel(Record.readInt());
Kelvin Li7ade93f2016-12-09 03:24:30 +00002161}
2162
Kelvin Libf594a52016-12-17 05:48:59 +00002163void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2164 VisitStmt(D);
2165 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002166 Record.skipInts(1);
Kelvin Libf594a52016-12-17 05:48:59 +00002167 VisitOMPExecutableDirective(D);
2168}
2169
Kelvin Li83c451e2016-12-25 04:52:54 +00002170void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2171 OMPTargetTeamsDistributeDirective *D) {
2172 VisitOMPLoopDirective(D);
2173}
2174
Kelvin Li80e8f562016-12-29 22:16:30 +00002175void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2176 OMPTargetTeamsDistributeParallelForDirective *D) {
2177 VisitOMPLoopDirective(D);
Alexey Bataev16e79882017-11-22 21:12:03 +00002178 D->setHasCancel(Record.readInt());
Kelvin Li80e8f562016-12-29 22:16:30 +00002179}
2180
Kelvin Li1851df52017-01-03 05:23:48 +00002181void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2182 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2183 VisitOMPLoopDirective(D);
2184}
2185
Kelvin Lida681182017-01-10 18:08:18 +00002186void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2187 OMPTargetTeamsDistributeSimdDirective *D) {
2188 VisitOMPLoopDirective(D);
2189}
2190
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002191//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002192// ASTReader Implementation
2193//===----------------------------------------------------------------------===//
2194
Douglas Gregorde3ef502011-11-30 23:21:26 +00002195Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002196 switch (ReadingKind) {
Richard Smith629ff362013-07-31 00:26:46 +00002197 case Read_None:
2198 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002199 case Read_Decl:
2200 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00002201 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002202 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002203 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002204 }
2205
2206 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002207}
2208
Douglas Gregorde3ef502011-11-30 23:21:26 +00002209Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00002210 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002211}
Chris Lattnere2437f42010-05-09 06:40:08 +00002212
Sebastian Redl2c499f62010-08-18 23:56:43 +00002213Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002214 return cast_or_null<Expr>(ReadSubStmt());
2215}
2216
Chris Lattnerf4262532009-04-27 05:41:06 +00002217// Within the bitstream, expressions are stored in Reverse Polish
2218// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002219// expression they are stored in. Subexpressions are stored from last to first.
2220// To evaluate expressions, we continue reading expressions and placing them on
2221// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00002222// stack. Evaluation terminates when we see a STMT_STOP record, and
2223// the single remaining expression on the stack is our result.
Douglas Gregorde3ef502011-11-30 23:21:26 +00002224Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002225 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00002226 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002227
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002228 // Map of offset to previously deserialized stmt. The offset points
George Burgess IV758cf9d2017-02-14 05:52:57 +00002229 // just after the stmt record.
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002230 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00002231
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002232#ifndef NDEBUG
2233 unsigned PrevNumStmts = StmtStack.size();
2234#endif
2235
David L. Jonesbe1557a2016-12-21 00:17:49 +00002236 ASTRecordReader Record(*this, F);
2237 ASTStmtReader Reader(Record, Cursor);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002238 Stmt::EmptyShell Empty;
2239
2240 while (true) {
Chris Lattner0e6c9402013-01-20 02:38:54 +00002241 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002242
Chris Lattner0e6c9402013-01-20 02:38:54 +00002243 switch (Entry.Kind) {
2244 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2245 case llvm::BitstreamEntry::Error:
2246 Error("malformed block record in AST file");
Craig Toppera13603a2014-05-22 05:54:18 +00002247 return nullptr;
Chris Lattner0e6c9402013-01-20 02:38:54 +00002248 case llvm::BitstreamEntry::EndBlock:
2249 goto Done;
2250 case llvm::BitstreamEntry::Record:
2251 // The interesting case.
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002252 break;
2253 }
2254
Richard Smithdbafb6c2017-06-29 23:23:46 +00002255 ASTContext &Context = getContext();
Craig Toppera13603a2014-05-22 05:54:18 +00002256 Stmt *S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002257 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002258 bool IsStmtReference = false;
David L. Jonesbe1557a2016-12-21 00:17:49 +00002259 switch ((StmtCode)Record.readRecord(Cursor, Entry.ID)) {
Sebastian Redl539c5062010-08-18 23:57:32 +00002260 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002261 Finished = true;
2262 break;
2263
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002264 case STMT_REF_PTR:
2265 IsStmtReference = true;
2266 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2267 "No stmt was recorded for this offset reference!");
David L. Jonesbe1557a2016-12-21 00:17:49 +00002268 S = StmtEntries[Record.readInt()];
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002269 break;
2270
Sebastian Redl539c5062010-08-18 23:57:32 +00002271 case STMT_NULL_PTR:
Craig Toppera13603a2014-05-22 05:54:18 +00002272 S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002273 break;
2274
Sebastian Redl539c5062010-08-18 23:57:32 +00002275 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002276 S = new (Context) NullStmt(Empty);
2277 break;
2278
Sebastian Redl539c5062010-08-18 23:57:32 +00002279 case STMT_COMPOUND:
Benjamin Kramer07420902017-12-24 16:24:20 +00002280 S = CompoundStmt::CreateEmpty(
2281 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002282 break;
2283
Sebastian Redl539c5062010-08-18 23:57:32 +00002284 case STMT_CASE:
Bruno Ricci5b30571752018-10-28 12:30:53 +00002285 S = CaseStmt::CreateEmpty(
2286 Context,
2287 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002288 break;
2289
Sebastian Redl539c5062010-08-18 23:57:32 +00002290 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002291 S = new (Context) DefaultStmt(Empty);
2292 break;
2293
Sebastian Redl539c5062010-08-18 23:57:32 +00002294 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002295 S = new (Context) LabelStmt(Empty);
2296 break;
2297
Richard Smithc202b282012-04-14 00:33:13 +00002298 case STMT_ATTRIBUTED:
Alexander Kornienko20f6fc62012-07-09 10:04:07 +00002299 S = AttributedStmt::CreateEmpty(
2300 Context,
2301 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smithc202b282012-04-14 00:33:13 +00002302 break;
2303
Sebastian Redl539c5062010-08-18 23:57:32 +00002304 case STMT_IF:
Bruno Riccib1cc94b2018-10-27 21:12:20 +00002305 S = IfStmt::CreateEmpty(
2306 Context,
2307 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2308 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2309 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002310 break;
2311
Sebastian Redl539c5062010-08-18 23:57:32 +00002312 case STMT_SWITCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002313 S = new (Context) SwitchStmt(Empty);
2314 break;
2315
Sebastian Redl539c5062010-08-18 23:57:32 +00002316 case STMT_WHILE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002317 S = new (Context) WhileStmt(Empty);
2318 break;
2319
Sebastian Redl539c5062010-08-18 23:57:32 +00002320 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002321 S = new (Context) DoStmt(Empty);
2322 break;
Mike Stump11289f42009-09-09 15:08:12 +00002323
Sebastian Redl539c5062010-08-18 23:57:32 +00002324 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002325 S = new (Context) ForStmt(Empty);
2326 break;
2327
Sebastian Redl539c5062010-08-18 23:57:32 +00002328 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002329 S = new (Context) GotoStmt(Empty);
2330 break;
Mike Stump11289f42009-09-09 15:08:12 +00002331
Sebastian Redl539c5062010-08-18 23:57:32 +00002332 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002333 S = new (Context) IndirectGotoStmt(Empty);
2334 break;
2335
Sebastian Redl539c5062010-08-18 23:57:32 +00002336 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002337 S = new (Context) ContinueStmt(Empty);
2338 break;
2339
Sebastian Redl539c5062010-08-18 23:57:32 +00002340 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002341 S = new (Context) BreakStmt(Empty);
2342 break;
2343
Sebastian Redl539c5062010-08-18 23:57:32 +00002344 case STMT_RETURN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002345 S = new (Context) ReturnStmt(Empty);
2346 break;
2347
Sebastian Redl539c5062010-08-18 23:57:32 +00002348 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002349 S = new (Context) DeclStmt(Empty);
2350 break;
2351
Chad Rosierde70e0e2012-08-25 00:11:56 +00002352 case STMT_GCCASM:
2353 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002354 break;
2355
Chad Rosiere30d4992012-08-24 23:51:02 +00002356 case STMT_MSASM:
2357 S = new (Context) MSAsmStmt(Empty);
2358 break;
2359
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002360 case STMT_CAPTURED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002361 S = CapturedStmt::CreateDeserialized(
2362 Context, Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002363 break;
2364
Sebastian Redl539c5062010-08-18 23:57:32 +00002365 case EXPR_PREDEFINED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002366 S = PredefinedExpr::CreateEmpty(
2367 Context,
2368 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002369 break;
Mike Stump11289f42009-09-09 15:08:12 +00002370
Sebastian Redl539c5062010-08-18 23:57:32 +00002371 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002372 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00002373 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002374 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2375 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnara7945c982012-01-27 09:46:47 +00002376 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002377 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
John McCall113bee02012-03-10 09:33:50 +00002378 Record[ASTStmtReader::NumExprFields + 5] : 0);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002379 break;
Mike Stump11289f42009-09-09 15:08:12 +00002380
Sebastian Redl539c5062010-08-18 23:57:32 +00002381 case EXPR_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002382 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002383 break;
Mike Stump11289f42009-09-09 15:08:12 +00002384
Sebastian Redl539c5062010-08-18 23:57:32 +00002385 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002386 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002387 break;
Mike Stump11289f42009-09-09 15:08:12 +00002388
Sebastian Redl539c5062010-08-18 23:57:32 +00002389 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002390 S = new (Context) ImaginaryLiteral(Empty);
2391 break;
2392
Sebastian Redl539c5062010-08-18 23:57:32 +00002393 case EXPR_STRING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002394 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002395 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002396 break;
2397
Sebastian Redl539c5062010-08-18 23:57:32 +00002398 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002399 S = new (Context) CharacterLiteral(Empty);
2400 break;
2401
Sebastian Redl539c5062010-08-18 23:57:32 +00002402 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002403 S = new (Context) ParenExpr(Empty);
2404 break;
2405
Sebastian Redl539c5062010-08-18 23:57:32 +00002406 case EXPR_PAREN_LIST:
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00002407 S = new (Context) ParenListExpr(Empty);
2408 break;
2409
Sebastian Redl539c5062010-08-18 23:57:32 +00002410 case EXPR_UNARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002411 S = new (Context) UnaryOperator(Empty);
2412 break;
2413
Sebastian Redl539c5062010-08-18 23:57:32 +00002414 case EXPR_OFFSETOF:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002415 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002416 Record[ASTStmtReader::NumExprFields],
2417 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00002418 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002419
Sebastian Redl539c5062010-08-18 23:57:32 +00002420 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00002421 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002422 break;
2423
Sebastian Redl539c5062010-08-18 23:57:32 +00002424 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002425 S = new (Context) ArraySubscriptExpr(Empty);
2426 break;
2427
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002428 case EXPR_OMP_ARRAY_SECTION:
2429 S = new (Context) OMPArraySectionExpr(Empty);
2430 break;
2431
Sebastian Redl539c5062010-08-18 23:57:32 +00002432 case EXPR_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002433 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002434 break;
2435
Sebastian Redl539c5062010-08-18 23:57:32 +00002436 case EXPR_MEMBER: {
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002437 // We load everything here and fully initialize it at creation.
2438 // That way we can use MemberExpr::Create and don't have to duplicate its
2439 // logic with a MemberExpr::CreateEmpty.
2440
David L. Jonesbe1557a2016-12-21 00:17:49 +00002441 assert(Record.getIdx() == 0);
Douglas Gregorea972d32011-02-28 21:54:11 +00002442 NestedNameSpecifierLoc QualifierLoc;
David L. Jonesbe1557a2016-12-21 00:17:49 +00002443 if (Record.readInt()) { // HasQualifier.
David L. Jonesb6a8f022016-12-21 04:34:52 +00002444 QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002445 }
2446
Abramo Bagnara7945c982012-01-27 09:46:47 +00002447 SourceLocation TemplateKWLoc;
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002448 TemplateArgumentListInfo ArgInfo;
David L. Jonesbe1557a2016-12-21 00:17:49 +00002449 bool HasTemplateKWAndArgsInfo = Record.readInt();
Abramo Bagnara7945c982012-01-27 09:46:47 +00002450 if (HasTemplateKWAndArgsInfo) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002451 TemplateKWLoc = Record.readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002452 unsigned NumTemplateArgs = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002453 ArgInfo.setLAngleLoc(Record.readSourceLocation());
2454 ArgInfo.setRAngleLoc(Record.readSourceLocation());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002455 for (unsigned i = 0; i != NumTemplateArgs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002456 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002457 }
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00002458
David L. Jonesbe1557a2016-12-21 00:17:49 +00002459 bool HadMultipleCandidates = Record.readInt();
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00002460
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002461 auto *FoundD = Record.readDeclAs<NamedDecl>();
2462 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002463 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
2464
David L. Jonesbe1557a2016-12-21 00:17:49 +00002465 QualType T = Record.readType();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002466 auto VK = static_cast<ExprValueKind>(Record.readInt());
2467 auto OK = static_cast<ExprObjectKind>(Record.readInt());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002468 Expr *Base = ReadSubExpr();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002469 auto *MemberD = Record.readDeclAs<ValueDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002470 SourceLocation MemberLoc = Record.readSourceLocation();
Yunzhong Gaoeba323a2015-05-01 02:04:32 +00002471 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002472 bool IsArrow = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002473 SourceLocation OperatorLoc = Record.readSourceLocation();
Yunzhong Gaoeba323a2015-05-01 02:04:32 +00002474
2475 S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc,
2476 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
2477 HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T,
2478 VK, OK);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002479 Record.readDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc,
David L. Jonesbe1557a2016-12-21 00:17:49 +00002480 MemberD->getDeclName());
Yunzhong Gaoeba323a2015-05-01 02:04:32 +00002481 if (HadMultipleCandidates)
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00002482 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002483 break;
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002484 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002485
Sebastian Redl539c5062010-08-18 23:57:32 +00002486 case EXPR_BINARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002487 S = new (Context) BinaryOperator(Empty);
2488 break;
2489
Sebastian Redl539c5062010-08-18 23:57:32 +00002490 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002491 S = new (Context) CompoundAssignOperator(Empty);
2492 break;
2493
Sebastian Redl539c5062010-08-18 23:57:32 +00002494 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002495 S = new (Context) ConditionalOperator(Empty);
2496 break;
2497
John McCallc07a0c72011-02-17 10:25:35 +00002498 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2499 S = new (Context) BinaryConditionalOperator(Empty);
2500 break;
2501
Sebastian Redl539c5062010-08-18 23:57:32 +00002502 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002503 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002504 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002505 break;
2506
Sebastian Redl539c5062010-08-18 23:57:32 +00002507 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002508 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002509 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002510 break;
2511
Sebastian Redl539c5062010-08-18 23:57:32 +00002512 case EXPR_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002513 S = new (Context) CompoundLiteralExpr(Empty);
2514 break;
2515
Sebastian Redl539c5062010-08-18 23:57:32 +00002516 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002517 S = new (Context) ExtVectorElementExpr(Empty);
2518 break;
2519
Sebastian Redl539c5062010-08-18 23:57:32 +00002520 case EXPR_INIT_LIST:
Argyrios Kyrtzidis0f05fb92012-11-28 03:56:16 +00002521 S = new (Context) InitListExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002522 break;
2523
Sebastian Redl539c5062010-08-18 23:57:32 +00002524 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002525 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002526 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00002527
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002528 break;
2529
Yunzhong Gaocb779302015-06-10 00:27:52 +00002530 case EXPR_DESIGNATED_INIT_UPDATE:
2531 S = new (Context) DesignatedInitUpdateExpr(Empty);
2532 break;
2533
Sebastian Redl539c5062010-08-18 23:57:32 +00002534 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002535 S = new (Context) ImplicitValueInitExpr(Empty);
2536 break;
2537
Yunzhong Gaocb779302015-06-10 00:27:52 +00002538 case EXPR_NO_INIT:
2539 S = new (Context) NoInitExpr(Empty);
2540 break;
2541
Richard Smith410306b2016-12-12 02:53:20 +00002542 case EXPR_ARRAY_INIT_LOOP:
2543 S = new (Context) ArrayInitLoopExpr(Empty);
2544 break;
2545
2546 case EXPR_ARRAY_INIT_INDEX:
2547 S = new (Context) ArrayInitIndexExpr(Empty);
2548 break;
2549
Sebastian Redl539c5062010-08-18 23:57:32 +00002550 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002551 S = new (Context) VAArgExpr(Empty);
2552 break;
2553
Sebastian Redl539c5062010-08-18 23:57:32 +00002554 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002555 S = new (Context) AddrLabelExpr(Empty);
2556 break;
2557
Sebastian Redl539c5062010-08-18 23:57:32 +00002558 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002559 S = new (Context) StmtExpr(Empty);
2560 break;
2561
Sebastian Redl539c5062010-08-18 23:57:32 +00002562 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002563 S = new (Context) ChooseExpr(Empty);
2564 break;
2565
Sebastian Redl539c5062010-08-18 23:57:32 +00002566 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002567 S = new (Context) GNUNullExpr(Empty);
2568 break;
2569
Sebastian Redl539c5062010-08-18 23:57:32 +00002570 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002571 S = new (Context) ShuffleVectorExpr(Empty);
2572 break;
Mike Stump11289f42009-09-09 15:08:12 +00002573
Hal Finkelc4d7c822013-09-18 03:29:45 +00002574 case EXPR_CONVERT_VECTOR:
2575 S = new (Context) ConvertVectorExpr(Empty);
2576 break;
2577
Sebastian Redl539c5062010-08-18 23:57:32 +00002578 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002579 S = new (Context) BlockExpr(Empty);
2580 break;
2581
Peter Collingbourne91147592011-04-15 00:35:48 +00002582 case EXPR_GENERIC_SELECTION:
2583 S = new (Context) GenericSelectionExpr(Empty);
2584 break;
2585
Sebastian Redl539c5062010-08-18 23:57:32 +00002586 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002587 S = new (Context) ObjCStringLiteral(Empty);
2588 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002589
Patrick Beard0caa3942012-04-19 00:25:12 +00002590 case EXPR_OBJC_BOXED_EXPRESSION:
2591 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremeneke65b0862012-03-06 20:05:56 +00002592 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002593
Ted Kremeneke65b0862012-03-06 20:05:56 +00002594 case EXPR_OBJC_ARRAY_LITERAL:
2595 S = ObjCArrayLiteral::CreateEmpty(Context,
2596 Record[ASTStmtReader::NumExprFields]);
2597 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002598
Ted Kremeneke65b0862012-03-06 20:05:56 +00002599 case EXPR_OBJC_DICTIONARY_LITERAL:
2600 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2601 Record[ASTStmtReader::NumExprFields],
2602 Record[ASTStmtReader::NumExprFields + 1]);
2603 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002604
Sebastian Redl539c5062010-08-18 23:57:32 +00002605 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002606 S = new (Context) ObjCEncodeExpr(Empty);
2607 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002608
Sebastian Redl539c5062010-08-18 23:57:32 +00002609 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002610 S = new (Context) ObjCSelectorExpr(Empty);
2611 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002612
Sebastian Redl539c5062010-08-18 23:57:32 +00002613 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002614 S = new (Context) ObjCProtocolExpr(Empty);
2615 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002616
Sebastian Redl539c5062010-08-18 23:57:32 +00002617 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002618 S = new (Context) ObjCIvarRefExpr(Empty);
2619 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002620
Sebastian Redl539c5062010-08-18 23:57:32 +00002621 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002622 S = new (Context) ObjCPropertyRefExpr(Empty);
2623 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002624
Ted Kremeneke65b0862012-03-06 20:05:56 +00002625 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2626 S = new (Context) ObjCSubscriptRefExpr(Empty);
2627 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002628
Sebastian Redl539c5062010-08-18 23:57:32 +00002629 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00002630 llvm_unreachable("mismatching AST file");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002631
Sebastian Redl539c5062010-08-18 23:57:32 +00002632 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002633 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00002634 Record[ASTStmtReader::NumExprFields],
2635 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002636 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002637
Sebastian Redl539c5062010-08-18 23:57:32 +00002638 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00002639 S = new (Context) ObjCIsaExpr(Empty);
2640 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002641
John McCall31168b02011-06-15 23:02:42 +00002642 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2643 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2644 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002645
John McCall31168b02011-06-15 23:02:42 +00002646 case EXPR_OBJC_BRIDGED_CAST:
2647 S = new (Context) ObjCBridgedCastExpr(Empty);
2648 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002649
Sebastian Redl539c5062010-08-18 23:57:32 +00002650 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002651 S = new (Context) ObjCForCollectionStmt(Empty);
2652 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002653
Sebastian Redl539c5062010-08-18 23:57:32 +00002654 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002655 S = new (Context) ObjCAtCatchStmt(Empty);
2656 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002657
Sebastian Redl539c5062010-08-18 23:57:32 +00002658 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002659 S = new (Context) ObjCAtFinallyStmt(Empty);
2660 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002661
Sebastian Redl539c5062010-08-18 23:57:32 +00002662 case STMT_OBJC_AT_TRY:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002663 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002664 Record[ASTStmtReader::NumStmtFields],
2665 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002666 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002667
Sebastian Redl539c5062010-08-18 23:57:32 +00002668 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002669 S = new (Context) ObjCAtSynchronizedStmt(Empty);
2670 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002671
Sebastian Redl539c5062010-08-18 23:57:32 +00002672 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002673 S = new (Context) ObjCAtThrowStmt(Empty);
2674 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002675
John McCall31168b02011-06-15 23:02:42 +00002676 case STMT_OBJC_AUTORELEASE_POOL:
2677 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2678 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002679
Ted Kremeneke65b0862012-03-06 20:05:56 +00002680 case EXPR_OBJC_BOOL_LITERAL:
2681 S = new (Context) ObjCBoolLiteralExpr(Empty);
2682 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002683
Erik Pilkington29099de2016-07-16 00:35:23 +00002684 case EXPR_OBJC_AVAILABILITY_CHECK:
2685 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
2686 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002687
Nico Weber9b982072014-07-07 00:12:30 +00002688 case STMT_SEH_LEAVE:
2689 S = new (Context) SEHLeaveStmt(Empty);
2690 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002691
John McCallfa194042011-07-15 07:00:14 +00002692 case STMT_SEH_EXCEPT:
2693 S = new (Context) SEHExceptStmt(Empty);
2694 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002695
John McCallfa194042011-07-15 07:00:14 +00002696 case STMT_SEH_FINALLY:
2697 S = new (Context) SEHFinallyStmt(Empty);
2698 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002699
John McCallfa194042011-07-15 07:00:14 +00002700 case STMT_SEH_TRY:
2701 S = new (Context) SEHTryStmt(Empty);
2702 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002703
Sebastian Redl539c5062010-08-18 23:57:32 +00002704 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00002705 S = new (Context) CXXCatchStmt(Empty);
2706 break;
2707
Sebastian Redl539c5062010-08-18 23:57:32 +00002708 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002709 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002710 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00002711 break;
2712
Richard Smith02e85f32011-04-14 22:09:26 +00002713 case STMT_CXX_FOR_RANGE:
2714 S = new (Context) CXXForRangeStmt(Empty);
2715 break;
2716
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00002717 case STMT_MS_DEPENDENT_EXISTS:
2718 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2719 NestedNameSpecifierLoc(),
2720 DeclarationNameInfo(),
Craig Toppera13603a2014-05-22 05:54:18 +00002721 nullptr);
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00002722 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002723
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002724 case STMT_OMP_PARALLEL_DIRECTIVE:
2725 S =
2726 OMPParallelDirective::CreateEmpty(Context,
2727 Record[ASTStmtReader::NumStmtFields],
2728 Empty);
2729 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002730
2731 case STMT_OMP_SIMD_DIRECTIVE: {
2732 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2733 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2734 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
2735 CollapsedNum, Empty);
2736 break;
2737 }
2738
Alexey Bataevf29276e2014-06-18 04:14:57 +00002739 case STMT_OMP_FOR_DIRECTIVE: {
2740 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2741 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2742 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2743 Empty);
2744 break;
2745 }
2746
Alexander Musmanf82886e2014-09-18 05:12:34 +00002747 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
2748 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2749 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2750 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2751 Empty);
2752 break;
2753 }
2754
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002755 case STMT_OMP_SECTIONS_DIRECTIVE:
2756 S = OMPSectionsDirective::CreateEmpty(
2757 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2758 break;
2759
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002760 case STMT_OMP_SECTION_DIRECTIVE:
2761 S = OMPSectionDirective::CreateEmpty(Context, Empty);
2762 break;
2763
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002764 case STMT_OMP_SINGLE_DIRECTIVE:
2765 S = OMPSingleDirective::CreateEmpty(
2766 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2767 break;
2768
Alexander Musman80c22892014-07-17 08:54:58 +00002769 case STMT_OMP_MASTER_DIRECTIVE:
2770 S = OMPMasterDirective::CreateEmpty(Context, Empty);
2771 break;
2772
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002773 case STMT_OMP_CRITICAL_DIRECTIVE:
Alexey Bataev28c75412015-12-15 08:19:24 +00002774 S = OMPCriticalDirective::CreateEmpty(
2775 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002776 break;
2777
Alexey Bataev4acb8592014-07-07 13:01:15 +00002778 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
2779 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2780 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2781 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
2782 CollapsedNum, Empty);
2783 break;
2784 }
2785
Alexander Musmane4e893b2014-09-23 09:33:00 +00002786 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
2787 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2788 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2789 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2790 CollapsedNum, Empty);
2791 break;
2792 }
2793
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002794 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
2795 S = OMPParallelSectionsDirective::CreateEmpty(
2796 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2797 break;
2798
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002799 case STMT_OMP_TASK_DIRECTIVE:
2800 S = OMPTaskDirective::CreateEmpty(
2801 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2802 break;
2803
Alexey Bataev68446b72014-07-18 07:47:19 +00002804 case STMT_OMP_TASKYIELD_DIRECTIVE:
2805 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
2806 break;
2807
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002808 case STMT_OMP_BARRIER_DIRECTIVE:
2809 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
2810 break;
2811
Alexey Bataev2df347a2014-07-18 10:17:07 +00002812 case STMT_OMP_TASKWAIT_DIRECTIVE:
2813 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
2814 break;
2815
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002816 case STMT_OMP_TASKGROUP_DIRECTIVE:
Alexey Bataev169d96a2017-07-18 20:17:46 +00002817 S = OMPTaskgroupDirective::CreateEmpty(
2818 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002819 break;
2820
Alexey Bataev6125da92014-07-21 11:26:11 +00002821 case STMT_OMP_FLUSH_DIRECTIVE:
2822 S = OMPFlushDirective::CreateEmpty(
2823 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2824 break;
2825
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002826 case STMT_OMP_ORDERED_DIRECTIVE:
Alexey Bataev346265e2015-09-25 10:37:12 +00002827 S = OMPOrderedDirective::CreateEmpty(
2828 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002829 break;
2830
Alexey Bataev0162e452014-07-22 10:10:35 +00002831 case STMT_OMP_ATOMIC_DIRECTIVE:
2832 S = OMPAtomicDirective::CreateEmpty(
2833 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2834 break;
2835
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002836 case STMT_OMP_TARGET_DIRECTIVE:
2837 S = OMPTargetDirective::CreateEmpty(
2838 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2839 break;
2840
Michael Wong65f367f2015-07-21 13:44:28 +00002841 case STMT_OMP_TARGET_DATA_DIRECTIVE:
2842 S = OMPTargetDataDirective::CreateEmpty(
2843 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2844 break;
2845
Samuel Antaodf67fc42016-01-19 19:15:56 +00002846 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
2847 S = OMPTargetEnterDataDirective::CreateEmpty(
2848 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2849 break;
2850
Samuel Antao72590762016-01-19 20:04:50 +00002851 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
2852 S = OMPTargetExitDataDirective::CreateEmpty(
2853 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2854 break;
2855
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002856 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
2857 S = OMPTargetParallelDirective::CreateEmpty(
2858 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2859 break;
2860
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002861 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
2862 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2863 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2864 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
2865 CollapsedNum, Empty);
2866 break;
2867 }
2868
Samuel Antao686c70c2016-05-26 17:30:50 +00002869 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
2870 S = OMPTargetUpdateDirective::CreateEmpty(
2871 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2872 break;
2873
Alexey Bataev13314bf2014-10-09 04:18:56 +00002874 case STMT_OMP_TEAMS_DIRECTIVE:
2875 S = OMPTeamsDirective::CreateEmpty(
2876 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2877 break;
2878
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002879 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
2880 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
2881 break;
2882
Alexey Bataev80909872015-07-02 11:25:17 +00002883 case STMT_OMP_CANCEL_DIRECTIVE:
Alexey Bataev87933c72015-09-18 08:07:34 +00002884 S = OMPCancelDirective::CreateEmpty(
2885 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev80909872015-07-02 11:25:17 +00002886 break;
2887
Alexey Bataev49f6e782015-12-01 04:18:41 +00002888 case STMT_OMP_TASKLOOP_DIRECTIVE: {
2889 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2890 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2891 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2892 Empty);
2893 break;
2894 }
2895
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002896 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
2897 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2898 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2899 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
2900 CollapsedNum, Empty);
2901 break;
2902 }
2903
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002904 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
2905 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2906 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2907 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2908 Empty);
2909 break;
2910 }
2911
Carlo Bertolli9925f152016-06-27 14:55:37 +00002912 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
2913 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2914 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2915 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
2916 CollapsedNum, Empty);
2917 break;
2918 }
2919
Kelvin Li4a39add2016-07-05 05:00:15 +00002920 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
2921 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2922 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2923 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2924 CollapsedNum,
2925 Empty);
2926 break;
2927 }
2928
Kelvin Li787f3fc2016-07-06 04:45:38 +00002929 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
2930 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2931 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2932 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
2933 CollapsedNum, Empty);
2934 break;
2935 }
2936
Kelvin Lia579b912016-07-14 02:54:56 +00002937 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
2938 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2939 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2940 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2941 CollapsedNum, Empty);
2942 break;
2943 }
2944
Kelvin Li986330c2016-07-20 22:57:10 +00002945 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
2946 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2947 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2948 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2949 Empty);
2950 break;
2951 }
2952
Kelvin Li83c451e2016-12-25 04:52:54 +00002953 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
Kelvin Li02532872016-08-05 14:37:37 +00002954 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2955 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2956 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
2957 CollapsedNum, Empty);
2958 break;
2959 }
2960
Kelvin Li4e325f72016-10-25 12:50:55 +00002961 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
2962 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2963 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2964 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
2965 CollapsedNum, Empty);
2966 break;
2967 }
2968
Kelvin Li579e41c2016-11-30 23:51:03 +00002969 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
2970 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2971 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2972 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
2973 Context, NumClauses, CollapsedNum, Empty);
2974 break;
2975 }
2976
Kelvin Li7ade93f2016-12-09 03:24:30 +00002977 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
2978 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2979 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2980 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
2981 Context, NumClauses, CollapsedNum, Empty);
2982 break;
2983 }
2984
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002985 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
Kelvin Libf594a52016-12-17 05:48:59 +00002986 S = OMPTargetTeamsDirective::CreateEmpty(
2987 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2988 break;
Kelvin Li83c451e2016-12-25 04:52:54 +00002989
2990 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
2991 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2992 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2993 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
2994 CollapsedNum, Empty);
2995 break;
2996 }
2997
Kelvin Li80e8f562016-12-29 22:16:30 +00002998 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
2999 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3000 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3001 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3002 Context, NumClauses, CollapsedNum, Empty);
3003 break;
3004 }
3005
Kelvin Li1851df52017-01-03 05:23:48 +00003006 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3007 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3008 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3009 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3010 Context, NumClauses, CollapsedNum, Empty);
3011 break;
3012 }
3013
Kelvin Lida681182017-01-10 18:08:18 +00003014 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3015 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3016 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3017 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3018 Context, NumClauses, CollapsedNum, Empty);
3019 break;
3020 }
3021
Sebastian Redl539c5062010-08-18 23:57:32 +00003022 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003023 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00003024 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003025
Sebastian Redl539c5062010-08-18 23:57:32 +00003026 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003027 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003028 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003029
Sebastian Redl539c5062010-08-18 23:57:32 +00003030 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003031 S = new (Context) CXXConstructExpr(Empty);
3032 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003033
Richard Smith5179eb72016-06-28 19:03:57 +00003034 case EXPR_CXX_INHERITED_CTOR_INIT:
3035 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3036 break;
3037
Sebastian Redl539c5062010-08-18 23:57:32 +00003038 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003039 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00003040 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003041
Sebastian Redl539c5062010-08-18 23:57:32 +00003042 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003043 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003044 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003045 break;
3046
Sebastian Redl539c5062010-08-18 23:57:32 +00003047 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003048 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003049 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003050 break;
3051
Sebastian Redl539c5062010-08-18 23:57:32 +00003052 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003053 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003054 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003055 break;
3056
Sebastian Redl539c5062010-08-18 23:57:32 +00003057 case EXPR_CXX_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003058 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00003059 break;
3060
Sebastian Redl539c5062010-08-18 23:57:32 +00003061 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003062 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003063 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003064 break;
3065
Richard Smithc67fdd42012-03-07 08:35:16 +00003066 case EXPR_USER_DEFINED_LITERAL:
3067 S = new (Context) UserDefinedLiteral(Context, Empty);
3068 break;
3069
Richard Smithcc1b96d2013-06-12 22:31:48 +00003070 case EXPR_CXX_STD_INITIALIZER_LIST:
3071 S = new (Context) CXXStdInitializerListExpr(Empty);
3072 break;
3073
Sebastian Redl539c5062010-08-18 23:57:32 +00003074 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003075 S = new (Context) CXXBoolLiteralExpr(Empty);
3076 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003077
Sebastian Redl539c5062010-08-18 23:57:32 +00003078 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003079 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3080 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003081
Sebastian Redl539c5062010-08-18 23:57:32 +00003082 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003083 S = new (Context) CXXTypeidExpr(Empty, true);
3084 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003085
Sebastian Redl539c5062010-08-18 23:57:32 +00003086 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003087 S = new (Context) CXXTypeidExpr(Empty, false);
3088 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003089
Francois Pichet9f4f2072010-09-08 12:20:18 +00003090 case EXPR_CXX_UUIDOF_EXPR:
3091 S = new (Context) CXXUuidofExpr(Empty, true);
3092 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003093
John McCall5e77d762013-04-16 07:28:30 +00003094 case EXPR_CXX_PROPERTY_REF_EXPR:
3095 S = new (Context) MSPropertyRefExpr(Empty);
3096 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003097
Alexey Bataevf7630272015-11-25 12:01:00 +00003098 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3099 S = new (Context) MSPropertySubscriptExpr(Empty);
3100 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003101
Francois Pichet9f4f2072010-09-08 12:20:18 +00003102 case EXPR_CXX_UUIDOF_TYPE:
3103 S = new (Context) CXXUuidofExpr(Empty, false);
3104 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003105
Sebastian Redl539c5062010-08-18 23:57:32 +00003106 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00003107 S = new (Context) CXXThisExpr(Empty);
3108 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003109
Sebastian Redl539c5062010-08-18 23:57:32 +00003110 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00003111 S = new (Context) CXXThrowExpr(Empty);
3112 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003113
John McCall32791cc2016-01-06 22:34:54 +00003114 case EXPR_CXX_DEFAULT_ARG:
3115 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00003116 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003117
Richard Smith852c9db2013-04-20 22:23:05 +00003118 case EXPR_CXX_DEFAULT_INIT:
3119 S = new (Context) CXXDefaultInitExpr(Empty);
3120 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003121
Sebastian Redl539c5062010-08-18 23:57:32 +00003122 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00003123 S = new (Context) CXXBindTemporaryExpr(Empty);
3124 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003125
Sebastian Redl539c5062010-08-18 23:57:32 +00003126 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00003127 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003128 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003129
Sebastian Redl539c5062010-08-18 23:57:32 +00003130 case EXPR_CXX_NEW:
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003131 S = new (Context) CXXNewExpr(Empty);
3132 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003133
Sebastian Redl539c5062010-08-18 23:57:32 +00003134 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00003135 S = new (Context) CXXDeleteExpr(Empty);
3136 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003137
Sebastian Redl539c5062010-08-18 23:57:32 +00003138 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00003139 S = new (Context) CXXPseudoDestructorExpr(Empty);
3140 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003141
John McCall5d413782010-12-06 08:20:24 +00003142 case EXPR_EXPR_WITH_CLEANUPS:
John McCall28fc7092011-11-10 05:35:25 +00003143 S = ExprWithCleanups::Create(Context, Empty,
3144 Record[ASTStmtReader::NumExprFields]);
Chris Lattnercba86142010-05-10 00:25:06 +00003145 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003146
Sebastian Redl539c5062010-08-18 23:57:32 +00003147 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003148 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003149 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003150 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003151 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003152 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003153 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003154
Sebastian Redl539c5062010-08-18 23:57:32 +00003155 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003156 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003157 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003158 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003159 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003160 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00003161 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003162
Sebastian Redl539c5062010-08-18 23:57:32 +00003163 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003164 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003165 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00003166 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003167
Sebastian Redl539c5062010-08-18 23:57:32 +00003168 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003169 S = UnresolvedMemberExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003170 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003171 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003172 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003173 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003174 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003175
Sebastian Redl539c5062010-08-18 23:57:32 +00003176 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003177 S = UnresolvedLookupExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003178 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003179 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003180 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003181 : 0);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00003182 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003183
Douglas Gregor29c42f22012-02-24 07:38:34 +00003184 case EXPR_TYPE_TRAIT:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003185 S = TypeTraitExpr::CreateDeserialized(Context,
Douglas Gregor29c42f22012-02-24 07:38:34 +00003186 Record[ASTStmtReader::NumExprFields]);
3187 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003188
John Wiegley6242b6a2011-04-28 00:16:57 +00003189 case EXPR_ARRAY_TYPE_TRAIT:
3190 S = new (Context) ArrayTypeTraitExpr(Empty);
3191 break;
3192
John Wiegleyf9f65842011-04-25 06:54:41 +00003193 case EXPR_CXX_EXPRESSION_TRAIT:
3194 S = new (Context) ExpressionTraitExpr(Empty);
3195 break;
3196
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003197 case EXPR_CXX_NOEXCEPT:
3198 S = new (Context) CXXNoexceptExpr(Empty);
3199 break;
John McCall8d69a212010-11-15 23:31:06 +00003200
Douglas Gregore8e9dd62011-01-03 17:17:50 +00003201 case EXPR_PACK_EXPANSION:
3202 S = new (Context) PackExpansionExpr(Empty);
3203 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003204
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003205 case EXPR_SIZEOF_PACK:
Richard Smithd784e682015-09-23 21:41:42 +00003206 S = SizeOfPackExpr::CreateDeserialized(
3207 Context,
3208 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003209 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003210
John McCallfa194042011-07-15 07:00:14 +00003211 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3212 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3213 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003214
Douglas Gregorcdbc5392011-01-15 01:15:58 +00003215 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3216 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3217 break;
Richard Smithb15fe3a2012-09-12 00:56:43 +00003218
3219 case EXPR_FUNCTION_PARM_PACK:
3220 S = FunctionParmPackExpr::CreateEmpty(Context,
3221 Record[ASTStmtReader::NumExprFields]);
3222 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003223
Douglas Gregorfe314812011-06-21 17:03:29 +00003224 case EXPR_MATERIALIZE_TEMPORARY:
3225 S = new (Context) MaterializeTemporaryExpr(Empty);
3226 break;
Richard Smith0f0af192014-11-08 05:07:16 +00003227
3228 case EXPR_CXX_FOLD:
3229 S = new (Context) CXXFoldExpr(Empty);
3230 break;
3231
Argyrios Kyrtzidisb2b07952011-12-03 03:49:52 +00003232 case EXPR_OPAQUE_VALUE:
3233 S = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00003234 break;
Peter Collingbourne41f85462011-02-09 21:07:24 +00003235
3236 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003237 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00003238 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003239
Tanya Lattner55808c12011-06-04 00:47:47 +00003240 case EXPR_ASTYPE:
3241 S = new (Context) AsTypeExpr(Empty);
3242 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003243
John McCallfe96e0b2011-11-06 09:01:30 +00003244 case EXPR_PSEUDO_OBJECT: {
3245 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3246 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3247 break;
3248 }
3249
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003250 case EXPR_ATOMIC:
3251 S = new (Context) AtomicExpr(Empty);
3252 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003253
Douglas Gregor99ae8062012-02-14 17:54:36 +00003254 case EXPR_LAMBDA: {
3255 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
Richard Smith30e304e2016-12-14 00:03:17 +00003256 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
Douglas Gregor99ae8062012-02-14 17:54:36 +00003257 break;
3258 }
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +00003259
3260 case STMT_COROUTINE_BODY: {
3261 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3262 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3263 break;
3264 }
3265
3266 case STMT_CORETURN:
3267 S = new (Context) CoreturnStmt(Empty);
3268 break;
3269
3270 case EXPR_COAWAIT:
3271 S = new (Context) CoawaitExpr(Empty);
3272 break;
3273
3274 case EXPR_COYIELD:
3275 S = new (Context) CoyieldExpr(Empty);
3276 break;
3277
3278 case EXPR_DEPENDENT_COAWAIT:
3279 S = new (Context) DependentCoawaitExpr(Empty);
3280 break;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003281 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003282
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003283 // We hit a STMT_STOP, so we're done with this expression.
3284 if (Finished)
3285 break;
3286
3287 ++NumStatementsRead;
3288
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003289 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003290 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003291 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3292 }
3293
David L. Jonesbe1557a2016-12-21 00:17:49 +00003294 assert(Record.getIdx() == Record.size() &&
3295 "Invalid deserialization of statement");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003296 StmtStack.push_back(S);
3297 }
Chris Lattner0e6c9402013-01-20 02:38:54 +00003298Done:
Alp Toker028ed912013-12-06 17:56:43 +00003299 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003300 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003301 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003302}