blob: 5d7c6762061c80b9f629c2f4915ee2fc499d58e9 [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
Sebastian Redlf5b13462010-08-18 23:57:17 +000014#include "clang/Serialization/ASTReader.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> {
Alexey Bataev5ec3eb12013-07-19 03:13:43 +000070 friend class OMPClauseReader;
David L. Jonesc4808b9e2016-12-15 20:53:26 +000071
David L. Jonesbe1557a2016-12-21 00:17:49 +000072 ASTRecordReader &Record;
Sebastian Redlc67764e2010-07-22 22:43:28 +000073 llvm::BitstreamCursor &DeclsCursor;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000074
John McCall3ce3d232019-12-13 03:37:23 -050075 SourceLocation readSourceLocation() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000076 return Record.readSourceLocation();
John McCallf413f5e2013-05-03 00:10:13 +000077 }
78
John McCall3ce3d232019-12-13 03:37:23 -050079 SourceRange readSourceRange() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000080 return Record.readSourceRange();
Sebastian Redl2c373b92010-10-05 15:59:54 +000081 }
John McCallf413f5e2013-05-03 00:10:13 +000082
John McCall3ce3d232019-12-13 03:37:23 -050083 std::string readString() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000084 return Record.readString();
Sebastian Redl2c373b92010-10-05 15:59:54 +000085 }
John McCallf413f5e2013-05-03 00:10:13 +000086
John McCall3ce3d232019-12-13 03:37:23 -050087 TypeSourceInfo *readTypeSourceInfo() {
88 return Record.readTypeSourceInfo();
John McCallf413f5e2013-05-03 00:10:13 +000089 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000090
John McCall3ce3d232019-12-13 03:37:23 -050091 Decl *readDecl() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000092 return Record.readDecl();
Sebastian Redl2c373b92010-10-05 15:59:54 +000093 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000094
Douglas Gregor7fb09192011-07-21 22:35:25 +000095 template<typename T>
John McCall3ce3d232019-12-13 03:37:23 -050096 T *readDeclAs() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000097 return Record.readDeclAs<T>();
Douglas Gregor7fb09192011-07-21 22:35:25 +000098 }
99
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000100 public:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000101 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
102 : Record(Record), DeclsCursor(Cursor) {}
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000103
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000104 /// The number of record fields required for the Stmt class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000105 /// itself.
Roman Lebedevb5700602019-03-20 16:32:36 +0000106 static const unsigned NumStmtFields = 1;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000107
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000108 /// The number of record fields required for the Expr class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000109 /// itself.
Douglas Gregor678d76c2011-07-01 01:22:09 +0000110 static const unsigned NumExprFields = NumStmtFields + 7;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000111
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000112 /// Read and initialize a ExplicitTemplateArgumentList structure.
Abramo Bagnara7945c982012-01-27 09:46:47 +0000113 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
James Y Knighte7d82282015-12-29 18:15:14 +0000114 TemplateArgumentLoc *ArgsLocArray,
Abramo Bagnara7945c982012-01-27 09:46:47 +0000115 unsigned NumTemplateArgs);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000116
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000117 /// Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisde6aa082011-09-22 20:07:03 +0000118 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000119 unsigned NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000120
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000121 void VisitStmt(Stmt *S);
John McCallfa194042011-07-15 07:00:14 +0000122#define STMT(Type, Base) \
123 void Visit##Type(Type *);
124#include "clang/AST/StmtNodes.inc"
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000125 };
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000126
127} // namespace clang
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000128
James Y Knighte7d82282015-12-29 18:15:14 +0000129void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
130 TemplateArgumentLoc *ArgsLocArray,
131 unsigned NumTemplateArgs) {
John McCall3ce3d232019-12-13 03:37:23 -0500132 SourceLocation TemplateKWLoc = readSourceLocation();
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000133 TemplateArgumentListInfo ArgInfo;
John McCall3ce3d232019-12-13 03:37:23 -0500134 ArgInfo.setLAngleLoc(readSourceLocation());
135 ArgInfo.setRAngleLoc(readSourceLocation());
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000136 for (unsigned i = 0; i != NumTemplateArgs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000137 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
James Y Knighte7d82282015-12-29 18:15:14 +0000138 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000139}
140
Sebastian Redl70c751d2010-08-18 23:56:52 +0000141void ASTStmtReader::VisitStmt(Stmt *S) {
Roman Lebedevb5700602019-03-20 16:32:36 +0000142 S->setIsOMPStructuredBlock(Record.readInt());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000143 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000144}
145
Sebastian Redl70c751d2010-08-18 23:56:52 +0000146void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000147 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500148 S->setSemiLoc(readSourceLocation());
Bruno Ricci41d11c02018-10-27 18:43:27 +0000149 S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000150}
151
Sebastian Redl70c751d2010-08-18 23:56:52 +0000152void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000153 VisitStmt(S);
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000154 SmallVector<Stmt *, 16> Stmts;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000155 unsigned NumStmts = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000156 while (NumStmts--)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000157 Stmts.push_back(Record.readSubStmt());
Benjamin Kramer07420902017-12-24 16:24:20 +0000158 S->setStmts(Stmts);
John McCall3ce3d232019-12-13 03:37:23 -0500159 S->CompoundStmtBits.LBraceLoc = readSourceLocation();
160 S->RBraceLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000161}
162
Sebastian Redl70c751d2010-08-18 23:56:52 +0000163void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000164 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000165 Record.recordSwitchCaseID(S, Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500166 S->setKeywordLoc(readSourceLocation());
167 S->setColonLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000168}
169
Sebastian Redl70c751d2010-08-18 23:56:52 +0000170void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000171 VisitSwitchCase(S);
Bruno Ricci5b30571752018-10-28 12:30:53 +0000172 bool CaseStmtIsGNURange = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000173 S->setLHS(Record.readSubExpr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000174 S->setSubStmt(Record.readSubStmt());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000175 if (CaseStmtIsGNURange) {
176 S->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500177 S->setEllipsisLoc(readSourceLocation());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000178 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000179}
180
Sebastian Redl70c751d2010-08-18 23:56:52 +0000181void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000182 VisitSwitchCase(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000183 S->setSubStmt(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000184}
185
Sebastian Redl70c751d2010-08-18 23:56:52 +0000186void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000187 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500188 auto *LD = readDeclAs<LabelDecl>();
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000189 LD->setStmt(S);
190 S->setDecl(LD);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000191 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500192 S->setIdentLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000193}
194
Richard Smithc202b282012-04-14 00:33:13 +0000195void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
196 VisitStmt(S);
Bruno Ricci41d11c02018-10-27 18:43:27 +0000197 // NumAttrs in AttributedStmt is set when creating an empty
198 // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
199 // to allocate the right amount of space for the trailing Attr *.
David L. Jonesbe1557a2016-12-21 00:17:49 +0000200 uint64_t NumAttrs = Record.readInt();
Richard Smithc202b282012-04-14 00:33:13 +0000201 AttrVec Attrs;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000202 Record.readAttributes(Attrs);
Matt Beaumont-Gayad0bb8e2012-07-09 18:55:31 +0000203 (void)NumAttrs;
Bruno Ricci41d11c02018-10-27 18:43:27 +0000204 assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
Alexander Kornienko20f6fc62012-07-09 10:04:07 +0000205 assert(NumAttrs == Attrs.size());
Aaron Ballmanf3d9b092014-05-13 14:55:01 +0000206 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000207 S->SubStmt = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500208 S->AttributedStmtBits.AttrLoc = readSourceLocation();
Richard Smithc202b282012-04-14 00:33:13 +0000209}
210
Sebastian Redl70c751d2010-08-18 23:56:52 +0000211void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000212 VisitStmt(S);
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000213
David L. Jonesbe1557a2016-12-21 00:17:49 +0000214 S->setConstexpr(Record.readInt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000215 bool HasElse = Record.readInt();
216 bool HasVar = Record.readInt();
217 bool HasInit = Record.readInt();
218
David L. Jonesb6a8f022016-12-21 04:34:52 +0000219 S->setCond(Record.readSubExpr());
220 S->setThen(Record.readSubStmt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000221 if (HasElse)
222 S->setElse(Record.readSubStmt());
223 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500224 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000225 if (HasInit)
226 S->setInit(Record.readSubStmt());
227
John McCall3ce3d232019-12-13 03:37:23 -0500228 S->setIfLoc(readSourceLocation());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000229 if (HasElse)
John McCall3ce3d232019-12-13 03:37:23 -0500230 S->setElseLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000231}
232
Sebastian Redl70c751d2010-08-18 23:56:52 +0000233void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000234 VisitStmt(S);
Bruno Riccie2806f82018-10-29 16:12:37 +0000235
236 bool HasInit = Record.readInt();
237 bool HasVar = Record.readInt();
238 bool AllEnumCasesCovered = Record.readInt();
239 if (AllEnumCasesCovered)
240 S->setAllEnumCasesCovered();
241
David L. Jonesb6a8f022016-12-21 04:34:52 +0000242 S->setCond(Record.readSubExpr());
243 S->setBody(Record.readSubStmt());
Bruno Riccie2806f82018-10-29 16:12:37 +0000244 if (HasInit)
245 S->setInit(Record.readSubStmt());
246 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500247 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccie2806f82018-10-29 16:12:37 +0000248
John McCall3ce3d232019-12-13 03:37:23 -0500249 S->setSwitchLoc(readSourceLocation());
Ted Kremenekc42f3452010-09-09 00:05:53 +0000250
Craig Toppera13603a2014-05-22 05:54:18 +0000251 SwitchCase *PrevSC = nullptr;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000252 for (auto E = Record.size(); Record.getIdx() != E; ) {
253 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000254 if (PrevSC)
255 PrevSC->setNextSwitchCase(SC);
256 else
257 S->setSwitchCaseList(SC);
Mike Stump11289f42009-09-09 15:08:12 +0000258
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000259 PrevSC = SC;
260 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000261}
262
Sebastian Redl70c751d2010-08-18 23:56:52 +0000263void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000264 VisitStmt(S);
Bruno Riccibacf7512018-10-30 13:42:41 +0000265
266 bool HasVar = Record.readInt();
Douglas Gregor7fb09192011-07-21 22:35:25 +0000267
David L. Jonesb6a8f022016-12-21 04:34:52 +0000268 S->setCond(Record.readSubExpr());
269 S->setBody(Record.readSubStmt());
Bruno Riccibacf7512018-10-30 13:42:41 +0000270 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500271 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccibacf7512018-10-30 13:42:41 +0000272
John McCall3ce3d232019-12-13 03:37:23 -0500273 S->setWhileLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000274}
275
Sebastian Redl70c751d2010-08-18 23:56:52 +0000276void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000277 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000278 S->setCond(Record.readSubExpr());
279 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500280 S->setDoLoc(readSourceLocation());
281 S->setWhileLoc(readSourceLocation());
282 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000283}
284
Sebastian Redl70c751d2010-08-18 23:56:52 +0000285void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000286 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000287 S->setInit(Record.readSubStmt());
288 S->setCond(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500289 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000290 S->setInc(Record.readSubExpr());
291 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500292 S->setForLoc(readSourceLocation());
293 S->setLParenLoc(readSourceLocation());
294 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000295}
296
Sebastian Redl70c751d2010-08-18 23:56:52 +0000297void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000298 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500299 S->setLabel(readDeclAs<LabelDecl>());
300 S->setGotoLoc(readSourceLocation());
301 S->setLabelLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000302}
303
Sebastian Redl70c751d2010-08-18 23:56:52 +0000304void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000305 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500306 S->setGotoLoc(readSourceLocation());
307 S->setStarLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000308 S->setTarget(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000309}
310
Sebastian Redl70c751d2010-08-18 23:56:52 +0000311void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000312 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500313 S->setContinueLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000314}
315
Sebastian Redl70c751d2010-08-18 23:56:52 +0000316void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000317 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500318 S->setBreakLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000319}
320
Sebastian Redl70c751d2010-08-18 23:56:52 +0000321void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000322 VisitStmt(S);
Bruno Ricci023b1d12018-10-30 14:40:49 +0000323
324 bool HasNRVOCandidate = Record.readInt();
325
David L. Jonesb6a8f022016-12-21 04:34:52 +0000326 S->setRetValue(Record.readSubExpr());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000327 if (HasNRVOCandidate)
John McCall3ce3d232019-12-13 03:37:23 -0500328 S->setNRVOCandidate(readDeclAs<VarDecl>());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000329
John McCall3ce3d232019-12-13 03:37:23 -0500330 S->setReturnLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000331}
332
Sebastian Redl70c751d2010-08-18 23:56:52 +0000333void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000334 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500335 S->setStartLoc(readSourceLocation());
336 S->setEndLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000337
David L. Jonesbe1557a2016-12-21 00:17:49 +0000338 if (Record.size() - Record.getIdx() == 1) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000339 // Single declaration
John McCall3ce3d232019-12-13 03:37:23 -0500340 S->setDeclGroup(DeclGroupRef(readDecl()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000341 } else {
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000342 SmallVector<Decl *, 16> Decls;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000343 int N = Record.size() - Record.getIdx();
344 Decls.reserve(N);
345 for (int I = 0; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500346 Decls.push_back(readDecl());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000347 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
Douglas Gregor038c3382009-05-22 22:45:36 +0000348 Decls.data(),
349 Decls.size())));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000350 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000351}
352
John McCallf413f5e2013-05-03 00:10:13 +0000353void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000354 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000355 S->NumOutputs = Record.readInt();
356 S->NumInputs = Record.readInt();
357 S->NumClobbers = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500358 S->setAsmLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000359 S->setVolatile(Record.readInt());
360 S->setSimple(Record.readInt());
John McCallf413f5e2013-05-03 00:10:13 +0000361}
Mike Stump11289f42009-09-09 15:08:12 +0000362
John McCallf413f5e2013-05-03 00:10:13 +0000363void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
364 VisitAsmStmt(S);
Jennifer Yub8fee672019-06-03 15:57:25 +0000365 S->NumLabels = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500366 S->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000367 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000368
John McCallf413f5e2013-05-03 00:10:13 +0000369 unsigned NumOutputs = S->getNumOutputs();
370 unsigned NumInputs = S->getNumInputs();
371 unsigned NumClobbers = S->getNumClobbers();
Jennifer Yub8fee672019-06-03 15:57:25 +0000372 unsigned NumLabels = S->getNumLabels();
John McCallf413f5e2013-05-03 00:10:13 +0000373
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000374 // Outputs and inputs
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000375 SmallVector<IdentifierInfo *, 16> Names;
376 SmallVector<StringLiteral*, 16> Constraints;
377 SmallVector<Stmt*, 16> Exprs;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000378 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -0500379 Names.push_back(Record.readIdentifier());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000380 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
381 Exprs.push_back(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000382 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000383
384 // Constraints
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000385 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000386 for (unsigned I = 0; I != NumClobbers; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000387 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000388
Jennifer Yub8fee672019-06-03 15:57:25 +0000389 // Labels
390 for (unsigned I = 0, N = NumLabels; I != N; ++I)
391 Exprs.push_back(Record.readSubStmt());
392
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000393 S->setOutputsAndInputsAndClobbers(Record.getContext(),
394 Names.data(), Constraints.data(),
395 Exprs.data(), NumOutputs, NumInputs,
Jennifer Yub8fee672019-06-03 15:57:25 +0000396 NumLabels,
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000397 Clobbers.data(), NumClobbers);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000398}
399
Chad Rosier32503022012-06-11 20:47:18 +0000400void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
John McCallf413f5e2013-05-03 00:10:13 +0000401 VisitAsmStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500402 S->LBraceLoc = readSourceLocation();
403 S->EndLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000404 S->NumAsmToks = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500405 std::string AsmStr = readString();
John McCallf413f5e2013-05-03 00:10:13 +0000406
407 // Read the tokens.
408 SmallVector<Token, 16> AsmToks;
409 AsmToks.reserve(S->NumAsmToks);
410 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000411 AsmToks.push_back(Record.readToken());
John McCallf413f5e2013-05-03 00:10:13 +0000412 }
413
414 // The calls to reserve() for the FooData vectors are mandatory to
415 // prevent dead StringRefs in the Foo vectors.
416
417 // Read the clobbers.
418 SmallVector<std::string, 16> ClobbersData;
419 SmallVector<StringRef, 16> Clobbers;
420 ClobbersData.reserve(S->NumClobbers);
421 Clobbers.reserve(S->NumClobbers);
422 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
John McCall3ce3d232019-12-13 03:37:23 -0500423 ClobbersData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000424 Clobbers.push_back(ClobbersData.back());
425 }
426
427 // Read the operands.
428 unsigned NumOperands = S->NumOutputs + S->NumInputs;
429 SmallVector<Expr*, 16> Exprs;
430 SmallVector<std::string, 16> ConstraintsData;
431 SmallVector<StringRef, 16> Constraints;
432 Exprs.reserve(NumOperands);
433 ConstraintsData.reserve(NumOperands);
434 Constraints.reserve(NumOperands);
435 for (unsigned i = 0; i != NumOperands; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000436 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -0500437 ConstraintsData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000438 Constraints.push_back(ConstraintsData.back());
439 }
440
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000441 S->initialize(Record.getContext(), AsmStr, AsmToks,
John McCallf413f5e2013-05-03 00:10:13 +0000442 Constraints, Exprs, Clobbers);
Chad Rosier32503022012-06-11 20:47:18 +0000443}
444
Richard Smith9f690bd2015-10-27 06:02:45 +0000445void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000446 VisitStmt(S);
447 assert(Record.peekInt() == S->NumParams);
448 Record.skipInts(1);
449 auto *StoredStmts = S->getStoredStmts();
450 for (unsigned i = 0;
451 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
452 StoredStmts[i] = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000453}
454
455void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000456 VisitStmt(S);
457 S->CoreturnLoc = Record.readSourceLocation();
458 for (auto &SubStmt: S->SubStmts)
459 SubStmt = Record.readSubStmt();
460 S->IsImplicit = Record.readInt() != 0;
Richard Smith9f690bd2015-10-27 06:02:45 +0000461}
462
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000463void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
464 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500465 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000466 for (auto &SubExpr: E->SubExprs)
467 SubExpr = Record.readSubStmt();
468 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
469 E->setIsImplicit(Record.readInt() != 0);
Richard Smith9f690bd2015-10-27 06:02:45 +0000470}
471
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000472void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
473 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500474 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000475 for (auto &SubExpr: E->SubExprs)
476 SubExpr = Record.readSubStmt();
477 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
Eric Fiselier20f25cb2017-03-06 23:38:15 +0000478}
479
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000480void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
481 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500482 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000483 for (auto &SubExpr: E->SubExprs)
484 SubExpr = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000485}
486
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000487void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
Ben Langmuirce914fc2013-05-03 19:20:19 +0000488 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000489 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500490 S->setCapturedDecl(readDeclAs<CapturedDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000491 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500492 S->setCapturedRecordDecl(readDeclAs<RecordDecl>());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000493
494 // Capture inits
495 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
496 E = S->capture_init_end();
497 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000498 *I = Record.readSubExpr();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000499
500 // Body
David L. Jonesb6a8f022016-12-21 04:34:52 +0000501 S->setCapturedStmt(Record.readSubStmt());
Wei Pan17fbf6e2013-05-04 03:59:06 +0000502 S->getCapturedDecl()->setBody(S->getCapturedStmt());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000503
504 // Captures
Aaron Ballmanc656303a2014-03-14 18:08:33 +0000505 for (auto &I : S->captures()) {
John McCall3ce3d232019-12-13 03:37:23 -0500506 I.VarAndKind.setPointer(readDeclAs<VarDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000507 I.VarAndKind.setInt(
508 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500509 I.Loc = readSourceLocation();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000510 }
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000511}
512
Sebastian Redl70c751d2010-08-18 23:56:52 +0000513void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000514 VisitStmt(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000515 E->setType(Record.readType());
516 E->setTypeDependent(Record.readInt());
517 E->setValueDependent(Record.readInt());
518 E->setInstantiationDependent(Record.readInt());
519 E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
520 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
521 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
522 assert(Record.getIdx() == NumExprFields &&
523 "Incorrect expression field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000524}
525
Bill Wendling7c44da22018-10-31 03:48:47 +0000526void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
527 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000528 E->ConstantExprBits.ResultKind = Record.readInt();
529 switch (E->ConstantExprBits.ResultKind) {
530 case ConstantExpr::RSK_Int64: {
531 E->Int64Result() = Record.readInt();
532 uint64_t tmp = Record.readInt();
533 E->ConstantExprBits.IsUnsigned = tmp & 0x1;
534 E->ConstantExprBits.BitWidth = tmp >> 1;
535 break;
536 }
537 case ConstantExpr::RSK_APValue:
538 E->APValueResult() = Record.readAPValue();
539 }
Bill Wendling7c44da22018-10-31 03:48:47 +0000540 E->setSubExpr(Record.readSubExpr());
541}
542
Sebastian Redl70c751d2010-08-18 23:56:52 +0000543void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000544 VisitExpr(E);
Bruno Ricci17ff0262018-10-27 19:21:19 +0000545 bool HasFunctionName = Record.readInt();
546 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
547 E->PredefinedExprBits.Kind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500548 E->setLocation(readSourceLocation());
Bruno Ricci17ff0262018-10-27 19:21:19 +0000549 if (HasFunctionName)
550 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000551}
552
Sebastian Redl70c751d2010-08-18 23:56:52 +0000553void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000554 VisitExpr(E);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000555
David L. Jonesbe1557a2016-12-21 00:17:49 +0000556 E->DeclRefExprBits.HasQualifier = Record.readInt();
557 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
558 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
559 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
560 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
Richard Smith715f7a12019-06-11 17:50:32 +0000561 E->DeclRefExprBits.NonOdrUseReason = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000562 unsigned NumTemplateArgs = 0;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000563 if (E->hasTemplateKWAndArgsInfo())
David L. Jonesbe1557a2016-12-21 00:17:49 +0000564 NumTemplateArgs = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000565
Chandler Carruth0e439962011-05-01 21:29:53 +0000566 if (E->hasQualifier())
James Y Knighte7d82282015-12-29 18:15:14 +0000567 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
David L. Jonesb6a8f022016-12-21 04:34:52 +0000568 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000569
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000570 if (E->hasFoundDecl())
John McCall3ce3d232019-12-13 03:37:23 -0500571 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000572
Abramo Bagnara7945c982012-01-27 09:46:47 +0000573 if (E->hasTemplateKWAndArgsInfo())
James Y Knighte7d82282015-12-29 18:15:14 +0000574 ReadTemplateKWAndArgsInfo(
575 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
576 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000577
John McCall3ce3d232019-12-13 03:37:23 -0500578 E->setDecl(readDeclAs<ValueDecl>());
579 E->setLocation(readSourceLocation());
580 E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000581}
582
Sebastian Redl70c751d2010-08-18 23:56:52 +0000583void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000584 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500585 E->setLocation(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000586 E->setValue(Record.getContext(), Record.readAPInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000587}
588
Leonard Chandb01c3a2018-06-20 17:19:40 +0000589void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
590 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500591 E->setLocation(readSourceLocation());
Leonard Chandb01c3a2018-06-20 17:19:40 +0000592 E->setValue(Record.getContext(), Record.readAPInt());
593}
594
Sebastian Redl70c751d2010-08-18 23:56:52 +0000595void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000596 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000597 E->setRawSemantics(
598 static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
David L. Jonesbe1557a2016-12-21 00:17:49 +0000599 E->setExact(Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000600 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
John McCall3ce3d232019-12-13 03:37:23 -0500601 E->setLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000602}
603
Sebastian Redl70c751d2010-08-18 23:56:52 +0000604void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000605 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000606 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000607}
608
Sebastian Redl70c751d2010-08-18 23:56:52 +0000609void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000610 VisitExpr(E);
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000611
612 // NumConcatenated, Length and CharByteWidth are set by the empty
613 // ctor since they are needed to allocate storage for the trailing objects.
614 unsigned NumConcatenated = Record.readInt();
615 unsigned Length = Record.readInt();
616 unsigned CharByteWidth = Record.readInt();
617 assert((NumConcatenated == E->getNumConcatenated()) &&
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000618 "Wrong number of concatenated tokens!");
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000619 assert((Length == E->getLength()) && "Wrong Length!");
620 assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
621 E->StringLiteralBits.Kind = Record.readInt();
622 E->StringLiteralBits.IsPascal = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000623
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000624 // The character width is originally computed via mapCharByteWidth.
625 // Check that the deserialized character width is consistant with the result
626 // of calling mapCharByteWidth.
627 assert((CharByteWidth ==
628 StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
629 E->getKind())) &&
630 "Wrong character width!");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000631
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000632 // Deserialize the trailing array of SourceLocation.
633 for (unsigned I = 0; I < NumConcatenated; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500634 E->setStrTokenLoc(I, readSourceLocation());
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000635
636 // Deserialize the trailing array of char holding the string data.
637 char *StrData = E->getStrDataAsChar();
638 for (unsigned I = 0; I < Length * CharByteWidth; ++I)
639 StrData[I] = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000640}
641
Sebastian Redl70c751d2010-08-18 23:56:52 +0000642void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000643 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000644 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500645 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000646 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000647}
648
Sebastian Redl70c751d2010-08-18 23:56:52 +0000649void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000650 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500651 E->setLParen(readSourceLocation());
652 E->setRParen(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000653 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000654}
655
Sebastian Redl70c751d2010-08-18 23:56:52 +0000656void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000657 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000658 unsigned NumExprs = Record.readInt();
Bruno Riccif49e1ca2018-11-20 16:20:40 +0000659 assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
660 for (unsigned I = 0; I != NumExprs; ++I)
661 E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500662 E->LParenLoc = readSourceLocation();
663 E->RParenLoc = readSourceLocation();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000664}
665
Sebastian Redl70c751d2010-08-18 23:56:52 +0000666void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000667 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000668 E->setSubExpr(Record.readSubExpr());
669 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500670 E->setOperatorLoc(readSourceLocation());
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000671 E->setCanOverflow(Record.readInt());
672}
673
674void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000675 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000676 assert(E->getNumComponents() == Record.peekInt());
677 Record.skipInts(1);
678 assert(E->getNumExpressions() == Record.peekInt());
679 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500680 E->setOperatorLoc(readSourceLocation());
681 E->setRParenLoc(readSourceLocation());
682 E->setTypeSourceInfo(readTypeSourceInfo());
Douglas Gregor882211c2010-04-28 22:16:22 +0000683 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000684 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500685 SourceLocation Start = readSourceLocation();
686 SourceLocation End = readSourceLocation();
Douglas Gregor882211c2010-04-28 22:16:22 +0000687 switch (Kind) {
James Y Knight7281c352015-12-29 22:31:18 +0000688 case OffsetOfNode::Array:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000689 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000690 break;
691
James Y Knight7281c352015-12-29 22:31:18 +0000692 case OffsetOfNode::Field:
693 E->setComponent(
John McCall3ce3d232019-12-13 03:37:23 -0500694 I, OffsetOfNode(Start, readDeclAs<FieldDecl>(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000695 break;
James Y Knight7281c352015-12-29 22:31:18 +0000696
697 case OffsetOfNode::Identifier:
698 E->setComponent(
699 I,
John McCall3ce3d232019-12-13 03:37:23 -0500700 OffsetOfNode(Start, Record.readIdentifier(), End));
James Y Knight7281c352015-12-29 22:31:18 +0000701 break;
702
703 case OffsetOfNode::Base: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000704 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000705 *Base = Record.readCXXBaseSpecifier();
James Y Knight7281c352015-12-29 22:31:18 +0000706 E->setComponent(I, OffsetOfNode(Base));
Douglas Gregord1702062010-04-29 00:18:15 +0000707 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000708 }
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000709 }
Douglas Gregor882211c2010-04-28 22:16:22 +0000710 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000711
Douglas Gregor882211c2010-04-28 22:16:22 +0000712 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000713 E->setIndexExpr(I, Record.readSubExpr());
Douglas Gregor882211c2010-04-28 22:16:22 +0000714}
715
Peter Collingbournee190dee2011-03-11 19:24:49 +0000716void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000717 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000718 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
719 if (Record.peekInt() == 0) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000720 E->setArgument(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000721 Record.skipInts(1);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000722 } else {
John McCall3ce3d232019-12-13 03:37:23 -0500723 E->setArgument(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000724 }
John McCall3ce3d232019-12-13 03:37:23 -0500725 E->setOperatorLoc(readSourceLocation());
726 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000727}
728
Saar Raz5d98ba62019-10-15 15:24:26 +0000729void ASTStmtReader::VisitConceptSpecializationExpr(
730 ConceptSpecializationExpr *E) {
731 VisitExpr(E);
732 unsigned NumTemplateArgs = Record.readInt();
733 E->NestedNameSpec = Record.readNestedNameSpecifierLoc();
734 E->TemplateKWLoc = Record.readSourceLocation();
735 E->ConceptNameLoc = Record.readSourceLocation();
John McCall3ce3d232019-12-13 03:37:23 -0500736 E->FoundDecl = readDeclAs<NamedDecl>();
737 E->NamedConcept = readDeclAs<ConceptDecl>();
Saar Raz5d98ba62019-10-15 15:24:26 +0000738 const ASTTemplateArgumentListInfo *ArgsAsWritten =
739 Record.readASTTemplateArgumentListInfo();
740 llvm::SmallVector<TemplateArgument, 4> Args;
741 for (unsigned I = 0; I < NumTemplateArgs; ++I)
742 Args.push_back(Record.readTemplateArgument());
743 E->setTemplateArguments(ArgsAsWritten, Args);
Saar Razfdf80e82019-12-06 01:30:21 +0200744 ConstraintSatisfaction Satisfaction;
745 Satisfaction.IsSatisfied = Record.readInt();
746 if (!Satisfaction.IsSatisfied) {
747 unsigned NumDetailRecords = Record.readInt();
748 for (unsigned i = 0; i != NumDetailRecords; ++i) {
749 Expr *ConstraintExpr = Record.readExpr();
750 bool IsDiagnostic = Record.readInt();
751 if (IsDiagnostic) {
752 SourceLocation DiagLocation = Record.readSourceLocation();
753 std::string DiagMessage = Record.readString();
754 Satisfaction.Details.emplace_back(
755 ConstraintExpr, new (Record.getContext())
756 ConstraintSatisfaction::SubstitutionDiagnostic{
757 DiagLocation, DiagMessage});
758 } else
759 Satisfaction.Details.emplace_back(ConstraintExpr, Record.readExpr());
760 }
761 }
762 E->Satisfaction = ASTConstraintSatisfaction::Create(Record.getContext(),
763 Satisfaction);
Saar Raz5d98ba62019-10-15 15:24:26 +0000764}
765
Sebastian Redl70c751d2010-08-18 23:56:52 +0000766void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000767 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000768 E->setLHS(Record.readSubExpr());
769 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500770 E->setRBracketLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000771}
772
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000773void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
774 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000775 E->setBase(Record.readSubExpr());
776 E->setLowerBound(Record.readSubExpr());
777 E->setLength(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500778 E->setColonLoc(readSourceLocation());
779 E->setRBracketLoc(readSourceLocation());
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000780}
781
Sebastian Redl70c751d2010-08-18 23:56:52 +0000782void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000783 VisitExpr(E);
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000784 unsigned NumArgs = Record.readInt();
785 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
John McCall3ce3d232019-12-13 03:37:23 -0500786 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000787 E->setCallee(Record.readSubExpr());
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000788 for (unsigned I = 0; I != NumArgs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000789 E->setArg(I, Record.readSubExpr());
Eric Fiselier5cdc2cd2018-12-12 21:50:55 +0000790 E->setADLCallKind(static_cast<CallExpr::ADLCallKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000791}
792
John McCallfa194042011-07-15 07:00:14 +0000793void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
794 VisitCallExpr(E);
795}
796
Sebastian Redl70c751d2010-08-18 23:56:52 +0000797void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Richard Smithdcf17de2019-06-06 23:24:15 +0000798 VisitExpr(E);
799
800 bool HasQualifier = Record.readInt();
801 bool HasFoundDecl = Record.readInt();
802 bool HasTemplateInfo = Record.readInt();
803 unsigned NumTemplateArgs = Record.readInt();
804
805 E->Base = Record.readSubExpr();
806 E->MemberDecl = Record.readDeclAs<ValueDecl>();
John McCall3ce3d232019-12-13 03:37:23 -0500807 E->MemberDNLoc = Record.readDeclarationNameLoc(E->MemberDecl->getDeclName());
Richard Smithdcf17de2019-06-06 23:24:15 +0000808 E->MemberLoc = Record.readSourceLocation();
809 E->MemberExprBits.IsArrow = Record.readInt();
810 E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
811 E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
812 E->MemberExprBits.HadMultipleCandidates = Record.readInt();
Richard Smith1bbad592019-06-11 17:50:36 +0000813 E->MemberExprBits.NonOdrUseReason = Record.readInt();
Richard Smithdcf17de2019-06-06 23:24:15 +0000814 E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
815
816 if (HasQualifier || HasFoundDecl) {
817 DeclAccessPair FoundDecl;
818 if (HasFoundDecl) {
819 auto *FoundD = Record.readDeclAs<NamedDecl>();
820 auto AS = (AccessSpecifier)Record.readInt();
821 FoundDecl = DeclAccessPair::make(FoundD, AS);
822 } else {
823 FoundDecl = DeclAccessPair::make(E->MemberDecl,
824 E->MemberDecl->getAccess());
825 }
826 E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
827
828 NestedNameSpecifierLoc QualifierLoc;
829 if (HasQualifier)
830 QualifierLoc = Record.readNestedNameSpecifierLoc();
831 E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
832 QualifierLoc;
833 }
834
835 if (HasTemplateInfo)
836 ReadTemplateKWAndArgsInfo(
837 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
838 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000839}
840
Sebastian Redl70c751d2010-08-18 23:56:52 +0000841void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Naroffe87026a2009-07-24 17:54:45 +0000842 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000843 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500844 E->setIsaMemberLoc(readSourceLocation());
845 E->setOpLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000846 E->setArrow(Record.readInt());
Steve Naroffe87026a2009-07-24 17:54:45 +0000847}
848
John McCall31168b02011-06-15 23:02:42 +0000849void ASTStmtReader::
850VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
851 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000852 E->Operand = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000853 E->setShouldCopy(Record.readInt());
John McCall31168b02011-06-15 23:02:42 +0000854}
855
856void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
857 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500858 E->LParenLoc = readSourceLocation();
859 E->BridgeKeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000860 E->Kind = Record.readInt();
John McCall31168b02011-06-15 23:02:42 +0000861}
862
Sebastian Redl70c751d2010-08-18 23:56:52 +0000863void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000864 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000865 unsigned NumBaseSpecs = Record.readInt();
John McCallcf142162010-08-07 06:22:56 +0000866 assert(NumBaseSpecs == E->path_size());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000867 E->setSubExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000868 E->setCastKind((CastKind)Record.readInt());
John McCallcf142162010-08-07 06:22:56 +0000869 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000870 while (NumBaseSpecs--) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000871 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000872 *BaseSpec = Record.readCXXBaseSpecifier();
John McCallcf142162010-08-07 06:22:56 +0000873 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000874 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000875}
876
Sebastian Redl70c751d2010-08-18 23:56:52 +0000877void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000878 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000879 E->setLHS(Record.readSubExpr());
880 E->setRHS(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000881 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500882 E->setOperatorLoc(readSourceLocation());
Adam Nemet484aa452017-03-27 19:17:25 +0000883 E->setFPFeatures(FPOptions(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000884}
885
Sebastian Redl70c751d2010-08-18 23:56:52 +0000886void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000887 VisitBinaryOperator(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000888 E->setComputationLHSType(Record.readType());
889 E->setComputationResultType(Record.readType());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000890}
891
Sebastian Redl70c751d2010-08-18 23:56:52 +0000892void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000893 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000894 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
895 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
896 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -0500897 E->QuestionLoc = readSourceLocation();
898 E->ColonLoc = readSourceLocation();
John McCallc07a0c72011-02-17 10:25:35 +0000899}
900
901void
902ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
903 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000904 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
905 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
906 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
907 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
908 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -0500909 E->QuestionLoc = readSourceLocation();
910 E->ColonLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000911}
912
Sebastian Redl70c751d2010-08-18 23:56:52 +0000913void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000914 VisitCastExpr(E);
Roman Lebedev12216f12018-07-27 07:27:14 +0000915 E->setIsPartOfExplicitCast(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000916}
917
Sebastian Redl70c751d2010-08-18 23:56:52 +0000918void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000919 VisitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500920 E->setTypeInfoAsWritten(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000921}
922
Sebastian Redl70c751d2010-08-18 23:56:52 +0000923void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000924 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500925 E->setLParenLoc(readSourceLocation());
926 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000927}
928
Sebastian Redl70c751d2010-08-18 23:56:52 +0000929void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000930 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500931 E->setLParenLoc(readSourceLocation());
932 E->setTypeSourceInfo(readTypeSourceInfo());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000933 E->setInitializer(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000934 E->setFileScope(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000935}
936
Sebastian Redl70c751d2010-08-18 23:56:52 +0000937void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000938 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000939 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500940 E->setAccessor(Record.readIdentifier());
941 E->setAccessorLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000942}
943
Sebastian Redl70c751d2010-08-18 23:56:52 +0000944void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000945 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000946 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
Abramo Bagnara8d16bd42012-11-08 18:41:43 +0000947 E->setSyntacticForm(SyntForm);
John McCall3ce3d232019-12-13 03:37:23 -0500948 E->setLBraceLoc(readSourceLocation());
949 E->setRBraceLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000950 bool isArrayFiller = Record.readInt();
Craig Toppera13603a2014-05-22 05:54:18 +0000951 Expr *filler = nullptr;
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000952 if (isArrayFiller) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000953 filler = Record.readSubExpr();
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000954 E->ArrayFillerOrUnionFieldInit = filler;
955 } else
John McCall3ce3d232019-12-13 03:37:23 -0500956 E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000957 E->sawArrayRangeDesignator(Record.readInt());
958 unsigned NumInits = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000959 E->reserveInits(Record.getContext(), NumInits);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000960 if (isArrayFiller) {
961 for (unsigned I = 0; I != NumInits; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000962 Expr *init = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000963 E->updateInit(Record.getContext(), I, init ? init : filler);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000964 }
965 } else {
966 for (unsigned I = 0; I != NumInits; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000967 E->updateInit(Record.getContext(), I, Record.readSubExpr());
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000968 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000969}
970
Sebastian Redl70c751d2010-08-18 23:56:52 +0000971void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000972 using Designator = DesignatedInitExpr::Designator;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000973
974 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000975 unsigned NumSubExprs = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000976 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
977 for (unsigned I = 0; I != NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000978 E->setSubExpr(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500979 E->setEqualOrColonLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000980 E->setGNUSyntax(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000981
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000982 SmallVector<Designator, 4> Designators;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000983 while (Record.getIdx() < Record.size()) {
984 switch ((DesignatorTypes)Record.readInt()) {
Sebastian Redl539c5062010-08-18 23:57:32 +0000985 case DESIG_FIELD_DECL: {
John McCall3ce3d232019-12-13 03:37:23 -0500986 auto *Field = readDeclAs<FieldDecl>();
987 SourceLocation DotLoc = readSourceLocation();
988 SourceLocation FieldLoc = readSourceLocation();
Mike Stump11289f42009-09-09 15:08:12 +0000989 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000990 FieldLoc));
991 Designators.back().setField(Field);
992 break;
993 }
994
Sebastian Redl539c5062010-08-18 23:57:32 +0000995 case DESIG_FIELD_NAME: {
John McCall3ce3d232019-12-13 03:37:23 -0500996 const IdentifierInfo *Name = Record.readIdentifier();
997 SourceLocation DotLoc = readSourceLocation();
998 SourceLocation FieldLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000999 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
1000 break;
1001 }
Mike Stump11289f42009-09-09 15:08:12 +00001002
Sebastian Redl539c5062010-08-18 23:57:32 +00001003 case DESIG_ARRAY: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001004 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001005 SourceLocation LBracketLoc = readSourceLocation();
1006 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001007 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
1008 break;
1009 }
1010
Sebastian Redl539c5062010-08-18 23:57:32 +00001011 case DESIG_ARRAY_RANGE: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001012 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001013 SourceLocation LBracketLoc = readSourceLocation();
1014 SourceLocation EllipsisLoc = readSourceLocation();
1015 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001016 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
1017 RBracketLoc));
1018 break;
1019 }
1020 }
1021 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001022 E->setDesignators(Record.getContext(),
Douglas Gregor03e8bdc2010-01-06 23:17:19 +00001023 Designators.data(), Designators.size());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001024}
1025
Yunzhong Gaocb779302015-06-10 00:27:52 +00001026void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1027 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001028 E->setBase(Record.readSubExpr());
1029 E->setUpdater(Record.readSubExpr());
Yunzhong Gaocb779302015-06-10 00:27:52 +00001030}
1031
1032void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1033 VisitExpr(E);
1034}
1035
Richard Smith410306b2016-12-12 02:53:20 +00001036void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1037 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001038 E->SubExprs[0] = Record.readSubExpr();
1039 E->SubExprs[1] = Record.readSubExpr();
Richard Smith410306b2016-12-12 02:53:20 +00001040}
1041
1042void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1043 VisitExpr(E);
1044}
1045
Sebastian Redl70c751d2010-08-18 23:56:52 +00001046void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001047 VisitExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001048}
1049
Sebastian Redl70c751d2010-08-18 23:56:52 +00001050void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001051 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001052 E->setSubExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001053 E->setWrittenTypeInfo(readTypeSourceInfo());
1054 E->setBuiltinLoc(readSourceLocation());
1055 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001056 E->setIsMicrosoftABI(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001057}
1058
Eric Fiselier708afb52019-05-16 21:04:15 +00001059void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1060 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001061 E->ParentContext = readDeclAs<DeclContext>();
1062 E->BuiltinLoc = readSourceLocation();
1063 E->RParenLoc = readSourceLocation();
Eric Fiselier708afb52019-05-16 21:04:15 +00001064 E->SourceLocExprBits.Kind =
1065 static_cast<SourceLocExpr::IdentKind>(Record.readInt());
1066}
1067
Sebastian Redl70c751d2010-08-18 23:56:52 +00001068void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001069 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001070 E->setAmpAmpLoc(readSourceLocation());
1071 E->setLabelLoc(readSourceLocation());
1072 E->setLabel(readDeclAs<LabelDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001073}
1074
Sebastian Redl70c751d2010-08-18 23:56:52 +00001075void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001076 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001077 E->setLParenLoc(readSourceLocation());
1078 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001079 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001080}
1081
Sebastian Redl70c751d2010-08-18 23:56:52 +00001082void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001083 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001084 E->setCond(Record.readSubExpr());
1085 E->setLHS(Record.readSubExpr());
1086 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001087 E->setBuiltinLoc(readSourceLocation());
1088 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001089 E->setIsConditionTrue(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001090}
1091
Sebastian Redl70c751d2010-08-18 23:56:52 +00001092void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001093 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001094 E->setTokenLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001095}
1096
Sebastian Redl70c751d2010-08-18 23:56:52 +00001097void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001098 VisitExpr(E);
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001099 SmallVector<Expr *, 16> Exprs;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001100 unsigned NumExprs = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001101 while (NumExprs--)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001102 Exprs.push_back(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001103 E->setExprs(Record.getContext(), Exprs);
John McCall3ce3d232019-12-13 03:37:23 -05001104 E->setBuiltinLoc(readSourceLocation());
1105 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001106}
1107
Hal Finkelc4d7c822013-09-18 03:29:45 +00001108void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1109 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001110 E->BuiltinLoc = readSourceLocation();
1111 E->RParenLoc = readSourceLocation();
1112 E->TInfo = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001113 E->SrcExpr = Record.readSubExpr();
Hal Finkelc4d7c822013-09-18 03:29:45 +00001114}
1115
Sebastian Redl70c751d2010-08-18 23:56:52 +00001116void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001117 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001118 E->setBlockDecl(readDeclAs<BlockDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001119}
1120
Peter Collingbourne91147592011-04-15 00:35:48 +00001121void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1122 VisitExpr(E);
Bruno Riccidb076832019-01-26 14:15:10 +00001123
1124 unsigned NumAssocs = Record.readInt();
1125 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
Bruno Ricci94498c72019-01-26 13:58:15 +00001126 E->ResultIndex = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001127 E->GenericSelectionExprBits.GenericLoc = readSourceLocation();
1128 E->DefaultLoc = readSourceLocation();
1129 E->RParenLoc = readSourceLocation();
Bruno Riccidb076832019-01-26 14:15:10 +00001130
1131 Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1132 // Add 1 to account for the controlling expression which is the first
1133 // expression in the trailing array of Stmt *. This is not needed for
1134 // the trailing array of TypeSourceInfo *.
1135 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1136 Stmts[I] = Record.readSubExpr();
1137
1138 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1139 for (unsigned I = 0, N = NumAssocs; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001140 TSIs[I] = readTypeSourceInfo();
Peter Collingbourne91147592011-04-15 00:35:48 +00001141}
1142
John McCallfe96e0b2011-11-06 09:01:30 +00001143void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1144 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001145 unsigned numSemanticExprs = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001146 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001147 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001148
1149 // Read the syntactic expression.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001150 E->getSubExprsBuffer()[0] = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001151
1152 // Read all the semantic expressions.
1153 for (unsigned i = 0; i != numSemanticExprs; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001154 Expr *subExpr = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001155 E->getSubExprsBuffer()[i+1] = subExpr;
1156 }
1157}
1158
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001159void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1160 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001161 E->Op = AtomicExpr::AtomicOp(Record.readInt());
Richard Smithaa22a8c2012-04-10 22:49:28 +00001162 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1163 for (unsigned I = 0; I != E->NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001164 E->SubExprs[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001165 E->BuiltinLoc = readSourceLocation();
1166 E->RParenLoc = readSourceLocation();
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001167}
1168
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001169//===----------------------------------------------------------------------===//
1170// Objective-C Expressions and Statements
1171
Sebastian Redl70c751d2010-08-18 23:56:52 +00001172void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001173 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001174 E->setString(cast<StringLiteral>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -05001175 E->setAtLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001176}
1177
Patrick Beard0caa3942012-04-19 00:25:12 +00001178void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001179 VisitExpr(E);
1180 // could be one of several IntegerLiteral, FloatLiteral, etc.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001181 E->SubExpr = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -05001182 E->BoxingMethod = readDeclAs<ObjCMethodDecl>();
1183 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001184}
1185
1186void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1187 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001188 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001189 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1190 Expr **Elements = E->getElements();
1191 for (unsigned I = 0, N = NumElements; I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001192 Elements[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001193 E->ArrayWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1194 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001195}
1196
1197void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1198 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001199 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001200 assert(NumElements == E->getNumElements() && "Wrong number of elements");
David L. Jonesbe1557a2016-12-21 00:17:49 +00001201 bool HasPackExpansions = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001202 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001203 auto *KeyValues =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001204 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001205 auto *Expansions =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001206 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001207 for (unsigned I = 0; I != NumElements; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001208 KeyValues[I].Key = Record.readSubExpr();
1209 KeyValues[I].Value = Record.readSubExpr();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001210 if (HasPackExpansions) {
John McCall3ce3d232019-12-13 03:37:23 -05001211 Expansions[I].EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001212 Expansions[I].NumExpansionsPlusOne = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001213 }
1214 }
John McCall3ce3d232019-12-13 03:37:23 -05001215 E->DictWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1216 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001217}
1218
Sebastian Redl70c751d2010-08-18 23:56:52 +00001219void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001220 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001221 E->setEncodedTypeSourceInfo(readTypeSourceInfo());
1222 E->setAtLoc(readSourceLocation());
1223 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001224}
1225
Sebastian Redl70c751d2010-08-18 23:56:52 +00001226void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001227 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001228 E->setSelector(Record.readSelector());
John McCall3ce3d232019-12-13 03:37:23 -05001229 E->setAtLoc(readSourceLocation());
1230 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001231}
1232
Sebastian Redl70c751d2010-08-18 23:56:52 +00001233void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001234 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001235 E->setProtocol(readDeclAs<ObjCProtocolDecl>());
1236 E->setAtLoc(readSourceLocation());
1237 E->ProtoLoc = readSourceLocation();
1238 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001239}
1240
Sebastian Redl70c751d2010-08-18 23:56:52 +00001241void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001242 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001243 E->setDecl(readDeclAs<ObjCIvarDecl>());
1244 E->setLocation(readSourceLocation());
1245 E->setOpLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001246 E->setBase(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001247 E->setIsArrow(Record.readInt());
1248 E->setIsFreeIvar(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001249}
1250
Sebastian Redl70c751d2010-08-18 23:56:52 +00001251void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001252 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001253 unsigned MethodRefFlags = Record.readInt();
1254 bool Implicit = Record.readInt() != 0;
John McCallb7bd14f2010-12-02 01:19:52 +00001255 if (Implicit) {
John McCall3ce3d232019-12-13 03:37:23 -05001256 auto *Getter = readDeclAs<ObjCMethodDecl>();
1257 auto *Setter = readDeclAs<ObjCMethodDecl>();
Argyrios Kyrtzidisab468b02012-03-30 00:19:18 +00001258 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCallb7bd14f2010-12-02 01:19:52 +00001259 } else {
John McCall3ce3d232019-12-13 03:37:23 -05001260 E->setExplicitProperty(readDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001261 }
John McCall3ce3d232019-12-13 03:37:23 -05001262 E->setLocation(readSourceLocation());
1263 E->setReceiverLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001264 switch (Record.readInt()) {
John McCallb7bd14f2010-12-02 01:19:52 +00001265 case 0:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001266 E->setBase(Record.readSubExpr());
John McCallb7bd14f2010-12-02 01:19:52 +00001267 break;
1268 case 1:
David L. Jonesbe1557a2016-12-21 00:17:49 +00001269 E->setSuperReceiver(Record.readType());
John McCallb7bd14f2010-12-02 01:19:52 +00001270 break;
1271 case 2:
John McCall3ce3d232019-12-13 03:37:23 -05001272 E->setClassReceiver(readDeclAs<ObjCInterfaceDecl>());
John McCallb7bd14f2010-12-02 01:19:52 +00001273 break;
1274 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001275}
1276
Ted Kremeneke65b0862012-03-06 20:05:56 +00001277void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1278 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001279 E->setRBracket(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001280 E->setBaseExpr(Record.readSubExpr());
1281 E->setKeyExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001282 E->GetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1283 E->SetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001284}
1285
Sebastian Redl70c751d2010-08-18 23:56:52 +00001286void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001287 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001288 assert(Record.peekInt() == E->getNumArgs());
1289 Record.skipInts(1);
1290 unsigned NumStoredSelLocs = Record.readInt();
1291 E->SelLocsKind = Record.readInt();
1292 E->setDelegateInitCall(Record.readInt());
1293 E->IsImplicit = Record.readInt();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001294 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
Douglas Gregor9a129192010-04-21 00:45:42 +00001295 switch (Kind) {
1296 case ObjCMessageExpr::Instance:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001297 E->setInstanceReceiver(Record.readSubExpr());
Douglas Gregor9a129192010-04-21 00:45:42 +00001298 break;
1299
1300 case ObjCMessageExpr::Class:
John McCall3ce3d232019-12-13 03:37:23 -05001301 E->setClassReceiver(readTypeSourceInfo());
Douglas Gregor9a129192010-04-21 00:45:42 +00001302 break;
1303
1304 case ObjCMessageExpr::SuperClass:
1305 case ObjCMessageExpr::SuperInstance: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001306 QualType T = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001307 SourceLocation SuperLoc = readSourceLocation();
Douglas Gregor9a129192010-04-21 00:45:42 +00001308 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1309 break;
1310 }
1311 }
1312
1313 assert(Kind == E->getReceiverKind());
1314
David L. Jonesbe1557a2016-12-21 00:17:49 +00001315 if (Record.readInt())
John McCall3ce3d232019-12-13 03:37:23 -05001316 E->setMethodDecl(readDeclAs<ObjCMethodDecl>());
Douglas Gregor9a129192010-04-21 00:45:42 +00001317 else
David L. Jonesb6a8f022016-12-21 04:34:52 +00001318 E->setSelector(Record.readSelector());
Douglas Gregor9a129192010-04-21 00:45:42 +00001319
John McCall3ce3d232019-12-13 03:37:23 -05001320 E->LBracLoc = readSourceLocation();
1321 E->RBracLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001322
1323 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001324 E->setArg(I, Record.readSubExpr());
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00001325
1326 SourceLocation *Locs = E->getStoredSelLocs();
1327 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001328 Locs[I] = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001329}
1330
Sebastian Redl70c751d2010-08-18 23:56:52 +00001331void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001332 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001333 S->setElement(Record.readSubStmt());
1334 S->setCollection(Record.readSubExpr());
1335 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001336 S->setForLoc(readSourceLocation());
1337 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001338}
1339
Sebastian Redl70c751d2010-08-18 23:56:52 +00001340void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001341 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001342 S->setCatchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001343 S->setCatchParamDecl(readDeclAs<VarDecl>());
1344 S->setAtCatchLoc(readSourceLocation());
1345 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001346}
1347
Sebastian Redl70c751d2010-08-18 23:56:52 +00001348void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001349 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001350 S->setFinallyBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001351 S->setAtFinallyLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001352}
1353
John McCall31168b02011-06-15 23:02:42 +00001354void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001355 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001356 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001357 S->setAtLoc(readSourceLocation());
John McCall31168b02011-06-15 23:02:42 +00001358}
1359
Sebastian Redl70c751d2010-08-18 23:56:52 +00001360void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001361 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001362 assert(Record.peekInt() == S->getNumCatchStmts());
1363 Record.skipInts(1);
1364 bool HasFinally = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001365 S->setTryBody(Record.readSubStmt());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001366 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001367 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
Douglas Gregor96c79492010-04-23 22:50:49 +00001368
Douglas Gregor96c79492010-04-23 22:50:49 +00001369 if (HasFinally)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001370 S->setFinallyStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001371 S->setAtTryLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001372}
1373
Sebastian Redl70c751d2010-08-18 23:56:52 +00001374void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001375 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001376 S->setSynchExpr(Record.readSubStmt());
1377 S->setSynchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001378 S->setAtSynchronizedLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001379}
1380
Sebastian Redl70c751d2010-08-18 23:56:52 +00001381void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001382 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001383 S->setThrowExpr(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001384 S->setThrowLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001385}
1386
Ted Kremeneke65b0862012-03-06 20:05:56 +00001387void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1388 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001389 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001390 E->setLocation(readSourceLocation());
Ted Kremeneke65b0862012-03-06 20:05:56 +00001391}
1392
Erik Pilkington29099de2016-07-16 00:35:23 +00001393void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1394 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001395 SourceRange R = Record.readSourceRange();
Erik Pilkington29099de2016-07-16 00:35:23 +00001396 E->AtLoc = R.getBegin();
1397 E->RParen = R.getEnd();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001398 E->VersionToCheck = Record.readVersionTuple();
Erik Pilkington29099de2016-07-16 00:35:23 +00001399}
1400
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001401//===----------------------------------------------------------------------===//
1402// C++ Expressions and Statements
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001403//===----------------------------------------------------------------------===//
1404
Sebastian Redl70c751d2010-08-18 23:56:52 +00001405void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001406 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001407 S->CatchLoc = readSourceLocation();
1408 S->ExceptionDecl = readDeclAs<VarDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001409 S->HandlerBlock = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001410}
1411
Sebastian Redl70c751d2010-08-18 23:56:52 +00001412void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001413 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001414 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1415 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -05001416 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001417 S->getStmts()[0] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001418 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001419 S->getStmts()[i + 1] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001420}
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001421
Richard Smith02e85f32011-04-14 22:09:26 +00001422void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1423 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001424 S->ForLoc = readSourceLocation();
1425 S->CoawaitLoc = readSourceLocation();
1426 S->ColonLoc = readSourceLocation();
1427 S->RParenLoc = readSourceLocation();
Richard Smith8baa5002018-09-28 18:44:09 +00001428 S->setInit(Record.readSubStmt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001429 S->setRangeStmt(Record.readSubStmt());
1430 S->setBeginStmt(Record.readSubStmt());
1431 S->setEndStmt(Record.readSubStmt());
1432 S->setCond(Record.readSubExpr());
1433 S->setInc(Record.readSubExpr());
1434 S->setLoopVarStmt(Record.readSubStmt());
1435 S->setBody(Record.readSubStmt());
Richard Smith02e85f32011-04-14 22:09:26 +00001436}
1437
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001438void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1439 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001440 S->KeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001441 S->IsIfExists = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001442 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001443 S->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001444 S->SubStmt = Record.readSubStmt();
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001445}
1446
Sebastian Redl70c751d2010-08-18 23:56:52 +00001447void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001448 VisitCallExpr(E);
Bruno Riccifeb19232018-12-21 16:51:57 +00001449 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1450 E->CXXOperatorCallExprBits.FPFeatures = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001451 E->Range = Record.readSourceRange();
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001452}
1453
Richard Smith778dc0f2019-10-19 00:04:38 +00001454void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1455 CXXRewrittenBinaryOperator *E) {
1456 VisitExpr(E);
1457 E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1458 E->SemanticForm = Record.readSubExpr();
1459}
1460
Sebastian Redl70c751d2010-08-18 23:56:52 +00001461void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001462 VisitExpr(E);
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001463
1464 unsigned NumArgs = Record.readInt();
1465 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1466
1467 E->CXXConstructExprBits.Elidable = Record.readInt();
1468 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1469 E->CXXConstructExprBits.ListInitialization = Record.readInt();
1470 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1471 E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1472 E->CXXConstructExprBits.ConstructionKind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001473 E->CXXConstructExprBits.Loc = readSourceLocation();
1474 E->Constructor = readDeclAs<CXXConstructorDecl>();
1475 E->ParenOrBraceRange = readSourceRange();
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001476
1477 for (unsigned I = 0; I != NumArgs; ++I)
1478 E->setArg(I, Record.readSubExpr());
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001479}
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001480
Richard Smith5179eb72016-06-28 19:03:57 +00001481void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1482 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001483 E->Constructor = readDeclAs<CXXConstructorDecl>();
1484 E->Loc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001485 E->ConstructsVirtualBase = Record.readInt();
1486 E->InheritedFromVirtualBase = Record.readInt();
Richard Smith5179eb72016-06-28 19:03:57 +00001487}
1488
Sebastian Redl70c751d2010-08-18 23:56:52 +00001489void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001490 VisitCXXConstructExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001491 E->TSI = readTypeSourceInfo();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001492}
1493
Douglas Gregore31e6062012-02-07 10:09:13 +00001494void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1495 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001496 unsigned NumCaptures = Record.readInt();
Douglas Gregor99ae8062012-02-14 17:54:36 +00001497 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
John McCall3ce3d232019-12-13 03:37:23 -05001498 E->IntroducerRange = readSourceRange();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001499 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001500 E->CaptureDefaultLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001501 E->ExplicitParams = Record.readInt();
1502 E->ExplicitResultType = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001503 E->ClosingBrace = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001504
Douglas Gregor99ae8062012-02-14 17:54:36 +00001505 // Read capture initializers.
1506 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1507 CEnd = E->capture_init_end();
1508 C != CEnd; ++C)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001509 *C = Record.readSubExpr();
Douglas Gregore31e6062012-02-07 10:09:13 +00001510}
1511
Richard Smithcc1b96d2013-06-12 22:31:48 +00001512void
1513ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1514 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001515 E->SubExpr = Record.readSubExpr();
Richard Smithcc1b96d2013-06-12 22:31:48 +00001516}
1517
Sebastian Redl70c751d2010-08-18 23:56:52 +00001518void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001519 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001520 SourceRange R = readSourceRange();
Douglas Gregor4478f852011-01-12 22:41:29 +00001521 E->Loc = R.getBegin();
1522 E->RParenLoc = R.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05001523 R = readSourceRange();
Fariborz Jahanianf0738712013-02-22 22:02:53 +00001524 E->AngleBrackets = R;
Sam Weinigd01101e2010-01-16 21:21:01 +00001525}
1526
Sebastian Redl70c751d2010-08-18 23:56:52 +00001527void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001528 return VisitCXXNamedCastExpr(E);
1529}
1530
Sebastian Redl70c751d2010-08-18 23:56:52 +00001531void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001532 return VisitCXXNamedCastExpr(E);
1533}
1534
Sebastian Redl70c751d2010-08-18 23:56:52 +00001535void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001536 return VisitCXXNamedCastExpr(E);
1537}
1538
Sebastian Redl70c751d2010-08-18 23:56:52 +00001539void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001540 return VisitCXXNamedCastExpr(E);
1541}
1542
Sebastian Redl70c751d2010-08-18 23:56:52 +00001543void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001544 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001545 E->setLParenLoc(readSourceLocation());
1546 E->setRParenLoc(readSourceLocation());
Sam Weinigd01101e2010-01-16 21:21:01 +00001547}
1548
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001549void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1550 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001551 E->KWLoc = readSourceLocation();
1552 E->RParenLoc = readSourceLocation();
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001553}
1554
Richard Smithc67fdd42012-03-07 08:35:16 +00001555void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1556 VisitCallExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001557 E->UDSuffixLoc = readSourceLocation();
Richard Smithc67fdd42012-03-07 08:35:16 +00001558}
1559
Sebastian Redl70c751d2010-08-18 23:56:52 +00001560void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001561 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001562 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001563 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001564}
1565
Sebastian Redl70c751d2010-08-18 23:56:52 +00001566void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001567 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001568 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001569}
1570
Sebastian Redl70c751d2010-08-18 23:56:52 +00001571void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001572 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001573 E->setSourceRange(readSourceRange());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001574 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redlc67764e2010-07-22 22:43:28 +00001575 E->setTypeOperandSourceInfo(
John McCall3ce3d232019-12-13 03:37:23 -05001576 readTypeSourceInfo());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001577 return;
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001578 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001579
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001580 // typeid(42+2)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001581 E->setExprOperand(Record.readSubExpr());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001582}
1583
Sebastian Redl70c751d2010-08-18 23:56:52 +00001584void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001585 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001586 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001587 E->setImplicit(Record.readInt());
Chris Lattner98267332010-05-09 06:15:05 +00001588}
1589
Sebastian Redl70c751d2010-08-18 23:56:52 +00001590void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001591 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001592 E->CXXThrowExprBits.ThrowLoc = readSourceLocation();
Bruno Riccib7de97b2018-11-17 12:53:56 +00001593 E->Operand = Record.readSubExpr();
1594 E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
Chris Lattner98267332010-05-09 06:15:05 +00001595}
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001596
Sebastian Redl70c751d2010-08-18 23:56:52 +00001597void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattnere2437f42010-05-09 06:40:08 +00001598 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001599 E->Param = readDeclAs<ParmVarDecl>();
1600 E->UsedContext = readDeclAs<DeclContext>();
1601 E->CXXDefaultArgExprBits.Loc = readSourceLocation();
Chris Lattnercba86142010-05-10 00:25:06 +00001602}
1603
Richard Smith852c9db2013-04-20 22:23:05 +00001604void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1605 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001606 E->Field = readDeclAs<FieldDecl>();
1607 E->UsedContext = readDeclAs<DeclContext>();
1608 E->CXXDefaultInitExprBits.Loc = readSourceLocation();
Richard Smith852c9db2013-04-20 22:23:05 +00001609}
1610
Sebastian Redl70c751d2010-08-18 23:56:52 +00001611void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001612 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001613 E->setTemporary(Record.readCXXTemporary());
1614 E->setSubExpr(Record.readSubExpr());
Chris Lattnercba86142010-05-10 00:25:06 +00001615}
1616
Sebastian Redl70c751d2010-08-18 23:56:52 +00001617void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001618 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001619 E->TypeInfo = readTypeSourceInfo();
1620 E->CXXScalarValueInitExprBits.RParenLoc = readSourceLocation();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001621}
1622
Sebastian Redl70c751d2010-08-18 23:56:52 +00001623void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001624 VisitExpr(E);
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001625
1626 bool IsArray = Record.readInt();
1627 bool HasInit = Record.readInt();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001628 unsigned NumPlacementArgs = Record.readInt();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001629 bool IsParenTypeId = Record.readInt();
1630
1631 E->CXXNewExprBits.IsGlobalNew = Record.readInt();
1632 E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
1633 E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1634 E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
1635
1636 assert((IsArray == E->isArray()) && "Wrong IsArray!");
1637 assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
1638 assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
1639 "Wrong NumPlacementArgs!");
1640 assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
1641 (void)IsArray;
1642 (void)HasInit;
1643 (void)NumPlacementArgs;
1644
John McCall3ce3d232019-12-13 03:37:23 -05001645 E->setOperatorNew(readDeclAs<FunctionDecl>());
1646 E->setOperatorDelete(readDeclAs<FunctionDecl>());
1647 E->AllocatedTypeInfo = readTypeSourceInfo();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001648 if (IsParenTypeId)
John McCall3ce3d232019-12-13 03:37:23 -05001649 E->getTrailingObjects<SourceRange>()[0] = readSourceRange();
1650 E->Range = readSourceRange();
1651 E->DirectInitRange = readSourceRange();
Chandler Carruth01718152010-10-25 08:47:36 +00001652
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001653 // Install all the subexpressions.
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001654 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
1655 N = E->raw_arg_end();
1656 I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001657 *I = Record.readSubStmt();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001658}
1659
Sebastian Redl70c751d2010-08-18 23:56:52 +00001660void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001661 VisitExpr(E);
Bruno Ricci91728fc2018-12-03 12:32:32 +00001662 E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
1663 E->CXXDeleteExprBits.ArrayForm = Record.readInt();
1664 E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
1665 E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001666 E->OperatorDelete = readDeclAs<FunctionDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001667 E->Argument = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001668 E->CXXDeleteExprBits.Loc = readSourceLocation();
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001669}
Chris Lattnercba86142010-05-10 00:25:06 +00001670
Sebastian Redl70c751d2010-08-18 23:56:52 +00001671void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001672 VisitExpr(E);
1673
David L. Jonesb6a8f022016-12-21 04:34:52 +00001674 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001675 E->IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001676 E->OperatorLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001677 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001678 E->ScopeType = readTypeSourceInfo();
1679 E->ColonColonLoc = readSourceLocation();
1680 E->TildeLoc = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001681
John McCall3ce3d232019-12-13 03:37:23 -05001682 IdentifierInfo *II = Record.readIdentifier();
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001683 if (II)
John McCall3ce3d232019-12-13 03:37:23 -05001684 E->setDestroyedType(II, readSourceLocation());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001685 else
John McCall3ce3d232019-12-13 03:37:23 -05001686 E->setDestroyedType(readTypeSourceInfo());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001687}
1688
John McCall5d413782010-12-06 08:20:24 +00001689void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001690 VisitExpr(E);
John McCall28fc7092011-11-10 05:35:25 +00001691
David L. Jonesbe1557a2016-12-21 00:17:49 +00001692 unsigned NumObjects = Record.readInt();
John McCall28fc7092011-11-10 05:35:25 +00001693 assert(NumObjects == E->getNumObjects());
1694 for (unsigned i = 0; i != NumObjects; ++i)
James Y Knighte00a67e2015-12-31 04:18:25 +00001695 E->getTrailingObjects<BlockDecl *>()[i] =
John McCall3ce3d232019-12-13 03:37:23 -05001696 readDeclAs<BlockDecl>();
John McCall28fc7092011-11-10 05:35:25 +00001697
David L. Jonesbe1557a2016-12-21 00:17:49 +00001698 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001699 E->SubExpr = Record.readSubExpr();
Chris Lattnere2437f42010-05-09 06:40:08 +00001700}
1701
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001702void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1703 CXXDependentScopeMemberExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001704 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001705
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001706 bool HasTemplateKWAndArgsInfo = Record.readInt();
1707 unsigned NumTemplateArgs = Record.readInt();
1708 bool HasFirstQualifierFoundInScope = Record.readInt();
1709
1710 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
1711 "Wrong HasTemplateKWAndArgsInfo!");
1712 assert(
1713 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
1714 "Wrong HasFirstQualifierFoundInScope!");
1715
1716 if (HasTemplateKWAndArgsInfo)
James Y Knighte7d82282015-12-29 18:15:14 +00001717 ReadTemplateKWAndArgsInfo(
1718 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001719 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001720
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001721 assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
1722 "Wrong NumTemplateArgs!");
1723
1724 E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001725 E->CXXDependentScopeMemberExprBits.OperatorLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001726 E->BaseType = Record.readType();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001727 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001728 E->Base = Record.readSubExpr();
1729
1730 if (HasFirstQualifierFoundInScope)
John McCall3ce3d232019-12-13 03:37:23 -05001731 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001732
John McCall3ce3d232019-12-13 03:37:23 -05001733 E->MemberNameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001734}
1735
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001736void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001737ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001738 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001739
David L. Jonesbe1557a2016-12-21 00:17:49 +00001740 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001741 ReadTemplateKWAndArgsInfo(
1742 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1743 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001744 /*NumTemplateArgs=*/Record.readInt());
Douglas Gregor3a43fd62011-02-25 20:49:16 +00001745
David L. Jonesb6a8f022016-12-21 04:34:52 +00001746 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001747 E->NameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001748}
1749
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001750void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001751ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001752 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001753 assert(Record.peekInt() == E->arg_size() &&
1754 "Read wrong record during creation ?");
1755 Record.skipInts(1);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001756 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001757 E->setArg(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001758 E->TSI = readTypeSourceInfo();
1759 E->setLParenLoc(readSourceLocation());
1760 E->setRParenLoc(readSourceLocation());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001761}
1762
Sebastian Redl70c751d2010-08-18 23:56:52 +00001763void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001764 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001765
Bruno Riccid7628d92019-01-09 15:43:19 +00001766 unsigned NumResults = Record.readInt();
1767 bool HasTemplateKWAndArgsInfo = Record.readInt();
1768 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
1769 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
1770 "Wrong HasTemplateKWAndArgsInfo!");
1771
1772 if (HasTemplateKWAndArgsInfo) {
1773 unsigned NumTemplateArgs = Record.readInt();
James Y Knighte7d82282015-12-29 18:15:14 +00001774 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1775 E->getTrailingTemplateArgumentLoc(),
Bruno Riccid7628d92019-01-09 15:43:19 +00001776 NumTemplateArgs);
1777 assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
1778 "Wrong NumTemplateArgs!");
1779 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001780
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001781 UnresolvedSet<8> Decls;
Bruno Riccid7628d92019-01-09 15:43:19 +00001782 for (unsigned I = 0; I != NumResults; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -05001783 auto *D = readDeclAs<NamedDecl>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001784 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001785 Decls.addDecl(D, AS);
1786 }
Bruno Riccid7628d92019-01-09 15:43:19 +00001787
1788 DeclAccessPair *Results = E->getTrailingResults();
1789 UnresolvedSetIterator Iter = Decls.begin();
1790 for (unsigned I = 0; I != NumResults; ++I) {
1791 Results[I] = (Iter + I).getPair();
1792 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001793
John McCall3ce3d232019-12-13 03:37:23 -05001794 E->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001795 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001796}
1797
Sebastian Redl70c751d2010-08-18 23:56:52 +00001798void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001799 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00001800 E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
1801 E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001802 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001803 E->BaseType = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001804 E->OperatorLoc = readSourceLocation();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001805}
1806
Sebastian Redl70c751d2010-08-18 23:56:52 +00001807void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001808 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00001809 E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
1810 E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001811 E->NamingClass = readDeclAs<CXXRecordDecl>();
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00001812}
1813
Douglas Gregor29c42f22012-02-24 07:38:34 +00001814void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1815 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001816 E->TypeTraitExprBits.NumArgs = Record.readInt();
1817 E->TypeTraitExprBits.Kind = Record.readInt();
1818 E->TypeTraitExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001819 SourceRange Range = readSourceRange();
Jordan Rose99e80c12013-12-20 01:26:47 +00001820 E->Loc = Range.getBegin();
1821 E->RParenLoc = Range.getEnd();
1822
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001823 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001824 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001825 Args[I] = readTypeSourceInfo();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001826}
1827
John Wiegley6242b6a2011-04-28 00:16:57 +00001828void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1829 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001830 E->ATT = (ArrayTypeTrait)Record.readInt();
1831 E->Value = (unsigned int)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001832 SourceRange Range = readSourceRange();
John Wiegley6242b6a2011-04-28 00:16:57 +00001833 E->Loc = Range.getBegin();
1834 E->RParen = Range.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05001835 E->QueriedType = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001836 E->Dimension = Record.readSubExpr();
John Wiegley6242b6a2011-04-28 00:16:57 +00001837}
1838
John Wiegleyf9f65842011-04-25 06:54:41 +00001839void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1840 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001841 E->ET = (ExpressionTrait)Record.readInt();
1842 E->Value = (bool)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001843 SourceRange Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001844 E->QueriedExpression = Record.readSubExpr();
John Wiegleyf9f65842011-04-25 06:54:41 +00001845 E->Loc = Range.getBegin();
1846 E->RParen = Range.getEnd();
1847}
1848
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001849void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1850 VisitExpr(E);
Bruno Riccid56edfe2019-01-08 14:44:34 +00001851 E->CXXNoexceptExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001852 E->Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001853 E->Operand = Record.readSubExpr();
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001854}
1855
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001856void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1857 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001858 E->EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001859 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001860 E->Pattern = Record.readSubExpr();
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001861}
1862
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001863void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1864 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001865 unsigned NumPartialArgs = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001866 E->OperatorLoc = readSourceLocation();
1867 E->PackLoc = readSourceLocation();
1868 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001869 E->Pack = Record.readDeclAs<NamedDecl>();
Richard Smithd784e682015-09-23 21:41:42 +00001870 if (E->isPartiallySubstituted()) {
1871 assert(E->Length == NumPartialArgs);
James Y Knighte00a67e2015-12-31 04:18:25 +00001872 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
Richard Smithd784e682015-09-23 21:41:42 +00001873 *E = I + NumPartialArgs;
1874 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001875 new (I) TemplateArgument(Record.readTemplateArgument());
Richard Smithd784e682015-09-23 21:41:42 +00001876 } else if (!E->isValueDependent()) {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001877 E->Length = Record.readInt();
Richard Smithd784e682015-09-23 21:41:42 +00001878 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001879}
1880
John McCallfa194042011-07-15 07:00:14 +00001881void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1882 SubstNonTypeTemplateParmExpr *E) {
1883 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001884 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
1885 E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001886 E->Replacement = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00001887}
1888
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001889void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1890 SubstNonTypeTemplateParmPackExpr *E) {
1891 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001892 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001893 TemplateArgument ArgPack = Record.readTemplateArgument();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001894 if (ArgPack.getKind() != TemplateArgument::Pack)
1895 return;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001896
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001897 E->Arguments = ArgPack.pack_begin();
1898 E->NumArguments = ArgPack.pack_size();
John McCall3ce3d232019-12-13 03:37:23 -05001899 E->NameLoc = readSourceLocation();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001900}
1901
Richard Smithb15fe3a2012-09-12 00:56:43 +00001902void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1903 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001904 E->NumParameters = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001905 E->ParamPack = readDeclAs<ParmVarDecl>();
1906 E->NameLoc = readSourceLocation();
Richard Smithb2997f52019-05-21 20:10:50 +00001907 auto **Parms = E->getTrailingObjects<VarDecl *>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00001908 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
John McCall3ce3d232019-12-13 03:37:23 -05001909 Parms[i] = readDeclAs<VarDecl>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00001910}
1911
Douglas Gregorfe314812011-06-21 17:03:29 +00001912void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1913 VisitExpr(E);
Tykerb0561b32019-11-17 11:41:55 +01001914 bool HasMaterialzedDecl = Record.readInt();
1915 if (HasMaterialzedDecl)
1916 E->State = cast<LifetimeExtendedTemporaryDecl>(Record.readDecl());
1917 else
1918 E->State = Record.readSubExpr();
Douglas Gregorfe314812011-06-21 17:03:29 +00001919}
1920
Richard Smith0f0af192014-11-08 05:07:16 +00001921void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
1922 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001923 E->LParenLoc = readSourceLocation();
1924 E->EllipsisLoc = readSourceLocation();
1925 E->RParenLoc = readSourceLocation();
Richard Smithc7214f62019-05-13 08:31:14 +00001926 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001927 E->SubExprs[0] = Record.readSubExpr();
1928 E->SubExprs[1] = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001929 E->Opcode = (BinaryOperatorKind)Record.readInt();
Richard Smith0f0af192014-11-08 05:07:16 +00001930}
1931
John McCall8d69a212010-11-15 23:31:06 +00001932void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1933 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001934 E->SourceExpr = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001935 E->OpaqueValueExprBits.Loc = readSourceLocation();
Akira Hatanaka797afe32018-03-20 01:47:58 +00001936 E->setIsUnique(Record.readInt());
John McCall8d69a212010-11-15 23:31:06 +00001937}
1938
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001939void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
1940 llvm_unreachable("Cannot read TypoExpr nodes");
1941}
1942
Peter Collingbourne41f85462011-02-09 21:07:24 +00001943//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00001944// Microsoft Expressions and Statements
1945//===----------------------------------------------------------------------===//
John McCall5e77d762013-04-16 07:28:30 +00001946void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1947 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001948 E->IsArrow = (Record.readInt() != 0);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001949 E->BaseExpr = Record.readSubExpr();
1950 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001951 E->MemberLoc = readSourceLocation();
1952 E->TheDecl = readDeclAs<MSPropertyDecl>();
John McCall5e77d762013-04-16 07:28:30 +00001953}
1954
Alexey Bataevf7630272015-11-25 12:01:00 +00001955void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
1956 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001957 E->setBase(Record.readSubExpr());
1958 E->setIdx(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001959 E->setRBracketLoc(readSourceLocation());
Alexey Bataevf7630272015-11-25 12:01:00 +00001960}
1961
John McCallfa194042011-07-15 07:00:14 +00001962void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1963 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001964 E->setSourceRange(readSourceRange());
1965 std::string UuidStr = readString();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001966 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
John McCallfa194042011-07-15 07:00:14 +00001967 if (E->isTypeOperand()) { // __uuidof(ComType)
1968 E->setTypeOperandSourceInfo(
John McCall3ce3d232019-12-13 03:37:23 -05001969 readTypeSourceInfo());
John McCallfa194042011-07-15 07:00:14 +00001970 return;
1971 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001972
John McCallfa194042011-07-15 07:00:14 +00001973 // __uuidof(expr)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001974 E->setExprOperand(Record.readSubExpr());
John McCallfa194042011-07-15 07:00:14 +00001975}
1976
Nico Weber9b982072014-07-07 00:12:30 +00001977void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1978 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001979 S->setLeaveLoc(readSourceLocation());
Nico Weber9b982072014-07-07 00:12:30 +00001980}
1981
John McCallfa194042011-07-15 07:00:14 +00001982void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1983 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001984 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001985 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
1986 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001987}
1988
1989void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1990 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001991 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001992 S->Block = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001993}
1994
1995void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1996 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001997 S->IsCXXTry = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001998 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001999 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
2000 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00002001}
2002
2003//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00002004// CUDA Expressions and Statements
2005//===----------------------------------------------------------------------===//
2006
2007void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2008 VisitCallExpr(E);
Richard Smithfd420792019-05-24 23:26:07 +00002009 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
Peter Collingbourne41f85462011-02-09 21:07:24 +00002010}
2011
John McCallfa194042011-07-15 07:00:14 +00002012//===----------------------------------------------------------------------===//
2013// OpenCL Expressions and Statements.
2014//===----------------------------------------------------------------------===//
2015void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2016 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002017 E->BuiltinLoc = readSourceLocation();
2018 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002019 E->SrcExpr = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002020}
2021
2022//===----------------------------------------------------------------------===//
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002023// OpenMP Directives.
2024//===----------------------------------------------------------------------===//
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002025
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002026void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
John McCall3ce3d232019-12-13 03:37:23 -05002027 E->setLocStart(readSourceLocation());
2028 E->setLocEnd(readSourceLocation());
Kelvin Libe286f52018-09-15 13:54:15 +00002029 OMPClauseReader ClauseReader(Record);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002030 SmallVector<OMPClause *, 5> Clauses;
2031 for (unsigned i = 0; i < E->getNumClauses(); ++i)
2032 Clauses.push_back(ClauseReader.readClause());
2033 E->setClauses(Clauses);
Alexey Bataev68446b72014-07-18 07:47:19 +00002034 if (E->hasAssociatedStmt())
David L. Jonesb6a8f022016-12-21 04:34:52 +00002035 E->setAssociatedStmt(Record.readSubStmt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002036}
2037
Alexander Musman3aaab662014-08-19 11:27:13 +00002038void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2039 VisitStmt(D);
2040 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002041 Record.skipInts(2);
Alexander Musman3aaab662014-08-19 11:27:13 +00002042 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002043 D->setIterationVariable(Record.readSubExpr());
2044 D->setLastIteration(Record.readSubExpr());
2045 D->setCalcLastIteration(Record.readSubExpr());
2046 D->setPreCond(Record.readSubExpr());
2047 D->setCond(Record.readSubExpr());
2048 D->setInit(Record.readSubExpr());
2049 D->setInc(Record.readSubExpr());
2050 D->setPreInits(Record.readSubStmt());
Alexey Bataev3392d762016-02-16 11:18:12 +00002051 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
Carlo Bertollifc35ad22016-03-07 16:04:49 +00002052 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2053 isOpenMPDistributeDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002054 D->setIsLastIterVariable(Record.readSubExpr());
2055 D->setLowerBoundVariable(Record.readSubExpr());
2056 D->setUpperBoundVariable(Record.readSubExpr());
2057 D->setStrideVariable(Record.readSubExpr());
2058 D->setEnsureUpperBound(Record.readSubExpr());
2059 D->setNextLowerBound(Record.readSubExpr());
2060 D->setNextUpperBound(Record.readSubExpr());
2061 D->setNumIterations(Record.readSubExpr());
Alexander Musmanc6388682014-12-15 07:07:06 +00002062 }
Carlo Bertolli9925f152016-06-27 14:55:37 +00002063 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002064 D->setPrevLowerBoundVariable(Record.readSubExpr());
2065 D->setPrevUpperBoundVariable(Record.readSubExpr());
Carlo Bertolli8429d812017-02-17 21:29:13 +00002066 D->setDistInc(Record.readSubExpr());
2067 D->setPrevEnsureUpperBound(Record.readSubExpr());
Carlo Bertolliffafe102017-04-20 00:39:39 +00002068 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2069 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2070 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2071 D->setCombinedInit(Record.readSubExpr());
2072 D->setCombinedCond(Record.readSubExpr());
2073 D->setCombinedNextLowerBound(Record.readSubExpr());
2074 D->setCombinedNextUpperBound(Record.readSubExpr());
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00002075 D->setCombinedDistCond(Record.readSubExpr());
2076 D->setCombinedParForInDistCond(Record.readSubExpr());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002077 }
Alexander Musmana5f070a2014-10-01 06:03:56 +00002078 SmallVector<Expr *, 4> Sub;
2079 unsigned CollapsedNum = D->getCollapsedNumber();
2080 Sub.reserve(CollapsedNum);
2081 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002082 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002083 D->setCounters(Sub);
2084 Sub.clear();
2085 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002086 Sub.push_back(Record.readSubExpr());
Alexey Bataeva8899172015-08-06 12:30:57 +00002087 D->setPrivateCounters(Sub);
2088 Sub.clear();
2089 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002090 Sub.push_back(Record.readSubExpr());
Alexey Bataevb08f89f2015-08-14 12:25:37 +00002091 D->setInits(Sub);
2092 Sub.clear();
2093 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002094 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002095 D->setUpdates(Sub);
2096 Sub.clear();
2097 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002098 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002099 D->setFinals(Sub);
Alexey Bataevf8be4762019-08-14 19:30:06 +00002100 Sub.clear();
2101 for (unsigned i = 0; i < CollapsedNum; ++i)
2102 Sub.push_back(Record.readSubExpr());
2103 D->setDependentCounters(Sub);
2104 Sub.clear();
2105 for (unsigned i = 0; i < CollapsedNum; ++i)
2106 Sub.push_back(Record.readSubExpr());
2107 D->setDependentInits(Sub);
2108 Sub.clear();
2109 for (unsigned i = 0; i < CollapsedNum; ++i)
2110 Sub.push_back(Record.readSubExpr());
2111 D->setFinalsConditions(Sub);
Alexander Musman3aaab662014-08-19 11:27:13 +00002112}
2113
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002114void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002115 VisitStmt(D);
2116 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002117 Record.skipInts(1);
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002118 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002119 D->setHasCancel(Record.readInt());
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002120}
2121
2122void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002123 VisitOMPLoopDirective(D);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002124}
2125
Alexey Bataevf29276e2014-06-18 04:14:57 +00002126void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002127 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002128 D->setHasCancel(Record.readInt());
Alexey Bataevf29276e2014-06-18 04:14:57 +00002129}
2130
Alexander Musmanf82886e2014-09-18 05:12:34 +00002131void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2132 VisitOMPLoopDirective(D);
2133}
2134
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002135void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2136 VisitStmt(D);
2137 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002138 Record.skipInts(1);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002139 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002140 D->setHasCancel(Record.readInt());
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002141}
2142
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002143void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2144 VisitStmt(D);
2145 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002146 D->setHasCancel(Record.readInt());
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002147}
2148
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002149void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2150 VisitStmt(D);
2151 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002152 Record.skipInts(1);
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002153 VisitOMPExecutableDirective(D);
2154}
2155
Alexander Musman80c22892014-07-17 08:54:58 +00002156void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2157 VisitStmt(D);
2158 VisitOMPExecutableDirective(D);
2159}
2160
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002161void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2162 VisitStmt(D);
Alexey Bataev28c75412015-12-15 08:19:24 +00002163 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002164 Record.skipInts(1);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002165 VisitOMPExecutableDirective(D);
John McCall3ce3d232019-12-13 03:37:23 -05002166 D->DirName = Record.readDeclarationNameInfo();
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002167}
2168
Alexey Bataev4acb8592014-07-07 13:01:15 +00002169void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002170 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002171 D->setHasCancel(Record.readInt());
Alexey Bataev4acb8592014-07-07 13:01:15 +00002172}
2173
Alexander Musmane4e893b2014-09-23 09:33:00 +00002174void ASTStmtReader::VisitOMPParallelForSimdDirective(
2175 OMPParallelForSimdDirective *D) {
2176 VisitOMPLoopDirective(D);
2177}
2178
cchen47d60942019-12-05 13:43:48 -05002179void ASTStmtReader::VisitOMPParallelMasterDirective(
2180 OMPParallelMasterDirective *D) {
2181 VisitStmt(D);
2182 // The NumClauses field was read in ReadStmtFromStream.
2183 Record.skipInts(1);
2184 VisitOMPExecutableDirective(D);
2185}
2186
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002187void ASTStmtReader::VisitOMPParallelSectionsDirective(
2188 OMPParallelSectionsDirective *D) {
2189 VisitStmt(D);
2190 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002191 Record.skipInts(1);
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002192 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002193 D->setHasCancel(Record.readInt());
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002194}
2195
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002196void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2197 VisitStmt(D);
2198 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002199 Record.skipInts(1);
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002200 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002201 D->setHasCancel(Record.readInt());
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002202}
2203
Alexey Bataev68446b72014-07-18 07:47:19 +00002204void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2205 VisitStmt(D);
2206 VisitOMPExecutableDirective(D);
2207}
2208
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002209void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2210 VisitStmt(D);
2211 VisitOMPExecutableDirective(D);
2212}
2213
Alexey Bataev2df347a2014-07-18 10:17:07 +00002214void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2215 VisitStmt(D);
2216 VisitOMPExecutableDirective(D);
2217}
2218
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002219void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2220 VisitStmt(D);
Alexey Bataev169d96a2017-07-18 20:17:46 +00002221 // The NumClauses field was read in ReadStmtFromStream.
2222 Record.skipInts(1);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002223 VisitOMPExecutableDirective(D);
Alexey Bataev3b1b8952017-07-25 15:53:26 +00002224 D->setReductionRef(Record.readSubExpr());
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002225}
2226
Alexey Bataev6125da92014-07-21 11:26:11 +00002227void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2228 VisitStmt(D);
2229 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002230 Record.skipInts(1);
Alexey Bataev6125da92014-07-21 11:26:11 +00002231 VisitOMPExecutableDirective(D);
2232}
2233
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002234void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2235 VisitStmt(D);
Alexey Bataev346265e2015-09-25 10:37:12 +00002236 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002237 Record.skipInts(1);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002238 VisitOMPExecutableDirective(D);
2239}
2240
Alexey Bataev0162e452014-07-22 10:10:35 +00002241void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2242 VisitStmt(D);
2243 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002244 Record.skipInts(1);
Alexey Bataev0162e452014-07-22 10:10:35 +00002245 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002246 D->setX(Record.readSubExpr());
2247 D->setV(Record.readSubExpr());
2248 D->setExpr(Record.readSubExpr());
2249 D->setUpdateExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002250 D->IsXLHSInRHSPart = Record.readInt() != 0;
2251 D->IsPostfixUpdate = Record.readInt() != 0;
Alexey Bataev0162e452014-07-22 10:10:35 +00002252}
2253
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002254void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2255 VisitStmt(D);
2256 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002257 Record.skipInts(1);
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002258 VisitOMPExecutableDirective(D);
2259}
2260
Michael Wong65f367f2015-07-21 13:44:28 +00002261void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2262 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002263 Record.skipInts(1);
Michael Wong65f367f2015-07-21 13:44:28 +00002264 VisitOMPExecutableDirective(D);
2265}
2266
Samuel Antaodf67fc42016-01-19 19:15:56 +00002267void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2268 OMPTargetEnterDataDirective *D) {
2269 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002270 Record.skipInts(1);
Samuel Antaodf67fc42016-01-19 19:15:56 +00002271 VisitOMPExecutableDirective(D);
2272}
2273
Samuel Antao72590762016-01-19 20:04:50 +00002274void ASTStmtReader::VisitOMPTargetExitDataDirective(
2275 OMPTargetExitDataDirective *D) {
2276 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002277 Record.skipInts(1);
Samuel Antao72590762016-01-19 20:04:50 +00002278 VisitOMPExecutableDirective(D);
2279}
2280
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002281void ASTStmtReader::VisitOMPTargetParallelDirective(
2282 OMPTargetParallelDirective *D) {
2283 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002284 Record.skipInts(1);
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002285 VisitOMPExecutableDirective(D);
2286}
2287
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002288void ASTStmtReader::VisitOMPTargetParallelForDirective(
2289 OMPTargetParallelForDirective *D) {
2290 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002291 D->setHasCancel(Record.readInt());
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002292}
2293
Alexey Bataev13314bf2014-10-09 04:18:56 +00002294void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2295 VisitStmt(D);
2296 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002297 Record.skipInts(1);
Alexey Bataev13314bf2014-10-09 04:18:56 +00002298 VisitOMPExecutableDirective(D);
2299}
2300
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002301void ASTStmtReader::VisitOMPCancellationPointDirective(
2302 OMPCancellationPointDirective *D) {
2303 VisitStmt(D);
2304 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002305 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002306}
2307
Alexey Bataev80909872015-07-02 11:25:17 +00002308void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2309 VisitStmt(D);
Alexey Bataev87933c72015-09-18 08:07:34 +00002310 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002311 Record.skipInts(1);
Alexey Bataev80909872015-07-02 11:25:17 +00002312 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002313 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev80909872015-07-02 11:25:17 +00002314}
2315
Alexey Bataev49f6e782015-12-01 04:18:41 +00002316void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2317 VisitOMPLoopDirective(D);
2318}
2319
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002320void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2321 VisitOMPLoopDirective(D);
2322}
2323
Alexey Bataev60e51c42019-10-10 20:13:02 +00002324void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2325 OMPMasterTaskLoopDirective *D) {
2326 VisitOMPLoopDirective(D);
2327}
2328
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002329void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2330 OMPMasterTaskLoopSimdDirective *D) {
2331 VisitOMPLoopDirective(D);
2332}
2333
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002334void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2335 OMPParallelMasterTaskLoopDirective *D) {
2336 VisitOMPLoopDirective(D);
2337}
2338
Alexey Bataev14a388f2019-10-25 10:27:13 -04002339void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2340 OMPParallelMasterTaskLoopSimdDirective *D) {
2341 VisitOMPLoopDirective(D);
2342}
2343
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002344void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2345 VisitOMPLoopDirective(D);
2346}
2347
Samuel Antao686c70c2016-05-26 17:30:50 +00002348void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2349 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002350 Record.skipInts(1);
Samuel Antao686c70c2016-05-26 17:30:50 +00002351 VisitOMPExecutableDirective(D);
2352}
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002353
Carlo Bertolli9925f152016-06-27 14:55:37 +00002354void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2355 OMPDistributeParallelForDirective *D) {
2356 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002357 D->setHasCancel(Record.readInt());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002358}
Samuel Antao686c70c2016-05-26 17:30:50 +00002359
Kelvin Li4a39add2016-07-05 05:00:15 +00002360void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2361 OMPDistributeParallelForSimdDirective *D) {
2362 VisitOMPLoopDirective(D);
2363}
2364
Kelvin Li787f3fc2016-07-06 04:45:38 +00002365void ASTStmtReader::VisitOMPDistributeSimdDirective(
2366 OMPDistributeSimdDirective *D) {
2367 VisitOMPLoopDirective(D);
2368}
2369
Kelvin Lia579b912016-07-14 02:54:56 +00002370void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2371 OMPTargetParallelForSimdDirective *D) {
2372 VisitOMPLoopDirective(D);
2373}
2374
Kelvin Li986330c2016-07-20 22:57:10 +00002375void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2376 VisitOMPLoopDirective(D);
2377}
2378
Kelvin Li02532872016-08-05 14:37:37 +00002379void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2380 OMPTeamsDistributeDirective *D) {
2381 VisitOMPLoopDirective(D);
2382}
2383
Kelvin Li4e325f72016-10-25 12:50:55 +00002384void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2385 OMPTeamsDistributeSimdDirective *D) {
2386 VisitOMPLoopDirective(D);
2387}
2388
Kelvin Li579e41c2016-11-30 23:51:03 +00002389void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2390 OMPTeamsDistributeParallelForSimdDirective *D) {
2391 VisitOMPLoopDirective(D);
2392}
2393
Kelvin Li7ade93f2016-12-09 03:24:30 +00002394void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2395 OMPTeamsDistributeParallelForDirective *D) {
2396 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002397 D->setHasCancel(Record.readInt());
Kelvin Li7ade93f2016-12-09 03:24:30 +00002398}
2399
Kelvin Libf594a52016-12-17 05:48:59 +00002400void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2401 VisitStmt(D);
2402 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002403 Record.skipInts(1);
Kelvin Libf594a52016-12-17 05:48:59 +00002404 VisitOMPExecutableDirective(D);
2405}
2406
Kelvin Li83c451e2016-12-25 04:52:54 +00002407void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2408 OMPTargetTeamsDistributeDirective *D) {
2409 VisitOMPLoopDirective(D);
2410}
2411
Kelvin Li80e8f562016-12-29 22:16:30 +00002412void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2413 OMPTargetTeamsDistributeParallelForDirective *D) {
2414 VisitOMPLoopDirective(D);
Alexey Bataev16e79882017-11-22 21:12:03 +00002415 D->setHasCancel(Record.readInt());
Kelvin Li80e8f562016-12-29 22:16:30 +00002416}
2417
Kelvin Li1851df52017-01-03 05:23:48 +00002418void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2419 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2420 VisitOMPLoopDirective(D);
2421}
2422
Kelvin Lida681182017-01-10 18:08:18 +00002423void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2424 OMPTargetTeamsDistributeSimdDirective *D) {
2425 VisitOMPLoopDirective(D);
2426}
2427
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002428//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002429// ASTReader Implementation
2430//===----------------------------------------------------------------------===//
2431
Douglas Gregorde3ef502011-11-30 23:21:26 +00002432Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002433 switch (ReadingKind) {
Richard Smith629ff362013-07-31 00:26:46 +00002434 case Read_None:
2435 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002436 case Read_Decl:
2437 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00002438 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002439 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002440 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002441 }
2442
2443 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002444}
2445
Douglas Gregorde3ef502011-11-30 23:21:26 +00002446Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00002447 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002448}
Chris Lattnere2437f42010-05-09 06:40:08 +00002449
Sebastian Redl2c499f62010-08-18 23:56:43 +00002450Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002451 return cast_or_null<Expr>(ReadSubStmt());
2452}
2453
Chris Lattnerf4262532009-04-27 05:41:06 +00002454// Within the bitstream, expressions are stored in Reverse Polish
2455// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002456// expression they are stored in. Subexpressions are stored from last to first.
2457// To evaluate expressions, we continue reading expressions and placing them on
2458// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00002459// stack. Evaluation terminates when we see a STMT_STOP record, and
2460// the single remaining expression on the stack is our result.
Douglas Gregorde3ef502011-11-30 23:21:26 +00002461Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002462 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00002463 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002464
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002465 // Map of offset to previously deserialized stmt. The offset points
George Burgess IV758cf9d2017-02-14 05:52:57 +00002466 // just after the stmt record.
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002467 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00002468
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002469#ifndef NDEBUG
2470 unsigned PrevNumStmts = StmtStack.size();
2471#endif
2472
David L. Jonesbe1557a2016-12-21 00:17:49 +00002473 ASTRecordReader Record(*this, F);
2474 ASTStmtReader Reader(Record, Cursor);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002475 Stmt::EmptyShell Empty;
2476
2477 while (true) {
JF Bastien0e828952019-06-26 19:50:12 +00002478 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2479 Cursor.advanceSkippingSubblocks();
2480 if (!MaybeEntry) {
2481 Error(toString(MaybeEntry.takeError()));
2482 return nullptr;
2483 }
2484 llvm::BitstreamEntry Entry = MaybeEntry.get();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002485
Chris Lattner0e6c9402013-01-20 02:38:54 +00002486 switch (Entry.Kind) {
2487 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2488 case llvm::BitstreamEntry::Error:
2489 Error("malformed block record in AST file");
Craig Toppera13603a2014-05-22 05:54:18 +00002490 return nullptr;
Chris Lattner0e6c9402013-01-20 02:38:54 +00002491 case llvm::BitstreamEntry::EndBlock:
2492 goto Done;
2493 case llvm::BitstreamEntry::Record:
2494 // The interesting case.
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002495 break;
2496 }
2497
Richard Smithdbafb6c2017-06-29 23:23:46 +00002498 ASTContext &Context = getContext();
Craig Toppera13603a2014-05-22 05:54:18 +00002499 Stmt *S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002500 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002501 bool IsStmtReference = false;
JF Bastien0e828952019-06-26 19:50:12 +00002502 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2503 if (!MaybeStmtCode) {
2504 Error(toString(MaybeStmtCode.takeError()));
2505 return nullptr;
2506 }
2507 switch ((StmtCode)MaybeStmtCode.get()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00002508 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002509 Finished = true;
2510 break;
2511
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002512 case STMT_REF_PTR:
2513 IsStmtReference = true;
2514 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2515 "No stmt was recorded for this offset reference!");
David L. Jonesbe1557a2016-12-21 00:17:49 +00002516 S = StmtEntries[Record.readInt()];
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002517 break;
2518
Sebastian Redl539c5062010-08-18 23:57:32 +00002519 case STMT_NULL_PTR:
Craig Toppera13603a2014-05-22 05:54:18 +00002520 S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002521 break;
2522
Sebastian Redl539c5062010-08-18 23:57:32 +00002523 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002524 S = new (Context) NullStmt(Empty);
2525 break;
2526
Sebastian Redl539c5062010-08-18 23:57:32 +00002527 case STMT_COMPOUND:
Benjamin Kramer07420902017-12-24 16:24:20 +00002528 S = CompoundStmt::CreateEmpty(
2529 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002530 break;
2531
Sebastian Redl539c5062010-08-18 23:57:32 +00002532 case STMT_CASE:
Bruno Ricci5b30571752018-10-28 12:30:53 +00002533 S = CaseStmt::CreateEmpty(
2534 Context,
2535 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002536 break;
2537
Sebastian Redl539c5062010-08-18 23:57:32 +00002538 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002539 S = new (Context) DefaultStmt(Empty);
2540 break;
2541
Sebastian Redl539c5062010-08-18 23:57:32 +00002542 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002543 S = new (Context) LabelStmt(Empty);
2544 break;
2545
Richard Smithc202b282012-04-14 00:33:13 +00002546 case STMT_ATTRIBUTED:
Alexander Kornienko20f6fc62012-07-09 10:04:07 +00002547 S = AttributedStmt::CreateEmpty(
2548 Context,
2549 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smithc202b282012-04-14 00:33:13 +00002550 break;
2551
Sebastian Redl539c5062010-08-18 23:57:32 +00002552 case STMT_IF:
Bruno Riccib1cc94b2018-10-27 21:12:20 +00002553 S = IfStmt::CreateEmpty(
2554 Context,
2555 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2556 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2557 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002558 break;
2559
Sebastian Redl539c5062010-08-18 23:57:32 +00002560 case STMT_SWITCH:
Bruno Riccie2806f82018-10-29 16:12:37 +00002561 S = SwitchStmt::CreateEmpty(
2562 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002563 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
Bruno Riccie2806f82018-10-29 16:12:37 +00002564 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002565 break;
2566
Sebastian Redl539c5062010-08-18 23:57:32 +00002567 case STMT_WHILE:
Bruno Riccibacf7512018-10-30 13:42:41 +00002568 S = WhileStmt::CreateEmpty(
2569 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002570 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002571 break;
2572
Sebastian Redl539c5062010-08-18 23:57:32 +00002573 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002574 S = new (Context) DoStmt(Empty);
2575 break;
Mike Stump11289f42009-09-09 15:08:12 +00002576
Sebastian Redl539c5062010-08-18 23:57:32 +00002577 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002578 S = new (Context) ForStmt(Empty);
2579 break;
2580
Sebastian Redl539c5062010-08-18 23:57:32 +00002581 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002582 S = new (Context) GotoStmt(Empty);
2583 break;
Mike Stump11289f42009-09-09 15:08:12 +00002584
Sebastian Redl539c5062010-08-18 23:57:32 +00002585 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002586 S = new (Context) IndirectGotoStmt(Empty);
2587 break;
2588
Sebastian Redl539c5062010-08-18 23:57:32 +00002589 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002590 S = new (Context) ContinueStmt(Empty);
2591 break;
2592
Sebastian Redl539c5062010-08-18 23:57:32 +00002593 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002594 S = new (Context) BreakStmt(Empty);
2595 break;
2596
Sebastian Redl539c5062010-08-18 23:57:32 +00002597 case STMT_RETURN:
Bruno Ricci023b1d12018-10-30 14:40:49 +00002598 S = ReturnStmt::CreateEmpty(
2599 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002600 break;
2601
Sebastian Redl539c5062010-08-18 23:57:32 +00002602 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002603 S = new (Context) DeclStmt(Empty);
2604 break;
2605
Chad Rosierde70e0e2012-08-25 00:11:56 +00002606 case STMT_GCCASM:
2607 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002608 break;
2609
Chad Rosiere30d4992012-08-24 23:51:02 +00002610 case STMT_MSASM:
2611 S = new (Context) MSAsmStmt(Empty);
2612 break;
2613
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002614 case STMT_CAPTURED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002615 S = CapturedStmt::CreateDeserialized(
2616 Context, Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002617 break;
2618
Bill Wendling7c44da22018-10-31 03:48:47 +00002619 case EXPR_CONSTANT:
Gauthier Harnisch83c7b612019-06-15 10:24:47 +00002620 S = ConstantExpr::CreateEmpty(
2621 Context,
2622 static_cast<ConstantExpr::ResultStorageKind>(
2623 Record[ASTStmtReader::NumExprFields]),
2624 Empty);
Bill Wendling7c44da22018-10-31 03:48:47 +00002625 break;
2626
Sebastian Redl539c5062010-08-18 23:57:32 +00002627 case EXPR_PREDEFINED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002628 S = PredefinedExpr::CreateEmpty(
2629 Context,
2630 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002631 break;
Mike Stump11289f42009-09-09 15:08:12 +00002632
Sebastian Redl539c5062010-08-18 23:57:32 +00002633 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002634 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00002635 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002636 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2637 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnara7945c982012-01-27 09:46:47 +00002638 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002639 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Richard Smith715f7a12019-06-11 17:50:32 +00002640 Record[ASTStmtReader::NumExprFields + 6] : 0);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002641 break;
Mike Stump11289f42009-09-09 15:08:12 +00002642
Sebastian Redl539c5062010-08-18 23:57:32 +00002643 case EXPR_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002644 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002645 break;
Mike Stump11289f42009-09-09 15:08:12 +00002646
Sebastian Redl539c5062010-08-18 23:57:32 +00002647 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002648 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002649 break;
Mike Stump11289f42009-09-09 15:08:12 +00002650
Sebastian Redl539c5062010-08-18 23:57:32 +00002651 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002652 S = new (Context) ImaginaryLiteral(Empty);
2653 break;
2654
Sebastian Redl539c5062010-08-18 23:57:32 +00002655 case EXPR_STRING_LITERAL:
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002656 S = StringLiteral::CreateEmpty(
2657 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002658 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002659 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2660 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002661 break;
2662
Sebastian Redl539c5062010-08-18 23:57:32 +00002663 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002664 S = new (Context) CharacterLiteral(Empty);
2665 break;
2666
Sebastian Redl539c5062010-08-18 23:57:32 +00002667 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002668 S = new (Context) ParenExpr(Empty);
2669 break;
2670
Sebastian Redl539c5062010-08-18 23:57:32 +00002671 case EXPR_PAREN_LIST:
Bruno Riccif49e1ca2018-11-20 16:20:40 +00002672 S = ParenListExpr::CreateEmpty(
2673 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002674 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00002675 break;
2676
Sebastian Redl539c5062010-08-18 23:57:32 +00002677 case EXPR_UNARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002678 S = new (Context) UnaryOperator(Empty);
2679 break;
2680
Sebastian Redl539c5062010-08-18 23:57:32 +00002681 case EXPR_OFFSETOF:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002682 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002683 Record[ASTStmtReader::NumExprFields],
2684 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00002685 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002686
Sebastian Redl539c5062010-08-18 23:57:32 +00002687 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00002688 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002689 break;
2690
Sebastian Redl539c5062010-08-18 23:57:32 +00002691 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002692 S = new (Context) ArraySubscriptExpr(Empty);
2693 break;
2694
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002695 case EXPR_OMP_ARRAY_SECTION:
2696 S = new (Context) OMPArraySectionExpr(Empty);
2697 break;
2698
Sebastian Redl539c5062010-08-18 23:57:32 +00002699 case EXPR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00002700 S = CallExpr::CreateEmpty(
2701 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002702 break;
2703
Richard Smithdcf17de2019-06-06 23:24:15 +00002704 case EXPR_MEMBER:
2705 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
2706 Record[ASTStmtReader::NumExprFields + 1],
2707 Record[ASTStmtReader::NumExprFields + 2],
2708 Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002709 break;
2710
Sebastian Redl539c5062010-08-18 23:57:32 +00002711 case EXPR_BINARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002712 S = new (Context) BinaryOperator(Empty);
2713 break;
2714
Sebastian Redl539c5062010-08-18 23:57:32 +00002715 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002716 S = new (Context) CompoundAssignOperator(Empty);
2717 break;
2718
Sebastian Redl539c5062010-08-18 23:57:32 +00002719 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002720 S = new (Context) ConditionalOperator(Empty);
2721 break;
2722
John McCallc07a0c72011-02-17 10:25:35 +00002723 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2724 S = new (Context) BinaryConditionalOperator(Empty);
2725 break;
2726
Sebastian Redl539c5062010-08-18 23:57:32 +00002727 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002728 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002729 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002730 break;
2731
Sebastian Redl539c5062010-08-18 23:57:32 +00002732 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002733 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002734 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002735 break;
2736
Sebastian Redl539c5062010-08-18 23:57:32 +00002737 case EXPR_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002738 S = new (Context) CompoundLiteralExpr(Empty);
2739 break;
2740
Sebastian Redl539c5062010-08-18 23:57:32 +00002741 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002742 S = new (Context) ExtVectorElementExpr(Empty);
2743 break;
2744
Sebastian Redl539c5062010-08-18 23:57:32 +00002745 case EXPR_INIT_LIST:
Argyrios Kyrtzidis0f05fb92012-11-28 03:56:16 +00002746 S = new (Context) InitListExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002747 break;
2748
Sebastian Redl539c5062010-08-18 23:57:32 +00002749 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002750 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002751 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00002752
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002753 break;
2754
Yunzhong Gaocb779302015-06-10 00:27:52 +00002755 case EXPR_DESIGNATED_INIT_UPDATE:
2756 S = new (Context) DesignatedInitUpdateExpr(Empty);
2757 break;
2758
Sebastian Redl539c5062010-08-18 23:57:32 +00002759 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002760 S = new (Context) ImplicitValueInitExpr(Empty);
2761 break;
2762
Yunzhong Gaocb779302015-06-10 00:27:52 +00002763 case EXPR_NO_INIT:
2764 S = new (Context) NoInitExpr(Empty);
2765 break;
2766
Richard Smith410306b2016-12-12 02:53:20 +00002767 case EXPR_ARRAY_INIT_LOOP:
2768 S = new (Context) ArrayInitLoopExpr(Empty);
2769 break;
2770
2771 case EXPR_ARRAY_INIT_INDEX:
2772 S = new (Context) ArrayInitIndexExpr(Empty);
2773 break;
2774
Sebastian Redl539c5062010-08-18 23:57:32 +00002775 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002776 S = new (Context) VAArgExpr(Empty);
2777 break;
2778
Eric Fiselier708afb52019-05-16 21:04:15 +00002779 case EXPR_SOURCE_LOC:
2780 S = new (Context) SourceLocExpr(Empty);
2781 break;
2782
Sebastian Redl539c5062010-08-18 23:57:32 +00002783 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002784 S = new (Context) AddrLabelExpr(Empty);
2785 break;
2786
Sebastian Redl539c5062010-08-18 23:57:32 +00002787 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002788 S = new (Context) StmtExpr(Empty);
2789 break;
2790
Sebastian Redl539c5062010-08-18 23:57:32 +00002791 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002792 S = new (Context) ChooseExpr(Empty);
2793 break;
2794
Sebastian Redl539c5062010-08-18 23:57:32 +00002795 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002796 S = new (Context) GNUNullExpr(Empty);
2797 break;
2798
Sebastian Redl539c5062010-08-18 23:57:32 +00002799 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002800 S = new (Context) ShuffleVectorExpr(Empty);
2801 break;
Mike Stump11289f42009-09-09 15:08:12 +00002802
Hal Finkelc4d7c822013-09-18 03:29:45 +00002803 case EXPR_CONVERT_VECTOR:
2804 S = new (Context) ConvertVectorExpr(Empty);
2805 break;
2806
Sebastian Redl539c5062010-08-18 23:57:32 +00002807 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002808 S = new (Context) BlockExpr(Empty);
2809 break;
2810
Peter Collingbourne91147592011-04-15 00:35:48 +00002811 case EXPR_GENERIC_SELECTION:
Bruno Riccidb076832019-01-26 14:15:10 +00002812 S = GenericSelectionExpr::CreateEmpty(
2813 Context,
2814 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
Peter Collingbourne91147592011-04-15 00:35:48 +00002815 break;
2816
Sebastian Redl539c5062010-08-18 23:57:32 +00002817 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002818 S = new (Context) ObjCStringLiteral(Empty);
2819 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002820
Patrick Beard0caa3942012-04-19 00:25:12 +00002821 case EXPR_OBJC_BOXED_EXPRESSION:
2822 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremeneke65b0862012-03-06 20:05:56 +00002823 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002824
Ted Kremeneke65b0862012-03-06 20:05:56 +00002825 case EXPR_OBJC_ARRAY_LITERAL:
2826 S = ObjCArrayLiteral::CreateEmpty(Context,
2827 Record[ASTStmtReader::NumExprFields]);
2828 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002829
Ted Kremeneke65b0862012-03-06 20:05:56 +00002830 case EXPR_OBJC_DICTIONARY_LITERAL:
2831 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2832 Record[ASTStmtReader::NumExprFields],
2833 Record[ASTStmtReader::NumExprFields + 1]);
2834 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002835
Sebastian Redl539c5062010-08-18 23:57:32 +00002836 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002837 S = new (Context) ObjCEncodeExpr(Empty);
2838 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002839
Sebastian Redl539c5062010-08-18 23:57:32 +00002840 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002841 S = new (Context) ObjCSelectorExpr(Empty);
2842 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002843
Sebastian Redl539c5062010-08-18 23:57:32 +00002844 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002845 S = new (Context) ObjCProtocolExpr(Empty);
2846 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002847
Sebastian Redl539c5062010-08-18 23:57:32 +00002848 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002849 S = new (Context) ObjCIvarRefExpr(Empty);
2850 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002851
Sebastian Redl539c5062010-08-18 23:57:32 +00002852 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002853 S = new (Context) ObjCPropertyRefExpr(Empty);
2854 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002855
Ted Kremeneke65b0862012-03-06 20:05:56 +00002856 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2857 S = new (Context) ObjCSubscriptRefExpr(Empty);
2858 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002859
Sebastian Redl539c5062010-08-18 23:57:32 +00002860 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00002861 llvm_unreachable("mismatching AST file");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002862
Sebastian Redl539c5062010-08-18 23:57:32 +00002863 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002864 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00002865 Record[ASTStmtReader::NumExprFields],
2866 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002867 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002868
Sebastian Redl539c5062010-08-18 23:57:32 +00002869 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00002870 S = new (Context) ObjCIsaExpr(Empty);
2871 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002872
John McCall31168b02011-06-15 23:02:42 +00002873 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2874 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2875 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002876
John McCall31168b02011-06-15 23:02:42 +00002877 case EXPR_OBJC_BRIDGED_CAST:
2878 S = new (Context) ObjCBridgedCastExpr(Empty);
2879 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002880
Sebastian Redl539c5062010-08-18 23:57:32 +00002881 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002882 S = new (Context) ObjCForCollectionStmt(Empty);
2883 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002884
Sebastian Redl539c5062010-08-18 23:57:32 +00002885 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002886 S = new (Context) ObjCAtCatchStmt(Empty);
2887 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002888
Sebastian Redl539c5062010-08-18 23:57:32 +00002889 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002890 S = new (Context) ObjCAtFinallyStmt(Empty);
2891 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002892
Sebastian Redl539c5062010-08-18 23:57:32 +00002893 case STMT_OBJC_AT_TRY:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002894 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002895 Record[ASTStmtReader::NumStmtFields],
2896 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002897 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002898
Sebastian Redl539c5062010-08-18 23:57:32 +00002899 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002900 S = new (Context) ObjCAtSynchronizedStmt(Empty);
2901 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002902
Sebastian Redl539c5062010-08-18 23:57:32 +00002903 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002904 S = new (Context) ObjCAtThrowStmt(Empty);
2905 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002906
John McCall31168b02011-06-15 23:02:42 +00002907 case STMT_OBJC_AUTORELEASE_POOL:
2908 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2909 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002910
Ted Kremeneke65b0862012-03-06 20:05:56 +00002911 case EXPR_OBJC_BOOL_LITERAL:
2912 S = new (Context) ObjCBoolLiteralExpr(Empty);
2913 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002914
Erik Pilkington29099de2016-07-16 00:35:23 +00002915 case EXPR_OBJC_AVAILABILITY_CHECK:
2916 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
2917 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002918
Nico Weber9b982072014-07-07 00:12:30 +00002919 case STMT_SEH_LEAVE:
2920 S = new (Context) SEHLeaveStmt(Empty);
2921 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002922
John McCallfa194042011-07-15 07:00:14 +00002923 case STMT_SEH_EXCEPT:
2924 S = new (Context) SEHExceptStmt(Empty);
2925 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002926
John McCallfa194042011-07-15 07:00:14 +00002927 case STMT_SEH_FINALLY:
2928 S = new (Context) SEHFinallyStmt(Empty);
2929 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002930
John McCallfa194042011-07-15 07:00:14 +00002931 case STMT_SEH_TRY:
2932 S = new (Context) SEHTryStmt(Empty);
2933 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002934
Sebastian Redl539c5062010-08-18 23:57:32 +00002935 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00002936 S = new (Context) CXXCatchStmt(Empty);
2937 break;
2938
Sebastian Redl539c5062010-08-18 23:57:32 +00002939 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002940 S = CXXTryStmt::Create(Context, Empty,
Rui Ueyama49a3ad22019-07-16 04:46:31 +00002941 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00002942 break;
2943
Richard Smith02e85f32011-04-14 22:09:26 +00002944 case STMT_CXX_FOR_RANGE:
2945 S = new (Context) CXXForRangeStmt(Empty);
2946 break;
2947
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00002948 case STMT_MS_DEPENDENT_EXISTS:
2949 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2950 NestedNameSpecifierLoc(),
2951 DeclarationNameInfo(),
Craig Toppera13603a2014-05-22 05:54:18 +00002952 nullptr);
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00002953 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002954
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002955 case STMT_OMP_PARALLEL_DIRECTIVE:
2956 S =
2957 OMPParallelDirective::CreateEmpty(Context,
2958 Record[ASTStmtReader::NumStmtFields],
2959 Empty);
2960 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002961
2962 case STMT_OMP_SIMD_DIRECTIVE: {
2963 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2964 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2965 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
2966 CollapsedNum, Empty);
2967 break;
2968 }
2969
Alexey Bataevf29276e2014-06-18 04:14:57 +00002970 case STMT_OMP_FOR_DIRECTIVE: {
2971 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2972 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2973 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2974 Empty);
2975 break;
2976 }
2977
Alexander Musmanf82886e2014-09-18 05:12:34 +00002978 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
2979 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2980 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2981 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2982 Empty);
2983 break;
2984 }
2985
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002986 case STMT_OMP_SECTIONS_DIRECTIVE:
2987 S = OMPSectionsDirective::CreateEmpty(
2988 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2989 break;
2990
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002991 case STMT_OMP_SECTION_DIRECTIVE:
2992 S = OMPSectionDirective::CreateEmpty(Context, Empty);
2993 break;
2994
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002995 case STMT_OMP_SINGLE_DIRECTIVE:
2996 S = OMPSingleDirective::CreateEmpty(
2997 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2998 break;
2999
Alexander Musman80c22892014-07-17 08:54:58 +00003000 case STMT_OMP_MASTER_DIRECTIVE:
3001 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3002 break;
3003
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003004 case STMT_OMP_CRITICAL_DIRECTIVE:
Alexey Bataev28c75412015-12-15 08:19:24 +00003005 S = OMPCriticalDirective::CreateEmpty(
3006 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003007 break;
3008
Alexey Bataev4acb8592014-07-07 13:01:15 +00003009 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3010 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3011 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3012 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3013 CollapsedNum, Empty);
3014 break;
3015 }
3016
Alexander Musmane4e893b2014-09-23 09:33:00 +00003017 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3018 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3019 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3020 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3021 CollapsedNum, Empty);
3022 break;
3023 }
3024
cchen47d60942019-12-05 13:43:48 -05003025 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3026 S = OMPParallelMasterDirective::CreateEmpty(
3027 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3028 break;
3029
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00003030 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3031 S = OMPParallelSectionsDirective::CreateEmpty(
3032 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3033 break;
3034
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00003035 case STMT_OMP_TASK_DIRECTIVE:
3036 S = OMPTaskDirective::CreateEmpty(
3037 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3038 break;
3039
Alexey Bataev68446b72014-07-18 07:47:19 +00003040 case STMT_OMP_TASKYIELD_DIRECTIVE:
3041 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3042 break;
3043
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00003044 case STMT_OMP_BARRIER_DIRECTIVE:
3045 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3046 break;
3047
Alexey Bataev2df347a2014-07-18 10:17:07 +00003048 case STMT_OMP_TASKWAIT_DIRECTIVE:
3049 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3050 break;
3051
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003052 case STMT_OMP_TASKGROUP_DIRECTIVE:
Alexey Bataev169d96a2017-07-18 20:17:46 +00003053 S = OMPTaskgroupDirective::CreateEmpty(
3054 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003055 break;
3056
Alexey Bataev6125da92014-07-21 11:26:11 +00003057 case STMT_OMP_FLUSH_DIRECTIVE:
3058 S = OMPFlushDirective::CreateEmpty(
3059 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3060 break;
3061
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003062 case STMT_OMP_ORDERED_DIRECTIVE:
Alexey Bataev346265e2015-09-25 10:37:12 +00003063 S = OMPOrderedDirective::CreateEmpty(
3064 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003065 break;
3066
Alexey Bataev0162e452014-07-22 10:10:35 +00003067 case STMT_OMP_ATOMIC_DIRECTIVE:
3068 S = OMPAtomicDirective::CreateEmpty(
3069 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3070 break;
3071
Alexey Bataev0bd520b2014-09-19 08:19:49 +00003072 case STMT_OMP_TARGET_DIRECTIVE:
3073 S = OMPTargetDirective::CreateEmpty(
3074 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3075 break;
3076
Michael Wong65f367f2015-07-21 13:44:28 +00003077 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3078 S = OMPTargetDataDirective::CreateEmpty(
3079 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3080 break;
3081
Samuel Antaodf67fc42016-01-19 19:15:56 +00003082 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3083 S = OMPTargetEnterDataDirective::CreateEmpty(
3084 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3085 break;
3086
Samuel Antao72590762016-01-19 20:04:50 +00003087 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3088 S = OMPTargetExitDataDirective::CreateEmpty(
3089 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3090 break;
3091
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00003092 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3093 S = OMPTargetParallelDirective::CreateEmpty(
3094 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3095 break;
3096
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00003097 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3098 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3099 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3100 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3101 CollapsedNum, Empty);
3102 break;
3103 }
3104
Samuel Antao686c70c2016-05-26 17:30:50 +00003105 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3106 S = OMPTargetUpdateDirective::CreateEmpty(
3107 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3108 break;
3109
Alexey Bataev13314bf2014-10-09 04:18:56 +00003110 case STMT_OMP_TEAMS_DIRECTIVE:
3111 S = OMPTeamsDirective::CreateEmpty(
3112 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3113 break;
3114
Alexey Bataev6d4ed052015-07-01 06:57:41 +00003115 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3116 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3117 break;
3118
Alexey Bataev80909872015-07-02 11:25:17 +00003119 case STMT_OMP_CANCEL_DIRECTIVE:
Alexey Bataev87933c72015-09-18 08:07:34 +00003120 S = OMPCancelDirective::CreateEmpty(
3121 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev80909872015-07-02 11:25:17 +00003122 break;
3123
Alexey Bataev49f6e782015-12-01 04:18:41 +00003124 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3125 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3126 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3127 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3128 Empty);
3129 break;
3130 }
3131
Alexey Bataev0a6ed842015-12-03 09:40:15 +00003132 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3133 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3134 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3135 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3136 CollapsedNum, Empty);
3137 break;
3138 }
3139
Alexey Bataev60e51c42019-10-10 20:13:02 +00003140 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3141 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3142 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3143 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3144 CollapsedNum, Empty);
3145 break;
3146 }
3147
Alexey Bataevb8552ab2019-10-18 16:47:35 +00003148 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3149 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3150 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3151 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3152 CollapsedNum, Empty);
3153 break;
3154 }
3155
Alexey Bataev5bbcead2019-10-14 17:17:41 +00003156 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3157 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3158 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3159 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3160 CollapsedNum, Empty);
3161 break;
3162 }
3163
Alexey Bataev14a388f2019-10-25 10:27:13 -04003164 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3165 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3166 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3167 S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3168 Context, NumClauses, CollapsedNum, Empty);
3169 break;
3170 }
3171
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00003172 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3173 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3174 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3175 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3176 Empty);
3177 break;
3178 }
3179
Carlo Bertolli9925f152016-06-27 14:55:37 +00003180 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3181 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3182 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3183 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3184 CollapsedNum, Empty);
3185 break;
3186 }
3187
Kelvin Li4a39add2016-07-05 05:00:15 +00003188 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3189 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3190 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3191 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3192 CollapsedNum,
3193 Empty);
3194 break;
3195 }
3196
Kelvin Li787f3fc2016-07-06 04:45:38 +00003197 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3198 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3199 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3200 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3201 CollapsedNum, Empty);
3202 break;
3203 }
3204
Kelvin Lia579b912016-07-14 02:54:56 +00003205 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3206 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3207 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3208 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3209 CollapsedNum, Empty);
3210 break;
3211 }
3212
Kelvin Li986330c2016-07-20 22:57:10 +00003213 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3214 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3215 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3216 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3217 Empty);
3218 break;
3219 }
3220
Kelvin Li83c451e2016-12-25 04:52:54 +00003221 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
Kelvin Li02532872016-08-05 14:37:37 +00003222 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3223 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3224 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3225 CollapsedNum, Empty);
3226 break;
3227 }
3228
Kelvin Li4e325f72016-10-25 12:50:55 +00003229 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3230 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3231 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3232 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3233 CollapsedNum, Empty);
3234 break;
3235 }
3236
Kelvin Li579e41c2016-11-30 23:51:03 +00003237 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3238 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3239 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3240 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3241 Context, NumClauses, CollapsedNum, Empty);
3242 break;
3243 }
3244
Kelvin Li7ade93f2016-12-09 03:24:30 +00003245 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3246 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3247 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3248 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3249 Context, NumClauses, CollapsedNum, Empty);
3250 break;
3251 }
3252
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003253 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
Kelvin Libf594a52016-12-17 05:48:59 +00003254 S = OMPTargetTeamsDirective::CreateEmpty(
3255 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3256 break;
Kelvin Li83c451e2016-12-25 04:52:54 +00003257
3258 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3259 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3260 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3261 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3262 CollapsedNum, Empty);
3263 break;
3264 }
3265
Kelvin Li80e8f562016-12-29 22:16:30 +00003266 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3267 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3268 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3269 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3270 Context, NumClauses, CollapsedNum, Empty);
3271 break;
3272 }
3273
Kelvin Li1851df52017-01-03 05:23:48 +00003274 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3275 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3276 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3277 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3278 Context, NumClauses, CollapsedNum, Empty);
3279 break;
3280 }
3281
Kelvin Lida681182017-01-10 18:08:18 +00003282 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3283 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3284 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3285 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3286 Context, NumClauses, CollapsedNum, Empty);
3287 break;
3288 }
3289
Sebastian Redl539c5062010-08-18 23:57:32 +00003290 case EXPR_CXX_OPERATOR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003291 S = CXXOperatorCallExpr::CreateEmpty(
3292 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00003293 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003294
Sebastian Redl539c5062010-08-18 23:57:32 +00003295 case EXPR_CXX_MEMBER_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003296 S = CXXMemberCallExpr::CreateEmpty(
3297 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003298 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003299
Richard Smith778dc0f2019-10-19 00:04:38 +00003300 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3301 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3302 break;
3303
Sebastian Redl539c5062010-08-18 23:57:32 +00003304 case EXPR_CXX_CONSTRUCT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003305 S = CXXConstructExpr::CreateEmpty(
3306 Context,
3307 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003308 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003309
Richard Smith5179eb72016-06-28 19:03:57 +00003310 case EXPR_CXX_INHERITED_CTOR_INIT:
3311 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3312 break;
3313
Sebastian Redl539c5062010-08-18 23:57:32 +00003314 case EXPR_CXX_TEMPORARY_OBJECT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003315 S = CXXTemporaryObjectExpr::CreateEmpty(
3316 Context,
3317 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00003318 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003319
Sebastian Redl539c5062010-08-18 23:57:32 +00003320 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003321 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003322 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003323 break;
3324
Sebastian Redl539c5062010-08-18 23:57:32 +00003325 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003326 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003327 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003328 break;
3329
Sebastian Redl539c5062010-08-18 23:57:32 +00003330 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003331 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003332 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003333 break;
3334
Sebastian Redl539c5062010-08-18 23:57:32 +00003335 case EXPR_CXX_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003336 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00003337 break;
3338
Sebastian Redl539c5062010-08-18 23:57:32 +00003339 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003340 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003341 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003342 break;
3343
Richard Smithc67fdd42012-03-07 08:35:16 +00003344 case EXPR_USER_DEFINED_LITERAL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003345 S = UserDefinedLiteral::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003346 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Richard Smithc67fdd42012-03-07 08:35:16 +00003347 break;
3348
Richard Smithcc1b96d2013-06-12 22:31:48 +00003349 case EXPR_CXX_STD_INITIALIZER_LIST:
3350 S = new (Context) CXXStdInitializerListExpr(Empty);
3351 break;
3352
Sebastian Redl539c5062010-08-18 23:57:32 +00003353 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003354 S = new (Context) CXXBoolLiteralExpr(Empty);
3355 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003356
Sebastian Redl539c5062010-08-18 23:57:32 +00003357 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003358 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3359 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003360
Sebastian Redl539c5062010-08-18 23:57:32 +00003361 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003362 S = new (Context) CXXTypeidExpr(Empty, true);
3363 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003364
Sebastian Redl539c5062010-08-18 23:57:32 +00003365 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003366 S = new (Context) CXXTypeidExpr(Empty, false);
3367 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003368
Francois Pichet9f4f2072010-09-08 12:20:18 +00003369 case EXPR_CXX_UUIDOF_EXPR:
3370 S = new (Context) CXXUuidofExpr(Empty, true);
3371 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003372
John McCall5e77d762013-04-16 07:28:30 +00003373 case EXPR_CXX_PROPERTY_REF_EXPR:
3374 S = new (Context) MSPropertyRefExpr(Empty);
3375 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003376
Alexey Bataevf7630272015-11-25 12:01:00 +00003377 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3378 S = new (Context) MSPropertySubscriptExpr(Empty);
3379 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003380
Francois Pichet9f4f2072010-09-08 12:20:18 +00003381 case EXPR_CXX_UUIDOF_TYPE:
3382 S = new (Context) CXXUuidofExpr(Empty, false);
3383 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003384
Sebastian Redl539c5062010-08-18 23:57:32 +00003385 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00003386 S = new (Context) CXXThisExpr(Empty);
3387 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003388
Sebastian Redl539c5062010-08-18 23:57:32 +00003389 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00003390 S = new (Context) CXXThrowExpr(Empty);
3391 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003392
John McCall32791cc2016-01-06 22:34:54 +00003393 case EXPR_CXX_DEFAULT_ARG:
3394 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00003395 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003396
Richard Smith852c9db2013-04-20 22:23:05 +00003397 case EXPR_CXX_DEFAULT_INIT:
3398 S = new (Context) CXXDefaultInitExpr(Empty);
3399 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003400
Sebastian Redl539c5062010-08-18 23:57:32 +00003401 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00003402 S = new (Context) CXXBindTemporaryExpr(Empty);
3403 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003404
Sebastian Redl539c5062010-08-18 23:57:32 +00003405 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00003406 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003407 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003408
Sebastian Redl539c5062010-08-18 23:57:32 +00003409 case EXPR_CXX_NEW:
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00003410 S = CXXNewExpr::CreateEmpty(
3411 Context,
3412 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3413 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3414 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3415 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003416 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003417
Sebastian Redl539c5062010-08-18 23:57:32 +00003418 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00003419 S = new (Context) CXXDeleteExpr(Empty);
3420 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003421
Sebastian Redl539c5062010-08-18 23:57:32 +00003422 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00003423 S = new (Context) CXXPseudoDestructorExpr(Empty);
3424 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003425
John McCall5d413782010-12-06 08:20:24 +00003426 case EXPR_EXPR_WITH_CLEANUPS:
John McCall28fc7092011-11-10 05:35:25 +00003427 S = ExprWithCleanups::Create(Context, Empty,
3428 Record[ASTStmtReader::NumExprFields]);
Chris Lattnercba86142010-05-10 00:25:06 +00003429 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003430
Sebastian Redl539c5062010-08-18 23:57:32 +00003431 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Bruno Ricci2e6dc532019-01-08 14:17:00 +00003432 S = CXXDependentScopeMemberExpr::CreateEmpty(
3433 Context,
3434 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3435 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3436 /*HasFirstQualifierFoundInScope=*/
3437 Record[ASTStmtReader::NumExprFields + 2]);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003438 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003439
Sebastian Redl539c5062010-08-18 23:57:32 +00003440 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003441 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003442 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003443 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003444 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003445 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00003446 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003447
Sebastian Redl539c5062010-08-18 23:57:32 +00003448 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003449 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003450 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00003451 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003452
Sebastian Redl539c5062010-08-18 23:57:32 +00003453 case EXPR_CXX_UNRESOLVED_MEMBER:
Bruno Riccid7628d92019-01-09 15:43:19 +00003454 S = UnresolvedMemberExpr::CreateEmpty(
3455 Context,
3456 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3457 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3458 /*NumTemplateArgs=*/
3459 Record[ASTStmtReader::NumExprFields + 1]
3460 ? Record[ASTStmtReader::NumExprFields + 2]
3461 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003462 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003463
Sebastian Redl539c5062010-08-18 23:57:32 +00003464 case EXPR_CXX_UNRESOLVED_LOOKUP:
Bruno Riccid7628d92019-01-09 15:43:19 +00003465 S = UnresolvedLookupExpr::CreateEmpty(
3466 Context,
3467 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3468 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3469 /*NumTemplateArgs=*/
3470 Record[ASTStmtReader::NumExprFields + 1]
3471 ? Record[ASTStmtReader::NumExprFields + 2]
3472 : 0);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00003473 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003474
Douglas Gregor29c42f22012-02-24 07:38:34 +00003475 case EXPR_TYPE_TRAIT:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003476 S = TypeTraitExpr::CreateDeserialized(Context,
Douglas Gregor29c42f22012-02-24 07:38:34 +00003477 Record[ASTStmtReader::NumExprFields]);
3478 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003479
John Wiegley6242b6a2011-04-28 00:16:57 +00003480 case EXPR_ARRAY_TYPE_TRAIT:
3481 S = new (Context) ArrayTypeTraitExpr(Empty);
3482 break;
3483
John Wiegleyf9f65842011-04-25 06:54:41 +00003484 case EXPR_CXX_EXPRESSION_TRAIT:
3485 S = new (Context) ExpressionTraitExpr(Empty);
3486 break;
3487
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003488 case EXPR_CXX_NOEXCEPT:
3489 S = new (Context) CXXNoexceptExpr(Empty);
3490 break;
John McCall8d69a212010-11-15 23:31:06 +00003491
Douglas Gregore8e9dd62011-01-03 17:17:50 +00003492 case EXPR_PACK_EXPANSION:
3493 S = new (Context) PackExpansionExpr(Empty);
3494 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003495
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003496 case EXPR_SIZEOF_PACK:
Richard Smithd784e682015-09-23 21:41:42 +00003497 S = SizeOfPackExpr::CreateDeserialized(
3498 Context,
3499 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003500 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003501
John McCallfa194042011-07-15 07:00:14 +00003502 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3503 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3504 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003505
Douglas Gregorcdbc5392011-01-15 01:15:58 +00003506 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3507 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3508 break;
Richard Smithb15fe3a2012-09-12 00:56:43 +00003509
3510 case EXPR_FUNCTION_PARM_PACK:
3511 S = FunctionParmPackExpr::CreateEmpty(Context,
3512 Record[ASTStmtReader::NumExprFields]);
3513 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003514
Douglas Gregorfe314812011-06-21 17:03:29 +00003515 case EXPR_MATERIALIZE_TEMPORARY:
3516 S = new (Context) MaterializeTemporaryExpr(Empty);
3517 break;
Richard Smith0f0af192014-11-08 05:07:16 +00003518
3519 case EXPR_CXX_FOLD:
3520 S = new (Context) CXXFoldExpr(Empty);
3521 break;
3522
Argyrios Kyrtzidisb2b07952011-12-03 03:49:52 +00003523 case EXPR_OPAQUE_VALUE:
3524 S = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00003525 break;
Peter Collingbourne41f85462011-02-09 21:07:24 +00003526
3527 case EXPR_CUDA_KERNEL_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003528 S = CUDAKernelCallExpr::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003529 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00003530 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003531
Tanya Lattner55808c12011-06-04 00:47:47 +00003532 case EXPR_ASTYPE:
3533 S = new (Context) AsTypeExpr(Empty);
3534 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003535
John McCallfe96e0b2011-11-06 09:01:30 +00003536 case EXPR_PSEUDO_OBJECT: {
3537 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3538 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3539 break;
3540 }
3541
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003542 case EXPR_ATOMIC:
3543 S = new (Context) AtomicExpr(Empty);
3544 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003545
Douglas Gregor99ae8062012-02-14 17:54:36 +00003546 case EXPR_LAMBDA: {
3547 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
Richard Smith30e304e2016-12-14 00:03:17 +00003548 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
Douglas Gregor99ae8062012-02-14 17:54:36 +00003549 break;
3550 }
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +00003551
3552 case STMT_COROUTINE_BODY: {
3553 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3554 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3555 break;
3556 }
3557
3558 case STMT_CORETURN:
3559 S = new (Context) CoreturnStmt(Empty);
3560 break;
3561
3562 case EXPR_COAWAIT:
3563 S = new (Context) CoawaitExpr(Empty);
3564 break;
3565
3566 case EXPR_COYIELD:
3567 S = new (Context) CoyieldExpr(Empty);
3568 break;
3569
3570 case EXPR_DEPENDENT_COAWAIT:
3571 S = new (Context) DependentCoawaitExpr(Empty);
3572 break;
Saar Raz5d98ba62019-10-15 15:24:26 +00003573
3574 case EXPR_CONCEPT_SPECIALIZATION:
3575 unsigned numTemplateArgs = Record[ASTStmtReader::NumExprFields];
3576 S = ConceptSpecializationExpr::Create(Context, Empty, numTemplateArgs);
3577 break;
3578
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003579 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003580
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003581 // We hit a STMT_STOP, so we're done with this expression.
3582 if (Finished)
3583 break;
3584
3585 ++NumStatementsRead;
3586
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003587 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003588 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003589 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3590 }
3591
David L. Jonesbe1557a2016-12-21 00:17:49 +00003592 assert(Record.getIdx() == Record.size() &&
3593 "Invalid deserialization of statement");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003594 StmtStack.push_back(S);
3595 }
Chris Lattner0e6c9402013-01-20 02:38:54 +00003596Done:
Alp Toker028ed912013-12-06 17:56:43 +00003597 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003598 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003599 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003600}