blob: f558c26b5f1e8a9e2f551d7ef14b3f8c2ced9727 [file] [log] [blame]
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001//===- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------------------===//
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Chris Lattner92ba5ff2009-04-27 05:14:47 +00006//
7//===----------------------------------------------------------------------===//
8//
9// Statement/expression deserialization. This implements the
Sebastian Redl2c499f62010-08-18 23:56:43 +000010// ASTReader::ReadStmt method.
Chris Lattner92ba5ff2009-04-27 05:14:47 +000011//
12//===----------------------------------------------------------------------===//
13
John McCallc2f18312019-12-14 03:01:28 -050014#include "clang/Serialization/ASTRecordReader.h"
Saar Razfdf80e82019-12-06 01:30:21 +020015#include "clang/AST/ASTConcept.h"
Benjamin Kramer4ab984e2012-07-04 20:19:54 +000016#include "clang/AST/ASTContext.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000017#include "clang/AST/AttrIterator.h"
18#include "clang/AST/Decl.h"
19#include "clang/AST/DeclAccessPair.h"
Douglas Gregor5d3507d2009-09-09 23:08:42 +000020#include "clang/AST/DeclCXX.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000021#include "clang/AST/DeclGroup.h"
22#include "clang/AST/DeclObjC.h"
Douglas Gregorcdbc5392011-01-15 01:15:58 +000023#include "clang/AST/DeclTemplate.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000024#include "clang/AST/DeclarationName.h"
25#include "clang/AST/Expr.h"
26#include "clang/AST/ExprCXX.h"
27#include "clang/AST/ExprObjC.h"
28#include "clang/AST/ExprOpenMP.h"
29#include "clang/AST/NestedNameSpecifier.h"
30#include "clang/AST/OpenMPClause.h"
31#include "clang/AST/OperationKinds.h"
32#include "clang/AST/Stmt.h"
33#include "clang/AST/StmtCXX.h"
34#include "clang/AST/StmtObjC.h"
35#include "clang/AST/StmtOpenMP.h"
Chris Lattner92ba5ff2009-04-27 05:14:47 +000036#include "clang/AST/StmtVisitor.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000037#include "clang/AST/TemplateBase.h"
38#include "clang/AST/Type.h"
39#include "clang/AST/UnresolvedSet.h"
40#include "clang/Basic/CapturedStmt.h"
41#include "clang/Basic/ExpressionTraits.h"
42#include "clang/Basic/LLVM.h"
43#include "clang/Basic/Lambda.h"
44#include "clang/Basic/LangOptions.h"
45#include "clang/Basic/OpenMPKinds.h"
46#include "clang/Basic/OperatorKinds.h"
47#include "clang/Basic/SourceLocation.h"
48#include "clang/Basic/Specifiers.h"
49#include "clang/Basic/TypeTraits.h"
John McCallf413f5e2013-05-03 00:10:13 +000050#include "clang/Lex/Token.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000051#include "clang/Serialization/ASTBitCodes.h"
52#include "llvm/ADT/DenseMap.h"
Benjamin Kramer49038022012-02-04 13:45:25 +000053#include "llvm/ADT/SmallString.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000054#include "llvm/ADT/SmallVector.h"
55#include "llvm/ADT/StringRef.h"
Francis Visoiu Mistrihe0308272019-07-03 22:40:07 +000056#include "llvm/Bitstream/BitstreamReader.h"
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000057#include "llvm/Support/Casting.h"
58#include "llvm/Support/ErrorHandling.h"
59#include <algorithm>
60#include <cassert>
61#include <cstdint>
62#include <string>
63
Chris Lattner92ba5ff2009-04-27 05:14:47 +000064using namespace clang;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +000065using namespace serialization;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000066
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +000067namespace clang {
Argyrios Kyrtzidisddf5f212010-06-28 09:31:42 +000068
Sebastian Redl70c751d2010-08-18 23:56:52 +000069 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
David L. Jonesbe1557a2016-12-21 00:17:49 +000070 ASTRecordReader &Record;
Sebastian Redlc67764e2010-07-22 22:43:28 +000071 llvm::BitstreamCursor &DeclsCursor;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000072
John McCall3ce3d232019-12-13 03:37:23 -050073 SourceLocation readSourceLocation() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000074 return Record.readSourceLocation();
John McCallf413f5e2013-05-03 00:10:13 +000075 }
76
John McCall3ce3d232019-12-13 03:37:23 -050077 SourceRange readSourceRange() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000078 return Record.readSourceRange();
Sebastian Redl2c373b92010-10-05 15:59:54 +000079 }
John McCallf413f5e2013-05-03 00:10:13 +000080
John McCall3ce3d232019-12-13 03:37:23 -050081 std::string readString() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000082 return Record.readString();
Sebastian Redl2c373b92010-10-05 15:59:54 +000083 }
John McCallf413f5e2013-05-03 00:10:13 +000084
John McCall3ce3d232019-12-13 03:37:23 -050085 TypeSourceInfo *readTypeSourceInfo() {
86 return Record.readTypeSourceInfo();
John McCallf413f5e2013-05-03 00:10:13 +000087 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000088
John McCall3ce3d232019-12-13 03:37:23 -050089 Decl *readDecl() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000090 return Record.readDecl();
Sebastian Redl2c373b92010-10-05 15:59:54 +000091 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +000092
Douglas Gregor7fb09192011-07-21 22:35:25 +000093 template<typename T>
John McCall3ce3d232019-12-13 03:37:23 -050094 T *readDeclAs() {
David L. Jonesb6a8f022016-12-21 04:34:52 +000095 return Record.readDeclAs<T>();
Douglas Gregor7fb09192011-07-21 22:35:25 +000096 }
97
Chris Lattner92ba5ff2009-04-27 05:14:47 +000098 public:
David L. Jonesbe1557a2016-12-21 00:17:49 +000099 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
100 : Record(Record), DeclsCursor(Cursor) {}
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000101
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000102 /// The number of record fields required for the Stmt class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000103 /// itself.
Roman Lebedevb5700602019-03-20 16:32:36 +0000104 static const unsigned NumStmtFields = 1;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000105
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000106 /// The number of record fields required for the Expr class
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000107 /// itself.
Douglas Gregor678d76c2011-07-01 01:22:09 +0000108 static const unsigned NumExprFields = NumStmtFields + 7;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000109
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000110 /// Read and initialize a ExplicitTemplateArgumentList structure.
Abramo Bagnara7945c982012-01-27 09:46:47 +0000111 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
James Y Knighte7d82282015-12-29 18:15:14 +0000112 TemplateArgumentLoc *ArgsLocArray,
Abramo Bagnara7945c982012-01-27 09:46:47 +0000113 unsigned NumTemplateArgs);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000114
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000115 /// Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisde6aa082011-09-22 20:07:03 +0000116 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000117 unsigned NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000118
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000119 void VisitStmt(Stmt *S);
John McCallfa194042011-07-15 07:00:14 +0000120#define STMT(Type, Base) \
121 void Visit##Type(Type *);
122#include "clang/AST/StmtNodes.inc"
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000123 };
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000124
125} // namespace clang
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000126
James Y Knighte7d82282015-12-29 18:15:14 +0000127void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
128 TemplateArgumentLoc *ArgsLocArray,
129 unsigned NumTemplateArgs) {
John McCall3ce3d232019-12-13 03:37:23 -0500130 SourceLocation TemplateKWLoc = readSourceLocation();
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000131 TemplateArgumentListInfo ArgInfo;
John McCall3ce3d232019-12-13 03:37:23 -0500132 ArgInfo.setLAngleLoc(readSourceLocation());
133 ArgInfo.setRAngleLoc(readSourceLocation());
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000134 for (unsigned i = 0; i != NumTemplateArgs; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000135 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
James Y Knighte7d82282015-12-29 18:15:14 +0000136 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000137}
138
Sebastian Redl70c751d2010-08-18 23:56:52 +0000139void ASTStmtReader::VisitStmt(Stmt *S) {
Roman Lebedevb5700602019-03-20 16:32:36 +0000140 S->setIsOMPStructuredBlock(Record.readInt());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000141 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000142}
143
Sebastian Redl70c751d2010-08-18 23:56:52 +0000144void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000145 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500146 S->setSemiLoc(readSourceLocation());
Bruno Ricci41d11c02018-10-27 18:43:27 +0000147 S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000148}
149
Sebastian Redl70c751d2010-08-18 23:56:52 +0000150void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000151 VisitStmt(S);
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000152 SmallVector<Stmt *, 16> Stmts;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000153 unsigned NumStmts = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000154 while (NumStmts--)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000155 Stmts.push_back(Record.readSubStmt());
Benjamin Kramer07420902017-12-24 16:24:20 +0000156 S->setStmts(Stmts);
John McCall3ce3d232019-12-13 03:37:23 -0500157 S->CompoundStmtBits.LBraceLoc = readSourceLocation();
158 S->RBraceLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000159}
160
Sebastian Redl70c751d2010-08-18 23:56:52 +0000161void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000162 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000163 Record.recordSwitchCaseID(S, Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500164 S->setKeywordLoc(readSourceLocation());
165 S->setColonLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000166}
167
Sebastian Redl70c751d2010-08-18 23:56:52 +0000168void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000169 VisitSwitchCase(S);
Bruno Ricci5b30571752018-10-28 12:30:53 +0000170 bool CaseStmtIsGNURange = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000171 S->setLHS(Record.readSubExpr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000172 S->setSubStmt(Record.readSubStmt());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000173 if (CaseStmtIsGNURange) {
174 S->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500175 S->setEllipsisLoc(readSourceLocation());
Bruno Ricci5b30571752018-10-28 12:30:53 +0000176 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000177}
178
Sebastian Redl70c751d2010-08-18 23:56:52 +0000179void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000180 VisitSwitchCase(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000181 S->setSubStmt(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000182}
183
Sebastian Redl70c751d2010-08-18 23:56:52 +0000184void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000185 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500186 auto *LD = readDeclAs<LabelDecl>();
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000187 LD->setStmt(S);
188 S->setDecl(LD);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000189 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500190 S->setIdentLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000191}
192
Richard Smithc202b282012-04-14 00:33:13 +0000193void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
194 VisitStmt(S);
Bruno Ricci41d11c02018-10-27 18:43:27 +0000195 // NumAttrs in AttributedStmt is set when creating an empty
196 // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
197 // to allocate the right amount of space for the trailing Attr *.
David L. Jonesbe1557a2016-12-21 00:17:49 +0000198 uint64_t NumAttrs = Record.readInt();
Richard Smithc202b282012-04-14 00:33:13 +0000199 AttrVec Attrs;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000200 Record.readAttributes(Attrs);
Matt Beaumont-Gayad0bb8e2012-07-09 18:55:31 +0000201 (void)NumAttrs;
Bruno Ricci41d11c02018-10-27 18:43:27 +0000202 assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
Alexander Kornienko20f6fc62012-07-09 10:04:07 +0000203 assert(NumAttrs == Attrs.size());
Aaron Ballmanf3d9b092014-05-13 14:55:01 +0000204 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000205 S->SubStmt = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500206 S->AttributedStmtBits.AttrLoc = readSourceLocation();
Richard Smithc202b282012-04-14 00:33:13 +0000207}
208
Sebastian Redl70c751d2010-08-18 23:56:52 +0000209void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000210 VisitStmt(S);
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000211
David L. Jonesbe1557a2016-12-21 00:17:49 +0000212 S->setConstexpr(Record.readInt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000213 bool HasElse = Record.readInt();
214 bool HasVar = Record.readInt();
215 bool HasInit = Record.readInt();
216
David L. Jonesb6a8f022016-12-21 04:34:52 +0000217 S->setCond(Record.readSubExpr());
218 S->setThen(Record.readSubStmt());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000219 if (HasElse)
220 S->setElse(Record.readSubStmt());
221 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500222 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000223 if (HasInit)
224 S->setInit(Record.readSubStmt());
225
John McCall3ce3d232019-12-13 03:37:23 -0500226 S->setIfLoc(readSourceLocation());
Bruno Riccib1cc94b2018-10-27 21:12:20 +0000227 if (HasElse)
John McCall3ce3d232019-12-13 03:37:23 -0500228 S->setElseLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000229}
230
Sebastian Redl70c751d2010-08-18 23:56:52 +0000231void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000232 VisitStmt(S);
Bruno Riccie2806f82018-10-29 16:12:37 +0000233
234 bool HasInit = Record.readInt();
235 bool HasVar = Record.readInt();
236 bool AllEnumCasesCovered = Record.readInt();
237 if (AllEnumCasesCovered)
238 S->setAllEnumCasesCovered();
239
David L. Jonesb6a8f022016-12-21 04:34:52 +0000240 S->setCond(Record.readSubExpr());
241 S->setBody(Record.readSubStmt());
Bruno Riccie2806f82018-10-29 16:12:37 +0000242 if (HasInit)
243 S->setInit(Record.readSubStmt());
244 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500245 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccie2806f82018-10-29 16:12:37 +0000246
John McCall3ce3d232019-12-13 03:37:23 -0500247 S->setSwitchLoc(readSourceLocation());
Ted Kremenekc42f3452010-09-09 00:05:53 +0000248
Craig Toppera13603a2014-05-22 05:54:18 +0000249 SwitchCase *PrevSC = nullptr;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000250 for (auto E = Record.size(); Record.getIdx() != E; ) {
251 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000252 if (PrevSC)
253 PrevSC->setNextSwitchCase(SC);
254 else
255 S->setSwitchCaseList(SC);
Mike Stump11289f42009-09-09 15:08:12 +0000256
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000257 PrevSC = SC;
258 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000259}
260
Sebastian Redl70c751d2010-08-18 23:56:52 +0000261void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000262 VisitStmt(S);
Bruno Riccibacf7512018-10-30 13:42:41 +0000263
264 bool HasVar = Record.readInt();
Douglas Gregor7fb09192011-07-21 22:35:25 +0000265
David L. Jonesb6a8f022016-12-21 04:34:52 +0000266 S->setCond(Record.readSubExpr());
267 S->setBody(Record.readSubStmt());
Bruno Riccibacf7512018-10-30 13:42:41 +0000268 if (HasVar)
John McCall3ce3d232019-12-13 03:37:23 -0500269 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
Bruno Riccibacf7512018-10-30 13:42:41 +0000270
John McCall3ce3d232019-12-13 03:37:23 -0500271 S->setWhileLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000272}
273
Sebastian Redl70c751d2010-08-18 23:56:52 +0000274void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000275 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000276 S->setCond(Record.readSubExpr());
277 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500278 S->setDoLoc(readSourceLocation());
279 S->setWhileLoc(readSourceLocation());
280 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000281}
282
Sebastian Redl70c751d2010-08-18 23:56:52 +0000283void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000284 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000285 S->setInit(Record.readSubStmt());
286 S->setCond(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500287 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000288 S->setInc(Record.readSubExpr());
289 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -0500290 S->setForLoc(readSourceLocation());
291 S->setLParenLoc(readSourceLocation());
292 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000293}
294
Sebastian Redl70c751d2010-08-18 23:56:52 +0000295void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000296 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500297 S->setLabel(readDeclAs<LabelDecl>());
298 S->setGotoLoc(readSourceLocation());
299 S->setLabelLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000300}
301
Sebastian Redl70c751d2010-08-18 23:56:52 +0000302void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000303 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500304 S->setGotoLoc(readSourceLocation());
305 S->setStarLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000306 S->setTarget(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000307}
308
Sebastian Redl70c751d2010-08-18 23:56:52 +0000309void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000310 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500311 S->setContinueLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000312}
313
Sebastian Redl70c751d2010-08-18 23:56:52 +0000314void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000315 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500316 S->setBreakLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000317}
318
Sebastian Redl70c751d2010-08-18 23:56:52 +0000319void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000320 VisitStmt(S);
Bruno Ricci023b1d12018-10-30 14:40:49 +0000321
322 bool HasNRVOCandidate = Record.readInt();
323
David L. Jonesb6a8f022016-12-21 04:34:52 +0000324 S->setRetValue(Record.readSubExpr());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000325 if (HasNRVOCandidate)
John McCall3ce3d232019-12-13 03:37:23 -0500326 S->setNRVOCandidate(readDeclAs<VarDecl>());
Bruno Ricci023b1d12018-10-30 14:40:49 +0000327
John McCall3ce3d232019-12-13 03:37:23 -0500328 S->setReturnLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000329}
330
Sebastian Redl70c751d2010-08-18 23:56:52 +0000331void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000332 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500333 S->setStartLoc(readSourceLocation());
334 S->setEndLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000335
David L. Jonesbe1557a2016-12-21 00:17:49 +0000336 if (Record.size() - Record.getIdx() == 1) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000337 // Single declaration
John McCall3ce3d232019-12-13 03:37:23 -0500338 S->setDeclGroup(DeclGroupRef(readDecl()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000339 } else {
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000340 SmallVector<Decl *, 16> Decls;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000341 int N = Record.size() - Record.getIdx();
342 Decls.reserve(N);
343 for (int I = 0; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500344 Decls.push_back(readDecl());
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000345 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
Douglas Gregor038c3382009-05-22 22:45:36 +0000346 Decls.data(),
347 Decls.size())));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000348 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000349}
350
John McCallf413f5e2013-05-03 00:10:13 +0000351void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000352 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000353 S->NumOutputs = Record.readInt();
354 S->NumInputs = Record.readInt();
355 S->NumClobbers = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500356 S->setAsmLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000357 S->setVolatile(Record.readInt());
358 S->setSimple(Record.readInt());
John McCallf413f5e2013-05-03 00:10:13 +0000359}
Mike Stump11289f42009-09-09 15:08:12 +0000360
John McCallf413f5e2013-05-03 00:10:13 +0000361void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
362 VisitAsmStmt(S);
Jennifer Yub8fee672019-06-03 15:57:25 +0000363 S->NumLabels = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500364 S->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000365 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000366
John McCallf413f5e2013-05-03 00:10:13 +0000367 unsigned NumOutputs = S->getNumOutputs();
368 unsigned NumInputs = S->getNumInputs();
369 unsigned NumClobbers = S->getNumClobbers();
Jennifer Yub8fee672019-06-03 15:57:25 +0000370 unsigned NumLabels = S->getNumLabels();
John McCallf413f5e2013-05-03 00:10:13 +0000371
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000372 // Outputs and inputs
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000373 SmallVector<IdentifierInfo *, 16> Names;
374 SmallVector<StringLiteral*, 16> Constraints;
375 SmallVector<Stmt*, 16> Exprs;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000376 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -0500377 Names.push_back(Record.readIdentifier());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000378 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
379 Exprs.push_back(Record.readSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000380 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000381
382 // Constraints
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000383 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000384 for (unsigned I = 0; I != NumClobbers; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000385 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000386
Jennifer Yub8fee672019-06-03 15:57:25 +0000387 // Labels
388 for (unsigned I = 0, N = NumLabels; I != N; ++I)
389 Exprs.push_back(Record.readSubStmt());
390
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000391 S->setOutputsAndInputsAndClobbers(Record.getContext(),
392 Names.data(), Constraints.data(),
393 Exprs.data(), NumOutputs, NumInputs,
Jennifer Yub8fee672019-06-03 15:57:25 +0000394 NumLabels,
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000395 Clobbers.data(), NumClobbers);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000396}
397
Chad Rosier32503022012-06-11 20:47:18 +0000398void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
John McCallf413f5e2013-05-03 00:10:13 +0000399 VisitAsmStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -0500400 S->LBraceLoc = readSourceLocation();
401 S->EndLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000402 S->NumAsmToks = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500403 std::string AsmStr = readString();
John McCallf413f5e2013-05-03 00:10:13 +0000404
405 // Read the tokens.
406 SmallVector<Token, 16> AsmToks;
407 AsmToks.reserve(S->NumAsmToks);
408 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000409 AsmToks.push_back(Record.readToken());
John McCallf413f5e2013-05-03 00:10:13 +0000410 }
411
412 // The calls to reserve() for the FooData vectors are mandatory to
413 // prevent dead StringRefs in the Foo vectors.
414
415 // Read the clobbers.
416 SmallVector<std::string, 16> ClobbersData;
417 SmallVector<StringRef, 16> Clobbers;
418 ClobbersData.reserve(S->NumClobbers);
419 Clobbers.reserve(S->NumClobbers);
420 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
John McCall3ce3d232019-12-13 03:37:23 -0500421 ClobbersData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000422 Clobbers.push_back(ClobbersData.back());
423 }
424
425 // Read the operands.
426 unsigned NumOperands = S->NumOutputs + S->NumInputs;
427 SmallVector<Expr*, 16> Exprs;
428 SmallVector<std::string, 16> ConstraintsData;
429 SmallVector<StringRef, 16> Constraints;
430 Exprs.reserve(NumOperands);
431 ConstraintsData.reserve(NumOperands);
432 Constraints.reserve(NumOperands);
433 for (unsigned i = 0; i != NumOperands; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000434 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -0500435 ConstraintsData.push_back(readString());
John McCallf413f5e2013-05-03 00:10:13 +0000436 Constraints.push_back(ConstraintsData.back());
437 }
438
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000439 S->initialize(Record.getContext(), AsmStr, AsmToks,
John McCallf413f5e2013-05-03 00:10:13 +0000440 Constraints, Exprs, Clobbers);
Chad Rosier32503022012-06-11 20:47:18 +0000441}
442
Richard Smith9f690bd2015-10-27 06:02:45 +0000443void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000444 VisitStmt(S);
445 assert(Record.peekInt() == S->NumParams);
446 Record.skipInts(1);
447 auto *StoredStmts = S->getStoredStmts();
448 for (unsigned i = 0;
449 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
450 StoredStmts[i] = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000451}
452
453void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000454 VisitStmt(S);
455 S->CoreturnLoc = Record.readSourceLocation();
456 for (auto &SubStmt: S->SubStmts)
457 SubStmt = Record.readSubStmt();
458 S->IsImplicit = Record.readInt() != 0;
Richard Smith9f690bd2015-10-27 06:02:45 +0000459}
460
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000461void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
462 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500463 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000464 for (auto &SubExpr: E->SubExprs)
465 SubExpr = Record.readSubStmt();
466 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
467 E->setIsImplicit(Record.readInt() != 0);
Richard Smith9f690bd2015-10-27 06:02:45 +0000468}
469
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000470void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
471 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500472 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000473 for (auto &SubExpr: E->SubExprs)
474 SubExpr = Record.readSubStmt();
475 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
Eric Fiselier20f25cb2017-03-06 23:38:15 +0000476}
477
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000478void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
479 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500480 E->KeywordLoc = readSourceLocation();
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +0000481 for (auto &SubExpr: E->SubExprs)
482 SubExpr = Record.readSubStmt();
Richard Smith9f690bd2015-10-27 06:02:45 +0000483}
484
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000485void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
Ben Langmuirce914fc2013-05-03 19:20:19 +0000486 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000487 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500488 S->setCapturedDecl(readDeclAs<CapturedDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000489 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500490 S->setCapturedRecordDecl(readDeclAs<RecordDecl>());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000491
492 // Capture inits
493 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
494 E = S->capture_init_end();
495 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000496 *I = Record.readSubExpr();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000497
498 // Body
David L. Jonesb6a8f022016-12-21 04:34:52 +0000499 S->setCapturedStmt(Record.readSubStmt());
Wei Pan17fbf6e2013-05-04 03:59:06 +0000500 S->getCapturedDecl()->setBody(S->getCapturedStmt());
Ben Langmuirce914fc2013-05-03 19:20:19 +0000501
502 // Captures
Aaron Ballmanc656303a2014-03-14 18:08:33 +0000503 for (auto &I : S->captures()) {
John McCall3ce3d232019-12-13 03:37:23 -0500504 I.VarAndKind.setPointer(readDeclAs<VarDecl>());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000505 I.VarAndKind.setInt(
506 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
John McCall3ce3d232019-12-13 03:37:23 -0500507 I.Loc = readSourceLocation();
Ben Langmuirce914fc2013-05-03 19:20:19 +0000508 }
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000509}
510
Sebastian Redl70c751d2010-08-18 23:56:52 +0000511void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000512 VisitStmt(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000513 E->setType(Record.readType());
514 E->setTypeDependent(Record.readInt());
515 E->setValueDependent(Record.readInt());
516 E->setInstantiationDependent(Record.readInt());
517 E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
518 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
519 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
520 assert(Record.getIdx() == NumExprFields &&
521 "Incorrect expression field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000522}
523
Bill Wendling7c44da22018-10-31 03:48:47 +0000524void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
525 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000526 E->ConstantExprBits.ResultKind = Record.readInt();
527 switch (E->ConstantExprBits.ResultKind) {
528 case ConstantExpr::RSK_Int64: {
529 E->Int64Result() = Record.readInt();
530 uint64_t tmp = Record.readInt();
531 E->ConstantExprBits.IsUnsigned = tmp & 0x1;
532 E->ConstantExprBits.BitWidth = tmp >> 1;
533 break;
534 }
535 case ConstantExpr::RSK_APValue:
536 E->APValueResult() = Record.readAPValue();
537 }
Bill Wendling7c44da22018-10-31 03:48:47 +0000538 E->setSubExpr(Record.readSubExpr());
539}
540
Sebastian Redl70c751d2010-08-18 23:56:52 +0000541void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000542 VisitExpr(E);
Bruno Ricci17ff0262018-10-27 19:21:19 +0000543 bool HasFunctionName = Record.readInt();
544 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
545 E->PredefinedExprBits.Kind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -0500546 E->setLocation(readSourceLocation());
Bruno Ricci17ff0262018-10-27 19:21:19 +0000547 if (HasFunctionName)
548 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000549}
550
Sebastian Redl70c751d2010-08-18 23:56:52 +0000551void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000552 VisitExpr(E);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000553
David L. Jonesbe1557a2016-12-21 00:17:49 +0000554 E->DeclRefExprBits.HasQualifier = Record.readInt();
555 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
556 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
557 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
558 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
Richard Smith715f7a12019-06-11 17:50:32 +0000559 E->DeclRefExprBits.NonOdrUseReason = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000560 unsigned NumTemplateArgs = 0;
Abramo Bagnara7945c982012-01-27 09:46:47 +0000561 if (E->hasTemplateKWAndArgsInfo())
David L. Jonesbe1557a2016-12-21 00:17:49 +0000562 NumTemplateArgs = Record.readInt();
Anders Carlsson80756f62011-03-06 18:19:42 +0000563
Chandler Carruth0e439962011-05-01 21:29:53 +0000564 if (E->hasQualifier())
James Y Knighte7d82282015-12-29 18:15:14 +0000565 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
David L. Jonesb6a8f022016-12-21 04:34:52 +0000566 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000567
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000568 if (E->hasFoundDecl())
John McCall3ce3d232019-12-13 03:37:23 -0500569 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000570
Abramo Bagnara7945c982012-01-27 09:46:47 +0000571 if (E->hasTemplateKWAndArgsInfo())
James Y Knighte7d82282015-12-29 18:15:14 +0000572 ReadTemplateKWAndArgsInfo(
573 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
574 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000575
John McCall3ce3d232019-12-13 03:37:23 -0500576 E->setDecl(readDeclAs<ValueDecl>());
577 E->setLocation(readSourceLocation());
578 E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000579}
580
Sebastian Redl70c751d2010-08-18 23:56:52 +0000581void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000582 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500583 E->setLocation(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000584 E->setValue(Record.getContext(), Record.readAPInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000585}
586
Leonard Chandb01c3a2018-06-20 17:19:40 +0000587void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
588 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500589 E->setLocation(readSourceLocation());
Leonard Chandb01c3a2018-06-20 17:19:40 +0000590 E->setValue(Record.getContext(), Record.readAPInt());
591}
592
Sebastian Redl70c751d2010-08-18 23:56:52 +0000593void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000594 VisitExpr(E);
Gauthier Harnisch83c7b612019-06-15 10:24:47 +0000595 E->setRawSemantics(
596 static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
David L. Jonesbe1557a2016-12-21 00:17:49 +0000597 E->setExact(Record.readInt());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000598 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
John McCall3ce3d232019-12-13 03:37:23 -0500599 E->setLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000600}
601
Sebastian Redl70c751d2010-08-18 23:56:52 +0000602void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000603 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000604 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000605}
606
Sebastian Redl70c751d2010-08-18 23:56:52 +0000607void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000608 VisitExpr(E);
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000609
610 // NumConcatenated, Length and CharByteWidth are set by the empty
611 // ctor since they are needed to allocate storage for the trailing objects.
612 unsigned NumConcatenated = Record.readInt();
613 unsigned Length = Record.readInt();
614 unsigned CharByteWidth = Record.readInt();
615 assert((NumConcatenated == E->getNumConcatenated()) &&
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000616 "Wrong number of concatenated tokens!");
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000617 assert((Length == E->getLength()) && "Wrong Length!");
618 assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
619 E->StringLiteralBits.Kind = Record.readInt();
620 E->StringLiteralBits.IsPascal = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000621
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000622 // The character width is originally computed via mapCharByteWidth.
623 // Check that the deserialized character width is consistant with the result
624 // of calling mapCharByteWidth.
625 assert((CharByteWidth ==
626 StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
627 E->getKind())) &&
628 "Wrong character width!");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000629
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000630 // Deserialize the trailing array of SourceLocation.
631 for (unsigned I = 0; I < NumConcatenated; ++I)
John McCall3ce3d232019-12-13 03:37:23 -0500632 E->setStrTokenLoc(I, readSourceLocation());
Bruno Riccib94ad1e2018-11-15 17:31:16 +0000633
634 // Deserialize the trailing array of char holding the string data.
635 char *StrData = E->getStrDataAsChar();
636 for (unsigned I = 0; I < Length * CharByteWidth; ++I)
637 StrData[I] = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000638}
639
Sebastian Redl70c751d2010-08-18 23:56:52 +0000640void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000641 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000642 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500643 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000644 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000645}
646
Sebastian Redl70c751d2010-08-18 23:56:52 +0000647void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000648 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500649 E->setLParen(readSourceLocation());
650 E->setRParen(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000651 E->setSubExpr(Record.readSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000652}
653
Sebastian Redl70c751d2010-08-18 23:56:52 +0000654void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000655 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000656 unsigned NumExprs = Record.readInt();
Bruno Riccif49e1ca2018-11-20 16:20:40 +0000657 assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
658 for (unsigned I = 0; I != NumExprs; ++I)
659 E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -0500660 E->LParenLoc = readSourceLocation();
661 E->RParenLoc = readSourceLocation();
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000662}
663
Sebastian Redl70c751d2010-08-18 23:56:52 +0000664void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000665 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000666 E->setSubExpr(Record.readSubExpr());
667 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500668 E->setOperatorLoc(readSourceLocation());
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000669 E->setCanOverflow(Record.readInt());
670}
671
672void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000673 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000674 assert(E->getNumComponents() == Record.peekInt());
675 Record.skipInts(1);
676 assert(E->getNumExpressions() == Record.peekInt());
677 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -0500678 E->setOperatorLoc(readSourceLocation());
679 E->setRParenLoc(readSourceLocation());
680 E->setTypeSourceInfo(readTypeSourceInfo());
Douglas Gregor882211c2010-04-28 22:16:22 +0000681 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000682 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500683 SourceLocation Start = readSourceLocation();
684 SourceLocation End = readSourceLocation();
Douglas Gregor882211c2010-04-28 22:16:22 +0000685 switch (Kind) {
James Y Knight7281c352015-12-29 22:31:18 +0000686 case OffsetOfNode::Array:
David L. Jonesbe1557a2016-12-21 00:17:49 +0000687 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000688 break;
689
James Y Knight7281c352015-12-29 22:31:18 +0000690 case OffsetOfNode::Field:
691 E->setComponent(
John McCall3ce3d232019-12-13 03:37:23 -0500692 I, OffsetOfNode(Start, readDeclAs<FieldDecl>(), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000693 break;
James Y Knight7281c352015-12-29 22:31:18 +0000694
695 case OffsetOfNode::Identifier:
696 E->setComponent(
697 I,
John McCall3ce3d232019-12-13 03:37:23 -0500698 OffsetOfNode(Start, Record.readIdentifier(), End));
James Y Knight7281c352015-12-29 22:31:18 +0000699 break;
700
701 case OffsetOfNode::Base: {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000702 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
David L. Jonesb6a8f022016-12-21 04:34:52 +0000703 *Base = Record.readCXXBaseSpecifier();
James Y Knight7281c352015-12-29 22:31:18 +0000704 E->setComponent(I, OffsetOfNode(Base));
Douglas Gregord1702062010-04-29 00:18:15 +0000705 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000706 }
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000707 }
Douglas Gregor882211c2010-04-28 22:16:22 +0000708 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000709
Douglas Gregor882211c2010-04-28 22:16:22 +0000710 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000711 E->setIndexExpr(I, Record.readSubExpr());
Douglas Gregor882211c2010-04-28 22:16:22 +0000712}
713
Peter Collingbournee190dee2011-03-11 19:24:49 +0000714void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000715 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000716 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
717 if (Record.peekInt() == 0) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000718 E->setArgument(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000719 Record.skipInts(1);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000720 } else {
John McCall3ce3d232019-12-13 03:37:23 -0500721 E->setArgument(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000722 }
John McCall3ce3d232019-12-13 03:37:23 -0500723 E->setOperatorLoc(readSourceLocation());
724 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000725}
726
Saar Raz5d98ba62019-10-15 15:24:26 +0000727void ASTStmtReader::VisitConceptSpecializationExpr(
728 ConceptSpecializationExpr *E) {
729 VisitExpr(E);
730 unsigned NumTemplateArgs = Record.readInt();
731 E->NestedNameSpec = Record.readNestedNameSpecifierLoc();
732 E->TemplateKWLoc = Record.readSourceLocation();
Saar Razff1e0fc2020-01-15 02:48:42 +0200733 E->ConceptName = Record.readDeclarationNameInfo();
John McCall3ce3d232019-12-13 03:37:23 -0500734 E->NamedConcept = readDeclAs<ConceptDecl>();
Saar Razff1e0fc2020-01-15 02:48:42 +0200735 E->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
Saar Raz5d98ba62019-10-15 15:24:26 +0000736 llvm::SmallVector<TemplateArgument, 4> Args;
737 for (unsigned I = 0; I < NumTemplateArgs; ++I)
738 Args.push_back(Record.readTemplateArgument());
Saar Razff1e0fc2020-01-15 02:48:42 +0200739 E->setTemplateArguments(Args);
Saar Razfdf80e82019-12-06 01:30:21 +0200740 ConstraintSatisfaction Satisfaction;
741 Satisfaction.IsSatisfied = Record.readInt();
742 if (!Satisfaction.IsSatisfied) {
743 unsigned NumDetailRecords = Record.readInt();
744 for (unsigned i = 0; i != NumDetailRecords; ++i) {
745 Expr *ConstraintExpr = Record.readExpr();
746 bool IsDiagnostic = Record.readInt();
747 if (IsDiagnostic) {
748 SourceLocation DiagLocation = Record.readSourceLocation();
749 std::string DiagMessage = Record.readString();
750 Satisfaction.Details.emplace_back(
751 ConstraintExpr, new (Record.getContext())
752 ConstraintSatisfaction::SubstitutionDiagnostic{
753 DiagLocation, DiagMessage});
754 } else
755 Satisfaction.Details.emplace_back(ConstraintExpr, Record.readExpr());
756 }
757 }
758 E->Satisfaction = ASTConstraintSatisfaction::Create(Record.getContext(),
759 Satisfaction);
Saar Raz5d98ba62019-10-15 15:24:26 +0000760}
761
Sebastian Redl70c751d2010-08-18 23:56:52 +0000762void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000763 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000764 E->setLHS(Record.readSubExpr());
765 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500766 E->setRBracketLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000767}
768
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000769void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
770 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000771 E->setBase(Record.readSubExpr());
772 E->setLowerBound(Record.readSubExpr());
773 E->setLength(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500774 E->setColonLoc(readSourceLocation());
775 E->setRBracketLoc(readSourceLocation());
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000776}
777
Sebastian Redl70c751d2010-08-18 23:56:52 +0000778void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000779 VisitExpr(E);
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000780 unsigned NumArgs = Record.readInt();
781 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
John McCall3ce3d232019-12-13 03:37:23 -0500782 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000783 E->setCallee(Record.readSubExpr());
Bruno Ricci4c9a0192018-12-03 14:54:03 +0000784 for (unsigned I = 0; I != NumArgs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000785 E->setArg(I, Record.readSubExpr());
Eric Fiselier5cdc2cd2018-12-12 21:50:55 +0000786 E->setADLCallKind(static_cast<CallExpr::ADLCallKind>(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000787}
788
John McCallfa194042011-07-15 07:00:14 +0000789void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
790 VisitCallExpr(E);
791}
792
Sebastian Redl70c751d2010-08-18 23:56:52 +0000793void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Richard Smithdcf17de2019-06-06 23:24:15 +0000794 VisitExpr(E);
795
796 bool HasQualifier = Record.readInt();
797 bool HasFoundDecl = Record.readInt();
798 bool HasTemplateInfo = Record.readInt();
799 unsigned NumTemplateArgs = Record.readInt();
800
801 E->Base = Record.readSubExpr();
802 E->MemberDecl = Record.readDeclAs<ValueDecl>();
John McCall3ce3d232019-12-13 03:37:23 -0500803 E->MemberDNLoc = Record.readDeclarationNameLoc(E->MemberDecl->getDeclName());
Richard Smithdcf17de2019-06-06 23:24:15 +0000804 E->MemberLoc = Record.readSourceLocation();
805 E->MemberExprBits.IsArrow = Record.readInt();
806 E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
807 E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
808 E->MemberExprBits.HadMultipleCandidates = Record.readInt();
Richard Smith1bbad592019-06-11 17:50:36 +0000809 E->MemberExprBits.NonOdrUseReason = Record.readInt();
Richard Smithdcf17de2019-06-06 23:24:15 +0000810 E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
811
812 if (HasQualifier || HasFoundDecl) {
813 DeclAccessPair FoundDecl;
814 if (HasFoundDecl) {
815 auto *FoundD = Record.readDeclAs<NamedDecl>();
816 auto AS = (AccessSpecifier)Record.readInt();
817 FoundDecl = DeclAccessPair::make(FoundD, AS);
818 } else {
819 FoundDecl = DeclAccessPair::make(E->MemberDecl,
820 E->MemberDecl->getAccess());
821 }
822 E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
823
824 NestedNameSpecifierLoc QualifierLoc;
825 if (HasQualifier)
826 QualifierLoc = Record.readNestedNameSpecifierLoc();
827 E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
828 QualifierLoc;
829 }
830
831 if (HasTemplateInfo)
832 ReadTemplateKWAndArgsInfo(
833 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
834 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000835}
836
Sebastian Redl70c751d2010-08-18 23:56:52 +0000837void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Naroffe87026a2009-07-24 17:54:45 +0000838 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000839 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500840 E->setIsaMemberLoc(readSourceLocation());
841 E->setOpLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000842 E->setArrow(Record.readInt());
Steve Naroffe87026a2009-07-24 17:54:45 +0000843}
844
John McCall31168b02011-06-15 23:02:42 +0000845void ASTStmtReader::
846VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
847 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000848 E->Operand = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000849 E->setShouldCopy(Record.readInt());
John McCall31168b02011-06-15 23:02:42 +0000850}
851
852void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
853 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500854 E->LParenLoc = readSourceLocation();
855 E->BridgeKeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000856 E->Kind = Record.readInt();
John McCall31168b02011-06-15 23:02:42 +0000857}
858
Sebastian Redl70c751d2010-08-18 23:56:52 +0000859void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000860 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000861 unsigned NumBaseSpecs = Record.readInt();
John McCallcf142162010-08-07 06:22:56 +0000862 assert(NumBaseSpecs == E->path_size());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000863 E->setSubExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000864 E->setCastKind((CastKind)Record.readInt());
John McCallcf142162010-08-07 06:22:56 +0000865 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000866 while (NumBaseSpecs--) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000867 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
David L. Jonesb6a8f022016-12-21 04:34:52 +0000868 *BaseSpec = Record.readCXXBaseSpecifier();
John McCallcf142162010-08-07 06:22:56 +0000869 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000870 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000871}
872
Sebastian Redl70c751d2010-08-18 23:56:52 +0000873void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000874 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000875 E->setLHS(Record.readSubExpr());
876 E->setRHS(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000877 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -0500878 E->setOperatorLoc(readSourceLocation());
Adam Nemet484aa452017-03-27 19:17:25 +0000879 E->setFPFeatures(FPOptions(Record.readInt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000880}
881
Sebastian Redl70c751d2010-08-18 23:56:52 +0000882void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000883 VisitBinaryOperator(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000884 E->setComputationLHSType(Record.readType());
885 E->setComputationResultType(Record.readType());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000886}
887
Sebastian Redl70c751d2010-08-18 23:56:52 +0000888void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000889 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000890 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
891 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
892 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -0500893 E->QuestionLoc = readSourceLocation();
894 E->ColonLoc = readSourceLocation();
John McCallc07a0c72011-02-17 10:25:35 +0000895}
896
897void
898ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
899 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000900 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
901 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
902 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
903 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
904 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -0500905 E->QuestionLoc = readSourceLocation();
906 E->ColonLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000907}
908
Sebastian Redl70c751d2010-08-18 23:56:52 +0000909void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000910 VisitCastExpr(E);
Roman Lebedev12216f12018-07-27 07:27:14 +0000911 E->setIsPartOfExplicitCast(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000912}
913
Sebastian Redl70c751d2010-08-18 23:56:52 +0000914void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000915 VisitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500916 E->setTypeInfoAsWritten(readTypeSourceInfo());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000917}
918
Sebastian Redl70c751d2010-08-18 23:56:52 +0000919void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000920 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500921 E->setLParenLoc(readSourceLocation());
922 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000923}
924
Sebastian Redl70c751d2010-08-18 23:56:52 +0000925void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000926 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -0500927 E->setLParenLoc(readSourceLocation());
928 E->setTypeSourceInfo(readTypeSourceInfo());
David L. Jonesb6a8f022016-12-21 04:34:52 +0000929 E->setInitializer(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000930 E->setFileScope(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000931}
932
Sebastian Redl70c751d2010-08-18 23:56:52 +0000933void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000934 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +0000935 E->setBase(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500936 E->setAccessor(Record.readIdentifier());
937 E->setAccessorLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000938}
939
Sebastian Redl70c751d2010-08-18 23:56:52 +0000940void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000941 VisitExpr(E);
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000942 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
Abramo Bagnara8d16bd42012-11-08 18:41:43 +0000943 E->setSyntacticForm(SyntForm);
John McCall3ce3d232019-12-13 03:37:23 -0500944 E->setLBraceLoc(readSourceLocation());
945 E->setRBraceLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000946 bool isArrayFiller = Record.readInt();
Craig Toppera13603a2014-05-22 05:54:18 +0000947 Expr *filler = nullptr;
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000948 if (isArrayFiller) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000949 filler = Record.readSubExpr();
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000950 E->ArrayFillerOrUnionFieldInit = filler;
951 } else
John McCall3ce3d232019-12-13 03:37:23 -0500952 E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
David L. Jonesbe1557a2016-12-21 00:17:49 +0000953 E->sawArrayRangeDesignator(Record.readInt());
954 unsigned NumInits = Record.readInt();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000955 E->reserveInits(Record.getContext(), NumInits);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000956 if (isArrayFiller) {
957 for (unsigned I = 0; I != NumInits; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +0000958 Expr *init = Record.readSubExpr();
David L. Jonesc4808b9e2016-12-15 20:53:26 +0000959 E->updateInit(Record.getContext(), I, init ? init : filler);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000960 }
961 } else {
962 for (unsigned I = 0; I != NumInits; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000963 E->updateInit(Record.getContext(), I, Record.readSubExpr());
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000964 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000965}
966
Sebastian Redl70c751d2010-08-18 23:56:52 +0000967void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +0000968 using Designator = DesignatedInitExpr::Designator;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000969
970 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +0000971 unsigned NumSubExprs = Record.readInt();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000972 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
973 for (unsigned I = 0; I != NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +0000974 E->setSubExpr(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -0500975 E->setEqualOrColonLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +0000976 E->setGNUSyntax(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000977
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000978 SmallVector<Designator, 4> Designators;
David L. Jonesbe1557a2016-12-21 00:17:49 +0000979 while (Record.getIdx() < Record.size()) {
980 switch ((DesignatorTypes)Record.readInt()) {
Sebastian Redl539c5062010-08-18 23:57:32 +0000981 case DESIG_FIELD_DECL: {
John McCall3ce3d232019-12-13 03:37:23 -0500982 auto *Field = readDeclAs<FieldDecl>();
983 SourceLocation DotLoc = readSourceLocation();
984 SourceLocation FieldLoc = readSourceLocation();
Mike Stump11289f42009-09-09 15:08:12 +0000985 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000986 FieldLoc));
987 Designators.back().setField(Field);
988 break;
989 }
990
Sebastian Redl539c5062010-08-18 23:57:32 +0000991 case DESIG_FIELD_NAME: {
John McCall3ce3d232019-12-13 03:37:23 -0500992 const IdentifierInfo *Name = Record.readIdentifier();
993 SourceLocation DotLoc = readSourceLocation();
994 SourceLocation FieldLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000995 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
996 break;
997 }
Mike Stump11289f42009-09-09 15:08:12 +0000998
Sebastian Redl539c5062010-08-18 23:57:32 +0000999 case DESIG_ARRAY: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001000 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001001 SourceLocation LBracketLoc = readSourceLocation();
1002 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001003 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
1004 break;
1005 }
1006
Sebastian Redl539c5062010-08-18 23:57:32 +00001007 case DESIG_ARRAY_RANGE: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001008 unsigned Index = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001009 SourceLocation LBracketLoc = readSourceLocation();
1010 SourceLocation EllipsisLoc = readSourceLocation();
1011 SourceLocation RBracketLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001012 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
1013 RBracketLoc));
1014 break;
1015 }
1016 }
1017 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001018 E->setDesignators(Record.getContext(),
Douglas Gregor03e8bdc2010-01-06 23:17:19 +00001019 Designators.data(), Designators.size());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001020}
1021
Yunzhong Gaocb779302015-06-10 00:27:52 +00001022void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1023 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001024 E->setBase(Record.readSubExpr());
1025 E->setUpdater(Record.readSubExpr());
Yunzhong Gaocb779302015-06-10 00:27:52 +00001026}
1027
1028void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1029 VisitExpr(E);
1030}
1031
Richard Smith410306b2016-12-12 02:53:20 +00001032void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1033 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001034 E->SubExprs[0] = Record.readSubExpr();
1035 E->SubExprs[1] = Record.readSubExpr();
Richard Smith410306b2016-12-12 02:53:20 +00001036}
1037
1038void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1039 VisitExpr(E);
1040}
1041
Sebastian Redl70c751d2010-08-18 23:56:52 +00001042void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001043 VisitExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001044}
1045
Sebastian Redl70c751d2010-08-18 23:56:52 +00001046void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001047 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001048 E->setSubExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001049 E->setWrittenTypeInfo(readTypeSourceInfo());
1050 E->setBuiltinLoc(readSourceLocation());
1051 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001052 E->setIsMicrosoftABI(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001053}
1054
Eric Fiselier708afb52019-05-16 21:04:15 +00001055void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1056 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001057 E->ParentContext = readDeclAs<DeclContext>();
1058 E->BuiltinLoc = readSourceLocation();
1059 E->RParenLoc = readSourceLocation();
Eric Fiselier708afb52019-05-16 21:04:15 +00001060 E->SourceLocExprBits.Kind =
1061 static_cast<SourceLocExpr::IdentKind>(Record.readInt());
1062}
1063
Sebastian Redl70c751d2010-08-18 23:56:52 +00001064void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001065 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001066 E->setAmpAmpLoc(readSourceLocation());
1067 E->setLabelLoc(readSourceLocation());
1068 E->setLabel(readDeclAs<LabelDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001069}
1070
Sebastian Redl70c751d2010-08-18 23:56:52 +00001071void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001072 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001073 E->setLParenLoc(readSourceLocation());
1074 E->setRParenLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001075 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001076}
1077
Sebastian Redl70c751d2010-08-18 23:56:52 +00001078void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001079 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001080 E->setCond(Record.readSubExpr());
1081 E->setLHS(Record.readSubExpr());
1082 E->setRHS(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001083 E->setBuiltinLoc(readSourceLocation());
1084 E->setRParenLoc(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001085 E->setIsConditionTrue(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001086}
1087
Sebastian Redl70c751d2010-08-18 23:56:52 +00001088void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001089 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001090 E->setTokenLocation(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001091}
1092
Sebastian Redl70c751d2010-08-18 23:56:52 +00001093void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001094 VisitExpr(E);
Chris Lattner0e62c1c2011-07-23 10:55:15 +00001095 SmallVector<Expr *, 16> Exprs;
David L. Jonesbe1557a2016-12-21 00:17:49 +00001096 unsigned NumExprs = Record.readInt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001097 while (NumExprs--)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001098 Exprs.push_back(Record.readSubExpr());
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001099 E->setExprs(Record.getContext(), Exprs);
John McCall3ce3d232019-12-13 03:37:23 -05001100 E->setBuiltinLoc(readSourceLocation());
1101 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001102}
1103
Hal Finkelc4d7c822013-09-18 03:29:45 +00001104void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1105 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001106 E->BuiltinLoc = readSourceLocation();
1107 E->RParenLoc = readSourceLocation();
1108 E->TInfo = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001109 E->SrcExpr = Record.readSubExpr();
Hal Finkelc4d7c822013-09-18 03:29:45 +00001110}
1111
Sebastian Redl70c751d2010-08-18 23:56:52 +00001112void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001113 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001114 E->setBlockDecl(readDeclAs<BlockDecl>());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001115}
1116
Peter Collingbourne91147592011-04-15 00:35:48 +00001117void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1118 VisitExpr(E);
Bruno Riccidb076832019-01-26 14:15:10 +00001119
1120 unsigned NumAssocs = Record.readInt();
1121 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
Bruno Ricci94498c72019-01-26 13:58:15 +00001122 E->ResultIndex = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001123 E->GenericSelectionExprBits.GenericLoc = readSourceLocation();
1124 E->DefaultLoc = readSourceLocation();
1125 E->RParenLoc = readSourceLocation();
Bruno Riccidb076832019-01-26 14:15:10 +00001126
1127 Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1128 // Add 1 to account for the controlling expression which is the first
1129 // expression in the trailing array of Stmt *. This is not needed for
1130 // the trailing array of TypeSourceInfo *.
1131 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1132 Stmts[I] = Record.readSubExpr();
1133
1134 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1135 for (unsigned I = 0, N = NumAssocs; I < N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001136 TSIs[I] = readTypeSourceInfo();
Peter Collingbourne91147592011-04-15 00:35:48 +00001137}
1138
John McCallfe96e0b2011-11-06 09:01:30 +00001139void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1140 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001141 unsigned numSemanticExprs = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001142 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001143 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
John McCallfe96e0b2011-11-06 09:01:30 +00001144
1145 // Read the syntactic expression.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001146 E->getSubExprsBuffer()[0] = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001147
1148 // Read all the semantic expressions.
1149 for (unsigned i = 0; i != numSemanticExprs; ++i) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001150 Expr *subExpr = Record.readSubExpr();
John McCallfe96e0b2011-11-06 09:01:30 +00001151 E->getSubExprsBuffer()[i+1] = subExpr;
1152 }
1153}
1154
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001155void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1156 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001157 E->Op = AtomicExpr::AtomicOp(Record.readInt());
Richard Smithaa22a8c2012-04-10 22:49:28 +00001158 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1159 for (unsigned I = 0; I != E->NumSubExprs; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001160 E->SubExprs[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001161 E->BuiltinLoc = readSourceLocation();
1162 E->RParenLoc = readSourceLocation();
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001163}
1164
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001165//===----------------------------------------------------------------------===//
1166// Objective-C Expressions and Statements
1167
Sebastian Redl70c751d2010-08-18 23:56:52 +00001168void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001169 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001170 E->setString(cast<StringLiteral>(Record.readSubStmt()));
John McCall3ce3d232019-12-13 03:37:23 -05001171 E->setAtLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001172}
1173
Patrick Beard0caa3942012-04-19 00:25:12 +00001174void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001175 VisitExpr(E);
1176 // could be one of several IntegerLiteral, FloatLiteral, etc.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001177 E->SubExpr = Record.readSubStmt();
John McCall3ce3d232019-12-13 03:37:23 -05001178 E->BoxingMethod = readDeclAs<ObjCMethodDecl>();
1179 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001180}
1181
1182void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1183 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001184 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001185 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1186 Expr **Elements = E->getElements();
1187 for (unsigned I = 0, N = NumElements; I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001188 Elements[I] = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001189 E->ArrayWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1190 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001191}
1192
1193void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1194 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001195 unsigned NumElements = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001196 assert(NumElements == E->getNumElements() && "Wrong number of elements");
David L. Jonesbe1557a2016-12-21 00:17:49 +00001197 bool HasPackExpansions = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001198 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001199 auto *KeyValues =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001200 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001201 auto *Expansions =
James Y Knight6c2f06b2015-12-31 04:43:19 +00001202 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001203 for (unsigned I = 0; I != NumElements; ++I) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00001204 KeyValues[I].Key = Record.readSubExpr();
1205 KeyValues[I].Value = Record.readSubExpr();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001206 if (HasPackExpansions) {
John McCall3ce3d232019-12-13 03:37:23 -05001207 Expansions[I].EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001208 Expansions[I].NumExpansionsPlusOne = Record.readInt();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001209 }
1210 }
John McCall3ce3d232019-12-13 03:37:23 -05001211 E->DictWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1212 E->Range = readSourceRange();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001213}
1214
Sebastian Redl70c751d2010-08-18 23:56:52 +00001215void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001216 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001217 E->setEncodedTypeSourceInfo(readTypeSourceInfo());
1218 E->setAtLoc(readSourceLocation());
1219 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001220}
1221
Sebastian Redl70c751d2010-08-18 23:56:52 +00001222void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001223 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001224 E->setSelector(Record.readSelector());
John McCall3ce3d232019-12-13 03:37:23 -05001225 E->setAtLoc(readSourceLocation());
1226 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001227}
1228
Sebastian Redl70c751d2010-08-18 23:56:52 +00001229void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001230 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001231 E->setProtocol(readDeclAs<ObjCProtocolDecl>());
1232 E->setAtLoc(readSourceLocation());
1233 E->ProtoLoc = readSourceLocation();
1234 E->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001235}
1236
Sebastian Redl70c751d2010-08-18 23:56:52 +00001237void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001238 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001239 E->setDecl(readDeclAs<ObjCIvarDecl>());
1240 E->setLocation(readSourceLocation());
1241 E->setOpLoc(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001242 E->setBase(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001243 E->setIsArrow(Record.readInt());
1244 E->setIsFreeIvar(Record.readInt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001245}
1246
Sebastian Redl70c751d2010-08-18 23:56:52 +00001247void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001248 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001249 unsigned MethodRefFlags = Record.readInt();
1250 bool Implicit = Record.readInt() != 0;
John McCallb7bd14f2010-12-02 01:19:52 +00001251 if (Implicit) {
John McCall3ce3d232019-12-13 03:37:23 -05001252 auto *Getter = readDeclAs<ObjCMethodDecl>();
1253 auto *Setter = readDeclAs<ObjCMethodDecl>();
Argyrios Kyrtzidisab468b02012-03-30 00:19:18 +00001254 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCallb7bd14f2010-12-02 01:19:52 +00001255 } else {
John McCall3ce3d232019-12-13 03:37:23 -05001256 E->setExplicitProperty(readDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001257 }
John McCall3ce3d232019-12-13 03:37:23 -05001258 E->setLocation(readSourceLocation());
1259 E->setReceiverLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001260 switch (Record.readInt()) {
John McCallb7bd14f2010-12-02 01:19:52 +00001261 case 0:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001262 E->setBase(Record.readSubExpr());
John McCallb7bd14f2010-12-02 01:19:52 +00001263 break;
1264 case 1:
David L. Jonesbe1557a2016-12-21 00:17:49 +00001265 E->setSuperReceiver(Record.readType());
John McCallb7bd14f2010-12-02 01:19:52 +00001266 break;
1267 case 2:
John McCall3ce3d232019-12-13 03:37:23 -05001268 E->setClassReceiver(readDeclAs<ObjCInterfaceDecl>());
John McCallb7bd14f2010-12-02 01:19:52 +00001269 break;
1270 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001271}
1272
Ted Kremeneke65b0862012-03-06 20:05:56 +00001273void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1274 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001275 E->setRBracket(readSourceLocation());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001276 E->setBaseExpr(Record.readSubExpr());
1277 E->setKeyExpr(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001278 E->GetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1279 E->SetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
Ted Kremeneke65b0862012-03-06 20:05:56 +00001280}
1281
Sebastian Redl70c751d2010-08-18 23:56:52 +00001282void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001283 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001284 assert(Record.peekInt() == E->getNumArgs());
1285 Record.skipInts(1);
1286 unsigned NumStoredSelLocs = Record.readInt();
1287 E->SelLocsKind = Record.readInt();
1288 E->setDelegateInitCall(Record.readInt());
1289 E->IsImplicit = Record.readInt();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001290 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
Douglas Gregor9a129192010-04-21 00:45:42 +00001291 switch (Kind) {
1292 case ObjCMessageExpr::Instance:
David L. Jonesb6a8f022016-12-21 04:34:52 +00001293 E->setInstanceReceiver(Record.readSubExpr());
Douglas Gregor9a129192010-04-21 00:45:42 +00001294 break;
1295
1296 case ObjCMessageExpr::Class:
John McCall3ce3d232019-12-13 03:37:23 -05001297 E->setClassReceiver(readTypeSourceInfo());
Douglas Gregor9a129192010-04-21 00:45:42 +00001298 break;
1299
1300 case ObjCMessageExpr::SuperClass:
1301 case ObjCMessageExpr::SuperInstance: {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001302 QualType T = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001303 SourceLocation SuperLoc = readSourceLocation();
Douglas Gregor9a129192010-04-21 00:45:42 +00001304 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1305 break;
1306 }
1307 }
1308
1309 assert(Kind == E->getReceiverKind());
1310
David L. Jonesbe1557a2016-12-21 00:17:49 +00001311 if (Record.readInt())
John McCall3ce3d232019-12-13 03:37:23 -05001312 E->setMethodDecl(readDeclAs<ObjCMethodDecl>());
Douglas Gregor9a129192010-04-21 00:45:42 +00001313 else
David L. Jonesb6a8f022016-12-21 04:34:52 +00001314 E->setSelector(Record.readSelector());
Douglas Gregor9a129192010-04-21 00:45:42 +00001315
John McCall3ce3d232019-12-13 03:37:23 -05001316 E->LBracLoc = readSourceLocation();
1317 E->RBracLoc = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001318
1319 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001320 E->setArg(I, Record.readSubExpr());
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00001321
1322 SourceLocation *Locs = E->getStoredSelLocs();
1323 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001324 Locs[I] = readSourceLocation();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001325}
1326
Sebastian Redl70c751d2010-08-18 23:56:52 +00001327void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001328 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001329 S->setElement(Record.readSubStmt());
1330 S->setCollection(Record.readSubExpr());
1331 S->setBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001332 S->setForLoc(readSourceLocation());
1333 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001334}
1335
Sebastian Redl70c751d2010-08-18 23:56:52 +00001336void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001337 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001338 S->setCatchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001339 S->setCatchParamDecl(readDeclAs<VarDecl>());
1340 S->setAtCatchLoc(readSourceLocation());
1341 S->setRParenLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001342}
1343
Sebastian Redl70c751d2010-08-18 23:56:52 +00001344void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001345 VisitStmt(S);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001346 S->setFinallyBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001347 S->setAtFinallyLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001348}
1349
John McCall31168b02011-06-15 23:02:42 +00001350void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001351 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001352 S->setSubStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001353 S->setAtLoc(readSourceLocation());
John McCall31168b02011-06-15 23:02:42 +00001354}
1355
Sebastian Redl70c751d2010-08-18 23:56:52 +00001356void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001357 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001358 assert(Record.peekInt() == S->getNumCatchStmts());
1359 Record.skipInts(1);
1360 bool HasFinally = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001361 S->setTryBody(Record.readSubStmt());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001362 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001363 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
Douglas Gregor96c79492010-04-23 22:50:49 +00001364
Douglas Gregor96c79492010-04-23 22:50:49 +00001365 if (HasFinally)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001366 S->setFinallyStmt(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001367 S->setAtTryLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001368}
1369
Sebastian Redl70c751d2010-08-18 23:56:52 +00001370void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001371 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001372 S->setSynchExpr(Record.readSubStmt());
1373 S->setSynchBody(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001374 S->setAtSynchronizedLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001375}
1376
Sebastian Redl70c751d2010-08-18 23:56:52 +00001377void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Roman Lebedev773c3912019-03-12 21:31:00 +00001378 VisitStmt(S); // FIXME: no test coverage.
David L. Jonesb6a8f022016-12-21 04:34:52 +00001379 S->setThrowExpr(Record.readSubStmt());
John McCall3ce3d232019-12-13 03:37:23 -05001380 S->setThrowLoc(readSourceLocation());
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001381}
1382
Ted Kremeneke65b0862012-03-06 20:05:56 +00001383void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1384 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001385 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001386 E->setLocation(readSourceLocation());
Ted Kremeneke65b0862012-03-06 20:05:56 +00001387}
1388
Erik Pilkington29099de2016-07-16 00:35:23 +00001389void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1390 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001391 SourceRange R = Record.readSourceRange();
Erik Pilkington29099de2016-07-16 00:35:23 +00001392 E->AtLoc = R.getBegin();
1393 E->RParen = R.getEnd();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001394 E->VersionToCheck = Record.readVersionTuple();
Erik Pilkington29099de2016-07-16 00:35:23 +00001395}
1396
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001397//===----------------------------------------------------------------------===//
1398// C++ Expressions and Statements
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001399//===----------------------------------------------------------------------===//
1400
Sebastian Redl70c751d2010-08-18 23:56:52 +00001401void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001402 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001403 S->CatchLoc = readSourceLocation();
1404 S->ExceptionDecl = readDeclAs<VarDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001405 S->HandlerBlock = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001406}
1407
Sebastian Redl70c751d2010-08-18 23:56:52 +00001408void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001409 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001410 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1411 Record.skipInts(1);
John McCall3ce3d232019-12-13 03:37:23 -05001412 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001413 S->getStmts()[0] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001414 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001415 S->getStmts()[i + 1] = Record.readSubStmt();
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001416}
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001417
Richard Smith02e85f32011-04-14 22:09:26 +00001418void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1419 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001420 S->ForLoc = readSourceLocation();
1421 S->CoawaitLoc = readSourceLocation();
1422 S->ColonLoc = readSourceLocation();
1423 S->RParenLoc = readSourceLocation();
Richard Smith8baa5002018-09-28 18:44:09 +00001424 S->setInit(Record.readSubStmt());
David L. Jonesb6a8f022016-12-21 04:34:52 +00001425 S->setRangeStmt(Record.readSubStmt());
1426 S->setBeginStmt(Record.readSubStmt());
1427 S->setEndStmt(Record.readSubStmt());
1428 S->setCond(Record.readSubExpr());
1429 S->setInc(Record.readSubExpr());
1430 S->setLoopVarStmt(Record.readSubStmt());
1431 S->setBody(Record.readSubStmt());
Richard Smith02e85f32011-04-14 22:09:26 +00001432}
1433
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001434void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1435 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001436 S->KeywordLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001437 S->IsIfExists = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001438 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001439 S->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001440 S->SubStmt = Record.readSubStmt();
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001441}
1442
Sebastian Redl70c751d2010-08-18 23:56:52 +00001443void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001444 VisitCallExpr(E);
Bruno Riccifeb19232018-12-21 16:51:57 +00001445 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1446 E->CXXOperatorCallExprBits.FPFeatures = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001447 E->Range = Record.readSourceRange();
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001448}
1449
Richard Smith778dc0f2019-10-19 00:04:38 +00001450void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1451 CXXRewrittenBinaryOperator *E) {
1452 VisitExpr(E);
1453 E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1454 E->SemanticForm = Record.readSubExpr();
1455}
1456
Sebastian Redl70c751d2010-08-18 23:56:52 +00001457void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001458 VisitExpr(E);
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001459
1460 unsigned NumArgs = Record.readInt();
1461 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1462
1463 E->CXXConstructExprBits.Elidable = Record.readInt();
1464 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1465 E->CXXConstructExprBits.ListInitialization = Record.readInt();
1466 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1467 E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1468 E->CXXConstructExprBits.ConstructionKind = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001469 E->CXXConstructExprBits.Loc = readSourceLocation();
1470 E->Constructor = readDeclAs<CXXConstructorDecl>();
1471 E->ParenOrBraceRange = readSourceRange();
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00001472
1473 for (unsigned I = 0; I != NumArgs; ++I)
1474 E->setArg(I, Record.readSubExpr());
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001475}
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001476
Richard Smith5179eb72016-06-28 19:03:57 +00001477void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1478 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001479 E->Constructor = readDeclAs<CXXConstructorDecl>();
1480 E->Loc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001481 E->ConstructsVirtualBase = Record.readInt();
1482 E->InheritedFromVirtualBase = Record.readInt();
Richard Smith5179eb72016-06-28 19:03:57 +00001483}
1484
Sebastian Redl70c751d2010-08-18 23:56:52 +00001485void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001486 VisitCXXConstructExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001487 E->TSI = readTypeSourceInfo();
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001488}
1489
Douglas Gregore31e6062012-02-07 10:09:13 +00001490void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1491 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001492 unsigned NumCaptures = Record.readInt();
Douglas Gregor99ae8062012-02-14 17:54:36 +00001493 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
John McCall3ce3d232019-12-13 03:37:23 -05001494 E->IntroducerRange = readSourceRange();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001495 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001496 E->CaptureDefaultLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001497 E->ExplicitParams = Record.readInt();
1498 E->ExplicitResultType = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001499 E->ClosingBrace = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001500
Douglas Gregor99ae8062012-02-14 17:54:36 +00001501 // Read capture initializers.
1502 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1503 CEnd = E->capture_init_end();
1504 C != CEnd; ++C)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001505 *C = Record.readSubExpr();
Douglas Gregore31e6062012-02-07 10:09:13 +00001506}
1507
Richard Smithcc1b96d2013-06-12 22:31:48 +00001508void
1509ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1510 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001511 E->SubExpr = Record.readSubExpr();
Richard Smithcc1b96d2013-06-12 22:31:48 +00001512}
1513
Sebastian Redl70c751d2010-08-18 23:56:52 +00001514void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001515 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001516 SourceRange R = readSourceRange();
Douglas Gregor4478f852011-01-12 22:41:29 +00001517 E->Loc = R.getBegin();
1518 E->RParenLoc = R.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05001519 R = readSourceRange();
Fariborz Jahanianf0738712013-02-22 22:02:53 +00001520 E->AngleBrackets = R;
Sam Weinigd01101e2010-01-16 21:21:01 +00001521}
1522
Sebastian Redl70c751d2010-08-18 23:56:52 +00001523void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001524 return VisitCXXNamedCastExpr(E);
1525}
1526
Sebastian Redl70c751d2010-08-18 23:56:52 +00001527void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001528 return VisitCXXNamedCastExpr(E);
1529}
1530
Sebastian Redl70c751d2010-08-18 23:56:52 +00001531void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001532 return VisitCXXNamedCastExpr(E);
1533}
1534
Sebastian Redl70c751d2010-08-18 23:56:52 +00001535void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001536 return VisitCXXNamedCastExpr(E);
1537}
1538
Sebastian Redl70c751d2010-08-18 23:56:52 +00001539void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001540 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001541 E->setLParenLoc(readSourceLocation());
1542 E->setRParenLoc(readSourceLocation());
Sam Weinigd01101e2010-01-16 21:21:01 +00001543}
1544
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001545void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1546 VisitExplicitCastExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001547 E->KWLoc = readSourceLocation();
1548 E->RParenLoc = readSourceLocation();
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001549}
1550
Richard Smithc67fdd42012-03-07 08:35:16 +00001551void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1552 VisitCallExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001553 E->UDSuffixLoc = readSourceLocation();
Richard Smithc67fdd42012-03-07 08:35:16 +00001554}
1555
Sebastian Redl70c751d2010-08-18 23:56:52 +00001556void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001557 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001558 E->setValue(Record.readInt());
John McCall3ce3d232019-12-13 03:37:23 -05001559 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001560}
1561
Sebastian Redl70c751d2010-08-18 23:56:52 +00001562void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001563 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001564 E->setLocation(readSourceLocation());
Sam Weinige83b3ac2010-02-07 06:32:43 +00001565}
1566
Sebastian Redl70c751d2010-08-18 23:56:52 +00001567void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001568 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001569 E->setSourceRange(readSourceRange());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001570 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redlc67764e2010-07-22 22:43:28 +00001571 E->setTypeOperandSourceInfo(
John McCall3ce3d232019-12-13 03:37:23 -05001572 readTypeSourceInfo());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001573 return;
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001574 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001575
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001576 // typeid(42+2)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001577 E->setExprOperand(Record.readSubExpr());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001578}
1579
Sebastian Redl70c751d2010-08-18 23:56:52 +00001580void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001581 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001582 E->setLocation(readSourceLocation());
David L. Jonesbe1557a2016-12-21 00:17:49 +00001583 E->setImplicit(Record.readInt());
Chris Lattner98267332010-05-09 06:15:05 +00001584}
1585
Sebastian Redl70c751d2010-08-18 23:56:52 +00001586void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001587 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001588 E->CXXThrowExprBits.ThrowLoc = readSourceLocation();
Bruno Riccib7de97b2018-11-17 12:53:56 +00001589 E->Operand = Record.readSubExpr();
1590 E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
Chris Lattner98267332010-05-09 06:15:05 +00001591}
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001592
Sebastian Redl70c751d2010-08-18 23:56:52 +00001593void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattnere2437f42010-05-09 06:40:08 +00001594 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001595 E->Param = readDeclAs<ParmVarDecl>();
1596 E->UsedContext = readDeclAs<DeclContext>();
1597 E->CXXDefaultArgExprBits.Loc = readSourceLocation();
Chris Lattnercba86142010-05-10 00:25:06 +00001598}
1599
Richard Smith852c9db2013-04-20 22:23:05 +00001600void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1601 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001602 E->Field = readDeclAs<FieldDecl>();
1603 E->UsedContext = readDeclAs<DeclContext>();
1604 E->CXXDefaultInitExprBits.Loc = readSourceLocation();
Richard Smith852c9db2013-04-20 22:23:05 +00001605}
1606
Sebastian Redl70c751d2010-08-18 23:56:52 +00001607void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001608 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001609 E->setTemporary(Record.readCXXTemporary());
1610 E->setSubExpr(Record.readSubExpr());
Chris Lattnercba86142010-05-10 00:25:06 +00001611}
1612
Sebastian Redl70c751d2010-08-18 23:56:52 +00001613void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001614 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001615 E->TypeInfo = readTypeSourceInfo();
1616 E->CXXScalarValueInitExprBits.RParenLoc = readSourceLocation();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001617}
1618
Sebastian Redl70c751d2010-08-18 23:56:52 +00001619void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001620 VisitExpr(E);
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001621
1622 bool IsArray = Record.readInt();
1623 bool HasInit = Record.readInt();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001624 unsigned NumPlacementArgs = Record.readInt();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001625 bool IsParenTypeId = Record.readInt();
1626
1627 E->CXXNewExprBits.IsGlobalNew = Record.readInt();
1628 E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
1629 E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1630 E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
1631
1632 assert((IsArray == E->isArray()) && "Wrong IsArray!");
1633 assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
1634 assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
1635 "Wrong NumPlacementArgs!");
1636 assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
1637 (void)IsArray;
1638 (void)HasInit;
1639 (void)NumPlacementArgs;
1640
John McCall3ce3d232019-12-13 03:37:23 -05001641 E->setOperatorNew(readDeclAs<FunctionDecl>());
1642 E->setOperatorDelete(readDeclAs<FunctionDecl>());
1643 E->AllocatedTypeInfo = readTypeSourceInfo();
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001644 if (IsParenTypeId)
John McCall3ce3d232019-12-13 03:37:23 -05001645 E->getTrailingObjects<SourceRange>()[0] = readSourceRange();
1646 E->Range = readSourceRange();
1647 E->DirectInitRange = readSourceRange();
Chandler Carruth01718152010-10-25 08:47:36 +00001648
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001649 // Install all the subexpressions.
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00001650 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
1651 N = E->raw_arg_end();
1652 I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001653 *I = Record.readSubStmt();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001654}
1655
Sebastian Redl70c751d2010-08-18 23:56:52 +00001656void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001657 VisitExpr(E);
Bruno Ricci91728fc2018-12-03 12:32:32 +00001658 E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
1659 E->CXXDeleteExprBits.ArrayForm = Record.readInt();
1660 E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
1661 E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001662 E->OperatorDelete = readDeclAs<FunctionDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001663 E->Argument = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001664 E->CXXDeleteExprBits.Loc = readSourceLocation();
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001665}
Chris Lattnercba86142010-05-10 00:25:06 +00001666
Sebastian Redl70c751d2010-08-18 23:56:52 +00001667void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001668 VisitExpr(E);
1669
David L. Jonesb6a8f022016-12-21 04:34:52 +00001670 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001671 E->IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001672 E->OperatorLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001673 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001674 E->ScopeType = readTypeSourceInfo();
1675 E->ColonColonLoc = readSourceLocation();
1676 E->TildeLoc = readSourceLocation();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001677
John McCall3ce3d232019-12-13 03:37:23 -05001678 IdentifierInfo *II = Record.readIdentifier();
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001679 if (II)
John McCall3ce3d232019-12-13 03:37:23 -05001680 E->setDestroyedType(II, readSourceLocation());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001681 else
John McCall3ce3d232019-12-13 03:37:23 -05001682 E->setDestroyedType(readTypeSourceInfo());
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001683}
1684
John McCall5d413782010-12-06 08:20:24 +00001685void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001686 VisitExpr(E);
John McCall28fc7092011-11-10 05:35:25 +00001687
David L. Jonesbe1557a2016-12-21 00:17:49 +00001688 unsigned NumObjects = Record.readInt();
John McCall28fc7092011-11-10 05:35:25 +00001689 assert(NumObjects == E->getNumObjects());
1690 for (unsigned i = 0; i != NumObjects; ++i)
James Y Knighte00a67e2015-12-31 04:18:25 +00001691 E->getTrailingObjects<BlockDecl *>()[i] =
John McCall3ce3d232019-12-13 03:37:23 -05001692 readDeclAs<BlockDecl>();
John McCall28fc7092011-11-10 05:35:25 +00001693
David L. Jonesbe1557a2016-12-21 00:17:49 +00001694 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001695 E->SubExpr = Record.readSubExpr();
Chris Lattnere2437f42010-05-09 06:40:08 +00001696}
1697
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001698void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1699 CXXDependentScopeMemberExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001700 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001701
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001702 bool HasTemplateKWAndArgsInfo = Record.readInt();
1703 unsigned NumTemplateArgs = Record.readInt();
1704 bool HasFirstQualifierFoundInScope = Record.readInt();
1705
1706 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
1707 "Wrong HasTemplateKWAndArgsInfo!");
1708 assert(
1709 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
1710 "Wrong HasFirstQualifierFoundInScope!");
1711
1712 if (HasTemplateKWAndArgsInfo)
James Y Knighte7d82282015-12-29 18:15:14 +00001713 ReadTemplateKWAndArgsInfo(
1714 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001715 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001716
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001717 assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
1718 "Wrong NumTemplateArgs!");
1719
1720 E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001721 E->CXXDependentScopeMemberExprBits.OperatorLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001722 E->BaseType = Record.readType();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001723 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001724 E->Base = Record.readSubExpr();
1725
1726 if (HasFirstQualifierFoundInScope)
John McCall3ce3d232019-12-13 03:37:23 -05001727 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
Bruno Ricci2e6dc532019-01-08 14:17:00 +00001728
John McCall3ce3d232019-12-13 03:37:23 -05001729 E->MemberNameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001730}
1731
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001732void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001733ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001734 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001735
David L. Jonesbe1557a2016-12-21 00:17:49 +00001736 if (Record.readInt()) // HasTemplateKWAndArgsInfo
James Y Knighte7d82282015-12-29 18:15:14 +00001737 ReadTemplateKWAndArgsInfo(
1738 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1739 E->getTrailingObjects<TemplateArgumentLoc>(),
David L. Jonesbe1557a2016-12-21 00:17:49 +00001740 /*NumTemplateArgs=*/Record.readInt());
Douglas Gregor3a43fd62011-02-25 20:49:16 +00001741
David L. Jonesb6a8f022016-12-21 04:34:52 +00001742 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001743 E->NameInfo = Record.readDeclarationNameInfo();
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001744}
1745
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001746void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001747ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001748 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001749 assert(Record.peekInt() == E->arg_size() &&
1750 "Read wrong record during creation ?");
1751 Record.skipInts(1);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001752 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001753 E->setArg(I, Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001754 E->TSI = readTypeSourceInfo();
1755 E->setLParenLoc(readSourceLocation());
1756 E->setRParenLoc(readSourceLocation());
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001757}
1758
Sebastian Redl70c751d2010-08-18 23:56:52 +00001759void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001760 VisitExpr(E);
Abramo Bagnara7945c982012-01-27 09:46:47 +00001761
Bruno Riccid7628d92019-01-09 15:43:19 +00001762 unsigned NumResults = Record.readInt();
1763 bool HasTemplateKWAndArgsInfo = Record.readInt();
1764 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
1765 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
1766 "Wrong HasTemplateKWAndArgsInfo!");
1767
1768 if (HasTemplateKWAndArgsInfo) {
1769 unsigned NumTemplateArgs = Record.readInt();
James Y Knighte7d82282015-12-29 18:15:14 +00001770 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1771 E->getTrailingTemplateArgumentLoc(),
Bruno Riccid7628d92019-01-09 15:43:19 +00001772 NumTemplateArgs);
1773 assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
1774 "Wrong NumTemplateArgs!");
1775 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001776
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001777 UnresolvedSet<8> Decls;
Bruno Riccid7628d92019-01-09 15:43:19 +00001778 for (unsigned I = 0; I != NumResults; ++I) {
John McCall3ce3d232019-12-13 03:37:23 -05001779 auto *D = readDeclAs<NamedDecl>();
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001780 auto AS = (AccessSpecifier)Record.readInt();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001781 Decls.addDecl(D, AS);
1782 }
Bruno Riccid7628d92019-01-09 15:43:19 +00001783
1784 DeclAccessPair *Results = E->getTrailingResults();
1785 UnresolvedSetIterator Iter = Decls.begin();
1786 for (unsigned I = 0; I != NumResults; ++I) {
1787 Results[I] = (Iter + I).getPair();
1788 }
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001789
John McCall3ce3d232019-12-13 03:37:23 -05001790 E->NameInfo = Record.readDeclarationNameInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001791 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001792}
1793
Sebastian Redl70c751d2010-08-18 23:56:52 +00001794void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001795 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00001796 E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
1797 E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001798 E->Base = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001799 E->BaseType = Record.readType();
John McCall3ce3d232019-12-13 03:37:23 -05001800 E->OperatorLoc = readSourceLocation();
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001801}
1802
Sebastian Redl70c751d2010-08-18 23:56:52 +00001803void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001804 VisitOverloadExpr(E);
Bruno Riccid7628d92019-01-09 15:43:19 +00001805 E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
1806 E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001807 E->NamingClass = readDeclAs<CXXRecordDecl>();
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00001808}
1809
Douglas Gregor29c42f22012-02-24 07:38:34 +00001810void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1811 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001812 E->TypeTraitExprBits.NumArgs = Record.readInt();
1813 E->TypeTraitExprBits.Kind = Record.readInt();
1814 E->TypeTraitExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001815 SourceRange Range = readSourceRange();
Jordan Rose99e80c12013-12-20 01:26:47 +00001816 E->Loc = Range.getBegin();
1817 E->RParenLoc = Range.getEnd();
1818
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00001819 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001820 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
John McCall3ce3d232019-12-13 03:37:23 -05001821 Args[I] = readTypeSourceInfo();
Douglas Gregor29c42f22012-02-24 07:38:34 +00001822}
1823
John Wiegley6242b6a2011-04-28 00:16:57 +00001824void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1825 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001826 E->ATT = (ArrayTypeTrait)Record.readInt();
1827 E->Value = (unsigned int)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001828 SourceRange Range = readSourceRange();
John Wiegley6242b6a2011-04-28 00:16:57 +00001829 E->Loc = Range.getBegin();
1830 E->RParen = Range.getEnd();
John McCall3ce3d232019-12-13 03:37:23 -05001831 E->QueriedType = readTypeSourceInfo();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001832 E->Dimension = Record.readSubExpr();
John Wiegley6242b6a2011-04-28 00:16:57 +00001833}
1834
John Wiegleyf9f65842011-04-25 06:54:41 +00001835void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1836 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001837 E->ET = (ExpressionTrait)Record.readInt();
1838 E->Value = (bool)Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001839 SourceRange Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001840 E->QueriedExpression = Record.readSubExpr();
John Wiegleyf9f65842011-04-25 06:54:41 +00001841 E->Loc = Range.getBegin();
1842 E->RParen = Range.getEnd();
1843}
1844
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001845void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1846 VisitExpr(E);
Bruno Riccid56edfe2019-01-08 14:44:34 +00001847 E->CXXNoexceptExprBits.Value = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001848 E->Range = readSourceRange();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001849 E->Operand = Record.readSubExpr();
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001850}
1851
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001852void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1853 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001854 E->EllipsisLoc = readSourceLocation();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001855 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001856 E->Pattern = Record.readSubExpr();
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001857}
1858
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001859void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1860 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001861 unsigned NumPartialArgs = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001862 E->OperatorLoc = readSourceLocation();
1863 E->PackLoc = readSourceLocation();
1864 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001865 E->Pack = Record.readDeclAs<NamedDecl>();
Richard Smithd784e682015-09-23 21:41:42 +00001866 if (E->isPartiallySubstituted()) {
1867 assert(E->Length == NumPartialArgs);
James Y Knighte00a67e2015-12-31 04:18:25 +00001868 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
Richard Smithd784e682015-09-23 21:41:42 +00001869 *E = I + NumPartialArgs;
1870 I != E; ++I)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001871 new (I) TemplateArgument(Record.readTemplateArgument());
Richard Smithd784e682015-09-23 21:41:42 +00001872 } else if (!E->isValueDependent()) {
David L. Jonesbe1557a2016-12-21 00:17:49 +00001873 E->Length = Record.readInt();
Richard Smithd784e682015-09-23 21:41:42 +00001874 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001875}
1876
John McCallfa194042011-07-15 07:00:14 +00001877void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1878 SubstNonTypeTemplateParmExpr *E) {
1879 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001880 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
1881 E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001882 E->Replacement = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00001883}
1884
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001885void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1886 SubstNonTypeTemplateParmPackExpr *E) {
1887 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001888 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001889 TemplateArgument ArgPack = Record.readTemplateArgument();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001890 if (ArgPack.getKind() != TemplateArgument::Pack)
1891 return;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001892
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001893 E->Arguments = ArgPack.pack_begin();
1894 E->NumArguments = ArgPack.pack_size();
John McCall3ce3d232019-12-13 03:37:23 -05001895 E->NameLoc = readSourceLocation();
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001896}
1897
Richard Smithb15fe3a2012-09-12 00:56:43 +00001898void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1899 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001900 E->NumParameters = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001901 E->ParamPack = readDeclAs<ParmVarDecl>();
1902 E->NameLoc = readSourceLocation();
Richard Smithb2997f52019-05-21 20:10:50 +00001903 auto **Parms = E->getTrailingObjects<VarDecl *>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00001904 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
John McCall3ce3d232019-12-13 03:37:23 -05001905 Parms[i] = readDeclAs<VarDecl>();
Richard Smithb15fe3a2012-09-12 00:56:43 +00001906}
1907
Douglas Gregorfe314812011-06-21 17:03:29 +00001908void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1909 VisitExpr(E);
Tykerb0561b32019-11-17 11:41:55 +01001910 bool HasMaterialzedDecl = Record.readInt();
1911 if (HasMaterialzedDecl)
1912 E->State = cast<LifetimeExtendedTemporaryDecl>(Record.readDecl());
1913 else
1914 E->State = Record.readSubExpr();
Douglas Gregorfe314812011-06-21 17:03:29 +00001915}
1916
Richard Smith0f0af192014-11-08 05:07:16 +00001917void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
1918 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001919 E->LParenLoc = readSourceLocation();
1920 E->EllipsisLoc = readSourceLocation();
1921 E->RParenLoc = readSourceLocation();
Richard Smithc7214f62019-05-13 08:31:14 +00001922 E->NumExpansions = Record.readInt();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001923 E->SubExprs[0] = Record.readSubExpr();
1924 E->SubExprs[1] = Record.readSubExpr();
David L. Jonesbe1557a2016-12-21 00:17:49 +00001925 E->Opcode = (BinaryOperatorKind)Record.readInt();
Richard Smith0f0af192014-11-08 05:07:16 +00001926}
1927
John McCall8d69a212010-11-15 23:31:06 +00001928void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1929 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001930 E->SourceExpr = Record.readSubExpr();
John McCall3ce3d232019-12-13 03:37:23 -05001931 E->OpaqueValueExprBits.Loc = readSourceLocation();
Akira Hatanaka797afe32018-03-20 01:47:58 +00001932 E->setIsUnique(Record.readInt());
John McCall8d69a212010-11-15 23:31:06 +00001933}
1934
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001935void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
1936 llvm_unreachable("Cannot read TypoExpr nodes");
1937}
1938
Peter Collingbourne41f85462011-02-09 21:07:24 +00001939//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00001940// Microsoft Expressions and Statements
1941//===----------------------------------------------------------------------===//
John McCall5e77d762013-04-16 07:28:30 +00001942void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1943 VisitExpr(E);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001944 E->IsArrow = (Record.readInt() != 0);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001945 E->BaseExpr = Record.readSubExpr();
1946 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
John McCall3ce3d232019-12-13 03:37:23 -05001947 E->MemberLoc = readSourceLocation();
1948 E->TheDecl = readDeclAs<MSPropertyDecl>();
John McCall5e77d762013-04-16 07:28:30 +00001949}
1950
Alexey Bataevf7630272015-11-25 12:01:00 +00001951void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
1952 VisitExpr(E);
David L. Jonesb6a8f022016-12-21 04:34:52 +00001953 E->setBase(Record.readSubExpr());
1954 E->setIdx(Record.readSubExpr());
John McCall3ce3d232019-12-13 03:37:23 -05001955 E->setRBracketLoc(readSourceLocation());
Alexey Bataevf7630272015-11-25 12:01:00 +00001956}
1957
John McCallfa194042011-07-15 07:00:14 +00001958void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1959 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05001960 E->setSourceRange(readSourceRange());
1961 std::string UuidStr = readString();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001962 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
John McCallfa194042011-07-15 07:00:14 +00001963 if (E->isTypeOperand()) { // __uuidof(ComType)
1964 E->setTypeOperandSourceInfo(
John McCall3ce3d232019-12-13 03:37:23 -05001965 readTypeSourceInfo());
John McCallfa194042011-07-15 07:00:14 +00001966 return;
1967 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00001968
John McCallfa194042011-07-15 07:00:14 +00001969 // __uuidof(expr)
David L. Jonesb6a8f022016-12-21 04:34:52 +00001970 E->setExprOperand(Record.readSubExpr());
John McCallfa194042011-07-15 07:00:14 +00001971}
1972
Nico Weber9b982072014-07-07 00:12:30 +00001973void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1974 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001975 S->setLeaveLoc(readSourceLocation());
Nico Weber9b982072014-07-07 00:12:30 +00001976}
1977
John McCallfa194042011-07-15 07:00:14 +00001978void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1979 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001980 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001981 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
1982 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001983}
1984
1985void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1986 VisitStmt(S);
John McCall3ce3d232019-12-13 03:37:23 -05001987 S->Loc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001988 S->Block = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001989}
1990
1991void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1992 VisitStmt(S);
David L. Jonesbe1557a2016-12-21 00:17:49 +00001993 S->IsCXXTry = Record.readInt();
John McCall3ce3d232019-12-13 03:37:23 -05001994 S->TryLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00001995 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
1996 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
John McCallfa194042011-07-15 07:00:14 +00001997}
1998
1999//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00002000// CUDA Expressions and Statements
2001//===----------------------------------------------------------------------===//
2002
2003void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2004 VisitCallExpr(E);
Richard Smithfd420792019-05-24 23:26:07 +00002005 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
Peter Collingbourne41f85462011-02-09 21:07:24 +00002006}
2007
John McCallfa194042011-07-15 07:00:14 +00002008//===----------------------------------------------------------------------===//
2009// OpenCL Expressions and Statements.
2010//===----------------------------------------------------------------------===//
2011void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2012 VisitExpr(E);
John McCall3ce3d232019-12-13 03:37:23 -05002013 E->BuiltinLoc = readSourceLocation();
2014 E->RParenLoc = readSourceLocation();
David L. Jonesb6a8f022016-12-21 04:34:52 +00002015 E->SrcExpr = Record.readSubExpr();
John McCallfa194042011-07-15 07:00:14 +00002016}
2017
2018//===----------------------------------------------------------------------===//
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002019// OpenMP Directives.
2020//===----------------------------------------------------------------------===//
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002021
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002022void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
John McCall3ce3d232019-12-13 03:37:23 -05002023 E->setLocStart(readSourceLocation());
2024 E->setLocEnd(readSourceLocation());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002025 SmallVector<OMPClause *, 5> Clauses;
2026 for (unsigned i = 0; i < E->getNumClauses(); ++i)
John McCallc2f18312019-12-14 03:01:28 -05002027 Clauses.push_back(Record.readOMPClause());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002028 E->setClauses(Clauses);
Alexey Bataev68446b72014-07-18 07:47:19 +00002029 if (E->hasAssociatedStmt())
David L. Jonesb6a8f022016-12-21 04:34:52 +00002030 E->setAssociatedStmt(Record.readSubStmt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002031}
2032
Alexander Musman3aaab662014-08-19 11:27:13 +00002033void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2034 VisitStmt(D);
2035 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002036 Record.skipInts(2);
Alexander Musman3aaab662014-08-19 11:27:13 +00002037 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002038 D->setIterationVariable(Record.readSubExpr());
2039 D->setLastIteration(Record.readSubExpr());
2040 D->setCalcLastIteration(Record.readSubExpr());
2041 D->setPreCond(Record.readSubExpr());
2042 D->setCond(Record.readSubExpr());
2043 D->setInit(Record.readSubExpr());
2044 D->setInc(Record.readSubExpr());
2045 D->setPreInits(Record.readSubStmt());
Alexey Bataev3392d762016-02-16 11:18:12 +00002046 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
Carlo Bertollifc35ad22016-03-07 16:04:49 +00002047 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2048 isOpenMPDistributeDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002049 D->setIsLastIterVariable(Record.readSubExpr());
2050 D->setLowerBoundVariable(Record.readSubExpr());
2051 D->setUpperBoundVariable(Record.readSubExpr());
2052 D->setStrideVariable(Record.readSubExpr());
2053 D->setEnsureUpperBound(Record.readSubExpr());
2054 D->setNextLowerBound(Record.readSubExpr());
2055 D->setNextUpperBound(Record.readSubExpr());
2056 D->setNumIterations(Record.readSubExpr());
Alexander Musmanc6388682014-12-15 07:07:06 +00002057 }
Carlo Bertolli9925f152016-06-27 14:55:37 +00002058 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
David L. Jonesb6a8f022016-12-21 04:34:52 +00002059 D->setPrevLowerBoundVariable(Record.readSubExpr());
2060 D->setPrevUpperBoundVariable(Record.readSubExpr());
Carlo Bertolli8429d812017-02-17 21:29:13 +00002061 D->setDistInc(Record.readSubExpr());
2062 D->setPrevEnsureUpperBound(Record.readSubExpr());
Carlo Bertolliffafe102017-04-20 00:39:39 +00002063 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2064 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2065 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2066 D->setCombinedInit(Record.readSubExpr());
2067 D->setCombinedCond(Record.readSubExpr());
2068 D->setCombinedNextLowerBound(Record.readSubExpr());
2069 D->setCombinedNextUpperBound(Record.readSubExpr());
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00002070 D->setCombinedDistCond(Record.readSubExpr());
2071 D->setCombinedParForInDistCond(Record.readSubExpr());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002072 }
Alexander Musmana5f070a2014-10-01 06:03:56 +00002073 SmallVector<Expr *, 4> Sub;
2074 unsigned CollapsedNum = D->getCollapsedNumber();
2075 Sub.reserve(CollapsedNum);
2076 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002077 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002078 D->setCounters(Sub);
2079 Sub.clear();
2080 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002081 Sub.push_back(Record.readSubExpr());
Alexey Bataeva8899172015-08-06 12:30:57 +00002082 D->setPrivateCounters(Sub);
2083 Sub.clear();
2084 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002085 Sub.push_back(Record.readSubExpr());
Alexey Bataevb08f89f2015-08-14 12:25:37 +00002086 D->setInits(Sub);
2087 Sub.clear();
2088 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002089 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002090 D->setUpdates(Sub);
2091 Sub.clear();
2092 for (unsigned i = 0; i < CollapsedNum; ++i)
David L. Jonesb6a8f022016-12-21 04:34:52 +00002093 Sub.push_back(Record.readSubExpr());
Alexander Musmana5f070a2014-10-01 06:03:56 +00002094 D->setFinals(Sub);
Alexey Bataevf8be4762019-08-14 19:30:06 +00002095 Sub.clear();
2096 for (unsigned i = 0; i < CollapsedNum; ++i)
2097 Sub.push_back(Record.readSubExpr());
2098 D->setDependentCounters(Sub);
2099 Sub.clear();
2100 for (unsigned i = 0; i < CollapsedNum; ++i)
2101 Sub.push_back(Record.readSubExpr());
2102 D->setDependentInits(Sub);
2103 Sub.clear();
2104 for (unsigned i = 0; i < CollapsedNum; ++i)
2105 Sub.push_back(Record.readSubExpr());
2106 D->setFinalsConditions(Sub);
Alexander Musman3aaab662014-08-19 11:27:13 +00002107}
2108
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002109void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002110 VisitStmt(D);
2111 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002112 Record.skipInts(1);
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002113 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002114 D->setHasCancel(Record.readInt());
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002115}
2116
2117void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002118 VisitOMPLoopDirective(D);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002119}
2120
Alexey Bataevf29276e2014-06-18 04:14:57 +00002121void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002122 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002123 D->setHasCancel(Record.readInt());
Alexey Bataevf29276e2014-06-18 04:14:57 +00002124}
2125
Alexander Musmanf82886e2014-09-18 05:12:34 +00002126void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2127 VisitOMPLoopDirective(D);
2128}
2129
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002130void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2131 VisitStmt(D);
2132 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002133 Record.skipInts(1);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002134 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002135 D->setHasCancel(Record.readInt());
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002136}
2137
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002138void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2139 VisitStmt(D);
2140 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002141 D->setHasCancel(Record.readInt());
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002142}
2143
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002144void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2145 VisitStmt(D);
2146 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002147 Record.skipInts(1);
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002148 VisitOMPExecutableDirective(D);
2149}
2150
Alexander Musman80c22892014-07-17 08:54:58 +00002151void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2152 VisitStmt(D);
2153 VisitOMPExecutableDirective(D);
2154}
2155
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002156void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2157 VisitStmt(D);
Alexey Bataev28c75412015-12-15 08:19:24 +00002158 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002159 Record.skipInts(1);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002160 VisitOMPExecutableDirective(D);
John McCall3ce3d232019-12-13 03:37:23 -05002161 D->DirName = Record.readDeclarationNameInfo();
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002162}
2163
Alexey Bataev4acb8592014-07-07 13:01:15 +00002164void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
Alexander Musman3aaab662014-08-19 11:27:13 +00002165 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002166 D->setHasCancel(Record.readInt());
Alexey Bataev4acb8592014-07-07 13:01:15 +00002167}
2168
Alexander Musmane4e893b2014-09-23 09:33:00 +00002169void ASTStmtReader::VisitOMPParallelForSimdDirective(
2170 OMPParallelForSimdDirective *D) {
2171 VisitOMPLoopDirective(D);
2172}
2173
cchen47d60942019-12-05 13:43:48 -05002174void ASTStmtReader::VisitOMPParallelMasterDirective(
2175 OMPParallelMasterDirective *D) {
2176 VisitStmt(D);
2177 // The NumClauses field was read in ReadStmtFromStream.
2178 Record.skipInts(1);
2179 VisitOMPExecutableDirective(D);
2180}
2181
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002182void ASTStmtReader::VisitOMPParallelSectionsDirective(
2183 OMPParallelSectionsDirective *D) {
2184 VisitStmt(D);
2185 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002186 Record.skipInts(1);
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002187 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002188 D->setHasCancel(Record.readInt());
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002189}
2190
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002191void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2192 VisitStmt(D);
2193 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002194 Record.skipInts(1);
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002195 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002196 D->setHasCancel(Record.readInt());
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002197}
2198
Alexey Bataev68446b72014-07-18 07:47:19 +00002199void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2200 VisitStmt(D);
2201 VisitOMPExecutableDirective(D);
2202}
2203
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002204void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2205 VisitStmt(D);
2206 VisitOMPExecutableDirective(D);
2207}
2208
Alexey Bataev2df347a2014-07-18 10:17:07 +00002209void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2210 VisitStmt(D);
2211 VisitOMPExecutableDirective(D);
2212}
2213
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002214void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2215 VisitStmt(D);
Alexey Bataev169d96a2017-07-18 20:17:46 +00002216 // The NumClauses field was read in ReadStmtFromStream.
2217 Record.skipInts(1);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002218 VisitOMPExecutableDirective(D);
Alexey Bataev3b1b8952017-07-25 15:53:26 +00002219 D->setReductionRef(Record.readSubExpr());
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002220}
2221
Alexey Bataev6125da92014-07-21 11:26:11 +00002222void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2223 VisitStmt(D);
2224 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002225 Record.skipInts(1);
Alexey Bataev6125da92014-07-21 11:26:11 +00002226 VisitOMPExecutableDirective(D);
2227}
2228
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002229void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2230 VisitStmt(D);
Alexey Bataev346265e2015-09-25 10:37:12 +00002231 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002232 Record.skipInts(1);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002233 VisitOMPExecutableDirective(D);
2234}
2235
Alexey Bataev0162e452014-07-22 10:10:35 +00002236void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2237 VisitStmt(D);
2238 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002239 Record.skipInts(1);
Alexey Bataev0162e452014-07-22 10:10:35 +00002240 VisitOMPExecutableDirective(D);
David L. Jonesb6a8f022016-12-21 04:34:52 +00002241 D->setX(Record.readSubExpr());
2242 D->setV(Record.readSubExpr());
2243 D->setExpr(Record.readSubExpr());
2244 D->setUpdateExpr(Record.readSubExpr());
David L. Jonesbe1557a2016-12-21 00:17:49 +00002245 D->IsXLHSInRHSPart = Record.readInt() != 0;
2246 D->IsPostfixUpdate = Record.readInt() != 0;
Alexey Bataev0162e452014-07-22 10:10:35 +00002247}
2248
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002249void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2250 VisitStmt(D);
2251 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002252 Record.skipInts(1);
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002253 VisitOMPExecutableDirective(D);
2254}
2255
Michael Wong65f367f2015-07-21 13:44:28 +00002256void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2257 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002258 Record.skipInts(1);
Michael Wong65f367f2015-07-21 13:44:28 +00002259 VisitOMPExecutableDirective(D);
2260}
2261
Samuel Antaodf67fc42016-01-19 19:15:56 +00002262void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2263 OMPTargetEnterDataDirective *D) {
2264 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002265 Record.skipInts(1);
Samuel Antaodf67fc42016-01-19 19:15:56 +00002266 VisitOMPExecutableDirective(D);
2267}
2268
Samuel Antao72590762016-01-19 20:04:50 +00002269void ASTStmtReader::VisitOMPTargetExitDataDirective(
2270 OMPTargetExitDataDirective *D) {
2271 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002272 Record.skipInts(1);
Samuel Antao72590762016-01-19 20:04:50 +00002273 VisitOMPExecutableDirective(D);
2274}
2275
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002276void ASTStmtReader::VisitOMPTargetParallelDirective(
2277 OMPTargetParallelDirective *D) {
2278 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002279 Record.skipInts(1);
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002280 VisitOMPExecutableDirective(D);
2281}
2282
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002283void ASTStmtReader::VisitOMPTargetParallelForDirective(
2284 OMPTargetParallelForDirective *D) {
2285 VisitOMPLoopDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002286 D->setHasCancel(Record.readInt());
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002287}
2288
Alexey Bataev13314bf2014-10-09 04:18:56 +00002289void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2290 VisitStmt(D);
2291 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002292 Record.skipInts(1);
Alexey Bataev13314bf2014-10-09 04:18:56 +00002293 VisitOMPExecutableDirective(D);
2294}
2295
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002296void ASTStmtReader::VisitOMPCancellationPointDirective(
2297 OMPCancellationPointDirective *D) {
2298 VisitStmt(D);
2299 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002300 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002301}
2302
Alexey Bataev80909872015-07-02 11:25:17 +00002303void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2304 VisitStmt(D);
Alexey Bataev87933c72015-09-18 08:07:34 +00002305 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002306 Record.skipInts(1);
Alexey Bataev80909872015-07-02 11:25:17 +00002307 VisitOMPExecutableDirective(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002308 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
Alexey Bataev80909872015-07-02 11:25:17 +00002309}
2310
Alexey Bataev49f6e782015-12-01 04:18:41 +00002311void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2312 VisitOMPLoopDirective(D);
2313}
2314
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002315void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2316 VisitOMPLoopDirective(D);
2317}
2318
Alexey Bataev60e51c42019-10-10 20:13:02 +00002319void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2320 OMPMasterTaskLoopDirective *D) {
2321 VisitOMPLoopDirective(D);
2322}
2323
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002324void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2325 OMPMasterTaskLoopSimdDirective *D) {
2326 VisitOMPLoopDirective(D);
2327}
2328
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002329void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2330 OMPParallelMasterTaskLoopDirective *D) {
2331 VisitOMPLoopDirective(D);
2332}
2333
Alexey Bataev14a388f2019-10-25 10:27:13 -04002334void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2335 OMPParallelMasterTaskLoopSimdDirective *D) {
2336 VisitOMPLoopDirective(D);
2337}
2338
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002339void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2340 VisitOMPLoopDirective(D);
2341}
2342
Samuel Antao686c70c2016-05-26 17:30:50 +00002343void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2344 VisitStmt(D);
David L. Jonesbe1557a2016-12-21 00:17:49 +00002345 Record.skipInts(1);
Samuel Antao686c70c2016-05-26 17:30:50 +00002346 VisitOMPExecutableDirective(D);
2347}
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002348
Carlo Bertolli9925f152016-06-27 14:55:37 +00002349void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2350 OMPDistributeParallelForDirective *D) {
2351 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002352 D->setHasCancel(Record.readInt());
Carlo Bertolli9925f152016-06-27 14:55:37 +00002353}
Samuel Antao686c70c2016-05-26 17:30:50 +00002354
Kelvin Li4a39add2016-07-05 05:00:15 +00002355void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2356 OMPDistributeParallelForSimdDirective *D) {
2357 VisitOMPLoopDirective(D);
2358}
2359
Kelvin Li787f3fc2016-07-06 04:45:38 +00002360void ASTStmtReader::VisitOMPDistributeSimdDirective(
2361 OMPDistributeSimdDirective *D) {
2362 VisitOMPLoopDirective(D);
2363}
2364
Kelvin Lia579b912016-07-14 02:54:56 +00002365void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2366 OMPTargetParallelForSimdDirective *D) {
2367 VisitOMPLoopDirective(D);
2368}
2369
Kelvin Li986330c2016-07-20 22:57:10 +00002370void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2371 VisitOMPLoopDirective(D);
2372}
2373
Kelvin Li02532872016-08-05 14:37:37 +00002374void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2375 OMPTeamsDistributeDirective *D) {
2376 VisitOMPLoopDirective(D);
2377}
2378
Kelvin Li4e325f72016-10-25 12:50:55 +00002379void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2380 OMPTeamsDistributeSimdDirective *D) {
2381 VisitOMPLoopDirective(D);
2382}
2383
Kelvin Li579e41c2016-11-30 23:51:03 +00002384void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2385 OMPTeamsDistributeParallelForSimdDirective *D) {
2386 VisitOMPLoopDirective(D);
2387}
2388
Kelvin Li7ade93f2016-12-09 03:24:30 +00002389void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2390 OMPTeamsDistributeParallelForDirective *D) {
2391 VisitOMPLoopDirective(D);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00002392 D->setHasCancel(Record.readInt());
Kelvin Li7ade93f2016-12-09 03:24:30 +00002393}
2394
Kelvin Libf594a52016-12-17 05:48:59 +00002395void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2396 VisitStmt(D);
2397 // The NumClauses field was read in ReadStmtFromStream.
David L. Jonesbe1557a2016-12-21 00:17:49 +00002398 Record.skipInts(1);
Kelvin Libf594a52016-12-17 05:48:59 +00002399 VisitOMPExecutableDirective(D);
2400}
2401
Kelvin Li83c451e2016-12-25 04:52:54 +00002402void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2403 OMPTargetTeamsDistributeDirective *D) {
2404 VisitOMPLoopDirective(D);
2405}
2406
Kelvin Li80e8f562016-12-29 22:16:30 +00002407void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2408 OMPTargetTeamsDistributeParallelForDirective *D) {
2409 VisitOMPLoopDirective(D);
Alexey Bataev16e79882017-11-22 21:12:03 +00002410 D->setHasCancel(Record.readInt());
Kelvin Li80e8f562016-12-29 22:16:30 +00002411}
2412
Kelvin Li1851df52017-01-03 05:23:48 +00002413void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2414 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2415 VisitOMPLoopDirective(D);
2416}
2417
Kelvin Lida681182017-01-10 18:08:18 +00002418void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2419 OMPTargetTeamsDistributeSimdDirective *D) {
2420 VisitOMPLoopDirective(D);
2421}
2422
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002423//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00002424// ASTReader Implementation
2425//===----------------------------------------------------------------------===//
2426
Douglas Gregorde3ef502011-11-30 23:21:26 +00002427Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002428 switch (ReadingKind) {
Richard Smith629ff362013-07-31 00:26:46 +00002429 case Read_None:
2430 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002431 case Read_Decl:
2432 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00002433 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002434 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002435 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002436 }
2437
2438 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002439}
2440
Douglas Gregorde3ef502011-11-30 23:21:26 +00002441Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00002442 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002443}
Chris Lattnere2437f42010-05-09 06:40:08 +00002444
Sebastian Redl2c499f62010-08-18 23:56:43 +00002445Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00002446 return cast_or_null<Expr>(ReadSubStmt());
2447}
2448
Chris Lattnerf4262532009-04-27 05:41:06 +00002449// Within the bitstream, expressions are stored in Reverse Polish
2450// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002451// expression they are stored in. Subexpressions are stored from last to first.
2452// To evaluate expressions, we continue reading expressions and placing them on
2453// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00002454// stack. Evaluation terminates when we see a STMT_STOP record, and
2455// the single remaining expression on the stack is our result.
Douglas Gregorde3ef502011-11-30 23:21:26 +00002456Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002457 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00002458 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002459
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002460 // Map of offset to previously deserialized stmt. The offset points
George Burgess IV758cf9d2017-02-14 05:52:57 +00002461 // just after the stmt record.
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002462 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00002463
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002464#ifndef NDEBUG
2465 unsigned PrevNumStmts = StmtStack.size();
2466#endif
2467
David L. Jonesbe1557a2016-12-21 00:17:49 +00002468 ASTRecordReader Record(*this, F);
2469 ASTStmtReader Reader(Record, Cursor);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002470 Stmt::EmptyShell Empty;
2471
2472 while (true) {
JF Bastien0e828952019-06-26 19:50:12 +00002473 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2474 Cursor.advanceSkippingSubblocks();
2475 if (!MaybeEntry) {
2476 Error(toString(MaybeEntry.takeError()));
2477 return nullptr;
2478 }
2479 llvm::BitstreamEntry Entry = MaybeEntry.get();
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002480
Chris Lattner0e6c9402013-01-20 02:38:54 +00002481 switch (Entry.Kind) {
2482 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2483 case llvm::BitstreamEntry::Error:
2484 Error("malformed block record in AST file");
Craig Toppera13603a2014-05-22 05:54:18 +00002485 return nullptr;
Chris Lattner0e6c9402013-01-20 02:38:54 +00002486 case llvm::BitstreamEntry::EndBlock:
2487 goto Done;
2488 case llvm::BitstreamEntry::Record:
2489 // The interesting case.
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002490 break;
2491 }
2492
Richard Smithdbafb6c2017-06-29 23:23:46 +00002493 ASTContext &Context = getContext();
Craig Toppera13603a2014-05-22 05:54:18 +00002494 Stmt *S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002495 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002496 bool IsStmtReference = false;
JF Bastien0e828952019-06-26 19:50:12 +00002497 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2498 if (!MaybeStmtCode) {
2499 Error(toString(MaybeStmtCode.takeError()));
2500 return nullptr;
2501 }
2502 switch ((StmtCode)MaybeStmtCode.get()) {
Sebastian Redl539c5062010-08-18 23:57:32 +00002503 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002504 Finished = true;
2505 break;
2506
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002507 case STMT_REF_PTR:
2508 IsStmtReference = true;
2509 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2510 "No stmt was recorded for this offset reference!");
David L. Jonesbe1557a2016-12-21 00:17:49 +00002511 S = StmtEntries[Record.readInt()];
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002512 break;
2513
Sebastian Redl539c5062010-08-18 23:57:32 +00002514 case STMT_NULL_PTR:
Craig Toppera13603a2014-05-22 05:54:18 +00002515 S = nullptr;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002516 break;
2517
Sebastian Redl539c5062010-08-18 23:57:32 +00002518 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002519 S = new (Context) NullStmt(Empty);
2520 break;
2521
Sebastian Redl539c5062010-08-18 23:57:32 +00002522 case STMT_COMPOUND:
Benjamin Kramer07420902017-12-24 16:24:20 +00002523 S = CompoundStmt::CreateEmpty(
2524 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002525 break;
2526
Sebastian Redl539c5062010-08-18 23:57:32 +00002527 case STMT_CASE:
Bruno Ricci5b30571752018-10-28 12:30:53 +00002528 S = CaseStmt::CreateEmpty(
2529 Context,
2530 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002531 break;
2532
Sebastian Redl539c5062010-08-18 23:57:32 +00002533 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002534 S = new (Context) DefaultStmt(Empty);
2535 break;
2536
Sebastian Redl539c5062010-08-18 23:57:32 +00002537 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002538 S = new (Context) LabelStmt(Empty);
2539 break;
2540
Richard Smithc202b282012-04-14 00:33:13 +00002541 case STMT_ATTRIBUTED:
Alexander Kornienko20f6fc62012-07-09 10:04:07 +00002542 S = AttributedStmt::CreateEmpty(
2543 Context,
2544 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smithc202b282012-04-14 00:33:13 +00002545 break;
2546
Sebastian Redl539c5062010-08-18 23:57:32 +00002547 case STMT_IF:
Bruno Riccib1cc94b2018-10-27 21:12:20 +00002548 S = IfStmt::CreateEmpty(
2549 Context,
2550 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2551 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2552 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002553 break;
2554
Sebastian Redl539c5062010-08-18 23:57:32 +00002555 case STMT_SWITCH:
Bruno Riccie2806f82018-10-29 16:12:37 +00002556 S = SwitchStmt::CreateEmpty(
2557 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002558 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
Bruno Riccie2806f82018-10-29 16:12:37 +00002559 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002560 break;
2561
Sebastian Redl539c5062010-08-18 23:57:32 +00002562 case STMT_WHILE:
Bruno Riccibacf7512018-10-30 13:42:41 +00002563 S = WhileStmt::CreateEmpty(
2564 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002565 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002566 break;
2567
Sebastian Redl539c5062010-08-18 23:57:32 +00002568 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002569 S = new (Context) DoStmt(Empty);
2570 break;
Mike Stump11289f42009-09-09 15:08:12 +00002571
Sebastian Redl539c5062010-08-18 23:57:32 +00002572 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002573 S = new (Context) ForStmt(Empty);
2574 break;
2575
Sebastian Redl539c5062010-08-18 23:57:32 +00002576 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002577 S = new (Context) GotoStmt(Empty);
2578 break;
Mike Stump11289f42009-09-09 15:08:12 +00002579
Sebastian Redl539c5062010-08-18 23:57:32 +00002580 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002581 S = new (Context) IndirectGotoStmt(Empty);
2582 break;
2583
Sebastian Redl539c5062010-08-18 23:57:32 +00002584 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002585 S = new (Context) ContinueStmt(Empty);
2586 break;
2587
Sebastian Redl539c5062010-08-18 23:57:32 +00002588 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002589 S = new (Context) BreakStmt(Empty);
2590 break;
2591
Sebastian Redl539c5062010-08-18 23:57:32 +00002592 case STMT_RETURN:
Bruno Ricci023b1d12018-10-30 14:40:49 +00002593 S = ReturnStmt::CreateEmpty(
2594 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002595 break;
2596
Sebastian Redl539c5062010-08-18 23:57:32 +00002597 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002598 S = new (Context) DeclStmt(Empty);
2599 break;
2600
Chad Rosierde70e0e2012-08-25 00:11:56 +00002601 case STMT_GCCASM:
2602 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002603 break;
2604
Chad Rosiere30d4992012-08-24 23:51:02 +00002605 case STMT_MSASM:
2606 S = new (Context) MSAsmStmt(Empty);
2607 break;
2608
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002609 case STMT_CAPTURED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002610 S = CapturedStmt::CreateDeserialized(
2611 Context, Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj24110cc2013-04-16 18:53:08 +00002612 break;
2613
Bill Wendling7c44da22018-10-31 03:48:47 +00002614 case EXPR_CONSTANT:
Gauthier Harnisch83c7b612019-06-15 10:24:47 +00002615 S = ConstantExpr::CreateEmpty(
2616 Context,
2617 static_cast<ConstantExpr::ResultStorageKind>(
2618 Record[ASTStmtReader::NumExprFields]),
2619 Empty);
Bill Wendling7c44da22018-10-31 03:48:47 +00002620 break;
2621
Sebastian Redl539c5062010-08-18 23:57:32 +00002622 case EXPR_PREDEFINED:
Bruno Ricci17ff0262018-10-27 19:21:19 +00002623 S = PredefinedExpr::CreateEmpty(
2624 Context,
2625 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002626 break;
Mike Stump11289f42009-09-09 15:08:12 +00002627
Sebastian Redl539c5062010-08-18 23:57:32 +00002628 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002629 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00002630 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002631 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2632 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnara7945c982012-01-27 09:46:47 +00002633 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth8d26bb02011-05-01 23:48:14 +00002634 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Richard Smith715f7a12019-06-11 17:50:32 +00002635 Record[ASTStmtReader::NumExprFields + 6] : 0);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002636 break;
Mike Stump11289f42009-09-09 15:08:12 +00002637
Sebastian Redl539c5062010-08-18 23:57:32 +00002638 case EXPR_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002639 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002640 break;
Mike Stump11289f42009-09-09 15:08:12 +00002641
Sebastian Redl539c5062010-08-18 23:57:32 +00002642 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002643 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002644 break;
Mike Stump11289f42009-09-09 15:08:12 +00002645
Sebastian Redl539c5062010-08-18 23:57:32 +00002646 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002647 S = new (Context) ImaginaryLiteral(Empty);
2648 break;
2649
Sebastian Redl539c5062010-08-18 23:57:32 +00002650 case EXPR_STRING_LITERAL:
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002651 S = StringLiteral::CreateEmpty(
2652 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002653 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
Bruno Riccib94ad1e2018-11-15 17:31:16 +00002654 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2655 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002656 break;
2657
Sebastian Redl539c5062010-08-18 23:57:32 +00002658 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002659 S = new (Context) CharacterLiteral(Empty);
2660 break;
2661
Sebastian Redl539c5062010-08-18 23:57:32 +00002662 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002663 S = new (Context) ParenExpr(Empty);
2664 break;
2665
Sebastian Redl539c5062010-08-18 23:57:32 +00002666 case EXPR_PAREN_LIST:
Bruno Riccif49e1ca2018-11-20 16:20:40 +00002667 S = ParenListExpr::CreateEmpty(
2668 Context,
Bruno Ricci9b1afac2018-12-03 16:17:45 +00002669 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00002670 break;
2671
Sebastian Redl539c5062010-08-18 23:57:32 +00002672 case EXPR_UNARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002673 S = new (Context) UnaryOperator(Empty);
2674 break;
2675
Sebastian Redl539c5062010-08-18 23:57:32 +00002676 case EXPR_OFFSETOF:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002677 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002678 Record[ASTStmtReader::NumExprFields],
2679 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00002680 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002681
Sebastian Redl539c5062010-08-18 23:57:32 +00002682 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00002683 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002684 break;
2685
Sebastian Redl539c5062010-08-18 23:57:32 +00002686 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002687 S = new (Context) ArraySubscriptExpr(Empty);
2688 break;
2689
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002690 case EXPR_OMP_ARRAY_SECTION:
2691 S = new (Context) OMPArraySectionExpr(Empty);
2692 break;
2693
Sebastian Redl539c5062010-08-18 23:57:32 +00002694 case EXPR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00002695 S = CallExpr::CreateEmpty(
2696 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002697 break;
2698
Richard Smithdcf17de2019-06-06 23:24:15 +00002699 case EXPR_MEMBER:
2700 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
2701 Record[ASTStmtReader::NumExprFields + 1],
2702 Record[ASTStmtReader::NumExprFields + 2],
2703 Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002704 break;
2705
Sebastian Redl539c5062010-08-18 23:57:32 +00002706 case EXPR_BINARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002707 S = new (Context) BinaryOperator(Empty);
2708 break;
2709
Sebastian Redl539c5062010-08-18 23:57:32 +00002710 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002711 S = new (Context) CompoundAssignOperator(Empty);
2712 break;
2713
Sebastian Redl539c5062010-08-18 23:57:32 +00002714 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002715 S = new (Context) ConditionalOperator(Empty);
2716 break;
2717
John McCallc07a0c72011-02-17 10:25:35 +00002718 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2719 S = new (Context) BinaryConditionalOperator(Empty);
2720 break;
2721
Sebastian Redl539c5062010-08-18 23:57:32 +00002722 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002723 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002724 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002725 break;
2726
Sebastian Redl539c5062010-08-18 23:57:32 +00002727 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002728 S = CStyleCastExpr::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_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002733 S = new (Context) CompoundLiteralExpr(Empty);
2734 break;
2735
Sebastian Redl539c5062010-08-18 23:57:32 +00002736 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002737 S = new (Context) ExtVectorElementExpr(Empty);
2738 break;
2739
Sebastian Redl539c5062010-08-18 23:57:32 +00002740 case EXPR_INIT_LIST:
Argyrios Kyrtzidis0f05fb92012-11-28 03:56:16 +00002741 S = new (Context) InitListExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002742 break;
2743
Sebastian Redl539c5062010-08-18 23:57:32 +00002744 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002745 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002746 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00002747
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002748 break;
2749
Yunzhong Gaocb779302015-06-10 00:27:52 +00002750 case EXPR_DESIGNATED_INIT_UPDATE:
2751 S = new (Context) DesignatedInitUpdateExpr(Empty);
2752 break;
2753
Sebastian Redl539c5062010-08-18 23:57:32 +00002754 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002755 S = new (Context) ImplicitValueInitExpr(Empty);
2756 break;
2757
Yunzhong Gaocb779302015-06-10 00:27:52 +00002758 case EXPR_NO_INIT:
2759 S = new (Context) NoInitExpr(Empty);
2760 break;
2761
Richard Smith410306b2016-12-12 02:53:20 +00002762 case EXPR_ARRAY_INIT_LOOP:
2763 S = new (Context) ArrayInitLoopExpr(Empty);
2764 break;
2765
2766 case EXPR_ARRAY_INIT_INDEX:
2767 S = new (Context) ArrayInitIndexExpr(Empty);
2768 break;
2769
Sebastian Redl539c5062010-08-18 23:57:32 +00002770 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002771 S = new (Context) VAArgExpr(Empty);
2772 break;
2773
Eric Fiselier708afb52019-05-16 21:04:15 +00002774 case EXPR_SOURCE_LOC:
2775 S = new (Context) SourceLocExpr(Empty);
2776 break;
2777
Sebastian Redl539c5062010-08-18 23:57:32 +00002778 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002779 S = new (Context) AddrLabelExpr(Empty);
2780 break;
2781
Sebastian Redl539c5062010-08-18 23:57:32 +00002782 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002783 S = new (Context) StmtExpr(Empty);
2784 break;
2785
Sebastian Redl539c5062010-08-18 23:57:32 +00002786 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002787 S = new (Context) ChooseExpr(Empty);
2788 break;
2789
Sebastian Redl539c5062010-08-18 23:57:32 +00002790 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002791 S = new (Context) GNUNullExpr(Empty);
2792 break;
2793
Sebastian Redl539c5062010-08-18 23:57:32 +00002794 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002795 S = new (Context) ShuffleVectorExpr(Empty);
2796 break;
Mike Stump11289f42009-09-09 15:08:12 +00002797
Hal Finkelc4d7c822013-09-18 03:29:45 +00002798 case EXPR_CONVERT_VECTOR:
2799 S = new (Context) ConvertVectorExpr(Empty);
2800 break;
2801
Sebastian Redl539c5062010-08-18 23:57:32 +00002802 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002803 S = new (Context) BlockExpr(Empty);
2804 break;
2805
Peter Collingbourne91147592011-04-15 00:35:48 +00002806 case EXPR_GENERIC_SELECTION:
Bruno Riccidb076832019-01-26 14:15:10 +00002807 S = GenericSelectionExpr::CreateEmpty(
2808 Context,
2809 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
Peter Collingbourne91147592011-04-15 00:35:48 +00002810 break;
2811
Sebastian Redl539c5062010-08-18 23:57:32 +00002812 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002813 S = new (Context) ObjCStringLiteral(Empty);
2814 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002815
Patrick Beard0caa3942012-04-19 00:25:12 +00002816 case EXPR_OBJC_BOXED_EXPRESSION:
2817 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremeneke65b0862012-03-06 20:05:56 +00002818 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002819
Ted Kremeneke65b0862012-03-06 20:05:56 +00002820 case EXPR_OBJC_ARRAY_LITERAL:
2821 S = ObjCArrayLiteral::CreateEmpty(Context,
2822 Record[ASTStmtReader::NumExprFields]);
2823 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002824
Ted Kremeneke65b0862012-03-06 20:05:56 +00002825 case EXPR_OBJC_DICTIONARY_LITERAL:
2826 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2827 Record[ASTStmtReader::NumExprFields],
2828 Record[ASTStmtReader::NumExprFields + 1]);
2829 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002830
Sebastian Redl539c5062010-08-18 23:57:32 +00002831 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002832 S = new (Context) ObjCEncodeExpr(Empty);
2833 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002834
Sebastian Redl539c5062010-08-18 23:57:32 +00002835 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002836 S = new (Context) ObjCSelectorExpr(Empty);
2837 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002838
Sebastian Redl539c5062010-08-18 23:57:32 +00002839 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002840 S = new (Context) ObjCProtocolExpr(Empty);
2841 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002842
Sebastian Redl539c5062010-08-18 23:57:32 +00002843 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002844 S = new (Context) ObjCIvarRefExpr(Empty);
2845 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002846
Sebastian Redl539c5062010-08-18 23:57:32 +00002847 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002848 S = new (Context) ObjCPropertyRefExpr(Empty);
2849 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002850
Ted Kremeneke65b0862012-03-06 20:05:56 +00002851 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2852 S = new (Context) ObjCSubscriptRefExpr(Empty);
2853 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002854
Sebastian Redl539c5062010-08-18 23:57:32 +00002855 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00002856 llvm_unreachable("mismatching AST file");
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002857
Sebastian Redl539c5062010-08-18 23:57:32 +00002858 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002859 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00002860 Record[ASTStmtReader::NumExprFields],
2861 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002862 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002863
Sebastian Redl539c5062010-08-18 23:57:32 +00002864 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00002865 S = new (Context) ObjCIsaExpr(Empty);
2866 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002867
John McCall31168b02011-06-15 23:02:42 +00002868 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2869 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2870 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002871
John McCall31168b02011-06-15 23:02:42 +00002872 case EXPR_OBJC_BRIDGED_CAST:
2873 S = new (Context) ObjCBridgedCastExpr(Empty);
2874 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002875
Sebastian Redl539c5062010-08-18 23:57:32 +00002876 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002877 S = new (Context) ObjCForCollectionStmt(Empty);
2878 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002879
Sebastian Redl539c5062010-08-18 23:57:32 +00002880 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002881 S = new (Context) ObjCAtCatchStmt(Empty);
2882 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002883
Sebastian Redl539c5062010-08-18 23:57:32 +00002884 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002885 S = new (Context) ObjCAtFinallyStmt(Empty);
2886 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002887
Sebastian Redl539c5062010-08-18 23:57:32 +00002888 case STMT_OBJC_AT_TRY:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00002889 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00002890 Record[ASTStmtReader::NumStmtFields],
2891 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002892 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002893
Sebastian Redl539c5062010-08-18 23:57:32 +00002894 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002895 S = new (Context) ObjCAtSynchronizedStmt(Empty);
2896 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002897
Sebastian Redl539c5062010-08-18 23:57:32 +00002898 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002899 S = new (Context) ObjCAtThrowStmt(Empty);
2900 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002901
John McCall31168b02011-06-15 23:02:42 +00002902 case STMT_OBJC_AUTORELEASE_POOL:
2903 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2904 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002905
Ted Kremeneke65b0862012-03-06 20:05:56 +00002906 case EXPR_OBJC_BOOL_LITERAL:
2907 S = new (Context) ObjCBoolLiteralExpr(Empty);
2908 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002909
Erik Pilkington29099de2016-07-16 00:35:23 +00002910 case EXPR_OBJC_AVAILABILITY_CHECK:
2911 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
2912 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002913
Nico Weber9b982072014-07-07 00:12:30 +00002914 case STMT_SEH_LEAVE:
2915 S = new (Context) SEHLeaveStmt(Empty);
2916 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002917
John McCallfa194042011-07-15 07:00:14 +00002918 case STMT_SEH_EXCEPT:
2919 S = new (Context) SEHExceptStmt(Empty);
2920 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002921
John McCallfa194042011-07-15 07:00:14 +00002922 case STMT_SEH_FINALLY:
2923 S = new (Context) SEHFinallyStmt(Empty);
2924 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002925
John McCallfa194042011-07-15 07:00:14 +00002926 case STMT_SEH_TRY:
2927 S = new (Context) SEHTryStmt(Empty);
2928 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00002929
Sebastian Redl539c5062010-08-18 23:57:32 +00002930 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00002931 S = new (Context) CXXCatchStmt(Empty);
2932 break;
2933
Sebastian Redl539c5062010-08-18 23:57:32 +00002934 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002935 S = CXXTryStmt::Create(Context, Empty,
Rui Ueyama49a3ad22019-07-16 04:46:31 +00002936 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00002937 break;
2938
Richard Smith02e85f32011-04-14 22:09:26 +00002939 case STMT_CXX_FOR_RANGE:
2940 S = new (Context) CXXForRangeStmt(Empty);
2941 break;
2942
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00002943 case STMT_MS_DEPENDENT_EXISTS:
2944 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2945 NestedNameSpecifierLoc(),
2946 DeclarationNameInfo(),
Craig Toppera13603a2014-05-22 05:54:18 +00002947 nullptr);
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00002948 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002949
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002950 case STMT_OMP_PARALLEL_DIRECTIVE:
2951 S =
2952 OMPParallelDirective::CreateEmpty(Context,
2953 Record[ASTStmtReader::NumStmtFields],
2954 Empty);
2955 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002956
2957 case STMT_OMP_SIMD_DIRECTIVE: {
2958 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2959 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2960 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
2961 CollapsedNum, Empty);
2962 break;
2963 }
2964
Alexey Bataevf29276e2014-06-18 04:14:57 +00002965 case STMT_OMP_FOR_DIRECTIVE: {
2966 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2967 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2968 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2969 Empty);
2970 break;
2971 }
2972
Alexander Musmanf82886e2014-09-18 05:12:34 +00002973 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
2974 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2975 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2976 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2977 Empty);
2978 break;
2979 }
2980
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002981 case STMT_OMP_SECTIONS_DIRECTIVE:
2982 S = OMPSectionsDirective::CreateEmpty(
2983 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2984 break;
2985
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002986 case STMT_OMP_SECTION_DIRECTIVE:
2987 S = OMPSectionDirective::CreateEmpty(Context, Empty);
2988 break;
2989
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002990 case STMT_OMP_SINGLE_DIRECTIVE:
2991 S = OMPSingleDirective::CreateEmpty(
2992 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2993 break;
2994
Alexander Musman80c22892014-07-17 08:54:58 +00002995 case STMT_OMP_MASTER_DIRECTIVE:
2996 S = OMPMasterDirective::CreateEmpty(Context, Empty);
2997 break;
2998
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002999 case STMT_OMP_CRITICAL_DIRECTIVE:
Alexey Bataev28c75412015-12-15 08:19:24 +00003000 S = OMPCriticalDirective::CreateEmpty(
3001 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexander Musmand9ed09f2014-07-21 09:42:05 +00003002 break;
3003
Alexey Bataev4acb8592014-07-07 13:01:15 +00003004 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3005 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3006 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3007 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3008 CollapsedNum, Empty);
3009 break;
3010 }
3011
Alexander Musmane4e893b2014-09-23 09:33:00 +00003012 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3013 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3014 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3015 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3016 CollapsedNum, Empty);
3017 break;
3018 }
3019
cchen47d60942019-12-05 13:43:48 -05003020 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3021 S = OMPParallelMasterDirective::CreateEmpty(
3022 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3023 break;
3024
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00003025 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3026 S = OMPParallelSectionsDirective::CreateEmpty(
3027 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3028 break;
3029
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00003030 case STMT_OMP_TASK_DIRECTIVE:
3031 S = OMPTaskDirective::CreateEmpty(
3032 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3033 break;
3034
Alexey Bataev68446b72014-07-18 07:47:19 +00003035 case STMT_OMP_TASKYIELD_DIRECTIVE:
3036 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3037 break;
3038
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00003039 case STMT_OMP_BARRIER_DIRECTIVE:
3040 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3041 break;
3042
Alexey Bataev2df347a2014-07-18 10:17:07 +00003043 case STMT_OMP_TASKWAIT_DIRECTIVE:
3044 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3045 break;
3046
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003047 case STMT_OMP_TASKGROUP_DIRECTIVE:
Alexey Bataev169d96a2017-07-18 20:17:46 +00003048 S = OMPTaskgroupDirective::CreateEmpty(
3049 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00003050 break;
3051
Alexey Bataev6125da92014-07-21 11:26:11 +00003052 case STMT_OMP_FLUSH_DIRECTIVE:
3053 S = OMPFlushDirective::CreateEmpty(
3054 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3055 break;
3056
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003057 case STMT_OMP_ORDERED_DIRECTIVE:
Alexey Bataev346265e2015-09-25 10:37:12 +00003058 S = OMPOrderedDirective::CreateEmpty(
3059 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev9fb6e642014-07-22 06:45:04 +00003060 break;
3061
Alexey Bataev0162e452014-07-22 10:10:35 +00003062 case STMT_OMP_ATOMIC_DIRECTIVE:
3063 S = OMPAtomicDirective::CreateEmpty(
3064 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3065 break;
3066
Alexey Bataev0bd520b2014-09-19 08:19:49 +00003067 case STMT_OMP_TARGET_DIRECTIVE:
3068 S = OMPTargetDirective::CreateEmpty(
3069 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3070 break;
3071
Michael Wong65f367f2015-07-21 13:44:28 +00003072 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3073 S = OMPTargetDataDirective::CreateEmpty(
3074 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3075 break;
3076
Samuel Antaodf67fc42016-01-19 19:15:56 +00003077 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3078 S = OMPTargetEnterDataDirective::CreateEmpty(
3079 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3080 break;
3081
Samuel Antao72590762016-01-19 20:04:50 +00003082 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3083 S = OMPTargetExitDataDirective::CreateEmpty(
3084 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3085 break;
3086
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00003087 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3088 S = OMPTargetParallelDirective::CreateEmpty(
3089 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3090 break;
3091
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00003092 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3093 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3094 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3095 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3096 CollapsedNum, Empty);
3097 break;
3098 }
3099
Samuel Antao686c70c2016-05-26 17:30:50 +00003100 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3101 S = OMPTargetUpdateDirective::CreateEmpty(
3102 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3103 break;
3104
Alexey Bataev13314bf2014-10-09 04:18:56 +00003105 case STMT_OMP_TEAMS_DIRECTIVE:
3106 S = OMPTeamsDirective::CreateEmpty(
3107 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3108 break;
3109
Alexey Bataev6d4ed052015-07-01 06:57:41 +00003110 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3111 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3112 break;
3113
Alexey Bataev80909872015-07-02 11:25:17 +00003114 case STMT_OMP_CANCEL_DIRECTIVE:
Alexey Bataev87933c72015-09-18 08:07:34 +00003115 S = OMPCancelDirective::CreateEmpty(
3116 Context, Record[ASTStmtReader::NumStmtFields], Empty);
Alexey Bataev80909872015-07-02 11:25:17 +00003117 break;
3118
Alexey Bataev49f6e782015-12-01 04:18:41 +00003119 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3120 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3121 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3122 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3123 Empty);
3124 break;
3125 }
3126
Alexey Bataev0a6ed842015-12-03 09:40:15 +00003127 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3128 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3129 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3130 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3131 CollapsedNum, Empty);
3132 break;
3133 }
3134
Alexey Bataev60e51c42019-10-10 20:13:02 +00003135 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3136 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3137 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3138 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3139 CollapsedNum, Empty);
3140 break;
3141 }
3142
Alexey Bataevb8552ab2019-10-18 16:47:35 +00003143 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3144 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3145 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3146 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3147 CollapsedNum, Empty);
3148 break;
3149 }
3150
Alexey Bataev5bbcead2019-10-14 17:17:41 +00003151 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3152 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3153 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3154 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3155 CollapsedNum, Empty);
3156 break;
3157 }
3158
Alexey Bataev14a388f2019-10-25 10:27:13 -04003159 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3160 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3161 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3162 S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3163 Context, NumClauses, CollapsedNum, Empty);
3164 break;
3165 }
3166
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00003167 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3168 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3169 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3170 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3171 Empty);
3172 break;
3173 }
3174
Carlo Bertolli9925f152016-06-27 14:55:37 +00003175 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3176 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3177 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3178 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3179 CollapsedNum, Empty);
3180 break;
3181 }
3182
Kelvin Li4a39add2016-07-05 05:00:15 +00003183 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3184 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3185 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3186 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3187 CollapsedNum,
3188 Empty);
3189 break;
3190 }
3191
Kelvin Li787f3fc2016-07-06 04:45:38 +00003192 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3193 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3194 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3195 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3196 CollapsedNum, Empty);
3197 break;
3198 }
3199
Kelvin Lia579b912016-07-14 02:54:56 +00003200 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3201 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3202 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3203 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3204 CollapsedNum, Empty);
3205 break;
3206 }
3207
Kelvin Li986330c2016-07-20 22:57:10 +00003208 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3209 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3210 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3211 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3212 Empty);
3213 break;
3214 }
3215
Kelvin Li83c451e2016-12-25 04:52:54 +00003216 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
Kelvin Li02532872016-08-05 14:37:37 +00003217 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3218 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3219 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3220 CollapsedNum, Empty);
3221 break;
3222 }
3223
Kelvin Li4e325f72016-10-25 12:50:55 +00003224 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3225 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3226 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3227 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3228 CollapsedNum, Empty);
3229 break;
3230 }
3231
Kelvin Li579e41c2016-11-30 23:51:03 +00003232 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3233 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3234 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3235 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3236 Context, NumClauses, CollapsedNum, Empty);
3237 break;
3238 }
3239
Kelvin Li7ade93f2016-12-09 03:24:30 +00003240 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3241 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3242 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3243 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3244 Context, NumClauses, CollapsedNum, Empty);
3245 break;
3246 }
3247
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003248 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
Kelvin Libf594a52016-12-17 05:48:59 +00003249 S = OMPTargetTeamsDirective::CreateEmpty(
3250 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3251 break;
Kelvin Li83c451e2016-12-25 04:52:54 +00003252
3253 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3254 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3255 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3256 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3257 CollapsedNum, Empty);
3258 break;
3259 }
3260
Kelvin Li80e8f562016-12-29 22:16:30 +00003261 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3262 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3263 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3264 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3265 Context, NumClauses, CollapsedNum, Empty);
3266 break;
3267 }
3268
Kelvin Li1851df52017-01-03 05:23:48 +00003269 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3270 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3271 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3272 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3273 Context, NumClauses, CollapsedNum, Empty);
3274 break;
3275 }
3276
Kelvin Lida681182017-01-10 18:08:18 +00003277 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3278 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3279 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3280 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3281 Context, NumClauses, CollapsedNum, Empty);
3282 break;
3283 }
3284
Sebastian Redl539c5062010-08-18 23:57:32 +00003285 case EXPR_CXX_OPERATOR_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003286 S = CXXOperatorCallExpr::CreateEmpty(
3287 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00003288 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003289
Sebastian Redl539c5062010-08-18 23:57:32 +00003290 case EXPR_CXX_MEMBER_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003291 S = CXXMemberCallExpr::CreateEmpty(
3292 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00003293 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003294
Richard Smith778dc0f2019-10-19 00:04:38 +00003295 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3296 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3297 break;
3298
Sebastian Redl539c5062010-08-18 23:57:32 +00003299 case EXPR_CXX_CONSTRUCT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003300 S = CXXConstructExpr::CreateEmpty(
3301 Context,
3302 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00003303 break;
Alexey Bataev1b59ab52014-02-27 08:29:12 +00003304
Richard Smith5179eb72016-06-28 19:03:57 +00003305 case EXPR_CXX_INHERITED_CTOR_INIT:
3306 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3307 break;
3308
Sebastian Redl539c5062010-08-18 23:57:32 +00003309 case EXPR_CXX_TEMPORARY_OBJECT:
Bruno Ricciddb8f6b2018-12-22 14:39:30 +00003310 S = CXXTemporaryObjectExpr::CreateEmpty(
3311 Context,
3312 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00003313 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003314
Sebastian Redl539c5062010-08-18 23:57:32 +00003315 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003316 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003317 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003318 break;
3319
Sebastian Redl539c5062010-08-18 23:57:32 +00003320 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003321 S = CXXDynamicCastExpr::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_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003326 S = CXXReinterpretCastExpr::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_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003331 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00003332 break;
3333
Sebastian Redl539c5062010-08-18 23:57:32 +00003334 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003335 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003336 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00003337 break;
3338
Richard Smithc67fdd42012-03-07 08:35:16 +00003339 case EXPR_USER_DEFINED_LITERAL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003340 S = UserDefinedLiteral::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003341 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Richard Smithc67fdd42012-03-07 08:35:16 +00003342 break;
3343
Richard Smithcc1b96d2013-06-12 22:31:48 +00003344 case EXPR_CXX_STD_INITIALIZER_LIST:
3345 S = new (Context) CXXStdInitializerListExpr(Empty);
3346 break;
3347
Sebastian Redl539c5062010-08-18 23:57:32 +00003348 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003349 S = new (Context) CXXBoolLiteralExpr(Empty);
3350 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00003351
Sebastian Redl539c5062010-08-18 23:57:32 +00003352 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00003353 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3354 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003355
Sebastian Redl539c5062010-08-18 23:57:32 +00003356 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003357 S = new (Context) CXXTypeidExpr(Empty, true);
3358 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003359
Sebastian Redl539c5062010-08-18 23:57:32 +00003360 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00003361 S = new (Context) CXXTypeidExpr(Empty, false);
3362 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003363
Francois Pichet9f4f2072010-09-08 12:20:18 +00003364 case EXPR_CXX_UUIDOF_EXPR:
3365 S = new (Context) CXXUuidofExpr(Empty, true);
3366 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003367
John McCall5e77d762013-04-16 07:28:30 +00003368 case EXPR_CXX_PROPERTY_REF_EXPR:
3369 S = new (Context) MSPropertyRefExpr(Empty);
3370 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003371
Alexey Bataevf7630272015-11-25 12:01:00 +00003372 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3373 S = new (Context) MSPropertySubscriptExpr(Empty);
3374 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003375
Francois Pichet9f4f2072010-09-08 12:20:18 +00003376 case EXPR_CXX_UUIDOF_TYPE:
3377 S = new (Context) CXXUuidofExpr(Empty, false);
3378 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003379
Sebastian Redl539c5062010-08-18 23:57:32 +00003380 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00003381 S = new (Context) CXXThisExpr(Empty);
3382 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003383
Sebastian Redl539c5062010-08-18 23:57:32 +00003384 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00003385 S = new (Context) CXXThrowExpr(Empty);
3386 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003387
John McCall32791cc2016-01-06 22:34:54 +00003388 case EXPR_CXX_DEFAULT_ARG:
3389 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00003390 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003391
Richard Smith852c9db2013-04-20 22:23:05 +00003392 case EXPR_CXX_DEFAULT_INIT:
3393 S = new (Context) CXXDefaultInitExpr(Empty);
3394 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003395
Sebastian Redl539c5062010-08-18 23:57:32 +00003396 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00003397 S = new (Context) CXXBindTemporaryExpr(Empty);
3398 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003399
Sebastian Redl539c5062010-08-18 23:57:32 +00003400 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00003401 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003402 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003403
Sebastian Redl539c5062010-08-18 23:57:32 +00003404 case EXPR_CXX_NEW:
Bruno Ricci9b6dfac2019-01-07 15:04:45 +00003405 S = CXXNewExpr::CreateEmpty(
3406 Context,
3407 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3408 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3409 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3410 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00003411 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003412
Sebastian Redl539c5062010-08-18 23:57:32 +00003413 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00003414 S = new (Context) CXXDeleteExpr(Empty);
3415 break;
Eugene Zelenkoe69b33f2018-04-11 20:57:28 +00003416
Sebastian Redl539c5062010-08-18 23:57:32 +00003417 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00003418 S = new (Context) CXXPseudoDestructorExpr(Empty);
3419 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003420
John McCall5d413782010-12-06 08:20:24 +00003421 case EXPR_EXPR_WITH_CLEANUPS:
John McCall28fc7092011-11-10 05:35:25 +00003422 S = ExprWithCleanups::Create(Context, Empty,
3423 Record[ASTStmtReader::NumExprFields]);
Chris Lattnercba86142010-05-10 00:25:06 +00003424 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003425
Sebastian Redl539c5062010-08-18 23:57:32 +00003426 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Bruno Ricci2e6dc532019-01-08 14:17:00 +00003427 S = CXXDependentScopeMemberExpr::CreateEmpty(
3428 Context,
3429 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3430 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3431 /*HasFirstQualifierFoundInScope=*/
3432 Record[ASTStmtReader::NumExprFields + 2]);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003433 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003434
Sebastian Redl539c5062010-08-18 23:57:32 +00003435 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003436 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnara7945c982012-01-27 09:46:47 +00003437 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregor87866ce2011-02-04 12:01:24 +00003438 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003439 ? Record[ASTStmtReader::NumExprFields + 1]
Douglas Gregor87866ce2011-02-04 12:01:24 +00003440 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00003441 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003442
Sebastian Redl539c5062010-08-18 23:57:32 +00003443 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00003444 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00003445 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00003446 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003447
Sebastian Redl539c5062010-08-18 23:57:32 +00003448 case EXPR_CXX_UNRESOLVED_MEMBER:
Bruno Riccid7628d92019-01-09 15:43:19 +00003449 S = UnresolvedMemberExpr::CreateEmpty(
3450 Context,
3451 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3452 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3453 /*NumTemplateArgs=*/
3454 Record[ASTStmtReader::NumExprFields + 1]
3455 ? Record[ASTStmtReader::NumExprFields + 2]
3456 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00003457 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003458
Sebastian Redl539c5062010-08-18 23:57:32 +00003459 case EXPR_CXX_UNRESOLVED_LOOKUP:
Bruno Riccid7628d92019-01-09 15:43:19 +00003460 S = UnresolvedLookupExpr::CreateEmpty(
3461 Context,
3462 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3463 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3464 /*NumTemplateArgs=*/
3465 Record[ASTStmtReader::NumExprFields + 1]
3466 ? Record[ASTStmtReader::NumExprFields + 2]
3467 : 0);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00003468 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003469
Douglas Gregor29c42f22012-02-24 07:38:34 +00003470 case EXPR_TYPE_TRAIT:
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003471 S = TypeTraitExpr::CreateDeserialized(Context,
Douglas Gregor29c42f22012-02-24 07:38:34 +00003472 Record[ASTStmtReader::NumExprFields]);
3473 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003474
John Wiegley6242b6a2011-04-28 00:16:57 +00003475 case EXPR_ARRAY_TYPE_TRAIT:
3476 S = new (Context) ArrayTypeTraitExpr(Empty);
3477 break;
3478
John Wiegleyf9f65842011-04-25 06:54:41 +00003479 case EXPR_CXX_EXPRESSION_TRAIT:
3480 S = new (Context) ExpressionTraitExpr(Empty);
3481 break;
3482
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00003483 case EXPR_CXX_NOEXCEPT:
3484 S = new (Context) CXXNoexceptExpr(Empty);
3485 break;
John McCall8d69a212010-11-15 23:31:06 +00003486
Douglas Gregore8e9dd62011-01-03 17:17:50 +00003487 case EXPR_PACK_EXPANSION:
3488 S = new (Context) PackExpansionExpr(Empty);
3489 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003490
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003491 case EXPR_SIZEOF_PACK:
Richard Smithd784e682015-09-23 21:41:42 +00003492 S = SizeOfPackExpr::CreateDeserialized(
3493 Context,
3494 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00003495 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003496
John McCallfa194042011-07-15 07:00:14 +00003497 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3498 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3499 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003500
Douglas Gregorcdbc5392011-01-15 01:15:58 +00003501 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3502 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3503 break;
Richard Smithb15fe3a2012-09-12 00:56:43 +00003504
3505 case EXPR_FUNCTION_PARM_PACK:
3506 S = FunctionParmPackExpr::CreateEmpty(Context,
3507 Record[ASTStmtReader::NumExprFields]);
3508 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003509
Douglas Gregorfe314812011-06-21 17:03:29 +00003510 case EXPR_MATERIALIZE_TEMPORARY:
3511 S = new (Context) MaterializeTemporaryExpr(Empty);
3512 break;
Richard Smith0f0af192014-11-08 05:07:16 +00003513
3514 case EXPR_CXX_FOLD:
3515 S = new (Context) CXXFoldExpr(Empty);
3516 break;
3517
Argyrios Kyrtzidisb2b07952011-12-03 03:49:52 +00003518 case EXPR_OPAQUE_VALUE:
3519 S = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00003520 break;
Peter Collingbourne41f85462011-02-09 21:07:24 +00003521
3522 case EXPR_CUDA_KERNEL_CALL:
Bruno Riccic5885cf2018-12-21 15:20:32 +00003523 S = CUDAKernelCallExpr::CreateEmpty(
Bruno Ricci9b1afac2018-12-03 16:17:45 +00003524 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00003525 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003526
Tanya Lattner55808c12011-06-04 00:47:47 +00003527 case EXPR_ASTYPE:
3528 S = new (Context) AsTypeExpr(Empty);
3529 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003530
John McCallfe96e0b2011-11-06 09:01:30 +00003531 case EXPR_PSEUDO_OBJECT: {
3532 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3533 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3534 break;
3535 }
3536
Eli Friedmandf14b3a2011-10-11 02:20:01 +00003537 case EXPR_ATOMIC:
3538 S = new (Context) AtomicExpr(Empty);
3539 break;
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003540
Douglas Gregor99ae8062012-02-14 17:54:36 +00003541 case EXPR_LAMBDA: {
3542 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
Richard Smith30e304e2016-12-14 00:03:17 +00003543 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
Douglas Gregor99ae8062012-02-14 17:54:36 +00003544 break;
3545 }
Gor Nishanovf5ecb5e2017-07-25 18:01:49 +00003546
3547 case STMT_COROUTINE_BODY: {
3548 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3549 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3550 break;
3551 }
3552
3553 case STMT_CORETURN:
3554 S = new (Context) CoreturnStmt(Empty);
3555 break;
3556
3557 case EXPR_COAWAIT:
3558 S = new (Context) CoawaitExpr(Empty);
3559 break;
3560
3561 case EXPR_COYIELD:
3562 S = new (Context) CoyieldExpr(Empty);
3563 break;
3564
3565 case EXPR_DEPENDENT_COAWAIT:
3566 S = new (Context) DependentCoawaitExpr(Empty);
3567 break;
Saar Raz5d98ba62019-10-15 15:24:26 +00003568
3569 case EXPR_CONCEPT_SPECIALIZATION:
3570 unsigned numTemplateArgs = Record[ASTStmtReader::NumExprFields];
3571 S = ConceptSpecializationExpr::Create(Context, Empty, numTemplateArgs);
3572 break;
3573
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003574 }
David L. Jonesc4808b9e2016-12-15 20:53:26 +00003575
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003576 // We hit a STMT_STOP, so we're done with this expression.
3577 if (Finished)
3578 break;
3579
3580 ++NumStatementsRead;
3581
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003582 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003583 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00003584 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3585 }
3586
David L. Jonesbe1557a2016-12-21 00:17:49 +00003587 assert(Record.getIdx() == Record.size() &&
3588 "Invalid deserialization of statement");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003589 StmtStack.push_back(S);
3590 }
Chris Lattner0e6c9402013-01-20 02:38:54 +00003591Done:
Alp Toker028ed912013-12-06 17:56:43 +00003592 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003593 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00003594 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00003595}