blob: 5dd0ef9d43c3e75597a18e7c3fdbe5ffbae262c0 [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
John McCallc2f18312019-12-14 03:01:28 -050014#include "clang/Serialization/ASTRecordReader.h"
Saar Razfdf80e82019-12-06 01:30:21 +020015#include "clang/AST/ASTConcept.h"
Benjamin Kramer4ab984e2012-07-04 20:19:54 +000016#include "clang/AST/ASTContext.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000017#include "clang/AST/AttrIterator.h"
18#include "clang/AST/Decl.h"
19#include "clang/AST/DeclAccessPair.h"
Douglas Gregor5d3507d2009-09-09 23:08:42 +000020#include "clang/AST/DeclCXX.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000021#include "clang/AST/DeclGroup.h"
22#include "clang/AST/DeclObjC.h"
Douglas Gregorcdbc5392011-01-15 01:15:58 +000023#include "clang/AST/DeclTemplate.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000024#include "clang/AST/DeclarationName.h"
25#include "clang/AST/Expr.h"
26#include "clang/AST/ExprCXX.h"
27#include "clang/AST/ExprObjC.h"
28#include "clang/AST/ExprOpenMP.h"
29#include "clang/AST/NestedNameSpecifier.h"
30#include "clang/AST/OpenMPClause.h"
31#include "clang/AST/OperationKinds.h"
32#include "clang/AST/Stmt.h"
33#include "clang/AST/StmtCXX.h"
34#include "clang/AST/StmtObjC.h"
35#include "clang/AST/StmtOpenMP.h"
Chris Lattner92ba5ff2009-04-27 05:14:47 +000036#include "clang/AST/StmtVisitor.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000037#include "clang/AST/TemplateBase.h"
38#include "clang/AST/Type.h"
39#include "clang/AST/UnresolvedSet.h"
40#include "clang/Basic/CapturedStmt.h"
41#include "clang/Basic/ExpressionTraits.h"
42#include "clang/Basic/LLVM.h"
43#include "clang/Basic/Lambda.h"
44#include "clang/Basic/LangOptions.h"
45#include "clang/Basic/OpenMPKinds.h"
46#include "clang/Basic/OperatorKinds.h"
47#include "clang/Basic/SourceLocation.h"
48#include "clang/Basic/Specifiers.h"
49#include "clang/Basic/TypeTraits.h"
John McCallf413f5e2013-05-03 00:10:13 +000050#include "clang/Lex/Token.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000051#include "clang/Serialization/ASTBitCodes.h"
52#include "llvm/ADT/DenseMap.h"
Benjamin Kramer49038022012-02-04 13:45:25 +000053#include "llvm/ADT/SmallString.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000054#include "llvm/ADT/SmallVector.h"
55#include "llvm/ADT/StringRef.h"
Francis Visoiu Mistrihe0308272019-07-03 22:40:07 +000056#include "llvm/Bitstream/BitstreamReader.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000057#include "llvm/Support/Casting.h"
58#include "llvm/Support/ErrorHandling.h"
59#include <algorithm>
60#include <cassert>
61#include <cstdint>
62#include <string>
63
Chris Lattner92ba5ff2009-04-27 05:14:47 +000064using namespace clang;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000065using namespace serialization;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000066
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +000067namespace clang {
Argyrios Kyrtzidisddf5f212010-06-28 09:31:42 +000068
Sebastian Redl70c751d2010-08-18 23:56:52 +000069 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
David L. Jonesbe1557a2016-12-21 00:17:49 +000070 ASTRecordReader &Record;
Sebastian Redlc67764e2010-07-22 22:43:28 +000071 llvm::BitstreamCursor &DeclsCursor;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000072
John McCall3ce3d232019-12-13 03:37:23 -050073 SourceLocation readSourceLocation() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000074 return Record.readSourceLocation();
John McCallf413f5e2013-05-03 00:10:13 +000075 }
76
John McCall3ce3d232019-12-13 03:37:23 -050077 SourceRange readSourceRange() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000078 return Record.readSourceRange();
Sebastian Redl2c373b92010-10-05 15:59:54 +000079 }
John McCallf413f5e2013-05-03 00:10:13 +000080
John McCall3ce3d232019-12-13 03:37:23 -050081 std::string readString() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000082 return Record.readString();
Sebastian Redl2c373b92010-10-05 15:59:54 +000083 }
John McCallf413f5e2013-05-03 00:10:13 +000084
John McCall3ce3d232019-12-13 03:37:23 -050085 TypeSourceInfo *readTypeSourceInfo() {
86 return Record.readTypeSourceInfo();
John McCallf413f5e2013-05-03 00:10:13 +000087 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000088
John McCall3ce3d232019-12-13 03:37:23 -050089 Decl *readDecl() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000090 return Record.readDecl();
Sebastian Redl2c373b92010-10-05 15:59:54 +000091 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000092
Douglas Gregor7fb09192011-07-21 22:35:25 +000093 template<typename T>
John McCall3ce3d232019-12-13 03:37:23 -050094 T *readDeclAs() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000095 return Record.readDeclAs<T>();
Douglas Gregor7fb09192011-07-21 22:35:25 +000096 }
97
Chris Lattner92ba5ff2009-04-27 05:14:47 +000098 public:
David L. Jonesbe1557a2016-12-21 00:17:49 +000099 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
100 : Record(Record), DeclsCursor(Cursor) {}
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000101
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000102 /// The number of record fields required for the Stmt class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000103 /// itself.
Roman Lebedevb5700602019-03-20 16:32:36 +0000104 static const unsigned NumStmtFields = 1;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000105
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000106 /// The number of record fields required for the Expr class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000107 /// itself.
Douglas Gregor678d76c2011-07-01 01:22:09 +0000108 static const unsigned NumExprFields = NumStmtFields + 7;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000109
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000110 /// Read and initialize a ExplicitTemplateArgumentList structure.
Abramo Bagnara7945c982012-01-27 09:46:47 +0000111 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
James Y Knighte7d82282015-12-29 18:15:14 +0000112 TemplateArgumentLoc *ArgsLocArray,
Abramo Bagnara7945c982012-01-27 09:46:47 +0000113 unsigned NumTemplateArgs);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000114
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000115 /// Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisde6aa082011-09-22 20:07:03 +0000116 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000117 unsigned NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000118
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000119 void VisitStmt(Stmt *S);
John McCallfa194042011-07-15 07:00:14 +0000120#define STMT(Type, Base) \
121 void Visit##Type(Type *);
122#include "clang/AST/StmtNodes.inc"
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000123 };
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000124
125} // namespace clang
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000126
James Y Knighte7d82282015-12-29 18:15:14 +0000127void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
128 TemplateArgumentLoc *ArgsLocArray,
129 unsigned NumTemplateArgs) {
John McCall3ce3d232019-12-13 03:37:23 -0500130 SourceLocation TemplateKWLoc = readSourceLocation();
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000131 TemplateArgumentListInfo ArgInfo;
John McCall3ce3d232019-12-13 03:37:23 -0500132 ArgInfo.setLAngleLoc(readSourceLocation());
133 ArgInfo.setRAngleLoc(readSourceLocation());
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000134 for (unsigned i = 0; i != NumTemplateArgs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000135 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
James Y Knighte7d82282015-12-29 18:15:14 +0000136 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000137}
138
Sebastian Redl70c751d2010-08-18 23:56:52 +0000139void ASTStmtReader::VisitStmt(Stmt *S) {
Roman Lebedevb5700602019-03-20 16:32:36 +0000140 S->setIsOMPStructuredBlock(Record.readInt());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000141 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000142}
143
Sebastian Redl70c751d2010-08-18 23:56:52 +0000144void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000145 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500146 S->setSemiLoc(readSourceLocation());
Bruno Ricci41d11c02018-10-27 18:43:27 +0000147 S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000148}
149
Sebastian Redl70c751d2010-08-18 23:56:52 +0000150void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000151 VisitStmt(S);
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000152 SmallVector<Stmt *, 16> Stmts;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000153 unsigned NumStmts = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000154 while (NumStmts--)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000155 Stmts.push_back(Record.readSubStmt());
Benjamin Kramer07420902017-12-24 16:24:20 +0000156 S->setStmts(Stmts);
John McCall3ce3d232019-12-13 03:37:23 -0500157 S->CompoundStmtBits.LBraceLoc = readSourceLocation();
158 S->RBraceLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000159}
160
Sebastian Redl70c751d2010-08-18 23:56:52 +0000161void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000162 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000163 Record.recordSwitchCaseID(S, Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500164 S->setKeywordLoc(readSourceLocation());
165 S->setColonLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000166}
167
Sebastian Redl70c751d2010-08-18 23:56:52 +0000168void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000169 VisitSwitchCase(S);
Bruno Ricci5b30571752018-10-28 12:30:53 +0000170 bool CaseStmtIsGNURange = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000171 S->setLHS(Record.readSubExpr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000172 S->setSubStmt(Record.readSubStmt());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000173 if (CaseStmtIsGNURange) {
174 S->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500175 S->setEllipsisLoc(readSourceLocation());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000176 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000177}
178
Sebastian Redl70c751d2010-08-18 23:56:52 +0000179void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000180 VisitSwitchCase(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000181 S->setSubStmt(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000182}
183
Sebastian Redl70c751d2010-08-18 23:56:52 +0000184void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000185 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500186 auto *LD = readDeclAs<LabelDecl>();
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000187 LD->setStmt(S);
188 S->setDecl(LD);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000189 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500190 S->setIdentLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000191}
192
Richard Smithc202b282012-04-14 00:33:13 +0000193void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
194 VisitStmt(S);
Bruno Ricci41d11c02018-10-27 18:43:27 +0000195 // NumAttrs in AttributedStmt is set when creating an empty
196 // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
197 // to allocate the right amount of space for the trailing Attr *.
David L. Jonesbe1557a2016-12-21 00:17:49 +0000198 uint64_t NumAttrs = Record.readInt();
Richard Smithc202b282012-04-14 00:33:13 +0000199 AttrVec Attrs;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000200 Record.readAttributes(Attrs);
Matt Beaumont-Gayad0bb8e2012-07-09 18:55:31 +0000201 (void)NumAttrs;
Bruno Ricci41d11c02018-10-27 18:43:27 +0000202 assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
Alexander Kornienko20f6fc62012-07-09 10:04:07 +0000203 assert(NumAttrs == Attrs.size());
Aaron Ballmanf3d9b092014-05-13 14:55:01 +0000204 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000205 S->SubStmt = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500206 S->AttributedStmtBits.AttrLoc = readSourceLocation();
Richard Smithc202b282012-04-14 00:33:13 +0000207}
208
Sebastian Redl70c751d2010-08-18 23:56:52 +0000209void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000210 VisitStmt(S);
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000211
David L. Jonesbe1557a2016-12-21 00:17:49 +0000212 S->setConstexpr(Record.readInt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000213 bool HasElse = Record.readInt();
214 bool HasVar = Record.readInt();
215 bool HasInit = Record.readInt();
216
David L. Jonesb6a8f022016-12-21 04:34:52 +0000217 S->setCond(Record.readSubExpr());
218 S->setThen(Record.readSubStmt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000219 if (HasElse)
220 S->setElse(Record.readSubStmt());
221 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500222 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000223 if (HasInit)
224 S->setInit(Record.readSubStmt());
225
John McCall3ce3d232019-12-13 03:37:23 -0500226 S->setIfLoc(readSourceLocation());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000227 if (HasElse)
John McCall3ce3d232019-12-13 03:37:23 -0500228 S->setElseLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000229}
230
Sebastian Redl70c751d2010-08-18 23:56:52 +0000231void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000232 VisitStmt(S);
Bruno Riccie2806f82018-10-29 16:12:37 +0000233
234 bool HasInit = Record.readInt();
235 bool HasVar = Record.readInt();
236 bool AllEnumCasesCovered = Record.readInt();
237 if (AllEnumCasesCovered)
238 S->setAllEnumCasesCovered();
239
David L. Jonesb6a8f022016-12-21 04:34:52 +0000240 S->setCond(Record.readSubExpr());
241 S->setBody(Record.readSubStmt());
Bruno Riccie2806f82018-10-29 16:12:37 +0000242 if (HasInit)
243 S->setInit(Record.readSubStmt());
244 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500245 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccie2806f82018-10-29 16:12:37 +0000246
John McCall3ce3d232019-12-13 03:37:23 -0500247 S->setSwitchLoc(readSourceLocation());
Ted Kremenekc42f3452010-09-09 00:05:53 +0000248
Craig Toppera13603a2014-05-22 05:54:18 +0000249 SwitchCase *PrevSC = nullptr;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000250 for (auto E = Record.size(); Record.getIdx() != E; ) {
251 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000252 if (PrevSC)
253 PrevSC->setNextSwitchCase(SC);
254 else
255 S->setSwitchCaseList(SC);
Mike Stump11289f42009-09-09 15:08:12 +0000256
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000257 PrevSC = SC;
258 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000259}
260
Sebastian Redl70c751d2010-08-18 23:56:52 +0000261void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000262 VisitStmt(S);
Bruno Riccibacf7512018-10-30 13:42:41 +0000263
264 bool HasVar = Record.readInt();
Douglas Gregor7fb09192011-07-21 22:35:25 +0000265
David L. Jonesb6a8f022016-12-21 04:34:52 +0000266 S->setCond(Record.readSubExpr());
267 S->setBody(Record.readSubStmt());
Bruno Riccibacf7512018-10-30 13:42:41 +0000268 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500269 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccibacf7512018-10-30 13:42:41 +0000270
John McCall3ce3d232019-12-13 03:37:23 -0500271 S->setWhileLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000272}
273
Sebastian Redl70c751d2010-08-18 23:56:52 +0000274void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000275 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000276 S->setCond(Record.readSubExpr());
277 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500278 S->setDoLoc(readSourceLocation());
279 S->setWhileLoc(readSourceLocation());
280 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000281}
282
Sebastian Redl70c751d2010-08-18 23:56:52 +0000283void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000284 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000285 S->setInit(Record.readSubStmt());
286 S->setCond(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500287 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000288 S->setInc(Record.readSubExpr());
289 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500290 S->setForLoc(readSourceLocation());
291 S->setLParenLoc(readSourceLocation());
292 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000293}
294
Sebastian Redl70c751d2010-08-18 23:56:52 +0000295void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000296 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500297 S->setLabel(readDeclAs<LabelDecl>());
298 S->setGotoLoc(readSourceLocation());
299 S->setLabelLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000300}
301
Sebastian Redl70c751d2010-08-18 23:56:52 +0000302void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000303 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500304 S->setGotoLoc(readSourceLocation());
305 S->setStarLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000306 S->setTarget(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000307}
308
Sebastian Redl70c751d2010-08-18 23:56:52 +0000309void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000310 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500311 S->setContinueLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000312}
313
Sebastian Redl70c751d2010-08-18 23:56:52 +0000314void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000315 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500316 S->setBreakLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000317}
318
Sebastian Redl70c751d2010-08-18 23:56:52 +0000319void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000320 VisitStmt(S);
Bruno Ricci023b1d12018-10-30 14:40:49 +0000321
322 bool HasNRVOCandidate = Record.readInt();
323
David L. Jonesb6a8f022016-12-21 04:34:52 +0000324 S->setRetValue(Record.readSubExpr());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000325 if (HasNRVOCandidate)
John McCall3ce3d232019-12-13 03:37:23 -0500326 S->setNRVOCandidate(readDeclAs<VarDecl>());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000327
John McCall3ce3d232019-12-13 03:37:23 -0500328 S->setReturnLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000329}
330
Sebastian Redl70c751d2010-08-18 23:56:52 +0000331void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000332 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500333 S->setStartLoc(readSourceLocation());
334 S->setEndLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000335
David L. Jonesbe1557a2016-12-21 00:17:49 +0000336 if (Record.size() - Record.getIdx() == 1) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000337 // Single declaration
John McCall3ce3d232019-12-13 03:37:23 -0500338 S->setDeclGroup(DeclGroupRef(readDecl()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000339 } else {
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000340 SmallVector<Decl *, 16> Decls;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000341 int N = Record.size() - Record.getIdx();
342 Decls.reserve(N);
343 for (int I = 0; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500344 Decls.push_back(readDecl());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000345 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
Douglas Gregor038c3382009-05-22 22:45:36 +0000346 Decls.data(),
347 Decls.size())));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000348 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000349}
350
John McCallf413f5e2013-05-03 00:10:13 +0000351void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000352 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000353 S->NumOutputs = Record.readInt();
354 S->NumInputs = Record.readInt();
355 S->NumClobbers = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500356 S->setAsmLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000357 S->setVolatile(Record.readInt());
358 S->setSimple(Record.readInt());
John McCallf413f5e2013-05-03 00:10:13 +0000359}
Mike Stump11289f42009-09-09 15:08:12 +0000360
John McCallf413f5e2013-05-03 00:10:13 +0000361void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
362 VisitAsmStmt(S);
Jennifer Yub8fee672019-06-03 15:57:25 +0000363 S->NumLabels = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500364 S->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000365 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000366
John McCallf413f5e2013-05-03 00:10:13 +0000367 unsigned NumOutputs = S->getNumOutputs();
368 unsigned NumInputs = S->getNumInputs();
369 unsigned NumClobbers = S->getNumClobbers();
Jennifer Yub8fee672019-06-03 15:57:25 +0000370 unsigned NumLabels = S->getNumLabels();
John McCallf413f5e2013-05-03 00:10:13 +0000371
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000372 // Outputs and inputs
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000373 SmallVector<IdentifierInfo *, 16> Names;
374 SmallVector<StringLiteral*, 16> Constraints;
375 SmallVector<Stmt*, 16> Exprs;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000376 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -0500377 Names.push_back(Record.readIdentifier());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000378 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
379 Exprs.push_back(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000380 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000381
382 // Constraints
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000383 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000384 for (unsigned I = 0; I != NumClobbers; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000385 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000386
Jennifer Yub8fee672019-06-03 15:57:25 +0000387 // Labels
388 for (unsigned I = 0, N = NumLabels; I != N; ++I)
389 Exprs.push_back(Record.readSubStmt());
390
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000391 S->setOutputsAndInputsAndClobbers(Record.getContext(),
392 Names.data(), Constraints.data(),
393 Exprs.data(), NumOutputs, NumInputs,
Jennifer Yub8fee672019-06-03 15:57:25 +0000394 NumLabels,
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000395 Clobbers.data(), NumClobbers);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000396}
397
Chad Rosier32503022012-06-11 20:47:18 +0000398void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
John McCallf413f5e2013-05-03 00:10:13 +0000399 VisitAsmStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500400 S->LBraceLoc = readSourceLocation();
401 S->EndLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000402 S->NumAsmToks = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500403 std::string AsmStr = readString();
John McCallf413f5e2013-05-03 00:10:13 +0000404
405 // Read the tokens.
406 SmallVector<Token, 16> AsmToks;
407 AsmToks.reserve(S->NumAsmToks);
408 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000409 AsmToks.push_back(Record.readToken());
John McCallf413f5e2013-05-03 00:10:13 +0000410 }
411
412 // The calls to reserve() for the FooData vectors are mandatory to
413 // prevent dead StringRefs in the Foo vectors.
414
415 // Read the clobbers.
416 SmallVector<std::string, 16> ClobbersData;
417 SmallVector<StringRef, 16> Clobbers;
418 ClobbersData.reserve(S->NumClobbers);
419 Clobbers.reserve(S->NumClobbers);
420 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
John McCall3ce3d232019-12-13 03:37:23 -0500421 ClobbersData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000422 Clobbers.push_back(ClobbersData.back());
423 }
424
425 // Read the operands.
426 unsigned NumOperands = S->NumOutputs + S->NumInputs;
427 SmallVector<Expr*, 16> Exprs;
428 SmallVector<std::string, 16> ConstraintsData;
429 SmallVector<StringRef, 16> Constraints;
430 Exprs.reserve(NumOperands);
431 ConstraintsData.reserve(NumOperands);
432 Constraints.reserve(NumOperands);
433 for (unsigned i = 0; i != NumOperands; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000434 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -0500435 ConstraintsData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000436 Constraints.push_back(ConstraintsData.back());
437 }
438
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000439 S->initialize(Record.getContext(), AsmStr, AsmToks,
John McCallf413f5e2013-05-03 00:10:13 +0000440 Constraints, Exprs, Clobbers);
Chad Rosier32503022012-06-11 20:47:18 +0000441}
442
Richard Smith9f690bd2015-10-27 06:02:45 +0000443void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000444 VisitStmt(S);
445 assert(Record.peekInt() == S->NumParams);
446 Record.skipInts(1);
447 auto *StoredStmts = S->getStoredStmts();
448 for (unsigned i = 0;
449 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
450 StoredStmts[i] = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000451}
452
453void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000454 VisitStmt(S);
455 S->CoreturnLoc = Record.readSourceLocation();
456 for (auto &SubStmt: S->SubStmts)
457 SubStmt = Record.readSubStmt();
458 S->IsImplicit = Record.readInt() != 0;
Richard Smith9f690bd2015-10-27 06:02:45 +0000459}
460
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000461void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
462 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500463 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000464 for (auto &SubExpr: E->SubExprs)
465 SubExpr = Record.readSubStmt();
466 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
467 E->setIsImplicit(Record.readInt() != 0);
Richard Smith9f690bd2015-10-27 06:02:45 +0000468}
469
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000470void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
471 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500472 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000473 for (auto &SubExpr: E->SubExprs)
474 SubExpr = Record.readSubStmt();
475 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
Eric Fiselier20f25cb2017-03-06 23:38:15 +0000476}
477
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000478void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
479 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500480 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000481 for (auto &SubExpr: E->SubExprs)
482 SubExpr = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000483}
484
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000485void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
Ben Langmuirce914fc2013-05-03 19:20:19 +0000486 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000487 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500488 S->setCapturedDecl(readDeclAs<CapturedDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000489 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500490 S->setCapturedRecordDecl(readDeclAs<RecordDecl>());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000491
492 // Capture inits
493 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
494 E = S->capture_init_end();
495 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000496 *I = Record.readSubExpr();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000497
498 // Body
David L. Jonesb6a8f022016-12-21 04:34:52 +0000499 S->setCapturedStmt(Record.readSubStmt());
Wei Pan17fbf6e2013-05-04 03:59:06 +0000500 S->getCapturedDecl()->setBody(S->getCapturedStmt());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000501
502 // Captures
Aaron Ballmanc656303a2014-03-14 18:08:33 +0000503 for (auto &I : S->captures()) {
John McCall3ce3d232019-12-13 03:37:23 -0500504 I.VarAndKind.setPointer(readDeclAs<VarDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000505 I.VarAndKind.setInt(
506 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500507 I.Loc = readSourceLocation();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000508 }
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000509}
510
Sebastian Redl70c751d2010-08-18 23:56:52 +0000511void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000512 VisitStmt(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000513 E->setType(Record.readType());
514 E->setTypeDependent(Record.readInt());
515 E->setValueDependent(Record.readInt());
516 E->setInstantiationDependent(Record.readInt());
517 E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
518 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
519 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
520 assert(Record.getIdx() == NumExprFields &&
521 "Incorrect expression field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000522}
523
Bill Wendling7c44da22018-10-31 03:48:47 +0000524void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
525 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000526 E->ConstantExprBits.ResultKind = Record.readInt();
527 switch (E->ConstantExprBits.ResultKind) {
528 case ConstantExpr::RSK_Int64: {
529 E->Int64Result() = Record.readInt();
530 uint64_t tmp = Record.readInt();
531 E->ConstantExprBits.IsUnsigned = tmp & 0x1;
532 E->ConstantExprBits.BitWidth = tmp >> 1;
533 break;
534 }
535 case ConstantExpr::RSK_APValue:
536 E->APValueResult() = Record.readAPValue();
537 }
Bill Wendling7c44da22018-10-31 03:48:47 +0000538 E->setSubExpr(Record.readSubExpr());
539}
540
Sebastian Redl70c751d2010-08-18 23:56:52 +0000541void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000542 VisitExpr(E);
Bruno Ricci17ff0262018-10-27 19:21:19 +0000543 bool HasFunctionName = Record.readInt();
544 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
545 E->PredefinedExprBits.Kind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500546 E->setLocation(readSourceLocation());
Bruno Ricci17ff0262018-10-27 19:21:19 +0000547 if (HasFunctionName)
548 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000549}
550
Sebastian Redl70c751d2010-08-18 23:56:52 +0000551void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000552 VisitExpr(E);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000553
David L. Jonesbe1557a2016-12-21 00:17:49 +0000554 E->DeclRefExprBits.HasQualifier = Record.readInt();
555 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
556 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
557 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
558 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
Richard Smith715f7a12019-06-11 17:50:32 +0000559 E->DeclRefExprBits.NonOdrUseReason = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000560 unsigned NumTemplateArgs = 0;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000561 if (E->hasTemplateKWAndArgsInfo())
David L. Jonesbe1557a2016-12-21 00:17:49 +0000562 NumTemplateArgs = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000563
Chandler Carruth0e439962011-05-01 21:29:53 +0000564 if (E->hasQualifier())
James Y Knighte7d82282015-12-29 18:15:14 +0000565 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
David L. Jonesb6a8f022016-12-21 04:34:52 +0000566 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000567
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000568 if (E->hasFoundDecl())
John McCall3ce3d232019-12-13 03:37:23 -0500569 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000570
Abramo Bagnara7945c982012-01-27 09:46:47 +0000571 if (E->hasTemplateKWAndArgsInfo())
James Y Knighte7d82282015-12-29 18:15:14 +0000572 ReadTemplateKWAndArgsInfo(
573 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
574 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000575
John McCall3ce3d232019-12-13 03:37:23 -0500576 E->setDecl(readDeclAs<ValueDecl>());
577 E->setLocation(readSourceLocation());
578 E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000579}
580
Sebastian Redl70c751d2010-08-18 23:56:52 +0000581void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000582 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500583 E->setLocation(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000584 E->setValue(Record.getContext(), Record.readAPInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000585}
586
Leonard Chandb01c3a2018-06-20 17:19:40 +0000587void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
588 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500589 E->setLocation(readSourceLocation());
Leonard Chandb01c3a2018-06-20 17:19:40 +0000590 E->setValue(Record.getContext(), Record.readAPInt());
591}
592
Sebastian Redl70c751d2010-08-18 23:56:52 +0000593void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000594 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000595 E->setRawSemantics(
596 static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
David L. Jonesbe1557a2016-12-21 00:17:49 +0000597 E->setExact(Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000598 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
John McCall3ce3d232019-12-13 03:37:23 -0500599 E->setLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000600}
601
Sebastian Redl70c751d2010-08-18 23:56:52 +0000602void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000603 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000604 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000605}
606
Sebastian Redl70c751d2010-08-18 23:56:52 +0000607void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000608 VisitExpr(E);
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000609
610 // NumConcatenated, Length and CharByteWidth are set by the empty
611 // ctor since they are needed to allocate storage for the trailing objects.
612 unsigned NumConcatenated = Record.readInt();
613 unsigned Length = Record.readInt();
614 unsigned CharByteWidth = Record.readInt();
615 assert((NumConcatenated == E->getNumConcatenated()) &&
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000616 "Wrong number of concatenated tokens!");
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000617 assert((Length == E->getLength()) && "Wrong Length!");
618 assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
619 E->StringLiteralBits.Kind = Record.readInt();
620 E->StringLiteralBits.IsPascal = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000621
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000622 // The character width is originally computed via mapCharByteWidth.
623 // Check that the deserialized character width is consistant with the result
624 // of calling mapCharByteWidth.
625 assert((CharByteWidth ==
626 StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
627 E->getKind())) &&
628 "Wrong character width!");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000629
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000630 // Deserialize the trailing array of SourceLocation.
631 for (unsigned I = 0; I < NumConcatenated; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500632 E->setStrTokenLoc(I, readSourceLocation());
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000633
634 // Deserialize the trailing array of char holding the string data.
635 char *StrData = E->getStrDataAsChar();
636 for (unsigned I = 0; I < Length * CharByteWidth; ++I)
637 StrData[I] = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000638}
639
Sebastian Redl70c751d2010-08-18 23:56:52 +0000640void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000641 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000642 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500643 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000644 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000645}
646
Sebastian Redl70c751d2010-08-18 23:56:52 +0000647void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000648 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500649 E->setLParen(readSourceLocation());
650 E->setRParen(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000651 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000652}
653
Sebastian Redl70c751d2010-08-18 23:56:52 +0000654void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000655 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000656 unsigned NumExprs = Record.readInt();
Bruno Riccif49e1ca2018-11-20 16:20:40 +0000657 assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
658 for (unsigned I = 0; I != NumExprs; ++I)
659 E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500660 E->LParenLoc = readSourceLocation();
661 E->RParenLoc = readSourceLocation();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000662}
663
Sebastian Redl70c751d2010-08-18 23:56:52 +0000664void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000665 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000666 E->setSubExpr(Record.readSubExpr());
667 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500668 E->setOperatorLoc(readSourceLocation());
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000669 E->setCanOverflow(Record.readInt());
670}
671
672void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000673 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000674 assert(E->getNumComponents() == Record.peekInt());
675 Record.skipInts(1);
676 assert(E->getNumExpressions() == Record.peekInt());
677 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500678 E->setOperatorLoc(readSourceLocation());
679 E->setRParenLoc(readSourceLocation());
680 E->setTypeSourceInfo(readTypeSourceInfo());
Douglas Gregor882211c2010-04-28 22:16:22 +0000681 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000682 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500683 SourceLocation Start = readSourceLocation();
684 SourceLocation End = readSourceLocation();
Douglas Gregor882211c2010-04-28 22:16:22 +0000685 switch (Kind) {
James Y Knight7281c352015-12-29 22:31:18 +0000686 case OffsetOfNode::Array:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000687 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000688 break;
689
James Y Knight7281c352015-12-29 22:31:18 +0000690 case OffsetOfNode::Field:
691 E->setComponent(
John McCall3ce3d232019-12-13 03:37:23 -0500692 I, OffsetOfNode(Start, readDeclAs<FieldDecl>(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000693 break;
James Y Knight7281c352015-12-29 22:31:18 +0000694
695 case OffsetOfNode::Identifier:
696 E->setComponent(
697 I,
John McCall3ce3d232019-12-13 03:37:23 -0500698 OffsetOfNode(Start, Record.readIdentifier(), End));
James Y Knight7281c352015-12-29 22:31:18 +0000699 break;
700
701 case OffsetOfNode::Base: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000702 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000703 *Base = Record.readCXXBaseSpecifier();
James Y Knight7281c352015-12-29 22:31:18 +0000704 E->setComponent(I, OffsetOfNode(Base));
Douglas Gregord1702062010-04-29 00:18:15 +0000705 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000706 }
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000707 }
Douglas Gregor882211c2010-04-28 22:16:22 +0000708 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000709
Douglas Gregor882211c2010-04-28 22:16:22 +0000710 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000711 E->setIndexExpr(I, Record.readSubExpr());
Douglas Gregor882211c2010-04-28 22:16:22 +0000712}
713
Peter Collingbournee190dee2011-03-11 19:24:49 +0000714void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000715 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000716 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
717 if (Record.peekInt() == 0) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000718 E->setArgument(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000719 Record.skipInts(1);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000720 } else {
John McCall3ce3d232019-12-13 03:37:23 -0500721 E->setArgument(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000722 }
John McCall3ce3d232019-12-13 03:37:23 -0500723 E->setOperatorLoc(readSourceLocation());
724 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000725}
726
Saar Raza0f50d72020-01-18 09:11:43 +0200727static ConstraintSatisfaction
728readConstraintSatisfaction(ASTRecordReader &Record) {
729 ConstraintSatisfaction Satisfaction;
730 Satisfaction.IsSatisfied = Record.readInt();
731 if (!Satisfaction.IsSatisfied) {
732 unsigned NumDetailRecords = Record.readInt();
733 for (unsigned i = 0; i != NumDetailRecords; ++i) {
734 Expr *ConstraintExpr = Record.readExpr();
735 if (bool IsDiagnostic = Record.readInt()) {
736 SourceLocation DiagLocation = Record.readSourceLocation();
737 std::string DiagMessage = Record.readString();
738 Satisfaction.Details.emplace_back(
739 ConstraintExpr, new (Record.getContext())
740 ConstraintSatisfaction::SubstitutionDiagnostic{
741 DiagLocation, DiagMessage});
742 } else
743 Satisfaction.Details.emplace_back(ConstraintExpr, Record.readExpr());
744 }
745 }
746 return Satisfaction;
747}
748
Saar Raz5d98ba62019-10-15 15:24:26 +0000749void ASTStmtReader::VisitConceptSpecializationExpr(
750 ConceptSpecializationExpr *E) {
751 VisitExpr(E);
752 unsigned NumTemplateArgs = Record.readInt();
753 E->NestedNameSpec = Record.readNestedNameSpecifierLoc();
754 E->TemplateKWLoc = Record.readSourceLocation();
Saar Razff1e0fc2020-01-15 02:48:42 +0200755 E->ConceptName = Record.readDeclarationNameInfo();
John McCall3ce3d232019-12-13 03:37:23 -0500756 E->NamedConcept = readDeclAs<ConceptDecl>();
Saar Razff1e0fc2020-01-15 02:48:42 +0200757 E->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
Saar Raz5d98ba62019-10-15 15:24:26 +0000758 llvm::SmallVector<TemplateArgument, 4> Args;
759 for (unsigned I = 0; I < NumTemplateArgs; ++I)
760 Args.push_back(Record.readTemplateArgument());
Saar Razff1e0fc2020-01-15 02:48:42 +0200761 E->setTemplateArguments(Args);
Saar Raza0f50d72020-01-18 09:11:43 +0200762 E->Satisfaction = E->isValueDependent() ? nullptr :
763 ASTConstraintSatisfaction::Create(Record.getContext(),
764 readConstraintSatisfaction(Record));
765}
766
767static concepts::Requirement::SubstitutionDiagnostic *
768readSubstitutionDiagnostic(ASTRecordReader &Record) {
769 std::string SubstitutedEntity = Record.readString();
770 SourceLocation DiagLoc = Record.readSourceLocation();
771 std::string DiagMessage = Record.readString();
772 return new (Record.getContext())
773 concepts::Requirement::SubstitutionDiagnostic{SubstitutedEntity, DiagLoc,
774 DiagMessage};
775}
776
777void ASTStmtReader::VisitRequiresExpr(RequiresExpr *E) {
778 VisitExpr(E);
779 unsigned NumLocalParameters = Record.readInt();
780 unsigned NumRequirements = Record.readInt();
781 E->RequiresExprBits.RequiresKWLoc = Record.readSourceLocation();
782 E->RequiresExprBits.IsSatisfied = Record.readInt();
783 E->Body = Record.readDeclAs<RequiresExprBodyDecl>();
784 llvm::SmallVector<ParmVarDecl *, 4> LocalParameters;
785 for (unsigned i = 0; i < NumLocalParameters; ++i)
786 LocalParameters.push_back(cast<ParmVarDecl>(Record.readDecl()));
787 std::copy(LocalParameters.begin(), LocalParameters.end(),
788 E->getTrailingObjects<ParmVarDecl *>());
789 llvm::SmallVector<concepts::Requirement *, 4> Requirements;
790 for (unsigned i = 0; i < NumRequirements; ++i) {
791 auto RK =
792 static_cast<concepts::Requirement::RequirementKind>(Record.readInt());
793 concepts::Requirement *R = nullptr;
794 switch (RK) {
795 case concepts::Requirement::RK_Type: {
796 auto Status =
797 static_cast<concepts::TypeRequirement::SatisfactionStatus>(
798 Record.readInt());
799 if (Status == concepts::TypeRequirement::SS_SubstitutionFailure)
800 R = new (Record.getContext())
801 concepts::TypeRequirement(readSubstitutionDiagnostic(Record));
802 else
803 R = new (Record.getContext())
804 concepts::TypeRequirement(Record.readTypeSourceInfo());
805 } break;
806 case concepts::Requirement::RK_Simple:
807 case concepts::Requirement::RK_Compound: {
808 auto Status =
809 static_cast<concepts::ExprRequirement::SatisfactionStatus>(
810 Record.readInt());
811 llvm::PointerUnion<concepts::Requirement::SubstitutionDiagnostic *,
812 Expr *> E;
813 if (Status == concepts::ExprRequirement::SS_ExprSubstitutionFailure) {
814 E = readSubstitutionDiagnostic(Record);
815 } else
816 E = Record.readExpr();
817
818 llvm::Optional<concepts::ExprRequirement::ReturnTypeRequirement> Req;
819 ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr;
820 SourceLocation NoexceptLoc;
821 if (RK == concepts::Requirement::RK_Simple) {
822 Req.emplace();
823 } else {
824 NoexceptLoc = Record.readSourceLocation();
825 switch (auto returnTypeRequirementKind = Record.readInt()) {
826 case 0:
827 // No return type requirement.
828 Req.emplace();
829 break;
830 case 1: {
831 // type-constraint
832 TemplateParameterList *TPL = Record.readTemplateParameterList();
833 if (Status >=
834 concepts::ExprRequirement::SS_ConstraintsNotSatisfied)
835 SubstitutedConstraintExpr =
836 cast<ConceptSpecializationExpr>(Record.readExpr());
837 Req.emplace(TPL);
838 } break;
839 case 2:
840 // Substitution failure
841 Req.emplace(readSubstitutionDiagnostic(Record));
842 break;
843 }
844 }
845 if (Expr *Ex = E.dyn_cast<Expr *>())
846 R = new (Record.getContext()) concepts::ExprRequirement(
847 Ex, RK == concepts::Requirement::RK_Simple, NoexceptLoc,
848 std::move(*Req), Status, SubstitutedConstraintExpr);
849 else
850 R = new (Record.getContext()) concepts::ExprRequirement(
851 E.get<concepts::Requirement::SubstitutionDiagnostic *>(),
852 RK == concepts::Requirement::RK_Simple, NoexceptLoc,
853 std::move(*Req));
854 } break;
855 case concepts::Requirement::RK_Nested: {
856 if (bool IsSubstitutionDiagnostic = Record.readInt()) {
857 R = new (Record.getContext()) concepts::NestedRequirement(
858 readSubstitutionDiagnostic(Record));
859 break;
860 }
861 Expr *E = Record.readExpr();
862 if (E->isInstantiationDependent())
863 R = new (Record.getContext()) concepts::NestedRequirement(E);
864 else
865 R = new (Record.getContext())
866 concepts::NestedRequirement(Record.getContext(), E,
867 readConstraintSatisfaction(Record));
868 } break;
Saar Razfdf80e82019-12-06 01:30:21 +0200869 }
Saar Raza0f50d72020-01-18 09:11:43 +0200870 if (!R)
871 continue;
872 Requirements.push_back(R);
Saar Razfdf80e82019-12-06 01:30:21 +0200873 }
Saar Raza0f50d72020-01-18 09:11:43 +0200874 std::copy(Requirements.begin(), Requirements.end(),
875 E->getTrailingObjects<concepts::Requirement *>());
876 E->RBraceLoc = Record.readSourceLocation();
Saar Raz5d98ba62019-10-15 15:24:26 +0000877}
878
Sebastian Redl70c751d2010-08-18 23:56:52 +0000879void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000880 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000881 E->setLHS(Record.readSubExpr());
882 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500883 E->setRBracketLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000884}
885
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000886void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
887 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000888 E->setBase(Record.readSubExpr());
889 E->setLowerBound(Record.readSubExpr());
890 E->setLength(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500891 E->setColonLoc(readSourceLocation());
892 E->setRBracketLoc(readSourceLocation());
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000893}
894
Sebastian Redl70c751d2010-08-18 23:56:52 +0000895void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000896 VisitExpr(E);
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000897 unsigned NumArgs = Record.readInt();
898 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
John McCall3ce3d232019-12-13 03:37:23 -0500899 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000900 E->setCallee(Record.readSubExpr());
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000901 for (unsigned I = 0; I != NumArgs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000902 E->setArg(I, Record.readSubExpr());
Eric Fiselier5cdc2cd2018-12-12 21:50:55 +0000903 E->setADLCallKind(static_cast<CallExpr::ADLCallKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000904}
905
John McCallfa194042011-07-15 07:00:14 +0000906void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
907 VisitCallExpr(E);
908}
909
Sebastian Redl70c751d2010-08-18 23:56:52 +0000910void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Richard Smithdcf17de2019-06-06 23:24:15 +0000911 VisitExpr(E);
912
913 bool HasQualifier = Record.readInt();
914 bool HasFoundDecl = Record.readInt();
915 bool HasTemplateInfo = Record.readInt();
916 unsigned NumTemplateArgs = Record.readInt();
917
918 E->Base = Record.readSubExpr();
919 E->MemberDecl = Record.readDeclAs<ValueDecl>();
John McCall3ce3d232019-12-13 03:37:23 -0500920 E->MemberDNLoc = Record.readDeclarationNameLoc(E->MemberDecl->getDeclName());
Richard Smithdcf17de2019-06-06 23:24:15 +0000921 E->MemberLoc = Record.readSourceLocation();
922 E->MemberExprBits.IsArrow = Record.readInt();
923 E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
924 E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
925 E->MemberExprBits.HadMultipleCandidates = Record.readInt();
Richard Smith1bbad592019-06-11 17:50:36 +0000926 E->MemberExprBits.NonOdrUseReason = Record.readInt();
Richard Smithdcf17de2019-06-06 23:24:15 +0000927 E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
928
929 if (HasQualifier || HasFoundDecl) {
930 DeclAccessPair FoundDecl;
931 if (HasFoundDecl) {
932 auto *FoundD = Record.readDeclAs<NamedDecl>();
933 auto AS = (AccessSpecifier)Record.readInt();
934 FoundDecl = DeclAccessPair::make(FoundD, AS);
935 } else {
936 FoundDecl = DeclAccessPair::make(E->MemberDecl,
937 E->MemberDecl->getAccess());
938 }
939 E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
940
941 NestedNameSpecifierLoc QualifierLoc;
942 if (HasQualifier)
943 QualifierLoc = Record.readNestedNameSpecifierLoc();
944 E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
945 QualifierLoc;
946 }
947
948 if (HasTemplateInfo)
949 ReadTemplateKWAndArgsInfo(
950 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
951 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000952}
953
Sebastian Redl70c751d2010-08-18 23:56:52 +0000954void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Naroffe87026a2009-07-24 17:54:45 +0000955 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000956 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500957 E->setIsaMemberLoc(readSourceLocation());
958 E->setOpLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000959 E->setArrow(Record.readInt());
Steve Naroffe87026a2009-07-24 17:54:45 +0000960}
961
John McCall31168b02011-06-15 23:02:42 +0000962void ASTStmtReader::
963VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
964 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000965 E->Operand = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000966 E->setShouldCopy(Record.readInt());
John McCall31168b02011-06-15 23:02:42 +0000967}
968
969void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
970 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500971 E->LParenLoc = readSourceLocation();
972 E->BridgeKeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000973 E->Kind = Record.readInt();
John McCall31168b02011-06-15 23:02:42 +0000974}
975
Sebastian Redl70c751d2010-08-18 23:56:52 +0000976void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000977 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000978 unsigned NumBaseSpecs = Record.readInt();
John McCallcf142162010-08-07 06:22:56 +0000979 assert(NumBaseSpecs == E->path_size());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000980 E->setSubExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000981 E->setCastKind((CastKind)Record.readInt());
John McCallcf142162010-08-07 06:22:56 +0000982 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000983 while (NumBaseSpecs--) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000984 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000985 *BaseSpec = Record.readCXXBaseSpecifier();
John McCallcf142162010-08-07 06:22:56 +0000986 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000987 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000988}
989
Sebastian Redl70c751d2010-08-18 23:56:52 +0000990void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000991 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000992 E->setLHS(Record.readSubExpr());
993 E->setRHS(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000994 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500995 E->setOperatorLoc(readSourceLocation());
Adam Nemet484aa452017-03-27 19:17:25 +0000996 E->setFPFeatures(FPOptions(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000997}
998
Sebastian Redl70c751d2010-08-18 23:56:52 +0000999void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001000 VisitBinaryOperator(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001001 E->setComputationLHSType(Record.readType());
1002 E->setComputationResultType(Record.readType());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001003}
1004
Sebastian Redl70c751d2010-08-18 23:56:52 +00001005void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001006 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001007 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
1008 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
1009 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001010 E->QuestionLoc = readSourceLocation();
1011 E->ColonLoc = readSourceLocation();
John McCallc07a0c72011-02-17 10:25:35 +00001012}
1013
1014void
1015ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
1016 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001017 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
1018 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
1019 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
1020 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
1021 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001022 E->QuestionLoc = readSourceLocation();
1023 E->ColonLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001024}
1025
Sebastian Redl70c751d2010-08-18 23:56:52 +00001026void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001027 VisitCastExpr(E);
Roman Lebedev12216f12018-07-27 07:27:14 +00001028 E->setIsPartOfExplicitCast(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001029}
1030
Sebastian Redl70c751d2010-08-18 23:56:52 +00001031void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001032 VisitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001033 E->setTypeInfoAsWritten(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001034}
1035
Sebastian Redl70c751d2010-08-18 23:56:52 +00001036void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001037 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001038 E->setLParenLoc(readSourceLocation());
1039 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001040}
1041
Sebastian Redl70c751d2010-08-18 23:56:52 +00001042void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001043 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001044 E->setLParenLoc(readSourceLocation());
1045 E->setTypeSourceInfo(readTypeSourceInfo());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001046 E->setInitializer(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001047 E->setFileScope(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001048}
1049
Sebastian Redl70c751d2010-08-18 23:56:52 +00001050void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001051 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001052 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001053 E->setAccessor(Record.readIdentifier());
1054 E->setAccessorLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001055}
1056
Sebastian Redl70c751d2010-08-18 23:56:52 +00001057void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001058 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001059 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
Abramo Bagnara8d16bd42012-11-08 18:41:43 +00001060 E->setSyntacticForm(SyntForm);
John McCall3ce3d232019-12-13 03:37:23 -05001061 E->setLBraceLoc(readSourceLocation());
1062 E->setRBraceLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001063 bool isArrayFiller = Record.readInt();
Craig Toppera13603a2014-05-22 05:54:18 +00001064 Expr *filler = nullptr;
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001065 if (isArrayFiller) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001066 filler = Record.readSubExpr();
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001067 E->ArrayFillerOrUnionFieldInit = filler;
1068 } else
John McCall3ce3d232019-12-13 03:37:23 -05001069 E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001070 E->sawArrayRangeDesignator(Record.readInt());
1071 unsigned NumInits = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001072 E->reserveInits(Record.getContext(), NumInits);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001073 if (isArrayFiller) {
1074 for (unsigned I = 0; I != NumInits; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001075 Expr *init = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001076 E->updateInit(Record.getContext(), I, init ? init : filler);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001077 }
1078 } else {
1079 for (unsigned I = 0; I != NumInits; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001080 E->updateInit(Record.getContext(), I, Record.readSubExpr());
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +00001081 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001082}
1083
Sebastian Redl70c751d2010-08-18 23:56:52 +00001084void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001085 using Designator = DesignatedInitExpr::Designator;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001086
1087 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001088 unsigned NumSubExprs = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001089 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
1090 for (unsigned I = 0; I != NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001091 E->setSubExpr(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001092 E->setEqualOrColonLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001093 E->setGNUSyntax(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001094
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001095 SmallVector<Designator, 4> Designators;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001096 while (Record.getIdx() < Record.size()) {
1097 switch ((DesignatorTypes)Record.readInt()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00001098 case DESIG_FIELD_DECL: {
John McCall3ce3d232019-12-13 03:37:23 -05001099 auto *Field = readDeclAs<FieldDecl>();
1100 SourceLocation DotLoc = readSourceLocation();
1101 SourceLocation FieldLoc = readSourceLocation();
Mike Stump11289f42009-09-09 15:08:12 +00001102 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001103 FieldLoc));
1104 Designators.back().setField(Field);
1105 break;
1106 }
1107
Sebastian Redl539c5062010-08-18 23:57:32 +00001108 case DESIG_FIELD_NAME: {
John McCall3ce3d232019-12-13 03:37:23 -05001109 const IdentifierInfo *Name = Record.readIdentifier();
1110 SourceLocation DotLoc = readSourceLocation();
1111 SourceLocation FieldLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001112 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
1113 break;
1114 }
Mike Stump11289f42009-09-09 15:08:12 +00001115
Sebastian Redl539c5062010-08-18 23:57:32 +00001116 case DESIG_ARRAY: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001117 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001118 SourceLocation LBracketLoc = readSourceLocation();
1119 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001120 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
1121 break;
1122 }
1123
Sebastian Redl539c5062010-08-18 23:57:32 +00001124 case DESIG_ARRAY_RANGE: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001125 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001126 SourceLocation LBracketLoc = readSourceLocation();
1127 SourceLocation EllipsisLoc = readSourceLocation();
1128 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001129 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
1130 RBracketLoc));
1131 break;
1132 }
1133 }
1134 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001135 E->setDesignators(Record.getContext(),
Douglas Gregor03e8bdc2010-01-06 23:17:19 +00001136 Designators.data(), Designators.size());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001137}
1138
Yunzhong Gaocb779302015-06-10 00:27:52 +00001139void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1140 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001141 E->setBase(Record.readSubExpr());
1142 E->setUpdater(Record.readSubExpr());
Yunzhong Gaocb779302015-06-10 00:27:52 +00001143}
1144
1145void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1146 VisitExpr(E);
1147}
1148
Richard Smith410306b2016-12-12 02:53:20 +00001149void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1150 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001151 E->SubExprs[0] = Record.readSubExpr();
1152 E->SubExprs[1] = Record.readSubExpr();
Richard Smith410306b2016-12-12 02:53:20 +00001153}
1154
1155void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1156 VisitExpr(E);
1157}
1158
Sebastian Redl70c751d2010-08-18 23:56:52 +00001159void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001160 VisitExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001161}
1162
Sebastian Redl70c751d2010-08-18 23:56:52 +00001163void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001164 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001165 E->setSubExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001166 E->setWrittenTypeInfo(readTypeSourceInfo());
1167 E->setBuiltinLoc(readSourceLocation());
1168 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001169 E->setIsMicrosoftABI(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001170}
1171
Eric Fiselier708afb52019-05-16 21:04:15 +00001172void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1173 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001174 E->ParentContext = readDeclAs<DeclContext>();
1175 E->BuiltinLoc = readSourceLocation();
1176 E->RParenLoc = readSourceLocation();
Eric Fiselier708afb52019-05-16 21:04:15 +00001177 E->SourceLocExprBits.Kind =
1178 static_cast<SourceLocExpr::IdentKind>(Record.readInt());
1179}
1180
Sebastian Redl70c751d2010-08-18 23:56:52 +00001181void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001182 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001183 E->setAmpAmpLoc(readSourceLocation());
1184 E->setLabelLoc(readSourceLocation());
1185 E->setLabel(readDeclAs<LabelDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001186}
1187
Sebastian Redl70c751d2010-08-18 23:56:52 +00001188void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001189 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001190 E->setLParenLoc(readSourceLocation());
1191 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001192 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001193}
1194
Sebastian Redl70c751d2010-08-18 23:56:52 +00001195void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001196 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001197 E->setCond(Record.readSubExpr());
1198 E->setLHS(Record.readSubExpr());
1199 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001200 E->setBuiltinLoc(readSourceLocation());
1201 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001202 E->setIsConditionTrue(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001203}
1204
Sebastian Redl70c751d2010-08-18 23:56:52 +00001205void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001206 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001207 E->setTokenLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001208}
1209
Sebastian Redl70c751d2010-08-18 23:56:52 +00001210void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001211 VisitExpr(E);
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001212 SmallVector<Expr *, 16> Exprs;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001213 unsigned NumExprs = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001214 while (NumExprs--)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001215 Exprs.push_back(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001216 E->setExprs(Record.getContext(), Exprs);
John McCall3ce3d232019-12-13 03:37:23 -05001217 E->setBuiltinLoc(readSourceLocation());
1218 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001219}
1220
Hal Finkelc4d7c822013-09-18 03:29:45 +00001221void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1222 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001223 E->BuiltinLoc = readSourceLocation();
1224 E->RParenLoc = readSourceLocation();
1225 E->TInfo = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001226 E->SrcExpr = Record.readSubExpr();
Hal Finkelc4d7c822013-09-18 03:29:45 +00001227}
1228
Sebastian Redl70c751d2010-08-18 23:56:52 +00001229void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001230 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001231 E->setBlockDecl(readDeclAs<BlockDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001232}
1233
Peter Collingbourne91147592011-04-15 00:35:48 +00001234void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1235 VisitExpr(E);
Bruno Riccidb076832019-01-26 14:15:10 +00001236
1237 unsigned NumAssocs = Record.readInt();
1238 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
Bruno Ricci94498c72019-01-26 13:58:15 +00001239 E->ResultIndex = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001240 E->GenericSelectionExprBits.GenericLoc = readSourceLocation();
1241 E->DefaultLoc = readSourceLocation();
1242 E->RParenLoc = readSourceLocation();
Bruno Riccidb076832019-01-26 14:15:10 +00001243
1244 Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1245 // Add 1 to account for the controlling expression which is the first
1246 // expression in the trailing array of Stmt *. This is not needed for
1247 // the trailing array of TypeSourceInfo *.
1248 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1249 Stmts[I] = Record.readSubExpr();
1250
1251 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1252 for (unsigned I = 0, N = NumAssocs; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001253 TSIs[I] = readTypeSourceInfo();
Peter Collingbourne91147592011-04-15 00:35:48 +00001254}
1255
John McCallfe96e0b2011-11-06 09:01:30 +00001256void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1257 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001258 unsigned numSemanticExprs = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001259 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001260 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001261
1262 // Read the syntactic expression.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001263 E->getSubExprsBuffer()[0] = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001264
1265 // Read all the semantic expressions.
1266 for (unsigned i = 0; i != numSemanticExprs; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001267 Expr *subExpr = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001268 E->getSubExprsBuffer()[i+1] = subExpr;
1269 }
1270}
1271
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001272void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1273 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001274 E->Op = AtomicExpr::AtomicOp(Record.readInt());
Richard Smithaa22a8c2012-04-10 22:49:28 +00001275 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1276 for (unsigned I = 0; I != E->NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001277 E->SubExprs[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001278 E->BuiltinLoc = readSourceLocation();
1279 E->RParenLoc = readSourceLocation();
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001280}
1281
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001282//===----------------------------------------------------------------------===//
1283// Objective-C Expressions and Statements
1284
Sebastian Redl70c751d2010-08-18 23:56:52 +00001285void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001286 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001287 E->setString(cast<StringLiteral>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -05001288 E->setAtLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001289}
1290
Patrick Beard0caa3942012-04-19 00:25:12 +00001291void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001292 VisitExpr(E);
1293 // could be one of several IntegerLiteral, FloatLiteral, etc.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001294 E->SubExpr = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -05001295 E->BoxingMethod = readDeclAs<ObjCMethodDecl>();
1296 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001297}
1298
1299void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1300 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001301 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001302 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1303 Expr **Elements = E->getElements();
1304 for (unsigned I = 0, N = NumElements; I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001305 Elements[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001306 E->ArrayWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1307 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001308}
1309
1310void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1311 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001312 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001313 assert(NumElements == E->getNumElements() && "Wrong number of elements");
David L. Jonesbe1557a2016-12-21 00:17:49 +00001314 bool HasPackExpansions = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001315 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001316 auto *KeyValues =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001317 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001318 auto *Expansions =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001319 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001320 for (unsigned I = 0; I != NumElements; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001321 KeyValues[I].Key = Record.readSubExpr();
1322 KeyValues[I].Value = Record.readSubExpr();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001323 if (HasPackExpansions) {
John McCall3ce3d232019-12-13 03:37:23 -05001324 Expansions[I].EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001325 Expansions[I].NumExpansionsPlusOne = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001326 }
1327 }
John McCall3ce3d232019-12-13 03:37:23 -05001328 E->DictWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1329 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001330}
1331
Sebastian Redl70c751d2010-08-18 23:56:52 +00001332void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001333 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001334 E->setEncodedTypeSourceInfo(readTypeSourceInfo());
1335 E->setAtLoc(readSourceLocation());
1336 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001337}
1338
Sebastian Redl70c751d2010-08-18 23:56:52 +00001339void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001340 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001341 E->setSelector(Record.readSelector());
John McCall3ce3d232019-12-13 03:37:23 -05001342 E->setAtLoc(readSourceLocation());
1343 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001344}
1345
Sebastian Redl70c751d2010-08-18 23:56:52 +00001346void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001347 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001348 E->setProtocol(readDeclAs<ObjCProtocolDecl>());
1349 E->setAtLoc(readSourceLocation());
1350 E->ProtoLoc = readSourceLocation();
1351 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001352}
1353
Sebastian Redl70c751d2010-08-18 23:56:52 +00001354void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001355 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001356 E->setDecl(readDeclAs<ObjCIvarDecl>());
1357 E->setLocation(readSourceLocation());
1358 E->setOpLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001359 E->setBase(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001360 E->setIsArrow(Record.readInt());
1361 E->setIsFreeIvar(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001362}
1363
Sebastian Redl70c751d2010-08-18 23:56:52 +00001364void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001365 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001366 unsigned MethodRefFlags = Record.readInt();
1367 bool Implicit = Record.readInt() != 0;
John McCallb7bd14f2010-12-02 01:19:52 +00001368 if (Implicit) {
John McCall3ce3d232019-12-13 03:37:23 -05001369 auto *Getter = readDeclAs<ObjCMethodDecl>();
1370 auto *Setter = readDeclAs<ObjCMethodDecl>();
Argyrios Kyrtzidisab468b02012-03-30 00:19:18 +00001371 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCallb7bd14f2010-12-02 01:19:52 +00001372 } else {
John McCall3ce3d232019-12-13 03:37:23 -05001373 E->setExplicitProperty(readDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001374 }
John McCall3ce3d232019-12-13 03:37:23 -05001375 E->setLocation(readSourceLocation());
1376 E->setReceiverLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001377 switch (Record.readInt()) {
John McCallb7bd14f2010-12-02 01:19:52 +00001378 case 0:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001379 E->setBase(Record.readSubExpr());
John McCallb7bd14f2010-12-02 01:19:52 +00001380 break;
1381 case 1:
David L. Jonesbe1557a2016-12-21 00:17:49 +00001382 E->setSuperReceiver(Record.readType());
John McCallb7bd14f2010-12-02 01:19:52 +00001383 break;
1384 case 2:
John McCall3ce3d232019-12-13 03:37:23 -05001385 E->setClassReceiver(readDeclAs<ObjCInterfaceDecl>());
John McCallb7bd14f2010-12-02 01:19:52 +00001386 break;
1387 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001388}
1389
Ted Kremeneke65b0862012-03-06 20:05:56 +00001390void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1391 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001392 E->setRBracket(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001393 E->setBaseExpr(Record.readSubExpr());
1394 E->setKeyExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001395 E->GetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1396 E->SetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001397}
1398
Sebastian Redl70c751d2010-08-18 23:56:52 +00001399void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001400 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001401 assert(Record.peekInt() == E->getNumArgs());
1402 Record.skipInts(1);
1403 unsigned NumStoredSelLocs = Record.readInt();
1404 E->SelLocsKind = Record.readInt();
1405 E->setDelegateInitCall(Record.readInt());
1406 E->IsImplicit = Record.readInt();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001407 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
Douglas Gregor9a129192010-04-21 00:45:42 +00001408 switch (Kind) {
1409 case ObjCMessageExpr::Instance:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001410 E->setInstanceReceiver(Record.readSubExpr());
Douglas Gregor9a129192010-04-21 00:45:42 +00001411 break;
1412
1413 case ObjCMessageExpr::Class:
John McCall3ce3d232019-12-13 03:37:23 -05001414 E->setClassReceiver(readTypeSourceInfo());
Douglas Gregor9a129192010-04-21 00:45:42 +00001415 break;
1416
1417 case ObjCMessageExpr::SuperClass:
1418 case ObjCMessageExpr::SuperInstance: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001419 QualType T = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001420 SourceLocation SuperLoc = readSourceLocation();
Douglas Gregor9a129192010-04-21 00:45:42 +00001421 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1422 break;
1423 }
1424 }
1425
1426 assert(Kind == E->getReceiverKind());
1427
David L. Jonesbe1557a2016-12-21 00:17:49 +00001428 if (Record.readInt())
John McCall3ce3d232019-12-13 03:37:23 -05001429 E->setMethodDecl(readDeclAs<ObjCMethodDecl>());
Douglas Gregor9a129192010-04-21 00:45:42 +00001430 else
David L. Jonesb6a8f022016-12-21 04:34:52 +00001431 E->setSelector(Record.readSelector());
Douglas Gregor9a129192010-04-21 00:45:42 +00001432
John McCall3ce3d232019-12-13 03:37:23 -05001433 E->LBracLoc = readSourceLocation();
1434 E->RBracLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001435
1436 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001437 E->setArg(I, Record.readSubExpr());
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00001438
1439 SourceLocation *Locs = E->getStoredSelLocs();
1440 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001441 Locs[I] = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001442}
1443
Sebastian Redl70c751d2010-08-18 23:56:52 +00001444void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001445 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001446 S->setElement(Record.readSubStmt());
1447 S->setCollection(Record.readSubExpr());
1448 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001449 S->setForLoc(readSourceLocation());
1450 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001451}
1452
Sebastian Redl70c751d2010-08-18 23:56:52 +00001453void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001454 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001455 S->setCatchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001456 S->setCatchParamDecl(readDeclAs<VarDecl>());
1457 S->setAtCatchLoc(readSourceLocation());
1458 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001459}
1460
Sebastian Redl70c751d2010-08-18 23:56:52 +00001461void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001462 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001463 S->setFinallyBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001464 S->setAtFinallyLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001465}
1466
John McCall31168b02011-06-15 23:02:42 +00001467void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001468 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001469 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001470 S->setAtLoc(readSourceLocation());
John McCall31168b02011-06-15 23:02:42 +00001471}
1472
Sebastian Redl70c751d2010-08-18 23:56:52 +00001473void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001474 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001475 assert(Record.peekInt() == S->getNumCatchStmts());
1476 Record.skipInts(1);
1477 bool HasFinally = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001478 S->setTryBody(Record.readSubStmt());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001479 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001480 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
Douglas Gregor96c79492010-04-23 22:50:49 +00001481
Douglas Gregor96c79492010-04-23 22:50:49 +00001482 if (HasFinally)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001483 S->setFinallyStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001484 S->setAtTryLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001485}
1486
Sebastian Redl70c751d2010-08-18 23:56:52 +00001487void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001488 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001489 S->setSynchExpr(Record.readSubStmt());
1490 S->setSynchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001491 S->setAtSynchronizedLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001492}
1493
Sebastian Redl70c751d2010-08-18 23:56:52 +00001494void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001495 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001496 S->setThrowExpr(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001497 S->setThrowLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001498}
1499
Ted Kremeneke65b0862012-03-06 20:05:56 +00001500void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1501 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001502 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001503 E->setLocation(readSourceLocation());
Ted Kremeneke65b0862012-03-06 20:05:56 +00001504}
1505
Erik Pilkington29099de2016-07-16 00:35:23 +00001506void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1507 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001508 SourceRange R = Record.readSourceRange();
Erik Pilkington29099de2016-07-16 00:35:23 +00001509 E->AtLoc = R.getBegin();
1510 E->RParen = R.getEnd();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001511 E->VersionToCheck = Record.readVersionTuple();
Erik Pilkington29099de2016-07-16 00:35:23 +00001512}
1513
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001514//===----------------------------------------------------------------------===//
1515// C++ Expressions and Statements
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001516//===----------------------------------------------------------------------===//
1517
Sebastian Redl70c751d2010-08-18 23:56:52 +00001518void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001519 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001520 S->CatchLoc = readSourceLocation();
1521 S->ExceptionDecl = readDeclAs<VarDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001522 S->HandlerBlock = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001523}
1524
Sebastian Redl70c751d2010-08-18 23:56:52 +00001525void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001526 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001527 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1528 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -05001529 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001530 S->getStmts()[0] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001531 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001532 S->getStmts()[i + 1] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001533}
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001534
Richard Smith02e85f32011-04-14 22:09:26 +00001535void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1536 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001537 S->ForLoc = readSourceLocation();
1538 S->CoawaitLoc = readSourceLocation();
1539 S->ColonLoc = readSourceLocation();
1540 S->RParenLoc = readSourceLocation();
Richard Smith8baa5002018-09-28 18:44:09 +00001541 S->setInit(Record.readSubStmt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001542 S->setRangeStmt(Record.readSubStmt());
1543 S->setBeginStmt(Record.readSubStmt());
1544 S->setEndStmt(Record.readSubStmt());
1545 S->setCond(Record.readSubExpr());
1546 S->setInc(Record.readSubExpr());
1547 S->setLoopVarStmt(Record.readSubStmt());
1548 S->setBody(Record.readSubStmt());
Richard Smith02e85f32011-04-14 22:09:26 +00001549}
1550
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001551void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1552 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001553 S->KeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001554 S->IsIfExists = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001555 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001556 S->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001557 S->SubStmt = Record.readSubStmt();
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001558}
1559
Sebastian Redl70c751d2010-08-18 23:56:52 +00001560void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001561 VisitCallExpr(E);
Bruno Riccifeb19232018-12-21 16:51:57 +00001562 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1563 E->CXXOperatorCallExprBits.FPFeatures = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001564 E->Range = Record.readSourceRange();
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001565}
1566
Richard Smith778dc0f2019-10-19 00:04:38 +00001567void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1568 CXXRewrittenBinaryOperator *E) {
1569 VisitExpr(E);
1570 E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1571 E->SemanticForm = Record.readSubExpr();
1572}
1573
Sebastian Redl70c751d2010-08-18 23:56:52 +00001574void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001575 VisitExpr(E);
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001576
1577 unsigned NumArgs = Record.readInt();
1578 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1579
1580 E->CXXConstructExprBits.Elidable = Record.readInt();
1581 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1582 E->CXXConstructExprBits.ListInitialization = Record.readInt();
1583 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1584 E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1585 E->CXXConstructExprBits.ConstructionKind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001586 E->CXXConstructExprBits.Loc = readSourceLocation();
1587 E->Constructor = readDeclAs<CXXConstructorDecl>();
1588 E->ParenOrBraceRange = readSourceRange();
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001589
1590 for (unsigned I = 0; I != NumArgs; ++I)
1591 E->setArg(I, Record.readSubExpr());
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001592}
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001593
Richard Smith5179eb72016-06-28 19:03:57 +00001594void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1595 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001596 E->Constructor = readDeclAs<CXXConstructorDecl>();
1597 E->Loc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001598 E->ConstructsVirtualBase = Record.readInt();
1599 E->InheritedFromVirtualBase = Record.readInt();
Richard Smith5179eb72016-06-28 19:03:57 +00001600}
1601
Sebastian Redl70c751d2010-08-18 23:56:52 +00001602void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001603 VisitCXXConstructExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001604 E->TSI = readTypeSourceInfo();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001605}
1606
Douglas Gregore31e6062012-02-07 10:09:13 +00001607void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1608 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001609 unsigned NumCaptures = Record.readInt();
Douglas Gregor99ae8062012-02-14 17:54:36 +00001610 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
John McCall3ce3d232019-12-13 03:37:23 -05001611 E->IntroducerRange = readSourceRange();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001612 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001613 E->CaptureDefaultLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001614 E->ExplicitParams = Record.readInt();
1615 E->ExplicitResultType = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001616 E->ClosingBrace = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001617
Douglas Gregor99ae8062012-02-14 17:54:36 +00001618 // Read capture initializers.
1619 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1620 CEnd = E->capture_init_end();
1621 C != CEnd; ++C)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001622 *C = Record.readSubExpr();
Douglas Gregore31e6062012-02-07 10:09:13 +00001623}
1624
Richard Smithcc1b96d2013-06-12 22:31:48 +00001625void
1626ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1627 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001628 E->SubExpr = Record.readSubExpr();
Richard Smithcc1b96d2013-06-12 22:31:48 +00001629}
1630
Sebastian Redl70c751d2010-08-18 23:56:52 +00001631void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001632 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001633 SourceRange R = readSourceRange();
Douglas Gregor4478f852011-01-12 22:41:29 +00001634 E->Loc = R.getBegin();
1635 E->RParenLoc = R.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05001636 R = readSourceRange();
Fariborz Jahanianf0738712013-02-22 22:02:53 +00001637 E->AngleBrackets = R;
Sam Weinigd01101e2010-01-16 21:21:01 +00001638}
1639
Sebastian Redl70c751d2010-08-18 23:56:52 +00001640void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001641 return VisitCXXNamedCastExpr(E);
1642}
1643
Sebastian Redl70c751d2010-08-18 23:56:52 +00001644void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001645 return VisitCXXNamedCastExpr(E);
1646}
1647
Sebastian Redl70c751d2010-08-18 23:56:52 +00001648void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001649 return VisitCXXNamedCastExpr(E);
1650}
1651
Sebastian Redl70c751d2010-08-18 23:56:52 +00001652void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001653 return VisitCXXNamedCastExpr(E);
1654}
1655
Sebastian Redl70c751d2010-08-18 23:56:52 +00001656void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001657 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001658 E->setLParenLoc(readSourceLocation());
1659 E->setRParenLoc(readSourceLocation());
Sam Weinigd01101e2010-01-16 21:21:01 +00001660}
1661
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001662void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1663 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001664 E->KWLoc = readSourceLocation();
1665 E->RParenLoc = readSourceLocation();
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001666}
1667
Richard Smithc67fdd42012-03-07 08:35:16 +00001668void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1669 VisitCallExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001670 E->UDSuffixLoc = readSourceLocation();
Richard Smithc67fdd42012-03-07 08:35:16 +00001671}
1672
Sebastian Redl70c751d2010-08-18 23:56:52 +00001673void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001674 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001675 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001676 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001677}
1678
Sebastian Redl70c751d2010-08-18 23:56:52 +00001679void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001680 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001681 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001682}
1683
Sebastian Redl70c751d2010-08-18 23:56:52 +00001684void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001685 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001686 E->setSourceRange(readSourceRange());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001687 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redlc67764e2010-07-22 22:43:28 +00001688 E->setTypeOperandSourceInfo(
John McCall3ce3d232019-12-13 03:37:23 -05001689 readTypeSourceInfo());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001690 return;
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001691 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001692
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001693 // typeid(42+2)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001694 E->setExprOperand(Record.readSubExpr());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001695}
1696
Sebastian Redl70c751d2010-08-18 23:56:52 +00001697void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001698 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001699 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001700 E->setImplicit(Record.readInt());
Chris Lattner98267332010-05-09 06:15:05 +00001701}
1702
Sebastian Redl70c751d2010-08-18 23:56:52 +00001703void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001704 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001705 E->CXXThrowExprBits.ThrowLoc = readSourceLocation();
Bruno Riccib7de97b2018-11-17 12:53:56 +00001706 E->Operand = Record.readSubExpr();
1707 E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
Chris Lattner98267332010-05-09 06:15:05 +00001708}
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001709
Sebastian Redl70c751d2010-08-18 23:56:52 +00001710void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattnere2437f42010-05-09 06:40:08 +00001711 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001712 E->Param = readDeclAs<ParmVarDecl>();
1713 E->UsedContext = readDeclAs<DeclContext>();
1714 E->CXXDefaultArgExprBits.Loc = readSourceLocation();
Chris Lattnercba86142010-05-10 00:25:06 +00001715}
1716
Richard Smith852c9db2013-04-20 22:23:05 +00001717void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1718 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001719 E->Field = readDeclAs<FieldDecl>();
1720 E->UsedContext = readDeclAs<DeclContext>();
1721 E->CXXDefaultInitExprBits.Loc = readSourceLocation();
Richard Smith852c9db2013-04-20 22:23:05 +00001722}
1723
Sebastian Redl70c751d2010-08-18 23:56:52 +00001724void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001725 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001726 E->setTemporary(Record.readCXXTemporary());
1727 E->setSubExpr(Record.readSubExpr());
Chris Lattnercba86142010-05-10 00:25:06 +00001728}
1729
Sebastian Redl70c751d2010-08-18 23:56:52 +00001730void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001731 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001732 E->TypeInfo = readTypeSourceInfo();
1733 E->CXXScalarValueInitExprBits.RParenLoc = readSourceLocation();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001734}
1735
Sebastian Redl70c751d2010-08-18 23:56:52 +00001736void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001737 VisitExpr(E);
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001738
1739 bool IsArray = Record.readInt();
1740 bool HasInit = Record.readInt();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001741 unsigned NumPlacementArgs = Record.readInt();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001742 bool IsParenTypeId = Record.readInt();
1743
1744 E->CXXNewExprBits.IsGlobalNew = Record.readInt();
1745 E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
1746 E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1747 E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
1748
1749 assert((IsArray == E->isArray()) && "Wrong IsArray!");
1750 assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
1751 assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
1752 "Wrong NumPlacementArgs!");
1753 assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
1754 (void)IsArray;
1755 (void)HasInit;
1756 (void)NumPlacementArgs;
1757
John McCall3ce3d232019-12-13 03:37:23 -05001758 E->setOperatorNew(readDeclAs<FunctionDecl>());
1759 E->setOperatorDelete(readDeclAs<FunctionDecl>());
1760 E->AllocatedTypeInfo = readTypeSourceInfo();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001761 if (IsParenTypeId)
John McCall3ce3d232019-12-13 03:37:23 -05001762 E->getTrailingObjects<SourceRange>()[0] = readSourceRange();
1763 E->Range = readSourceRange();
1764 E->DirectInitRange = readSourceRange();
Chandler Carruth01718152010-10-25 08:47:36 +00001765
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001766 // Install all the subexpressions.
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001767 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
1768 N = E->raw_arg_end();
1769 I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001770 *I = Record.readSubStmt();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001771}
1772
Sebastian Redl70c751d2010-08-18 23:56:52 +00001773void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001774 VisitExpr(E);
Bruno Ricci91728fc2018-12-03 12:32:32 +00001775 E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
1776 E->CXXDeleteExprBits.ArrayForm = Record.readInt();
1777 E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
1778 E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001779 E->OperatorDelete = readDeclAs<FunctionDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001780 E->Argument = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001781 E->CXXDeleteExprBits.Loc = readSourceLocation();
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001782}
Chris Lattnercba86142010-05-10 00:25:06 +00001783
Sebastian Redl70c751d2010-08-18 23:56:52 +00001784void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001785 VisitExpr(E);
1786
David L. Jonesb6a8f022016-12-21 04:34:52 +00001787 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001788 E->IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001789 E->OperatorLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001790 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001791 E->ScopeType = readTypeSourceInfo();
1792 E->ColonColonLoc = readSourceLocation();
1793 E->TildeLoc = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001794
John McCall3ce3d232019-12-13 03:37:23 -05001795 IdentifierInfo *II = Record.readIdentifier();
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001796 if (II)
John McCall3ce3d232019-12-13 03:37:23 -05001797 E->setDestroyedType(II, readSourceLocation());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001798 else
John McCall3ce3d232019-12-13 03:37:23 -05001799 E->setDestroyedType(readTypeSourceInfo());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001800}
1801
John McCall5d413782010-12-06 08:20:24 +00001802void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001803 VisitExpr(E);
John McCall28fc7092011-11-10 05:35:25 +00001804
David L. Jonesbe1557a2016-12-21 00:17:49 +00001805 unsigned NumObjects = Record.readInt();
John McCall28fc7092011-11-10 05:35:25 +00001806 assert(NumObjects == E->getNumObjects());
1807 for (unsigned i = 0; i != NumObjects; ++i)
James Y Knighte00a67e2015-12-31 04:18:25 +00001808 E->getTrailingObjects<BlockDecl *>()[i] =
John McCall3ce3d232019-12-13 03:37:23 -05001809 readDeclAs<BlockDecl>();
John McCall28fc7092011-11-10 05:35:25 +00001810
David L. Jonesbe1557a2016-12-21 00:17:49 +00001811 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001812 E->SubExpr = Record.readSubExpr();
Chris Lattnere2437f42010-05-09 06:40:08 +00001813}
1814
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001815void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1816 CXXDependentScopeMemberExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001817 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001818
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001819 bool HasTemplateKWAndArgsInfo = Record.readInt();
1820 unsigned NumTemplateArgs = Record.readInt();
1821 bool HasFirstQualifierFoundInScope = Record.readInt();
1822
1823 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
1824 "Wrong HasTemplateKWAndArgsInfo!");
1825 assert(
1826 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
1827 "Wrong HasFirstQualifierFoundInScope!");
1828
1829 if (HasTemplateKWAndArgsInfo)
James Y Knighte7d82282015-12-29 18:15:14 +00001830 ReadTemplateKWAndArgsInfo(
1831 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001832 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001833
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001834 assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
1835 "Wrong NumTemplateArgs!");
1836
1837 E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001838 E->CXXDependentScopeMemberExprBits.OperatorLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001839 E->BaseType = Record.readType();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001840 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001841 E->Base = Record.readSubExpr();
1842
1843 if (HasFirstQualifierFoundInScope)
John McCall3ce3d232019-12-13 03:37:23 -05001844 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001845
John McCall3ce3d232019-12-13 03:37:23 -05001846 E->MemberNameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001847}
1848
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001849void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001850ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001851 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001852
David L. Jonesbe1557a2016-12-21 00:17:49 +00001853 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001854 ReadTemplateKWAndArgsInfo(
1855 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1856 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001857 /*NumTemplateArgs=*/Record.readInt());
Douglas Gregor3a43fd62011-02-25 20:49:16 +00001858
David L. Jonesb6a8f022016-12-21 04:34:52 +00001859 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001860 E->NameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001861}
1862
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001863void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001864ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001865 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001866 assert(Record.peekInt() == E->arg_size() &&
1867 "Read wrong record during creation ?");
1868 Record.skipInts(1);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001869 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001870 E->setArg(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001871 E->TSI = readTypeSourceInfo();
1872 E->setLParenLoc(readSourceLocation());
1873 E->setRParenLoc(readSourceLocation());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001874}
1875
Sebastian Redl70c751d2010-08-18 23:56:52 +00001876void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001877 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001878
Bruno Riccid7628d92019-01-09 15:43:19 +00001879 unsigned NumResults = Record.readInt();
1880 bool HasTemplateKWAndArgsInfo = Record.readInt();
1881 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
1882 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
1883 "Wrong HasTemplateKWAndArgsInfo!");
1884
1885 if (HasTemplateKWAndArgsInfo) {
1886 unsigned NumTemplateArgs = Record.readInt();
James Y Knighte7d82282015-12-29 18:15:14 +00001887 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1888 E->getTrailingTemplateArgumentLoc(),
Bruno Riccid7628d92019-01-09 15:43:19 +00001889 NumTemplateArgs);
1890 assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
1891 "Wrong NumTemplateArgs!");
1892 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001893
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001894 UnresolvedSet<8> Decls;
Bruno Riccid7628d92019-01-09 15:43:19 +00001895 for (unsigned I = 0; I != NumResults; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -05001896 auto *D = readDeclAs<NamedDecl>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001897 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001898 Decls.addDecl(D, AS);
1899 }
Bruno Riccid7628d92019-01-09 15:43:19 +00001900
1901 DeclAccessPair *Results = E->getTrailingResults();
1902 UnresolvedSetIterator Iter = Decls.begin();
1903 for (unsigned I = 0; I != NumResults; ++I) {
1904 Results[I] = (Iter + I).getPair();
1905 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001906
John McCall3ce3d232019-12-13 03:37:23 -05001907 E->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001908 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001909}
1910
Sebastian Redl70c751d2010-08-18 23:56:52 +00001911void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001912 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00001913 E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
1914 E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001915 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001916 E->BaseType = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001917 E->OperatorLoc = readSourceLocation();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001918}
1919
Sebastian Redl70c751d2010-08-18 23:56:52 +00001920void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001921 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00001922 E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
1923 E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001924 E->NamingClass = readDeclAs<CXXRecordDecl>();
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00001925}
1926
Douglas Gregor29c42f22012-02-24 07:38:34 +00001927void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1928 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001929 E->TypeTraitExprBits.NumArgs = Record.readInt();
1930 E->TypeTraitExprBits.Kind = Record.readInt();
1931 E->TypeTraitExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001932 SourceRange Range = readSourceRange();
Jordan Rose99e80c12013-12-20 01:26:47 +00001933 E->Loc = Range.getBegin();
1934 E->RParenLoc = Range.getEnd();
1935
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001936 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001937 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001938 Args[I] = readTypeSourceInfo();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001939}
1940
John Wiegley6242b6a2011-04-28 00:16:57 +00001941void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1942 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001943 E->ATT = (ArrayTypeTrait)Record.readInt();
1944 E->Value = (unsigned int)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001945 SourceRange Range = readSourceRange();
John Wiegley6242b6a2011-04-28 00:16:57 +00001946 E->Loc = Range.getBegin();
1947 E->RParen = Range.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05001948 E->QueriedType = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001949 E->Dimension = Record.readSubExpr();
John Wiegley6242b6a2011-04-28 00:16:57 +00001950}
1951
John Wiegleyf9f65842011-04-25 06:54:41 +00001952void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1953 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001954 E->ET = (ExpressionTrait)Record.readInt();
1955 E->Value = (bool)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001956 SourceRange Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001957 E->QueriedExpression = Record.readSubExpr();
John Wiegleyf9f65842011-04-25 06:54:41 +00001958 E->Loc = Range.getBegin();
1959 E->RParen = Range.getEnd();
1960}
1961
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001962void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1963 VisitExpr(E);
Bruno Riccid56edfe2019-01-08 14:44:34 +00001964 E->CXXNoexceptExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001965 E->Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001966 E->Operand = Record.readSubExpr();
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001967}
1968
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001969void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1970 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001971 E->EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001972 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001973 E->Pattern = Record.readSubExpr();
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001974}
1975
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001976void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1977 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001978 unsigned NumPartialArgs = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001979 E->OperatorLoc = readSourceLocation();
1980 E->PackLoc = readSourceLocation();
1981 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001982 E->Pack = Record.readDeclAs<NamedDecl>();
Richard Smithd784e682015-09-23 21:41:42 +00001983 if (E->isPartiallySubstituted()) {
1984 assert(E->Length == NumPartialArgs);
James Y Knighte00a67e2015-12-31 04:18:25 +00001985 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
Richard Smithd784e682015-09-23 21:41:42 +00001986 *E = I + NumPartialArgs;
1987 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001988 new (I) TemplateArgument(Record.readTemplateArgument());
Richard Smithd784e682015-09-23 21:41:42 +00001989 } else if (!E->isValueDependent()) {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001990 E->Length = Record.readInt();
Richard Smithd784e682015-09-23 21:41:42 +00001991 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001992}
1993
John McCallfa194042011-07-15 07:00:14 +00001994void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1995 SubstNonTypeTemplateParmExpr *E) {
1996 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001997 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
1998 E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001999 E->Replacement = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002000}
2001
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002002void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
2003 SubstNonTypeTemplateParmPackExpr *E) {
2004 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002005 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002006 TemplateArgument ArgPack = Record.readTemplateArgument();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002007 if (ArgPack.getKind() != TemplateArgument::Pack)
2008 return;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002009
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002010 E->Arguments = ArgPack.pack_begin();
2011 E->NumArguments = ArgPack.pack_size();
John McCall3ce3d232019-12-13 03:37:23 -05002012 E->NameLoc = readSourceLocation();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002013}
2014
Richard Smithb15fe3a2012-09-12 00:56:43 +00002015void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2016 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002017 E->NumParameters = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002018 E->ParamPack = readDeclAs<ParmVarDecl>();
2019 E->NameLoc = readSourceLocation();
Richard Smithb2997f52019-05-21 20:10:50 +00002020 auto **Parms = E->getTrailingObjects<VarDecl *>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00002021 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
John McCall3ce3d232019-12-13 03:37:23 -05002022 Parms[i] = readDeclAs<VarDecl>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00002023}
2024
Douglas Gregorfe314812011-06-21 17:03:29 +00002025void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
2026 VisitExpr(E);
Tykerb0561b32019-11-17 11:41:55 +01002027 bool HasMaterialzedDecl = Record.readInt();
2028 if (HasMaterialzedDecl)
2029 E->State = cast<LifetimeExtendedTemporaryDecl>(Record.readDecl());
2030 else
2031 E->State = Record.readSubExpr();
Douglas Gregorfe314812011-06-21 17:03:29 +00002032}
2033
Richard Smith0f0af192014-11-08 05:07:16 +00002034void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
2035 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002036 E->LParenLoc = readSourceLocation();
2037 E->EllipsisLoc = readSourceLocation();
2038 E->RParenLoc = readSourceLocation();
Richard Smithc7214f62019-05-13 08:31:14 +00002039 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002040 E->SubExprs[0] = Record.readSubExpr();
2041 E->SubExprs[1] = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00002042 E->Opcode = (BinaryOperatorKind)Record.readInt();
Richard Smith0f0af192014-11-08 05:07:16 +00002043}
2044
John McCall8d69a212010-11-15 23:31:06 +00002045void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
2046 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002047 E->SourceExpr = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05002048 E->OpaqueValueExprBits.Loc = readSourceLocation();
Akira Hatanaka797afe32018-03-20 01:47:58 +00002049 E->setIsUnique(Record.readInt());
John McCall8d69a212010-11-15 23:31:06 +00002050}
2051
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00002052void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
2053 llvm_unreachable("Cannot read TypoExpr nodes");
2054}
2055
Peter Collingbourne41f85462011-02-09 21:07:24 +00002056//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002057// Microsoft Expressions and Statements
2058//===----------------------------------------------------------------------===//
John McCall5e77d762013-04-16 07:28:30 +00002059void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
2060 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002061 E->IsArrow = (Record.readInt() != 0);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002062 E->BaseExpr = Record.readSubExpr();
2063 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05002064 E->MemberLoc = readSourceLocation();
2065 E->TheDecl = readDeclAs<MSPropertyDecl>();
John McCall5e77d762013-04-16 07:28:30 +00002066}
2067
Alexey Bataevf7630272015-11-25 12:01:00 +00002068void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
2069 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002070 E->setBase(Record.readSubExpr());
2071 E->setIdx(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05002072 E->setRBracketLoc(readSourceLocation());
Alexey Bataevf7630272015-11-25 12:01:00 +00002073}
2074
John McCallfa194042011-07-15 07:00:14 +00002075void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
2076 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002077 E->setSourceRange(readSourceRange());
2078 std::string UuidStr = readString();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002079 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
John McCallfa194042011-07-15 07:00:14 +00002080 if (E->isTypeOperand()) { // __uuidof(ComType)
2081 E->setTypeOperandSourceInfo(
John McCall3ce3d232019-12-13 03:37:23 -05002082 readTypeSourceInfo());
John McCallfa194042011-07-15 07:00:14 +00002083 return;
2084 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002085
John McCallfa194042011-07-15 07:00:14 +00002086 // __uuidof(expr)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002087 E->setExprOperand(Record.readSubExpr());
John McCallfa194042011-07-15 07:00:14 +00002088}
2089
Nico Weber9b982072014-07-07 00:12:30 +00002090void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
2091 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002092 S->setLeaveLoc(readSourceLocation());
Nico Weber9b982072014-07-07 00:12:30 +00002093}
2094
John McCallfa194042011-07-15 07:00:14 +00002095void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
2096 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002097 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002098 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
2099 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002100}
2101
2102void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
2103 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05002104 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002105 S->Block = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002106}
2107
2108void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
2109 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002110 S->IsCXXTry = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05002111 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002112 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
2113 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002114}
2115
2116//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00002117// CUDA Expressions and Statements
2118//===----------------------------------------------------------------------===//
2119
2120void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2121 VisitCallExpr(E);
Richard Smithfd420792019-05-24 23:26:07 +00002122 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
Peter Collingbourne41f85462011-02-09 21:07:24 +00002123}
2124
John McCallfa194042011-07-15 07:00:14 +00002125//===----------------------------------------------------------------------===//
2126// OpenCL Expressions and Statements.
2127//===----------------------------------------------------------------------===//
2128void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2129 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002130 E->BuiltinLoc = readSourceLocation();
2131 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002132 E->SrcExpr = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002133}
2134
2135//===----------------------------------------------------------------------===//
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002136// OpenMP Directives.
2137//===----------------------------------------------------------------------===//
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002138
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002139void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
John McCall3ce3d232019-12-13 03:37:23 -05002140 E->setLocStart(readSourceLocation());
2141 E->setLocEnd(readSourceLocation());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002142 SmallVector<OMPClause *, 5> Clauses;
2143 for (unsigned i = 0; i < E->getNumClauses(); ++i)
John McCallc2f18312019-12-14 03:01:28 -05002144 Clauses.push_back(Record.readOMPClause());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002145 E->setClauses(Clauses);
Alexey Bataev68446b72014-07-18 07:47:19 +00002146 if (E->hasAssociatedStmt())
David L. Jonesb6a8f022016-12-21 04:34:52 +00002147 E->setAssociatedStmt(Record.readSubStmt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002148}
2149
Alexander Musman3aaab662014-08-19 11:27:13 +00002150void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2151 VisitStmt(D);
2152 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002153 Record.skipInts(2);
Alexander Musman3aaab662014-08-19 11:27:13 +00002154 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002155 D->setIterationVariable(Record.readSubExpr());
2156 D->setLastIteration(Record.readSubExpr());
2157 D->setCalcLastIteration(Record.readSubExpr());
2158 D->setPreCond(Record.readSubExpr());
2159 D->setCond(Record.readSubExpr());
2160 D->setInit(Record.readSubExpr());
2161 D->setInc(Record.readSubExpr());
2162 D->setPreInits(Record.readSubStmt());
Alexey Bataev3392d762016-02-16 11:18:12 +00002163 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
Carlo Bertollifc35ad22016-03-07 16:04:49 +00002164 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2165 isOpenMPDistributeDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002166 D->setIsLastIterVariable(Record.readSubExpr());
2167 D->setLowerBoundVariable(Record.readSubExpr());
2168 D->setUpperBoundVariable(Record.readSubExpr());
2169 D->setStrideVariable(Record.readSubExpr());
2170 D->setEnsureUpperBound(Record.readSubExpr());
2171 D->setNextLowerBound(Record.readSubExpr());
2172 D->setNextUpperBound(Record.readSubExpr());
2173 D->setNumIterations(Record.readSubExpr());
Alexander Musmanc6388682014-12-15 07:07:06 +00002174 }
Carlo Bertolli9925f152016-06-27 14:55:37 +00002175 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002176 D->setPrevLowerBoundVariable(Record.readSubExpr());
2177 D->setPrevUpperBoundVariable(Record.readSubExpr());
Carlo Bertolli8429d812017-02-17 21:29:13 +00002178 D->setDistInc(Record.readSubExpr());
2179 D->setPrevEnsureUpperBound(Record.readSubExpr());
Carlo Bertolliffafe102017-04-20 00:39:39 +00002180 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2181 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2182 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2183 D->setCombinedInit(Record.readSubExpr());
2184 D->setCombinedCond(Record.readSubExpr());
2185 D->setCombinedNextLowerBound(Record.readSubExpr());
2186 D->setCombinedNextUpperBound(Record.readSubExpr());
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00002187 D->setCombinedDistCond(Record.readSubExpr());
2188 D->setCombinedParForInDistCond(Record.readSubExpr());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002189 }
Alexander Musmana5f070a2014-10-01 06:03:56 +00002190 SmallVector<Expr *, 4> Sub;
2191 unsigned CollapsedNum = D->getCollapsedNumber();
2192 Sub.reserve(CollapsedNum);
2193 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002194 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002195 D->setCounters(Sub);
2196 Sub.clear();
2197 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002198 Sub.push_back(Record.readSubExpr());
Alexey Bataeva8899172015-08-06 12:30:57 +00002199 D->setPrivateCounters(Sub);
2200 Sub.clear();
2201 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002202 Sub.push_back(Record.readSubExpr());
Alexey Bataevb08f89f2015-08-14 12:25:37 +00002203 D->setInits(Sub);
2204 Sub.clear();
2205 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002206 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002207 D->setUpdates(Sub);
2208 Sub.clear();
2209 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002210 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002211 D->setFinals(Sub);
Alexey Bataevf8be4762019-08-14 19:30:06 +00002212 Sub.clear();
2213 for (unsigned i = 0; i < CollapsedNum; ++i)
2214 Sub.push_back(Record.readSubExpr());
2215 D->setDependentCounters(Sub);
2216 Sub.clear();
2217 for (unsigned i = 0; i < CollapsedNum; ++i)
2218 Sub.push_back(Record.readSubExpr());
2219 D->setDependentInits(Sub);
2220 Sub.clear();
2221 for (unsigned i = 0; i < CollapsedNum; ++i)
2222 Sub.push_back(Record.readSubExpr());
2223 D->setFinalsConditions(Sub);
Alexander Musman3aaab662014-08-19 11:27:13 +00002224}
2225
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002226void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002227 VisitStmt(D);
2228 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002229 Record.skipInts(1);
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002230 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002231 D->setHasCancel(Record.readInt());
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002232}
2233
2234void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002235 VisitOMPLoopDirective(D);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002236}
2237
Alexey Bataevf29276e2014-06-18 04:14:57 +00002238void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002239 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002240 D->setHasCancel(Record.readInt());
Alexey Bataevf29276e2014-06-18 04:14:57 +00002241}
2242
Alexander Musmanf82886e2014-09-18 05:12:34 +00002243void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2244 VisitOMPLoopDirective(D);
2245}
2246
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002247void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2248 VisitStmt(D);
2249 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002250 Record.skipInts(1);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002251 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002252 D->setHasCancel(Record.readInt());
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002253}
2254
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002255void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2256 VisitStmt(D);
2257 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002258 D->setHasCancel(Record.readInt());
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002259}
2260
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002261void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2262 VisitStmt(D);
2263 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002264 Record.skipInts(1);
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002265 VisitOMPExecutableDirective(D);
2266}
2267
Alexander Musman80c22892014-07-17 08:54:58 +00002268void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2269 VisitStmt(D);
2270 VisitOMPExecutableDirective(D);
2271}
2272
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002273void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2274 VisitStmt(D);
Alexey Bataev28c75412015-12-15 08:19:24 +00002275 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002276 Record.skipInts(1);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002277 VisitOMPExecutableDirective(D);
John McCall3ce3d232019-12-13 03:37:23 -05002278 D->DirName = Record.readDeclarationNameInfo();
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002279}
2280
Alexey Bataev4acb8592014-07-07 13:01:15 +00002281void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002282 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002283 D->setHasCancel(Record.readInt());
Alexey Bataev4acb8592014-07-07 13:01:15 +00002284}
2285
Alexander Musmane4e893b2014-09-23 09:33:00 +00002286void ASTStmtReader::VisitOMPParallelForSimdDirective(
2287 OMPParallelForSimdDirective *D) {
2288 VisitOMPLoopDirective(D);
2289}
2290
cchen47d60942019-12-05 13:43:48 -05002291void ASTStmtReader::VisitOMPParallelMasterDirective(
2292 OMPParallelMasterDirective *D) {
2293 VisitStmt(D);
2294 // The NumClauses field was read in ReadStmtFromStream.
2295 Record.skipInts(1);
2296 VisitOMPExecutableDirective(D);
2297}
2298
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002299void ASTStmtReader::VisitOMPParallelSectionsDirective(
2300 OMPParallelSectionsDirective *D) {
2301 VisitStmt(D);
2302 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002303 Record.skipInts(1);
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002304 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002305 D->setHasCancel(Record.readInt());
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002306}
2307
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002308void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2309 VisitStmt(D);
2310 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002311 Record.skipInts(1);
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002312 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002313 D->setHasCancel(Record.readInt());
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002314}
2315
Alexey Bataev68446b72014-07-18 07:47:19 +00002316void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2317 VisitStmt(D);
2318 VisitOMPExecutableDirective(D);
2319}
2320
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002321void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2322 VisitStmt(D);
2323 VisitOMPExecutableDirective(D);
2324}
2325
Alexey Bataev2df347a2014-07-18 10:17:07 +00002326void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2327 VisitStmt(D);
2328 VisitOMPExecutableDirective(D);
2329}
2330
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002331void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2332 VisitStmt(D);
Alexey Bataev169d96a2017-07-18 20:17:46 +00002333 // The NumClauses field was read in ReadStmtFromStream.
2334 Record.skipInts(1);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002335 VisitOMPExecutableDirective(D);
Alexey Bataev3b1b8952017-07-25 15:53:26 +00002336 D->setReductionRef(Record.readSubExpr());
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002337}
2338
Alexey Bataev6125da92014-07-21 11:26:11 +00002339void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2340 VisitStmt(D);
2341 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002342 Record.skipInts(1);
Alexey Bataev6125da92014-07-21 11:26:11 +00002343 VisitOMPExecutableDirective(D);
2344}
2345
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002346void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2347 VisitStmt(D);
Alexey Bataev346265e2015-09-25 10:37:12 +00002348 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002349 Record.skipInts(1);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002350 VisitOMPExecutableDirective(D);
2351}
2352
Alexey Bataev0162e452014-07-22 10:10:35 +00002353void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2354 VisitStmt(D);
2355 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002356 Record.skipInts(1);
Alexey Bataev0162e452014-07-22 10:10:35 +00002357 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002358 D->setX(Record.readSubExpr());
2359 D->setV(Record.readSubExpr());
2360 D->setExpr(Record.readSubExpr());
2361 D->setUpdateExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002362 D->IsXLHSInRHSPart = Record.readInt() != 0;
2363 D->IsPostfixUpdate = Record.readInt() != 0;
Alexey Bataev0162e452014-07-22 10:10:35 +00002364}
2365
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002366void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *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 Bataev0bd520b2014-09-19 08:19:49 +00002370 VisitOMPExecutableDirective(D);
2371}
2372
Michael Wong65f367f2015-07-21 13:44:28 +00002373void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2374 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002375 Record.skipInts(1);
Michael Wong65f367f2015-07-21 13:44:28 +00002376 VisitOMPExecutableDirective(D);
2377}
2378
Samuel Antaodf67fc42016-01-19 19:15:56 +00002379void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2380 OMPTargetEnterDataDirective *D) {
2381 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002382 Record.skipInts(1);
Samuel Antaodf67fc42016-01-19 19:15:56 +00002383 VisitOMPExecutableDirective(D);
2384}
2385
Samuel Antao72590762016-01-19 20:04:50 +00002386void ASTStmtReader::VisitOMPTargetExitDataDirective(
2387 OMPTargetExitDataDirective *D) {
2388 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002389 Record.skipInts(1);
Samuel Antao72590762016-01-19 20:04:50 +00002390 VisitOMPExecutableDirective(D);
2391}
2392
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002393void ASTStmtReader::VisitOMPTargetParallelDirective(
2394 OMPTargetParallelDirective *D) {
2395 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002396 Record.skipInts(1);
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002397 VisitOMPExecutableDirective(D);
2398}
2399
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002400void ASTStmtReader::VisitOMPTargetParallelForDirective(
2401 OMPTargetParallelForDirective *D) {
2402 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002403 D->setHasCancel(Record.readInt());
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002404}
2405
Alexey Bataev13314bf2014-10-09 04:18:56 +00002406void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2407 VisitStmt(D);
2408 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002409 Record.skipInts(1);
Alexey Bataev13314bf2014-10-09 04:18:56 +00002410 VisitOMPExecutableDirective(D);
2411}
2412
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002413void ASTStmtReader::VisitOMPCancellationPointDirective(
2414 OMPCancellationPointDirective *D) {
2415 VisitStmt(D);
2416 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002417 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002418}
2419
Alexey Bataev80909872015-07-02 11:25:17 +00002420void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2421 VisitStmt(D);
Alexey Bataev87933c72015-09-18 08:07:34 +00002422 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002423 Record.skipInts(1);
Alexey Bataev80909872015-07-02 11:25:17 +00002424 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002425 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev80909872015-07-02 11:25:17 +00002426}
2427
Alexey Bataev49f6e782015-12-01 04:18:41 +00002428void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2429 VisitOMPLoopDirective(D);
2430}
2431
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002432void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2433 VisitOMPLoopDirective(D);
2434}
2435
Alexey Bataev60e51c42019-10-10 20:13:02 +00002436void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2437 OMPMasterTaskLoopDirective *D) {
2438 VisitOMPLoopDirective(D);
2439}
2440
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002441void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2442 OMPMasterTaskLoopSimdDirective *D) {
2443 VisitOMPLoopDirective(D);
2444}
2445
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002446void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2447 OMPParallelMasterTaskLoopDirective *D) {
2448 VisitOMPLoopDirective(D);
2449}
2450
Alexey Bataev14a388f2019-10-25 10:27:13 -04002451void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2452 OMPParallelMasterTaskLoopSimdDirective *D) {
2453 VisitOMPLoopDirective(D);
2454}
2455
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002456void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2457 VisitOMPLoopDirective(D);
2458}
2459
Samuel Antao686c70c2016-05-26 17:30:50 +00002460void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2461 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002462 Record.skipInts(1);
Samuel Antao686c70c2016-05-26 17:30:50 +00002463 VisitOMPExecutableDirective(D);
2464}
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002465
Carlo Bertolli9925f152016-06-27 14:55:37 +00002466void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2467 OMPDistributeParallelForDirective *D) {
2468 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002469 D->setHasCancel(Record.readInt());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002470}
Samuel Antao686c70c2016-05-26 17:30:50 +00002471
Kelvin Li4a39add2016-07-05 05:00:15 +00002472void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2473 OMPDistributeParallelForSimdDirective *D) {
2474 VisitOMPLoopDirective(D);
2475}
2476
Kelvin Li787f3fc2016-07-06 04:45:38 +00002477void ASTStmtReader::VisitOMPDistributeSimdDirective(
2478 OMPDistributeSimdDirective *D) {
2479 VisitOMPLoopDirective(D);
2480}
2481
Kelvin Lia579b912016-07-14 02:54:56 +00002482void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2483 OMPTargetParallelForSimdDirective *D) {
2484 VisitOMPLoopDirective(D);
2485}
2486
Kelvin Li986330c2016-07-20 22:57:10 +00002487void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2488 VisitOMPLoopDirective(D);
2489}
2490
Kelvin Li02532872016-08-05 14:37:37 +00002491void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2492 OMPTeamsDistributeDirective *D) {
2493 VisitOMPLoopDirective(D);
2494}
2495
Kelvin Li4e325f72016-10-25 12:50:55 +00002496void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2497 OMPTeamsDistributeSimdDirective *D) {
2498 VisitOMPLoopDirective(D);
2499}
2500
Kelvin Li579e41c2016-11-30 23:51:03 +00002501void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2502 OMPTeamsDistributeParallelForSimdDirective *D) {
2503 VisitOMPLoopDirective(D);
2504}
2505
Kelvin Li7ade93f2016-12-09 03:24:30 +00002506void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2507 OMPTeamsDistributeParallelForDirective *D) {
2508 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002509 D->setHasCancel(Record.readInt());
Kelvin Li7ade93f2016-12-09 03:24:30 +00002510}
2511
Kelvin Libf594a52016-12-17 05:48:59 +00002512void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2513 VisitStmt(D);
2514 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002515 Record.skipInts(1);
Kelvin Libf594a52016-12-17 05:48:59 +00002516 VisitOMPExecutableDirective(D);
2517}
2518
Kelvin Li83c451e2016-12-25 04:52:54 +00002519void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2520 OMPTargetTeamsDistributeDirective *D) {
2521 VisitOMPLoopDirective(D);
2522}
2523
Kelvin Li80e8f562016-12-29 22:16:30 +00002524void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2525 OMPTargetTeamsDistributeParallelForDirective *D) {
2526 VisitOMPLoopDirective(D);
Alexey Bataev16e79882017-11-22 21:12:03 +00002527 D->setHasCancel(Record.readInt());
Kelvin Li80e8f562016-12-29 22:16:30 +00002528}
2529
Kelvin Li1851df52017-01-03 05:23:48 +00002530void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2531 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2532 VisitOMPLoopDirective(D);
2533}
2534
Kelvin Lida681182017-01-10 18:08:18 +00002535void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2536 OMPTargetTeamsDistributeSimdDirective *D) {
2537 VisitOMPLoopDirective(D);
2538}
2539
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002540//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002541// ASTReader Implementation
2542//===----------------------------------------------------------------------===//
2543
Douglas Gregorde3ef502011-11-30 23:21:26 +00002544Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002545 switch (ReadingKind) {
Richard Smith629ff362013-07-31 00:26:46 +00002546 case Read_None:
2547 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002548 case Read_Decl:
2549 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00002550 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002551 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002552 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002553 }
2554
2555 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002556}
2557
Douglas Gregorde3ef502011-11-30 23:21:26 +00002558Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00002559 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002560}
Chris Lattnere2437f42010-05-09 06:40:08 +00002561
Sebastian Redl2c499f62010-08-18 23:56:43 +00002562Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002563 return cast_or_null<Expr>(ReadSubStmt());
2564}
2565
Chris Lattnerf4262532009-04-27 05:41:06 +00002566// Within the bitstream, expressions are stored in Reverse Polish
2567// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002568// expression they are stored in. Subexpressions are stored from last to first.
2569// To evaluate expressions, we continue reading expressions and placing them on
2570// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00002571// stack. Evaluation terminates when we see a STMT_STOP record, and
2572// the single remaining expression on the stack is our result.
Douglas Gregorde3ef502011-11-30 23:21:26 +00002573Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002574 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00002575 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002576
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002577 // Map of offset to previously deserialized stmt. The offset points
George Burgess IV758cf9d2017-02-14 05:52:57 +00002578 // just after the stmt record.
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002579 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00002580
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002581#ifndef NDEBUG
2582 unsigned PrevNumStmts = StmtStack.size();
2583#endif
2584
David L. Jonesbe1557a2016-12-21 00:17:49 +00002585 ASTRecordReader Record(*this, F);
2586 ASTStmtReader Reader(Record, Cursor);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002587 Stmt::EmptyShell Empty;
2588
2589 while (true) {
JF Bastien0e828952019-06-26 19:50:12 +00002590 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2591 Cursor.advanceSkippingSubblocks();
2592 if (!MaybeEntry) {
2593 Error(toString(MaybeEntry.takeError()));
2594 return nullptr;
2595 }
2596 llvm::BitstreamEntry Entry = MaybeEntry.get();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002597
Chris Lattner0e6c9402013-01-20 02:38:54 +00002598 switch (Entry.Kind) {
2599 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2600 case llvm::BitstreamEntry::Error:
2601 Error("malformed block record in AST file");
Craig Toppera13603a2014-05-22 05:54:18 +00002602 return nullptr;
Chris Lattner0e6c9402013-01-20 02:38:54 +00002603 case llvm::BitstreamEntry::EndBlock:
2604 goto Done;
2605 case llvm::BitstreamEntry::Record:
2606 // The interesting case.
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002607 break;
2608 }
2609
Richard Smithdbafb6c2017-06-29 23:23:46 +00002610 ASTContext &Context = getContext();
Craig Toppera13603a2014-05-22 05:54:18 +00002611 Stmt *S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002612 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002613 bool IsStmtReference = false;
JF Bastien0e828952019-06-26 19:50:12 +00002614 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2615 if (!MaybeStmtCode) {
2616 Error(toString(MaybeStmtCode.takeError()));
2617 return nullptr;
2618 }
2619 switch ((StmtCode)MaybeStmtCode.get()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00002620 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002621 Finished = true;
2622 break;
2623
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002624 case STMT_REF_PTR:
2625 IsStmtReference = true;
2626 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2627 "No stmt was recorded for this offset reference!");
David L. Jonesbe1557a2016-12-21 00:17:49 +00002628 S = StmtEntries[Record.readInt()];
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002629 break;
2630
Sebastian Redl539c5062010-08-18 23:57:32 +00002631 case STMT_NULL_PTR:
Craig Toppera13603a2014-05-22 05:54:18 +00002632 S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002633 break;
2634
Sebastian Redl539c5062010-08-18 23:57:32 +00002635 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002636 S = new (Context) NullStmt(Empty);
2637 break;
2638
Sebastian Redl539c5062010-08-18 23:57:32 +00002639 case STMT_COMPOUND:
Benjamin Kramer07420902017-12-24 16:24:20 +00002640 S = CompoundStmt::CreateEmpty(
2641 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002642 break;
2643
Sebastian Redl539c5062010-08-18 23:57:32 +00002644 case STMT_CASE:
Bruno Ricci5b30571752018-10-28 12:30:53 +00002645 S = CaseStmt::CreateEmpty(
2646 Context,
2647 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002648 break;
2649
Sebastian Redl539c5062010-08-18 23:57:32 +00002650 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002651 S = new (Context) DefaultStmt(Empty);
2652 break;
2653
Sebastian Redl539c5062010-08-18 23:57:32 +00002654 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002655 S = new (Context) LabelStmt(Empty);
2656 break;
2657
Richard Smithc202b282012-04-14 00:33:13 +00002658 case STMT_ATTRIBUTED:
Alexander Kornienko20f6fc62012-07-09 10:04:07 +00002659 S = AttributedStmt::CreateEmpty(
2660 Context,
2661 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smithc202b282012-04-14 00:33:13 +00002662 break;
2663
Sebastian Redl539c5062010-08-18 23:57:32 +00002664 case STMT_IF:
Bruno Riccib1cc94b2018-10-27 21:12:20 +00002665 S = IfStmt::CreateEmpty(
2666 Context,
2667 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2668 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2669 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002670 break;
2671
Sebastian Redl539c5062010-08-18 23:57:32 +00002672 case STMT_SWITCH:
Bruno Riccie2806f82018-10-29 16:12:37 +00002673 S = SwitchStmt::CreateEmpty(
2674 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002675 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
Bruno Riccie2806f82018-10-29 16:12:37 +00002676 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002677 break;
2678
Sebastian Redl539c5062010-08-18 23:57:32 +00002679 case STMT_WHILE:
Bruno Riccibacf7512018-10-30 13:42:41 +00002680 S = WhileStmt::CreateEmpty(
2681 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002682 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002683 break;
2684
Sebastian Redl539c5062010-08-18 23:57:32 +00002685 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002686 S = new (Context) DoStmt(Empty);
2687 break;
Mike Stump11289f42009-09-09 15:08:12 +00002688
Sebastian Redl539c5062010-08-18 23:57:32 +00002689 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002690 S = new (Context) ForStmt(Empty);
2691 break;
2692
Sebastian Redl539c5062010-08-18 23:57:32 +00002693 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002694 S = new (Context) GotoStmt(Empty);
2695 break;
Mike Stump11289f42009-09-09 15:08:12 +00002696
Sebastian Redl539c5062010-08-18 23:57:32 +00002697 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002698 S = new (Context) IndirectGotoStmt(Empty);
2699 break;
2700
Sebastian Redl539c5062010-08-18 23:57:32 +00002701 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002702 S = new (Context) ContinueStmt(Empty);
2703 break;
2704
Sebastian Redl539c5062010-08-18 23:57:32 +00002705 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002706 S = new (Context) BreakStmt(Empty);
2707 break;
2708
Sebastian Redl539c5062010-08-18 23:57:32 +00002709 case STMT_RETURN:
Bruno Ricci023b1d12018-10-30 14:40:49 +00002710 S = ReturnStmt::CreateEmpty(
2711 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002712 break;
2713
Sebastian Redl539c5062010-08-18 23:57:32 +00002714 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002715 S = new (Context) DeclStmt(Empty);
2716 break;
2717
Chad Rosierde70e0e2012-08-25 00:11:56 +00002718 case STMT_GCCASM:
2719 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002720 break;
2721
Chad Rosiere30d4992012-08-24 23:51:02 +00002722 case STMT_MSASM:
2723 S = new (Context) MSAsmStmt(Empty);
2724 break;
2725
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002726 case STMT_CAPTURED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002727 S = CapturedStmt::CreateDeserialized(
2728 Context, Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002729 break;
2730
Bill Wendling7c44da22018-10-31 03:48:47 +00002731 case EXPR_CONSTANT:
Gauthier Harnisch83c7b612019-06-15 10:24:47 +00002732 S = ConstantExpr::CreateEmpty(
2733 Context,
2734 static_cast<ConstantExpr::ResultStorageKind>(
2735 Record[ASTStmtReader::NumExprFields]),
2736 Empty);
Bill Wendling7c44da22018-10-31 03:48:47 +00002737 break;
2738
Sebastian Redl539c5062010-08-18 23:57:32 +00002739 case EXPR_PREDEFINED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002740 S = PredefinedExpr::CreateEmpty(
2741 Context,
2742 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002743 break;
Mike Stump11289f42009-09-09 15:08:12 +00002744
Sebastian Redl539c5062010-08-18 23:57:32 +00002745 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002746 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00002747 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002748 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2749 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnara7945c982012-01-27 09:46:47 +00002750 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002751 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Richard Smith715f7a12019-06-11 17:50:32 +00002752 Record[ASTStmtReader::NumExprFields + 6] : 0);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002753 break;
Mike Stump11289f42009-09-09 15:08:12 +00002754
Sebastian Redl539c5062010-08-18 23:57:32 +00002755 case EXPR_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002756 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002757 break;
Mike Stump11289f42009-09-09 15:08:12 +00002758
Sebastian Redl539c5062010-08-18 23:57:32 +00002759 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002760 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002761 break;
Mike Stump11289f42009-09-09 15:08:12 +00002762
Sebastian Redl539c5062010-08-18 23:57:32 +00002763 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002764 S = new (Context) ImaginaryLiteral(Empty);
2765 break;
2766
Sebastian Redl539c5062010-08-18 23:57:32 +00002767 case EXPR_STRING_LITERAL:
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002768 S = StringLiteral::CreateEmpty(
2769 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002770 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002771 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2772 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002773 break;
2774
Sebastian Redl539c5062010-08-18 23:57:32 +00002775 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002776 S = new (Context) CharacterLiteral(Empty);
2777 break;
2778
Sebastian Redl539c5062010-08-18 23:57:32 +00002779 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002780 S = new (Context) ParenExpr(Empty);
2781 break;
2782
Sebastian Redl539c5062010-08-18 23:57:32 +00002783 case EXPR_PAREN_LIST:
Bruno Riccif49e1ca2018-11-20 16:20:40 +00002784 S = ParenListExpr::CreateEmpty(
2785 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002786 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00002787 break;
2788
Sebastian Redl539c5062010-08-18 23:57:32 +00002789 case EXPR_UNARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002790 S = new (Context) UnaryOperator(Empty);
2791 break;
2792
Sebastian Redl539c5062010-08-18 23:57:32 +00002793 case EXPR_OFFSETOF:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002794 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002795 Record[ASTStmtReader::NumExprFields],
2796 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00002797 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002798
Sebastian Redl539c5062010-08-18 23:57:32 +00002799 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00002800 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002801 break;
2802
Sebastian Redl539c5062010-08-18 23:57:32 +00002803 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002804 S = new (Context) ArraySubscriptExpr(Empty);
2805 break;
2806
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002807 case EXPR_OMP_ARRAY_SECTION:
2808 S = new (Context) OMPArraySectionExpr(Empty);
2809 break;
2810
Sebastian Redl539c5062010-08-18 23:57:32 +00002811 case EXPR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00002812 S = CallExpr::CreateEmpty(
2813 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002814 break;
2815
Richard Smithdcf17de2019-06-06 23:24:15 +00002816 case EXPR_MEMBER:
2817 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
2818 Record[ASTStmtReader::NumExprFields + 1],
2819 Record[ASTStmtReader::NumExprFields + 2],
2820 Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002821 break;
2822
Sebastian Redl539c5062010-08-18 23:57:32 +00002823 case EXPR_BINARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002824 S = new (Context) BinaryOperator(Empty);
2825 break;
2826
Sebastian Redl539c5062010-08-18 23:57:32 +00002827 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002828 S = new (Context) CompoundAssignOperator(Empty);
2829 break;
2830
Sebastian Redl539c5062010-08-18 23:57:32 +00002831 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002832 S = new (Context) ConditionalOperator(Empty);
2833 break;
2834
John McCallc07a0c72011-02-17 10:25:35 +00002835 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2836 S = new (Context) BinaryConditionalOperator(Empty);
2837 break;
2838
Sebastian Redl539c5062010-08-18 23:57:32 +00002839 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002840 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002841 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002842 break;
2843
Sebastian Redl539c5062010-08-18 23:57:32 +00002844 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002845 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002846 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002847 break;
2848
Sebastian Redl539c5062010-08-18 23:57:32 +00002849 case EXPR_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002850 S = new (Context) CompoundLiteralExpr(Empty);
2851 break;
2852
Sebastian Redl539c5062010-08-18 23:57:32 +00002853 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002854 S = new (Context) ExtVectorElementExpr(Empty);
2855 break;
2856
Sebastian Redl539c5062010-08-18 23:57:32 +00002857 case EXPR_INIT_LIST:
Argyrios Kyrtzidis0f05fb92012-11-28 03:56:16 +00002858 S = new (Context) InitListExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002859 break;
2860
Sebastian Redl539c5062010-08-18 23:57:32 +00002861 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002862 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002863 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00002864
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002865 break;
2866
Yunzhong Gaocb779302015-06-10 00:27:52 +00002867 case EXPR_DESIGNATED_INIT_UPDATE:
2868 S = new (Context) DesignatedInitUpdateExpr(Empty);
2869 break;
2870
Sebastian Redl539c5062010-08-18 23:57:32 +00002871 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002872 S = new (Context) ImplicitValueInitExpr(Empty);
2873 break;
2874
Yunzhong Gaocb779302015-06-10 00:27:52 +00002875 case EXPR_NO_INIT:
2876 S = new (Context) NoInitExpr(Empty);
2877 break;
2878
Richard Smith410306b2016-12-12 02:53:20 +00002879 case EXPR_ARRAY_INIT_LOOP:
2880 S = new (Context) ArrayInitLoopExpr(Empty);
2881 break;
2882
2883 case EXPR_ARRAY_INIT_INDEX:
2884 S = new (Context) ArrayInitIndexExpr(Empty);
2885 break;
2886
Sebastian Redl539c5062010-08-18 23:57:32 +00002887 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002888 S = new (Context) VAArgExpr(Empty);
2889 break;
2890
Eric Fiselier708afb52019-05-16 21:04:15 +00002891 case EXPR_SOURCE_LOC:
2892 S = new (Context) SourceLocExpr(Empty);
2893 break;
2894
Sebastian Redl539c5062010-08-18 23:57:32 +00002895 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002896 S = new (Context) AddrLabelExpr(Empty);
2897 break;
2898
Sebastian Redl539c5062010-08-18 23:57:32 +00002899 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002900 S = new (Context) StmtExpr(Empty);
2901 break;
2902
Sebastian Redl539c5062010-08-18 23:57:32 +00002903 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002904 S = new (Context) ChooseExpr(Empty);
2905 break;
2906
Sebastian Redl539c5062010-08-18 23:57:32 +00002907 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002908 S = new (Context) GNUNullExpr(Empty);
2909 break;
2910
Sebastian Redl539c5062010-08-18 23:57:32 +00002911 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002912 S = new (Context) ShuffleVectorExpr(Empty);
2913 break;
Mike Stump11289f42009-09-09 15:08:12 +00002914
Hal Finkelc4d7c822013-09-18 03:29:45 +00002915 case EXPR_CONVERT_VECTOR:
2916 S = new (Context) ConvertVectorExpr(Empty);
2917 break;
2918
Sebastian Redl539c5062010-08-18 23:57:32 +00002919 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002920 S = new (Context) BlockExpr(Empty);
2921 break;
2922
Peter Collingbourne91147592011-04-15 00:35:48 +00002923 case EXPR_GENERIC_SELECTION:
Bruno Riccidb076832019-01-26 14:15:10 +00002924 S = GenericSelectionExpr::CreateEmpty(
2925 Context,
2926 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
Peter Collingbourne91147592011-04-15 00:35:48 +00002927 break;
2928
Sebastian Redl539c5062010-08-18 23:57:32 +00002929 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002930 S = new (Context) ObjCStringLiteral(Empty);
2931 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002932
Patrick Beard0caa3942012-04-19 00:25:12 +00002933 case EXPR_OBJC_BOXED_EXPRESSION:
2934 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremeneke65b0862012-03-06 20:05:56 +00002935 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002936
Ted Kremeneke65b0862012-03-06 20:05:56 +00002937 case EXPR_OBJC_ARRAY_LITERAL:
2938 S = ObjCArrayLiteral::CreateEmpty(Context,
2939 Record[ASTStmtReader::NumExprFields]);
2940 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002941
Ted Kremeneke65b0862012-03-06 20:05:56 +00002942 case EXPR_OBJC_DICTIONARY_LITERAL:
2943 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2944 Record[ASTStmtReader::NumExprFields],
2945 Record[ASTStmtReader::NumExprFields + 1]);
2946 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002947
Sebastian Redl539c5062010-08-18 23:57:32 +00002948 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002949 S = new (Context) ObjCEncodeExpr(Empty);
2950 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002951
Sebastian Redl539c5062010-08-18 23:57:32 +00002952 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002953 S = new (Context) ObjCSelectorExpr(Empty);
2954 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002955
Sebastian Redl539c5062010-08-18 23:57:32 +00002956 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002957 S = new (Context) ObjCProtocolExpr(Empty);
2958 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002959
Sebastian Redl539c5062010-08-18 23:57:32 +00002960 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002961 S = new (Context) ObjCIvarRefExpr(Empty);
2962 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002963
Sebastian Redl539c5062010-08-18 23:57:32 +00002964 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002965 S = new (Context) ObjCPropertyRefExpr(Empty);
2966 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002967
Ted Kremeneke65b0862012-03-06 20:05:56 +00002968 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2969 S = new (Context) ObjCSubscriptRefExpr(Empty);
2970 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002971
Sebastian Redl539c5062010-08-18 23:57:32 +00002972 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00002973 llvm_unreachable("mismatching AST file");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002974
Sebastian Redl539c5062010-08-18 23:57:32 +00002975 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002976 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00002977 Record[ASTStmtReader::NumExprFields],
2978 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002979 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002980
Sebastian Redl539c5062010-08-18 23:57:32 +00002981 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00002982 S = new (Context) ObjCIsaExpr(Empty);
2983 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002984
John McCall31168b02011-06-15 23:02:42 +00002985 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2986 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2987 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002988
John McCall31168b02011-06-15 23:02:42 +00002989 case EXPR_OBJC_BRIDGED_CAST:
2990 S = new (Context) ObjCBridgedCastExpr(Empty);
2991 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002992
Sebastian Redl539c5062010-08-18 23:57:32 +00002993 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002994 S = new (Context) ObjCForCollectionStmt(Empty);
2995 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002996
Sebastian Redl539c5062010-08-18 23:57:32 +00002997 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002998 S = new (Context) ObjCAtCatchStmt(Empty);
2999 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003000
Sebastian Redl539c5062010-08-18 23:57:32 +00003001 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003002 S = new (Context) ObjCAtFinallyStmt(Empty);
3003 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003004
Sebastian Redl539c5062010-08-18 23:57:32 +00003005 case STMT_OBJC_AT_TRY:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003006 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003007 Record[ASTStmtReader::NumStmtFields],
3008 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003009 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003010
Sebastian Redl539c5062010-08-18 23:57:32 +00003011 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003012 S = new (Context) ObjCAtSynchronizedStmt(Empty);
3013 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003014
Sebastian Redl539c5062010-08-18 23:57:32 +00003015 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003016 S = new (Context) ObjCAtThrowStmt(Empty);
3017 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003018
John McCall31168b02011-06-15 23:02:42 +00003019 case STMT_OBJC_AUTORELEASE_POOL:
3020 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3021 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003022
Ted Kremeneke65b0862012-03-06 20:05:56 +00003023 case EXPR_OBJC_BOOL_LITERAL:
3024 S = new (Context) ObjCBoolLiteralExpr(Empty);
3025 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003026
Erik Pilkington29099de2016-07-16 00:35:23 +00003027 case EXPR_OBJC_AVAILABILITY_CHECK:
3028 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3029 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003030
Nico Weber9b982072014-07-07 00:12:30 +00003031 case STMT_SEH_LEAVE:
3032 S = new (Context) SEHLeaveStmt(Empty);
3033 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003034
John McCallfa194042011-07-15 07:00:14 +00003035 case STMT_SEH_EXCEPT:
3036 S = new (Context) SEHExceptStmt(Empty);
3037 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003038
John McCallfa194042011-07-15 07:00:14 +00003039 case STMT_SEH_FINALLY:
3040 S = new (Context) SEHFinallyStmt(Empty);
3041 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003042
John McCallfa194042011-07-15 07:00:14 +00003043 case STMT_SEH_TRY:
3044 S = new (Context) SEHTryStmt(Empty);
3045 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003046
Sebastian Redl539c5062010-08-18 23:57:32 +00003047 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003048 S = new (Context) CXXCatchStmt(Empty);
3049 break;
3050
Sebastian Redl539c5062010-08-18 23:57:32 +00003051 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003052 S = CXXTryStmt::Create(Context, Empty,
Rui Ueyama49a3ad22019-07-16 04:46:31 +00003053 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00003054 break;
3055
Richard Smith02e85f32011-04-14 22:09:26 +00003056 case STMT_CXX_FOR_RANGE:
3057 S = new (Context) CXXForRangeStmt(Empty);
3058 break;
3059
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003060 case STMT_MS_DEPENDENT_EXISTS:
3061 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3062 NestedNameSpecifierLoc(),
3063 DeclarationNameInfo(),
Craig Toppera13603a2014-05-22 05:54:18 +00003064 nullptr);
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00003065 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003066
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00003067 case STMT_OMP_PARALLEL_DIRECTIVE:
3068 S =
3069 OMPParallelDirective::CreateEmpty(Context,
3070 Record[ASTStmtReader::NumStmtFields],
3071 Empty);
3072 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003073
3074 case STMT_OMP_SIMD_DIRECTIVE: {
3075 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3076 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3077 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3078 CollapsedNum, Empty);
3079 break;
3080 }
3081
Alexey Bataevf29276e2014-06-18 04:14:57 +00003082 case STMT_OMP_FOR_DIRECTIVE: {
3083 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3084 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3085 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3086 Empty);
3087 break;
3088 }
3089
Alexander Musmanf82886e2014-09-18 05:12:34 +00003090 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3091 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3092 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3093 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3094 Empty);
3095 break;
3096 }
3097
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00003098 case STMT_OMP_SECTIONS_DIRECTIVE:
3099 S = OMPSectionsDirective::CreateEmpty(
3100 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3101 break;
3102
Alexey Bataev1e0498a2014-06-26 08:21:58 +00003103 case STMT_OMP_SECTION_DIRECTIVE:
3104 S = OMPSectionDirective::CreateEmpty(Context, Empty);
3105 break;
3106
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00003107 case STMT_OMP_SINGLE_DIRECTIVE:
3108 S = OMPSingleDirective::CreateEmpty(
3109 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3110 break;
3111
Alexander Musman80c22892014-07-17 08:54:58 +00003112 case STMT_OMP_MASTER_DIRECTIVE:
3113 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3114 break;
3115
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003116 case STMT_OMP_CRITICAL_DIRECTIVE:
Alexey Bataev28c75412015-12-15 08:19:24 +00003117 S = OMPCriticalDirective::CreateEmpty(
3118 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003119 break;
3120
Alexey Bataev4acb8592014-07-07 13:01:15 +00003121 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3122 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3123 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3124 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3125 CollapsedNum, Empty);
3126 break;
3127 }
3128
Alexander Musmane4e893b2014-09-23 09:33:00 +00003129 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3130 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3131 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3132 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3133 CollapsedNum, Empty);
3134 break;
3135 }
3136
cchen47d60942019-12-05 13:43:48 -05003137 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3138 S = OMPParallelMasterDirective::CreateEmpty(
3139 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3140 break;
3141
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00003142 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3143 S = OMPParallelSectionsDirective::CreateEmpty(
3144 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3145 break;
3146
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00003147 case STMT_OMP_TASK_DIRECTIVE:
3148 S = OMPTaskDirective::CreateEmpty(
3149 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3150 break;
3151
Alexey Bataev68446b72014-07-18 07:47:19 +00003152 case STMT_OMP_TASKYIELD_DIRECTIVE:
3153 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3154 break;
3155
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00003156 case STMT_OMP_BARRIER_DIRECTIVE:
3157 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3158 break;
3159
Alexey Bataev2df347a2014-07-18 10:17:07 +00003160 case STMT_OMP_TASKWAIT_DIRECTIVE:
3161 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3162 break;
3163
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003164 case STMT_OMP_TASKGROUP_DIRECTIVE:
Alexey Bataev169d96a2017-07-18 20:17:46 +00003165 S = OMPTaskgroupDirective::CreateEmpty(
3166 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003167 break;
3168
Alexey Bataev6125da92014-07-21 11:26:11 +00003169 case STMT_OMP_FLUSH_DIRECTIVE:
3170 S = OMPFlushDirective::CreateEmpty(
3171 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3172 break;
3173
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003174 case STMT_OMP_ORDERED_DIRECTIVE:
Alexey Bataev346265e2015-09-25 10:37:12 +00003175 S = OMPOrderedDirective::CreateEmpty(
3176 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003177 break;
3178
Alexey Bataev0162e452014-07-22 10:10:35 +00003179 case STMT_OMP_ATOMIC_DIRECTIVE:
3180 S = OMPAtomicDirective::CreateEmpty(
3181 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3182 break;
3183
Alexey Bataev0bd520b2014-09-19 08:19:49 +00003184 case STMT_OMP_TARGET_DIRECTIVE:
3185 S = OMPTargetDirective::CreateEmpty(
3186 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3187 break;
3188
Michael Wong65f367f2015-07-21 13:44:28 +00003189 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3190 S = OMPTargetDataDirective::CreateEmpty(
3191 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3192 break;
3193
Samuel Antaodf67fc42016-01-19 19:15:56 +00003194 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3195 S = OMPTargetEnterDataDirective::CreateEmpty(
3196 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3197 break;
3198
Samuel Antao72590762016-01-19 20:04:50 +00003199 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3200 S = OMPTargetExitDataDirective::CreateEmpty(
3201 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3202 break;
3203
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00003204 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3205 S = OMPTargetParallelDirective::CreateEmpty(
3206 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3207 break;
3208
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00003209 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3210 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3211 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3212 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3213 CollapsedNum, Empty);
3214 break;
3215 }
3216
Samuel Antao686c70c2016-05-26 17:30:50 +00003217 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3218 S = OMPTargetUpdateDirective::CreateEmpty(
3219 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3220 break;
3221
Alexey Bataev13314bf2014-10-09 04:18:56 +00003222 case STMT_OMP_TEAMS_DIRECTIVE:
3223 S = OMPTeamsDirective::CreateEmpty(
3224 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3225 break;
3226
Alexey Bataev6d4ed052015-07-01 06:57:41 +00003227 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3228 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3229 break;
3230
Alexey Bataev80909872015-07-02 11:25:17 +00003231 case STMT_OMP_CANCEL_DIRECTIVE:
Alexey Bataev87933c72015-09-18 08:07:34 +00003232 S = OMPCancelDirective::CreateEmpty(
3233 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev80909872015-07-02 11:25:17 +00003234 break;
3235
Alexey Bataev49f6e782015-12-01 04:18:41 +00003236 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3237 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3238 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3239 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3240 Empty);
3241 break;
3242 }
3243
Alexey Bataev0a6ed842015-12-03 09:40:15 +00003244 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3245 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3246 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3247 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3248 CollapsedNum, Empty);
3249 break;
3250 }
3251
Alexey Bataev60e51c42019-10-10 20:13:02 +00003252 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3253 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3254 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3255 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3256 CollapsedNum, Empty);
3257 break;
3258 }
3259
Alexey Bataevb8552ab2019-10-18 16:47:35 +00003260 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3261 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3262 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3263 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3264 CollapsedNum, Empty);
3265 break;
3266 }
3267
Alexey Bataev5bbcead2019-10-14 17:17:41 +00003268 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3269 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3270 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3271 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3272 CollapsedNum, Empty);
3273 break;
3274 }
3275
Alexey Bataev14a388f2019-10-25 10:27:13 -04003276 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3277 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3278 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3279 S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3280 Context, NumClauses, CollapsedNum, Empty);
3281 break;
3282 }
3283
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00003284 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3285 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3286 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3287 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3288 Empty);
3289 break;
3290 }
3291
Carlo Bertolli9925f152016-06-27 14:55:37 +00003292 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3293 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3294 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3295 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3296 CollapsedNum, Empty);
3297 break;
3298 }
3299
Kelvin Li4a39add2016-07-05 05:00:15 +00003300 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3301 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3302 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3303 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3304 CollapsedNum,
3305 Empty);
3306 break;
3307 }
3308
Kelvin Li787f3fc2016-07-06 04:45:38 +00003309 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3310 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3311 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3312 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3313 CollapsedNum, Empty);
3314 break;
3315 }
3316
Kelvin Lia579b912016-07-14 02:54:56 +00003317 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3318 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3319 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3320 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3321 CollapsedNum, Empty);
3322 break;
3323 }
3324
Kelvin Li986330c2016-07-20 22:57:10 +00003325 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3326 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3327 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3328 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3329 Empty);
3330 break;
3331 }
3332
Kelvin Li83c451e2016-12-25 04:52:54 +00003333 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
Kelvin Li02532872016-08-05 14:37:37 +00003334 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3335 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3336 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3337 CollapsedNum, Empty);
3338 break;
3339 }
3340
Kelvin Li4e325f72016-10-25 12:50:55 +00003341 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3342 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3343 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3344 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3345 CollapsedNum, Empty);
3346 break;
3347 }
3348
Kelvin Li579e41c2016-11-30 23:51:03 +00003349 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3350 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3351 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3352 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3353 Context, NumClauses, CollapsedNum, Empty);
3354 break;
3355 }
3356
Kelvin Li7ade93f2016-12-09 03:24:30 +00003357 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3358 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3359 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3360 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3361 Context, NumClauses, CollapsedNum, Empty);
3362 break;
3363 }
3364
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003365 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
Kelvin Libf594a52016-12-17 05:48:59 +00003366 S = OMPTargetTeamsDirective::CreateEmpty(
3367 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3368 break;
Kelvin Li83c451e2016-12-25 04:52:54 +00003369
3370 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3371 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3372 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3373 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3374 CollapsedNum, Empty);
3375 break;
3376 }
3377
Kelvin Li80e8f562016-12-29 22:16:30 +00003378 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3379 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3380 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3381 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3382 Context, NumClauses, CollapsedNum, Empty);
3383 break;
3384 }
3385
Kelvin Li1851df52017-01-03 05:23:48 +00003386 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3387 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3388 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3389 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3390 Context, NumClauses, CollapsedNum, Empty);
3391 break;
3392 }
3393
Kelvin Lida681182017-01-10 18:08:18 +00003394 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3395 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3396 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3397 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3398 Context, NumClauses, CollapsedNum, Empty);
3399 break;
3400 }
3401
Sebastian Redl539c5062010-08-18 23:57:32 +00003402 case EXPR_CXX_OPERATOR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003403 S = CXXOperatorCallExpr::CreateEmpty(
3404 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00003405 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003406
Sebastian Redl539c5062010-08-18 23:57:32 +00003407 case EXPR_CXX_MEMBER_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003408 S = CXXMemberCallExpr::CreateEmpty(
3409 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003410 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003411
Richard Smith778dc0f2019-10-19 00:04:38 +00003412 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3413 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3414 break;
3415
Sebastian Redl539c5062010-08-18 23:57:32 +00003416 case EXPR_CXX_CONSTRUCT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003417 S = CXXConstructExpr::CreateEmpty(
3418 Context,
3419 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003420 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003421
Richard Smith5179eb72016-06-28 19:03:57 +00003422 case EXPR_CXX_INHERITED_CTOR_INIT:
3423 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3424 break;
3425
Sebastian Redl539c5062010-08-18 23:57:32 +00003426 case EXPR_CXX_TEMPORARY_OBJECT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003427 S = CXXTemporaryObjectExpr::CreateEmpty(
3428 Context,
3429 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00003430 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003431
Sebastian Redl539c5062010-08-18 23:57:32 +00003432 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003433 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003434 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003435 break;
3436
Sebastian Redl539c5062010-08-18 23:57:32 +00003437 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003438 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003439 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003440 break;
3441
Sebastian Redl539c5062010-08-18 23:57:32 +00003442 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003443 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003444 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003445 break;
3446
Sebastian Redl539c5062010-08-18 23:57:32 +00003447 case EXPR_CXX_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003448 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00003449 break;
3450
Sebastian Redl539c5062010-08-18 23:57:32 +00003451 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003452 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003453 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003454 break;
3455
Richard Smithc67fdd42012-03-07 08:35:16 +00003456 case EXPR_USER_DEFINED_LITERAL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003457 S = UserDefinedLiteral::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003458 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Richard Smithc67fdd42012-03-07 08:35:16 +00003459 break;
3460
Richard Smithcc1b96d2013-06-12 22:31:48 +00003461 case EXPR_CXX_STD_INITIALIZER_LIST:
3462 S = new (Context) CXXStdInitializerListExpr(Empty);
3463 break;
3464
Sebastian Redl539c5062010-08-18 23:57:32 +00003465 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003466 S = new (Context) CXXBoolLiteralExpr(Empty);
3467 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003468
Sebastian Redl539c5062010-08-18 23:57:32 +00003469 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003470 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3471 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003472
Sebastian Redl539c5062010-08-18 23:57:32 +00003473 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003474 S = new (Context) CXXTypeidExpr(Empty, true);
3475 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003476
Sebastian Redl539c5062010-08-18 23:57:32 +00003477 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003478 S = new (Context) CXXTypeidExpr(Empty, false);
3479 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003480
Francois Pichet9f4f2072010-09-08 12:20:18 +00003481 case EXPR_CXX_UUIDOF_EXPR:
3482 S = new (Context) CXXUuidofExpr(Empty, true);
3483 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003484
John McCall5e77d762013-04-16 07:28:30 +00003485 case EXPR_CXX_PROPERTY_REF_EXPR:
3486 S = new (Context) MSPropertyRefExpr(Empty);
3487 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003488
Alexey Bataevf7630272015-11-25 12:01:00 +00003489 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3490 S = new (Context) MSPropertySubscriptExpr(Empty);
3491 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003492
Francois Pichet9f4f2072010-09-08 12:20:18 +00003493 case EXPR_CXX_UUIDOF_TYPE:
3494 S = new (Context) CXXUuidofExpr(Empty, false);
3495 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003496
Sebastian Redl539c5062010-08-18 23:57:32 +00003497 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00003498 S = new (Context) CXXThisExpr(Empty);
3499 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003500
Sebastian Redl539c5062010-08-18 23:57:32 +00003501 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00003502 S = new (Context) CXXThrowExpr(Empty);
3503 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003504
John McCall32791cc2016-01-06 22:34:54 +00003505 case EXPR_CXX_DEFAULT_ARG:
3506 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00003507 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003508
Richard Smith852c9db2013-04-20 22:23:05 +00003509 case EXPR_CXX_DEFAULT_INIT:
3510 S = new (Context) CXXDefaultInitExpr(Empty);
3511 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003512
Sebastian Redl539c5062010-08-18 23:57:32 +00003513 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00003514 S = new (Context) CXXBindTemporaryExpr(Empty);
3515 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003516
Sebastian Redl539c5062010-08-18 23:57:32 +00003517 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00003518 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003519 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003520
Sebastian Redl539c5062010-08-18 23:57:32 +00003521 case EXPR_CXX_NEW:
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00003522 S = CXXNewExpr::CreateEmpty(
3523 Context,
3524 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3525 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3526 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3527 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003528 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003529
Sebastian Redl539c5062010-08-18 23:57:32 +00003530 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00003531 S = new (Context) CXXDeleteExpr(Empty);
3532 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003533
Sebastian Redl539c5062010-08-18 23:57:32 +00003534 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00003535 S = new (Context) CXXPseudoDestructorExpr(Empty);
3536 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003537
John McCall5d413782010-12-06 08:20:24 +00003538 case EXPR_EXPR_WITH_CLEANUPS:
John McCall28fc7092011-11-10 05:35:25 +00003539 S = ExprWithCleanups::Create(Context, Empty,
3540 Record[ASTStmtReader::NumExprFields]);
Chris Lattnercba86142010-05-10 00:25:06 +00003541 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003542
Sebastian Redl539c5062010-08-18 23:57:32 +00003543 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Bruno Ricci2e6dc532019-01-08 14:17:00 +00003544 S = CXXDependentScopeMemberExpr::CreateEmpty(
3545 Context,
3546 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3547 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3548 /*HasFirstQualifierFoundInScope=*/
3549 Record[ASTStmtReader::NumExprFields + 2]);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003550 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003551
Sebastian Redl539c5062010-08-18 23:57:32 +00003552 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003553 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003554 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003555 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003556 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003557 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00003558 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003559
Sebastian Redl539c5062010-08-18 23:57:32 +00003560 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003561 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003562 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00003563 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003564
Sebastian Redl539c5062010-08-18 23:57:32 +00003565 case EXPR_CXX_UNRESOLVED_MEMBER:
Bruno Riccid7628d92019-01-09 15:43:19 +00003566 S = UnresolvedMemberExpr::CreateEmpty(
3567 Context,
3568 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3569 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3570 /*NumTemplateArgs=*/
3571 Record[ASTStmtReader::NumExprFields + 1]
3572 ? Record[ASTStmtReader::NumExprFields + 2]
3573 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003574 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003575
Sebastian Redl539c5062010-08-18 23:57:32 +00003576 case EXPR_CXX_UNRESOLVED_LOOKUP:
Bruno Riccid7628d92019-01-09 15:43:19 +00003577 S = UnresolvedLookupExpr::CreateEmpty(
3578 Context,
3579 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3580 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3581 /*NumTemplateArgs=*/
3582 Record[ASTStmtReader::NumExprFields + 1]
3583 ? Record[ASTStmtReader::NumExprFields + 2]
3584 : 0);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00003585 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003586
Douglas Gregor29c42f22012-02-24 07:38:34 +00003587 case EXPR_TYPE_TRAIT:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003588 S = TypeTraitExpr::CreateDeserialized(Context,
Douglas Gregor29c42f22012-02-24 07:38:34 +00003589 Record[ASTStmtReader::NumExprFields]);
3590 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003591
John Wiegley6242b6a2011-04-28 00:16:57 +00003592 case EXPR_ARRAY_TYPE_TRAIT:
3593 S = new (Context) ArrayTypeTraitExpr(Empty);
3594 break;
3595
John Wiegleyf9f65842011-04-25 06:54:41 +00003596 case EXPR_CXX_EXPRESSION_TRAIT:
3597 S = new (Context) ExpressionTraitExpr(Empty);
3598 break;
3599
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003600 case EXPR_CXX_NOEXCEPT:
3601 S = new (Context) CXXNoexceptExpr(Empty);
3602 break;
John McCall8d69a212010-11-15 23:31:06 +00003603
Douglas Gregore8e9dd62011-01-03 17:17:50 +00003604 case EXPR_PACK_EXPANSION:
3605 S = new (Context) PackExpansionExpr(Empty);
3606 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003607
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003608 case EXPR_SIZEOF_PACK:
Richard Smithd784e682015-09-23 21:41:42 +00003609 S = SizeOfPackExpr::CreateDeserialized(
3610 Context,
3611 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003612 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003613
John McCallfa194042011-07-15 07:00:14 +00003614 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3615 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3616 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003617
Douglas Gregorcdbc5392011-01-15 01:15:58 +00003618 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3619 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3620 break;
Richard Smithb15fe3a2012-09-12 00:56:43 +00003621
3622 case EXPR_FUNCTION_PARM_PACK:
3623 S = FunctionParmPackExpr::CreateEmpty(Context,
3624 Record[ASTStmtReader::NumExprFields]);
3625 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003626
Douglas Gregorfe314812011-06-21 17:03:29 +00003627 case EXPR_MATERIALIZE_TEMPORARY:
3628 S = new (Context) MaterializeTemporaryExpr(Empty);
3629 break;
Richard Smith0f0af192014-11-08 05:07:16 +00003630
3631 case EXPR_CXX_FOLD:
3632 S = new (Context) CXXFoldExpr(Empty);
3633 break;
3634
Argyrios Kyrtzidisb2b07952011-12-03 03:49:52 +00003635 case EXPR_OPAQUE_VALUE:
3636 S = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00003637 break;
Peter Collingbourne41f85462011-02-09 21:07:24 +00003638
3639 case EXPR_CUDA_KERNEL_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003640 S = CUDAKernelCallExpr::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003641 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00003642 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003643
Tanya Lattner55808c12011-06-04 00:47:47 +00003644 case EXPR_ASTYPE:
3645 S = new (Context) AsTypeExpr(Empty);
3646 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003647
John McCallfe96e0b2011-11-06 09:01:30 +00003648 case EXPR_PSEUDO_OBJECT: {
3649 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3650 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3651 break;
3652 }
3653
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003654 case EXPR_ATOMIC:
3655 S = new (Context) AtomicExpr(Empty);
3656 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003657
Douglas Gregor99ae8062012-02-14 17:54:36 +00003658 case EXPR_LAMBDA: {
3659 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
Richard Smith30e304e2016-12-14 00:03:17 +00003660 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
Douglas Gregor99ae8062012-02-14 17:54:36 +00003661 break;
3662 }
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +00003663
3664 case STMT_COROUTINE_BODY: {
3665 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3666 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3667 break;
3668 }
3669
3670 case STMT_CORETURN:
3671 S = new (Context) CoreturnStmt(Empty);
3672 break;
3673
3674 case EXPR_COAWAIT:
3675 S = new (Context) CoawaitExpr(Empty);
3676 break;
3677
3678 case EXPR_COYIELD:
3679 S = new (Context) CoyieldExpr(Empty);
3680 break;
3681
3682 case EXPR_DEPENDENT_COAWAIT:
3683 S = new (Context) DependentCoawaitExpr(Empty);
3684 break;
Saar Raz5d98ba62019-10-15 15:24:26 +00003685
Saar Raza0f50d72020-01-18 09:11:43 +02003686 case EXPR_CONCEPT_SPECIALIZATION: {
Saar Raz5d98ba62019-10-15 15:24:26 +00003687 unsigned numTemplateArgs = Record[ASTStmtReader::NumExprFields];
3688 S = ConceptSpecializationExpr::Create(Context, Empty, numTemplateArgs);
3689 break;
Saar Raza0f50d72020-01-18 09:11:43 +02003690 }
3691
3692 case EXPR_REQUIRES:
3693 unsigned numLocalParameters = Record[ASTStmtReader::NumExprFields];
3694 unsigned numRequirement = Record[ASTStmtReader::NumExprFields + 1];
3695 S = RequiresExpr::Create(Context, Empty, numLocalParameters,
3696 numRequirement);
3697 break;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003698 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003699
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003700 // We hit a STMT_STOP, so we're done with this expression.
3701 if (Finished)
3702 break;
3703
3704 ++NumStatementsRead;
3705
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003706 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003707 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003708 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3709 }
3710
David L. Jonesbe1557a2016-12-21 00:17:49 +00003711 assert(Record.getIdx() == Record.size() &&
3712 "Invalid deserialization of statement");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003713 StmtStack.push_back(S);
3714 }
Chris Lattner0e6c9402013-01-20 02:38:54 +00003715Done:
Alp Toker028ed912013-12-06 17:56:43 +00003716 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003717 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003718 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003719}