blob: 1fbcab209303deb3579bf4c4685e2c7850999404 [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
Peter Collingbourne41f85462011-02-09 21:07:24 +00002083//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002084// Microsoft Expressions and Statements
2085//===----------------------------------------------------------------------===//
John McCall5e77d762013-04-16 07:28:30 +00002086void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
2087 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002088 E->IsArrow = (Record.readInt() != 0);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002089 E->BaseExpr = Record.readSubExpr();
2090 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05002091 E->MemberLoc = readSourceLocation();
2092 E->TheDecl = readDeclAs<MSPropertyDecl>();
John McCall5e77d762013-04-16 07:28:30 +00002093}
2094
Alexey Bataevf7630272015-11-25 12:01:00 +00002095void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
2096 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002097 E->setBase(Record.readSubExpr());
2098 E->setIdx(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05002099 E->setRBracketLoc(readSourceLocation());
Alexey Bataevf7630272015-11-25 12:01:00 +00002100}
2101
John McCallfa194042011-07-15 07:00:14 +00002102void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
2103 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002104 E->setSourceRange(readSourceRange());
2105 std::string UuidStr = readString();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002106 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
John McCallfa194042011-07-15 07:00:14 +00002107 if (E->isTypeOperand()) { // __uuidof(ComType)
2108 E->setTypeOperandSourceInfo(
John McCall3ce3d232019-12-13 03:37:23 -05002109 readTypeSourceInfo());
John McCallfa194042011-07-15 07:00:14 +00002110 return;
2111 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002112
John McCallfa194042011-07-15 07:00:14 +00002113 // __uuidof(expr)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002114 E->setExprOperand(Record.readSubExpr());
John McCallfa194042011-07-15 07:00:14 +00002115}
2116
Nico Weber9b982072014-07-07 00:12:30 +00002117void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
2118 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002119 S->setLeaveLoc(readSourceLocation());
Nico Weber9b982072014-07-07 00:12:30 +00002120}
2121
John McCallfa194042011-07-15 07:00:14 +00002122void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
2123 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002124 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002125 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
2126 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002127}
2128
2129void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
2130 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002131 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002132 S->Block = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002133}
2134
2135void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
2136 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002137 S->IsCXXTry = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002138 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002139 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
2140 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002141}
2142
2143//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00002144// CUDA Expressions and Statements
2145//===----------------------------------------------------------------------===//
2146
2147void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2148 VisitCallExpr(E);
Richard Smithfd420792019-05-24 23:26:07 +00002149 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
Peter Collingbourne41f85462011-02-09 21:07:24 +00002150}
2151
John McCallfa194042011-07-15 07:00:14 +00002152//===----------------------------------------------------------------------===//
2153// OpenCL Expressions and Statements.
2154//===----------------------------------------------------------------------===//
2155void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2156 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002157 E->BuiltinLoc = readSourceLocation();
2158 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002159 E->SrcExpr = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002160}
2161
2162//===----------------------------------------------------------------------===//
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002163// OpenMP Directives.
2164//===----------------------------------------------------------------------===//
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002165
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002166void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
John McCall3ce3d232019-12-13 03:37:23 -05002167 E->setLocStart(readSourceLocation());
2168 E->setLocEnd(readSourceLocation());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002169 SmallVector<OMPClause *, 5> Clauses;
2170 for (unsigned i = 0; i < E->getNumClauses(); ++i)
John McCallc2f18312019-12-14 03:01:28 -05002171 Clauses.push_back(Record.readOMPClause());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002172 E->setClauses(Clauses);
Alexey Bataev68446b72014-07-18 07:47:19 +00002173 if (E->hasAssociatedStmt())
David L. Jonesb6a8f022016-12-21 04:34:52 +00002174 E->setAssociatedStmt(Record.readSubStmt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002175}
2176
Alexander Musman3aaab662014-08-19 11:27:13 +00002177void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2178 VisitStmt(D);
2179 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002180 Record.skipInts(2);
Alexander Musman3aaab662014-08-19 11:27:13 +00002181 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002182 D->setIterationVariable(Record.readSubExpr());
2183 D->setLastIteration(Record.readSubExpr());
2184 D->setCalcLastIteration(Record.readSubExpr());
2185 D->setPreCond(Record.readSubExpr());
2186 D->setCond(Record.readSubExpr());
2187 D->setInit(Record.readSubExpr());
2188 D->setInc(Record.readSubExpr());
2189 D->setPreInits(Record.readSubStmt());
Alexey Bataev3392d762016-02-16 11:18:12 +00002190 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
Carlo Bertollifc35ad22016-03-07 16:04:49 +00002191 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2192 isOpenMPDistributeDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002193 D->setIsLastIterVariable(Record.readSubExpr());
2194 D->setLowerBoundVariable(Record.readSubExpr());
2195 D->setUpperBoundVariable(Record.readSubExpr());
2196 D->setStrideVariable(Record.readSubExpr());
2197 D->setEnsureUpperBound(Record.readSubExpr());
2198 D->setNextLowerBound(Record.readSubExpr());
2199 D->setNextUpperBound(Record.readSubExpr());
2200 D->setNumIterations(Record.readSubExpr());
Alexander Musmanc6388682014-12-15 07:07:06 +00002201 }
Carlo Bertolli9925f152016-06-27 14:55:37 +00002202 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002203 D->setPrevLowerBoundVariable(Record.readSubExpr());
2204 D->setPrevUpperBoundVariable(Record.readSubExpr());
Carlo Bertolli8429d812017-02-17 21:29:13 +00002205 D->setDistInc(Record.readSubExpr());
2206 D->setPrevEnsureUpperBound(Record.readSubExpr());
Carlo Bertolliffafe102017-04-20 00:39:39 +00002207 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2208 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2209 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2210 D->setCombinedInit(Record.readSubExpr());
2211 D->setCombinedCond(Record.readSubExpr());
2212 D->setCombinedNextLowerBound(Record.readSubExpr());
2213 D->setCombinedNextUpperBound(Record.readSubExpr());
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00002214 D->setCombinedDistCond(Record.readSubExpr());
2215 D->setCombinedParForInDistCond(Record.readSubExpr());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002216 }
Alexander Musmana5f070a2014-10-01 06:03:56 +00002217 SmallVector<Expr *, 4> Sub;
2218 unsigned CollapsedNum = D->getCollapsedNumber();
2219 Sub.reserve(CollapsedNum);
2220 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002221 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002222 D->setCounters(Sub);
2223 Sub.clear();
2224 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002225 Sub.push_back(Record.readSubExpr());
Alexey Bataeva8899172015-08-06 12:30:57 +00002226 D->setPrivateCounters(Sub);
2227 Sub.clear();
2228 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002229 Sub.push_back(Record.readSubExpr());
Alexey Bataevb08f89f2015-08-14 12:25:37 +00002230 D->setInits(Sub);
2231 Sub.clear();
2232 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002233 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002234 D->setUpdates(Sub);
2235 Sub.clear();
2236 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002237 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002238 D->setFinals(Sub);
Alexey Bataevf8be4762019-08-14 19:30:06 +00002239 Sub.clear();
2240 for (unsigned i = 0; i < CollapsedNum; ++i)
2241 Sub.push_back(Record.readSubExpr());
2242 D->setDependentCounters(Sub);
2243 Sub.clear();
2244 for (unsigned i = 0; i < CollapsedNum; ++i)
2245 Sub.push_back(Record.readSubExpr());
2246 D->setDependentInits(Sub);
2247 Sub.clear();
2248 for (unsigned i = 0; i < CollapsedNum; ++i)
2249 Sub.push_back(Record.readSubExpr());
2250 D->setFinalsConditions(Sub);
Alexander Musman3aaab662014-08-19 11:27:13 +00002251}
2252
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002253void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002254 VisitStmt(D);
2255 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002256 Record.skipInts(1);
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002257 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002258 D->setHasCancel(Record.readInt());
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002259}
2260
2261void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002262 VisitOMPLoopDirective(D);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002263}
2264
Alexey Bataevf29276e2014-06-18 04:14:57 +00002265void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002266 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002267 D->setHasCancel(Record.readInt());
Alexey Bataevf29276e2014-06-18 04:14:57 +00002268}
2269
Alexander Musmanf82886e2014-09-18 05:12:34 +00002270void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2271 VisitOMPLoopDirective(D);
2272}
2273
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002274void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2275 VisitStmt(D);
2276 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002277 Record.skipInts(1);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002278 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002279 D->setHasCancel(Record.readInt());
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002280}
2281
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002282void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2283 VisitStmt(D);
2284 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002285 D->setHasCancel(Record.readInt());
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002286}
2287
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002288void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2289 VisitStmt(D);
2290 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002291 Record.skipInts(1);
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002292 VisitOMPExecutableDirective(D);
2293}
2294
Alexander Musman80c22892014-07-17 08:54:58 +00002295void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2296 VisitStmt(D);
2297 VisitOMPExecutableDirective(D);
2298}
2299
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002300void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2301 VisitStmt(D);
Alexey Bataev28c75412015-12-15 08:19:24 +00002302 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002303 Record.skipInts(1);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002304 VisitOMPExecutableDirective(D);
John McCall3ce3d232019-12-13 03:37:23 -05002305 D->DirName = Record.readDeclarationNameInfo();
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002306}
2307
Alexey Bataev4acb8592014-07-07 13:01:15 +00002308void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002309 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002310 D->setHasCancel(Record.readInt());
Alexey Bataev4acb8592014-07-07 13:01:15 +00002311}
2312
Alexander Musmane4e893b2014-09-23 09:33:00 +00002313void ASTStmtReader::VisitOMPParallelForSimdDirective(
2314 OMPParallelForSimdDirective *D) {
2315 VisitOMPLoopDirective(D);
2316}
2317
cchen47d60942019-12-05 13:43:48 -05002318void ASTStmtReader::VisitOMPParallelMasterDirective(
2319 OMPParallelMasterDirective *D) {
2320 VisitStmt(D);
2321 // The NumClauses field was read in ReadStmtFromStream.
2322 Record.skipInts(1);
2323 VisitOMPExecutableDirective(D);
2324}
2325
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002326void ASTStmtReader::VisitOMPParallelSectionsDirective(
2327 OMPParallelSectionsDirective *D) {
2328 VisitStmt(D);
2329 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002330 Record.skipInts(1);
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002331 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002332 D->setHasCancel(Record.readInt());
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002333}
2334
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002335void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2336 VisitStmt(D);
2337 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002338 Record.skipInts(1);
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002339 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002340 D->setHasCancel(Record.readInt());
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002341}
2342
Alexey Bataev68446b72014-07-18 07:47:19 +00002343void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2344 VisitStmt(D);
2345 VisitOMPExecutableDirective(D);
2346}
2347
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002348void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2349 VisitStmt(D);
2350 VisitOMPExecutableDirective(D);
2351}
2352
Alexey Bataev2df347a2014-07-18 10:17:07 +00002353void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2354 VisitStmt(D);
2355 VisitOMPExecutableDirective(D);
2356}
2357
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002358void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2359 VisitStmt(D);
Alexey Bataev169d96a2017-07-18 20:17:46 +00002360 // The NumClauses field was read in ReadStmtFromStream.
2361 Record.skipInts(1);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002362 VisitOMPExecutableDirective(D);
Alexey Bataev3b1b8952017-07-25 15:53:26 +00002363 D->setReductionRef(Record.readSubExpr());
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002364}
2365
Alexey Bataev6125da92014-07-21 11:26:11 +00002366void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2367 VisitStmt(D);
2368 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002369 Record.skipInts(1);
Alexey Bataev6125da92014-07-21 11:26:11 +00002370 VisitOMPExecutableDirective(D);
2371}
2372
Alexey Bataevc112e942020-02-28 09:52:15 -05002373void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective *D) {
2374 VisitStmt(D);
2375 // The NumClauses field was read in ReadStmtFromStream.
2376 Record.skipInts(1);
2377 VisitOMPExecutableDirective(D);
2378}
2379
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002380void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2381 VisitStmt(D);
Alexey Bataev346265e2015-09-25 10:37:12 +00002382 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002383 Record.skipInts(1);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002384 VisitOMPExecutableDirective(D);
2385}
2386
Alexey Bataev0162e452014-07-22 10:10:35 +00002387void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2388 VisitStmt(D);
2389 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002390 Record.skipInts(1);
Alexey Bataev0162e452014-07-22 10:10:35 +00002391 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002392 D->setX(Record.readSubExpr());
2393 D->setV(Record.readSubExpr());
2394 D->setExpr(Record.readSubExpr());
2395 D->setUpdateExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002396 D->IsXLHSInRHSPart = Record.readInt() != 0;
2397 D->IsPostfixUpdate = Record.readInt() != 0;
Alexey Bataev0162e452014-07-22 10:10:35 +00002398}
2399
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002400void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2401 VisitStmt(D);
2402 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002403 Record.skipInts(1);
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002404 VisitOMPExecutableDirective(D);
2405}
2406
Michael Wong65f367f2015-07-21 13:44:28 +00002407void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2408 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002409 Record.skipInts(1);
Michael Wong65f367f2015-07-21 13:44:28 +00002410 VisitOMPExecutableDirective(D);
2411}
2412
Samuel Antaodf67fc42016-01-19 19:15:56 +00002413void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2414 OMPTargetEnterDataDirective *D) {
2415 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002416 Record.skipInts(1);
Samuel Antaodf67fc42016-01-19 19:15:56 +00002417 VisitOMPExecutableDirective(D);
2418}
2419
Samuel Antao72590762016-01-19 20:04:50 +00002420void ASTStmtReader::VisitOMPTargetExitDataDirective(
2421 OMPTargetExitDataDirective *D) {
2422 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002423 Record.skipInts(1);
Samuel Antao72590762016-01-19 20:04:50 +00002424 VisitOMPExecutableDirective(D);
2425}
2426
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002427void ASTStmtReader::VisitOMPTargetParallelDirective(
2428 OMPTargetParallelDirective *D) {
2429 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002430 Record.skipInts(1);
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002431 VisitOMPExecutableDirective(D);
2432}
2433
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002434void ASTStmtReader::VisitOMPTargetParallelForDirective(
2435 OMPTargetParallelForDirective *D) {
2436 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002437 D->setHasCancel(Record.readInt());
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002438}
2439
Alexey Bataev13314bf2014-10-09 04:18:56 +00002440void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2441 VisitStmt(D);
2442 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002443 Record.skipInts(1);
Alexey Bataev13314bf2014-10-09 04:18:56 +00002444 VisitOMPExecutableDirective(D);
2445}
2446
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002447void ASTStmtReader::VisitOMPCancellationPointDirective(
2448 OMPCancellationPointDirective *D) {
2449 VisitStmt(D);
2450 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002451 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002452}
2453
Alexey Bataev80909872015-07-02 11:25:17 +00002454void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2455 VisitStmt(D);
Alexey Bataev87933c72015-09-18 08:07:34 +00002456 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002457 Record.skipInts(1);
Alexey Bataev80909872015-07-02 11:25:17 +00002458 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002459 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev80909872015-07-02 11:25:17 +00002460}
2461
Alexey Bataev49f6e782015-12-01 04:18:41 +00002462void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2463 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002464 D->setHasCancel(Record.readInt());
Alexey Bataev49f6e782015-12-01 04:18:41 +00002465}
2466
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002467void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2468 VisitOMPLoopDirective(D);
2469}
2470
Alexey Bataev60e51c42019-10-10 20:13:02 +00002471void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2472 OMPMasterTaskLoopDirective *D) {
2473 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002474 D->setHasCancel(Record.readInt());
Alexey Bataev60e51c42019-10-10 20:13:02 +00002475}
2476
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002477void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2478 OMPMasterTaskLoopSimdDirective *D) {
2479 VisitOMPLoopDirective(D);
2480}
2481
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002482void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2483 OMPParallelMasterTaskLoopDirective *D) {
2484 VisitOMPLoopDirective(D);
Alexey Bataeve0ca4792020-02-12 16:12:53 -05002485 D->setHasCancel(Record.readInt());
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002486}
2487
Alexey Bataev14a388f2019-10-25 10:27:13 -04002488void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2489 OMPParallelMasterTaskLoopSimdDirective *D) {
2490 VisitOMPLoopDirective(D);
2491}
2492
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002493void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2494 VisitOMPLoopDirective(D);
2495}
2496
Samuel Antao686c70c2016-05-26 17:30:50 +00002497void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2498 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002499 Record.skipInts(1);
Samuel Antao686c70c2016-05-26 17:30:50 +00002500 VisitOMPExecutableDirective(D);
2501}
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002502
Carlo Bertolli9925f152016-06-27 14:55:37 +00002503void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2504 OMPDistributeParallelForDirective *D) {
2505 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002506 D->setHasCancel(Record.readInt());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002507}
Samuel Antao686c70c2016-05-26 17:30:50 +00002508
Kelvin Li4a39add2016-07-05 05:00:15 +00002509void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2510 OMPDistributeParallelForSimdDirective *D) {
2511 VisitOMPLoopDirective(D);
2512}
2513
Kelvin Li787f3fc2016-07-06 04:45:38 +00002514void ASTStmtReader::VisitOMPDistributeSimdDirective(
2515 OMPDistributeSimdDirective *D) {
2516 VisitOMPLoopDirective(D);
2517}
2518
Kelvin Lia579b912016-07-14 02:54:56 +00002519void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2520 OMPTargetParallelForSimdDirective *D) {
2521 VisitOMPLoopDirective(D);
2522}
2523
Kelvin Li986330c2016-07-20 22:57:10 +00002524void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2525 VisitOMPLoopDirective(D);
2526}
2527
Kelvin Li02532872016-08-05 14:37:37 +00002528void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2529 OMPTeamsDistributeDirective *D) {
2530 VisitOMPLoopDirective(D);
2531}
2532
Kelvin Li4e325f72016-10-25 12:50:55 +00002533void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2534 OMPTeamsDistributeSimdDirective *D) {
2535 VisitOMPLoopDirective(D);
2536}
2537
Kelvin Li579e41c2016-11-30 23:51:03 +00002538void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2539 OMPTeamsDistributeParallelForSimdDirective *D) {
2540 VisitOMPLoopDirective(D);
2541}
2542
Kelvin Li7ade93f2016-12-09 03:24:30 +00002543void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2544 OMPTeamsDistributeParallelForDirective *D) {
2545 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002546 D->setHasCancel(Record.readInt());
Kelvin Li7ade93f2016-12-09 03:24:30 +00002547}
2548
Kelvin Libf594a52016-12-17 05:48:59 +00002549void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2550 VisitStmt(D);
2551 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002552 Record.skipInts(1);
Kelvin Libf594a52016-12-17 05:48:59 +00002553 VisitOMPExecutableDirective(D);
2554}
2555
Kelvin Li83c451e2016-12-25 04:52:54 +00002556void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2557 OMPTargetTeamsDistributeDirective *D) {
2558 VisitOMPLoopDirective(D);
2559}
2560
Kelvin Li80e8f562016-12-29 22:16:30 +00002561void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2562 OMPTargetTeamsDistributeParallelForDirective *D) {
2563 VisitOMPLoopDirective(D);
Alexey Bataev16e79882017-11-22 21:12:03 +00002564 D->setHasCancel(Record.readInt());
Kelvin Li80e8f562016-12-29 22:16:30 +00002565}
2566
Kelvin Li1851df52017-01-03 05:23:48 +00002567void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2568 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2569 VisitOMPLoopDirective(D);
2570}
2571
Kelvin Lida681182017-01-10 18:08:18 +00002572void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2573 OMPTargetTeamsDistributeSimdDirective *D) {
2574 VisitOMPLoopDirective(D);
2575}
2576
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002577//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002578// ASTReader Implementation
2579//===----------------------------------------------------------------------===//
2580
Douglas Gregorde3ef502011-11-30 23:21:26 +00002581Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002582 switch (ReadingKind) {
Richard Smith629ff362013-07-31 00:26:46 +00002583 case Read_None:
2584 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002585 case Read_Decl:
2586 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00002587 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002588 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002589 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002590 }
2591
2592 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002593}
2594
Douglas Gregorde3ef502011-11-30 23:21:26 +00002595Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00002596 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002597}
Chris Lattnere2437f42010-05-09 06:40:08 +00002598
Sebastian Redl2c499f62010-08-18 23:56:43 +00002599Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002600 return cast_or_null<Expr>(ReadSubStmt());
2601}
2602
Chris Lattnerf4262532009-04-27 05:41:06 +00002603// Within the bitstream, expressions are stored in Reverse Polish
2604// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002605// expression they are stored in. Subexpressions are stored from last to first.
2606// To evaluate expressions, we continue reading expressions and placing them on
2607// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00002608// stack. Evaluation terminates when we see a STMT_STOP record, and
2609// the single remaining expression on the stack is our result.
Douglas Gregorde3ef502011-11-30 23:21:26 +00002610Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002611 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00002612 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002613
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002614 // Map of offset to previously deserialized stmt. The offset points
George Burgess IV758cf9d2017-02-14 05:52:57 +00002615 // just after the stmt record.
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002616 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00002617
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002618#ifndef NDEBUG
2619 unsigned PrevNumStmts = StmtStack.size();
2620#endif
2621
David L. Jonesbe1557a2016-12-21 00:17:49 +00002622 ASTRecordReader Record(*this, F);
2623 ASTStmtReader Reader(Record, Cursor);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002624 Stmt::EmptyShell Empty;
2625
2626 while (true) {
JF Bastien0e828952019-06-26 19:50:12 +00002627 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2628 Cursor.advanceSkippingSubblocks();
2629 if (!MaybeEntry) {
2630 Error(toString(MaybeEntry.takeError()));
2631 return nullptr;
2632 }
2633 llvm::BitstreamEntry Entry = MaybeEntry.get();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002634
Chris Lattner0e6c9402013-01-20 02:38:54 +00002635 switch (Entry.Kind) {
2636 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2637 case llvm::BitstreamEntry::Error:
2638 Error("malformed block record in AST file");
Craig Toppera13603a2014-05-22 05:54:18 +00002639 return nullptr;
Chris Lattner0e6c9402013-01-20 02:38:54 +00002640 case llvm::BitstreamEntry::EndBlock:
2641 goto Done;
2642 case llvm::BitstreamEntry::Record:
2643 // The interesting case.
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002644 break;
2645 }
2646
Richard Smithdbafb6c2017-06-29 23:23:46 +00002647 ASTContext &Context = getContext();
Craig Toppera13603a2014-05-22 05:54:18 +00002648 Stmt *S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002649 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002650 bool IsStmtReference = false;
JF Bastien0e828952019-06-26 19:50:12 +00002651 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2652 if (!MaybeStmtCode) {
2653 Error(toString(MaybeStmtCode.takeError()));
2654 return nullptr;
2655 }
2656 switch ((StmtCode)MaybeStmtCode.get()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00002657 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002658 Finished = true;
2659 break;
2660
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002661 case STMT_REF_PTR:
2662 IsStmtReference = true;
2663 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2664 "No stmt was recorded for this offset reference!");
David L. Jonesbe1557a2016-12-21 00:17:49 +00002665 S = StmtEntries[Record.readInt()];
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002666 break;
2667
Sebastian Redl539c5062010-08-18 23:57:32 +00002668 case STMT_NULL_PTR:
Craig Toppera13603a2014-05-22 05:54:18 +00002669 S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002670 break;
2671
Sebastian Redl539c5062010-08-18 23:57:32 +00002672 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002673 S = new (Context) NullStmt(Empty);
2674 break;
2675
Sebastian Redl539c5062010-08-18 23:57:32 +00002676 case STMT_COMPOUND:
Benjamin Kramer07420902017-12-24 16:24:20 +00002677 S = CompoundStmt::CreateEmpty(
2678 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002679 break;
2680
Sebastian Redl539c5062010-08-18 23:57:32 +00002681 case STMT_CASE:
Bruno Ricci5b30571752018-10-28 12:30:53 +00002682 S = CaseStmt::CreateEmpty(
2683 Context,
2684 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002685 break;
2686
Sebastian Redl539c5062010-08-18 23:57:32 +00002687 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002688 S = new (Context) DefaultStmt(Empty);
2689 break;
2690
Sebastian Redl539c5062010-08-18 23:57:32 +00002691 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002692 S = new (Context) LabelStmt(Empty);
2693 break;
2694
Richard Smithc202b282012-04-14 00:33:13 +00002695 case STMT_ATTRIBUTED:
Alexander Kornienko20f6fc62012-07-09 10:04:07 +00002696 S = AttributedStmt::CreateEmpty(
2697 Context,
2698 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smithc202b282012-04-14 00:33:13 +00002699 break;
2700
Sebastian Redl539c5062010-08-18 23:57:32 +00002701 case STMT_IF:
Bruno Riccib1cc94b2018-10-27 21:12:20 +00002702 S = IfStmt::CreateEmpty(
2703 Context,
2704 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2705 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2706 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002707 break;
2708
Sebastian Redl539c5062010-08-18 23:57:32 +00002709 case STMT_SWITCH:
Bruno Riccie2806f82018-10-29 16:12:37 +00002710 S = SwitchStmt::CreateEmpty(
2711 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002712 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
Bruno Riccie2806f82018-10-29 16:12:37 +00002713 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002714 break;
2715
Sebastian Redl539c5062010-08-18 23:57:32 +00002716 case STMT_WHILE:
Bruno Riccibacf7512018-10-30 13:42:41 +00002717 S = WhileStmt::CreateEmpty(
2718 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002719 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002720 break;
2721
Sebastian Redl539c5062010-08-18 23:57:32 +00002722 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002723 S = new (Context) DoStmt(Empty);
2724 break;
Mike Stump11289f42009-09-09 15:08:12 +00002725
Sebastian Redl539c5062010-08-18 23:57:32 +00002726 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002727 S = new (Context) ForStmt(Empty);
2728 break;
2729
Sebastian Redl539c5062010-08-18 23:57:32 +00002730 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002731 S = new (Context) GotoStmt(Empty);
2732 break;
Mike Stump11289f42009-09-09 15:08:12 +00002733
Sebastian Redl539c5062010-08-18 23:57:32 +00002734 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002735 S = new (Context) IndirectGotoStmt(Empty);
2736 break;
2737
Sebastian Redl539c5062010-08-18 23:57:32 +00002738 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002739 S = new (Context) ContinueStmt(Empty);
2740 break;
2741
Sebastian Redl539c5062010-08-18 23:57:32 +00002742 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002743 S = new (Context) BreakStmt(Empty);
2744 break;
2745
Sebastian Redl539c5062010-08-18 23:57:32 +00002746 case STMT_RETURN:
Bruno Ricci023b1d12018-10-30 14:40:49 +00002747 S = ReturnStmt::CreateEmpty(
2748 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002749 break;
2750
Sebastian Redl539c5062010-08-18 23:57:32 +00002751 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002752 S = new (Context) DeclStmt(Empty);
2753 break;
2754
Chad Rosierde70e0e2012-08-25 00:11:56 +00002755 case STMT_GCCASM:
2756 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002757 break;
2758
Chad Rosiere30d4992012-08-24 23:51:02 +00002759 case STMT_MSASM:
2760 S = new (Context) MSAsmStmt(Empty);
2761 break;
2762
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002763 case STMT_CAPTURED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002764 S = CapturedStmt::CreateDeserialized(
2765 Context, Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002766 break;
2767
Bill Wendling7c44da22018-10-31 03:48:47 +00002768 case EXPR_CONSTANT:
Gauthier Harnisch83c7b612019-06-15 10:24:47 +00002769 S = ConstantExpr::CreateEmpty(
2770 Context,
2771 static_cast<ConstantExpr::ResultStorageKind>(
2772 Record[ASTStmtReader::NumExprFields]),
2773 Empty);
Bill Wendling7c44da22018-10-31 03:48:47 +00002774 break;
2775
Sebastian Redl539c5062010-08-18 23:57:32 +00002776 case EXPR_PREDEFINED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002777 S = PredefinedExpr::CreateEmpty(
2778 Context,
2779 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002780 break;
Mike Stump11289f42009-09-09 15:08:12 +00002781
Sebastian Redl539c5062010-08-18 23:57:32 +00002782 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002783 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00002784 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002785 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2786 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnara7945c982012-01-27 09:46:47 +00002787 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002788 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Richard Smith715f7a12019-06-11 17:50:32 +00002789 Record[ASTStmtReader::NumExprFields + 6] : 0);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002790 break;
Mike Stump11289f42009-09-09 15:08:12 +00002791
Sebastian Redl539c5062010-08-18 23:57:32 +00002792 case EXPR_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002793 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002794 break;
Mike Stump11289f42009-09-09 15:08:12 +00002795
Sebastian Redl539c5062010-08-18 23:57:32 +00002796 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002797 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002798 break;
Mike Stump11289f42009-09-09 15:08:12 +00002799
Sebastian Redl539c5062010-08-18 23:57:32 +00002800 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002801 S = new (Context) ImaginaryLiteral(Empty);
2802 break;
2803
Sebastian Redl539c5062010-08-18 23:57:32 +00002804 case EXPR_STRING_LITERAL:
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002805 S = StringLiteral::CreateEmpty(
2806 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002807 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002808 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2809 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002810 break;
2811
Sebastian Redl539c5062010-08-18 23:57:32 +00002812 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002813 S = new (Context) CharacterLiteral(Empty);
2814 break;
2815
Sebastian Redl539c5062010-08-18 23:57:32 +00002816 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002817 S = new (Context) ParenExpr(Empty);
2818 break;
2819
Sebastian Redl539c5062010-08-18 23:57:32 +00002820 case EXPR_PAREN_LIST:
Bruno Riccif49e1ca2018-11-20 16:20:40 +00002821 S = ParenListExpr::CreateEmpty(
2822 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002823 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00002824 break;
2825
Sebastian Redl539c5062010-08-18 23:57:32 +00002826 case EXPR_UNARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002827 S = new (Context) UnaryOperator(Empty);
2828 break;
2829
Sebastian Redl539c5062010-08-18 23:57:32 +00002830 case EXPR_OFFSETOF:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002831 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002832 Record[ASTStmtReader::NumExprFields],
2833 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00002834 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002835
Sebastian Redl539c5062010-08-18 23:57:32 +00002836 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00002837 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002838 break;
2839
Sebastian Redl539c5062010-08-18 23:57:32 +00002840 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002841 S = new (Context) ArraySubscriptExpr(Empty);
2842 break;
2843
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002844 case EXPR_OMP_ARRAY_SECTION:
2845 S = new (Context) OMPArraySectionExpr(Empty);
2846 break;
2847
Sebastian Redl539c5062010-08-18 23:57:32 +00002848 case EXPR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00002849 S = CallExpr::CreateEmpty(
2850 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002851 break;
2852
Richard Smithdcf17de2019-06-06 23:24:15 +00002853 case EXPR_MEMBER:
2854 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
2855 Record[ASTStmtReader::NumExprFields + 1],
2856 Record[ASTStmtReader::NumExprFields + 2],
2857 Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002858 break;
2859
Sebastian Redl539c5062010-08-18 23:57:32 +00002860 case EXPR_BINARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002861 S = new (Context) BinaryOperator(Empty);
2862 break;
2863
Sebastian Redl539c5062010-08-18 23:57:32 +00002864 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002865 S = new (Context) CompoundAssignOperator(Empty);
2866 break;
2867
Sebastian Redl539c5062010-08-18 23:57:32 +00002868 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002869 S = new (Context) ConditionalOperator(Empty);
2870 break;
2871
John McCallc07a0c72011-02-17 10:25:35 +00002872 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2873 S = new (Context) BinaryConditionalOperator(Empty);
2874 break;
2875
Sebastian Redl539c5062010-08-18 23:57:32 +00002876 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002877 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002878 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002879 break;
2880
Sebastian Redl539c5062010-08-18 23:57:32 +00002881 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002882 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002883 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002884 break;
2885
Sebastian Redl539c5062010-08-18 23:57:32 +00002886 case EXPR_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002887 S = new (Context) CompoundLiteralExpr(Empty);
2888 break;
2889
Sebastian Redl539c5062010-08-18 23:57:32 +00002890 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002891 S = new (Context) ExtVectorElementExpr(Empty);
2892 break;
2893
Sebastian Redl539c5062010-08-18 23:57:32 +00002894 case EXPR_INIT_LIST:
Argyrios Kyrtzidis0f05fb92012-11-28 03:56:16 +00002895 S = new (Context) InitListExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002896 break;
2897
Sebastian Redl539c5062010-08-18 23:57:32 +00002898 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002899 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002900 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00002901
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002902 break;
2903
Yunzhong Gaocb779302015-06-10 00:27:52 +00002904 case EXPR_DESIGNATED_INIT_UPDATE:
2905 S = new (Context) DesignatedInitUpdateExpr(Empty);
2906 break;
2907
Sebastian Redl539c5062010-08-18 23:57:32 +00002908 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002909 S = new (Context) ImplicitValueInitExpr(Empty);
2910 break;
2911
Yunzhong Gaocb779302015-06-10 00:27:52 +00002912 case EXPR_NO_INIT:
2913 S = new (Context) NoInitExpr(Empty);
2914 break;
2915
Richard Smith410306b2016-12-12 02:53:20 +00002916 case EXPR_ARRAY_INIT_LOOP:
2917 S = new (Context) ArrayInitLoopExpr(Empty);
2918 break;
2919
2920 case EXPR_ARRAY_INIT_INDEX:
2921 S = new (Context) ArrayInitIndexExpr(Empty);
2922 break;
2923
Sebastian Redl539c5062010-08-18 23:57:32 +00002924 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002925 S = new (Context) VAArgExpr(Empty);
2926 break;
2927
Eric Fiselier708afb52019-05-16 21:04:15 +00002928 case EXPR_SOURCE_LOC:
2929 S = new (Context) SourceLocExpr(Empty);
2930 break;
2931
Sebastian Redl539c5062010-08-18 23:57:32 +00002932 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002933 S = new (Context) AddrLabelExpr(Empty);
2934 break;
2935
Sebastian Redl539c5062010-08-18 23:57:32 +00002936 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002937 S = new (Context) StmtExpr(Empty);
2938 break;
2939
Sebastian Redl539c5062010-08-18 23:57:32 +00002940 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002941 S = new (Context) ChooseExpr(Empty);
2942 break;
2943
Sebastian Redl539c5062010-08-18 23:57:32 +00002944 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002945 S = new (Context) GNUNullExpr(Empty);
2946 break;
2947
Sebastian Redl539c5062010-08-18 23:57:32 +00002948 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002949 S = new (Context) ShuffleVectorExpr(Empty);
2950 break;
Mike Stump11289f42009-09-09 15:08:12 +00002951
Hal Finkelc4d7c822013-09-18 03:29:45 +00002952 case EXPR_CONVERT_VECTOR:
2953 S = new (Context) ConvertVectorExpr(Empty);
2954 break;
2955
Sebastian Redl539c5062010-08-18 23:57:32 +00002956 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002957 S = new (Context) BlockExpr(Empty);
2958 break;
2959
Peter Collingbourne91147592011-04-15 00:35:48 +00002960 case EXPR_GENERIC_SELECTION:
Bruno Riccidb076832019-01-26 14:15:10 +00002961 S = GenericSelectionExpr::CreateEmpty(
2962 Context,
2963 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
Peter Collingbourne91147592011-04-15 00:35:48 +00002964 break;
2965
Sebastian Redl539c5062010-08-18 23:57:32 +00002966 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002967 S = new (Context) ObjCStringLiteral(Empty);
2968 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002969
Patrick Beard0caa3942012-04-19 00:25:12 +00002970 case EXPR_OBJC_BOXED_EXPRESSION:
2971 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremeneke65b0862012-03-06 20:05:56 +00002972 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002973
Ted Kremeneke65b0862012-03-06 20:05:56 +00002974 case EXPR_OBJC_ARRAY_LITERAL:
2975 S = ObjCArrayLiteral::CreateEmpty(Context,
2976 Record[ASTStmtReader::NumExprFields]);
2977 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002978
Ted Kremeneke65b0862012-03-06 20:05:56 +00002979 case EXPR_OBJC_DICTIONARY_LITERAL:
2980 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2981 Record[ASTStmtReader::NumExprFields],
2982 Record[ASTStmtReader::NumExprFields + 1]);
2983 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002984
Sebastian Redl539c5062010-08-18 23:57:32 +00002985 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002986 S = new (Context) ObjCEncodeExpr(Empty);
2987 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002988
Sebastian Redl539c5062010-08-18 23:57:32 +00002989 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002990 S = new (Context) ObjCSelectorExpr(Empty);
2991 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002992
Sebastian Redl539c5062010-08-18 23:57:32 +00002993 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002994 S = new (Context) ObjCProtocolExpr(Empty);
2995 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002996
Sebastian Redl539c5062010-08-18 23:57:32 +00002997 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002998 S = new (Context) ObjCIvarRefExpr(Empty);
2999 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003000
Sebastian Redl539c5062010-08-18 23:57:32 +00003001 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003002 S = new (Context) ObjCPropertyRefExpr(Empty);
3003 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003004
Ted Kremeneke65b0862012-03-06 20:05:56 +00003005 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
3006 S = new (Context) ObjCSubscriptRefExpr(Empty);
3007 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003008
Sebastian Redl539c5062010-08-18 23:57:32 +00003009 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00003010 llvm_unreachable("mismatching AST file");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003011
Sebastian Redl539c5062010-08-18 23:57:32 +00003012 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003013 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00003014 Record[ASTStmtReader::NumExprFields],
3015 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003016 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003017
Sebastian Redl539c5062010-08-18 23:57:32 +00003018 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00003019 S = new (Context) ObjCIsaExpr(Empty);
3020 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003021
John McCall31168b02011-06-15 23:02:42 +00003022 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
3023 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
3024 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003025
John McCall31168b02011-06-15 23:02:42 +00003026 case EXPR_OBJC_BRIDGED_CAST:
3027 S = new (Context) ObjCBridgedCastExpr(Empty);
3028 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003029
Sebastian Redl539c5062010-08-18 23:57:32 +00003030 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003031 S = new (Context) ObjCForCollectionStmt(Empty);
3032 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003033
Sebastian Redl539c5062010-08-18 23:57:32 +00003034 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003035 S = new (Context) ObjCAtCatchStmt(Empty);
3036 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003037
Sebastian Redl539c5062010-08-18 23:57:32 +00003038 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003039 S = new (Context) ObjCAtFinallyStmt(Empty);
3040 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003041
Sebastian Redl539c5062010-08-18 23:57:32 +00003042 case STMT_OBJC_AT_TRY:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003043 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003044 Record[ASTStmtReader::NumStmtFields],
3045 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003046 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003047
Sebastian Redl539c5062010-08-18 23:57:32 +00003048 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003049 S = new (Context) ObjCAtSynchronizedStmt(Empty);
3050 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003051
Sebastian Redl539c5062010-08-18 23:57:32 +00003052 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003053 S = new (Context) ObjCAtThrowStmt(Empty);
3054 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003055
John McCall31168b02011-06-15 23:02:42 +00003056 case STMT_OBJC_AUTORELEASE_POOL:
3057 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3058 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003059
Ted Kremeneke65b0862012-03-06 20:05:56 +00003060 case EXPR_OBJC_BOOL_LITERAL:
3061 S = new (Context) ObjCBoolLiteralExpr(Empty);
3062 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003063
Erik Pilkington29099de2016-07-16 00:35:23 +00003064 case EXPR_OBJC_AVAILABILITY_CHECK:
3065 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3066 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003067
Nico Weber9b982072014-07-07 00:12:30 +00003068 case STMT_SEH_LEAVE:
3069 S = new (Context) SEHLeaveStmt(Empty);
3070 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003071
John McCallfa194042011-07-15 07:00:14 +00003072 case STMT_SEH_EXCEPT:
3073 S = new (Context) SEHExceptStmt(Empty);
3074 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003075
John McCallfa194042011-07-15 07:00:14 +00003076 case STMT_SEH_FINALLY:
3077 S = new (Context) SEHFinallyStmt(Empty);
3078 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003079
John McCallfa194042011-07-15 07:00:14 +00003080 case STMT_SEH_TRY:
3081 S = new (Context) SEHTryStmt(Empty);
3082 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003083
Sebastian Redl539c5062010-08-18 23:57:32 +00003084 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003085 S = new (Context) CXXCatchStmt(Empty);
3086 break;
3087
Sebastian Redl539c5062010-08-18 23:57:32 +00003088 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003089 S = CXXTryStmt::Create(Context, Empty,
Rui Ueyama49a3ad22019-07-16 04:46:31 +00003090 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003091 break;
3092
Richard Smith02e85f32011-04-14 22:09:26 +00003093 case STMT_CXX_FOR_RANGE:
3094 S = new (Context) CXXForRangeStmt(Empty);
3095 break;
3096
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003097 case STMT_MS_DEPENDENT_EXISTS:
3098 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3099 NestedNameSpecifierLoc(),
3100 DeclarationNameInfo(),
Craig Toppera13603a2014-05-22 05:54:18 +00003101 nullptr);
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003102 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003103
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00003104 case STMT_OMP_PARALLEL_DIRECTIVE:
3105 S =
3106 OMPParallelDirective::CreateEmpty(Context,
3107 Record[ASTStmtReader::NumStmtFields],
3108 Empty);
3109 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003110
3111 case STMT_OMP_SIMD_DIRECTIVE: {
3112 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3113 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3114 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3115 CollapsedNum, Empty);
3116 break;
3117 }
3118
Alexey Bataevf29276e2014-06-18 04:14:57 +00003119 case STMT_OMP_FOR_DIRECTIVE: {
3120 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3121 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3122 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3123 Empty);
3124 break;
3125 }
3126
Alexander Musmanf82886e2014-09-18 05:12:34 +00003127 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3128 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3129 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3130 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3131 Empty);
3132 break;
3133 }
3134
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00003135 case STMT_OMP_SECTIONS_DIRECTIVE:
3136 S = OMPSectionsDirective::CreateEmpty(
3137 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3138 break;
3139
Alexey Bataev1e0498a2014-06-26 08:21:58 +00003140 case STMT_OMP_SECTION_DIRECTIVE:
3141 S = OMPSectionDirective::CreateEmpty(Context, Empty);
3142 break;
3143
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00003144 case STMT_OMP_SINGLE_DIRECTIVE:
3145 S = OMPSingleDirective::CreateEmpty(
3146 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3147 break;
3148
Alexander Musman80c22892014-07-17 08:54:58 +00003149 case STMT_OMP_MASTER_DIRECTIVE:
3150 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3151 break;
3152
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003153 case STMT_OMP_CRITICAL_DIRECTIVE:
Alexey Bataev28c75412015-12-15 08:19:24 +00003154 S = OMPCriticalDirective::CreateEmpty(
3155 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003156 break;
3157
Alexey Bataev4acb8592014-07-07 13:01:15 +00003158 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3159 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3160 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3161 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3162 CollapsedNum, Empty);
3163 break;
3164 }
3165
Alexander Musmane4e893b2014-09-23 09:33:00 +00003166 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3167 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3168 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3169 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3170 CollapsedNum, Empty);
3171 break;
3172 }
3173
cchen47d60942019-12-05 13:43:48 -05003174 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3175 S = OMPParallelMasterDirective::CreateEmpty(
3176 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3177 break;
3178
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00003179 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3180 S = OMPParallelSectionsDirective::CreateEmpty(
3181 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3182 break;
3183
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00003184 case STMT_OMP_TASK_DIRECTIVE:
3185 S = OMPTaskDirective::CreateEmpty(
3186 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3187 break;
3188
Alexey Bataev68446b72014-07-18 07:47:19 +00003189 case STMT_OMP_TASKYIELD_DIRECTIVE:
3190 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3191 break;
3192
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00003193 case STMT_OMP_BARRIER_DIRECTIVE:
3194 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3195 break;
3196
Alexey Bataev2df347a2014-07-18 10:17:07 +00003197 case STMT_OMP_TASKWAIT_DIRECTIVE:
3198 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3199 break;
3200
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003201 case STMT_OMP_TASKGROUP_DIRECTIVE:
Alexey Bataev169d96a2017-07-18 20:17:46 +00003202 S = OMPTaskgroupDirective::CreateEmpty(
3203 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003204 break;
3205
Alexey Bataev6125da92014-07-21 11:26:11 +00003206 case STMT_OMP_FLUSH_DIRECTIVE:
3207 S = OMPFlushDirective::CreateEmpty(
3208 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3209 break;
3210
Alexey Bataevc112e942020-02-28 09:52:15 -05003211 case STMT_OMP_DEPOBJ_DIRECTIVE:
3212 S = OMPDepobjDirective::CreateEmpty(
3213 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3214 break;
3215
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003216 case STMT_OMP_ORDERED_DIRECTIVE:
Alexey Bataev346265e2015-09-25 10:37:12 +00003217 S = OMPOrderedDirective::CreateEmpty(
3218 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003219 break;
3220
Alexey Bataev0162e452014-07-22 10:10:35 +00003221 case STMT_OMP_ATOMIC_DIRECTIVE:
3222 S = OMPAtomicDirective::CreateEmpty(
3223 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3224 break;
3225
Alexey Bataev0bd520b2014-09-19 08:19:49 +00003226 case STMT_OMP_TARGET_DIRECTIVE:
3227 S = OMPTargetDirective::CreateEmpty(
3228 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3229 break;
3230
Michael Wong65f367f2015-07-21 13:44:28 +00003231 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3232 S = OMPTargetDataDirective::CreateEmpty(
3233 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3234 break;
3235
Samuel Antaodf67fc42016-01-19 19:15:56 +00003236 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3237 S = OMPTargetEnterDataDirective::CreateEmpty(
3238 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3239 break;
3240
Samuel Antao72590762016-01-19 20:04:50 +00003241 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3242 S = OMPTargetExitDataDirective::CreateEmpty(
3243 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3244 break;
3245
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00003246 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3247 S = OMPTargetParallelDirective::CreateEmpty(
3248 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3249 break;
3250
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00003251 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3252 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3253 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3254 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3255 CollapsedNum, Empty);
3256 break;
3257 }
3258
Samuel Antao686c70c2016-05-26 17:30:50 +00003259 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3260 S = OMPTargetUpdateDirective::CreateEmpty(
3261 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3262 break;
3263
Alexey Bataev13314bf2014-10-09 04:18:56 +00003264 case STMT_OMP_TEAMS_DIRECTIVE:
3265 S = OMPTeamsDirective::CreateEmpty(
3266 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3267 break;
3268
Alexey Bataev6d4ed052015-07-01 06:57:41 +00003269 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3270 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3271 break;
3272
Alexey Bataev80909872015-07-02 11:25:17 +00003273 case STMT_OMP_CANCEL_DIRECTIVE:
Alexey Bataev87933c72015-09-18 08:07:34 +00003274 S = OMPCancelDirective::CreateEmpty(
3275 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev80909872015-07-02 11:25:17 +00003276 break;
3277
Alexey Bataev49f6e782015-12-01 04:18:41 +00003278 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3279 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3280 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3281 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3282 Empty);
3283 break;
3284 }
3285
Alexey Bataev0a6ed842015-12-03 09:40:15 +00003286 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3287 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3288 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3289 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3290 CollapsedNum, Empty);
3291 break;
3292 }
3293
Alexey Bataev60e51c42019-10-10 20:13:02 +00003294 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3295 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3296 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3297 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3298 CollapsedNum, Empty);
3299 break;
3300 }
3301
Alexey Bataevb8552ab2019-10-18 16:47:35 +00003302 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3303 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3304 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3305 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3306 CollapsedNum, Empty);
3307 break;
3308 }
3309
Alexey Bataev5bbcead2019-10-14 17:17:41 +00003310 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3311 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3312 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3313 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3314 CollapsedNum, Empty);
3315 break;
3316 }
3317
Alexey Bataev14a388f2019-10-25 10:27:13 -04003318 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3319 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3320 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3321 S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3322 Context, NumClauses, CollapsedNum, Empty);
3323 break;
3324 }
3325
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00003326 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3327 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3328 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3329 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3330 Empty);
3331 break;
3332 }
3333
Carlo Bertolli9925f152016-06-27 14:55:37 +00003334 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3335 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3336 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3337 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3338 CollapsedNum, Empty);
3339 break;
3340 }
3341
Kelvin Li4a39add2016-07-05 05:00:15 +00003342 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3343 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3344 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3345 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3346 CollapsedNum,
3347 Empty);
3348 break;
3349 }
3350
Kelvin Li787f3fc2016-07-06 04:45:38 +00003351 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3352 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3353 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3354 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3355 CollapsedNum, Empty);
3356 break;
3357 }
3358
Kelvin Lia579b912016-07-14 02:54:56 +00003359 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3360 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3361 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3362 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3363 CollapsedNum, Empty);
3364 break;
3365 }
3366
Kelvin Li986330c2016-07-20 22:57:10 +00003367 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3368 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3369 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3370 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3371 Empty);
3372 break;
3373 }
3374
Kelvin Li83c451e2016-12-25 04:52:54 +00003375 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
Kelvin Li02532872016-08-05 14:37:37 +00003376 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3377 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3378 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3379 CollapsedNum, Empty);
3380 break;
3381 }
3382
Kelvin Li4e325f72016-10-25 12:50:55 +00003383 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3384 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3385 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3386 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3387 CollapsedNum, Empty);
3388 break;
3389 }
3390
Kelvin Li579e41c2016-11-30 23:51:03 +00003391 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3392 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3393 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3394 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3395 Context, NumClauses, CollapsedNum, Empty);
3396 break;
3397 }
3398
Kelvin Li7ade93f2016-12-09 03:24:30 +00003399 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3400 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3401 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3402 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3403 Context, NumClauses, CollapsedNum, Empty);
3404 break;
3405 }
3406
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003407 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
Kelvin Libf594a52016-12-17 05:48:59 +00003408 S = OMPTargetTeamsDirective::CreateEmpty(
3409 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3410 break;
Kelvin Li83c451e2016-12-25 04:52:54 +00003411
3412 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3413 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3414 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3415 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3416 CollapsedNum, Empty);
3417 break;
3418 }
3419
Kelvin Li80e8f562016-12-29 22:16:30 +00003420 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3421 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3422 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3423 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3424 Context, NumClauses, CollapsedNum, Empty);
3425 break;
3426 }
3427
Kelvin Li1851df52017-01-03 05:23:48 +00003428 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3429 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3430 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3431 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3432 Context, NumClauses, CollapsedNum, Empty);
3433 break;
3434 }
3435
Kelvin Lida681182017-01-10 18:08:18 +00003436 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3437 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3438 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3439 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3440 Context, NumClauses, CollapsedNum, Empty);
3441 break;
3442 }
3443
Sebastian Redl539c5062010-08-18 23:57:32 +00003444 case EXPR_CXX_OPERATOR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003445 S = CXXOperatorCallExpr::CreateEmpty(
3446 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00003447 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003448
Sebastian Redl539c5062010-08-18 23:57:32 +00003449 case EXPR_CXX_MEMBER_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003450 S = CXXMemberCallExpr::CreateEmpty(
3451 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003452 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003453
Richard Smith778dc0f2019-10-19 00:04:38 +00003454 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3455 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3456 break;
3457
Sebastian Redl539c5062010-08-18 23:57:32 +00003458 case EXPR_CXX_CONSTRUCT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003459 S = CXXConstructExpr::CreateEmpty(
3460 Context,
3461 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003462 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003463
Richard Smith5179eb72016-06-28 19:03:57 +00003464 case EXPR_CXX_INHERITED_CTOR_INIT:
3465 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3466 break;
3467
Sebastian Redl539c5062010-08-18 23:57:32 +00003468 case EXPR_CXX_TEMPORARY_OBJECT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003469 S = CXXTemporaryObjectExpr::CreateEmpty(
3470 Context,
3471 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00003472 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003473
Sebastian Redl539c5062010-08-18 23:57:32 +00003474 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003475 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003476 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003477 break;
3478
Sebastian Redl539c5062010-08-18 23:57:32 +00003479 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003480 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003481 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003482 break;
3483
Sebastian Redl539c5062010-08-18 23:57:32 +00003484 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003485 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003486 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003487 break;
3488
Sebastian Redl539c5062010-08-18 23:57:32 +00003489 case EXPR_CXX_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003490 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00003491 break;
3492
Sebastian Redl539c5062010-08-18 23:57:32 +00003493 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003494 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003495 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003496 break;
3497
Richard Smithc67fdd42012-03-07 08:35:16 +00003498 case EXPR_USER_DEFINED_LITERAL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003499 S = UserDefinedLiteral::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003500 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Richard Smithc67fdd42012-03-07 08:35:16 +00003501 break;
3502
Richard Smithcc1b96d2013-06-12 22:31:48 +00003503 case EXPR_CXX_STD_INITIALIZER_LIST:
3504 S = new (Context) CXXStdInitializerListExpr(Empty);
3505 break;
3506
Sebastian Redl539c5062010-08-18 23:57:32 +00003507 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003508 S = new (Context) CXXBoolLiteralExpr(Empty);
3509 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003510
Sebastian Redl539c5062010-08-18 23:57:32 +00003511 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003512 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3513 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003514
Sebastian Redl539c5062010-08-18 23:57:32 +00003515 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003516 S = new (Context) CXXTypeidExpr(Empty, true);
3517 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003518
Sebastian Redl539c5062010-08-18 23:57:32 +00003519 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003520 S = new (Context) CXXTypeidExpr(Empty, false);
3521 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003522
Francois Pichet9f4f2072010-09-08 12:20:18 +00003523 case EXPR_CXX_UUIDOF_EXPR:
3524 S = new (Context) CXXUuidofExpr(Empty, true);
3525 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003526
John McCall5e77d762013-04-16 07:28:30 +00003527 case EXPR_CXX_PROPERTY_REF_EXPR:
3528 S = new (Context) MSPropertyRefExpr(Empty);
3529 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003530
Alexey Bataevf7630272015-11-25 12:01:00 +00003531 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3532 S = new (Context) MSPropertySubscriptExpr(Empty);
3533 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003534
Francois Pichet9f4f2072010-09-08 12:20:18 +00003535 case EXPR_CXX_UUIDOF_TYPE:
3536 S = new (Context) CXXUuidofExpr(Empty, false);
3537 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003538
Sebastian Redl539c5062010-08-18 23:57:32 +00003539 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00003540 S = new (Context) CXXThisExpr(Empty);
3541 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003542
Sebastian Redl539c5062010-08-18 23:57:32 +00003543 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00003544 S = new (Context) CXXThrowExpr(Empty);
3545 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003546
John McCall32791cc2016-01-06 22:34:54 +00003547 case EXPR_CXX_DEFAULT_ARG:
3548 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00003549 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003550
Richard Smith852c9db2013-04-20 22:23:05 +00003551 case EXPR_CXX_DEFAULT_INIT:
3552 S = new (Context) CXXDefaultInitExpr(Empty);
3553 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003554
Sebastian Redl539c5062010-08-18 23:57:32 +00003555 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00003556 S = new (Context) CXXBindTemporaryExpr(Empty);
3557 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003558
Sebastian Redl539c5062010-08-18 23:57:32 +00003559 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00003560 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003561 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003562
Sebastian Redl539c5062010-08-18 23:57:32 +00003563 case EXPR_CXX_NEW:
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00003564 S = CXXNewExpr::CreateEmpty(
3565 Context,
3566 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3567 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3568 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3569 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003570 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003571
Sebastian Redl539c5062010-08-18 23:57:32 +00003572 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00003573 S = new (Context) CXXDeleteExpr(Empty);
3574 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003575
Sebastian Redl539c5062010-08-18 23:57:32 +00003576 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00003577 S = new (Context) CXXPseudoDestructorExpr(Empty);
3578 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003579
John McCall5d413782010-12-06 08:20:24 +00003580 case EXPR_EXPR_WITH_CLEANUPS:
John McCall28fc7092011-11-10 05:35:25 +00003581 S = ExprWithCleanups::Create(Context, Empty,
3582 Record[ASTStmtReader::NumExprFields]);
Chris Lattnercba86142010-05-10 00:25:06 +00003583 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003584
Sebastian Redl539c5062010-08-18 23:57:32 +00003585 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Bruno Ricci2e6dc532019-01-08 14:17:00 +00003586 S = CXXDependentScopeMemberExpr::CreateEmpty(
3587 Context,
3588 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3589 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3590 /*HasFirstQualifierFoundInScope=*/
3591 Record[ASTStmtReader::NumExprFields + 2]);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003592 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003593
Sebastian Redl539c5062010-08-18 23:57:32 +00003594 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003595 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003596 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003597 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003598 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003599 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00003600 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003601
Sebastian Redl539c5062010-08-18 23:57:32 +00003602 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003603 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003604 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00003605 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003606
Sebastian Redl539c5062010-08-18 23:57:32 +00003607 case EXPR_CXX_UNRESOLVED_MEMBER:
Bruno Riccid7628d92019-01-09 15:43:19 +00003608 S = UnresolvedMemberExpr::CreateEmpty(
3609 Context,
3610 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3611 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3612 /*NumTemplateArgs=*/
3613 Record[ASTStmtReader::NumExprFields + 1]
3614 ? Record[ASTStmtReader::NumExprFields + 2]
3615 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003616 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003617
Sebastian Redl539c5062010-08-18 23:57:32 +00003618 case EXPR_CXX_UNRESOLVED_LOOKUP:
Bruno Riccid7628d92019-01-09 15:43:19 +00003619 S = UnresolvedLookupExpr::CreateEmpty(
3620 Context,
3621 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3622 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3623 /*NumTemplateArgs=*/
3624 Record[ASTStmtReader::NumExprFields + 1]
3625 ? Record[ASTStmtReader::NumExprFields + 2]
3626 : 0);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00003627 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003628
Douglas Gregor29c42f22012-02-24 07:38:34 +00003629 case EXPR_TYPE_TRAIT:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003630 S = TypeTraitExpr::CreateDeserialized(Context,
Douglas Gregor29c42f22012-02-24 07:38:34 +00003631 Record[ASTStmtReader::NumExprFields]);
3632 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003633
John Wiegley6242b6a2011-04-28 00:16:57 +00003634 case EXPR_ARRAY_TYPE_TRAIT:
3635 S = new (Context) ArrayTypeTraitExpr(Empty);
3636 break;
3637
John Wiegleyf9f65842011-04-25 06:54:41 +00003638 case EXPR_CXX_EXPRESSION_TRAIT:
3639 S = new (Context) ExpressionTraitExpr(Empty);
3640 break;
3641
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003642 case EXPR_CXX_NOEXCEPT:
3643 S = new (Context) CXXNoexceptExpr(Empty);
3644 break;
John McCall8d69a212010-11-15 23:31:06 +00003645
Douglas Gregore8e9dd62011-01-03 17:17:50 +00003646 case EXPR_PACK_EXPANSION:
3647 S = new (Context) PackExpansionExpr(Empty);
3648 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003649
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003650 case EXPR_SIZEOF_PACK:
Richard Smithd784e682015-09-23 21:41:42 +00003651 S = SizeOfPackExpr::CreateDeserialized(
3652 Context,
3653 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003654 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003655
John McCallfa194042011-07-15 07:00:14 +00003656 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3657 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3658 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003659
Douglas Gregorcdbc5392011-01-15 01:15:58 +00003660 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3661 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3662 break;
Richard Smithb15fe3a2012-09-12 00:56:43 +00003663
3664 case EXPR_FUNCTION_PARM_PACK:
3665 S = FunctionParmPackExpr::CreateEmpty(Context,
3666 Record[ASTStmtReader::NumExprFields]);
3667 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003668
Douglas Gregorfe314812011-06-21 17:03:29 +00003669 case EXPR_MATERIALIZE_TEMPORARY:
3670 S = new (Context) MaterializeTemporaryExpr(Empty);
3671 break;
Richard Smith0f0af192014-11-08 05:07:16 +00003672
3673 case EXPR_CXX_FOLD:
3674 S = new (Context) CXXFoldExpr(Empty);
3675 break;
3676
Argyrios Kyrtzidisb2b07952011-12-03 03:49:52 +00003677 case EXPR_OPAQUE_VALUE:
3678 S = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00003679 break;
Peter Collingbourne41f85462011-02-09 21:07:24 +00003680
3681 case EXPR_CUDA_KERNEL_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003682 S = CUDAKernelCallExpr::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003683 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00003684 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003685
Tanya Lattner55808c12011-06-04 00:47:47 +00003686 case EXPR_ASTYPE:
3687 S = new (Context) AsTypeExpr(Empty);
3688 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003689
John McCallfe96e0b2011-11-06 09:01:30 +00003690 case EXPR_PSEUDO_OBJECT: {
3691 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3692 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3693 break;
3694 }
3695
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003696 case EXPR_ATOMIC:
3697 S = new (Context) AtomicExpr(Empty);
3698 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003699
Douglas Gregor99ae8062012-02-14 17:54:36 +00003700 case EXPR_LAMBDA: {
3701 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
Richard Smith30e304e2016-12-14 00:03:17 +00003702 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
Douglas Gregor99ae8062012-02-14 17:54:36 +00003703 break;
3704 }
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +00003705
3706 case STMT_COROUTINE_BODY: {
3707 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3708 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3709 break;
3710 }
3711
3712 case STMT_CORETURN:
3713 S = new (Context) CoreturnStmt(Empty);
3714 break;
3715
3716 case EXPR_COAWAIT:
3717 S = new (Context) CoawaitExpr(Empty);
3718 break;
3719
3720 case EXPR_COYIELD:
3721 S = new (Context) CoyieldExpr(Empty);
3722 break;
3723
3724 case EXPR_DEPENDENT_COAWAIT:
3725 S = new (Context) DependentCoawaitExpr(Empty);
3726 break;
Saar Raz5d98ba62019-10-15 15:24:26 +00003727
Saar Raza0f50d72020-01-18 09:11:43 +02003728 case EXPR_CONCEPT_SPECIALIZATION: {
Saar Raz5d98ba62019-10-15 15:24:26 +00003729 unsigned numTemplateArgs = Record[ASTStmtReader::NumExprFields];
3730 S = ConceptSpecializationExpr::Create(Context, Empty, numTemplateArgs);
3731 break;
Saar Raza0f50d72020-01-18 09:11:43 +02003732 }
3733
3734 case EXPR_REQUIRES:
3735 unsigned numLocalParameters = Record[ASTStmtReader::NumExprFields];
3736 unsigned numRequirement = Record[ASTStmtReader::NumExprFields + 1];
3737 S = RequiresExpr::Create(Context, Empty, numLocalParameters,
3738 numRequirement);
3739 break;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003740 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003741
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003742 // We hit a STMT_STOP, so we're done with this expression.
3743 if (Finished)
3744 break;
3745
3746 ++NumStatementsRead;
3747
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003748 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003749 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003750 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3751 }
3752
David L. Jonesbe1557a2016-12-21 00:17:49 +00003753 assert(Record.getIdx() == Record.size() &&
3754 "Invalid deserialization of statement");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003755 StmtStack.push_back(S);
3756 }
Chris Lattner0e6c9402013-01-20 02:38:54 +00003757Done:
Alp Toker028ed912013-12-06 17:56:43 +00003758 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003759 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003760 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003761}