blob: f7f3f05cf3dba9ab59edc127d43bf68eae5a8333 [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);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000180 S->setLHS(Record.readSubExpr());
181 S->setRHS(Record.readSubExpr());
182 S->setSubStmt(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000183 S->setEllipsisLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000184}
185
Sebastian Redl70c751d2010-08-18 23:56:52 +0000186void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000187 VisitSwitchCase(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000188 S->setSubStmt(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000189}
190
Sebastian Redl70c751d2010-08-18 23:56:52 +0000191void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000192 VisitStmt(S);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000193 auto *LD = ReadDeclAs<LabelDecl>();
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000194 LD->setStmt(S);
195 S->setDecl(LD);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000196 S->setSubStmt(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000197 S->setIdentLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000198}
199
Richard Smithc202b282012-04-14 00:33:13 +0000200void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
201 VisitStmt(S);
Bruno Ricci41d11c02018-10-27 18:43:27 +0000202 // NumAttrs in AttributedStmt is set when creating an empty
203 // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
204 // to allocate the right amount of space for the trailing Attr *.
David L. Jonesbe1557a2016-12-21 00:17:49 +0000205 uint64_t NumAttrs = Record.readInt();
Richard Smithc202b282012-04-14 00:33:13 +0000206 AttrVec Attrs;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000207 Record.readAttributes(Attrs);
Matt Beaumont-Gayad0bb8e2012-07-09 18:55:31 +0000208 (void)NumAttrs;
Bruno Ricci41d11c02018-10-27 18:43:27 +0000209 assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
Alexander Kornienko20f6fc62012-07-09 10:04:07 +0000210 assert(NumAttrs == Attrs.size());
Aaron Ballmanf3d9b092014-05-13 14:55:01 +0000211 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000212 S->SubStmt = Record.readSubStmt();
Bruno Ricci41d11c02018-10-27 18:43:27 +0000213 S->AttributedStmtBits.AttrLoc = ReadSourceLocation();
Richard Smithc202b282012-04-14 00:33:13 +0000214}
215
Sebastian Redl70c751d2010-08-18 23:56:52 +0000216void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000217 VisitStmt(S);
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000218
David L. Jonesbe1557a2016-12-21 00:17:49 +0000219 S->setConstexpr(Record.readInt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000220 bool HasElse = Record.readInt();
221 bool HasVar = Record.readInt();
222 bool HasInit = Record.readInt();
223
David L. Jonesb6a8f022016-12-21 04:34:52 +0000224 S->setCond(Record.readSubExpr());
225 S->setThen(Record.readSubStmt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000226 if (HasElse)
227 S->setElse(Record.readSubStmt());
228 if (HasVar)
229 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
230 if (HasInit)
231 S->setInit(Record.readSubStmt());
232
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000233 S->setIfLoc(ReadSourceLocation());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000234 if (HasElse)
235 S->setElseLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000236}
237
Sebastian Redl70c751d2010-08-18 23:56:52 +0000238void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000239 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000240 S->setInit(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000241 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000242 S->setCond(Record.readSubExpr());
243 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000244 S->setSwitchLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000245 if (Record.readInt())
Ted Kremenekc42f3452010-09-09 00:05:53 +0000246 S->setAllEnumCasesCovered();
247
Craig Toppera13603a2014-05-22 05:54:18 +0000248 SwitchCase *PrevSC = nullptr;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000249 for (auto E = Record.size(); Record.getIdx() != E; ) {
250 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000251 if (PrevSC)
252 PrevSC->setNextSwitchCase(SC);
253 else
254 S->setSwitchCaseList(SC);
Mike Stump11289f42009-09-09 15:08:12 +0000255
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000256 PrevSC = SC;
257 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000258}
259
Sebastian Redl70c751d2010-08-18 23:56:52 +0000260void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000261 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000262 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
Douglas Gregor7fb09192011-07-21 22:35:25 +0000263
David L. Jonesb6a8f022016-12-21 04:34:52 +0000264 S->setCond(Record.readSubExpr());
265 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000266 S->setWhileLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000267}
268
Sebastian Redl70c751d2010-08-18 23:56:52 +0000269void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000270 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000271 S->setCond(Record.readSubExpr());
272 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000273 S->setDoLoc(ReadSourceLocation());
274 S->setWhileLoc(ReadSourceLocation());
275 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000276}
277
Sebastian Redl70c751d2010-08-18 23:56:52 +0000278void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000279 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000280 S->setInit(Record.readSubStmt());
281 S->setCond(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000282 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000283 S->setInc(Record.readSubExpr());
284 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000285 S->setForLoc(ReadSourceLocation());
286 S->setLParenLoc(ReadSourceLocation());
287 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000288}
289
Sebastian Redl70c751d2010-08-18 23:56:52 +0000290void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000291 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000292 S->setLabel(ReadDeclAs<LabelDecl>());
293 S->setGotoLoc(ReadSourceLocation());
294 S->setLabelLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000295}
296
Sebastian Redl70c751d2010-08-18 23:56:52 +0000297void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000298 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000299 S->setGotoLoc(ReadSourceLocation());
300 S->setStarLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000301 S->setTarget(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000302}
303
Sebastian Redl70c751d2010-08-18 23:56:52 +0000304void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000305 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000306 S->setContinueLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000307}
308
Sebastian Redl70c751d2010-08-18 23:56:52 +0000309void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000310 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000311 S->setBreakLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000312}
313
Sebastian Redl70c751d2010-08-18 23:56:52 +0000314void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000315 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000316 S->setRetValue(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000317 S->setReturnLoc(ReadSourceLocation());
318 S->setNRVOCandidate(ReadDeclAs<VarDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000319}
320
Sebastian Redl70c751d2010-08-18 23:56:52 +0000321void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000322 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000323 S->setStartLoc(ReadSourceLocation());
324 S->setEndLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000325
David L. Jonesbe1557a2016-12-21 00:17:49 +0000326 if (Record.size() - Record.getIdx() == 1) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000327 // Single declaration
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000328 S->setDeclGroup(DeclGroupRef(ReadDecl()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000329 } else {
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000330 SmallVector<Decl *, 16> Decls;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000331 int N = Record.size() - Record.getIdx();
332 Decls.reserve(N);
333 for (int I = 0; I < N; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000334 Decls.push_back(ReadDecl());
335 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
Douglas Gregor038c3382009-05-22 22:45:36 +0000336 Decls.data(),
337 Decls.size())));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000338 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000339}
340
John McCallf413f5e2013-05-03 00:10:13 +0000341void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000342 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000343 S->NumOutputs = Record.readInt();
344 S->NumInputs = Record.readInt();
345 S->NumClobbers = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000346 S->setAsmLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000347 S->setVolatile(Record.readInt());
348 S->setSimple(Record.readInt());
John McCallf413f5e2013-05-03 00:10:13 +0000349}
Mike Stump11289f42009-09-09 15:08:12 +0000350
John McCallf413f5e2013-05-03 00:10:13 +0000351void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
352 VisitAsmStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000353 S->setRParenLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000354 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000355
John McCallf413f5e2013-05-03 00:10:13 +0000356 unsigned NumOutputs = S->getNumOutputs();
357 unsigned NumInputs = S->getNumInputs();
358 unsigned NumClobbers = S->getNumClobbers();
359
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000360 // Outputs and inputs
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000361 SmallVector<IdentifierInfo *, 16> Names;
362 SmallVector<StringLiteral*, 16> Constraints;
363 SmallVector<Stmt*, 16> Exprs;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000364 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000365 Names.push_back(Record.getIdentifierInfo());
366 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
367 Exprs.push_back(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000368 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000369
370 // Constraints
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000371 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000372 for (unsigned I = 0; I != NumClobbers; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000373 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000374
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000375 S->setOutputsAndInputsAndClobbers(Record.getContext(),
376 Names.data(), Constraints.data(),
377 Exprs.data(), NumOutputs, NumInputs,
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000378 Clobbers.data(), NumClobbers);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000379}
380
Chad Rosier32503022012-06-11 20:47:18 +0000381void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
John McCallf413f5e2013-05-03 00:10:13 +0000382 VisitAsmStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000383 S->LBraceLoc = ReadSourceLocation();
384 S->EndLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000385 S->NumAsmToks = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000386 std::string AsmStr = ReadString();
John McCallf413f5e2013-05-03 00:10:13 +0000387
388 // Read the tokens.
389 SmallVector<Token, 16> AsmToks;
390 AsmToks.reserve(S->NumAsmToks);
391 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000392 AsmToks.push_back(Record.readToken());
John McCallf413f5e2013-05-03 00:10:13 +0000393 }
394
395 // The calls to reserve() for the FooData vectors are mandatory to
396 // prevent dead StringRefs in the Foo vectors.
397
398 // Read the clobbers.
399 SmallVector<std::string, 16> ClobbersData;
400 SmallVector<StringRef, 16> Clobbers;
401 ClobbersData.reserve(S->NumClobbers);
402 Clobbers.reserve(S->NumClobbers);
403 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000404 ClobbersData.push_back(ReadString());
John McCallf413f5e2013-05-03 00:10:13 +0000405 Clobbers.push_back(ClobbersData.back());
406 }
407
408 // Read the operands.
409 unsigned NumOperands = S->NumOutputs + S->NumInputs;
410 SmallVector<Expr*, 16> Exprs;
411 SmallVector<std::string, 16> ConstraintsData;
412 SmallVector<StringRef, 16> Constraints;
413 Exprs.reserve(NumOperands);
414 ConstraintsData.reserve(NumOperands);
415 Constraints.reserve(NumOperands);
416 for (unsigned i = 0; i != NumOperands; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000417 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000418 ConstraintsData.push_back(ReadString());
John McCallf413f5e2013-05-03 00:10:13 +0000419 Constraints.push_back(ConstraintsData.back());
420 }
421
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000422 S->initialize(Record.getContext(), AsmStr, AsmToks,
John McCallf413f5e2013-05-03 00:10:13 +0000423 Constraints, Exprs, Clobbers);
Chad Rosier32503022012-06-11 20:47:18 +0000424}
425
Richard Smith9f690bd2015-10-27 06:02:45 +0000426void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000427 VisitStmt(S);
428 assert(Record.peekInt() == S->NumParams);
429 Record.skipInts(1);
430 auto *StoredStmts = S->getStoredStmts();
431 for (unsigned i = 0;
432 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
433 StoredStmts[i] = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000434}
435
436void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000437 VisitStmt(S);
438 S->CoreturnLoc = Record.readSourceLocation();
439 for (auto &SubStmt: S->SubStmts)
440 SubStmt = Record.readSubStmt();
441 S->IsImplicit = Record.readInt() != 0;
Richard Smith9f690bd2015-10-27 06:02:45 +0000442}
443
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000444void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
445 VisitExpr(E);
446 E->KeywordLoc = ReadSourceLocation();
447 for (auto &SubExpr: E->SubExprs)
448 SubExpr = Record.readSubStmt();
449 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
450 E->setIsImplicit(Record.readInt() != 0);
Richard Smith9f690bd2015-10-27 06:02:45 +0000451}
452
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000453void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
454 VisitExpr(E);
455 E->KeywordLoc = ReadSourceLocation();
456 for (auto &SubExpr: E->SubExprs)
457 SubExpr = Record.readSubStmt();
458 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
Eric Fiselier20f25cb2017-03-06 23:38:15 +0000459}
460
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000461void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
462 VisitExpr(E);
463 E->KeywordLoc = ReadSourceLocation();
464 for (auto &SubExpr: E->SubExprs)
465 SubExpr = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000466}
467
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000468void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
Ben Langmuirce914fc2013-05-03 19:20:19 +0000469 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000470 Record.skipInts(1);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000471 S->setCapturedDecl(ReadDeclAs<CapturedDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000472 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000473 S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000474
475 // Capture inits
476 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
477 E = S->capture_init_end();
478 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000479 *I = Record.readSubExpr();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000480
481 // Body
David L. Jonesb6a8f022016-12-21 04:34:52 +0000482 S->setCapturedStmt(Record.readSubStmt());
Wei Pan17fbf6e2013-05-04 03:59:06 +0000483 S->getCapturedDecl()->setBody(S->getCapturedStmt());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000484
485 // Captures
Aaron Ballmanc656303a2014-03-14 18:08:33 +0000486 for (auto &I : S->captures()) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000487 I.VarAndKind.setPointer(ReadDeclAs<VarDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000488 I.VarAndKind.setInt(
489 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000490 I.Loc = ReadSourceLocation();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000491 }
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000492}
493
Sebastian Redl70c751d2010-08-18 23:56:52 +0000494void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000495 VisitStmt(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000496 E->setType(Record.readType());
497 E->setTypeDependent(Record.readInt());
498 E->setValueDependent(Record.readInt());
499 E->setInstantiationDependent(Record.readInt());
500 E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
501 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
502 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
503 assert(Record.getIdx() == NumExprFields &&
504 "Incorrect expression field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000505}
506
Sebastian Redl70c751d2010-08-18 23:56:52 +0000507void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000508 VisitExpr(E);
Bruno Ricci17ff0262018-10-27 19:21:19 +0000509 bool HasFunctionName = Record.readInt();
510 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
511 E->PredefinedExprBits.Kind = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000512 E->setLocation(ReadSourceLocation());
Bruno Ricci17ff0262018-10-27 19:21:19 +0000513 if (HasFunctionName)
514 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000515}
516
Sebastian Redl70c751d2010-08-18 23:56:52 +0000517void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000518 VisitExpr(E);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000519
David L. Jonesbe1557a2016-12-21 00:17:49 +0000520 E->DeclRefExprBits.HasQualifier = Record.readInt();
521 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
522 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
523 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
524 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000525 unsigned NumTemplateArgs = 0;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000526 if (E->hasTemplateKWAndArgsInfo())
David L. Jonesbe1557a2016-12-21 00:17:49 +0000527 NumTemplateArgs = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000528
Chandler Carruth0e439962011-05-01 21:29:53 +0000529 if (E->hasQualifier())
James Y Knighte7d82282015-12-29 18:15:14 +0000530 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
David L. Jonesb6a8f022016-12-21 04:34:52 +0000531 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000532
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000533 if (E->hasFoundDecl())
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000534 *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000535
Abramo Bagnara7945c982012-01-27 09:46:47 +0000536 if (E->hasTemplateKWAndArgsInfo())
James Y Knighte7d82282015-12-29 18:15:14 +0000537 ReadTemplateKWAndArgsInfo(
538 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
539 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000540
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000541 E->setDecl(ReadDeclAs<ValueDecl>());
542 E->setLocation(ReadSourceLocation());
543 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000544}
545
Sebastian Redl70c751d2010-08-18 23:56:52 +0000546void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000547 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000548 E->setLocation(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000549 E->setValue(Record.getContext(), Record.readAPInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000550}
551
Leonard Chandb01c3a2018-06-20 17:19:40 +0000552void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
553 VisitExpr(E);
554 E->setLocation(ReadSourceLocation());
555 E->setValue(Record.getContext(), Record.readAPInt());
556}
557
Sebastian Redl70c751d2010-08-18 23:56:52 +0000558void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000559 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000560 E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record.readInt()));
561 E->setExact(Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000562 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000563 E->setLocation(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000564}
565
Sebastian Redl70c751d2010-08-18 23:56:52 +0000566void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000567 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000568 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000569}
570
Sebastian Redl70c751d2010-08-18 23:56:52 +0000571void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000572 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000573 unsigned Len = Record.readInt();
574 assert(Record.peekInt() == E->getNumConcatenated() &&
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000575 "Wrong number of concatenated tokens!");
David L. Jonesbe1557a2016-12-21 00:17:49 +0000576 Record.skipInts(1);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000577 auto kind = static_cast<StringLiteral::StringKind>(Record.readInt());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000578 bool isPascal = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000579
Mike Stump11289f42009-09-09 15:08:12 +0000580 // Read string data
David L. Jonesbe1557a2016-12-21 00:17:49 +0000581 auto B = &Record.peekInt();
582 SmallString<16> Str(B, B + Len);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000583 E->setString(Record.getContext(), Str, kind, isPascal);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000584 Record.skipInts(Len);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000585
586 // Read source locations
587 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000588 E->setStrTokenLoc(I, ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000589}
590
Sebastian Redl70c751d2010-08-18 23:56:52 +0000591void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000592 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000593 E->setValue(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000594 E->setLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000595 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000596}
597
Sebastian Redl70c751d2010-08-18 23:56:52 +0000598void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000599 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000600 E->setLParen(ReadSourceLocation());
601 E->setRParen(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000602 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000603}
604
Sebastian Redl70c751d2010-08-18 23:56:52 +0000605void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000606 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000607 unsigned NumExprs = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000608 E->Exprs = new (Record.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000609 for (unsigned i = 0; i != NumExprs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000610 E->Exprs[i] = Record.readSubStmt();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000611 E->NumExprs = NumExprs;
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000612 E->LParenLoc = ReadSourceLocation();
613 E->RParenLoc = ReadSourceLocation();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000614}
615
Sebastian Redl70c751d2010-08-18 23:56:52 +0000616void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000617 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000618 E->setSubExpr(Record.readSubExpr());
619 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
620 E->setOperatorLoc(ReadSourceLocation());
621 E->setCanOverflow(Record.readInt());
622}
623
624void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000625 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000626 assert(E->getNumComponents() == Record.peekInt());
627 Record.skipInts(1);
628 assert(E->getNumExpressions() == Record.peekInt());
629 Record.skipInts(1);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000630 E->setOperatorLoc(ReadSourceLocation());
631 E->setRParenLoc(ReadSourceLocation());
632 E->setTypeSourceInfo(GetTypeSourceInfo());
Douglas Gregor882211c2010-04-28 22:16:22 +0000633 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000634 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000635 SourceLocation Start = ReadSourceLocation();
636 SourceLocation End = ReadSourceLocation();
Douglas Gregor882211c2010-04-28 22:16:22 +0000637 switch (Kind) {
James Y Knight7281c352015-12-29 22:31:18 +0000638 case OffsetOfNode::Array:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000639 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000640 break;
641
James Y Knight7281c352015-12-29 22:31:18 +0000642 case OffsetOfNode::Field:
643 E->setComponent(
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000644 I, OffsetOfNode(Start, ReadDeclAs<FieldDecl>(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000645 break;
James Y Knight7281c352015-12-29 22:31:18 +0000646
647 case OffsetOfNode::Identifier:
648 E->setComponent(
649 I,
David L. Jonesb6a8f022016-12-21 04:34:52 +0000650 OffsetOfNode(Start, Record.getIdentifierInfo(), End));
James Y Knight7281c352015-12-29 22:31:18 +0000651 break;
652
653 case OffsetOfNode::Base: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000654 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000655 *Base = Record.readCXXBaseSpecifier();
James Y Knight7281c352015-12-29 22:31:18 +0000656 E->setComponent(I, OffsetOfNode(Base));
Douglas Gregord1702062010-04-29 00:18:15 +0000657 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000658 }
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000659 }
Douglas Gregor882211c2010-04-28 22:16:22 +0000660 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000661
Douglas Gregor882211c2010-04-28 22:16:22 +0000662 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000663 E->setIndexExpr(I, Record.readSubExpr());
Douglas Gregor882211c2010-04-28 22:16:22 +0000664}
665
Peter Collingbournee190dee2011-03-11 19:24:49 +0000666void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000667 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000668 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
669 if (Record.peekInt() == 0) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000670 E->setArgument(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000671 Record.skipInts(1);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000672 } else {
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000673 E->setArgument(GetTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000674 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000675 E->setOperatorLoc(ReadSourceLocation());
676 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000677}
678
Sebastian Redl70c751d2010-08-18 23:56:52 +0000679void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000680 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000681 E->setLHS(Record.readSubExpr());
682 E->setRHS(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000683 E->setRBracketLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000684}
685
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000686void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
687 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000688 E->setBase(Record.readSubExpr());
689 E->setLowerBound(Record.readSubExpr());
690 E->setLength(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000691 E->setColonLoc(ReadSourceLocation());
692 E->setRBracketLoc(ReadSourceLocation());
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000693}
694
Sebastian Redl70c751d2010-08-18 23:56:52 +0000695void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000696 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000697 E->setNumArgs(Record.getContext(), Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000698 E->setRParenLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000699 E->setCallee(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000700 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000701 E->setArg(I, Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000702}
703
John McCallfa194042011-07-15 07:00:14 +0000704void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
705 VisitCallExpr(E);
706}
707
Sebastian Redl70c751d2010-08-18 23:56:52 +0000708void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000709 // Don't call VisitExpr, this is fully initialized at creation.
710 assert(E->getStmtClass() == Stmt::MemberExprClass &&
711 "It's a subclass, we must advance Idx!");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000712}
713
Sebastian Redl70c751d2010-08-18 23:56:52 +0000714void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Naroffe87026a2009-07-24 17:54:45 +0000715 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000716 E->setBase(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000717 E->setIsaMemberLoc(ReadSourceLocation());
718 E->setOpLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000719 E->setArrow(Record.readInt());
Steve Naroffe87026a2009-07-24 17:54:45 +0000720}
721
John McCall31168b02011-06-15 23:02:42 +0000722void ASTStmtReader::
723VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
724 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000725 E->Operand = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000726 E->setShouldCopy(Record.readInt());
John McCall31168b02011-06-15 23:02:42 +0000727}
728
729void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
730 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000731 E->LParenLoc = ReadSourceLocation();
732 E->BridgeKeywordLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000733 E->Kind = Record.readInt();
John McCall31168b02011-06-15 23:02:42 +0000734}
735
Sebastian Redl70c751d2010-08-18 23:56:52 +0000736void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000737 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000738 unsigned NumBaseSpecs = Record.readInt();
John McCallcf142162010-08-07 06:22:56 +0000739 assert(NumBaseSpecs == E->path_size());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000740 E->setSubExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000741 E->setCastKind((CastKind)Record.readInt());
John McCallcf142162010-08-07 06:22:56 +0000742 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000743 while (NumBaseSpecs--) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000744 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000745 *BaseSpec = Record.readCXXBaseSpecifier();
John McCallcf142162010-08-07 06:22:56 +0000746 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000747 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000748}
749
Sebastian Redl70c751d2010-08-18 23:56:52 +0000750void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000751 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000752 E->setLHS(Record.readSubExpr());
753 E->setRHS(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000754 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000755 E->setOperatorLoc(ReadSourceLocation());
Adam Nemet484aa452017-03-27 19:17:25 +0000756 E->setFPFeatures(FPOptions(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000757}
758
Sebastian Redl70c751d2010-08-18 23:56:52 +0000759void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000760 VisitBinaryOperator(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000761 E->setComputationLHSType(Record.readType());
762 E->setComputationResultType(Record.readType());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000763}
764
Sebastian Redl70c751d2010-08-18 23:56:52 +0000765void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000766 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000767 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
768 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
769 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000770 E->QuestionLoc = ReadSourceLocation();
771 E->ColonLoc = ReadSourceLocation();
John McCallc07a0c72011-02-17 10:25:35 +0000772}
773
774void
775ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
776 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000777 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
778 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
779 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
780 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
781 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000782 E->QuestionLoc = ReadSourceLocation();
783 E->ColonLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000784}
785
Sebastian Redl70c751d2010-08-18 23:56:52 +0000786void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000787 VisitCastExpr(E);
Roman Lebedev12216f12018-07-27 07:27:14 +0000788 E->setIsPartOfExplicitCast(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000789}
790
Sebastian Redl70c751d2010-08-18 23:56:52 +0000791void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000792 VisitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000793 E->setTypeInfoAsWritten(GetTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000794}
795
Sebastian Redl70c751d2010-08-18 23:56:52 +0000796void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000797 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000798 E->setLParenLoc(ReadSourceLocation());
799 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000800}
801
Sebastian Redl70c751d2010-08-18 23:56:52 +0000802void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000803 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000804 E->setLParenLoc(ReadSourceLocation());
805 E->setTypeSourceInfo(GetTypeSourceInfo());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000806 E->setInitializer(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000807 E->setFileScope(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000808}
809
Sebastian Redl70c751d2010-08-18 23:56:52 +0000810void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000811 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000812 E->setBase(Record.readSubExpr());
813 E->setAccessor(Record.getIdentifierInfo());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000814 E->setAccessorLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000815}
816
Sebastian Redl70c751d2010-08-18 23:56:52 +0000817void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000818 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000819 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
Abramo Bagnara8d16bd42012-11-08 18:41:43 +0000820 E->setSyntacticForm(SyntForm);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000821 E->setLBraceLoc(ReadSourceLocation());
822 E->setRBraceLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000823 bool isArrayFiller = Record.readInt();
Craig Toppera13603a2014-05-22 05:54:18 +0000824 Expr *filler = nullptr;
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000825 if (isArrayFiller) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000826 filler = Record.readSubExpr();
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000827 E->ArrayFillerOrUnionFieldInit = filler;
828 } else
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000829 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000830 E->sawArrayRangeDesignator(Record.readInt());
831 unsigned NumInits = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000832 E->reserveInits(Record.getContext(), NumInits);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000833 if (isArrayFiller) {
834 for (unsigned I = 0; I != NumInits; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000835 Expr *init = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000836 E->updateInit(Record.getContext(), I, init ? init : filler);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000837 }
838 } else {
839 for (unsigned I = 0; I != NumInits; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000840 E->updateInit(Record.getContext(), I, Record.readSubExpr());
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000841 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000842}
843
Sebastian Redl70c751d2010-08-18 23:56:52 +0000844void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000845 using Designator = DesignatedInitExpr::Designator;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000846
847 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000848 unsigned NumSubExprs = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000849 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
850 for (unsigned I = 0; I != NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000851 E->setSubExpr(I, Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000852 E->setEqualOrColonLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000853 E->setGNUSyntax(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000854
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000855 SmallVector<Designator, 4> Designators;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000856 while (Record.getIdx() < Record.size()) {
857 switch ((DesignatorTypes)Record.readInt()) {
Sebastian Redl539c5062010-08-18 23:57:32 +0000858 case DESIG_FIELD_DECL: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000859 auto *Field = ReadDeclAs<FieldDecl>();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000860 SourceLocation DotLoc = ReadSourceLocation();
861 SourceLocation FieldLoc = ReadSourceLocation();
Mike Stump11289f42009-09-09 15:08:12 +0000862 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000863 FieldLoc));
864 Designators.back().setField(Field);
865 break;
866 }
867
Sebastian Redl539c5062010-08-18 23:57:32 +0000868 case DESIG_FIELD_NAME: {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000869 const IdentifierInfo *Name = Record.getIdentifierInfo();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000870 SourceLocation DotLoc = ReadSourceLocation();
871 SourceLocation FieldLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000872 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
873 break;
874 }
Mike Stump11289f42009-09-09 15:08:12 +0000875
Sebastian Redl539c5062010-08-18 23:57:32 +0000876 case DESIG_ARRAY: {
David L. Jonesbe1557a2016-12-21 00:17:49 +0000877 unsigned Index = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000878 SourceLocation LBracketLoc = ReadSourceLocation();
879 SourceLocation RBracketLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000880 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
881 break;
882 }
883
Sebastian Redl539c5062010-08-18 23:57:32 +0000884 case DESIG_ARRAY_RANGE: {
David L. Jonesbe1557a2016-12-21 00:17:49 +0000885 unsigned Index = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000886 SourceLocation LBracketLoc = ReadSourceLocation();
887 SourceLocation EllipsisLoc = ReadSourceLocation();
888 SourceLocation RBracketLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000889 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
890 RBracketLoc));
891 break;
892 }
893 }
894 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000895 E->setDesignators(Record.getContext(),
Douglas Gregor03e8bdc2010-01-06 23:17:19 +0000896 Designators.data(), Designators.size());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000897}
898
Yunzhong Gaocb779302015-06-10 00:27:52 +0000899void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
900 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000901 E->setBase(Record.readSubExpr());
902 E->setUpdater(Record.readSubExpr());
Yunzhong Gaocb779302015-06-10 00:27:52 +0000903}
904
905void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
906 VisitExpr(E);
907}
908
Richard Smith410306b2016-12-12 02:53:20 +0000909void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
910 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000911 E->SubExprs[0] = Record.readSubExpr();
912 E->SubExprs[1] = Record.readSubExpr();
Richard Smith410306b2016-12-12 02:53:20 +0000913}
914
915void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
916 VisitExpr(E);
917}
918
Sebastian Redl70c751d2010-08-18 23:56:52 +0000919void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000920 VisitExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000921}
922
Sebastian Redl70c751d2010-08-18 23:56:52 +0000923void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000924 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000925 E->setSubExpr(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000926 E->setWrittenTypeInfo(GetTypeSourceInfo());
927 E->setBuiltinLoc(ReadSourceLocation());
928 E->setRParenLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000929 E->setIsMicrosoftABI(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000930}
931
Sebastian Redl70c751d2010-08-18 23:56:52 +0000932void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000933 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000934 E->setAmpAmpLoc(ReadSourceLocation());
935 E->setLabelLoc(ReadSourceLocation());
936 E->setLabel(ReadDeclAs<LabelDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000937}
938
Sebastian Redl70c751d2010-08-18 23:56:52 +0000939void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000940 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000941 E->setLParenLoc(ReadSourceLocation());
942 E->setRParenLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000943 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000944}
945
Sebastian Redl70c751d2010-08-18 23:56:52 +0000946void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000947 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000948 E->setCond(Record.readSubExpr());
949 E->setLHS(Record.readSubExpr());
950 E->setRHS(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000951 E->setBuiltinLoc(ReadSourceLocation());
952 E->setRParenLoc(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000953 E->setIsConditionTrue(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000954}
955
Sebastian Redl70c751d2010-08-18 23:56:52 +0000956void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000957 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000958 E->setTokenLocation(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000959}
960
Sebastian Redl70c751d2010-08-18 23:56:52 +0000961void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000962 VisitExpr(E);
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000963 SmallVector<Expr *, 16> Exprs;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000964 unsigned NumExprs = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000965 while (NumExprs--)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000966 Exprs.push_back(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000967 E->setExprs(Record.getContext(), Exprs);
968 E->setBuiltinLoc(ReadSourceLocation());
969 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000970}
971
Hal Finkelc4d7c822013-09-18 03:29:45 +0000972void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
973 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000974 E->BuiltinLoc = ReadSourceLocation();
975 E->RParenLoc = ReadSourceLocation();
976 E->TInfo = GetTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000977 E->SrcExpr = Record.readSubExpr();
Hal Finkelc4d7c822013-09-18 03:29:45 +0000978}
979
Sebastian Redl70c751d2010-08-18 23:56:52 +0000980void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000981 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000982 E->setBlockDecl(ReadDeclAs<BlockDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000983}
984
Peter Collingbourne91147592011-04-15 00:35:48 +0000985void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
986 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000987 E->NumAssocs = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000988 E->AssocTypes = new (Record.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbourne91147592011-04-15 00:35:48 +0000989 E->SubExprs =
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000990 new(Record.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbourne91147592011-04-15 00:35:48 +0000991
David L. Jonesb6a8f022016-12-21 04:34:52 +0000992 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Record.readSubExpr();
Peter Collingbourne91147592011-04-15 00:35:48 +0000993 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000994 E->AssocTypes[I] = GetTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000995 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Record.readSubExpr();
Peter Collingbourne91147592011-04-15 00:35:48 +0000996 }
David L. Jonesbe1557a2016-12-21 00:17:49 +0000997 E->ResultIndex = Record.readInt();
Peter Collingbourne91147592011-04-15 00:35:48 +0000998
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000999 E->GenericLoc = ReadSourceLocation();
1000 E->DefaultLoc = ReadSourceLocation();
1001 E->RParenLoc = ReadSourceLocation();
Peter Collingbourne91147592011-04-15 00:35:48 +00001002}
1003
John McCallfe96e0b2011-11-06 09:01:30 +00001004void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1005 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001006 unsigned numSemanticExprs = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001007 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001008 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001009
1010 // Read the syntactic expression.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001011 E->getSubExprsBuffer()[0] = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001012
1013 // Read all the semantic expressions.
1014 for (unsigned i = 0; i != numSemanticExprs; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001015 Expr *subExpr = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001016 E->getSubExprsBuffer()[i+1] = subExpr;
1017 }
1018}
1019
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001020void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1021 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001022 E->Op = AtomicExpr::AtomicOp(Record.readInt());
Richard Smithaa22a8c2012-04-10 22:49:28 +00001023 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1024 for (unsigned I = 0; I != E->NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001025 E->SubExprs[I] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001026 E->BuiltinLoc = ReadSourceLocation();
1027 E->RParenLoc = ReadSourceLocation();
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001028}
1029
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001030//===----------------------------------------------------------------------===//
1031// Objective-C Expressions and Statements
1032
Sebastian Redl70c751d2010-08-18 23:56:52 +00001033void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001034 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001035 E->setString(cast<StringLiteral>(Record.readSubStmt()));
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001036 E->setAtLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001037}
1038
Patrick Beard0caa3942012-04-19 00:25:12 +00001039void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001040 VisitExpr(E);
1041 // could be one of several IntegerLiteral, FloatLiteral, etc.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001042 E->SubExpr = Record.readSubStmt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001043 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>();
1044 E->Range = ReadSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001045}
1046
1047void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1048 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001049 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001050 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1051 Expr **Elements = E->getElements();
1052 for (unsigned I = 0, N = NumElements; I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001053 Elements[I] = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001054 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1055 E->Range = ReadSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001056}
1057
1058void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1059 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001060 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001061 assert(NumElements == E->getNumElements() && "Wrong number of elements");
David L. Jonesbe1557a2016-12-21 00:17:49 +00001062 bool HasPackExpansions = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001063 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001064 auto *KeyValues =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001065 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001066 auto *Expansions =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001067 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001068 for (unsigned I = 0; I != NumElements; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001069 KeyValues[I].Key = Record.readSubExpr();
1070 KeyValues[I].Value = Record.readSubExpr();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001071 if (HasPackExpansions) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001072 Expansions[I].EllipsisLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001073 Expansions[I].NumExpansionsPlusOne = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001074 }
1075 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001076 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1077 E->Range = ReadSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001078}
1079
Sebastian Redl70c751d2010-08-18 23:56:52 +00001080void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001081 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001082 E->setEncodedTypeSourceInfo(GetTypeSourceInfo());
1083 E->setAtLoc(ReadSourceLocation());
1084 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001085}
1086
Sebastian Redl70c751d2010-08-18 23:56:52 +00001087void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001088 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001089 E->setSelector(Record.readSelector());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001090 E->setAtLoc(ReadSourceLocation());
1091 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001092}
1093
Sebastian Redl70c751d2010-08-18 23:56:52 +00001094void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001095 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001096 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>());
1097 E->setAtLoc(ReadSourceLocation());
1098 E->ProtoLoc = ReadSourceLocation();
1099 E->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001100}
1101
Sebastian Redl70c751d2010-08-18 23:56:52 +00001102void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001103 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001104 E->setDecl(ReadDeclAs<ObjCIvarDecl>());
1105 E->setLocation(ReadSourceLocation());
1106 E->setOpLoc(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001107 E->setBase(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001108 E->setIsArrow(Record.readInt());
1109 E->setIsFreeIvar(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001110}
1111
Sebastian Redl70c751d2010-08-18 23:56:52 +00001112void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001113 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001114 unsigned MethodRefFlags = Record.readInt();
1115 bool Implicit = Record.readInt() != 0;
John McCallb7bd14f2010-12-02 01:19:52 +00001116 if (Implicit) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001117 auto *Getter = ReadDeclAs<ObjCMethodDecl>();
1118 auto *Setter = ReadDeclAs<ObjCMethodDecl>();
Argyrios Kyrtzidisab468b02012-03-30 00:19:18 +00001119 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCallb7bd14f2010-12-02 01:19:52 +00001120 } else {
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001121 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001122 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001123 E->setLocation(ReadSourceLocation());
1124 E->setReceiverLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001125 switch (Record.readInt()) {
John McCallb7bd14f2010-12-02 01:19:52 +00001126 case 0:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001127 E->setBase(Record.readSubExpr());
John McCallb7bd14f2010-12-02 01:19:52 +00001128 break;
1129 case 1:
David L. Jonesbe1557a2016-12-21 00:17:49 +00001130 E->setSuperReceiver(Record.readType());
John McCallb7bd14f2010-12-02 01:19:52 +00001131 break;
1132 case 2:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001133 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>());
John McCallb7bd14f2010-12-02 01:19:52 +00001134 break;
1135 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001136}
1137
Ted Kremeneke65b0862012-03-06 20:05:56 +00001138void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1139 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001140 E->setRBracket(ReadSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001141 E->setBaseExpr(Record.readSubExpr());
1142 E->setKeyExpr(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001143 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1144 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001145}
1146
Sebastian Redl70c751d2010-08-18 23:56:52 +00001147void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001148 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001149 assert(Record.peekInt() == E->getNumArgs());
1150 Record.skipInts(1);
1151 unsigned NumStoredSelLocs = Record.readInt();
1152 E->SelLocsKind = Record.readInt();
1153 E->setDelegateInitCall(Record.readInt());
1154 E->IsImplicit = Record.readInt();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001155 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
Douglas Gregor9a129192010-04-21 00:45:42 +00001156 switch (Kind) {
1157 case ObjCMessageExpr::Instance:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001158 E->setInstanceReceiver(Record.readSubExpr());
Douglas Gregor9a129192010-04-21 00:45:42 +00001159 break;
1160
1161 case ObjCMessageExpr::Class:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001162 E->setClassReceiver(GetTypeSourceInfo());
Douglas Gregor9a129192010-04-21 00:45:42 +00001163 break;
1164
1165 case ObjCMessageExpr::SuperClass:
1166 case ObjCMessageExpr::SuperInstance: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001167 QualType T = Record.readType();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001168 SourceLocation SuperLoc = ReadSourceLocation();
Douglas Gregor9a129192010-04-21 00:45:42 +00001169 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1170 break;
1171 }
1172 }
1173
1174 assert(Kind == E->getReceiverKind());
1175
David L. Jonesbe1557a2016-12-21 00:17:49 +00001176 if (Record.readInt())
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001177 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>());
Douglas Gregor9a129192010-04-21 00:45:42 +00001178 else
David L. Jonesb6a8f022016-12-21 04:34:52 +00001179 E->setSelector(Record.readSelector());
Douglas Gregor9a129192010-04-21 00:45:42 +00001180
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001181 E->LBracLoc = ReadSourceLocation();
1182 E->RBracLoc = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001183
1184 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001185 E->setArg(I, Record.readSubExpr());
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00001186
1187 SourceLocation *Locs = E->getStoredSelLocs();
1188 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001189 Locs[I] = ReadSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001190}
1191
Sebastian Redl70c751d2010-08-18 23:56:52 +00001192void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001193 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001194 S->setElement(Record.readSubStmt());
1195 S->setCollection(Record.readSubExpr());
1196 S->setBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001197 S->setForLoc(ReadSourceLocation());
1198 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001199}
1200
Sebastian Redl70c751d2010-08-18 23:56:52 +00001201void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001202 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001203 S->setCatchBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001204 S->setCatchParamDecl(ReadDeclAs<VarDecl>());
1205 S->setAtCatchLoc(ReadSourceLocation());
1206 S->setRParenLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001207}
1208
Sebastian Redl70c751d2010-08-18 23:56:52 +00001209void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001210 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001211 S->setFinallyBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001212 S->setAtFinallyLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001213}
1214
John McCall31168b02011-06-15 23:02:42 +00001215void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1216 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001217 S->setSubStmt(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001218 S->setAtLoc(ReadSourceLocation());
John McCall31168b02011-06-15 23:02:42 +00001219}
1220
Sebastian Redl70c751d2010-08-18 23:56:52 +00001221void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001222 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001223 assert(Record.peekInt() == S->getNumCatchStmts());
1224 Record.skipInts(1);
1225 bool HasFinally = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001226 S->setTryBody(Record.readSubStmt());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001227 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001228 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
Douglas Gregor96c79492010-04-23 22:50:49 +00001229
Douglas Gregor96c79492010-04-23 22:50:49 +00001230 if (HasFinally)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001231 S->setFinallyStmt(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001232 S->setAtTryLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001233}
1234
Sebastian Redl70c751d2010-08-18 23:56:52 +00001235void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001236 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001237 S->setSynchExpr(Record.readSubStmt());
1238 S->setSynchBody(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001239 S->setAtSynchronizedLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001240}
1241
Sebastian Redl70c751d2010-08-18 23:56:52 +00001242void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001243 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001244 S->setThrowExpr(Record.readSubStmt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001245 S->setThrowLoc(ReadSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001246}
1247
Ted Kremeneke65b0862012-03-06 20:05:56 +00001248void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1249 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001250 E->setValue(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001251 E->setLocation(ReadSourceLocation());
Ted Kremeneke65b0862012-03-06 20:05:56 +00001252}
1253
Erik Pilkington29099de2016-07-16 00:35:23 +00001254void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1255 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001256 SourceRange R = Record.readSourceRange();
Erik Pilkington29099de2016-07-16 00:35:23 +00001257 E->AtLoc = R.getBegin();
1258 E->RParen = R.getEnd();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001259 E->VersionToCheck = Record.readVersionTuple();
Erik Pilkington29099de2016-07-16 00:35:23 +00001260}
1261
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001262//===----------------------------------------------------------------------===//
1263// C++ Expressions and Statements
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001264//===----------------------------------------------------------------------===//
1265
Sebastian Redl70c751d2010-08-18 23:56:52 +00001266void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001267 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001268 S->CatchLoc = ReadSourceLocation();
1269 S->ExceptionDecl = ReadDeclAs<VarDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001270 S->HandlerBlock = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001271}
1272
Sebastian Redl70c751d2010-08-18 23:56:52 +00001273void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001274 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001275 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1276 Record.skipInts(1);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001277 S->TryLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001278 S->getStmts()[0] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001279 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001280 S->getStmts()[i + 1] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001281}
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001282
Richard Smith02e85f32011-04-14 22:09:26 +00001283void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1284 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001285 S->ForLoc = ReadSourceLocation();
1286 S->CoawaitLoc = ReadSourceLocation();
1287 S->ColonLoc = ReadSourceLocation();
1288 S->RParenLoc = ReadSourceLocation();
Richard Smith8baa5002018-09-28 18:44:09 +00001289 S->setInit(Record.readSubStmt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001290 S->setRangeStmt(Record.readSubStmt());
1291 S->setBeginStmt(Record.readSubStmt());
1292 S->setEndStmt(Record.readSubStmt());
1293 S->setCond(Record.readSubExpr());
1294 S->setInc(Record.readSubExpr());
1295 S->setLoopVarStmt(Record.readSubStmt());
1296 S->setBody(Record.readSubStmt());
Richard Smith02e85f32011-04-14 22:09:26 +00001297}
1298
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001299void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1300 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001301 S->KeywordLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001302 S->IsIfExists = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001303 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001304 ReadDeclarationNameInfo(S->NameInfo);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001305 S->SubStmt = Record.readSubStmt();
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001306}
1307
Sebastian Redl70c751d2010-08-18 23:56:52 +00001308void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001309 VisitCallExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001310 E->Operator = (OverloadedOperatorKind)Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001311 E->Range = Record.readSourceRange();
Adam Nemet484aa452017-03-27 19:17:25 +00001312 E->setFPFeatures(FPOptions(Record.readInt()));
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001313}
1314
Sebastian Redl70c751d2010-08-18 23:56:52 +00001315void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001316 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001317 E->NumArgs = Record.readInt();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001318 if (E->NumArgs)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001319 E->Args = new (Record.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis30d98f32010-06-24 08:57:09 +00001320 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001321 E->setArg(I, Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001322 E->setConstructor(ReadDeclAs<CXXConstructorDecl>());
1323 E->setLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001324 E->setElidable(Record.readInt());
1325 E->setHadMultipleCandidates(Record.readInt());
1326 E->setListInitialization(Record.readInt());
1327 E->setStdInitListInitialization(Record.readInt());
1328 E->setRequiresZeroInitialization(Record.readInt());
1329 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001330 E->ParenOrBraceRange = ReadSourceRange();
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001331}
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001332
Richard Smith5179eb72016-06-28 19:03:57 +00001333void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1334 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001335 E->Constructor = ReadDeclAs<CXXConstructorDecl>();
1336 E->Loc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001337 E->ConstructsVirtualBase = Record.readInt();
1338 E->InheritedFromVirtualBase = Record.readInt();
Richard Smith5179eb72016-06-28 19:03:57 +00001339}
1340
Sebastian Redl70c751d2010-08-18 23:56:52 +00001341void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001342 VisitCXXConstructExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001343 E->Type = GetTypeSourceInfo();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001344}
1345
Douglas Gregore31e6062012-02-07 10:09:13 +00001346void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1347 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001348 unsigned NumCaptures = Record.readInt();
Douglas Gregor99ae8062012-02-14 17:54:36 +00001349 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001350 E->IntroducerRange = ReadSourceRange();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001351 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001352 E->CaptureDefaultLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001353 E->ExplicitParams = Record.readInt();
1354 E->ExplicitResultType = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001355 E->ClosingBrace = ReadSourceLocation();
1356
Douglas Gregor99ae8062012-02-14 17:54:36 +00001357 // Read capture initializers.
1358 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1359 CEnd = E->capture_init_end();
1360 C != CEnd; ++C)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001361 *C = Record.readSubExpr();
Douglas Gregore31e6062012-02-07 10:09:13 +00001362}
1363
Richard Smithcc1b96d2013-06-12 22:31:48 +00001364void
1365ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1366 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001367 E->SubExpr = Record.readSubExpr();
Richard Smithcc1b96d2013-06-12 22:31:48 +00001368}
1369
Sebastian Redl70c751d2010-08-18 23:56:52 +00001370void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001371 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001372 SourceRange R = ReadSourceRange();
Douglas Gregor4478f852011-01-12 22:41:29 +00001373 E->Loc = R.getBegin();
1374 E->RParenLoc = R.getEnd();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001375 R = ReadSourceRange();
Fariborz Jahanianf0738712013-02-22 22:02:53 +00001376 E->AngleBrackets = R;
Sam Weinigd01101e2010-01-16 21:21:01 +00001377}
1378
Sebastian Redl70c751d2010-08-18 23:56:52 +00001379void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001380 return VisitCXXNamedCastExpr(E);
1381}
1382
Sebastian Redl70c751d2010-08-18 23:56:52 +00001383void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001384 return VisitCXXNamedCastExpr(E);
1385}
1386
Sebastian Redl70c751d2010-08-18 23:56:52 +00001387void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001388 return VisitCXXNamedCastExpr(E);
1389}
1390
Sebastian Redl70c751d2010-08-18 23:56:52 +00001391void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001392 return VisitCXXNamedCastExpr(E);
1393}
1394
Sebastian Redl70c751d2010-08-18 23:56:52 +00001395void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001396 VisitExplicitCastExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001397 E->setLParenLoc(ReadSourceLocation());
1398 E->setRParenLoc(ReadSourceLocation());
Sam Weinigd01101e2010-01-16 21:21:01 +00001399}
1400
Richard Smithc67fdd42012-03-07 08:35:16 +00001401void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1402 VisitCallExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001403 E->UDSuffixLoc = ReadSourceLocation();
Richard Smithc67fdd42012-03-07 08:35:16 +00001404}
1405
Sebastian Redl70c751d2010-08-18 23:56:52 +00001406void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001407 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001408 E->setValue(Record.readInt());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001409 E->setLocation(ReadSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001410}
1411
Sebastian Redl70c751d2010-08-18 23:56:52 +00001412void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001413 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001414 E->setLocation(ReadSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001415}
1416
Sebastian Redl70c751d2010-08-18 23:56:52 +00001417void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001418 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001419 E->setSourceRange(ReadSourceRange());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001420 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redlc67764e2010-07-22 22:43:28 +00001421 E->setTypeOperandSourceInfo(
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001422 GetTypeSourceInfo());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001423 return;
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001424 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001425
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001426 // typeid(42+2)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001427 E->setExprOperand(Record.readSubExpr());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001428}
1429
Sebastian Redl70c751d2010-08-18 23:56:52 +00001430void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001431 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001432 E->setLocation(ReadSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001433 E->setImplicit(Record.readInt());
Chris Lattner98267332010-05-09 06:15:05 +00001434}
1435
Sebastian Redl70c751d2010-08-18 23:56:52 +00001436void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001437 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001438 E->ThrowLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001439 E->Op = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001440 E->IsThrownVariableInScope = Record.readInt();
Chris Lattner98267332010-05-09 06:15:05 +00001441}
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001442
Sebastian Redl70c751d2010-08-18 23:56:52 +00001443void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattnere2437f42010-05-09 06:40:08 +00001444 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001445 E->Param = ReadDeclAs<ParmVarDecl>();
1446 E->Loc = ReadSourceLocation();
Chris Lattnercba86142010-05-10 00:25:06 +00001447}
1448
Richard Smith852c9db2013-04-20 22:23:05 +00001449void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1450 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001451 E->Field = ReadDeclAs<FieldDecl>();
1452 E->Loc = ReadSourceLocation();
Richard Smith852c9db2013-04-20 22:23:05 +00001453}
1454
Sebastian Redl70c751d2010-08-18 23:56:52 +00001455void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001456 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001457 E->setTemporary(Record.readCXXTemporary());
1458 E->setSubExpr(Record.readSubExpr());
Chris Lattnercba86142010-05-10 00:25:06 +00001459}
1460
Sebastian Redl70c751d2010-08-18 23:56:52 +00001461void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001462 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001463 E->TypeInfo = GetTypeSourceInfo();
1464 E->RParenLoc = ReadSourceLocation();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001465}
1466
Sebastian Redl70c751d2010-08-18 23:56:52 +00001467void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001468 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001469 E->GlobalNew = Record.readInt();
1470 bool isArray = Record.readInt();
1471 E->PassAlignment = Record.readInt();
1472 E->UsualArrayDeleteWantsSize = Record.readInt();
1473 unsigned NumPlacementArgs = Record.readInt();
1474 E->StoredInitializationStyle = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001475 E->setOperatorNew(ReadDeclAs<FunctionDecl>());
1476 E->setOperatorDelete(ReadDeclAs<FunctionDecl>());
1477 E->AllocatedTypeInfo = GetTypeSourceInfo();
1478 E->TypeIdParens = ReadSourceRange();
1479 E->Range = ReadSourceRange();
1480 E->DirectInitRange = ReadSourceRange();
Chandler Carruth01718152010-10-25 08:47:36 +00001481
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001482 E->AllocateArgsArray(Record.getContext(), isArray, NumPlacementArgs,
Sebastian Redl6047f072012-02-16 12:22:20 +00001483 E->StoredInitializationStyle != 0);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001484
1485 // Install all the subexpressions.
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001486 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1487 I != e; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001488 *I = Record.readSubStmt();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001489}
1490
Sebastian Redl70c751d2010-08-18 23:56:52 +00001491void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001492 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001493 E->GlobalDelete = Record.readInt();
1494 E->ArrayForm = Record.readInt();
1495 E->ArrayFormAsWritten = Record.readInt();
1496 E->UsualArrayDeleteWantsSize = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001497 E->OperatorDelete = ReadDeclAs<FunctionDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001498 E->Argument = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001499 E->Loc = ReadSourceLocation();
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001500}
Chris Lattnercba86142010-05-10 00:25:06 +00001501
Sebastian Redl70c751d2010-08-18 23:56:52 +00001502void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001503 VisitExpr(E);
1504
David L. Jonesb6a8f022016-12-21 04:34:52 +00001505 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001506 E->IsArrow = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001507 E->OperatorLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001508 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001509 E->ScopeType = GetTypeSourceInfo();
1510 E->ColonColonLoc = ReadSourceLocation();
1511 E->TildeLoc = ReadSourceLocation();
1512
David L. Jonesb6a8f022016-12-21 04:34:52 +00001513 IdentifierInfo *II = Record.getIdentifierInfo();
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001514 if (II)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001515 E->setDestroyedType(II, ReadSourceLocation());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001516 else
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001517 E->setDestroyedType(GetTypeSourceInfo());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001518}
1519
John McCall5d413782010-12-06 08:20:24 +00001520void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001521 VisitExpr(E);
John McCall28fc7092011-11-10 05:35:25 +00001522
David L. Jonesbe1557a2016-12-21 00:17:49 +00001523 unsigned NumObjects = Record.readInt();
John McCall28fc7092011-11-10 05:35:25 +00001524 assert(NumObjects == E->getNumObjects());
1525 for (unsigned i = 0; i != NumObjects; ++i)
James Y Knighte00a67e2015-12-31 04:18:25 +00001526 E->getTrailingObjects<BlockDecl *>()[i] =
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001527 ReadDeclAs<BlockDecl>();
John McCall28fc7092011-11-10 05:35:25 +00001528
David L. Jonesbe1557a2016-12-21 00:17:49 +00001529 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001530 E->SubExpr = Record.readSubExpr();
Chris Lattnere2437f42010-05-09 06:40:08 +00001531}
1532
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001533void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001534ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001535 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001536
David L. Jonesbe1557a2016-12-21 00:17:49 +00001537 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001538 ReadTemplateKWAndArgsInfo(
1539 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1540 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001541 /*NumTemplateArgs=*/Record.readInt());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001542
David L. Jonesb6a8f022016-12-21 04:34:52 +00001543 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001544 E->BaseType = Record.readType();
1545 E->IsArrow = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001546 E->OperatorLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001547 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001548 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>();
1549 ReadDeclarationNameInfo(E->MemberNameInfo);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001550}
1551
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001552void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001553ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001554 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001555
David L. Jonesbe1557a2016-12-21 00:17:49 +00001556 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001557 ReadTemplateKWAndArgsInfo(
1558 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1559 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001560 /*NumTemplateArgs=*/Record.readInt());
Douglas Gregor3a43fd62011-02-25 20:49:16 +00001561
David L. Jonesb6a8f022016-12-21 04:34:52 +00001562 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001563 ReadDeclarationNameInfo(E->NameInfo);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001564}
1565
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001566void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001567ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001568 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001569 assert(Record.peekInt() == E->arg_size() &&
1570 "Read wrong record during creation ?");
1571 Record.skipInts(1);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001572 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001573 E->setArg(I, Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001574 E->Type = GetTypeSourceInfo();
1575 E->setLParenLoc(ReadSourceLocation());
1576 E->setRParenLoc(ReadSourceLocation());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001577}
1578
Sebastian Redl70c751d2010-08-18 23:56:52 +00001579void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001580 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001581
David L. Jonesbe1557a2016-12-21 00:17:49 +00001582 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001583 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1584 E->getTrailingTemplateArgumentLoc(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001585 /*NumTemplateArgs=*/Record.readInt());
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001586
David L. Jonesbe1557a2016-12-21 00:17:49 +00001587 unsigned NumDecls = Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001588 UnresolvedSet<8> Decls;
1589 for (unsigned i = 0; i != NumDecls; ++i) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001590 auto *D = ReadDeclAs<NamedDecl>();
1591 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001592 Decls.addDecl(D, AS);
1593 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001594 E->initializeResults(Record.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001595
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001596 ReadDeclarationNameInfo(E->NameInfo);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001597 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001598}
1599
Sebastian Redl70c751d2010-08-18 23:56:52 +00001600void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001601 VisitOverloadExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001602 E->IsArrow = Record.readInt();
1603 E->HasUnresolvedUsing = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001604 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001605 E->BaseType = Record.readType();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001606 E->OperatorLoc = ReadSourceLocation();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001607}
1608
Sebastian Redl70c751d2010-08-18 23:56:52 +00001609void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001610 VisitOverloadExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001611 E->RequiresADL = Record.readInt();
1612 E->Overloaded = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001613 E->NamingClass = ReadDeclAs<CXXRecordDecl>();
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00001614}
1615
Douglas Gregor29c42f22012-02-24 07:38:34 +00001616void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1617 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001618 E->TypeTraitExprBits.NumArgs = Record.readInt();
1619 E->TypeTraitExprBits.Kind = Record.readInt();
1620 E->TypeTraitExprBits.Value = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001621 SourceRange Range = ReadSourceRange();
Jordan Rose99e80c12013-12-20 01:26:47 +00001622 E->Loc = Range.getBegin();
1623 E->RParenLoc = Range.getEnd();
1624
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001625 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001626 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001627 Args[I] = GetTypeSourceInfo();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001628}
1629
John Wiegley6242b6a2011-04-28 00:16:57 +00001630void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1631 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001632 E->ATT = (ArrayTypeTrait)Record.readInt();
1633 E->Value = (unsigned int)Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001634 SourceRange Range = ReadSourceRange();
John Wiegley6242b6a2011-04-28 00:16:57 +00001635 E->Loc = Range.getBegin();
1636 E->RParen = Range.getEnd();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001637 E->QueriedType = GetTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001638 E->Dimension = Record.readSubExpr();
John Wiegley6242b6a2011-04-28 00:16:57 +00001639}
1640
John Wiegleyf9f65842011-04-25 06:54:41 +00001641void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1642 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001643 E->ET = (ExpressionTrait)Record.readInt();
1644 E->Value = (bool)Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001645 SourceRange Range = ReadSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001646 E->QueriedExpression = Record.readSubExpr();
John Wiegleyf9f65842011-04-25 06:54:41 +00001647 E->Loc = Range.getBegin();
1648 E->RParen = Range.getEnd();
1649}
1650
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001651void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1652 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001653 E->Value = (bool)Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001654 E->Range = ReadSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001655 E->Operand = Record.readSubExpr();
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001656}
1657
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001658void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1659 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001660 E->EllipsisLoc = ReadSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001661 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001662 E->Pattern = Record.readSubExpr();
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001663}
1664
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001665void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1666 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001667 unsigned NumPartialArgs = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001668 E->OperatorLoc = ReadSourceLocation();
1669 E->PackLoc = ReadSourceLocation();
1670 E->RParenLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001671 E->Pack = Record.readDeclAs<NamedDecl>();
Richard Smithd784e682015-09-23 21:41:42 +00001672 if (E->isPartiallySubstituted()) {
1673 assert(E->Length == NumPartialArgs);
James Y Knighte00a67e2015-12-31 04:18:25 +00001674 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
Richard Smithd784e682015-09-23 21:41:42 +00001675 *E = I + NumPartialArgs;
1676 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001677 new (I) TemplateArgument(Record.readTemplateArgument());
Richard Smithd784e682015-09-23 21:41:42 +00001678 } else if (!E->isValueDependent()) {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001679 E->Length = Record.readInt();
Richard Smithd784e682015-09-23 21:41:42 +00001680 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001681}
1682
John McCallfa194042011-07-15 07:00:14 +00001683void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1684 SubstNonTypeTemplateParmExpr *E) {
1685 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001686 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1687 E->NameLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001688 E->Replacement = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00001689}
1690
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001691void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1692 SubstNonTypeTemplateParmPackExpr *E) {
1693 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001694 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001695 TemplateArgument ArgPack = Record.readTemplateArgument();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001696 if (ArgPack.getKind() != TemplateArgument::Pack)
1697 return;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001698
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001699 E->Arguments = ArgPack.pack_begin();
1700 E->NumArguments = ArgPack.pack_size();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001701 E->NameLoc = ReadSourceLocation();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001702}
1703
Richard Smithb15fe3a2012-09-12 00:56:43 +00001704void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1705 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001706 E->NumParameters = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001707 E->ParamPack = ReadDeclAs<ParmVarDecl>();
1708 E->NameLoc = ReadSourceLocation();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001709 auto **Parms = E->getTrailingObjects<ParmVarDecl *>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00001710 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001711 Parms[i] = ReadDeclAs<ParmVarDecl>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00001712}
1713
Douglas Gregorfe314812011-06-21 17:03:29 +00001714void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1715 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001716 E->State = Record.readSubExpr();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001717 auto *VD = ReadDeclAs<ValueDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001718 unsigned ManglingNumber = Record.readInt();
David Majnemerdaff3702014-05-01 17:50:17 +00001719 E->setExtendingDecl(VD, ManglingNumber);
Douglas Gregorfe314812011-06-21 17:03:29 +00001720}
1721
Richard Smith0f0af192014-11-08 05:07:16 +00001722void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
1723 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001724 E->LParenLoc = ReadSourceLocation();
1725 E->EllipsisLoc = ReadSourceLocation();
1726 E->RParenLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001727 E->SubExprs[0] = Record.readSubExpr();
1728 E->SubExprs[1] = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001729 E->Opcode = (BinaryOperatorKind)Record.readInt();
Richard Smith0f0af192014-11-08 05:07:16 +00001730}
1731
John McCall8d69a212010-11-15 23:31:06 +00001732void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1733 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001734 E->SourceExpr = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001735 E->Loc = ReadSourceLocation();
Akira Hatanaka797afe32018-03-20 01:47:58 +00001736 E->setIsUnique(Record.readInt());
John McCall8d69a212010-11-15 23:31:06 +00001737}
1738
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001739void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
1740 llvm_unreachable("Cannot read TypoExpr nodes");
1741}
1742
Peter Collingbourne41f85462011-02-09 21:07:24 +00001743//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00001744// Microsoft Expressions and Statements
1745//===----------------------------------------------------------------------===//
John McCall5e77d762013-04-16 07:28:30 +00001746void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1747 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001748 E->IsArrow = (Record.readInt() != 0);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001749 E->BaseExpr = Record.readSubExpr();
1750 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001751 E->MemberLoc = ReadSourceLocation();
1752 E->TheDecl = ReadDeclAs<MSPropertyDecl>();
John McCall5e77d762013-04-16 07:28:30 +00001753}
1754
Alexey Bataevf7630272015-11-25 12:01:00 +00001755void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
1756 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001757 E->setBase(Record.readSubExpr());
1758 E->setIdx(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001759 E->setRBracketLoc(ReadSourceLocation());
Alexey Bataevf7630272015-11-25 12:01:00 +00001760}
1761
John McCallfa194042011-07-15 07:00:14 +00001762void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1763 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001764 E->setSourceRange(ReadSourceRange());
1765 std::string UuidStr = ReadString();
1766 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
John McCallfa194042011-07-15 07:00:14 +00001767 if (E->isTypeOperand()) { // __uuidof(ComType)
1768 E->setTypeOperandSourceInfo(
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001769 GetTypeSourceInfo());
John McCallfa194042011-07-15 07:00:14 +00001770 return;
1771 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001772
John McCallfa194042011-07-15 07:00:14 +00001773 // __uuidof(expr)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001774 E->setExprOperand(Record.readSubExpr());
John McCallfa194042011-07-15 07:00:14 +00001775}
1776
Nico Weber9b982072014-07-07 00:12:30 +00001777void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1778 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001779 S->setLeaveLoc(ReadSourceLocation());
Nico Weber9b982072014-07-07 00:12:30 +00001780}
1781
John McCallfa194042011-07-15 07:00:14 +00001782void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1783 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001784 S->Loc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001785 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
1786 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001787}
1788
1789void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1790 VisitStmt(S);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001791 S->Loc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001792 S->Block = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001793}
1794
1795void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1796 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001797 S->IsCXXTry = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001798 S->TryLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001799 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
1800 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001801}
1802
1803//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00001804// CUDA Expressions and Statements
1805//===----------------------------------------------------------------------===//
1806
1807void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1808 VisitCallExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001809 E->setConfig(cast<CallExpr>(Record.readSubExpr()));
Peter Collingbourne41f85462011-02-09 21:07:24 +00001810}
1811
John McCallfa194042011-07-15 07:00:14 +00001812//===----------------------------------------------------------------------===//
1813// OpenCL Expressions and Statements.
1814//===----------------------------------------------------------------------===//
1815void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1816 VisitExpr(E);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001817 E->BuiltinLoc = ReadSourceLocation();
1818 E->RParenLoc = ReadSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001819 E->SrcExpr = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00001820}
1821
1822//===----------------------------------------------------------------------===//
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001823// OpenMP Directives.
1824//===----------------------------------------------------------------------===//
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001825
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001826void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001827 E->setLocStart(ReadSourceLocation());
1828 E->setLocEnd(ReadSourceLocation());
Kelvin Libe286f52018-09-15 13:54:15 +00001829 OMPClauseReader ClauseReader(Record);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001830 SmallVector<OMPClause *, 5> Clauses;
1831 for (unsigned i = 0; i < E->getNumClauses(); ++i)
1832 Clauses.push_back(ClauseReader.readClause());
1833 E->setClauses(Clauses);
Alexey Bataev68446b72014-07-18 07:47:19 +00001834 if (E->hasAssociatedStmt())
David L. Jonesb6a8f022016-12-21 04:34:52 +00001835 E->setAssociatedStmt(Record.readSubStmt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001836}
1837
Alexander Musman3aaab662014-08-19 11:27:13 +00001838void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
1839 VisitStmt(D);
1840 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001841 Record.skipInts(2);
Alexander Musman3aaab662014-08-19 11:27:13 +00001842 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001843 D->setIterationVariable(Record.readSubExpr());
1844 D->setLastIteration(Record.readSubExpr());
1845 D->setCalcLastIteration(Record.readSubExpr());
1846 D->setPreCond(Record.readSubExpr());
1847 D->setCond(Record.readSubExpr());
1848 D->setInit(Record.readSubExpr());
1849 D->setInc(Record.readSubExpr());
1850 D->setPreInits(Record.readSubStmt());
Alexey Bataev3392d762016-02-16 11:18:12 +00001851 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
Carlo Bertollifc35ad22016-03-07 16:04:49 +00001852 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
1853 isOpenMPDistributeDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001854 D->setIsLastIterVariable(Record.readSubExpr());
1855 D->setLowerBoundVariable(Record.readSubExpr());
1856 D->setUpperBoundVariable(Record.readSubExpr());
1857 D->setStrideVariable(Record.readSubExpr());
1858 D->setEnsureUpperBound(Record.readSubExpr());
1859 D->setNextLowerBound(Record.readSubExpr());
1860 D->setNextUpperBound(Record.readSubExpr());
1861 D->setNumIterations(Record.readSubExpr());
Alexander Musmanc6388682014-12-15 07:07:06 +00001862 }
Carlo Bertolli9925f152016-06-27 14:55:37 +00001863 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001864 D->setPrevLowerBoundVariable(Record.readSubExpr());
1865 D->setPrevUpperBoundVariable(Record.readSubExpr());
Carlo Bertolli8429d812017-02-17 21:29:13 +00001866 D->setDistInc(Record.readSubExpr());
1867 D->setPrevEnsureUpperBound(Record.readSubExpr());
Carlo Bertolliffafe102017-04-20 00:39:39 +00001868 D->setCombinedLowerBoundVariable(Record.readSubExpr());
1869 D->setCombinedUpperBoundVariable(Record.readSubExpr());
1870 D->setCombinedEnsureUpperBound(Record.readSubExpr());
1871 D->setCombinedInit(Record.readSubExpr());
1872 D->setCombinedCond(Record.readSubExpr());
1873 D->setCombinedNextLowerBound(Record.readSubExpr());
1874 D->setCombinedNextUpperBound(Record.readSubExpr());
Carlo Bertolli9925f152016-06-27 14:55:37 +00001875 }
Alexander Musmana5f070a2014-10-01 06:03:56 +00001876 SmallVector<Expr *, 4> Sub;
1877 unsigned CollapsedNum = D->getCollapsedNumber();
1878 Sub.reserve(CollapsedNum);
1879 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001880 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00001881 D->setCounters(Sub);
1882 Sub.clear();
1883 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001884 Sub.push_back(Record.readSubExpr());
Alexey Bataeva8899172015-08-06 12:30:57 +00001885 D->setPrivateCounters(Sub);
1886 Sub.clear();
1887 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001888 Sub.push_back(Record.readSubExpr());
Alexey Bataevb08f89f2015-08-14 12:25:37 +00001889 D->setInits(Sub);
1890 Sub.clear();
1891 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001892 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00001893 D->setUpdates(Sub);
1894 Sub.clear();
1895 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001896 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00001897 D->setFinals(Sub);
Alexander Musman3aaab662014-08-19 11:27:13 +00001898}
1899
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001900void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
Alexey Bataev1b59ab52014-02-27 08:29:12 +00001901 VisitStmt(D);
1902 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001903 Record.skipInts(1);
Alexey Bataev1b59ab52014-02-27 08:29:12 +00001904 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001905 D->setHasCancel(Record.readInt());
Alexey Bataev1b59ab52014-02-27 08:29:12 +00001906}
1907
1908void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00001909 VisitOMPLoopDirective(D);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00001910}
1911
Alexey Bataevf29276e2014-06-18 04:14:57 +00001912void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00001913 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001914 D->setHasCancel(Record.readInt());
Alexey Bataevf29276e2014-06-18 04:14:57 +00001915}
1916
Alexander Musmanf82886e2014-09-18 05:12:34 +00001917void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
1918 VisitOMPLoopDirective(D);
1919}
1920
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00001921void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
1922 VisitStmt(D);
1923 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001924 Record.skipInts(1);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00001925 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001926 D->setHasCancel(Record.readInt());
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00001927}
1928
Alexey Bataev1e0498a2014-06-26 08:21:58 +00001929void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
1930 VisitStmt(D);
1931 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001932 D->setHasCancel(Record.readInt());
Alexey Bataev1e0498a2014-06-26 08:21:58 +00001933}
1934
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00001935void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
1936 VisitStmt(D);
1937 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001938 Record.skipInts(1);
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00001939 VisitOMPExecutableDirective(D);
1940}
1941
Alexander Musman80c22892014-07-17 08:54:58 +00001942void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
1943 VisitStmt(D);
1944 VisitOMPExecutableDirective(D);
1945}
1946
Alexander Musmand9ed09f2014-07-21 09:42:05 +00001947void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
1948 VisitStmt(D);
Alexey Bataev28c75412015-12-15 08:19:24 +00001949 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001950 Record.skipInts(1);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00001951 VisitOMPExecutableDirective(D);
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001952 ReadDeclarationNameInfo(D->DirName);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00001953}
1954
Alexey Bataev4acb8592014-07-07 13:01:15 +00001955void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00001956 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001957 D->setHasCancel(Record.readInt());
Alexey Bataev4acb8592014-07-07 13:01:15 +00001958}
1959
Alexander Musmane4e893b2014-09-23 09:33:00 +00001960void ASTStmtReader::VisitOMPParallelForSimdDirective(
1961 OMPParallelForSimdDirective *D) {
1962 VisitOMPLoopDirective(D);
1963}
1964
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00001965void ASTStmtReader::VisitOMPParallelSectionsDirective(
1966 OMPParallelSectionsDirective *D) {
1967 VisitStmt(D);
1968 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001969 Record.skipInts(1);
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00001970 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001971 D->setHasCancel(Record.readInt());
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00001972}
1973
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00001974void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
1975 VisitStmt(D);
1976 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00001977 Record.skipInts(1);
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00001978 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001979 D->setHasCancel(Record.readInt());
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00001980}
1981
Alexey Bataev68446b72014-07-18 07:47:19 +00001982void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
1983 VisitStmt(D);
1984 VisitOMPExecutableDirective(D);
1985}
1986
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00001987void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
1988 VisitStmt(D);
1989 VisitOMPExecutableDirective(D);
1990}
1991
Alexey Bataev2df347a2014-07-18 10:17:07 +00001992void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
1993 VisitStmt(D);
1994 VisitOMPExecutableDirective(D);
1995}
1996
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00001997void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
1998 VisitStmt(D);
Alexey Bataev169d96a2017-07-18 20:17:46 +00001999 // The NumClauses field was read in ReadStmtFromStream.
2000 Record.skipInts(1);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002001 VisitOMPExecutableDirective(D);
Alexey Bataev3b1b8952017-07-25 15:53:26 +00002002 D->setReductionRef(Record.readSubExpr());
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002003}
2004
Alexey Bataev6125da92014-07-21 11:26:11 +00002005void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2006 VisitStmt(D);
2007 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002008 Record.skipInts(1);
Alexey Bataev6125da92014-07-21 11:26:11 +00002009 VisitOMPExecutableDirective(D);
2010}
2011
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002012void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2013 VisitStmt(D);
Alexey Bataev346265e2015-09-25 10:37:12 +00002014 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002015 Record.skipInts(1);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002016 VisitOMPExecutableDirective(D);
2017}
2018
Alexey Bataev0162e452014-07-22 10:10:35 +00002019void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2020 VisitStmt(D);
2021 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002022 Record.skipInts(1);
Alexey Bataev0162e452014-07-22 10:10:35 +00002023 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002024 D->setX(Record.readSubExpr());
2025 D->setV(Record.readSubExpr());
2026 D->setExpr(Record.readSubExpr());
2027 D->setUpdateExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002028 D->IsXLHSInRHSPart = Record.readInt() != 0;
2029 D->IsPostfixUpdate = Record.readInt() != 0;
Alexey Bataev0162e452014-07-22 10:10:35 +00002030}
2031
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002032void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2033 VisitStmt(D);
2034 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002035 Record.skipInts(1);
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002036 VisitOMPExecutableDirective(D);
2037}
2038
Michael Wong65f367f2015-07-21 13:44:28 +00002039void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2040 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002041 Record.skipInts(1);
Michael Wong65f367f2015-07-21 13:44:28 +00002042 VisitOMPExecutableDirective(D);
2043}
2044
Samuel Antaodf67fc42016-01-19 19:15:56 +00002045void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2046 OMPTargetEnterDataDirective *D) {
2047 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002048 Record.skipInts(1);
Samuel Antaodf67fc42016-01-19 19:15:56 +00002049 VisitOMPExecutableDirective(D);
2050}
2051
Samuel Antao72590762016-01-19 20:04:50 +00002052void ASTStmtReader::VisitOMPTargetExitDataDirective(
2053 OMPTargetExitDataDirective *D) {
2054 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002055 Record.skipInts(1);
Samuel Antao72590762016-01-19 20:04:50 +00002056 VisitOMPExecutableDirective(D);
2057}
2058
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002059void ASTStmtReader::VisitOMPTargetParallelDirective(
2060 OMPTargetParallelDirective *D) {
2061 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002062 Record.skipInts(1);
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002063 VisitOMPExecutableDirective(D);
2064}
2065
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002066void ASTStmtReader::VisitOMPTargetParallelForDirective(
2067 OMPTargetParallelForDirective *D) {
2068 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002069 D->setHasCancel(Record.readInt());
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002070}
2071
Alexey Bataev13314bf2014-10-09 04:18:56 +00002072void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2073 VisitStmt(D);
2074 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002075 Record.skipInts(1);
Alexey Bataev13314bf2014-10-09 04:18:56 +00002076 VisitOMPExecutableDirective(D);
2077}
2078
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002079void ASTStmtReader::VisitOMPCancellationPointDirective(
2080 OMPCancellationPointDirective *D) {
2081 VisitStmt(D);
2082 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002083 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002084}
2085
Alexey Bataev80909872015-07-02 11:25:17 +00002086void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2087 VisitStmt(D);
Alexey Bataev87933c72015-09-18 08:07:34 +00002088 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002089 Record.skipInts(1);
Alexey Bataev80909872015-07-02 11:25:17 +00002090 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002091 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev80909872015-07-02 11:25:17 +00002092}
2093
Alexey Bataev49f6e782015-12-01 04:18:41 +00002094void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2095 VisitOMPLoopDirective(D);
2096}
2097
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002098void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2099 VisitOMPLoopDirective(D);
2100}
2101
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002102void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2103 VisitOMPLoopDirective(D);
2104}
2105
Samuel Antao686c70c2016-05-26 17:30:50 +00002106void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2107 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002108 Record.skipInts(1);
Samuel Antao686c70c2016-05-26 17:30:50 +00002109 VisitOMPExecutableDirective(D);
2110}
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002111
Carlo Bertolli9925f152016-06-27 14:55:37 +00002112void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2113 OMPDistributeParallelForDirective *D) {
2114 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002115 D->setHasCancel(Record.readInt());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002116}
Samuel Antao686c70c2016-05-26 17:30:50 +00002117
Kelvin Li4a39add2016-07-05 05:00:15 +00002118void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2119 OMPDistributeParallelForSimdDirective *D) {
2120 VisitOMPLoopDirective(D);
2121}
2122
Kelvin Li787f3fc2016-07-06 04:45:38 +00002123void ASTStmtReader::VisitOMPDistributeSimdDirective(
2124 OMPDistributeSimdDirective *D) {
2125 VisitOMPLoopDirective(D);
2126}
2127
Kelvin Lia579b912016-07-14 02:54:56 +00002128void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2129 OMPTargetParallelForSimdDirective *D) {
2130 VisitOMPLoopDirective(D);
2131}
2132
Kelvin Li986330c2016-07-20 22:57:10 +00002133void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2134 VisitOMPLoopDirective(D);
2135}
2136
Kelvin Li02532872016-08-05 14:37:37 +00002137void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2138 OMPTeamsDistributeDirective *D) {
2139 VisitOMPLoopDirective(D);
2140}
2141
Kelvin Li4e325f72016-10-25 12:50:55 +00002142void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2143 OMPTeamsDistributeSimdDirective *D) {
2144 VisitOMPLoopDirective(D);
2145}
2146
Kelvin Li579e41c2016-11-30 23:51:03 +00002147void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2148 OMPTeamsDistributeParallelForSimdDirective *D) {
2149 VisitOMPLoopDirective(D);
2150}
2151
Kelvin Li7ade93f2016-12-09 03:24:30 +00002152void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2153 OMPTeamsDistributeParallelForDirective *D) {
2154 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002155 D->setHasCancel(Record.readInt());
Kelvin Li7ade93f2016-12-09 03:24:30 +00002156}
2157
Kelvin Libf594a52016-12-17 05:48:59 +00002158void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2159 VisitStmt(D);
2160 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002161 Record.skipInts(1);
Kelvin Libf594a52016-12-17 05:48:59 +00002162 VisitOMPExecutableDirective(D);
2163}
2164
Kelvin Li83c451e2016-12-25 04:52:54 +00002165void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2166 OMPTargetTeamsDistributeDirective *D) {
2167 VisitOMPLoopDirective(D);
2168}
2169
Kelvin Li80e8f562016-12-29 22:16:30 +00002170void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2171 OMPTargetTeamsDistributeParallelForDirective *D) {
2172 VisitOMPLoopDirective(D);
Alexey Bataev16e79882017-11-22 21:12:03 +00002173 D->setHasCancel(Record.readInt());
Kelvin Li80e8f562016-12-29 22:16:30 +00002174}
2175
Kelvin Li1851df52017-01-03 05:23:48 +00002176void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2177 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2178 VisitOMPLoopDirective(D);
2179}
2180
Kelvin Lida681182017-01-10 18:08:18 +00002181void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2182 OMPTargetTeamsDistributeSimdDirective *D) {
2183 VisitOMPLoopDirective(D);
2184}
2185
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002186//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002187// ASTReader Implementation
2188//===----------------------------------------------------------------------===//
2189
Douglas Gregorde3ef502011-11-30 23:21:26 +00002190Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002191 switch (ReadingKind) {
Richard Smith629ff362013-07-31 00:26:46 +00002192 case Read_None:
2193 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002194 case Read_Decl:
2195 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00002196 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002197 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002198 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002199 }
2200
2201 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002202}
2203
Douglas Gregorde3ef502011-11-30 23:21:26 +00002204Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00002205 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002206}
Chris Lattnere2437f42010-05-09 06:40:08 +00002207
Sebastian Redl2c499f62010-08-18 23:56:43 +00002208Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002209 return cast_or_null<Expr>(ReadSubStmt());
2210}
2211
Chris Lattnerf4262532009-04-27 05:41:06 +00002212// Within the bitstream, expressions are stored in Reverse Polish
2213// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002214// expression they are stored in. Subexpressions are stored from last to first.
2215// To evaluate expressions, we continue reading expressions and placing them on
2216// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00002217// stack. Evaluation terminates when we see a STMT_STOP record, and
2218// the single remaining expression on the stack is our result.
Douglas Gregorde3ef502011-11-30 23:21:26 +00002219Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002220 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00002221 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002222
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002223 // Map of offset to previously deserialized stmt. The offset points
George Burgess IV758cf9d2017-02-14 05:52:57 +00002224 // just after the stmt record.
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002225 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00002226
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002227#ifndef NDEBUG
2228 unsigned PrevNumStmts = StmtStack.size();
2229#endif
2230
David L. Jonesbe1557a2016-12-21 00:17:49 +00002231 ASTRecordReader Record(*this, F);
2232 ASTStmtReader Reader(Record, Cursor);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002233 Stmt::EmptyShell Empty;
2234
2235 while (true) {
Chris Lattner0e6c9402013-01-20 02:38:54 +00002236 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002237
Chris Lattner0e6c9402013-01-20 02:38:54 +00002238 switch (Entry.Kind) {
2239 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2240 case llvm::BitstreamEntry::Error:
2241 Error("malformed block record in AST file");
Craig Toppera13603a2014-05-22 05:54:18 +00002242 return nullptr;
Chris Lattner0e6c9402013-01-20 02:38:54 +00002243 case llvm::BitstreamEntry::EndBlock:
2244 goto Done;
2245 case llvm::BitstreamEntry::Record:
2246 // The interesting case.
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002247 break;
2248 }
2249
Richard Smithdbafb6c2017-06-29 23:23:46 +00002250 ASTContext &Context = getContext();
Craig Toppera13603a2014-05-22 05:54:18 +00002251 Stmt *S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002252 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002253 bool IsStmtReference = false;
David L. Jonesbe1557a2016-12-21 00:17:49 +00002254 switch ((StmtCode)Record.readRecord(Cursor, Entry.ID)) {
Sebastian Redl539c5062010-08-18 23:57:32 +00002255 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002256 Finished = true;
2257 break;
2258
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002259 case STMT_REF_PTR:
2260 IsStmtReference = true;
2261 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2262 "No stmt was recorded for this offset reference!");
David L. Jonesbe1557a2016-12-21 00:17:49 +00002263 S = StmtEntries[Record.readInt()];
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002264 break;
2265
Sebastian Redl539c5062010-08-18 23:57:32 +00002266 case STMT_NULL_PTR:
Craig Toppera13603a2014-05-22 05:54:18 +00002267 S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002268 break;
2269
Sebastian Redl539c5062010-08-18 23:57:32 +00002270 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002271 S = new (Context) NullStmt(Empty);
2272 break;
2273
Sebastian Redl539c5062010-08-18 23:57:32 +00002274 case STMT_COMPOUND:
Benjamin Kramer07420902017-12-24 16:24:20 +00002275 S = CompoundStmt::CreateEmpty(
2276 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002277 break;
2278
Sebastian Redl539c5062010-08-18 23:57:32 +00002279 case STMT_CASE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002280 S = new (Context) CaseStmt(Empty);
2281 break;
2282
Sebastian Redl539c5062010-08-18 23:57:32 +00002283 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002284 S = new (Context) DefaultStmt(Empty);
2285 break;
2286
Sebastian Redl539c5062010-08-18 23:57:32 +00002287 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002288 S = new (Context) LabelStmt(Empty);
2289 break;
2290
Richard Smithc202b282012-04-14 00:33:13 +00002291 case STMT_ATTRIBUTED:
Alexander Kornienko20f6fc62012-07-09 10:04:07 +00002292 S = AttributedStmt::CreateEmpty(
2293 Context,
2294 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smithc202b282012-04-14 00:33:13 +00002295 break;
2296
Sebastian Redl539c5062010-08-18 23:57:32 +00002297 case STMT_IF:
Bruno Riccib1cc94b2018-10-27 21:12:20 +00002298 S = IfStmt::CreateEmpty(
2299 Context,
2300 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2301 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2302 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002303 break;
2304
Sebastian Redl539c5062010-08-18 23:57:32 +00002305 case STMT_SWITCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002306 S = new (Context) SwitchStmt(Empty);
2307 break;
2308
Sebastian Redl539c5062010-08-18 23:57:32 +00002309 case STMT_WHILE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002310 S = new (Context) WhileStmt(Empty);
2311 break;
2312
Sebastian Redl539c5062010-08-18 23:57:32 +00002313 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002314 S = new (Context) DoStmt(Empty);
2315 break;
Mike Stump11289f42009-09-09 15:08:12 +00002316
Sebastian Redl539c5062010-08-18 23:57:32 +00002317 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002318 S = new (Context) ForStmt(Empty);
2319 break;
2320
Sebastian Redl539c5062010-08-18 23:57:32 +00002321 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002322 S = new (Context) GotoStmt(Empty);
2323 break;
Mike Stump11289f42009-09-09 15:08:12 +00002324
Sebastian Redl539c5062010-08-18 23:57:32 +00002325 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002326 S = new (Context) IndirectGotoStmt(Empty);
2327 break;
2328
Sebastian Redl539c5062010-08-18 23:57:32 +00002329 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002330 S = new (Context) ContinueStmt(Empty);
2331 break;
2332
Sebastian Redl539c5062010-08-18 23:57:32 +00002333 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002334 S = new (Context) BreakStmt(Empty);
2335 break;
2336
Sebastian Redl539c5062010-08-18 23:57:32 +00002337 case STMT_RETURN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002338 S = new (Context) ReturnStmt(Empty);
2339 break;
2340
Sebastian Redl539c5062010-08-18 23:57:32 +00002341 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002342 S = new (Context) DeclStmt(Empty);
2343 break;
2344
Chad Rosierde70e0e2012-08-25 00:11:56 +00002345 case STMT_GCCASM:
2346 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002347 break;
2348
Chad Rosiere30d4992012-08-24 23:51:02 +00002349 case STMT_MSASM:
2350 S = new (Context) MSAsmStmt(Empty);
2351 break;
2352
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002353 case STMT_CAPTURED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002354 S = CapturedStmt::CreateDeserialized(
2355 Context, Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002356 break;
2357
Sebastian Redl539c5062010-08-18 23:57:32 +00002358 case EXPR_PREDEFINED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002359 S = PredefinedExpr::CreateEmpty(
2360 Context,
2361 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002362 break;
Mike Stump11289f42009-09-09 15:08:12 +00002363
Sebastian Redl539c5062010-08-18 23:57:32 +00002364 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002365 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00002366 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002367 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2368 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnara7945c982012-01-27 09:46:47 +00002369 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002370 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
John McCall113bee02012-03-10 09:33:50 +00002371 Record[ASTStmtReader::NumExprFields + 5] : 0);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002372 break;
Mike Stump11289f42009-09-09 15:08:12 +00002373
Sebastian Redl539c5062010-08-18 23:57:32 +00002374 case EXPR_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002375 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002376 break;
Mike Stump11289f42009-09-09 15:08:12 +00002377
Sebastian Redl539c5062010-08-18 23:57:32 +00002378 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002379 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002380 break;
Mike Stump11289f42009-09-09 15:08:12 +00002381
Sebastian Redl539c5062010-08-18 23:57:32 +00002382 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002383 S = new (Context) ImaginaryLiteral(Empty);
2384 break;
2385
Sebastian Redl539c5062010-08-18 23:57:32 +00002386 case EXPR_STRING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002387 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002388 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002389 break;
2390
Sebastian Redl539c5062010-08-18 23:57:32 +00002391 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002392 S = new (Context) CharacterLiteral(Empty);
2393 break;
2394
Sebastian Redl539c5062010-08-18 23:57:32 +00002395 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002396 S = new (Context) ParenExpr(Empty);
2397 break;
2398
Sebastian Redl539c5062010-08-18 23:57:32 +00002399 case EXPR_PAREN_LIST:
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00002400 S = new (Context) ParenListExpr(Empty);
2401 break;
2402
Sebastian Redl539c5062010-08-18 23:57:32 +00002403 case EXPR_UNARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002404 S = new (Context) UnaryOperator(Empty);
2405 break;
2406
Sebastian Redl539c5062010-08-18 23:57:32 +00002407 case EXPR_OFFSETOF:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002408 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002409 Record[ASTStmtReader::NumExprFields],
2410 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00002411 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002412
Sebastian Redl539c5062010-08-18 23:57:32 +00002413 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00002414 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002415 break;
2416
Sebastian Redl539c5062010-08-18 23:57:32 +00002417 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002418 S = new (Context) ArraySubscriptExpr(Empty);
2419 break;
2420
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002421 case EXPR_OMP_ARRAY_SECTION:
2422 S = new (Context) OMPArraySectionExpr(Empty);
2423 break;
2424
Sebastian Redl539c5062010-08-18 23:57:32 +00002425 case EXPR_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002426 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002427 break;
2428
Sebastian Redl539c5062010-08-18 23:57:32 +00002429 case EXPR_MEMBER: {
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002430 // We load everything here and fully initialize it at creation.
2431 // That way we can use MemberExpr::Create and don't have to duplicate its
2432 // logic with a MemberExpr::CreateEmpty.
2433
David L. Jonesbe1557a2016-12-21 00:17:49 +00002434 assert(Record.getIdx() == 0);
Douglas Gregorea972d32011-02-28 21:54:11 +00002435 NestedNameSpecifierLoc QualifierLoc;
David L. Jonesbe1557a2016-12-21 00:17:49 +00002436 if (Record.readInt()) { // HasQualifier.
David L. Jonesb6a8f022016-12-21 04:34:52 +00002437 QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002438 }
2439
Abramo Bagnara7945c982012-01-27 09:46:47 +00002440 SourceLocation TemplateKWLoc;
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002441 TemplateArgumentListInfo ArgInfo;
David L. Jonesbe1557a2016-12-21 00:17:49 +00002442 bool HasTemplateKWAndArgsInfo = Record.readInt();
Abramo Bagnara7945c982012-01-27 09:46:47 +00002443 if (HasTemplateKWAndArgsInfo) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002444 TemplateKWLoc = Record.readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002445 unsigned NumTemplateArgs = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002446 ArgInfo.setLAngleLoc(Record.readSourceLocation());
2447 ArgInfo.setRAngleLoc(Record.readSourceLocation());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002448 for (unsigned i = 0; i != NumTemplateArgs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002449 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002450 }
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00002451
David L. Jonesbe1557a2016-12-21 00:17:49 +00002452 bool HadMultipleCandidates = Record.readInt();
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00002453
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002454 auto *FoundD = Record.readDeclAs<NamedDecl>();
2455 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002456 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
2457
David L. Jonesbe1557a2016-12-21 00:17:49 +00002458 QualType T = Record.readType();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002459 auto VK = static_cast<ExprValueKind>(Record.readInt());
2460 auto OK = static_cast<ExprObjectKind>(Record.readInt());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002461 Expr *Base = ReadSubExpr();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002462 auto *MemberD = Record.readDeclAs<ValueDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002463 SourceLocation MemberLoc = Record.readSourceLocation();
Yunzhong Gaoeba323a2015-05-01 02:04:32 +00002464 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002465 bool IsArrow = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002466 SourceLocation OperatorLoc = Record.readSourceLocation();
Yunzhong Gaoeba323a2015-05-01 02:04:32 +00002467
2468 S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc,
2469 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
2470 HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T,
2471 VK, OK);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002472 Record.readDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc,
David L. Jonesbe1557a2016-12-21 00:17:49 +00002473 MemberD->getDeclName());
Yunzhong Gaoeba323a2015-05-01 02:04:32 +00002474 if (HadMultipleCandidates)
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00002475 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002476 break;
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00002477 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002478
Sebastian Redl539c5062010-08-18 23:57:32 +00002479 case EXPR_BINARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002480 S = new (Context) BinaryOperator(Empty);
2481 break;
2482
Sebastian Redl539c5062010-08-18 23:57:32 +00002483 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002484 S = new (Context) CompoundAssignOperator(Empty);
2485 break;
2486
Sebastian Redl539c5062010-08-18 23:57:32 +00002487 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002488 S = new (Context) ConditionalOperator(Empty);
2489 break;
2490
John McCallc07a0c72011-02-17 10:25:35 +00002491 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2492 S = new (Context) BinaryConditionalOperator(Empty);
2493 break;
2494
Sebastian Redl539c5062010-08-18 23:57:32 +00002495 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002496 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002497 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002498 break;
2499
Sebastian Redl539c5062010-08-18 23:57:32 +00002500 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002501 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002502 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002503 break;
2504
Sebastian Redl539c5062010-08-18 23:57:32 +00002505 case EXPR_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002506 S = new (Context) CompoundLiteralExpr(Empty);
2507 break;
2508
Sebastian Redl539c5062010-08-18 23:57:32 +00002509 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002510 S = new (Context) ExtVectorElementExpr(Empty);
2511 break;
2512
Sebastian Redl539c5062010-08-18 23:57:32 +00002513 case EXPR_INIT_LIST:
Argyrios Kyrtzidis0f05fb92012-11-28 03:56:16 +00002514 S = new (Context) InitListExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002515 break;
2516
Sebastian Redl539c5062010-08-18 23:57:32 +00002517 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002518 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002519 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00002520
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002521 break;
2522
Yunzhong Gaocb779302015-06-10 00:27:52 +00002523 case EXPR_DESIGNATED_INIT_UPDATE:
2524 S = new (Context) DesignatedInitUpdateExpr(Empty);
2525 break;
2526
Sebastian Redl539c5062010-08-18 23:57:32 +00002527 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002528 S = new (Context) ImplicitValueInitExpr(Empty);
2529 break;
2530
Yunzhong Gaocb779302015-06-10 00:27:52 +00002531 case EXPR_NO_INIT:
2532 S = new (Context) NoInitExpr(Empty);
2533 break;
2534
Richard Smith410306b2016-12-12 02:53:20 +00002535 case EXPR_ARRAY_INIT_LOOP:
2536 S = new (Context) ArrayInitLoopExpr(Empty);
2537 break;
2538
2539 case EXPR_ARRAY_INIT_INDEX:
2540 S = new (Context) ArrayInitIndexExpr(Empty);
2541 break;
2542
Sebastian Redl539c5062010-08-18 23:57:32 +00002543 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002544 S = new (Context) VAArgExpr(Empty);
2545 break;
2546
Sebastian Redl539c5062010-08-18 23:57:32 +00002547 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002548 S = new (Context) AddrLabelExpr(Empty);
2549 break;
2550
Sebastian Redl539c5062010-08-18 23:57:32 +00002551 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002552 S = new (Context) StmtExpr(Empty);
2553 break;
2554
Sebastian Redl539c5062010-08-18 23:57:32 +00002555 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002556 S = new (Context) ChooseExpr(Empty);
2557 break;
2558
Sebastian Redl539c5062010-08-18 23:57:32 +00002559 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002560 S = new (Context) GNUNullExpr(Empty);
2561 break;
2562
Sebastian Redl539c5062010-08-18 23:57:32 +00002563 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002564 S = new (Context) ShuffleVectorExpr(Empty);
2565 break;
Mike Stump11289f42009-09-09 15:08:12 +00002566
Hal Finkelc4d7c822013-09-18 03:29:45 +00002567 case EXPR_CONVERT_VECTOR:
2568 S = new (Context) ConvertVectorExpr(Empty);
2569 break;
2570
Sebastian Redl539c5062010-08-18 23:57:32 +00002571 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002572 S = new (Context) BlockExpr(Empty);
2573 break;
2574
Peter Collingbourne91147592011-04-15 00:35:48 +00002575 case EXPR_GENERIC_SELECTION:
2576 S = new (Context) GenericSelectionExpr(Empty);
2577 break;
2578
Sebastian Redl539c5062010-08-18 23:57:32 +00002579 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002580 S = new (Context) ObjCStringLiteral(Empty);
2581 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002582
Patrick Beard0caa3942012-04-19 00:25:12 +00002583 case EXPR_OBJC_BOXED_EXPRESSION:
2584 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremeneke65b0862012-03-06 20:05:56 +00002585 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002586
Ted Kremeneke65b0862012-03-06 20:05:56 +00002587 case EXPR_OBJC_ARRAY_LITERAL:
2588 S = ObjCArrayLiteral::CreateEmpty(Context,
2589 Record[ASTStmtReader::NumExprFields]);
2590 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002591
Ted Kremeneke65b0862012-03-06 20:05:56 +00002592 case EXPR_OBJC_DICTIONARY_LITERAL:
2593 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2594 Record[ASTStmtReader::NumExprFields],
2595 Record[ASTStmtReader::NumExprFields + 1]);
2596 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002597
Sebastian Redl539c5062010-08-18 23:57:32 +00002598 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002599 S = new (Context) ObjCEncodeExpr(Empty);
2600 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002601
Sebastian Redl539c5062010-08-18 23:57:32 +00002602 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002603 S = new (Context) ObjCSelectorExpr(Empty);
2604 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002605
Sebastian Redl539c5062010-08-18 23:57:32 +00002606 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002607 S = new (Context) ObjCProtocolExpr(Empty);
2608 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002609
Sebastian Redl539c5062010-08-18 23:57:32 +00002610 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002611 S = new (Context) ObjCIvarRefExpr(Empty);
2612 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002613
Sebastian Redl539c5062010-08-18 23:57:32 +00002614 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002615 S = new (Context) ObjCPropertyRefExpr(Empty);
2616 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002617
Ted Kremeneke65b0862012-03-06 20:05:56 +00002618 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2619 S = new (Context) ObjCSubscriptRefExpr(Empty);
2620 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002621
Sebastian Redl539c5062010-08-18 23:57:32 +00002622 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00002623 llvm_unreachable("mismatching AST file");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002624
Sebastian Redl539c5062010-08-18 23:57:32 +00002625 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002626 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00002627 Record[ASTStmtReader::NumExprFields],
2628 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002629 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002630
Sebastian Redl539c5062010-08-18 23:57:32 +00002631 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00002632 S = new (Context) ObjCIsaExpr(Empty);
2633 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002634
John McCall31168b02011-06-15 23:02:42 +00002635 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2636 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2637 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002638
John McCall31168b02011-06-15 23:02:42 +00002639 case EXPR_OBJC_BRIDGED_CAST:
2640 S = new (Context) ObjCBridgedCastExpr(Empty);
2641 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002642
Sebastian Redl539c5062010-08-18 23:57:32 +00002643 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002644 S = new (Context) ObjCForCollectionStmt(Empty);
2645 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002646
Sebastian Redl539c5062010-08-18 23:57:32 +00002647 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002648 S = new (Context) ObjCAtCatchStmt(Empty);
2649 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002650
Sebastian Redl539c5062010-08-18 23:57:32 +00002651 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002652 S = new (Context) ObjCAtFinallyStmt(Empty);
2653 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002654
Sebastian Redl539c5062010-08-18 23:57:32 +00002655 case STMT_OBJC_AT_TRY:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002656 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002657 Record[ASTStmtReader::NumStmtFields],
2658 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002659 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002660
Sebastian Redl539c5062010-08-18 23:57:32 +00002661 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002662 S = new (Context) ObjCAtSynchronizedStmt(Empty);
2663 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002664
Sebastian Redl539c5062010-08-18 23:57:32 +00002665 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002666 S = new (Context) ObjCAtThrowStmt(Empty);
2667 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002668
John McCall31168b02011-06-15 23:02:42 +00002669 case STMT_OBJC_AUTORELEASE_POOL:
2670 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2671 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002672
Ted Kremeneke65b0862012-03-06 20:05:56 +00002673 case EXPR_OBJC_BOOL_LITERAL:
2674 S = new (Context) ObjCBoolLiteralExpr(Empty);
2675 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002676
Erik Pilkington29099de2016-07-16 00:35:23 +00002677 case EXPR_OBJC_AVAILABILITY_CHECK:
2678 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
2679 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002680
Nico Weber9b982072014-07-07 00:12:30 +00002681 case STMT_SEH_LEAVE:
2682 S = new (Context) SEHLeaveStmt(Empty);
2683 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002684
John McCallfa194042011-07-15 07:00:14 +00002685 case STMT_SEH_EXCEPT:
2686 S = new (Context) SEHExceptStmt(Empty);
2687 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002688
John McCallfa194042011-07-15 07:00:14 +00002689 case STMT_SEH_FINALLY:
2690 S = new (Context) SEHFinallyStmt(Empty);
2691 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002692
John McCallfa194042011-07-15 07:00:14 +00002693 case STMT_SEH_TRY:
2694 S = new (Context) SEHTryStmt(Empty);
2695 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002696
Sebastian Redl539c5062010-08-18 23:57:32 +00002697 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00002698 S = new (Context) CXXCatchStmt(Empty);
2699 break;
2700
Sebastian Redl539c5062010-08-18 23:57:32 +00002701 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002702 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002703 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00002704 break;
2705
Richard Smith02e85f32011-04-14 22:09:26 +00002706 case STMT_CXX_FOR_RANGE:
2707 S = new (Context) CXXForRangeStmt(Empty);
2708 break;
2709
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00002710 case STMT_MS_DEPENDENT_EXISTS:
2711 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2712 NestedNameSpecifierLoc(),
2713 DeclarationNameInfo(),
Craig Toppera13603a2014-05-22 05:54:18 +00002714 nullptr);
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00002715 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002716
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002717 case STMT_OMP_PARALLEL_DIRECTIVE:
2718 S =
2719 OMPParallelDirective::CreateEmpty(Context,
2720 Record[ASTStmtReader::NumStmtFields],
2721 Empty);
2722 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002723
2724 case STMT_OMP_SIMD_DIRECTIVE: {
2725 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2726 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2727 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
2728 CollapsedNum, Empty);
2729 break;
2730 }
2731
Alexey Bataevf29276e2014-06-18 04:14:57 +00002732 case STMT_OMP_FOR_DIRECTIVE: {
2733 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2734 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2735 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2736 Empty);
2737 break;
2738 }
2739
Alexander Musmanf82886e2014-09-18 05:12:34 +00002740 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
2741 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2742 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2743 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2744 Empty);
2745 break;
2746 }
2747
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002748 case STMT_OMP_SECTIONS_DIRECTIVE:
2749 S = OMPSectionsDirective::CreateEmpty(
2750 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2751 break;
2752
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002753 case STMT_OMP_SECTION_DIRECTIVE:
2754 S = OMPSectionDirective::CreateEmpty(Context, Empty);
2755 break;
2756
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002757 case STMT_OMP_SINGLE_DIRECTIVE:
2758 S = OMPSingleDirective::CreateEmpty(
2759 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2760 break;
2761
Alexander Musman80c22892014-07-17 08:54:58 +00002762 case STMT_OMP_MASTER_DIRECTIVE:
2763 S = OMPMasterDirective::CreateEmpty(Context, Empty);
2764 break;
2765
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002766 case STMT_OMP_CRITICAL_DIRECTIVE:
Alexey Bataev28c75412015-12-15 08:19:24 +00002767 S = OMPCriticalDirective::CreateEmpty(
2768 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002769 break;
2770
Alexey Bataev4acb8592014-07-07 13:01:15 +00002771 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
2772 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2773 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2774 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
2775 CollapsedNum, Empty);
2776 break;
2777 }
2778
Alexander Musmane4e893b2014-09-23 09:33:00 +00002779 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
2780 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2781 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2782 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2783 CollapsedNum, Empty);
2784 break;
2785 }
2786
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002787 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
2788 S = OMPParallelSectionsDirective::CreateEmpty(
2789 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2790 break;
2791
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002792 case STMT_OMP_TASK_DIRECTIVE:
2793 S = OMPTaskDirective::CreateEmpty(
2794 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2795 break;
2796
Alexey Bataev68446b72014-07-18 07:47:19 +00002797 case STMT_OMP_TASKYIELD_DIRECTIVE:
2798 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
2799 break;
2800
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002801 case STMT_OMP_BARRIER_DIRECTIVE:
2802 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
2803 break;
2804
Alexey Bataev2df347a2014-07-18 10:17:07 +00002805 case STMT_OMP_TASKWAIT_DIRECTIVE:
2806 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
2807 break;
2808
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002809 case STMT_OMP_TASKGROUP_DIRECTIVE:
Alexey Bataev169d96a2017-07-18 20:17:46 +00002810 S = OMPTaskgroupDirective::CreateEmpty(
2811 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002812 break;
2813
Alexey Bataev6125da92014-07-21 11:26:11 +00002814 case STMT_OMP_FLUSH_DIRECTIVE:
2815 S = OMPFlushDirective::CreateEmpty(
2816 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2817 break;
2818
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002819 case STMT_OMP_ORDERED_DIRECTIVE:
Alexey Bataev346265e2015-09-25 10:37:12 +00002820 S = OMPOrderedDirective::CreateEmpty(
2821 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002822 break;
2823
Alexey Bataev0162e452014-07-22 10:10:35 +00002824 case STMT_OMP_ATOMIC_DIRECTIVE:
2825 S = OMPAtomicDirective::CreateEmpty(
2826 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2827 break;
2828
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002829 case STMT_OMP_TARGET_DIRECTIVE:
2830 S = OMPTargetDirective::CreateEmpty(
2831 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2832 break;
2833
Michael Wong65f367f2015-07-21 13:44:28 +00002834 case STMT_OMP_TARGET_DATA_DIRECTIVE:
2835 S = OMPTargetDataDirective::CreateEmpty(
2836 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2837 break;
2838
Samuel Antaodf67fc42016-01-19 19:15:56 +00002839 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
2840 S = OMPTargetEnterDataDirective::CreateEmpty(
2841 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2842 break;
2843
Samuel Antao72590762016-01-19 20:04:50 +00002844 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
2845 S = OMPTargetExitDataDirective::CreateEmpty(
2846 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2847 break;
2848
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002849 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
2850 S = OMPTargetParallelDirective::CreateEmpty(
2851 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2852 break;
2853
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002854 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
2855 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2856 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2857 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
2858 CollapsedNum, Empty);
2859 break;
2860 }
2861
Samuel Antao686c70c2016-05-26 17:30:50 +00002862 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
2863 S = OMPTargetUpdateDirective::CreateEmpty(
2864 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2865 break;
2866
Alexey Bataev13314bf2014-10-09 04:18:56 +00002867 case STMT_OMP_TEAMS_DIRECTIVE:
2868 S = OMPTeamsDirective::CreateEmpty(
2869 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2870 break;
2871
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002872 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
2873 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
2874 break;
2875
Alexey Bataev80909872015-07-02 11:25:17 +00002876 case STMT_OMP_CANCEL_DIRECTIVE:
Alexey Bataev87933c72015-09-18 08:07:34 +00002877 S = OMPCancelDirective::CreateEmpty(
2878 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev80909872015-07-02 11:25:17 +00002879 break;
2880
Alexey Bataev49f6e782015-12-01 04:18:41 +00002881 case STMT_OMP_TASKLOOP_DIRECTIVE: {
2882 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2883 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2884 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2885 Empty);
2886 break;
2887 }
2888
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002889 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
2890 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2891 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2892 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
2893 CollapsedNum, Empty);
2894 break;
2895 }
2896
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002897 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
2898 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2899 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2900 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2901 Empty);
2902 break;
2903 }
2904
Carlo Bertolli9925f152016-06-27 14:55:37 +00002905 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
2906 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2907 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2908 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
2909 CollapsedNum, Empty);
2910 break;
2911 }
2912
Kelvin Li4a39add2016-07-05 05:00:15 +00002913 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
2914 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2915 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2916 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2917 CollapsedNum,
2918 Empty);
2919 break;
2920 }
2921
Kelvin Li787f3fc2016-07-06 04:45:38 +00002922 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
2923 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2924 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2925 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
2926 CollapsedNum, Empty);
2927 break;
2928 }
2929
Kelvin Lia579b912016-07-14 02:54:56 +00002930 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
2931 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2932 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2933 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2934 CollapsedNum, Empty);
2935 break;
2936 }
2937
Kelvin Li986330c2016-07-20 22:57:10 +00002938 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
2939 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2940 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2941 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2942 Empty);
2943 break;
2944 }
2945
Kelvin Li83c451e2016-12-25 04:52:54 +00002946 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
Kelvin Li02532872016-08-05 14:37:37 +00002947 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2948 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2949 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
2950 CollapsedNum, Empty);
2951 break;
2952 }
2953
Kelvin Li4e325f72016-10-25 12:50:55 +00002954 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
2955 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2956 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2957 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
2958 CollapsedNum, Empty);
2959 break;
2960 }
2961
Kelvin Li579e41c2016-11-30 23:51:03 +00002962 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
2963 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2964 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2965 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
2966 Context, NumClauses, CollapsedNum, Empty);
2967 break;
2968 }
2969
Kelvin Li7ade93f2016-12-09 03:24:30 +00002970 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
2971 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2972 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2973 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
2974 Context, NumClauses, CollapsedNum, Empty);
2975 break;
2976 }
2977
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002978 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
Kelvin Libf594a52016-12-17 05:48:59 +00002979 S = OMPTargetTeamsDirective::CreateEmpty(
2980 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2981 break;
Kelvin Li83c451e2016-12-25 04:52:54 +00002982
2983 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
2984 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2985 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2986 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
2987 CollapsedNum, Empty);
2988 break;
2989 }
2990
Kelvin Li80e8f562016-12-29 22:16:30 +00002991 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
2992 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
2993 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2994 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
2995 Context, NumClauses, CollapsedNum, Empty);
2996 break;
2997 }
2998
Kelvin Li1851df52017-01-03 05:23:48 +00002999 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3000 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3001 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3002 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3003 Context, NumClauses, CollapsedNum, Empty);
3004 break;
3005 }
3006
Kelvin Lida681182017-01-10 18:08:18 +00003007 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3008 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3009 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3010 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3011 Context, NumClauses, CollapsedNum, Empty);
3012 break;
3013 }
3014
Sebastian Redl539c5062010-08-18 23:57:32 +00003015 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003016 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00003017 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003018
Sebastian Redl539c5062010-08-18 23:57:32 +00003019 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003020 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003021 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003022
Sebastian Redl539c5062010-08-18 23:57:32 +00003023 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003024 S = new (Context) CXXConstructExpr(Empty);
3025 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003026
Richard Smith5179eb72016-06-28 19:03:57 +00003027 case EXPR_CXX_INHERITED_CTOR_INIT:
3028 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3029 break;
3030
Sebastian Redl539c5062010-08-18 23:57:32 +00003031 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003032 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00003033 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003034
Sebastian Redl539c5062010-08-18 23:57:32 +00003035 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003036 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003037 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003038 break;
3039
Sebastian Redl539c5062010-08-18 23:57:32 +00003040 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003041 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003042 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003043 break;
3044
Sebastian Redl539c5062010-08-18 23:57:32 +00003045 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003046 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003047 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003048 break;
3049
Sebastian Redl539c5062010-08-18 23:57:32 +00003050 case EXPR_CXX_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003051 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00003052 break;
3053
Sebastian Redl539c5062010-08-18 23:57:32 +00003054 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003055 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003056 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003057 break;
3058
Richard Smithc67fdd42012-03-07 08:35:16 +00003059 case EXPR_USER_DEFINED_LITERAL:
3060 S = new (Context) UserDefinedLiteral(Context, Empty);
3061 break;
3062
Richard Smithcc1b96d2013-06-12 22:31:48 +00003063 case EXPR_CXX_STD_INITIALIZER_LIST:
3064 S = new (Context) CXXStdInitializerListExpr(Empty);
3065 break;
3066
Sebastian Redl539c5062010-08-18 23:57:32 +00003067 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003068 S = new (Context) CXXBoolLiteralExpr(Empty);
3069 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003070
Sebastian Redl539c5062010-08-18 23:57:32 +00003071 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003072 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3073 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003074
Sebastian Redl539c5062010-08-18 23:57:32 +00003075 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003076 S = new (Context) CXXTypeidExpr(Empty, true);
3077 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003078
Sebastian Redl539c5062010-08-18 23:57:32 +00003079 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003080 S = new (Context) CXXTypeidExpr(Empty, false);
3081 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003082
Francois Pichet9f4f2072010-09-08 12:20:18 +00003083 case EXPR_CXX_UUIDOF_EXPR:
3084 S = new (Context) CXXUuidofExpr(Empty, true);
3085 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003086
John McCall5e77d762013-04-16 07:28:30 +00003087 case EXPR_CXX_PROPERTY_REF_EXPR:
3088 S = new (Context) MSPropertyRefExpr(Empty);
3089 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003090
Alexey Bataevf7630272015-11-25 12:01:00 +00003091 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3092 S = new (Context) MSPropertySubscriptExpr(Empty);
3093 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003094
Francois Pichet9f4f2072010-09-08 12:20:18 +00003095 case EXPR_CXX_UUIDOF_TYPE:
3096 S = new (Context) CXXUuidofExpr(Empty, false);
3097 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003098
Sebastian Redl539c5062010-08-18 23:57:32 +00003099 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00003100 S = new (Context) CXXThisExpr(Empty);
3101 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003102
Sebastian Redl539c5062010-08-18 23:57:32 +00003103 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00003104 S = new (Context) CXXThrowExpr(Empty);
3105 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003106
John McCall32791cc2016-01-06 22:34:54 +00003107 case EXPR_CXX_DEFAULT_ARG:
3108 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00003109 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003110
Richard Smith852c9db2013-04-20 22:23:05 +00003111 case EXPR_CXX_DEFAULT_INIT:
3112 S = new (Context) CXXDefaultInitExpr(Empty);
3113 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003114
Sebastian Redl539c5062010-08-18 23:57:32 +00003115 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00003116 S = new (Context) CXXBindTemporaryExpr(Empty);
3117 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003118
Sebastian Redl539c5062010-08-18 23:57:32 +00003119 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00003120 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003121 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003122
Sebastian Redl539c5062010-08-18 23:57:32 +00003123 case EXPR_CXX_NEW:
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003124 S = new (Context) CXXNewExpr(Empty);
3125 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003126
Sebastian Redl539c5062010-08-18 23:57:32 +00003127 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00003128 S = new (Context) CXXDeleteExpr(Empty);
3129 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003130
Sebastian Redl539c5062010-08-18 23:57:32 +00003131 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00003132 S = new (Context) CXXPseudoDestructorExpr(Empty);
3133 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003134
John McCall5d413782010-12-06 08:20:24 +00003135 case EXPR_EXPR_WITH_CLEANUPS:
John McCall28fc7092011-11-10 05:35:25 +00003136 S = ExprWithCleanups::Create(Context, Empty,
3137 Record[ASTStmtReader::NumExprFields]);
Chris Lattnercba86142010-05-10 00:25:06 +00003138 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003139
Sebastian Redl539c5062010-08-18 23:57:32 +00003140 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003141 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003142 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003143 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003144 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003145 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003146 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003147
Sebastian Redl539c5062010-08-18 23:57:32 +00003148 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003149 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003150 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003151 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003152 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003153 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00003154 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003155
Sebastian Redl539c5062010-08-18 23:57:32 +00003156 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003157 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003158 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00003159 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003160
Sebastian Redl539c5062010-08-18 23:57:32 +00003161 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003162 S = UnresolvedMemberExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003163 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003164 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003165 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003166 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003167 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003168
Sebastian Redl539c5062010-08-18 23:57:32 +00003169 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003170 S = UnresolvedLookupExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003171 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003172 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003173 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003174 : 0);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00003175 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003176
Douglas Gregor29c42f22012-02-24 07:38:34 +00003177 case EXPR_TYPE_TRAIT:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003178 S = TypeTraitExpr::CreateDeserialized(Context,
Douglas Gregor29c42f22012-02-24 07:38:34 +00003179 Record[ASTStmtReader::NumExprFields]);
3180 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003181
John Wiegley6242b6a2011-04-28 00:16:57 +00003182 case EXPR_ARRAY_TYPE_TRAIT:
3183 S = new (Context) ArrayTypeTraitExpr(Empty);
3184 break;
3185
John Wiegleyf9f65842011-04-25 06:54:41 +00003186 case EXPR_CXX_EXPRESSION_TRAIT:
3187 S = new (Context) ExpressionTraitExpr(Empty);
3188 break;
3189
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003190 case EXPR_CXX_NOEXCEPT:
3191 S = new (Context) CXXNoexceptExpr(Empty);
3192 break;
John McCall8d69a212010-11-15 23:31:06 +00003193
Douglas Gregore8e9dd62011-01-03 17:17:50 +00003194 case EXPR_PACK_EXPANSION:
3195 S = new (Context) PackExpansionExpr(Empty);
3196 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003197
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003198 case EXPR_SIZEOF_PACK:
Richard Smithd784e682015-09-23 21:41:42 +00003199 S = SizeOfPackExpr::CreateDeserialized(
3200 Context,
3201 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003202 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003203
John McCallfa194042011-07-15 07:00:14 +00003204 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3205 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3206 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003207
Douglas Gregorcdbc5392011-01-15 01:15:58 +00003208 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3209 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3210 break;
Richard Smithb15fe3a2012-09-12 00:56:43 +00003211
3212 case EXPR_FUNCTION_PARM_PACK:
3213 S = FunctionParmPackExpr::CreateEmpty(Context,
3214 Record[ASTStmtReader::NumExprFields]);
3215 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003216
Douglas Gregorfe314812011-06-21 17:03:29 +00003217 case EXPR_MATERIALIZE_TEMPORARY:
3218 S = new (Context) MaterializeTemporaryExpr(Empty);
3219 break;
Richard Smith0f0af192014-11-08 05:07:16 +00003220
3221 case EXPR_CXX_FOLD:
3222 S = new (Context) CXXFoldExpr(Empty);
3223 break;
3224
Argyrios Kyrtzidisb2b07952011-12-03 03:49:52 +00003225 case EXPR_OPAQUE_VALUE:
3226 S = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00003227 break;
Peter Collingbourne41f85462011-02-09 21:07:24 +00003228
3229 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003230 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00003231 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003232
Tanya Lattner55808c12011-06-04 00:47:47 +00003233 case EXPR_ASTYPE:
3234 S = new (Context) AsTypeExpr(Empty);
3235 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003236
John McCallfe96e0b2011-11-06 09:01:30 +00003237 case EXPR_PSEUDO_OBJECT: {
3238 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3239 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3240 break;
3241 }
3242
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003243 case EXPR_ATOMIC:
3244 S = new (Context) AtomicExpr(Empty);
3245 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003246
Douglas Gregor99ae8062012-02-14 17:54:36 +00003247 case EXPR_LAMBDA: {
3248 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
Richard Smith30e304e2016-12-14 00:03:17 +00003249 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
Douglas Gregor99ae8062012-02-14 17:54:36 +00003250 break;
3251 }
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +00003252
3253 case STMT_COROUTINE_BODY: {
3254 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3255 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3256 break;
3257 }
3258
3259 case STMT_CORETURN:
3260 S = new (Context) CoreturnStmt(Empty);
3261 break;
3262
3263 case EXPR_COAWAIT:
3264 S = new (Context) CoawaitExpr(Empty);
3265 break;
3266
3267 case EXPR_COYIELD:
3268 S = new (Context) CoyieldExpr(Empty);
3269 break;
3270
3271 case EXPR_DEPENDENT_COAWAIT:
3272 S = new (Context) DependentCoawaitExpr(Empty);
3273 break;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003274 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003275
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003276 // We hit a STMT_STOP, so we're done with this expression.
3277 if (Finished)
3278 break;
3279
3280 ++NumStatementsRead;
3281
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003282 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003283 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003284 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3285 }
3286
David L. Jonesbe1557a2016-12-21 00:17:49 +00003287 assert(Record.getIdx() == Record.size() &&
3288 "Invalid deserialization of statement");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003289 StmtStack.push_back(S);
3290 }
Chris Lattner0e6c9402013-01-20 02:38:54 +00003291Done:
Alp Toker028ed912013-12-06 17:56:43 +00003292 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003293 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003294 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003295}