blob: 5d9033e3797778c312347262d2bdc0c12568566c [file] [log] [blame]
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001//===- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------------------===//
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Chris Lattner92ba5ff2009-04-27 05:14:47 +00006//
7//===----------------------------------------------------------------------===//
8//
9// Statement/expression deserialization. This implements the
Sebastian Redl2c499f62010-08-18 23:56:43 +000010// ASTReader::ReadStmt method.
Chris Lattner92ba5ff2009-04-27 05:14:47 +000011//
12//===----------------------------------------------------------------------===//
13
Saar Razfdf80e82019-12-06 01:30:21 +020014#include "clang/AST/ASTConcept.h"
Benjamin Kramer4ab984e2012-07-04 20:19:54 +000015#include "clang/AST/ASTContext.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000016#include "clang/AST/AttrIterator.h"
17#include "clang/AST/Decl.h"
18#include "clang/AST/DeclAccessPair.h"
Douglas Gregor5d3507d2009-09-09 23:08:42 +000019#include "clang/AST/DeclCXX.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000020#include "clang/AST/DeclGroup.h"
21#include "clang/AST/DeclObjC.h"
Douglas Gregorcdbc5392011-01-15 01:15:58 +000022#include "clang/AST/DeclTemplate.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000023#include "clang/AST/DeclarationName.h"
Haojian Wu67d25912020-03-16 13:43:40 +010024#include "clang/AST/DependenceFlags.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000025#include "clang/AST/Expr.h"
26#include "clang/AST/ExprCXX.h"
27#include "clang/AST/ExprObjC.h"
28#include "clang/AST/ExprOpenMP.h"
29#include "clang/AST/NestedNameSpecifier.h"
30#include "clang/AST/OpenMPClause.h"
31#include "clang/AST/OperationKinds.h"
32#include "clang/AST/Stmt.h"
33#include "clang/AST/StmtCXX.h"
34#include "clang/AST/StmtObjC.h"
35#include "clang/AST/StmtOpenMP.h"
Chris Lattner92ba5ff2009-04-27 05:14:47 +000036#include "clang/AST/StmtVisitor.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000037#include "clang/AST/TemplateBase.h"
38#include "clang/AST/Type.h"
39#include "clang/AST/UnresolvedSet.h"
40#include "clang/Basic/CapturedStmt.h"
41#include "clang/Basic/ExpressionTraits.h"
42#include "clang/Basic/LLVM.h"
43#include "clang/Basic/Lambda.h"
44#include "clang/Basic/LangOptions.h"
45#include "clang/Basic/OpenMPKinds.h"
46#include "clang/Basic/OperatorKinds.h"
47#include "clang/Basic/SourceLocation.h"
48#include "clang/Basic/Specifiers.h"
49#include "clang/Basic/TypeTraits.h"
John McCallf413f5e2013-05-03 00:10:13 +000050#include "clang/Lex/Token.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000051#include "clang/Serialization/ASTBitCodes.h"
Ilya Biryukovec3060c2020-03-02 16:07:09 +010052#include "clang/Serialization/ASTRecordReader.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000053#include "llvm/ADT/DenseMap.h"
Benjamin Kramer49038022012-02-04 13:45:25 +000054#include "llvm/ADT/SmallString.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000055#include "llvm/ADT/SmallVector.h"
56#include "llvm/ADT/StringRef.h"
Francis Visoiu Mistrihe0308272019-07-03 22:40:07 +000057#include "llvm/Bitstream/BitstreamReader.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000058#include "llvm/Support/Casting.h"
59#include "llvm/Support/ErrorHandling.h"
60#include <algorithm>
61#include <cassert>
62#include <cstdint>
63#include <string>
64
Chris Lattner92ba5ff2009-04-27 05:14:47 +000065using namespace clang;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000066using namespace serialization;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000067
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +000068namespace clang {
Argyrios Kyrtzidisddf5f212010-06-28 09:31:42 +000069
Sebastian Redl70c751d2010-08-18 23:56:52 +000070 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
David L. Jonesbe1557a2016-12-21 00:17:49 +000071 ASTRecordReader &Record;
Sebastian Redlc67764e2010-07-22 22:43:28 +000072 llvm::BitstreamCursor &DeclsCursor;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000073
John McCall3ce3d232019-12-13 03:37:23 -050074 SourceLocation readSourceLocation() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000075 return Record.readSourceLocation();
John McCallf413f5e2013-05-03 00:10:13 +000076 }
77
John McCall3ce3d232019-12-13 03:37:23 -050078 SourceRange readSourceRange() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000079 return Record.readSourceRange();
Sebastian Redl2c373b92010-10-05 15:59:54 +000080 }
John McCallf413f5e2013-05-03 00:10:13 +000081
John McCall3ce3d232019-12-13 03:37:23 -050082 std::string readString() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000083 return Record.readString();
Sebastian Redl2c373b92010-10-05 15:59:54 +000084 }
John McCallf413f5e2013-05-03 00:10:13 +000085
John McCall3ce3d232019-12-13 03:37:23 -050086 TypeSourceInfo *readTypeSourceInfo() {
87 return Record.readTypeSourceInfo();
John McCallf413f5e2013-05-03 00:10:13 +000088 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000089
John McCall3ce3d232019-12-13 03:37:23 -050090 Decl *readDecl() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000091 return Record.readDecl();
Sebastian Redl2c373b92010-10-05 15:59:54 +000092 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000093
Douglas Gregor7fb09192011-07-21 22:35:25 +000094 template<typename T>
John McCall3ce3d232019-12-13 03:37:23 -050095 T *readDeclAs() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000096 return Record.readDeclAs<T>();
Douglas Gregor7fb09192011-07-21 22:35:25 +000097 }
98
Chris Lattner92ba5ff2009-04-27 05:14:47 +000099 public:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000100 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
101 : Record(Record), DeclsCursor(Cursor) {}
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000102
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000103 /// The number of record fields required for the Stmt class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000104 /// itself.
Roman Lebedevd5edcb92020-03-12 12:18:01 +0300105 static const unsigned NumStmtFields = 0;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000106
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000107 /// The number of record fields required for the Expr class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000108 /// itself.
Haojian Wu4b0f1e12020-03-17 10:36:19 +0100109 static const unsigned NumExprFields =
110 NumStmtFields + ExprDependenceBits + 3;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000111
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000112 /// Read and initialize a ExplicitTemplateArgumentList structure.
Abramo Bagnara7945c982012-01-27 09:46:47 +0000113 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
James Y Knighte7d82282015-12-29 18:15:14 +0000114 TemplateArgumentLoc *ArgsLocArray,
Abramo Bagnara7945c982012-01-27 09:46:47 +0000115 unsigned NumTemplateArgs);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000116
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000117 /// Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisde6aa082011-09-22 20:07:03 +0000118 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000119 unsigned NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000120
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000121 void VisitStmt(Stmt *S);
John McCallfa194042011-07-15 07:00:14 +0000122#define STMT(Type, Base) \
123 void Visit##Type(Type *);
124#include "clang/AST/StmtNodes.inc"
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000125 };
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000126
127} // namespace clang
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000128
James Y Knighte7d82282015-12-29 18:15:14 +0000129void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
130 TemplateArgumentLoc *ArgsLocArray,
131 unsigned NumTemplateArgs) {
John McCall3ce3d232019-12-13 03:37:23 -0500132 SourceLocation TemplateKWLoc = readSourceLocation();
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000133 TemplateArgumentListInfo ArgInfo;
John McCall3ce3d232019-12-13 03:37:23 -0500134 ArgInfo.setLAngleLoc(readSourceLocation());
135 ArgInfo.setRAngleLoc(readSourceLocation());
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000136 for (unsigned i = 0; i != NumTemplateArgs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000137 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
James Y Knighte7d82282015-12-29 18:15:14 +0000138 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000139}
140
Sebastian Redl70c751d2010-08-18 23:56:52 +0000141void ASTStmtReader::VisitStmt(Stmt *S) {
David L. Jonesbe1557a2016-12-21 00:17:49 +0000142 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000143}
144
Sebastian Redl70c751d2010-08-18 23:56:52 +0000145void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000146 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500147 S->setSemiLoc(readSourceLocation());
Bruno Ricci41d11c02018-10-27 18:43:27 +0000148 S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000149}
150
Sebastian Redl70c751d2010-08-18 23:56:52 +0000151void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000152 VisitStmt(S);
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000153 SmallVector<Stmt *, 16> Stmts;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000154 unsigned NumStmts = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000155 while (NumStmts--)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000156 Stmts.push_back(Record.readSubStmt());
Benjamin Kramer07420902017-12-24 16:24:20 +0000157 S->setStmts(Stmts);
John McCall3ce3d232019-12-13 03:37:23 -0500158 S->CompoundStmtBits.LBraceLoc = readSourceLocation();
159 S->RBraceLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000160}
161
Sebastian Redl70c751d2010-08-18 23:56:52 +0000162void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000163 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000164 Record.recordSwitchCaseID(S, Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500165 S->setKeywordLoc(readSourceLocation());
166 S->setColonLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000167}
168
Sebastian Redl70c751d2010-08-18 23:56:52 +0000169void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000170 VisitSwitchCase(S);
Bruno Ricci5b30571752018-10-28 12:30:53 +0000171 bool CaseStmtIsGNURange = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000172 S->setLHS(Record.readSubExpr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000173 S->setSubStmt(Record.readSubStmt());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000174 if (CaseStmtIsGNURange) {
175 S->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500176 S->setEllipsisLoc(readSourceLocation());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000177 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000178}
179
Sebastian Redl70c751d2010-08-18 23:56:52 +0000180void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000181 VisitSwitchCase(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000182 S->setSubStmt(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000183}
184
Sebastian Redl70c751d2010-08-18 23:56:52 +0000185void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000186 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500187 auto *LD = readDeclAs<LabelDecl>();
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000188 LD->setStmt(S);
189 S->setDecl(LD);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000190 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500191 S->setIdentLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000192}
193
Richard Smithc202b282012-04-14 00:33:13 +0000194void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
195 VisitStmt(S);
Bruno Ricci41d11c02018-10-27 18:43:27 +0000196 // NumAttrs in AttributedStmt is set when creating an empty
197 // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
198 // to allocate the right amount of space for the trailing Attr *.
David L. Jonesbe1557a2016-12-21 00:17:49 +0000199 uint64_t NumAttrs = Record.readInt();
Richard Smithc202b282012-04-14 00:33:13 +0000200 AttrVec Attrs;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000201 Record.readAttributes(Attrs);
Matt Beaumont-Gayad0bb8e2012-07-09 18:55:31 +0000202 (void)NumAttrs;
Bruno Ricci41d11c02018-10-27 18:43:27 +0000203 assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
Alexander Kornienko20f6fc62012-07-09 10:04:07 +0000204 assert(NumAttrs == Attrs.size());
Aaron Ballmanf3d9b092014-05-13 14:55:01 +0000205 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000206 S->SubStmt = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500207 S->AttributedStmtBits.AttrLoc = readSourceLocation();
Richard Smithc202b282012-04-14 00:33:13 +0000208}
209
Sebastian Redl70c751d2010-08-18 23:56:52 +0000210void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000211 VisitStmt(S);
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000212
David L. Jonesbe1557a2016-12-21 00:17:49 +0000213 S->setConstexpr(Record.readInt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000214 bool HasElse = Record.readInt();
215 bool HasVar = Record.readInt();
216 bool HasInit = Record.readInt();
217
David L. Jonesb6a8f022016-12-21 04:34:52 +0000218 S->setCond(Record.readSubExpr());
219 S->setThen(Record.readSubStmt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000220 if (HasElse)
221 S->setElse(Record.readSubStmt());
222 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500223 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000224 if (HasInit)
225 S->setInit(Record.readSubStmt());
226
John McCall3ce3d232019-12-13 03:37:23 -0500227 S->setIfLoc(readSourceLocation());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000228 if (HasElse)
John McCall3ce3d232019-12-13 03:37:23 -0500229 S->setElseLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000230}
231
Sebastian Redl70c751d2010-08-18 23:56:52 +0000232void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000233 VisitStmt(S);
Bruno Riccie2806f82018-10-29 16:12:37 +0000234
235 bool HasInit = Record.readInt();
236 bool HasVar = Record.readInt();
237 bool AllEnumCasesCovered = Record.readInt();
238 if (AllEnumCasesCovered)
239 S->setAllEnumCasesCovered();
240
David L. Jonesb6a8f022016-12-21 04:34:52 +0000241 S->setCond(Record.readSubExpr());
242 S->setBody(Record.readSubStmt());
Bruno Riccie2806f82018-10-29 16:12:37 +0000243 if (HasInit)
244 S->setInit(Record.readSubStmt());
245 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500246 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccie2806f82018-10-29 16:12:37 +0000247
John McCall3ce3d232019-12-13 03:37:23 -0500248 S->setSwitchLoc(readSourceLocation());
Ted Kremenekc42f3452010-09-09 00:05:53 +0000249
Craig Toppera13603a2014-05-22 05:54:18 +0000250 SwitchCase *PrevSC = nullptr;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000251 for (auto E = Record.size(); Record.getIdx() != E; ) {
252 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000253 if (PrevSC)
254 PrevSC->setNextSwitchCase(SC);
255 else
256 S->setSwitchCaseList(SC);
Mike Stump11289f42009-09-09 15:08:12 +0000257
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000258 PrevSC = SC;
259 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000260}
261
Sebastian Redl70c751d2010-08-18 23:56:52 +0000262void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000263 VisitStmt(S);
Bruno Riccibacf7512018-10-30 13:42:41 +0000264
265 bool HasVar = Record.readInt();
Douglas Gregor7fb09192011-07-21 22:35:25 +0000266
David L. Jonesb6a8f022016-12-21 04:34:52 +0000267 S->setCond(Record.readSubExpr());
268 S->setBody(Record.readSubStmt());
Bruno Riccibacf7512018-10-30 13:42:41 +0000269 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500270 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccibacf7512018-10-30 13:42:41 +0000271
John McCall3ce3d232019-12-13 03:37:23 -0500272 S->setWhileLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000273}
274
Sebastian Redl70c751d2010-08-18 23:56:52 +0000275void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000276 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000277 S->setCond(Record.readSubExpr());
278 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500279 S->setDoLoc(readSourceLocation());
280 S->setWhileLoc(readSourceLocation());
281 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000282}
283
Sebastian Redl70c751d2010-08-18 23:56:52 +0000284void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000285 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000286 S->setInit(Record.readSubStmt());
287 S->setCond(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500288 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000289 S->setInc(Record.readSubExpr());
290 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500291 S->setForLoc(readSourceLocation());
292 S->setLParenLoc(readSourceLocation());
293 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000294}
295
Sebastian Redl70c751d2010-08-18 23:56:52 +0000296void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000297 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500298 S->setLabel(readDeclAs<LabelDecl>());
299 S->setGotoLoc(readSourceLocation());
300 S->setLabelLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000301}
302
Sebastian Redl70c751d2010-08-18 23:56:52 +0000303void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000304 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500305 S->setGotoLoc(readSourceLocation());
306 S->setStarLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000307 S->setTarget(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000308}
309
Sebastian Redl70c751d2010-08-18 23:56:52 +0000310void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000311 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500312 S->setContinueLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000313}
314
Sebastian Redl70c751d2010-08-18 23:56:52 +0000315void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000316 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500317 S->setBreakLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000318}
319
Sebastian Redl70c751d2010-08-18 23:56:52 +0000320void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000321 VisitStmt(S);
Bruno Ricci023b1d12018-10-30 14:40:49 +0000322
323 bool HasNRVOCandidate = Record.readInt();
324
David L. Jonesb6a8f022016-12-21 04:34:52 +0000325 S->setRetValue(Record.readSubExpr());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000326 if (HasNRVOCandidate)
John McCall3ce3d232019-12-13 03:37:23 -0500327 S->setNRVOCandidate(readDeclAs<VarDecl>());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000328
John McCall3ce3d232019-12-13 03:37:23 -0500329 S->setReturnLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000330}
331
Sebastian Redl70c751d2010-08-18 23:56:52 +0000332void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000333 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500334 S->setStartLoc(readSourceLocation());
335 S->setEndLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000336
David L. Jonesbe1557a2016-12-21 00:17:49 +0000337 if (Record.size() - Record.getIdx() == 1) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000338 // Single declaration
John McCall3ce3d232019-12-13 03:37:23 -0500339 S->setDeclGroup(DeclGroupRef(readDecl()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000340 } else {
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000341 SmallVector<Decl *, 16> Decls;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000342 int N = Record.size() - Record.getIdx();
343 Decls.reserve(N);
344 for (int I = 0; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500345 Decls.push_back(readDecl());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000346 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
Douglas Gregor038c3382009-05-22 22:45:36 +0000347 Decls.data(),
348 Decls.size())));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000349 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000350}
351
John McCallf413f5e2013-05-03 00:10:13 +0000352void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000353 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000354 S->NumOutputs = Record.readInt();
355 S->NumInputs = Record.readInt();
356 S->NumClobbers = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500357 S->setAsmLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000358 S->setVolatile(Record.readInt());
359 S->setSimple(Record.readInt());
John McCallf413f5e2013-05-03 00:10:13 +0000360}
Mike Stump11289f42009-09-09 15:08:12 +0000361
John McCallf413f5e2013-05-03 00:10:13 +0000362void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
363 VisitAsmStmt(S);
Jennifer Yub8fee672019-06-03 15:57:25 +0000364 S->NumLabels = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500365 S->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000366 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000367
John McCallf413f5e2013-05-03 00:10:13 +0000368 unsigned NumOutputs = S->getNumOutputs();
369 unsigned NumInputs = S->getNumInputs();
370 unsigned NumClobbers = S->getNumClobbers();
Jennifer Yub8fee672019-06-03 15:57:25 +0000371 unsigned NumLabels = S->getNumLabels();
John McCallf413f5e2013-05-03 00:10:13 +0000372
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000373 // Outputs and inputs
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000374 SmallVector<IdentifierInfo *, 16> Names;
375 SmallVector<StringLiteral*, 16> Constraints;
376 SmallVector<Stmt*, 16> Exprs;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000377 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -0500378 Names.push_back(Record.readIdentifier());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000379 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
380 Exprs.push_back(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000381 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000382
383 // Constraints
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000384 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000385 for (unsigned I = 0; I != NumClobbers; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000386 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000387
Jennifer Yub8fee672019-06-03 15:57:25 +0000388 // Labels
389 for (unsigned I = 0, N = NumLabels; I != N; ++I)
390 Exprs.push_back(Record.readSubStmt());
391
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000392 S->setOutputsAndInputsAndClobbers(Record.getContext(),
393 Names.data(), Constraints.data(),
394 Exprs.data(), NumOutputs, NumInputs,
Jennifer Yub8fee672019-06-03 15:57:25 +0000395 NumLabels,
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000396 Clobbers.data(), NumClobbers);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000397}
398
Chad Rosier32503022012-06-11 20:47:18 +0000399void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
John McCallf413f5e2013-05-03 00:10:13 +0000400 VisitAsmStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500401 S->LBraceLoc = readSourceLocation();
402 S->EndLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000403 S->NumAsmToks = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500404 std::string AsmStr = readString();
John McCallf413f5e2013-05-03 00:10:13 +0000405
406 // Read the tokens.
407 SmallVector<Token, 16> AsmToks;
408 AsmToks.reserve(S->NumAsmToks);
409 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000410 AsmToks.push_back(Record.readToken());
John McCallf413f5e2013-05-03 00:10:13 +0000411 }
412
413 // The calls to reserve() for the FooData vectors are mandatory to
414 // prevent dead StringRefs in the Foo vectors.
415
416 // Read the clobbers.
417 SmallVector<std::string, 16> ClobbersData;
418 SmallVector<StringRef, 16> Clobbers;
419 ClobbersData.reserve(S->NumClobbers);
420 Clobbers.reserve(S->NumClobbers);
421 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
John McCall3ce3d232019-12-13 03:37:23 -0500422 ClobbersData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000423 Clobbers.push_back(ClobbersData.back());
424 }
425
426 // Read the operands.
427 unsigned NumOperands = S->NumOutputs + S->NumInputs;
428 SmallVector<Expr*, 16> Exprs;
429 SmallVector<std::string, 16> ConstraintsData;
430 SmallVector<StringRef, 16> Constraints;
431 Exprs.reserve(NumOperands);
432 ConstraintsData.reserve(NumOperands);
433 Constraints.reserve(NumOperands);
434 for (unsigned i = 0; i != NumOperands; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000435 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -0500436 ConstraintsData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000437 Constraints.push_back(ConstraintsData.back());
438 }
439
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000440 S->initialize(Record.getContext(), AsmStr, AsmToks,
John McCallf413f5e2013-05-03 00:10:13 +0000441 Constraints, Exprs, Clobbers);
Chad Rosier32503022012-06-11 20:47:18 +0000442}
443
Richard Smith9f690bd2015-10-27 06:02:45 +0000444void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000445 VisitStmt(S);
446 assert(Record.peekInt() == S->NumParams);
447 Record.skipInts(1);
448 auto *StoredStmts = S->getStoredStmts();
449 for (unsigned i = 0;
450 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
451 StoredStmts[i] = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000452}
453
454void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000455 VisitStmt(S);
456 S->CoreturnLoc = Record.readSourceLocation();
457 for (auto &SubStmt: S->SubStmts)
458 SubStmt = Record.readSubStmt();
459 S->IsImplicit = Record.readInt() != 0;
Richard Smith9f690bd2015-10-27 06:02:45 +0000460}
461
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000462void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
463 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500464 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000465 for (auto &SubExpr: E->SubExprs)
466 SubExpr = Record.readSubStmt();
467 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
468 E->setIsImplicit(Record.readInt() != 0);
Richard Smith9f690bd2015-10-27 06:02:45 +0000469}
470
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000471void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
472 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500473 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000474 for (auto &SubExpr: E->SubExprs)
475 SubExpr = Record.readSubStmt();
476 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
Eric Fiselier20f25cb2017-03-06 23:38:15 +0000477}
478
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000479void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
480 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500481 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000482 for (auto &SubExpr: E->SubExprs)
483 SubExpr = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000484}
485
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000486void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
Ben Langmuirce914fc2013-05-03 19:20:19 +0000487 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000488 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500489 S->setCapturedDecl(readDeclAs<CapturedDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000490 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500491 S->setCapturedRecordDecl(readDeclAs<RecordDecl>());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000492
493 // Capture inits
494 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
495 E = S->capture_init_end();
496 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000497 *I = Record.readSubExpr();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000498
499 // Body
David L. Jonesb6a8f022016-12-21 04:34:52 +0000500 S->setCapturedStmt(Record.readSubStmt());
Wei Pan17fbf6e2013-05-04 03:59:06 +0000501 S->getCapturedDecl()->setBody(S->getCapturedStmt());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000502
503 // Captures
Aaron Ballmanc656303a2014-03-14 18:08:33 +0000504 for (auto &I : S->captures()) {
John McCall3ce3d232019-12-13 03:37:23 -0500505 I.VarAndKind.setPointer(readDeclAs<VarDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000506 I.VarAndKind.setInt(
507 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500508 I.Loc = readSourceLocation();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000509 }
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000510}
511
Sebastian Redl70c751d2010-08-18 23:56:52 +0000512void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000513 VisitStmt(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000514 E->setType(Record.readType());
Ilya Biryukovec3060c2020-03-02 16:07:09 +0100515
516 // FIXME: write and read all DependentFlags with a single call.
517 bool TypeDependent = Record.readInt();
518 bool ValueDependent = Record.readInt();
519 bool InstantiationDependent = Record.readInt();
520 bool ContainsUnexpandedTemplateParameters = Record.readInt();
Haojian Wu4b0f1e12020-03-17 10:36:19 +0100521 bool ContainsErrors = Record.readInt();
Ilya Biryukovec3060c2020-03-02 16:07:09 +0100522 auto Deps = ExprDependence::None;
523 if (TypeDependent)
524 Deps |= ExprDependence::Type;
525 if (ValueDependent)
526 Deps |= ExprDependence::Value;
527 if (InstantiationDependent)
528 Deps |= ExprDependence::Instantiation;
529 if (ContainsUnexpandedTemplateParameters)
530 Deps |= ExprDependence::UnexpandedPack;
Haojian Wu4b0f1e12020-03-17 10:36:19 +0100531 if (ContainsErrors)
532 Deps |= ExprDependence::Error;
Ilya Biryukovec3060c2020-03-02 16:07:09 +0100533 E->setDependence(Deps);
534
David L. Jonesbe1557a2016-12-21 00:17:49 +0000535 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
536 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
537 assert(Record.getIdx() == NumExprFields &&
538 "Incorrect expression field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000539}
540
Bill Wendling7c44da22018-10-31 03:48:47 +0000541void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
542 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000543 E->ConstantExprBits.ResultKind = Record.readInt();
544 switch (E->ConstantExprBits.ResultKind) {
545 case ConstantExpr::RSK_Int64: {
546 E->Int64Result() = Record.readInt();
547 uint64_t tmp = Record.readInt();
548 E->ConstantExprBits.IsUnsigned = tmp & 0x1;
549 E->ConstantExprBits.BitWidth = tmp >> 1;
550 break;
551 }
552 case ConstantExpr::RSK_APValue:
553 E->APValueResult() = Record.readAPValue();
554 }
Bill Wendling7c44da22018-10-31 03:48:47 +0000555 E->setSubExpr(Record.readSubExpr());
556}
557
Sebastian Redl70c751d2010-08-18 23:56:52 +0000558void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000559 VisitExpr(E);
Bruno Ricci17ff0262018-10-27 19:21:19 +0000560 bool HasFunctionName = Record.readInt();
561 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
562 E->PredefinedExprBits.Kind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500563 E->setLocation(readSourceLocation());
Bruno Ricci17ff0262018-10-27 19:21:19 +0000564 if (HasFunctionName)
565 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000566}
567
Sebastian Redl70c751d2010-08-18 23:56:52 +0000568void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000569 VisitExpr(E);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000570
David L. Jonesbe1557a2016-12-21 00:17:49 +0000571 E->DeclRefExprBits.HasQualifier = Record.readInt();
572 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
573 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
574 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
575 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
Richard Smith715f7a12019-06-11 17:50:32 +0000576 E->DeclRefExprBits.NonOdrUseReason = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000577 unsigned NumTemplateArgs = 0;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000578 if (E->hasTemplateKWAndArgsInfo())
David L. Jonesbe1557a2016-12-21 00:17:49 +0000579 NumTemplateArgs = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000580
Chandler Carruth0e439962011-05-01 21:29:53 +0000581 if (E->hasQualifier())
James Y Knighte7d82282015-12-29 18:15:14 +0000582 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
David L. Jonesb6a8f022016-12-21 04:34:52 +0000583 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000584
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000585 if (E->hasFoundDecl())
John McCall3ce3d232019-12-13 03:37:23 -0500586 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000587
Abramo Bagnara7945c982012-01-27 09:46:47 +0000588 if (E->hasTemplateKWAndArgsInfo())
James Y Knighte7d82282015-12-29 18:15:14 +0000589 ReadTemplateKWAndArgsInfo(
590 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
591 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000592
John McCall3ce3d232019-12-13 03:37:23 -0500593 E->setDecl(readDeclAs<ValueDecl>());
594 E->setLocation(readSourceLocation());
595 E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000596}
597
Sebastian Redl70c751d2010-08-18 23:56:52 +0000598void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000599 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500600 E->setLocation(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000601 E->setValue(Record.getContext(), Record.readAPInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000602}
603
Leonard Chandb01c3a2018-06-20 17:19:40 +0000604void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
605 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500606 E->setLocation(readSourceLocation());
Leonard Chandb01c3a2018-06-20 17:19:40 +0000607 E->setValue(Record.getContext(), Record.readAPInt());
608}
609
Sebastian Redl70c751d2010-08-18 23:56:52 +0000610void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000611 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000612 E->setRawSemantics(
613 static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
David L. Jonesbe1557a2016-12-21 00:17:49 +0000614 E->setExact(Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000615 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
John McCall3ce3d232019-12-13 03:37:23 -0500616 E->setLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000617}
618
Sebastian Redl70c751d2010-08-18 23:56:52 +0000619void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000620 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000621 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000622}
623
Sebastian Redl70c751d2010-08-18 23:56:52 +0000624void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000625 VisitExpr(E);
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000626
627 // NumConcatenated, Length and CharByteWidth are set by the empty
628 // ctor since they are needed to allocate storage for the trailing objects.
629 unsigned NumConcatenated = Record.readInt();
630 unsigned Length = Record.readInt();
631 unsigned CharByteWidth = Record.readInt();
632 assert((NumConcatenated == E->getNumConcatenated()) &&
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000633 "Wrong number of concatenated tokens!");
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000634 assert((Length == E->getLength()) && "Wrong Length!");
635 assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
636 E->StringLiteralBits.Kind = Record.readInt();
637 E->StringLiteralBits.IsPascal = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000638
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000639 // The character width is originally computed via mapCharByteWidth.
640 // Check that the deserialized character width is consistant with the result
641 // of calling mapCharByteWidth.
642 assert((CharByteWidth ==
643 StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
644 E->getKind())) &&
645 "Wrong character width!");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000646
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000647 // Deserialize the trailing array of SourceLocation.
648 for (unsigned I = 0; I < NumConcatenated; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500649 E->setStrTokenLoc(I, readSourceLocation());
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000650
651 // Deserialize the trailing array of char holding the string data.
652 char *StrData = E->getStrDataAsChar();
653 for (unsigned I = 0; I < Length * CharByteWidth; ++I)
654 StrData[I] = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000655}
656
Sebastian Redl70c751d2010-08-18 23:56:52 +0000657void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000658 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000659 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500660 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000661 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000662}
663
Sebastian Redl70c751d2010-08-18 23:56:52 +0000664void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000665 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500666 E->setLParen(readSourceLocation());
667 E->setRParen(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000668 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000669}
670
Sebastian Redl70c751d2010-08-18 23:56:52 +0000671void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000672 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000673 unsigned NumExprs = Record.readInt();
Bruno Riccif49e1ca2018-11-20 16:20:40 +0000674 assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
675 for (unsigned I = 0; I != NumExprs; ++I)
676 E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500677 E->LParenLoc = readSourceLocation();
678 E->RParenLoc = readSourceLocation();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000679}
680
Sebastian Redl70c751d2010-08-18 23:56:52 +0000681void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000682 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000683 E->setSubExpr(Record.readSubExpr());
684 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500685 E->setOperatorLoc(readSourceLocation());
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000686 E->setCanOverflow(Record.readInt());
687}
688
689void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000690 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000691 assert(E->getNumComponents() == Record.peekInt());
692 Record.skipInts(1);
693 assert(E->getNumExpressions() == Record.peekInt());
694 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500695 E->setOperatorLoc(readSourceLocation());
696 E->setRParenLoc(readSourceLocation());
697 E->setTypeSourceInfo(readTypeSourceInfo());
Douglas Gregor882211c2010-04-28 22:16:22 +0000698 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000699 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500700 SourceLocation Start = readSourceLocation();
701 SourceLocation End = readSourceLocation();
Douglas Gregor882211c2010-04-28 22:16:22 +0000702 switch (Kind) {
James Y Knight7281c352015-12-29 22:31:18 +0000703 case OffsetOfNode::Array:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000704 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000705 break;
706
James Y Knight7281c352015-12-29 22:31:18 +0000707 case OffsetOfNode::Field:
708 E->setComponent(
John McCall3ce3d232019-12-13 03:37:23 -0500709 I, OffsetOfNode(Start, readDeclAs<FieldDecl>(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000710 break;
James Y Knight7281c352015-12-29 22:31:18 +0000711
712 case OffsetOfNode::Identifier:
713 E->setComponent(
714 I,
John McCall3ce3d232019-12-13 03:37:23 -0500715 OffsetOfNode(Start, Record.readIdentifier(), End));
James Y Knight7281c352015-12-29 22:31:18 +0000716 break;
717
718 case OffsetOfNode::Base: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000719 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000720 *Base = Record.readCXXBaseSpecifier();
James Y Knight7281c352015-12-29 22:31:18 +0000721 E->setComponent(I, OffsetOfNode(Base));
Douglas Gregord1702062010-04-29 00:18:15 +0000722 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000723 }
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000724 }
Douglas Gregor882211c2010-04-28 22:16:22 +0000725 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000726
Douglas Gregor882211c2010-04-28 22:16:22 +0000727 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000728 E->setIndexExpr(I, Record.readSubExpr());
Douglas Gregor882211c2010-04-28 22:16:22 +0000729}
730
Peter Collingbournee190dee2011-03-11 19:24:49 +0000731void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000732 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000733 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
734 if (Record.peekInt() == 0) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000735 E->setArgument(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000736 Record.skipInts(1);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000737 } else {
John McCall3ce3d232019-12-13 03:37:23 -0500738 E->setArgument(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000739 }
John McCall3ce3d232019-12-13 03:37:23 -0500740 E->setOperatorLoc(readSourceLocation());
741 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000742}
743
Saar Raza0f50d72020-01-18 09:11:43 +0200744static ConstraintSatisfaction
745readConstraintSatisfaction(ASTRecordReader &Record) {
746 ConstraintSatisfaction Satisfaction;
747 Satisfaction.IsSatisfied = Record.readInt();
748 if (!Satisfaction.IsSatisfied) {
749 unsigned NumDetailRecords = Record.readInt();
750 for (unsigned i = 0; i != NumDetailRecords; ++i) {
751 Expr *ConstraintExpr = Record.readExpr();
Michael Liao70b53a302020-01-19 12:23:11 -0500752 if (/* IsDiagnostic */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200753 SourceLocation DiagLocation = Record.readSourceLocation();
754 std::string DiagMessage = Record.readString();
755 Satisfaction.Details.emplace_back(
756 ConstraintExpr, new (Record.getContext())
757 ConstraintSatisfaction::SubstitutionDiagnostic{
758 DiagLocation, DiagMessage});
759 } else
760 Satisfaction.Details.emplace_back(ConstraintExpr, Record.readExpr());
761 }
762 }
763 return Satisfaction;
764}
765
Saar Raz5d98ba62019-10-15 15:24:26 +0000766void ASTStmtReader::VisitConceptSpecializationExpr(
767 ConceptSpecializationExpr *E) {
768 VisitExpr(E);
769 unsigned NumTemplateArgs = Record.readInt();
770 E->NestedNameSpec = Record.readNestedNameSpecifierLoc();
771 E->TemplateKWLoc = Record.readSourceLocation();
Saar Razff1e0fc2020-01-15 02:48:42 +0200772 E->ConceptName = Record.readDeclarationNameInfo();
John McCall3ce3d232019-12-13 03:37:23 -0500773 E->NamedConcept = readDeclAs<ConceptDecl>();
Saar Razf9e63892020-03-10 22:04:11 +0200774 E->FoundDecl = Record.readDeclAs<NamedDecl>();
Saar Razff1e0fc2020-01-15 02:48:42 +0200775 E->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
Saar Raz5d98ba62019-10-15 15:24:26 +0000776 llvm::SmallVector<TemplateArgument, 4> Args;
777 for (unsigned I = 0; I < NumTemplateArgs; ++I)
778 Args.push_back(Record.readTemplateArgument());
Saar Razff1e0fc2020-01-15 02:48:42 +0200779 E->setTemplateArguments(Args);
Saar Raza0f50d72020-01-18 09:11:43 +0200780 E->Satisfaction = E->isValueDependent() ? nullptr :
781 ASTConstraintSatisfaction::Create(Record.getContext(),
782 readConstraintSatisfaction(Record));
783}
784
785static concepts::Requirement::SubstitutionDiagnostic *
786readSubstitutionDiagnostic(ASTRecordReader &Record) {
787 std::string SubstitutedEntity = Record.readString();
788 SourceLocation DiagLoc = Record.readSourceLocation();
789 std::string DiagMessage = Record.readString();
790 return new (Record.getContext())
791 concepts::Requirement::SubstitutionDiagnostic{SubstitutedEntity, DiagLoc,
792 DiagMessage};
793}
794
795void ASTStmtReader::VisitRequiresExpr(RequiresExpr *E) {
796 VisitExpr(E);
797 unsigned NumLocalParameters = Record.readInt();
798 unsigned NumRequirements = Record.readInt();
799 E->RequiresExprBits.RequiresKWLoc = Record.readSourceLocation();
800 E->RequiresExprBits.IsSatisfied = Record.readInt();
801 E->Body = Record.readDeclAs<RequiresExprBodyDecl>();
802 llvm::SmallVector<ParmVarDecl *, 4> LocalParameters;
803 for (unsigned i = 0; i < NumLocalParameters; ++i)
804 LocalParameters.push_back(cast<ParmVarDecl>(Record.readDecl()));
805 std::copy(LocalParameters.begin(), LocalParameters.end(),
806 E->getTrailingObjects<ParmVarDecl *>());
807 llvm::SmallVector<concepts::Requirement *, 4> Requirements;
808 for (unsigned i = 0; i < NumRequirements; ++i) {
809 auto RK =
810 static_cast<concepts::Requirement::RequirementKind>(Record.readInt());
811 concepts::Requirement *R = nullptr;
812 switch (RK) {
813 case concepts::Requirement::RK_Type: {
814 auto Status =
815 static_cast<concepts::TypeRequirement::SatisfactionStatus>(
816 Record.readInt());
817 if (Status == concepts::TypeRequirement::SS_SubstitutionFailure)
818 R = new (Record.getContext())
819 concepts::TypeRequirement(readSubstitutionDiagnostic(Record));
820 else
821 R = new (Record.getContext())
822 concepts::TypeRequirement(Record.readTypeSourceInfo());
823 } break;
824 case concepts::Requirement::RK_Simple:
825 case concepts::Requirement::RK_Compound: {
826 auto Status =
827 static_cast<concepts::ExprRequirement::SatisfactionStatus>(
828 Record.readInt());
829 llvm::PointerUnion<concepts::Requirement::SubstitutionDiagnostic *,
830 Expr *> E;
831 if (Status == concepts::ExprRequirement::SS_ExprSubstitutionFailure) {
832 E = readSubstitutionDiagnostic(Record);
833 } else
834 E = Record.readExpr();
835
836 llvm::Optional<concepts::ExprRequirement::ReturnTypeRequirement> Req;
837 ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr;
838 SourceLocation NoexceptLoc;
839 if (RK == concepts::Requirement::RK_Simple) {
840 Req.emplace();
841 } else {
842 NoexceptLoc = Record.readSourceLocation();
Michael Liao70b53a302020-01-19 12:23:11 -0500843 switch (/* returnTypeRequirementKind */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200844 case 0:
845 // No return type requirement.
846 Req.emplace();
847 break;
848 case 1: {
849 // type-constraint
850 TemplateParameterList *TPL = Record.readTemplateParameterList();
851 if (Status >=
852 concepts::ExprRequirement::SS_ConstraintsNotSatisfied)
853 SubstitutedConstraintExpr =
854 cast<ConceptSpecializationExpr>(Record.readExpr());
855 Req.emplace(TPL);
856 } break;
857 case 2:
858 // Substitution failure
859 Req.emplace(readSubstitutionDiagnostic(Record));
860 break;
861 }
862 }
863 if (Expr *Ex = E.dyn_cast<Expr *>())
864 R = new (Record.getContext()) concepts::ExprRequirement(
865 Ex, RK == concepts::Requirement::RK_Simple, NoexceptLoc,
866 std::move(*Req), Status, SubstitutedConstraintExpr);
867 else
868 R = new (Record.getContext()) concepts::ExprRequirement(
869 E.get<concepts::Requirement::SubstitutionDiagnostic *>(),
870 RK == concepts::Requirement::RK_Simple, NoexceptLoc,
871 std::move(*Req));
872 } break;
873 case concepts::Requirement::RK_Nested: {
Michael Liao70b53a302020-01-19 12:23:11 -0500874 if (/* IsSubstitutionDiagnostic */Record.readInt()) {
Saar Raza0f50d72020-01-18 09:11:43 +0200875 R = new (Record.getContext()) concepts::NestedRequirement(
876 readSubstitutionDiagnostic(Record));
877 break;
878 }
879 Expr *E = Record.readExpr();
880 if (E->isInstantiationDependent())
881 R = new (Record.getContext()) concepts::NestedRequirement(E);
882 else
883 R = new (Record.getContext())
884 concepts::NestedRequirement(Record.getContext(), E,
885 readConstraintSatisfaction(Record));
886 } break;
Saar Razfdf80e82019-12-06 01:30:21 +0200887 }
Saar Raza0f50d72020-01-18 09:11:43 +0200888 if (!R)
889 continue;
890 Requirements.push_back(R);
Saar Razfdf80e82019-12-06 01:30:21 +0200891 }
Saar Raza0f50d72020-01-18 09:11:43 +0200892 std::copy(Requirements.begin(), Requirements.end(),
893 E->getTrailingObjects<concepts::Requirement *>());
894 E->RBraceLoc = Record.readSourceLocation();
Saar Raz5d98ba62019-10-15 15:24:26 +0000895}
896
Sebastian Redl70c751d2010-08-18 23:56:52 +0000897void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000898 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000899 E->setLHS(Record.readSubExpr());
900 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500901 E->setRBracketLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000902}
903
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000904void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
905 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000906 E->setBase(Record.readSubExpr());
907 E->setLowerBound(Record.readSubExpr());
908 E->setLength(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500909 E->setColonLoc(readSourceLocation());
910 E->setRBracketLoc(readSourceLocation());
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000911}
912
Sebastian Redl70c751d2010-08-18 23:56:52 +0000913void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000914 VisitExpr(E);
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000915 unsigned NumArgs = Record.readInt();
916 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
John McCall3ce3d232019-12-13 03:37:23 -0500917 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000918 E->setCallee(Record.readSubExpr());
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000919 for (unsigned I = 0; I != NumArgs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000920 E->setArg(I, Record.readSubExpr());
Eric Fiselier5cdc2cd2018-12-12 21:50:55 +0000921 E->setADLCallKind(static_cast<CallExpr::ADLCallKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000922}
923
John McCallfa194042011-07-15 07:00:14 +0000924void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
925 VisitCallExpr(E);
926}
927
Sebastian Redl70c751d2010-08-18 23:56:52 +0000928void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Richard Smithdcf17de2019-06-06 23:24:15 +0000929 VisitExpr(E);
930
931 bool HasQualifier = Record.readInt();
932 bool HasFoundDecl = Record.readInt();
933 bool HasTemplateInfo = Record.readInt();
934 unsigned NumTemplateArgs = Record.readInt();
935
936 E->Base = Record.readSubExpr();
937 E->MemberDecl = Record.readDeclAs<ValueDecl>();
John McCall3ce3d232019-12-13 03:37:23 -0500938 E->MemberDNLoc = Record.readDeclarationNameLoc(E->MemberDecl->getDeclName());
Richard Smithdcf17de2019-06-06 23:24:15 +0000939 E->MemberLoc = Record.readSourceLocation();
940 E->MemberExprBits.IsArrow = Record.readInt();
941 E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
942 E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
943 E->MemberExprBits.HadMultipleCandidates = Record.readInt();
Richard Smith1bbad592019-06-11 17:50:36 +0000944 E->MemberExprBits.NonOdrUseReason = Record.readInt();
Richard Smithdcf17de2019-06-06 23:24:15 +0000945 E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
946
947 if (HasQualifier || HasFoundDecl) {
948 DeclAccessPair FoundDecl;
949 if (HasFoundDecl) {
950 auto *FoundD = Record.readDeclAs<NamedDecl>();
951 auto AS = (AccessSpecifier)Record.readInt();
952 FoundDecl = DeclAccessPair::make(FoundD, AS);
953 } else {
954 FoundDecl = DeclAccessPair::make(E->MemberDecl,
955 E->MemberDecl->getAccess());
956 }
957 E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
958
959 NestedNameSpecifierLoc QualifierLoc;
960 if (HasQualifier)
961 QualifierLoc = Record.readNestedNameSpecifierLoc();
962 E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
963 QualifierLoc;
964 }
965
966 if (HasTemplateInfo)
967 ReadTemplateKWAndArgsInfo(
968 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
969 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000970}
971
Sebastian Redl70c751d2010-08-18 23:56:52 +0000972void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Naroffe87026a2009-07-24 17:54:45 +0000973 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000974 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500975 E->setIsaMemberLoc(readSourceLocation());
976 E->setOpLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000977 E->setArrow(Record.readInt());
Steve Naroffe87026a2009-07-24 17:54:45 +0000978}
979
John McCall31168b02011-06-15 23:02:42 +0000980void ASTStmtReader::
981VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
982 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000983 E->Operand = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000984 E->setShouldCopy(Record.readInt());
John McCall31168b02011-06-15 23:02:42 +0000985}
986
987void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
988 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500989 E->LParenLoc = readSourceLocation();
990 E->BridgeKeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000991 E->Kind = Record.readInt();
John McCall31168b02011-06-15 23:02:42 +0000992}
993
Sebastian Redl70c751d2010-08-18 23:56:52 +0000994void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000995 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000996 unsigned NumBaseSpecs = Record.readInt();
John McCallcf142162010-08-07 06:22:56 +0000997 assert(NumBaseSpecs == E->path_size());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000998 E->setSubExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000999 E->setCastKind((CastKind)Record.readInt());
John McCallcf142162010-08-07 06:22:56 +00001000 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +00001001 while (NumBaseSpecs--) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001002 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
David L. Jonesb6a8f022016-12-21 04:34:52 +00001003 *BaseSpec = Record.readCXXBaseSpecifier();
John McCallcf142162010-08-07 06:22:56 +00001004 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +00001005 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001006}
1007
Sebastian Redl70c751d2010-08-18 23:56:52 +00001008void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001009 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001010 E->setLHS(Record.readSubExpr());
1011 E->setRHS(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001012 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001013 E->setOperatorLoc(readSourceLocation());
Adam Nemet484aa452017-03-27 19:17:25 +00001014 E->setFPFeatures(FPOptions(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001015}
1016
Sebastian Redl70c751d2010-08-18 23:56:52 +00001017void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001018 VisitBinaryOperator(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001019 E->setComputationLHSType(Record.readType());
1020 E->setComputationResultType(Record.readType());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001021}
1022
Sebastian Redl70c751d2010-08-18 23:56:52 +00001023void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001024 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001025 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
1026 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
1027 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001028 E->QuestionLoc = readSourceLocation();
1029 E->ColonLoc = readSourceLocation();
John McCallc07a0c72011-02-17 10:25:35 +00001030}
1031
1032void
1033ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
1034 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001035 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
1036 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
1037 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
1038 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
1039 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001040 E->QuestionLoc = readSourceLocation();
1041 E->ColonLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001042}
1043
Sebastian Redl70c751d2010-08-18 23:56:52 +00001044void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001045 VisitCastExpr(E);
Roman Lebedev12216f12018-07-27 07:27:14 +00001046 E->setIsPartOfExplicitCast(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001047}
1048
Sebastian Redl70c751d2010-08-18 23:56:52 +00001049void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001050 VisitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001051 E->setTypeInfoAsWritten(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001052}
1053
Sebastian Redl70c751d2010-08-18 23:56:52 +00001054void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001055 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001056 E->setLParenLoc(readSourceLocation());
1057 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001058}
1059
Sebastian Redl70c751d2010-08-18 23:56:52 +00001060void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001061 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001062 E->setLParenLoc(readSourceLocation());
1063 E->setTypeSourceInfo(readTypeSourceInfo());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001064 E->setInitializer(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001065 E->setFileScope(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001066}
1067
Sebastian Redl70c751d2010-08-18 23:56:52 +00001068void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001069 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001070 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001071 E->setAccessor(Record.readIdentifier());
1072 E->setAccessorLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001073}
1074
Sebastian Redl70c751d2010-08-18 23:56:52 +00001075void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001076 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001077 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
Abramo Bagnara8d16bd42012-11-08 18:41:43 +00001078 E->setSyntacticForm(SyntForm);
John McCall3ce3d232019-12-13 03:37:23 -05001079 E->setLBraceLoc(readSourceLocation());
1080 E->setRBraceLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001081 bool isArrayFiller = Record.readInt();
Craig Toppera13603a2014-05-22 05:54:18 +00001082 Expr *filler = nullptr;
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001083 if (isArrayFiller) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001084 filler = Record.readSubExpr();
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001085 E->ArrayFillerOrUnionFieldInit = filler;
1086 } else
John McCall3ce3d232019-12-13 03:37:23 -05001087 E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001088 E->sawArrayRangeDesignator(Record.readInt());
1089 unsigned NumInits = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001090 E->reserveInits(Record.getContext(), NumInits);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001091 if (isArrayFiller) {
1092 for (unsigned I = 0; I != NumInits; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001093 Expr *init = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001094 E->updateInit(Record.getContext(), I, init ? init : filler);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001095 }
1096 } else {
1097 for (unsigned I = 0; I != NumInits; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001098 E->updateInit(Record.getContext(), I, Record.readSubExpr());
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001099 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001100}
1101
Sebastian Redl70c751d2010-08-18 23:56:52 +00001102void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001103 using Designator = DesignatedInitExpr::Designator;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001104
1105 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001106 unsigned NumSubExprs = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001107 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
1108 for (unsigned I = 0; I != NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001109 E->setSubExpr(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001110 E->setEqualOrColonLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001111 E->setGNUSyntax(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001112
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001113 SmallVector<Designator, 4> Designators;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001114 while (Record.getIdx() < Record.size()) {
1115 switch ((DesignatorTypes)Record.readInt()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00001116 case DESIG_FIELD_DECL: {
John McCall3ce3d232019-12-13 03:37:23 -05001117 auto *Field = readDeclAs<FieldDecl>();
1118 SourceLocation DotLoc = readSourceLocation();
1119 SourceLocation FieldLoc = readSourceLocation();
Mike Stump11289f42009-09-09 15:08:12 +00001120 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001121 FieldLoc));
1122 Designators.back().setField(Field);
1123 break;
1124 }
1125
Sebastian Redl539c5062010-08-18 23:57:32 +00001126 case DESIG_FIELD_NAME: {
John McCall3ce3d232019-12-13 03:37:23 -05001127 const IdentifierInfo *Name = Record.readIdentifier();
1128 SourceLocation DotLoc = readSourceLocation();
1129 SourceLocation FieldLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001130 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
1131 break;
1132 }
Mike Stump11289f42009-09-09 15:08:12 +00001133
Sebastian Redl539c5062010-08-18 23:57:32 +00001134 case DESIG_ARRAY: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001135 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001136 SourceLocation LBracketLoc = readSourceLocation();
1137 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001138 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
1139 break;
1140 }
1141
Sebastian Redl539c5062010-08-18 23:57:32 +00001142 case DESIG_ARRAY_RANGE: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001143 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001144 SourceLocation LBracketLoc = readSourceLocation();
1145 SourceLocation EllipsisLoc = readSourceLocation();
1146 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001147 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
1148 RBracketLoc));
1149 break;
1150 }
1151 }
1152 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001153 E->setDesignators(Record.getContext(),
Douglas Gregor03e8bdc2010-01-06 23:17:19 +00001154 Designators.data(), Designators.size());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001155}
1156
Yunzhong Gaocb779302015-06-10 00:27:52 +00001157void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1158 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001159 E->setBase(Record.readSubExpr());
1160 E->setUpdater(Record.readSubExpr());
Yunzhong Gaocb779302015-06-10 00:27:52 +00001161}
1162
1163void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1164 VisitExpr(E);
1165}
1166
Richard Smith410306b2016-12-12 02:53:20 +00001167void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1168 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001169 E->SubExprs[0] = Record.readSubExpr();
1170 E->SubExprs[1] = Record.readSubExpr();
Richard Smith410306b2016-12-12 02:53:20 +00001171}
1172
1173void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1174 VisitExpr(E);
1175}
1176
Sebastian Redl70c751d2010-08-18 23:56:52 +00001177void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001178 VisitExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001179}
1180
Sebastian Redl70c751d2010-08-18 23:56:52 +00001181void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001182 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001183 E->setSubExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001184 E->setWrittenTypeInfo(readTypeSourceInfo());
1185 E->setBuiltinLoc(readSourceLocation());
1186 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001187 E->setIsMicrosoftABI(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001188}
1189
Eric Fiselier708afb52019-05-16 21:04:15 +00001190void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1191 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001192 E->ParentContext = readDeclAs<DeclContext>();
1193 E->BuiltinLoc = readSourceLocation();
1194 E->RParenLoc = readSourceLocation();
Eric Fiselier708afb52019-05-16 21:04:15 +00001195 E->SourceLocExprBits.Kind =
1196 static_cast<SourceLocExpr::IdentKind>(Record.readInt());
1197}
1198
Sebastian Redl70c751d2010-08-18 23:56:52 +00001199void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001200 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001201 E->setAmpAmpLoc(readSourceLocation());
1202 E->setLabelLoc(readSourceLocation());
1203 E->setLabel(readDeclAs<LabelDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001204}
1205
Sebastian Redl70c751d2010-08-18 23:56:52 +00001206void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001207 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001208 E->setLParenLoc(readSourceLocation());
1209 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001210 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
Richard Smith5c845c12020-03-09 17:34:33 -07001211 E->StmtExprBits.TemplateDepth = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001212}
1213
Sebastian Redl70c751d2010-08-18 23:56:52 +00001214void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001215 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001216 E->setCond(Record.readSubExpr());
1217 E->setLHS(Record.readSubExpr());
1218 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001219 E->setBuiltinLoc(readSourceLocation());
1220 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001221 E->setIsConditionTrue(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001222}
1223
Sebastian Redl70c751d2010-08-18 23:56:52 +00001224void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001225 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001226 E->setTokenLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001227}
1228
Sebastian Redl70c751d2010-08-18 23:56:52 +00001229void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001230 VisitExpr(E);
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001231 SmallVector<Expr *, 16> Exprs;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001232 unsigned NumExprs = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001233 while (NumExprs--)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001234 Exprs.push_back(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001235 E->setExprs(Record.getContext(), Exprs);
John McCall3ce3d232019-12-13 03:37:23 -05001236 E->setBuiltinLoc(readSourceLocation());
1237 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001238}
1239
Hal Finkelc4d7c822013-09-18 03:29:45 +00001240void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1241 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001242 E->BuiltinLoc = readSourceLocation();
1243 E->RParenLoc = readSourceLocation();
1244 E->TInfo = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001245 E->SrcExpr = Record.readSubExpr();
Hal Finkelc4d7c822013-09-18 03:29:45 +00001246}
1247
Sebastian Redl70c751d2010-08-18 23:56:52 +00001248void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001249 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001250 E->setBlockDecl(readDeclAs<BlockDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001251}
1252
Peter Collingbourne91147592011-04-15 00:35:48 +00001253void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1254 VisitExpr(E);
Bruno Riccidb076832019-01-26 14:15:10 +00001255
1256 unsigned NumAssocs = Record.readInt();
1257 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
Bruno Ricci94498c72019-01-26 13:58:15 +00001258 E->ResultIndex = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001259 E->GenericSelectionExprBits.GenericLoc = readSourceLocation();
1260 E->DefaultLoc = readSourceLocation();
1261 E->RParenLoc = readSourceLocation();
Bruno Riccidb076832019-01-26 14:15:10 +00001262
1263 Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1264 // Add 1 to account for the controlling expression which is the first
1265 // expression in the trailing array of Stmt *. This is not needed for
1266 // the trailing array of TypeSourceInfo *.
1267 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1268 Stmts[I] = Record.readSubExpr();
1269
1270 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1271 for (unsigned I = 0, N = NumAssocs; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001272 TSIs[I] = readTypeSourceInfo();
Peter Collingbourne91147592011-04-15 00:35:48 +00001273}
1274
John McCallfe96e0b2011-11-06 09:01:30 +00001275void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1276 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001277 unsigned numSemanticExprs = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001278 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001279 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001280
1281 // Read the syntactic expression.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001282 E->getSubExprsBuffer()[0] = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001283
1284 // Read all the semantic expressions.
1285 for (unsigned i = 0; i != numSemanticExprs; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001286 Expr *subExpr = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001287 E->getSubExprsBuffer()[i+1] = subExpr;
1288 }
1289}
1290
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001291void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1292 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001293 E->Op = AtomicExpr::AtomicOp(Record.readInt());
Richard Smithaa22a8c2012-04-10 22:49:28 +00001294 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1295 for (unsigned I = 0; I != E->NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001296 E->SubExprs[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001297 E->BuiltinLoc = readSourceLocation();
1298 E->RParenLoc = readSourceLocation();
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001299}
1300
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001301//===----------------------------------------------------------------------===//
1302// Objective-C Expressions and Statements
1303
Sebastian Redl70c751d2010-08-18 23:56:52 +00001304void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001305 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001306 E->setString(cast<StringLiteral>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -05001307 E->setAtLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001308}
1309
Patrick Beard0caa3942012-04-19 00:25:12 +00001310void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001311 VisitExpr(E);
1312 // could be one of several IntegerLiteral, FloatLiteral, etc.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001313 E->SubExpr = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -05001314 E->BoxingMethod = readDeclAs<ObjCMethodDecl>();
1315 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001316}
1317
1318void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1319 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001320 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001321 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1322 Expr **Elements = E->getElements();
1323 for (unsigned I = 0, N = NumElements; I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001324 Elements[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001325 E->ArrayWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1326 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001327}
1328
1329void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1330 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001331 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001332 assert(NumElements == E->getNumElements() && "Wrong number of elements");
David L. Jonesbe1557a2016-12-21 00:17:49 +00001333 bool HasPackExpansions = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001334 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001335 auto *KeyValues =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001336 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001337 auto *Expansions =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001338 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001339 for (unsigned I = 0; I != NumElements; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001340 KeyValues[I].Key = Record.readSubExpr();
1341 KeyValues[I].Value = Record.readSubExpr();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001342 if (HasPackExpansions) {
John McCall3ce3d232019-12-13 03:37:23 -05001343 Expansions[I].EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001344 Expansions[I].NumExpansionsPlusOne = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001345 }
1346 }
John McCall3ce3d232019-12-13 03:37:23 -05001347 E->DictWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1348 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001349}
1350
Sebastian Redl70c751d2010-08-18 23:56:52 +00001351void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001352 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001353 E->setEncodedTypeSourceInfo(readTypeSourceInfo());
1354 E->setAtLoc(readSourceLocation());
1355 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001356}
1357
Sebastian Redl70c751d2010-08-18 23:56:52 +00001358void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001359 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001360 E->setSelector(Record.readSelector());
John McCall3ce3d232019-12-13 03:37:23 -05001361 E->setAtLoc(readSourceLocation());
1362 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001363}
1364
Sebastian Redl70c751d2010-08-18 23:56:52 +00001365void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001366 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001367 E->setProtocol(readDeclAs<ObjCProtocolDecl>());
1368 E->setAtLoc(readSourceLocation());
1369 E->ProtoLoc = readSourceLocation();
1370 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001371}
1372
Sebastian Redl70c751d2010-08-18 23:56:52 +00001373void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001374 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001375 E->setDecl(readDeclAs<ObjCIvarDecl>());
1376 E->setLocation(readSourceLocation());
1377 E->setOpLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001378 E->setBase(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001379 E->setIsArrow(Record.readInt());
1380 E->setIsFreeIvar(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001381}
1382
Sebastian Redl70c751d2010-08-18 23:56:52 +00001383void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001384 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001385 unsigned MethodRefFlags = Record.readInt();
1386 bool Implicit = Record.readInt() != 0;
John McCallb7bd14f2010-12-02 01:19:52 +00001387 if (Implicit) {
John McCall3ce3d232019-12-13 03:37:23 -05001388 auto *Getter = readDeclAs<ObjCMethodDecl>();
1389 auto *Setter = readDeclAs<ObjCMethodDecl>();
Argyrios Kyrtzidisab468b02012-03-30 00:19:18 +00001390 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCallb7bd14f2010-12-02 01:19:52 +00001391 } else {
John McCall3ce3d232019-12-13 03:37:23 -05001392 E->setExplicitProperty(readDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001393 }
John McCall3ce3d232019-12-13 03:37:23 -05001394 E->setLocation(readSourceLocation());
1395 E->setReceiverLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001396 switch (Record.readInt()) {
John McCallb7bd14f2010-12-02 01:19:52 +00001397 case 0:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001398 E->setBase(Record.readSubExpr());
John McCallb7bd14f2010-12-02 01:19:52 +00001399 break;
1400 case 1:
David L. Jonesbe1557a2016-12-21 00:17:49 +00001401 E->setSuperReceiver(Record.readType());
John McCallb7bd14f2010-12-02 01:19:52 +00001402 break;
1403 case 2:
John McCall3ce3d232019-12-13 03:37:23 -05001404 E->setClassReceiver(readDeclAs<ObjCInterfaceDecl>());
John McCallb7bd14f2010-12-02 01:19:52 +00001405 break;
1406 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001407}
1408
Ted Kremeneke65b0862012-03-06 20:05:56 +00001409void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1410 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001411 E->setRBracket(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001412 E->setBaseExpr(Record.readSubExpr());
1413 E->setKeyExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001414 E->GetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1415 E->SetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001416}
1417
Sebastian Redl70c751d2010-08-18 23:56:52 +00001418void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001419 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001420 assert(Record.peekInt() == E->getNumArgs());
1421 Record.skipInts(1);
1422 unsigned NumStoredSelLocs = Record.readInt();
1423 E->SelLocsKind = Record.readInt();
1424 E->setDelegateInitCall(Record.readInt());
1425 E->IsImplicit = Record.readInt();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001426 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
Douglas Gregor9a129192010-04-21 00:45:42 +00001427 switch (Kind) {
1428 case ObjCMessageExpr::Instance:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001429 E->setInstanceReceiver(Record.readSubExpr());
Douglas Gregor9a129192010-04-21 00:45:42 +00001430 break;
1431
1432 case ObjCMessageExpr::Class:
John McCall3ce3d232019-12-13 03:37:23 -05001433 E->setClassReceiver(readTypeSourceInfo());
Douglas Gregor9a129192010-04-21 00:45:42 +00001434 break;
1435
1436 case ObjCMessageExpr::SuperClass:
1437 case ObjCMessageExpr::SuperInstance: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001438 QualType T = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001439 SourceLocation SuperLoc = readSourceLocation();
Douglas Gregor9a129192010-04-21 00:45:42 +00001440 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1441 break;
1442 }
1443 }
1444
1445 assert(Kind == E->getReceiverKind());
1446
David L. Jonesbe1557a2016-12-21 00:17:49 +00001447 if (Record.readInt())
John McCall3ce3d232019-12-13 03:37:23 -05001448 E->setMethodDecl(readDeclAs<ObjCMethodDecl>());
Douglas Gregor9a129192010-04-21 00:45:42 +00001449 else
David L. Jonesb6a8f022016-12-21 04:34:52 +00001450 E->setSelector(Record.readSelector());
Douglas Gregor9a129192010-04-21 00:45:42 +00001451
John McCall3ce3d232019-12-13 03:37:23 -05001452 E->LBracLoc = readSourceLocation();
1453 E->RBracLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001454
1455 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001456 E->setArg(I, Record.readSubExpr());
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00001457
1458 SourceLocation *Locs = E->getStoredSelLocs();
1459 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001460 Locs[I] = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001461}
1462
Sebastian Redl70c751d2010-08-18 23:56:52 +00001463void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001464 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001465 S->setElement(Record.readSubStmt());
1466 S->setCollection(Record.readSubExpr());
1467 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001468 S->setForLoc(readSourceLocation());
1469 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001470}
1471
Sebastian Redl70c751d2010-08-18 23:56:52 +00001472void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001473 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001474 S->setCatchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001475 S->setCatchParamDecl(readDeclAs<VarDecl>());
1476 S->setAtCatchLoc(readSourceLocation());
1477 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001478}
1479
Sebastian Redl70c751d2010-08-18 23:56:52 +00001480void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001481 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001482 S->setFinallyBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001483 S->setAtFinallyLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001484}
1485
John McCall31168b02011-06-15 23:02:42 +00001486void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001487 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001488 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001489 S->setAtLoc(readSourceLocation());
John McCall31168b02011-06-15 23:02:42 +00001490}
1491
Sebastian Redl70c751d2010-08-18 23:56:52 +00001492void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001493 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001494 assert(Record.peekInt() == S->getNumCatchStmts());
1495 Record.skipInts(1);
1496 bool HasFinally = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001497 S->setTryBody(Record.readSubStmt());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001498 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001499 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
Douglas Gregor96c79492010-04-23 22:50:49 +00001500
Douglas Gregor96c79492010-04-23 22:50:49 +00001501 if (HasFinally)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001502 S->setFinallyStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001503 S->setAtTryLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001504}
1505
Sebastian Redl70c751d2010-08-18 23:56:52 +00001506void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001507 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001508 S->setSynchExpr(Record.readSubStmt());
1509 S->setSynchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001510 S->setAtSynchronizedLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001511}
1512
Sebastian Redl70c751d2010-08-18 23:56:52 +00001513void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001514 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001515 S->setThrowExpr(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001516 S->setThrowLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001517}
1518
Ted Kremeneke65b0862012-03-06 20:05:56 +00001519void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1520 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001521 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001522 E->setLocation(readSourceLocation());
Ted Kremeneke65b0862012-03-06 20:05:56 +00001523}
1524
Erik Pilkington29099de2016-07-16 00:35:23 +00001525void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1526 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001527 SourceRange R = Record.readSourceRange();
Erik Pilkington29099de2016-07-16 00:35:23 +00001528 E->AtLoc = R.getBegin();
1529 E->RParen = R.getEnd();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001530 E->VersionToCheck = Record.readVersionTuple();
Erik Pilkington29099de2016-07-16 00:35:23 +00001531}
1532
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001533//===----------------------------------------------------------------------===//
1534// C++ Expressions and Statements
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001535//===----------------------------------------------------------------------===//
1536
Sebastian Redl70c751d2010-08-18 23:56:52 +00001537void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001538 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001539 S->CatchLoc = readSourceLocation();
1540 S->ExceptionDecl = readDeclAs<VarDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001541 S->HandlerBlock = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001542}
1543
Sebastian Redl70c751d2010-08-18 23:56:52 +00001544void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001545 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001546 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1547 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -05001548 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001549 S->getStmts()[0] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001550 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001551 S->getStmts()[i + 1] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001552}
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001553
Richard Smith02e85f32011-04-14 22:09:26 +00001554void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1555 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001556 S->ForLoc = readSourceLocation();
1557 S->CoawaitLoc = readSourceLocation();
1558 S->ColonLoc = readSourceLocation();
1559 S->RParenLoc = readSourceLocation();
Richard Smith8baa5002018-09-28 18:44:09 +00001560 S->setInit(Record.readSubStmt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001561 S->setRangeStmt(Record.readSubStmt());
1562 S->setBeginStmt(Record.readSubStmt());
1563 S->setEndStmt(Record.readSubStmt());
1564 S->setCond(Record.readSubExpr());
1565 S->setInc(Record.readSubExpr());
1566 S->setLoopVarStmt(Record.readSubStmt());
1567 S->setBody(Record.readSubStmt());
Richard Smith02e85f32011-04-14 22:09:26 +00001568}
1569
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001570void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1571 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001572 S->KeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001573 S->IsIfExists = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001574 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001575 S->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001576 S->SubStmt = Record.readSubStmt();
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001577}
1578
Sebastian Redl70c751d2010-08-18 23:56:52 +00001579void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001580 VisitCallExpr(E);
Bruno Riccifeb19232018-12-21 16:51:57 +00001581 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1582 E->CXXOperatorCallExprBits.FPFeatures = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001583 E->Range = Record.readSourceRange();
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001584}
1585
Richard Smith778dc0f2019-10-19 00:04:38 +00001586void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1587 CXXRewrittenBinaryOperator *E) {
1588 VisitExpr(E);
1589 E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1590 E->SemanticForm = Record.readSubExpr();
1591}
1592
Sebastian Redl70c751d2010-08-18 23:56:52 +00001593void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001594 VisitExpr(E);
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001595
1596 unsigned NumArgs = Record.readInt();
1597 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1598
1599 E->CXXConstructExprBits.Elidable = Record.readInt();
1600 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1601 E->CXXConstructExprBits.ListInitialization = Record.readInt();
1602 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1603 E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1604 E->CXXConstructExprBits.ConstructionKind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001605 E->CXXConstructExprBits.Loc = readSourceLocation();
1606 E->Constructor = readDeclAs<CXXConstructorDecl>();
1607 E->ParenOrBraceRange = readSourceRange();
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001608
1609 for (unsigned I = 0; I != NumArgs; ++I)
1610 E->setArg(I, Record.readSubExpr());
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001611}
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001612
Richard Smith5179eb72016-06-28 19:03:57 +00001613void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1614 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001615 E->Constructor = readDeclAs<CXXConstructorDecl>();
1616 E->Loc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001617 E->ConstructsVirtualBase = Record.readInt();
1618 E->InheritedFromVirtualBase = Record.readInt();
Richard Smith5179eb72016-06-28 19:03:57 +00001619}
1620
Sebastian Redl70c751d2010-08-18 23:56:52 +00001621void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001622 VisitCXXConstructExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001623 E->TSI = readTypeSourceInfo();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001624}
1625
Douglas Gregore31e6062012-02-07 10:09:13 +00001626void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1627 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001628 unsigned NumCaptures = Record.readInt();
Douglas Gregor99ae8062012-02-14 17:54:36 +00001629 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
John McCall3ce3d232019-12-13 03:37:23 -05001630 E->IntroducerRange = readSourceRange();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001631 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001632 E->CaptureDefaultLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001633 E->ExplicitParams = Record.readInt();
1634 E->ExplicitResultType = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001635 E->ClosingBrace = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001636
Douglas Gregor99ae8062012-02-14 17:54:36 +00001637 // Read capture initializers.
1638 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1639 CEnd = E->capture_init_end();
1640 C != CEnd; ++C)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001641 *C = Record.readSubExpr();
Douglas Gregore31e6062012-02-07 10:09:13 +00001642}
1643
Richard Smithcc1b96d2013-06-12 22:31:48 +00001644void
1645ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1646 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001647 E->SubExpr = Record.readSubExpr();
Richard Smithcc1b96d2013-06-12 22:31:48 +00001648}
1649
Sebastian Redl70c751d2010-08-18 23:56:52 +00001650void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001651 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001652 SourceRange R = readSourceRange();
Douglas Gregor4478f852011-01-12 22:41:29 +00001653 E->Loc = R.getBegin();
1654 E->RParenLoc = R.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05001655 R = readSourceRange();
Fariborz Jahanianf0738712013-02-22 22:02:53 +00001656 E->AngleBrackets = R;
Sam Weinigd01101e2010-01-16 21:21:01 +00001657}
1658
Sebastian Redl70c751d2010-08-18 23:56:52 +00001659void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001660 return VisitCXXNamedCastExpr(E);
1661}
1662
Sebastian Redl70c751d2010-08-18 23:56:52 +00001663void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001664 return VisitCXXNamedCastExpr(E);
1665}
1666
Sebastian Redl70c751d2010-08-18 23:56:52 +00001667void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001668 return VisitCXXNamedCastExpr(E);
1669}
1670
Sebastian Redl70c751d2010-08-18 23:56:52 +00001671void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001672 return VisitCXXNamedCastExpr(E);
1673}
1674
Sebastian Redl70c751d2010-08-18 23:56:52 +00001675void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001676 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001677 E->setLParenLoc(readSourceLocation());
1678 E->setRParenLoc(readSourceLocation());
Sam Weinigd01101e2010-01-16 21:21:01 +00001679}
1680
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001681void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1682 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001683 E->KWLoc = readSourceLocation();
1684 E->RParenLoc = readSourceLocation();
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001685}
1686
Richard Smithc67fdd42012-03-07 08:35:16 +00001687void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1688 VisitCallExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001689 E->UDSuffixLoc = readSourceLocation();
Richard Smithc67fdd42012-03-07 08:35:16 +00001690}
1691
Sebastian Redl70c751d2010-08-18 23:56:52 +00001692void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001693 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001694 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001695 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001696}
1697
Sebastian Redl70c751d2010-08-18 23:56:52 +00001698void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001699 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001700 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001701}
1702
Sebastian Redl70c751d2010-08-18 23:56:52 +00001703void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001704 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001705 E->setSourceRange(readSourceRange());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001706 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redlc67764e2010-07-22 22:43:28 +00001707 E->setTypeOperandSourceInfo(
John McCall3ce3d232019-12-13 03:37:23 -05001708 readTypeSourceInfo());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001709 return;
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001710 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001711
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001712 // typeid(42+2)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001713 E->setExprOperand(Record.readSubExpr());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001714}
1715
Sebastian Redl70c751d2010-08-18 23:56:52 +00001716void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001717 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001718 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001719 E->setImplicit(Record.readInt());
Chris Lattner98267332010-05-09 06:15:05 +00001720}
1721
Sebastian Redl70c751d2010-08-18 23:56:52 +00001722void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001723 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001724 E->CXXThrowExprBits.ThrowLoc = readSourceLocation();
Bruno Riccib7de97b2018-11-17 12:53:56 +00001725 E->Operand = Record.readSubExpr();
1726 E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
Chris Lattner98267332010-05-09 06:15:05 +00001727}
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001728
Sebastian Redl70c751d2010-08-18 23:56:52 +00001729void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattnere2437f42010-05-09 06:40:08 +00001730 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001731 E->Param = readDeclAs<ParmVarDecl>();
1732 E->UsedContext = readDeclAs<DeclContext>();
1733 E->CXXDefaultArgExprBits.Loc = readSourceLocation();
Chris Lattnercba86142010-05-10 00:25:06 +00001734}
1735
Richard Smith852c9db2013-04-20 22:23:05 +00001736void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1737 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001738 E->Field = readDeclAs<FieldDecl>();
1739 E->UsedContext = readDeclAs<DeclContext>();
1740 E->CXXDefaultInitExprBits.Loc = readSourceLocation();
Richard Smith852c9db2013-04-20 22:23:05 +00001741}
1742
Sebastian Redl70c751d2010-08-18 23:56:52 +00001743void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001744 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001745 E->setTemporary(Record.readCXXTemporary());
1746 E->setSubExpr(Record.readSubExpr());
Chris Lattnercba86142010-05-10 00:25:06 +00001747}
1748
Sebastian Redl70c751d2010-08-18 23:56:52 +00001749void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001750 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001751 E->TypeInfo = readTypeSourceInfo();
1752 E->CXXScalarValueInitExprBits.RParenLoc = readSourceLocation();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001753}
1754
Sebastian Redl70c751d2010-08-18 23:56:52 +00001755void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001756 VisitExpr(E);
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001757
1758 bool IsArray = Record.readInt();
1759 bool HasInit = Record.readInt();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001760 unsigned NumPlacementArgs = Record.readInt();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001761 bool IsParenTypeId = Record.readInt();
1762
1763 E->CXXNewExprBits.IsGlobalNew = Record.readInt();
1764 E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
1765 E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1766 E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
1767
1768 assert((IsArray == E->isArray()) && "Wrong IsArray!");
1769 assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
1770 assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
1771 "Wrong NumPlacementArgs!");
1772 assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
1773 (void)IsArray;
1774 (void)HasInit;
1775 (void)NumPlacementArgs;
1776
John McCall3ce3d232019-12-13 03:37:23 -05001777 E->setOperatorNew(readDeclAs<FunctionDecl>());
1778 E->setOperatorDelete(readDeclAs<FunctionDecl>());
1779 E->AllocatedTypeInfo = readTypeSourceInfo();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001780 if (IsParenTypeId)
John McCall3ce3d232019-12-13 03:37:23 -05001781 E->getTrailingObjects<SourceRange>()[0] = readSourceRange();
1782 E->Range = readSourceRange();
1783 E->DirectInitRange = readSourceRange();
Chandler Carruth01718152010-10-25 08:47:36 +00001784
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001785 // Install all the subexpressions.
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001786 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
1787 N = E->raw_arg_end();
1788 I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001789 *I = Record.readSubStmt();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001790}
1791
Sebastian Redl70c751d2010-08-18 23:56:52 +00001792void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001793 VisitExpr(E);
Bruno Ricci91728fc2018-12-03 12:32:32 +00001794 E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
1795 E->CXXDeleteExprBits.ArrayForm = Record.readInt();
1796 E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
1797 E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001798 E->OperatorDelete = readDeclAs<FunctionDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001799 E->Argument = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001800 E->CXXDeleteExprBits.Loc = readSourceLocation();
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001801}
Chris Lattnercba86142010-05-10 00:25:06 +00001802
Sebastian Redl70c751d2010-08-18 23:56:52 +00001803void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001804 VisitExpr(E);
1805
David L. Jonesb6a8f022016-12-21 04:34:52 +00001806 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001807 E->IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001808 E->OperatorLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001809 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001810 E->ScopeType = readTypeSourceInfo();
1811 E->ColonColonLoc = readSourceLocation();
1812 E->TildeLoc = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001813
John McCall3ce3d232019-12-13 03:37:23 -05001814 IdentifierInfo *II = Record.readIdentifier();
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001815 if (II)
John McCall3ce3d232019-12-13 03:37:23 -05001816 E->setDestroyedType(II, readSourceLocation());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001817 else
John McCall3ce3d232019-12-13 03:37:23 -05001818 E->setDestroyedType(readTypeSourceInfo());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001819}
1820
John McCall5d413782010-12-06 08:20:24 +00001821void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001822 VisitExpr(E);
John McCall28fc7092011-11-10 05:35:25 +00001823
David L. Jonesbe1557a2016-12-21 00:17:49 +00001824 unsigned NumObjects = Record.readInt();
John McCall28fc7092011-11-10 05:35:25 +00001825 assert(NumObjects == E->getNumObjects());
Akira Hatanaka40568fe2020-03-10 14:06:25 -07001826 for (unsigned i = 0; i != NumObjects; ++i) {
1827 unsigned CleanupKind = Record.readInt();
1828 ExprWithCleanups::CleanupObject Obj;
1829 if (CleanupKind == COK_Block)
1830 Obj = readDeclAs<BlockDecl>();
1831 else if (CleanupKind == COK_CompoundLiteral)
1832 Obj = cast<CompoundLiteralExpr>(Record.readSubExpr());
1833 else
1834 llvm_unreachable("unexpected cleanup object type");
1835 E->getTrailingObjects<ExprWithCleanups::CleanupObject>()[i] = Obj;
1836 }
John McCall28fc7092011-11-10 05:35:25 +00001837
David L. Jonesbe1557a2016-12-21 00:17:49 +00001838 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001839 E->SubExpr = Record.readSubExpr();
Chris Lattnere2437f42010-05-09 06:40:08 +00001840}
1841
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001842void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1843 CXXDependentScopeMemberExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001844 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001845
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001846 bool HasTemplateKWAndArgsInfo = Record.readInt();
1847 unsigned NumTemplateArgs = Record.readInt();
1848 bool HasFirstQualifierFoundInScope = Record.readInt();
1849
1850 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
1851 "Wrong HasTemplateKWAndArgsInfo!");
1852 assert(
1853 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
1854 "Wrong HasFirstQualifierFoundInScope!");
1855
1856 if (HasTemplateKWAndArgsInfo)
James Y Knighte7d82282015-12-29 18:15:14 +00001857 ReadTemplateKWAndArgsInfo(
1858 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001859 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001860
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001861 assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
1862 "Wrong NumTemplateArgs!");
1863
1864 E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001865 E->CXXDependentScopeMemberExprBits.OperatorLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001866 E->BaseType = Record.readType();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001867 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001868 E->Base = Record.readSubExpr();
1869
1870 if (HasFirstQualifierFoundInScope)
John McCall3ce3d232019-12-13 03:37:23 -05001871 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001872
John McCall3ce3d232019-12-13 03:37:23 -05001873 E->MemberNameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001874}
1875
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001876void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001877ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001878 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001879
David L. Jonesbe1557a2016-12-21 00:17:49 +00001880 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001881 ReadTemplateKWAndArgsInfo(
1882 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1883 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001884 /*NumTemplateArgs=*/Record.readInt());
Douglas Gregor3a43fd62011-02-25 20:49:16 +00001885
David L. Jonesb6a8f022016-12-21 04:34:52 +00001886 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001887 E->NameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001888}
1889
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001890void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001891ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001892 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001893 assert(Record.peekInt() == E->arg_size() &&
1894 "Read wrong record during creation ?");
1895 Record.skipInts(1);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001896 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001897 E->setArg(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001898 E->TSI = readTypeSourceInfo();
1899 E->setLParenLoc(readSourceLocation());
1900 E->setRParenLoc(readSourceLocation());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001901}
1902
Sebastian Redl70c751d2010-08-18 23:56:52 +00001903void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001904 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001905
Bruno Riccid7628d92019-01-09 15:43:19 +00001906 unsigned NumResults = Record.readInt();
1907 bool HasTemplateKWAndArgsInfo = Record.readInt();
1908 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
1909 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
1910 "Wrong HasTemplateKWAndArgsInfo!");
1911
1912 if (HasTemplateKWAndArgsInfo) {
1913 unsigned NumTemplateArgs = Record.readInt();
James Y Knighte7d82282015-12-29 18:15:14 +00001914 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1915 E->getTrailingTemplateArgumentLoc(),
Bruno Riccid7628d92019-01-09 15:43:19 +00001916 NumTemplateArgs);
1917 assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
1918 "Wrong NumTemplateArgs!");
1919 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001920
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001921 UnresolvedSet<8> Decls;
Bruno Riccid7628d92019-01-09 15:43:19 +00001922 for (unsigned I = 0; I != NumResults; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -05001923 auto *D = readDeclAs<NamedDecl>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001924 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001925 Decls.addDecl(D, AS);
1926 }
Bruno Riccid7628d92019-01-09 15:43:19 +00001927
1928 DeclAccessPair *Results = E->getTrailingResults();
1929 UnresolvedSetIterator Iter = Decls.begin();
1930 for (unsigned I = 0; I != NumResults; ++I) {
1931 Results[I] = (Iter + I).getPair();
1932 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001933
John McCall3ce3d232019-12-13 03:37:23 -05001934 E->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001935 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001936}
1937
Sebastian Redl70c751d2010-08-18 23:56:52 +00001938void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001939 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00001940 E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
1941 E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001942 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001943 E->BaseType = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001944 E->OperatorLoc = readSourceLocation();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001945}
1946
Sebastian Redl70c751d2010-08-18 23:56:52 +00001947void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001948 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00001949 E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
1950 E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001951 E->NamingClass = readDeclAs<CXXRecordDecl>();
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00001952}
1953
Douglas Gregor29c42f22012-02-24 07:38:34 +00001954void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1955 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001956 E->TypeTraitExprBits.NumArgs = Record.readInt();
1957 E->TypeTraitExprBits.Kind = Record.readInt();
1958 E->TypeTraitExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001959 SourceRange Range = readSourceRange();
Jordan Rose99e80c12013-12-20 01:26:47 +00001960 E->Loc = Range.getBegin();
1961 E->RParenLoc = Range.getEnd();
1962
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001963 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001964 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001965 Args[I] = readTypeSourceInfo();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001966}
1967
John Wiegley6242b6a2011-04-28 00:16:57 +00001968void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1969 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001970 E->ATT = (ArrayTypeTrait)Record.readInt();
1971 E->Value = (unsigned int)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001972 SourceRange Range = readSourceRange();
John Wiegley6242b6a2011-04-28 00:16:57 +00001973 E->Loc = Range.getBegin();
1974 E->RParen = Range.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05001975 E->QueriedType = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001976 E->Dimension = Record.readSubExpr();
John Wiegley6242b6a2011-04-28 00:16:57 +00001977}
1978
John Wiegleyf9f65842011-04-25 06:54:41 +00001979void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1980 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001981 E->ET = (ExpressionTrait)Record.readInt();
1982 E->Value = (bool)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001983 SourceRange Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001984 E->QueriedExpression = Record.readSubExpr();
John Wiegleyf9f65842011-04-25 06:54:41 +00001985 E->Loc = Range.getBegin();
1986 E->RParen = Range.getEnd();
1987}
1988
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001989void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1990 VisitExpr(E);
Bruno Riccid56edfe2019-01-08 14:44:34 +00001991 E->CXXNoexceptExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001992 E->Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001993 E->Operand = Record.readSubExpr();
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001994}
1995
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001996void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1997 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001998 E->EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001999 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002000 E->Pattern = Record.readSubExpr();
Douglas Gregore8e9dd62011-01-03 17:17:50 +00002001}
2002
Douglas Gregor820ba7b2011-01-04 17:33:58 +00002003void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2004 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002005 unsigned NumPartialArgs = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002006 E->OperatorLoc = readSourceLocation();
2007 E->PackLoc = readSourceLocation();
2008 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002009 E->Pack = Record.readDeclAs<NamedDecl>();
Richard Smithd784e682015-09-23 21:41:42 +00002010 if (E->isPartiallySubstituted()) {
2011 assert(E->Length == NumPartialArgs);
James Y Knighte00a67e2015-12-31 04:18:25 +00002012 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
Richard Smithd784e682015-09-23 21:41:42 +00002013 *E = I + NumPartialArgs;
2014 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002015 new (I) TemplateArgument(Record.readTemplateArgument());
Richard Smithd784e682015-09-23 21:41:42 +00002016 } else if (!E->isValueDependent()) {
David L. Jonesbe1557a2016-12-21 00:17:49 +00002017 E->Length = Record.readInt();
Richard Smithd784e682015-09-23 21:41:42 +00002018 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00002019}
2020
John McCallfa194042011-07-15 07:00:14 +00002021void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
2022 SubstNonTypeTemplateParmExpr *E) {
2023 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002024 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
2025 E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002026 E->Replacement = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002027}
2028
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002029void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
2030 SubstNonTypeTemplateParmPackExpr *E) {
2031 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002032 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002033 TemplateArgument ArgPack = Record.readTemplateArgument();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002034 if (ArgPack.getKind() != TemplateArgument::Pack)
2035 return;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002036
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002037 E->Arguments = ArgPack.pack_begin();
2038 E->NumArguments = ArgPack.pack_size();
John McCall3ce3d232019-12-13 03:37:23 -05002039 E->NameLoc = readSourceLocation();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002040}
2041
Richard Smithb15fe3a2012-09-12 00:56:43 +00002042void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2043 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002044 E->NumParameters = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002045 E->ParamPack = readDeclAs<ParmVarDecl>();
2046 E->NameLoc = readSourceLocation();
Richard Smithb2997f52019-05-21 20:10:50 +00002047 auto **Parms = E->getTrailingObjects<VarDecl *>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00002048 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
John McCall3ce3d232019-12-13 03:37:23 -05002049 Parms[i] = readDeclAs<VarDecl>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00002050}
2051
Douglas Gregorfe314812011-06-21 17:03:29 +00002052void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
2053 VisitExpr(E);
Tykerb0561b32019-11-17 11:41:55 +01002054 bool HasMaterialzedDecl = Record.readInt();
2055 if (HasMaterialzedDecl)
2056 E->State = cast<LifetimeExtendedTemporaryDecl>(Record.readDecl());
2057 else
2058 E->State = Record.readSubExpr();
Douglas Gregorfe314812011-06-21 17:03:29 +00002059}
2060
Richard Smith0f0af192014-11-08 05:07:16 +00002061void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
2062 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002063 E->LParenLoc = readSourceLocation();
2064 E->EllipsisLoc = readSourceLocation();
2065 E->RParenLoc = readSourceLocation();
Richard Smithc7214f62019-05-13 08:31:14 +00002066 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002067 E->SubExprs[0] = Record.readSubExpr();
2068 E->SubExprs[1] = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002069 E->Opcode = (BinaryOperatorKind)Record.readInt();
Richard Smith0f0af192014-11-08 05:07:16 +00002070}
2071
John McCall8d69a212010-11-15 23:31:06 +00002072void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
2073 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002074 E->SourceExpr = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05002075 E->OpaqueValueExprBits.Loc = readSourceLocation();
Akira Hatanaka797afe32018-03-20 01:47:58 +00002076 E->setIsUnique(Record.readInt());
John McCall8d69a212010-11-15 23:31:06 +00002077}
2078
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00002079void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
2080 llvm_unreachable("Cannot read TypoExpr nodes");
2081}
2082
Haojian Wu733edf92020-03-19 16:30:40 +01002083void ASTStmtReader::VisitRecoveryExpr(RecoveryExpr *E) {
2084 VisitExpr(E);
2085 unsigned NumArgs = Record.readInt();
2086 E->BeginLoc = readSourceLocation();
2087 E->EndLoc = readSourceLocation();
2088 assert(
2089 (NumArgs == std::distance(E->children().begin(), E->children().end())) &&
2090 "Wrong NumArgs!");
2091 (void)NumArgs;
2092 for (Stmt *&Child : E->children())
2093 Child = Record.readSubStmt();
2094}
2095
Peter Collingbourne41f85462011-02-09 21:07:24 +00002096//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002097// Microsoft Expressions and Statements
2098//===----------------------------------------------------------------------===//
John McCall5e77d762013-04-16 07:28:30 +00002099void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
2100 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002101 E->IsArrow = (Record.readInt() != 0);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002102 E->BaseExpr = Record.readSubExpr();
2103 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05002104 E->MemberLoc = readSourceLocation();
2105 E->TheDecl = readDeclAs<MSPropertyDecl>();
John McCall5e77d762013-04-16 07:28:30 +00002106}
2107
Alexey Bataevf7630272015-11-25 12:01:00 +00002108void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
2109 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002110 E->setBase(Record.readSubExpr());
2111 E->setIdx(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05002112 E->setRBracketLoc(readSourceLocation());
Alexey Bataevf7630272015-11-25 12:01:00 +00002113}
2114
John McCallfa194042011-07-15 07:00:14 +00002115void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
2116 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002117 E->setSourceRange(readSourceRange());
2118 std::string UuidStr = readString();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002119 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
John McCallfa194042011-07-15 07:00:14 +00002120 if (E->isTypeOperand()) { // __uuidof(ComType)
2121 E->setTypeOperandSourceInfo(
John McCall3ce3d232019-12-13 03:37:23 -05002122 readTypeSourceInfo());
John McCallfa194042011-07-15 07:00:14 +00002123 return;
2124 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002125
John McCallfa194042011-07-15 07:00:14 +00002126 // __uuidof(expr)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002127 E->setExprOperand(Record.readSubExpr());
John McCallfa194042011-07-15 07:00:14 +00002128}
2129
Nico Weber9b982072014-07-07 00:12:30 +00002130void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
2131 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002132 S->setLeaveLoc(readSourceLocation());
Nico Weber9b982072014-07-07 00:12:30 +00002133}
2134
John McCallfa194042011-07-15 07:00:14 +00002135void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
2136 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002137 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002138 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
2139 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002140}
2141
2142void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
2143 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002144 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002145 S->Block = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002146}
2147
2148void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
2149 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002150 S->IsCXXTry = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002151 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002152 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
2153 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002154}
2155
2156//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00002157// CUDA Expressions and Statements
2158//===----------------------------------------------------------------------===//
2159
2160void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2161 VisitCallExpr(E);
Richard Smithfd420792019-05-24 23:26:07 +00002162 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
Peter Collingbourne41f85462011-02-09 21:07:24 +00002163}
2164
John McCallfa194042011-07-15 07:00:14 +00002165//===----------------------------------------------------------------------===//
2166// OpenCL Expressions and Statements.
2167//===----------------------------------------------------------------------===//
2168void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2169 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002170 E->BuiltinLoc = readSourceLocation();
2171 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002172 E->SrcExpr = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002173}
2174
2175//===----------------------------------------------------------------------===//
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002176// OpenMP Directives.
2177//===----------------------------------------------------------------------===//
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002178
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002179void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
John McCall3ce3d232019-12-13 03:37:23 -05002180 E->setLocStart(readSourceLocation());
2181 E->setLocEnd(readSourceLocation());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002182 SmallVector<OMPClause *, 5> Clauses;
2183 for (unsigned i = 0; i < E->getNumClauses(); ++i)
John McCallc2f18312019-12-14 03:01:28 -05002184 Clauses.push_back(Record.readOMPClause());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002185 E->setClauses(Clauses);
Alexey Bataev68446b72014-07-18 07:47:19 +00002186 if (E->hasAssociatedStmt())
David L. Jonesb6a8f022016-12-21 04:34:52 +00002187 E->setAssociatedStmt(Record.readSubStmt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002188}
2189
Alexander Musman3aaab662014-08-19 11:27:13 +00002190void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2191 VisitStmt(D);
2192 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002193 Record.skipInts(2);
Alexander Musman3aaab662014-08-19 11:27:13 +00002194 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002195 D->setIterationVariable(Record.readSubExpr());
2196 D->setLastIteration(Record.readSubExpr());
2197 D->setCalcLastIteration(Record.readSubExpr());
2198 D->setPreCond(Record.readSubExpr());
2199 D->setCond(Record.readSubExpr());
2200 D->setInit(Record.readSubExpr());
2201 D->setInc(Record.readSubExpr());
2202 D->setPreInits(Record.readSubStmt());
Alexey Bataev3392d762016-02-16 11:18:12 +00002203 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
Carlo Bertollifc35ad22016-03-07 16:04:49 +00002204 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2205 isOpenMPDistributeDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002206 D->setIsLastIterVariable(Record.readSubExpr());
2207 D->setLowerBoundVariable(Record.readSubExpr());
2208 D->setUpperBoundVariable(Record.readSubExpr());
2209 D->setStrideVariable(Record.readSubExpr());
2210 D->setEnsureUpperBound(Record.readSubExpr());
2211 D->setNextLowerBound(Record.readSubExpr());
2212 D->setNextUpperBound(Record.readSubExpr());
2213 D->setNumIterations(Record.readSubExpr());
Alexander Musmanc6388682014-12-15 07:07:06 +00002214 }
Carlo Bertolli9925f152016-06-27 14:55:37 +00002215 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002216 D->setPrevLowerBoundVariable(Record.readSubExpr());
2217 D->setPrevUpperBoundVariable(Record.readSubExpr());
Carlo Bertolli8429d812017-02-17 21:29:13 +00002218 D->setDistInc(Record.readSubExpr());
2219 D->setPrevEnsureUpperBound(Record.readSubExpr());
Carlo Bertolliffafe102017-04-20 00:39:39 +00002220 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2221 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2222 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2223 D->setCombinedInit(Record.readSubExpr());
2224 D->setCombinedCond(Record.readSubExpr());
2225 D->setCombinedNextLowerBound(Record.readSubExpr());
2226 D->setCombinedNextUpperBound(Record.readSubExpr());
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00002227 D->setCombinedDistCond(Record.readSubExpr());
2228 D->setCombinedParForInDistCond(Record.readSubExpr());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002229 }
Alexander Musmana5f070a2014-10-01 06:03:56 +00002230 SmallVector<Expr *, 4> Sub;
2231 unsigned CollapsedNum = D->getCollapsedNumber();
2232 Sub.reserve(CollapsedNum);
2233 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002234 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002235 D->setCounters(Sub);
2236 Sub.clear();
2237 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002238 Sub.push_back(Record.readSubExpr());
Alexey Bataeva8899172015-08-06 12:30:57 +00002239 D->setPrivateCounters(Sub);
2240 Sub.clear();
2241 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002242 Sub.push_back(Record.readSubExpr());
Alexey Bataevb08f89f2015-08-14 12:25:37 +00002243 D->setInits(Sub);
2244 Sub.clear();
2245 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002246 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002247 D->setUpdates(Sub);
2248 Sub.clear();
2249 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002250 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002251 D->setFinals(Sub);
Alexey Bataevf8be4762019-08-14 19:30:06 +00002252 Sub.clear();
2253 for (unsigned i = 0; i < CollapsedNum; ++i)
2254 Sub.push_back(Record.readSubExpr());
2255 D->setDependentCounters(Sub);
2256 Sub.clear();
2257 for (unsigned i = 0; i < CollapsedNum; ++i)
2258 Sub.push_back(Record.readSubExpr());
2259 D->setDependentInits(Sub);
2260 Sub.clear();
2261 for (unsigned i = 0; i < CollapsedNum; ++i)
2262 Sub.push_back(Record.readSubExpr());
2263 D->setFinalsConditions(Sub);
Alexander Musman3aaab662014-08-19 11:27:13 +00002264}
2265
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002266void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002267 VisitStmt(D);
2268 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002269 Record.skipInts(1);
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002270 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002271 D->setHasCancel(Record.readInt());
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002272}
2273
2274void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002275 VisitOMPLoopDirective(D);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002276}
2277
Alexey Bataevf29276e2014-06-18 04:14:57 +00002278void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002279 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002280 D->setHasCancel(Record.readInt());
Alexey Bataevf29276e2014-06-18 04:14:57 +00002281}
2282
Alexander Musmanf82886e2014-09-18 05:12:34 +00002283void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2284 VisitOMPLoopDirective(D);
2285}
2286
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002287void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2288 VisitStmt(D);
2289 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002290 Record.skipInts(1);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002291 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002292 D->setHasCancel(Record.readInt());
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002293}
2294
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002295void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2296 VisitStmt(D);
2297 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002298 D->setHasCancel(Record.readInt());
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002299}
2300
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002301void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2302 VisitStmt(D);
2303 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002304 Record.skipInts(1);
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002305 VisitOMPExecutableDirective(D);
2306}
2307
Alexander Musman80c22892014-07-17 08:54:58 +00002308void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2309 VisitStmt(D);
2310 VisitOMPExecutableDirective(D);
2311}
2312
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002313void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2314 VisitStmt(D);
Alexey Bataev28c75412015-12-15 08:19:24 +00002315 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002316 Record.skipInts(1);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002317 VisitOMPExecutableDirective(D);
John McCall3ce3d232019-12-13 03:37:23 -05002318 D->DirName = Record.readDeclarationNameInfo();
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002319}
2320
Alexey Bataev4acb8592014-07-07 13:01:15 +00002321void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002322 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002323 D->setHasCancel(Record.readInt());
Alexey Bataev4acb8592014-07-07 13:01:15 +00002324}
2325
Alexander Musmane4e893b2014-09-23 09:33:00 +00002326void ASTStmtReader::VisitOMPParallelForSimdDirective(
2327 OMPParallelForSimdDirective *D) {
2328 VisitOMPLoopDirective(D);
2329}
2330
cchen47d60942019-12-05 13:43:48 -05002331void ASTStmtReader::VisitOMPParallelMasterDirective(
2332 OMPParallelMasterDirective *D) {
2333 VisitStmt(D);
2334 // The NumClauses field was read in ReadStmtFromStream.
2335 Record.skipInts(1);
2336 VisitOMPExecutableDirective(D);
2337}
2338
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002339void ASTStmtReader::VisitOMPParallelSectionsDirective(
2340 OMPParallelSectionsDirective *D) {
2341 VisitStmt(D);
2342 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002343 Record.skipInts(1);
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002344 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002345 D->setHasCancel(Record.readInt());
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002346}
2347
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002348void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2349 VisitStmt(D);
2350 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002351 Record.skipInts(1);
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002352 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002353 D->setHasCancel(Record.readInt());
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002354}
2355
Alexey Bataev68446b72014-07-18 07:47:19 +00002356void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2357 VisitStmt(D);
2358 VisitOMPExecutableDirective(D);
2359}
2360
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002361void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2362 VisitStmt(D);
2363 VisitOMPExecutableDirective(D);
2364}
2365
Alexey Bataev2df347a2014-07-18 10:17:07 +00002366void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2367 VisitStmt(D);
2368 VisitOMPExecutableDirective(D);
2369}
2370
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002371void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2372 VisitStmt(D);
Alexey Bataev169d96a2017-07-18 20:17:46 +00002373 // The NumClauses field was read in ReadStmtFromStream.
2374 Record.skipInts(1);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002375 VisitOMPExecutableDirective(D);
Alexey Bataev3b1b8952017-07-25 15:53:26 +00002376 D->setReductionRef(Record.readSubExpr());
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002377}
2378
Alexey Bataev6125da92014-07-21 11:26:11 +00002379void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2380 VisitStmt(D);
2381 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002382 Record.skipInts(1);
Alexey Bataev6125da92014-07-21 11:26:11 +00002383 VisitOMPExecutableDirective(D);
2384}
2385
Alexey Bataevc112e942020-02-28 09:52:15 -05002386void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective *D) {
2387 VisitStmt(D);
2388 // The NumClauses field was read in ReadStmtFromStream.
2389 Record.skipInts(1);
2390 VisitOMPExecutableDirective(D);
2391}
2392
Alexey Bataevfcba7c32020-03-20 07:03:01 -04002393void ASTStmtReader::VisitOMPScanDirective(OMPScanDirective *D) {
2394 VisitStmt(D);
2395 // The NumClauses field was read in ReadStmtFromStream.
2396 Record.skipInts(1);
2397 VisitOMPExecutableDirective(D);
2398}
2399
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002400void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2401 VisitStmt(D);
Alexey Bataev346265e2015-09-25 10:37:12 +00002402 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002403 Record.skipInts(1);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002404 VisitOMPExecutableDirective(D);
2405}
2406
Alexey Bataev0162e452014-07-22 10:10:35 +00002407void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2408 VisitStmt(D);
2409 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002410 Record.skipInts(1);
Alexey Bataev0162e452014-07-22 10:10:35 +00002411 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002412 D->setX(Record.readSubExpr());
2413 D->setV(Record.readSubExpr());
2414 D->setExpr(Record.readSubExpr());
2415 D->setUpdateExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002416 D->IsXLHSInRHSPart = Record.readInt() != 0;
2417 D->IsPostfixUpdate = Record.readInt() != 0;
Alexey Bataev0162e452014-07-22 10:10:35 +00002418}
2419
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002420void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2421 VisitStmt(D);
2422 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002423 Record.skipInts(1);
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002424 VisitOMPExecutableDirective(D);
2425}
2426
Michael Wong65f367f2015-07-21 13:44:28 +00002427void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2428 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002429 Record.skipInts(1);
Michael Wong65f367f2015-07-21 13:44:28 +00002430 VisitOMPExecutableDirective(D);
2431}
2432
Samuel Antaodf67fc42016-01-19 19:15:56 +00002433void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2434 OMPTargetEnterDataDirective *D) {
2435 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002436 Record.skipInts(1);
Samuel Antaodf67fc42016-01-19 19:15:56 +00002437 VisitOMPExecutableDirective(D);
2438}
2439
Samuel Antao72590762016-01-19 20:04:50 +00002440void ASTStmtReader::VisitOMPTargetExitDataDirective(
2441 OMPTargetExitDataDirective *D) {
2442 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002443 Record.skipInts(1);
Samuel Antao72590762016-01-19 20:04:50 +00002444 VisitOMPExecutableDirective(D);
2445}
2446
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002447void ASTStmtReader::VisitOMPTargetParallelDirective(
2448 OMPTargetParallelDirective *D) {
2449 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002450 Record.skipInts(1);
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002451 VisitOMPExecutableDirective(D);
2452}
2453
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002454void ASTStmtReader::VisitOMPTargetParallelForDirective(
2455 OMPTargetParallelForDirective *D) {
2456 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002457 D->setHasCancel(Record.readInt());
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002458}
2459
Alexey Bataev13314bf2014-10-09 04:18:56 +00002460void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2461 VisitStmt(D);
2462 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002463 Record.skipInts(1);
Alexey Bataev13314bf2014-10-09 04:18:56 +00002464 VisitOMPExecutableDirective(D);
2465}
2466
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002467void ASTStmtReader::VisitOMPCancellationPointDirective(
2468 OMPCancellationPointDirective *D) {
2469 VisitStmt(D);
2470 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002471 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002472}
2473
Alexey Bataev80909872015-07-02 11:25:17 +00002474void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2475 VisitStmt(D);
Alexey Bataev87933c72015-09-18 08:07:34 +00002476 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002477 Record.skipInts(1);
Alexey Bataev80909872015-07-02 11:25:17 +00002478 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002479 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev80909872015-07-02 11:25:17 +00002480}
2481
Alexey Bataev49f6e782015-12-01 04:18:41 +00002482void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2483 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002484 D->setHasCancel(Record.readInt());
Alexey Bataev49f6e782015-12-01 04:18:41 +00002485}
2486
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002487void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2488 VisitOMPLoopDirective(D);
2489}
2490
Alexey Bataev60e51c42019-10-10 20:13:02 +00002491void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2492 OMPMasterTaskLoopDirective *D) {
2493 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002494 D->setHasCancel(Record.readInt());
Alexey Bataev60e51c42019-10-10 20:13:02 +00002495}
2496
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002497void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2498 OMPMasterTaskLoopSimdDirective *D) {
2499 VisitOMPLoopDirective(D);
2500}
2501
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002502void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2503 OMPParallelMasterTaskLoopDirective *D) {
2504 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002505 D->setHasCancel(Record.readInt());
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002506}
2507
Alexey Bataev14a388f2019-10-25 10:27:13 -04002508void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2509 OMPParallelMasterTaskLoopSimdDirective *D) {
2510 VisitOMPLoopDirective(D);
2511}
2512
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002513void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2514 VisitOMPLoopDirective(D);
2515}
2516
Samuel Antao686c70c2016-05-26 17:30:50 +00002517void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2518 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002519 Record.skipInts(1);
Samuel Antao686c70c2016-05-26 17:30:50 +00002520 VisitOMPExecutableDirective(D);
2521}
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002522
Carlo Bertolli9925f152016-06-27 14:55:37 +00002523void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2524 OMPDistributeParallelForDirective *D) {
2525 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002526 D->setHasCancel(Record.readInt());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002527}
Samuel Antao686c70c2016-05-26 17:30:50 +00002528
Kelvin Li4a39add2016-07-05 05:00:15 +00002529void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2530 OMPDistributeParallelForSimdDirective *D) {
2531 VisitOMPLoopDirective(D);
2532}
2533
Kelvin Li787f3fc2016-07-06 04:45:38 +00002534void ASTStmtReader::VisitOMPDistributeSimdDirective(
2535 OMPDistributeSimdDirective *D) {
2536 VisitOMPLoopDirective(D);
2537}
2538
Kelvin Lia579b912016-07-14 02:54:56 +00002539void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2540 OMPTargetParallelForSimdDirective *D) {
2541 VisitOMPLoopDirective(D);
2542}
2543
Kelvin Li986330c2016-07-20 22:57:10 +00002544void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2545 VisitOMPLoopDirective(D);
2546}
2547
Kelvin Li02532872016-08-05 14:37:37 +00002548void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2549 OMPTeamsDistributeDirective *D) {
2550 VisitOMPLoopDirective(D);
2551}
2552
Kelvin Li4e325f72016-10-25 12:50:55 +00002553void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2554 OMPTeamsDistributeSimdDirective *D) {
2555 VisitOMPLoopDirective(D);
2556}
2557
Kelvin Li579e41c2016-11-30 23:51:03 +00002558void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2559 OMPTeamsDistributeParallelForSimdDirective *D) {
2560 VisitOMPLoopDirective(D);
2561}
2562
Kelvin Li7ade93f2016-12-09 03:24:30 +00002563void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2564 OMPTeamsDistributeParallelForDirective *D) {
2565 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002566 D->setHasCancel(Record.readInt());
Kelvin Li7ade93f2016-12-09 03:24:30 +00002567}
2568
Kelvin Libf594a52016-12-17 05:48:59 +00002569void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2570 VisitStmt(D);
2571 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002572 Record.skipInts(1);
Kelvin Libf594a52016-12-17 05:48:59 +00002573 VisitOMPExecutableDirective(D);
2574}
2575
Kelvin Li83c451e2016-12-25 04:52:54 +00002576void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2577 OMPTargetTeamsDistributeDirective *D) {
2578 VisitOMPLoopDirective(D);
2579}
2580
Kelvin Li80e8f562016-12-29 22:16:30 +00002581void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2582 OMPTargetTeamsDistributeParallelForDirective *D) {
2583 VisitOMPLoopDirective(D);
Alexey Bataev16e79882017-11-22 21:12:03 +00002584 D->setHasCancel(Record.readInt());
Kelvin Li80e8f562016-12-29 22:16:30 +00002585}
2586
Kelvin Li1851df52017-01-03 05:23:48 +00002587void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2588 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2589 VisitOMPLoopDirective(D);
2590}
2591
Kelvin Lida681182017-01-10 18:08:18 +00002592void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2593 OMPTargetTeamsDistributeSimdDirective *D) {
2594 VisitOMPLoopDirective(D);
2595}
2596
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002597//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002598// ASTReader Implementation
2599//===----------------------------------------------------------------------===//
2600
Douglas Gregorde3ef502011-11-30 23:21:26 +00002601Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002602 switch (ReadingKind) {
Richard Smith629ff362013-07-31 00:26:46 +00002603 case Read_None:
2604 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002605 case Read_Decl:
2606 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00002607 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002608 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002609 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002610 }
2611
2612 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002613}
2614
Douglas Gregorde3ef502011-11-30 23:21:26 +00002615Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00002616 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002617}
Chris Lattnere2437f42010-05-09 06:40:08 +00002618
Sebastian Redl2c499f62010-08-18 23:56:43 +00002619Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002620 return cast_or_null<Expr>(ReadSubStmt());
2621}
2622
Chris Lattnerf4262532009-04-27 05:41:06 +00002623// Within the bitstream, expressions are stored in Reverse Polish
2624// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002625// expression they are stored in. Subexpressions are stored from last to first.
2626// To evaluate expressions, we continue reading expressions and placing them on
2627// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00002628// stack. Evaluation terminates when we see a STMT_STOP record, and
2629// the single remaining expression on the stack is our result.
Douglas Gregorde3ef502011-11-30 23:21:26 +00002630Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002631 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00002632 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002633
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002634 // Map of offset to previously deserialized stmt. The offset points
George Burgess IV758cf9d2017-02-14 05:52:57 +00002635 // just after the stmt record.
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002636 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00002637
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002638#ifndef NDEBUG
2639 unsigned PrevNumStmts = StmtStack.size();
2640#endif
2641
David L. Jonesbe1557a2016-12-21 00:17:49 +00002642 ASTRecordReader Record(*this, F);
2643 ASTStmtReader Reader(Record, Cursor);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002644 Stmt::EmptyShell Empty;
2645
2646 while (true) {
JF Bastien0e828952019-06-26 19:50:12 +00002647 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2648 Cursor.advanceSkippingSubblocks();
2649 if (!MaybeEntry) {
2650 Error(toString(MaybeEntry.takeError()));
2651 return nullptr;
2652 }
2653 llvm::BitstreamEntry Entry = MaybeEntry.get();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002654
Chris Lattner0e6c9402013-01-20 02:38:54 +00002655 switch (Entry.Kind) {
2656 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2657 case llvm::BitstreamEntry::Error:
2658 Error("malformed block record in AST file");
Craig Toppera13603a2014-05-22 05:54:18 +00002659 return nullptr;
Chris Lattner0e6c9402013-01-20 02:38:54 +00002660 case llvm::BitstreamEntry::EndBlock:
2661 goto Done;
2662 case llvm::BitstreamEntry::Record:
2663 // The interesting case.
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002664 break;
2665 }
2666
Richard Smithdbafb6c2017-06-29 23:23:46 +00002667 ASTContext &Context = getContext();
Craig Toppera13603a2014-05-22 05:54:18 +00002668 Stmt *S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002669 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002670 bool IsStmtReference = false;
JF Bastien0e828952019-06-26 19:50:12 +00002671 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2672 if (!MaybeStmtCode) {
2673 Error(toString(MaybeStmtCode.takeError()));
2674 return nullptr;
2675 }
2676 switch ((StmtCode)MaybeStmtCode.get()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00002677 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002678 Finished = true;
2679 break;
2680
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002681 case STMT_REF_PTR:
2682 IsStmtReference = true;
2683 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2684 "No stmt was recorded for this offset reference!");
David L. Jonesbe1557a2016-12-21 00:17:49 +00002685 S = StmtEntries[Record.readInt()];
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002686 break;
2687
Sebastian Redl539c5062010-08-18 23:57:32 +00002688 case STMT_NULL_PTR:
Craig Toppera13603a2014-05-22 05:54:18 +00002689 S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002690 break;
2691
Sebastian Redl539c5062010-08-18 23:57:32 +00002692 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002693 S = new (Context) NullStmt(Empty);
2694 break;
2695
Sebastian Redl539c5062010-08-18 23:57:32 +00002696 case STMT_COMPOUND:
Benjamin Kramer07420902017-12-24 16:24:20 +00002697 S = CompoundStmt::CreateEmpty(
2698 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002699 break;
2700
Sebastian Redl539c5062010-08-18 23:57:32 +00002701 case STMT_CASE:
Bruno Ricci5b30571752018-10-28 12:30:53 +00002702 S = CaseStmt::CreateEmpty(
2703 Context,
2704 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002705 break;
2706
Sebastian Redl539c5062010-08-18 23:57:32 +00002707 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002708 S = new (Context) DefaultStmt(Empty);
2709 break;
2710
Sebastian Redl539c5062010-08-18 23:57:32 +00002711 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002712 S = new (Context) LabelStmt(Empty);
2713 break;
2714
Richard Smithc202b282012-04-14 00:33:13 +00002715 case STMT_ATTRIBUTED:
Alexander Kornienko20f6fc62012-07-09 10:04:07 +00002716 S = AttributedStmt::CreateEmpty(
2717 Context,
2718 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smithc202b282012-04-14 00:33:13 +00002719 break;
2720
Sebastian Redl539c5062010-08-18 23:57:32 +00002721 case STMT_IF:
Bruno Riccib1cc94b2018-10-27 21:12:20 +00002722 S = IfStmt::CreateEmpty(
2723 Context,
2724 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2725 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2726 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002727 break;
2728
Sebastian Redl539c5062010-08-18 23:57:32 +00002729 case STMT_SWITCH:
Bruno Riccie2806f82018-10-29 16:12:37 +00002730 S = SwitchStmt::CreateEmpty(
2731 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002732 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
Bruno Riccie2806f82018-10-29 16:12:37 +00002733 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002734 break;
2735
Sebastian Redl539c5062010-08-18 23:57:32 +00002736 case STMT_WHILE:
Bruno Riccibacf7512018-10-30 13:42:41 +00002737 S = WhileStmt::CreateEmpty(
2738 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002739 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002740 break;
2741
Sebastian Redl539c5062010-08-18 23:57:32 +00002742 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002743 S = new (Context) DoStmt(Empty);
2744 break;
Mike Stump11289f42009-09-09 15:08:12 +00002745
Sebastian Redl539c5062010-08-18 23:57:32 +00002746 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002747 S = new (Context) ForStmt(Empty);
2748 break;
2749
Sebastian Redl539c5062010-08-18 23:57:32 +00002750 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002751 S = new (Context) GotoStmt(Empty);
2752 break;
Mike Stump11289f42009-09-09 15:08:12 +00002753
Sebastian Redl539c5062010-08-18 23:57:32 +00002754 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002755 S = new (Context) IndirectGotoStmt(Empty);
2756 break;
2757
Sebastian Redl539c5062010-08-18 23:57:32 +00002758 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002759 S = new (Context) ContinueStmt(Empty);
2760 break;
2761
Sebastian Redl539c5062010-08-18 23:57:32 +00002762 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002763 S = new (Context) BreakStmt(Empty);
2764 break;
2765
Sebastian Redl539c5062010-08-18 23:57:32 +00002766 case STMT_RETURN:
Bruno Ricci023b1d12018-10-30 14:40:49 +00002767 S = ReturnStmt::CreateEmpty(
2768 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002769 break;
2770
Sebastian Redl539c5062010-08-18 23:57:32 +00002771 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002772 S = new (Context) DeclStmt(Empty);
2773 break;
2774
Chad Rosierde70e0e2012-08-25 00:11:56 +00002775 case STMT_GCCASM:
2776 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002777 break;
2778
Chad Rosiere30d4992012-08-24 23:51:02 +00002779 case STMT_MSASM:
2780 S = new (Context) MSAsmStmt(Empty);
2781 break;
2782
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002783 case STMT_CAPTURED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002784 S = CapturedStmt::CreateDeserialized(
2785 Context, Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002786 break;
2787
Bill Wendling7c44da22018-10-31 03:48:47 +00002788 case EXPR_CONSTANT:
Gauthier Harnisch83c7b612019-06-15 10:24:47 +00002789 S = ConstantExpr::CreateEmpty(
2790 Context,
2791 static_cast<ConstantExpr::ResultStorageKind>(
2792 Record[ASTStmtReader::NumExprFields]),
2793 Empty);
Bill Wendling7c44da22018-10-31 03:48:47 +00002794 break;
2795
Sebastian Redl539c5062010-08-18 23:57:32 +00002796 case EXPR_PREDEFINED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002797 S = PredefinedExpr::CreateEmpty(
2798 Context,
2799 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002800 break;
Mike Stump11289f42009-09-09 15:08:12 +00002801
Sebastian Redl539c5062010-08-18 23:57:32 +00002802 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002803 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00002804 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002805 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2806 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnara7945c982012-01-27 09:46:47 +00002807 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002808 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Richard Smith715f7a12019-06-11 17:50:32 +00002809 Record[ASTStmtReader::NumExprFields + 6] : 0);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002810 break;
Mike Stump11289f42009-09-09 15:08:12 +00002811
Sebastian Redl539c5062010-08-18 23:57:32 +00002812 case EXPR_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002813 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002814 break;
Mike Stump11289f42009-09-09 15:08:12 +00002815
Sebastian Redl539c5062010-08-18 23:57:32 +00002816 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002817 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002818 break;
Mike Stump11289f42009-09-09 15:08:12 +00002819
Sebastian Redl539c5062010-08-18 23:57:32 +00002820 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002821 S = new (Context) ImaginaryLiteral(Empty);
2822 break;
2823
Sebastian Redl539c5062010-08-18 23:57:32 +00002824 case EXPR_STRING_LITERAL:
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002825 S = StringLiteral::CreateEmpty(
2826 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002827 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002828 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2829 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002830 break;
2831
Sebastian Redl539c5062010-08-18 23:57:32 +00002832 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002833 S = new (Context) CharacterLiteral(Empty);
2834 break;
2835
Sebastian Redl539c5062010-08-18 23:57:32 +00002836 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002837 S = new (Context) ParenExpr(Empty);
2838 break;
2839
Sebastian Redl539c5062010-08-18 23:57:32 +00002840 case EXPR_PAREN_LIST:
Bruno Riccif49e1ca2018-11-20 16:20:40 +00002841 S = ParenListExpr::CreateEmpty(
2842 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002843 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00002844 break;
2845
Sebastian Redl539c5062010-08-18 23:57:32 +00002846 case EXPR_UNARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002847 S = new (Context) UnaryOperator(Empty);
2848 break;
2849
Sebastian Redl539c5062010-08-18 23:57:32 +00002850 case EXPR_OFFSETOF:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002851 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002852 Record[ASTStmtReader::NumExprFields],
2853 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00002854 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002855
Sebastian Redl539c5062010-08-18 23:57:32 +00002856 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00002857 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002858 break;
2859
Sebastian Redl539c5062010-08-18 23:57:32 +00002860 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002861 S = new (Context) ArraySubscriptExpr(Empty);
2862 break;
2863
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002864 case EXPR_OMP_ARRAY_SECTION:
2865 S = new (Context) OMPArraySectionExpr(Empty);
2866 break;
2867
Sebastian Redl539c5062010-08-18 23:57:32 +00002868 case EXPR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00002869 S = CallExpr::CreateEmpty(
2870 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002871 break;
2872
Haojian Wu733edf92020-03-19 16:30:40 +01002873 case EXPR_RECOVERY:
2874 S = RecoveryExpr::CreateEmpty(
2875 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
2876 break;
2877
Richard Smithdcf17de2019-06-06 23:24:15 +00002878 case EXPR_MEMBER:
2879 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
2880 Record[ASTStmtReader::NumExprFields + 1],
2881 Record[ASTStmtReader::NumExprFields + 2],
2882 Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002883 break;
2884
Sebastian Redl539c5062010-08-18 23:57:32 +00002885 case EXPR_BINARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002886 S = new (Context) BinaryOperator(Empty);
2887 break;
2888
Sebastian Redl539c5062010-08-18 23:57:32 +00002889 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002890 S = new (Context) CompoundAssignOperator(Empty);
2891 break;
2892
Sebastian Redl539c5062010-08-18 23:57:32 +00002893 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002894 S = new (Context) ConditionalOperator(Empty);
2895 break;
2896
John McCallc07a0c72011-02-17 10:25:35 +00002897 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2898 S = new (Context) BinaryConditionalOperator(Empty);
2899 break;
2900
Sebastian Redl539c5062010-08-18 23:57:32 +00002901 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002902 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002903 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002904 break;
2905
Sebastian Redl539c5062010-08-18 23:57:32 +00002906 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002907 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002908 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002909 break;
2910
Sebastian Redl539c5062010-08-18 23:57:32 +00002911 case EXPR_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002912 S = new (Context) CompoundLiteralExpr(Empty);
2913 break;
2914
Sebastian Redl539c5062010-08-18 23:57:32 +00002915 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002916 S = new (Context) ExtVectorElementExpr(Empty);
2917 break;
2918
Sebastian Redl539c5062010-08-18 23:57:32 +00002919 case EXPR_INIT_LIST:
Argyrios Kyrtzidis0f05fb92012-11-28 03:56:16 +00002920 S = new (Context) InitListExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002921 break;
2922
Sebastian Redl539c5062010-08-18 23:57:32 +00002923 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002924 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002925 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00002926
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002927 break;
2928
Yunzhong Gaocb779302015-06-10 00:27:52 +00002929 case EXPR_DESIGNATED_INIT_UPDATE:
2930 S = new (Context) DesignatedInitUpdateExpr(Empty);
2931 break;
2932
Sebastian Redl539c5062010-08-18 23:57:32 +00002933 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002934 S = new (Context) ImplicitValueInitExpr(Empty);
2935 break;
2936
Yunzhong Gaocb779302015-06-10 00:27:52 +00002937 case EXPR_NO_INIT:
2938 S = new (Context) NoInitExpr(Empty);
2939 break;
2940
Richard Smith410306b2016-12-12 02:53:20 +00002941 case EXPR_ARRAY_INIT_LOOP:
2942 S = new (Context) ArrayInitLoopExpr(Empty);
2943 break;
2944
2945 case EXPR_ARRAY_INIT_INDEX:
2946 S = new (Context) ArrayInitIndexExpr(Empty);
2947 break;
2948
Sebastian Redl539c5062010-08-18 23:57:32 +00002949 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002950 S = new (Context) VAArgExpr(Empty);
2951 break;
2952
Eric Fiselier708afb52019-05-16 21:04:15 +00002953 case EXPR_SOURCE_LOC:
2954 S = new (Context) SourceLocExpr(Empty);
2955 break;
2956
Sebastian Redl539c5062010-08-18 23:57:32 +00002957 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002958 S = new (Context) AddrLabelExpr(Empty);
2959 break;
2960
Sebastian Redl539c5062010-08-18 23:57:32 +00002961 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002962 S = new (Context) StmtExpr(Empty);
2963 break;
2964
Sebastian Redl539c5062010-08-18 23:57:32 +00002965 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002966 S = new (Context) ChooseExpr(Empty);
2967 break;
2968
Sebastian Redl539c5062010-08-18 23:57:32 +00002969 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002970 S = new (Context) GNUNullExpr(Empty);
2971 break;
2972
Sebastian Redl539c5062010-08-18 23:57:32 +00002973 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002974 S = new (Context) ShuffleVectorExpr(Empty);
2975 break;
Mike Stump11289f42009-09-09 15:08:12 +00002976
Hal Finkelc4d7c822013-09-18 03:29:45 +00002977 case EXPR_CONVERT_VECTOR:
2978 S = new (Context) ConvertVectorExpr(Empty);
2979 break;
2980
Sebastian Redl539c5062010-08-18 23:57:32 +00002981 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002982 S = new (Context) BlockExpr(Empty);
2983 break;
2984
Peter Collingbourne91147592011-04-15 00:35:48 +00002985 case EXPR_GENERIC_SELECTION:
Bruno Riccidb076832019-01-26 14:15:10 +00002986 S = GenericSelectionExpr::CreateEmpty(
2987 Context,
2988 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
Peter Collingbourne91147592011-04-15 00:35:48 +00002989 break;
2990
Sebastian Redl539c5062010-08-18 23:57:32 +00002991 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002992 S = new (Context) ObjCStringLiteral(Empty);
2993 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002994
Patrick Beard0caa3942012-04-19 00:25:12 +00002995 case EXPR_OBJC_BOXED_EXPRESSION:
2996 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremeneke65b0862012-03-06 20:05:56 +00002997 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002998
Ted Kremeneke65b0862012-03-06 20:05:56 +00002999 case EXPR_OBJC_ARRAY_LITERAL:
3000 S = ObjCArrayLiteral::CreateEmpty(Context,
3001 Record[ASTStmtReader::NumExprFields]);
3002 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003003
Ted Kremeneke65b0862012-03-06 20:05:56 +00003004 case EXPR_OBJC_DICTIONARY_LITERAL:
3005 S = ObjCDictionaryLiteral::CreateEmpty(Context,
3006 Record[ASTStmtReader::NumExprFields],
3007 Record[ASTStmtReader::NumExprFields + 1]);
3008 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003009
Sebastian Redl539c5062010-08-18 23:57:32 +00003010 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003011 S = new (Context) ObjCEncodeExpr(Empty);
3012 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003013
Sebastian Redl539c5062010-08-18 23:57:32 +00003014 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003015 S = new (Context) ObjCSelectorExpr(Empty);
3016 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003017
Sebastian Redl539c5062010-08-18 23:57:32 +00003018 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003019 S = new (Context) ObjCProtocolExpr(Empty);
3020 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003021
Sebastian Redl539c5062010-08-18 23:57:32 +00003022 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003023 S = new (Context) ObjCIvarRefExpr(Empty);
3024 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003025
Sebastian Redl539c5062010-08-18 23:57:32 +00003026 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003027 S = new (Context) ObjCPropertyRefExpr(Empty);
3028 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003029
Ted Kremeneke65b0862012-03-06 20:05:56 +00003030 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
3031 S = new (Context) ObjCSubscriptRefExpr(Empty);
3032 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003033
Sebastian Redl539c5062010-08-18 23:57:32 +00003034 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00003035 llvm_unreachable("mismatching AST file");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003036
Sebastian Redl539c5062010-08-18 23:57:32 +00003037 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003038 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00003039 Record[ASTStmtReader::NumExprFields],
3040 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003041 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003042
Sebastian Redl539c5062010-08-18 23:57:32 +00003043 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00003044 S = new (Context) ObjCIsaExpr(Empty);
3045 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003046
John McCall31168b02011-06-15 23:02:42 +00003047 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
3048 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
3049 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003050
John McCall31168b02011-06-15 23:02:42 +00003051 case EXPR_OBJC_BRIDGED_CAST:
3052 S = new (Context) ObjCBridgedCastExpr(Empty);
3053 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003054
Sebastian Redl539c5062010-08-18 23:57:32 +00003055 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003056 S = new (Context) ObjCForCollectionStmt(Empty);
3057 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003058
Sebastian Redl539c5062010-08-18 23:57:32 +00003059 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003060 S = new (Context) ObjCAtCatchStmt(Empty);
3061 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003062
Sebastian Redl539c5062010-08-18 23:57:32 +00003063 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003064 S = new (Context) ObjCAtFinallyStmt(Empty);
3065 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003066
Sebastian Redl539c5062010-08-18 23:57:32 +00003067 case STMT_OBJC_AT_TRY:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003068 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003069 Record[ASTStmtReader::NumStmtFields],
3070 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003071 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003072
Sebastian Redl539c5062010-08-18 23:57:32 +00003073 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003074 S = new (Context) ObjCAtSynchronizedStmt(Empty);
3075 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003076
Sebastian Redl539c5062010-08-18 23:57:32 +00003077 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003078 S = new (Context) ObjCAtThrowStmt(Empty);
3079 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003080
John McCall31168b02011-06-15 23:02:42 +00003081 case STMT_OBJC_AUTORELEASE_POOL:
3082 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3083 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003084
Ted Kremeneke65b0862012-03-06 20:05:56 +00003085 case EXPR_OBJC_BOOL_LITERAL:
3086 S = new (Context) ObjCBoolLiteralExpr(Empty);
3087 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003088
Erik Pilkington29099de2016-07-16 00:35:23 +00003089 case EXPR_OBJC_AVAILABILITY_CHECK:
3090 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3091 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003092
Nico Weber9b982072014-07-07 00:12:30 +00003093 case STMT_SEH_LEAVE:
3094 S = new (Context) SEHLeaveStmt(Empty);
3095 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003096
John McCallfa194042011-07-15 07:00:14 +00003097 case STMT_SEH_EXCEPT:
3098 S = new (Context) SEHExceptStmt(Empty);
3099 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003100
John McCallfa194042011-07-15 07:00:14 +00003101 case STMT_SEH_FINALLY:
3102 S = new (Context) SEHFinallyStmt(Empty);
3103 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003104
John McCallfa194042011-07-15 07:00:14 +00003105 case STMT_SEH_TRY:
3106 S = new (Context) SEHTryStmt(Empty);
3107 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003108
Sebastian Redl539c5062010-08-18 23:57:32 +00003109 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003110 S = new (Context) CXXCatchStmt(Empty);
3111 break;
3112
Sebastian Redl539c5062010-08-18 23:57:32 +00003113 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003114 S = CXXTryStmt::Create(Context, Empty,
Rui Ueyama49a3ad22019-07-16 04:46:31 +00003115 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003116 break;
3117
Richard Smith02e85f32011-04-14 22:09:26 +00003118 case STMT_CXX_FOR_RANGE:
3119 S = new (Context) CXXForRangeStmt(Empty);
3120 break;
3121
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003122 case STMT_MS_DEPENDENT_EXISTS:
3123 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3124 NestedNameSpecifierLoc(),
3125 DeclarationNameInfo(),
Craig Toppera13603a2014-05-22 05:54:18 +00003126 nullptr);
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003127 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003128
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00003129 case STMT_OMP_PARALLEL_DIRECTIVE:
3130 S =
3131 OMPParallelDirective::CreateEmpty(Context,
3132 Record[ASTStmtReader::NumStmtFields],
3133 Empty);
3134 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003135
3136 case STMT_OMP_SIMD_DIRECTIVE: {
3137 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3138 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3139 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3140 CollapsedNum, Empty);
3141 break;
3142 }
3143
Alexey Bataevf29276e2014-06-18 04:14:57 +00003144 case STMT_OMP_FOR_DIRECTIVE: {
3145 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3146 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3147 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3148 Empty);
3149 break;
3150 }
3151
Alexander Musmanf82886e2014-09-18 05:12:34 +00003152 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3153 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3154 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3155 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3156 Empty);
3157 break;
3158 }
3159
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00003160 case STMT_OMP_SECTIONS_DIRECTIVE:
3161 S = OMPSectionsDirective::CreateEmpty(
3162 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3163 break;
3164
Alexey Bataev1e0498a2014-06-26 08:21:58 +00003165 case STMT_OMP_SECTION_DIRECTIVE:
3166 S = OMPSectionDirective::CreateEmpty(Context, Empty);
3167 break;
3168
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00003169 case STMT_OMP_SINGLE_DIRECTIVE:
3170 S = OMPSingleDirective::CreateEmpty(
3171 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3172 break;
3173
Alexander Musman80c22892014-07-17 08:54:58 +00003174 case STMT_OMP_MASTER_DIRECTIVE:
3175 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3176 break;
3177
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003178 case STMT_OMP_CRITICAL_DIRECTIVE:
Alexey Bataev28c75412015-12-15 08:19:24 +00003179 S = OMPCriticalDirective::CreateEmpty(
3180 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003181 break;
3182
Alexey Bataev4acb8592014-07-07 13:01:15 +00003183 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3184 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3185 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3186 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3187 CollapsedNum, Empty);
3188 break;
3189 }
3190
Alexander Musmane4e893b2014-09-23 09:33:00 +00003191 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3192 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3193 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3194 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3195 CollapsedNum, Empty);
3196 break;
3197 }
3198
cchen47d60942019-12-05 13:43:48 -05003199 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3200 S = OMPParallelMasterDirective::CreateEmpty(
3201 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3202 break;
3203
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00003204 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3205 S = OMPParallelSectionsDirective::CreateEmpty(
3206 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3207 break;
3208
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00003209 case STMT_OMP_TASK_DIRECTIVE:
3210 S = OMPTaskDirective::CreateEmpty(
3211 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3212 break;
3213
Alexey Bataev68446b72014-07-18 07:47:19 +00003214 case STMT_OMP_TASKYIELD_DIRECTIVE:
3215 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3216 break;
3217
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00003218 case STMT_OMP_BARRIER_DIRECTIVE:
3219 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3220 break;
3221
Alexey Bataev2df347a2014-07-18 10:17:07 +00003222 case STMT_OMP_TASKWAIT_DIRECTIVE:
3223 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3224 break;
3225
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003226 case STMT_OMP_TASKGROUP_DIRECTIVE:
Alexey Bataev169d96a2017-07-18 20:17:46 +00003227 S = OMPTaskgroupDirective::CreateEmpty(
3228 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003229 break;
3230
Alexey Bataev6125da92014-07-21 11:26:11 +00003231 case STMT_OMP_FLUSH_DIRECTIVE:
3232 S = OMPFlushDirective::CreateEmpty(
3233 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3234 break;
3235
Alexey Bataevc112e942020-02-28 09:52:15 -05003236 case STMT_OMP_DEPOBJ_DIRECTIVE:
3237 S = OMPDepobjDirective::CreateEmpty(
3238 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3239 break;
3240
Alexey Bataevfcba7c32020-03-20 07:03:01 -04003241 case STMT_OMP_SCAN_DIRECTIVE:
3242 S = OMPScanDirective::CreateEmpty(
3243 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3244 break;
3245
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003246 case STMT_OMP_ORDERED_DIRECTIVE:
Alexey Bataev346265e2015-09-25 10:37:12 +00003247 S = OMPOrderedDirective::CreateEmpty(
3248 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003249 break;
3250
Alexey Bataev0162e452014-07-22 10:10:35 +00003251 case STMT_OMP_ATOMIC_DIRECTIVE:
3252 S = OMPAtomicDirective::CreateEmpty(
3253 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3254 break;
3255
Alexey Bataev0bd520b2014-09-19 08:19:49 +00003256 case STMT_OMP_TARGET_DIRECTIVE:
3257 S = OMPTargetDirective::CreateEmpty(
3258 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3259 break;
3260
Michael Wong65f367f2015-07-21 13:44:28 +00003261 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3262 S = OMPTargetDataDirective::CreateEmpty(
3263 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3264 break;
3265
Samuel Antaodf67fc42016-01-19 19:15:56 +00003266 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3267 S = OMPTargetEnterDataDirective::CreateEmpty(
3268 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3269 break;
3270
Samuel Antao72590762016-01-19 20:04:50 +00003271 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3272 S = OMPTargetExitDataDirective::CreateEmpty(
3273 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3274 break;
3275
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00003276 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3277 S = OMPTargetParallelDirective::CreateEmpty(
3278 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3279 break;
3280
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00003281 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3282 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3283 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3284 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3285 CollapsedNum, Empty);
3286 break;
3287 }
3288
Samuel Antao686c70c2016-05-26 17:30:50 +00003289 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3290 S = OMPTargetUpdateDirective::CreateEmpty(
3291 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3292 break;
3293
Alexey Bataev13314bf2014-10-09 04:18:56 +00003294 case STMT_OMP_TEAMS_DIRECTIVE:
3295 S = OMPTeamsDirective::CreateEmpty(
3296 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3297 break;
3298
Alexey Bataev6d4ed052015-07-01 06:57:41 +00003299 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3300 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3301 break;
3302
Alexey Bataev80909872015-07-02 11:25:17 +00003303 case STMT_OMP_CANCEL_DIRECTIVE:
Alexey Bataev87933c72015-09-18 08:07:34 +00003304 S = OMPCancelDirective::CreateEmpty(
3305 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev80909872015-07-02 11:25:17 +00003306 break;
3307
Alexey Bataev49f6e782015-12-01 04:18:41 +00003308 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3309 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3310 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3311 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3312 Empty);
3313 break;
3314 }
3315
Alexey Bataev0a6ed842015-12-03 09:40:15 +00003316 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3317 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3318 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3319 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3320 CollapsedNum, Empty);
3321 break;
3322 }
3323
Alexey Bataev60e51c42019-10-10 20:13:02 +00003324 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3325 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3326 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3327 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3328 CollapsedNum, Empty);
3329 break;
3330 }
3331
Alexey Bataevb8552ab2019-10-18 16:47:35 +00003332 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3333 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3334 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3335 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3336 CollapsedNum, Empty);
3337 break;
3338 }
3339
Alexey Bataev5bbcead2019-10-14 17:17:41 +00003340 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3341 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3342 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3343 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3344 CollapsedNum, Empty);
3345 break;
3346 }
3347
Alexey Bataev14a388f2019-10-25 10:27:13 -04003348 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3349 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3350 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3351 S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3352 Context, NumClauses, CollapsedNum, Empty);
3353 break;
3354 }
3355
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00003356 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3357 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3358 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3359 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3360 Empty);
3361 break;
3362 }
3363
Carlo Bertolli9925f152016-06-27 14:55:37 +00003364 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3365 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3366 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3367 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3368 CollapsedNum, Empty);
3369 break;
3370 }
3371
Kelvin Li4a39add2016-07-05 05:00:15 +00003372 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3373 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3374 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3375 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3376 CollapsedNum,
3377 Empty);
3378 break;
3379 }
3380
Kelvin Li787f3fc2016-07-06 04:45:38 +00003381 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3382 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3383 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3384 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3385 CollapsedNum, Empty);
3386 break;
3387 }
3388
Kelvin Lia579b912016-07-14 02:54:56 +00003389 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3390 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3391 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3392 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3393 CollapsedNum, Empty);
3394 break;
3395 }
3396
Kelvin Li986330c2016-07-20 22:57:10 +00003397 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3398 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3399 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3400 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3401 Empty);
3402 break;
3403 }
3404
Kelvin Li83c451e2016-12-25 04:52:54 +00003405 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
Kelvin Li02532872016-08-05 14:37:37 +00003406 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3407 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3408 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3409 CollapsedNum, Empty);
3410 break;
3411 }
3412
Kelvin Li4e325f72016-10-25 12:50:55 +00003413 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3414 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3415 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3416 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3417 CollapsedNum, Empty);
3418 break;
3419 }
3420
Kelvin Li579e41c2016-11-30 23:51:03 +00003421 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3422 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3423 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3424 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3425 Context, NumClauses, CollapsedNum, Empty);
3426 break;
3427 }
3428
Kelvin Li7ade93f2016-12-09 03:24:30 +00003429 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3430 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3431 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3432 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3433 Context, NumClauses, CollapsedNum, Empty);
3434 break;
3435 }
3436
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003437 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
Kelvin Libf594a52016-12-17 05:48:59 +00003438 S = OMPTargetTeamsDirective::CreateEmpty(
3439 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3440 break;
Kelvin Li83c451e2016-12-25 04:52:54 +00003441
3442 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3443 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3444 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3445 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3446 CollapsedNum, Empty);
3447 break;
3448 }
3449
Kelvin Li80e8f562016-12-29 22:16:30 +00003450 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3451 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3452 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3453 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3454 Context, NumClauses, CollapsedNum, Empty);
3455 break;
3456 }
3457
Kelvin Li1851df52017-01-03 05:23:48 +00003458 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3459 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3460 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3461 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3462 Context, NumClauses, CollapsedNum, Empty);
3463 break;
3464 }
3465
Kelvin Lida681182017-01-10 18:08:18 +00003466 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3467 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3468 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3469 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3470 Context, NumClauses, CollapsedNum, Empty);
3471 break;
3472 }
3473
Sebastian Redl539c5062010-08-18 23:57:32 +00003474 case EXPR_CXX_OPERATOR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003475 S = CXXOperatorCallExpr::CreateEmpty(
3476 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00003477 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003478
Sebastian Redl539c5062010-08-18 23:57:32 +00003479 case EXPR_CXX_MEMBER_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003480 S = CXXMemberCallExpr::CreateEmpty(
3481 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003482 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003483
Richard Smith778dc0f2019-10-19 00:04:38 +00003484 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3485 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3486 break;
3487
Sebastian Redl539c5062010-08-18 23:57:32 +00003488 case EXPR_CXX_CONSTRUCT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003489 S = CXXConstructExpr::CreateEmpty(
3490 Context,
3491 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003492 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003493
Richard Smith5179eb72016-06-28 19:03:57 +00003494 case EXPR_CXX_INHERITED_CTOR_INIT:
3495 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3496 break;
3497
Sebastian Redl539c5062010-08-18 23:57:32 +00003498 case EXPR_CXX_TEMPORARY_OBJECT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003499 S = CXXTemporaryObjectExpr::CreateEmpty(
3500 Context,
3501 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00003502 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003503
Sebastian Redl539c5062010-08-18 23:57:32 +00003504 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003505 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003506 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003507 break;
3508
Sebastian Redl539c5062010-08-18 23:57:32 +00003509 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003510 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003511 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003512 break;
3513
Sebastian Redl539c5062010-08-18 23:57:32 +00003514 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003515 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003516 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003517 break;
3518
Sebastian Redl539c5062010-08-18 23:57:32 +00003519 case EXPR_CXX_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003520 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00003521 break;
3522
Sebastian Redl539c5062010-08-18 23:57:32 +00003523 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003524 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003525 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003526 break;
3527
Richard Smithc67fdd42012-03-07 08:35:16 +00003528 case EXPR_USER_DEFINED_LITERAL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003529 S = UserDefinedLiteral::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003530 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Richard Smithc67fdd42012-03-07 08:35:16 +00003531 break;
3532
Richard Smithcc1b96d2013-06-12 22:31:48 +00003533 case EXPR_CXX_STD_INITIALIZER_LIST:
3534 S = new (Context) CXXStdInitializerListExpr(Empty);
3535 break;
3536
Sebastian Redl539c5062010-08-18 23:57:32 +00003537 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003538 S = new (Context) CXXBoolLiteralExpr(Empty);
3539 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003540
Sebastian Redl539c5062010-08-18 23:57:32 +00003541 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003542 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3543 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003544
Sebastian Redl539c5062010-08-18 23:57:32 +00003545 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003546 S = new (Context) CXXTypeidExpr(Empty, true);
3547 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003548
Sebastian Redl539c5062010-08-18 23:57:32 +00003549 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003550 S = new (Context) CXXTypeidExpr(Empty, false);
3551 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003552
Francois Pichet9f4f2072010-09-08 12:20:18 +00003553 case EXPR_CXX_UUIDOF_EXPR:
3554 S = new (Context) CXXUuidofExpr(Empty, true);
3555 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003556
John McCall5e77d762013-04-16 07:28:30 +00003557 case EXPR_CXX_PROPERTY_REF_EXPR:
3558 S = new (Context) MSPropertyRefExpr(Empty);
3559 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003560
Alexey Bataevf7630272015-11-25 12:01:00 +00003561 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3562 S = new (Context) MSPropertySubscriptExpr(Empty);
3563 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003564
Francois Pichet9f4f2072010-09-08 12:20:18 +00003565 case EXPR_CXX_UUIDOF_TYPE:
3566 S = new (Context) CXXUuidofExpr(Empty, false);
3567 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003568
Sebastian Redl539c5062010-08-18 23:57:32 +00003569 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00003570 S = new (Context) CXXThisExpr(Empty);
3571 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003572
Sebastian Redl539c5062010-08-18 23:57:32 +00003573 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00003574 S = new (Context) CXXThrowExpr(Empty);
3575 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003576
John McCall32791cc2016-01-06 22:34:54 +00003577 case EXPR_CXX_DEFAULT_ARG:
3578 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00003579 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003580
Richard Smith852c9db2013-04-20 22:23:05 +00003581 case EXPR_CXX_DEFAULT_INIT:
3582 S = new (Context) CXXDefaultInitExpr(Empty);
3583 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003584
Sebastian Redl539c5062010-08-18 23:57:32 +00003585 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00003586 S = new (Context) CXXBindTemporaryExpr(Empty);
3587 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003588
Sebastian Redl539c5062010-08-18 23:57:32 +00003589 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00003590 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003591 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003592
Sebastian Redl539c5062010-08-18 23:57:32 +00003593 case EXPR_CXX_NEW:
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00003594 S = CXXNewExpr::CreateEmpty(
3595 Context,
3596 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3597 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3598 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3599 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003600 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003601
Sebastian Redl539c5062010-08-18 23:57:32 +00003602 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00003603 S = new (Context) CXXDeleteExpr(Empty);
3604 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003605
Sebastian Redl539c5062010-08-18 23:57:32 +00003606 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00003607 S = new (Context) CXXPseudoDestructorExpr(Empty);
3608 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003609
John McCall5d413782010-12-06 08:20:24 +00003610 case EXPR_EXPR_WITH_CLEANUPS:
John McCall28fc7092011-11-10 05:35:25 +00003611 S = ExprWithCleanups::Create(Context, Empty,
3612 Record[ASTStmtReader::NumExprFields]);
Chris Lattnercba86142010-05-10 00:25:06 +00003613 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003614
Sebastian Redl539c5062010-08-18 23:57:32 +00003615 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Bruno Ricci2e6dc532019-01-08 14:17:00 +00003616 S = CXXDependentScopeMemberExpr::CreateEmpty(
3617 Context,
3618 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3619 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3620 /*HasFirstQualifierFoundInScope=*/
3621 Record[ASTStmtReader::NumExprFields + 2]);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003622 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003623
Sebastian Redl539c5062010-08-18 23:57:32 +00003624 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003625 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003626 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003627 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003628 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003629 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00003630 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003631
Sebastian Redl539c5062010-08-18 23:57:32 +00003632 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003633 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003634 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00003635 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003636
Sebastian Redl539c5062010-08-18 23:57:32 +00003637 case EXPR_CXX_UNRESOLVED_MEMBER:
Bruno Riccid7628d92019-01-09 15:43:19 +00003638 S = UnresolvedMemberExpr::CreateEmpty(
3639 Context,
3640 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3641 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3642 /*NumTemplateArgs=*/
3643 Record[ASTStmtReader::NumExprFields + 1]
3644 ? Record[ASTStmtReader::NumExprFields + 2]
3645 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003646 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003647
Sebastian Redl539c5062010-08-18 23:57:32 +00003648 case EXPR_CXX_UNRESOLVED_LOOKUP:
Bruno Riccid7628d92019-01-09 15:43:19 +00003649 S = UnresolvedLookupExpr::CreateEmpty(
3650 Context,
3651 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3652 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3653 /*NumTemplateArgs=*/
3654 Record[ASTStmtReader::NumExprFields + 1]
3655 ? Record[ASTStmtReader::NumExprFields + 2]
3656 : 0);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00003657 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003658
Douglas Gregor29c42f22012-02-24 07:38:34 +00003659 case EXPR_TYPE_TRAIT:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003660 S = TypeTraitExpr::CreateDeserialized(Context,
Douglas Gregor29c42f22012-02-24 07:38:34 +00003661 Record[ASTStmtReader::NumExprFields]);
3662 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003663
John Wiegley6242b6a2011-04-28 00:16:57 +00003664 case EXPR_ARRAY_TYPE_TRAIT:
3665 S = new (Context) ArrayTypeTraitExpr(Empty);
3666 break;
3667
John Wiegleyf9f65842011-04-25 06:54:41 +00003668 case EXPR_CXX_EXPRESSION_TRAIT:
3669 S = new (Context) ExpressionTraitExpr(Empty);
3670 break;
3671
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003672 case EXPR_CXX_NOEXCEPT:
3673 S = new (Context) CXXNoexceptExpr(Empty);
3674 break;
John McCall8d69a212010-11-15 23:31:06 +00003675
Douglas Gregore8e9dd62011-01-03 17:17:50 +00003676 case EXPR_PACK_EXPANSION:
3677 S = new (Context) PackExpansionExpr(Empty);
3678 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003679
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003680 case EXPR_SIZEOF_PACK:
Richard Smithd784e682015-09-23 21:41:42 +00003681 S = SizeOfPackExpr::CreateDeserialized(
3682 Context,
3683 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003684 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003685
John McCallfa194042011-07-15 07:00:14 +00003686 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3687 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3688 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003689
Douglas Gregorcdbc5392011-01-15 01:15:58 +00003690 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3691 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3692 break;
Richard Smithb15fe3a2012-09-12 00:56:43 +00003693
3694 case EXPR_FUNCTION_PARM_PACK:
3695 S = FunctionParmPackExpr::CreateEmpty(Context,
3696 Record[ASTStmtReader::NumExprFields]);
3697 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003698
Douglas Gregorfe314812011-06-21 17:03:29 +00003699 case EXPR_MATERIALIZE_TEMPORARY:
3700 S = new (Context) MaterializeTemporaryExpr(Empty);
3701 break;
Richard Smith0f0af192014-11-08 05:07:16 +00003702
3703 case EXPR_CXX_FOLD:
3704 S = new (Context) CXXFoldExpr(Empty);
3705 break;
3706
Argyrios Kyrtzidisb2b07952011-12-03 03:49:52 +00003707 case EXPR_OPAQUE_VALUE:
3708 S = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00003709 break;
Peter Collingbourne41f85462011-02-09 21:07:24 +00003710
3711 case EXPR_CUDA_KERNEL_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003712 S = CUDAKernelCallExpr::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003713 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00003714 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003715
Tanya Lattner55808c12011-06-04 00:47:47 +00003716 case EXPR_ASTYPE:
3717 S = new (Context) AsTypeExpr(Empty);
3718 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003719
John McCallfe96e0b2011-11-06 09:01:30 +00003720 case EXPR_PSEUDO_OBJECT: {
3721 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3722 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3723 break;
3724 }
3725
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003726 case EXPR_ATOMIC:
3727 S = new (Context) AtomicExpr(Empty);
3728 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003729
Douglas Gregor99ae8062012-02-14 17:54:36 +00003730 case EXPR_LAMBDA: {
3731 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
Richard Smith30e304e2016-12-14 00:03:17 +00003732 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
Douglas Gregor99ae8062012-02-14 17:54:36 +00003733 break;
3734 }
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +00003735
3736 case STMT_COROUTINE_BODY: {
3737 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3738 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3739 break;
3740 }
3741
3742 case STMT_CORETURN:
3743 S = new (Context) CoreturnStmt(Empty);
3744 break;
3745
3746 case EXPR_COAWAIT:
3747 S = new (Context) CoawaitExpr(Empty);
3748 break;
3749
3750 case EXPR_COYIELD:
3751 S = new (Context) CoyieldExpr(Empty);
3752 break;
3753
3754 case EXPR_DEPENDENT_COAWAIT:
3755 S = new (Context) DependentCoawaitExpr(Empty);
3756 break;
Saar Raz5d98ba62019-10-15 15:24:26 +00003757
Saar Raza0f50d72020-01-18 09:11:43 +02003758 case EXPR_CONCEPT_SPECIALIZATION: {
Saar Raz5d98ba62019-10-15 15:24:26 +00003759 unsigned numTemplateArgs = Record[ASTStmtReader::NumExprFields];
3760 S = ConceptSpecializationExpr::Create(Context, Empty, numTemplateArgs);
3761 break;
Saar Raza0f50d72020-01-18 09:11:43 +02003762 }
3763
3764 case EXPR_REQUIRES:
3765 unsigned numLocalParameters = Record[ASTStmtReader::NumExprFields];
3766 unsigned numRequirement = Record[ASTStmtReader::NumExprFields + 1];
3767 S = RequiresExpr::Create(Context, Empty, numLocalParameters,
3768 numRequirement);
3769 break;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003770 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003771
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003772 // We hit a STMT_STOP, so we're done with this expression.
3773 if (Finished)
3774 break;
3775
3776 ++NumStatementsRead;
3777
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003778 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003779 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003780 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3781 }
3782
David L. Jonesbe1557a2016-12-21 00:17:49 +00003783 assert(Record.getIdx() == Record.size() &&
3784 "Invalid deserialization of statement");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003785 StmtStack.push_back(S);
3786 }
Chris Lattner0e6c9402013-01-20 02:38:54 +00003787Done:
Alp Toker028ed912013-12-06 17:56:43 +00003788 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003789 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003790 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003791}