Coverage Report

Created: 2023-09-30 09:22

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Serialization/ASTWriterStmt.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- ASTWriterStmt.cpp - Statement and Expression Serialization -------===//
2
//
3
// 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
6
//
7
//===----------------------------------------------------------------------===//
8
///
9
/// \file
10
/// Implements serialization for Statements and Expressions.
11
///
12
//===----------------------------------------------------------------------===//
13
14
#include "clang/AST/ASTConcept.h"
15
#include "clang/AST/ASTContext.h"
16
#include "clang/AST/DeclCXX.h"
17
#include "clang/AST/DeclObjC.h"
18
#include "clang/AST/DeclTemplate.h"
19
#include "clang/AST/ExprOpenMP.h"
20
#include "clang/AST/StmtVisitor.h"
21
#include "clang/Lex/Token.h"
22
#include "clang/Sema/DeclSpec.h"
23
#include "clang/Serialization/ASTRecordWriter.h"
24
#include "llvm/Bitstream/BitstreamWriter.h"
25
using namespace clang;
26
27
//===----------------------------------------------------------------------===//
28
// Statement/expression serialization
29
//===----------------------------------------------------------------------===//
30
31
namespace clang {
32
33
  class ASTStmtWriter : public StmtVisitor<ASTStmtWriter, void> {
34
    ASTWriter &Writer;
35
    ASTRecordWriter Record;
36
37
    serialization::StmtCode Code;
38
    unsigned AbbrevToUse;
39
40
  public:
41
    ASTStmtWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
42
3.39M
        : Writer(Writer), Record(Writer, Record),
43
3.39M
          Code(serialization::STMT_NULL_PTR), AbbrevToUse(0) {}
44
45
    ASTStmtWriter(const ASTStmtWriter&) = delete;
46
    ASTStmtWriter &operator=(const ASTStmtWriter &) = delete;
47
48
2.91M
    uint64_t Emit() {
49
2.91M
      assert(Code != serialization::STMT_NULL_PTR &&
50
2.91M
             "unhandled sub-statement writing AST file");
51
2.91M
      return Record.EmitStmt(Code, AbbrevToUse);
52
2.91M
    }
53
54
    void AddTemplateKWAndArgsInfo(const ASTTemplateKWAndArgsInfo &ArgInfo,
55
                                  const TemplateArgumentLoc *Args);
56
57
    void VisitStmt(Stmt *S);
58
#define STMT(Type, Base) \
59
    void Visit##Type(Type *);
60
#include "clang/AST/StmtNodes.inc"
61
  };
62
}
63
64
void ASTStmtWriter::AddTemplateKWAndArgsInfo(
65
7.52k
    const ASTTemplateKWAndArgsInfo &ArgInfo, const TemplateArgumentLoc *Args) {
66
7.52k
  Record.AddSourceLocation(ArgInfo.TemplateKWLoc);
67
7.52k
  Record.AddSourceLocation(ArgInfo.LAngleLoc);
68
7.52k
  Record.AddSourceLocation(ArgInfo.RAngleLoc);
69
17.2k
  for (unsigned i = 0; i != ArgInfo.NumTemplateArgs; 
++i9.68k
)
70
9.68k
    Record.AddTemplateArgumentLoc(Args[i]);
71
7.52k
}
72
73
2.91M
void ASTStmtWriter::VisitStmt(Stmt *S) {
74
2.91M
}
75
76
648
void ASTStmtWriter::VisitNullStmt(NullStmt *S) {
77
648
  VisitStmt(S);
78
648
  Record.AddSourceLocation(S->getSemiLoc());
79
648
  Record.push_back(S->NullStmtBits.HasLeadingEmptyMacro);
80
648
  Code = serialization::STMT_NULL;
81
648
}
82
83
118k
void ASTStmtWriter::VisitCompoundStmt(CompoundStmt *S) {
84
118k
  VisitStmt(S);
85
118k
  Record.push_back(S->size());
86
118k
  Record.push_back(S->hasStoredFPFeatures());
87
118k
  for (auto *CS : S->body())
88
201k
    Record.AddStmt(CS);
89
118k
  if (S->hasStoredFPFeatures())
90
16.9k
    Record.push_back(S->getStoredFPFeatures().getAsOpaqueInt());
91
118k
  Record.AddSourceLocation(S->getLBracLoc());
92
118k
  Record.AddSourceLocation(S->getRBracLoc());
93
118k
  Code = serialization::STMT_COMPOUND;
94
118k
}
95
96
1.02k
void ASTStmtWriter::VisitSwitchCase(SwitchCase *S) {
97
1.02k
  VisitStmt(S);
98
1.02k
  Record.push_back(Writer.getSwitchCaseID(S));
99
1.02k
  Record.AddSourceLocation(S->getKeywordLoc());
100
1.02k
  Record.AddSourceLocation(S->getColonLoc());
101
1.02k
}
102
103
941
void ASTStmtWriter::VisitCaseStmt(CaseStmt *S) {
104
941
  VisitSwitchCase(S);
105
941
  Record.push_back(S->caseStmtIsGNURange());
106
941
  Record.AddStmt(S->getLHS());
107
941
  Record.AddStmt(S->getSubStmt());
108
941
  if (S->caseStmtIsGNURange()) {
109
1
    Record.AddStmt(S->getRHS());
110
1
    Record.AddSourceLocation(S->getEllipsisLoc());
111
1
  }
112
941
  Code = serialization::STMT_CASE;
113
941
}
114
115
88
void ASTStmtWriter::VisitDefaultStmt(DefaultStmt *S) {
116
88
  VisitSwitchCase(S);
117
88
  Record.AddStmt(S->getSubStmt());
118
88
  Code = serialization::STMT_DEFAULT;
119
88
}
120
121
44
void ASTStmtWriter::VisitLabelStmt(LabelStmt *S) {
122
44
  VisitStmt(S);
123
44
  Record.push_back(S->isSideEntry());
124
44
  Record.AddDeclRef(S->getDecl());
125
44
  Record.AddStmt(S->getSubStmt());
126
44
  Record.AddSourceLocation(S->getIdentLoc());
127
44
  Code = serialization::STMT_LABEL;
128
44
}
129
130
35
void ASTStmtWriter::VisitAttributedStmt(AttributedStmt *S) {
131
35
  VisitStmt(S);
132
35
  Record.push_back(S->getAttrs().size());
133
35
  Record.AddAttributes(S->getAttrs());
134
35
  Record.AddStmt(S->getSubStmt());
135
35
  Record.AddSourceLocation(S->getAttrLoc());
136
35
  Code = serialization::STMT_ATTRIBUTED;
137
35
}
138
139
12.2k
void ASTStmtWriter::VisitIfStmt(IfStmt *S) {
140
12.2k
  VisitStmt(S);
141
142
12.2k
  bool HasElse = S->getElse() != nullptr;
143
12.2k
  bool HasVar = S->getConditionVariableDeclStmt() != nullptr;
144
12.2k
  bool HasInit = S->getInit() != nullptr;
145
146
12.2k
  Record.push_back(HasElse);
147
12.2k
  Record.push_back(HasVar);
148
12.2k
  Record.push_back(HasInit);
149
12.2k
  Record.push_back(static_cast<uint64_t>(S->getStatementKind()));
150
12.2k
  Record.AddStmt(S->getCond());
151
12.2k
  Record.AddStmt(S->getThen());
152
12.2k
  if (HasElse)
153
2.66k
    Record.AddStmt(S->getElse());
154
12.2k
  if (HasVar)
155
10
    Record.AddStmt(S->getConditionVariableDeclStmt());
156
12.2k
  if (HasInit)
157
4
    Record.AddStmt(S->getInit());
158
159
12.2k
  Record.AddSourceLocation(S->getIfLoc());
160
12.2k
  Record.AddSourceLocation(S->getLParenLoc());
161
12.2k
  Record.AddSourceLocation(S->getRParenLoc());
162
12.2k
  if (HasElse)
163
2.66k
    Record.AddSourceLocation(S->getElseLoc());
164
165
12.2k
  Code = serialization::STMT_IF;
166
12.2k
}
167
168
187
void ASTStmtWriter::VisitSwitchStmt(SwitchStmt *S) {
169
187
  VisitStmt(S);
170
171
187
  bool HasInit = S->getInit() != nullptr;
172
187
  bool HasVar = S->getConditionVariableDeclStmt() != nullptr;
173
187
  Record.push_back(HasInit);
174
187
  Record.push_back(HasVar);
175
187
  Record.push_back(S->isAllEnumCasesCovered());
176
177
187
  Record.AddStmt(S->getCond());
178
187
  Record.AddStmt(S->getBody());
179
187
  if (HasInit)
180
2
    Record.AddStmt(S->getInit());
181
187
  if (HasVar)
182
0
    Record.AddStmt(S->getConditionVariableDeclStmt());
183
184
187
  Record.AddSourceLocation(S->getSwitchLoc());
185
187
  Record.AddSourceLocation(S->getLParenLoc());
186
187
  Record.AddSourceLocation(S->getRParenLoc());
187
188
1.21k
  for (SwitchCase *SC = S->getSwitchCaseList(); SC;
189
1.02k
       SC = SC->getNextSwitchCase())
190
1.02k
    Record.push_back(Writer.RecordSwitchCaseID(SC));
191
187
  Code = serialization::STMT_SWITCH;
192
187
}
193
194
689
void ASTStmtWriter::VisitWhileStmt(WhileStmt *S) {
195
689
  VisitStmt(S);
196
197
689
  bool HasVar = S->getConditionVariableDeclStmt() != nullptr;
198
689
  Record.push_back(HasVar);
199
200
689
  Record.AddStmt(S->getCond());
201
689
  Record.AddStmt(S->getBody());
202
689
  if (HasVar)
203
3
    Record.AddStmt(S->getConditionVariableDeclStmt());
204
205
689
  Record.AddSourceLocation(S->getWhileLoc());
206
689
  Record.AddSourceLocation(S->getLParenLoc());
207
689
  Record.AddSourceLocation(S->getRParenLoc());
208
689
  Code = serialization::STMT_WHILE;
209
689
}
210
211
127
void ASTStmtWriter::VisitDoStmt(DoStmt *S) {
212
127
  VisitStmt(S);
213
127
  Record.AddStmt(S->getCond());
214
127
  Record.AddStmt(S->getBody());
215
127
  Record.AddSourceLocation(S->getDoLoc());
216
127
  Record.AddSourceLocation(S->getWhileLoc());
217
127
  Record.AddSourceLocation(S->getRParenLoc());
218
127
  Code = serialization::STMT_DO;
219
127
}
220
221
11.2k
void ASTStmtWriter::VisitForStmt(ForStmt *S) {
222
11.2k
  VisitStmt(S);
223
11.2k
  Record.AddStmt(S->getInit());
224
11.2k
  Record.AddStmt(S->getCond());
225
11.2k
  Record.AddStmt(S->getConditionVariableDeclStmt());
226
11.2k
  Record.AddStmt(S->getInc());
227
11.2k
  Record.AddStmt(S->getBody());
228
11.2k
  Record.AddSourceLocation(S->getForLoc());
229
11.2k
  Record.AddSourceLocation(S->getLParenLoc());
230
11.2k
  Record.AddSourceLocation(S->getRParenLoc());
231
11.2k
  Code = serialization::STMT_FOR;
232
11.2k
}
233
234
65
void ASTStmtWriter::VisitGotoStmt(GotoStmt *S) {
235
65
  VisitStmt(S);
236
65
  Record.AddDeclRef(S->getLabel());
237
65
  Record.AddSourceLocation(S->getGotoLoc());
238
65
  Record.AddSourceLocation(S->getLabelLoc());
239
65
  Code = serialization::STMT_GOTO;
240
65
}
241
242
2
void ASTStmtWriter::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
243
2
  VisitStmt(S);
244
2
  Record.AddSourceLocation(S->getGotoLoc());
245
2
  Record.AddSourceLocation(S->getStarLoc());
246
2
  Record.AddStmt(S->getTarget());
247
2
  Code = serialization::STMT_INDIRECT_GOTO;
248
2
}
249
250
36
void ASTStmtWriter::VisitContinueStmt(ContinueStmt *S) {
251
36
  VisitStmt(S);
252
36
  Record.AddSourceLocation(S->getContinueLoc());
253
36
  Code = serialization::STMT_CONTINUE;
254
36
}
255
256
832
void ASTStmtWriter::VisitBreakStmt(BreakStmt *S) {
257
832
  VisitStmt(S);
258
832
  Record.AddSourceLocation(S->getBreakLoc());
259
832
  Code = serialization::STMT_BREAK;
260
832
}
261
262
73.2k
void ASTStmtWriter::VisitReturnStmt(ReturnStmt *S) {
263
73.2k
  VisitStmt(S);
264
265
73.2k
  bool HasNRVOCandidate = S->getNRVOCandidate() != nullptr;
266
73.2k
  Record.push_back(HasNRVOCandidate);
267
268
73.2k
  Record.AddStmt(S->getRetValue());
269
73.2k
  if (HasNRVOCandidate)
270
1.14k
    Record.AddDeclRef(S->getNRVOCandidate());
271
272
73.2k
  Record.AddSourceLocation(S->getReturnLoc());
273
73.2k
  Code = serialization::STMT_RETURN;
274
73.2k
}
275
276
49.3k
void ASTStmtWriter::VisitDeclStmt(DeclStmt *S) {
277
49.3k
  VisitStmt(S);
278
49.3k
  Record.AddSourceLocation(S->getBeginLoc());
279
49.3k
  Record.AddSourceLocation(S->getEndLoc());
280
49.3k
  DeclGroupRef DG = S->getDeclGroup();
281
103k
  for (DeclGroupRef::iterator D = DG.begin(), DEnd = DG.end(); D != DEnd; 
++D54.2k
)
282
54.2k
    Record.AddDeclRef(*D);
283
49.3k
  Code = serialization::STMT_DECL;
284
49.3k
}
285
286
74
void ASTStmtWriter::VisitAsmStmt(AsmStmt *S) {
287
74
  VisitStmt(S);
288
74
  Record.push_back(S->getNumOutputs());
289
74
  Record.push_back(S->getNumInputs());
290
74
  Record.push_back(S->getNumClobbers());
291
74
  Record.AddSourceLocation(S->getAsmLoc());
292
74
  Record.push_back(S->isVolatile());
293
74
  Record.push_back(S->isSimple());
294
74
}
295
296
74
void ASTStmtWriter::VisitGCCAsmStmt(GCCAsmStmt *S) {
297
74
  VisitAsmStmt(S);
298
74
  Record.push_back(S->getNumLabels());
299
74
  Record.AddSourceLocation(S->getRParenLoc());
300
74
  Record.AddStmt(S->getAsmString());
301
302
  // Outputs
303
277
  for (unsigned I = 0, N = S->getNumOutputs(); I != N; 
++I203
) {
304
203
    Record.AddIdentifierRef(S->getOutputIdentifier(I));
305
203
    Record.AddStmt(S->getOutputConstraintLiteral(I));
306
203
    Record.AddStmt(S->getOutputExpr(I));
307
203
  }
308
309
  // Inputs
310
230
  for (unsigned I = 0, N = S->getNumInputs(); I != N; 
++I156
) {
311
156
    Record.AddIdentifierRef(S->getInputIdentifier(I));
312
156
    Record.AddStmt(S->getInputConstraintLiteral(I));
313
156
    Record.AddStmt(S->getInputExpr(I));
314
156
  }
315
316
  // Clobbers
317
123
  for (unsigned I = 0, N = S->getNumClobbers(); I != N; 
++I49
)
318
49
    Record.AddStmt(S->getClobberStringLiteral(I));
319
320
  // Labels
321
78
  for (unsigned I = 0, N = S->getNumLabels(); I != N; 
++I4
) {
322
4
    Record.AddIdentifierRef(S->getLabelIdentifier(I));
323
4
    Record.AddStmt(S->getLabelExpr(I));
324
4
  }
325
326
74
  Code = serialization::STMT_GCCASM;
327
74
}
328
329
0
void ASTStmtWriter::VisitMSAsmStmt(MSAsmStmt *S) {
330
0
  VisitAsmStmt(S);
331
0
  Record.AddSourceLocation(S->getLBraceLoc());
332
0
  Record.AddSourceLocation(S->getEndLoc());
333
0
  Record.push_back(S->getNumAsmToks());
334
0
  Record.AddString(S->getAsmString());
335
336
  // Tokens
337
0
  for (unsigned I = 0, N = S->getNumAsmToks(); I != N; ++I) {
338
    // FIXME: Move this to ASTRecordWriter?
339
0
    Writer.AddToken(S->getAsmToks()[I], Record.getRecordData());
340
0
  }
341
342
  // Clobbers
343
0
  for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I) {
344
0
    Record.AddString(S->getClobber(I));
345
0
  }
346
347
  // Outputs
348
0
  for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
349
0
    Record.AddStmt(S->getOutputExpr(I));
350
0
    Record.AddString(S->getOutputConstraint(I));
351
0
  }
352
353
  // Inputs
354
0
  for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
355
0
    Record.AddStmt(S->getInputExpr(I));
356
0
    Record.AddString(S->getInputConstraint(I));
357
0
  }
358
359
0
  Code = serialization::STMT_MSASM;
360
0
}
361
362
4
void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt *CoroStmt) {
363
4
  VisitStmt(CoroStmt);
364
4
  Record.push_back(CoroStmt->getParamMoves().size());
365
4
  for (Stmt *S : CoroStmt->children())
366
49
    Record.AddStmt(S);
367
4
  Code = serialization::STMT_COROUTINE_BODY;
368
4
}
369
370
3
void ASTStmtWriter::VisitCoreturnStmt(CoreturnStmt *S) {
371
3
  VisitStmt(S);
372
3
  Record.AddSourceLocation(S->getKeywordLoc());
373
3
  Record.AddStmt(S->getOperand());
374
3
  Record.AddStmt(S->getPromiseCall());
375
3
  Record.push_back(S->isImplicit());
376
3
  Code = serialization::STMT_CORETURN;
377
3
}
378
379
10
void ASTStmtWriter::VisitCoroutineSuspendExpr(CoroutineSuspendExpr *E) {
380
10
  VisitExpr(E);
381
10
  Record.AddSourceLocation(E->getKeywordLoc());
382
10
  for (Stmt *S : E->children())
383
50
    Record.AddStmt(S);
384
10
  Record.AddStmt(E->getOpaqueValue());
385
10
}
386
387
9
void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr *E) {
388
9
  VisitCoroutineSuspendExpr(E);
389
9
  Record.push_back(E->isImplicit());
390
9
  Code = serialization::EXPR_COAWAIT;
391
9
}
392
393
1
void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr *E) {
394
1
  VisitCoroutineSuspendExpr(E);
395
1
  Code = serialization::EXPR_COYIELD;
396
1
}
397
398
2
void ASTStmtWriter::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
399
2
  VisitExpr(E);
400
2
  Record.AddSourceLocation(E->getKeywordLoc());
401
2
  for (Stmt *S : E->children())
402
4
    Record.AddStmt(S);
403
2
  Code = serialization::EXPR_DEPENDENT_COAWAIT;
404
2
}
405
406
static void
407
addConstraintSatisfaction(ASTRecordWriter &Record,
408
6
                          const ASTConstraintSatisfaction &Satisfaction) {
409
6
  Record.push_back(Satisfaction.IsSatisfied);
410
6
  Record.push_back(Satisfaction.ContainsErrors);
411
6
  if (!Satisfaction.IsSatisfied) {
412
0
    Record.push_back(Satisfaction.NumRecords);
413
0
    for (const auto &DetailRecord : Satisfaction) {
414
0
      Record.AddStmt(const_cast<Expr *>(DetailRecord.first));
415
0
      auto *E = DetailRecord.second.dyn_cast<Expr *>();
416
0
      Record.push_back(E == nullptr);
417
0
      if (E)
418
0
        Record.AddStmt(E);
419
0
      else {
420
0
        auto *Diag = DetailRecord.second.get<std::pair<SourceLocation,
421
0
                                                       StringRef> *>();
422
0
        Record.AddSourceLocation(Diag->first);
423
0
        Record.AddString(Diag->second);
424
0
      }
425
0
    }
426
0
  }
427
6
}
428
429
static void
430
addSubstitutionDiagnostic(
431
    ASTRecordWriter &Record,
432
0
    const concepts::Requirement::SubstitutionDiagnostic *D) {
433
0
  Record.AddString(D->SubstitutedEntity);
434
0
  Record.AddSourceLocation(D->DiagLoc);
435
0
  Record.AddString(D->DiagMessage);
436
0
}
437
438
void ASTStmtWriter::VisitConceptSpecializationExpr(
439
75
        ConceptSpecializationExpr *E) {
440
75
  VisitExpr(E);
441
75
  Record.AddDeclRef(E->getSpecializationDecl());
442
75
  const ConceptReference *CR = E->getConceptReference();
443
75
  Record.push_back(CR != nullptr);
444
75
  if (CR)
445
75
    Record.AddConceptReference(CR);
446
75
  if (!E->isValueDependent())
447
6
    addConstraintSatisfaction(Record, E->getSatisfaction());
448
449
75
  Code = serialization::EXPR_CONCEPT_SPECIALIZATION;
450
75
}
451
452
24
void ASTStmtWriter::VisitRequiresExpr(RequiresExpr *E) {
453
24
  VisitExpr(E);
454
24
  Record.push_back(E->getLocalParameters().size());
455
24
  Record.push_back(E->getRequirements().size());
456
24
  Record.AddSourceLocation(E->RequiresExprBits.RequiresKWLoc);
457
24
  Record.push_back(E->RequiresExprBits.IsSatisfied);
458
24
  Record.AddDeclRef(E->getBody());
459
24
  for (ParmVarDecl *P : E->getLocalParameters())
460
17
    Record.AddDeclRef(P);
461
34
  for (concepts::Requirement *R : E->getRequirements()) {
462
34
    if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(R)) {
463
6
      Record.push_back(concepts::Requirement::RK_Type);
464
6
      Record.push_back(TypeReq->Status);
465
6
      if (TypeReq->Status == concepts::TypeRequirement::SS_SubstitutionFailure)
466
0
        addSubstitutionDiagnostic(Record, TypeReq->getSubstitutionDiagnostic());
467
6
      else
468
6
        Record.AddTypeSourceInfo(TypeReq->getType());
469
28
    } else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(R)) {
470
24
      Record.push_back(ExprReq->getKind());
471
24
      Record.push_back(ExprReq->Status);
472
24
      if (ExprReq->isExprSubstitutionFailure()) {
473
0
        addSubstitutionDiagnostic(Record,
474
0
         ExprReq->Value.get<concepts::Requirement::SubstitutionDiagnostic *>());
475
0
      } else
476
24
        Record.AddStmt(ExprReq->Value.get<Expr *>());
477
24
      if (ExprReq->getKind() == concepts::Requirement::RK_Compound) {
478
5
        Record.AddSourceLocation(ExprReq->NoexceptLoc);
479
5
        const auto &RetReq = ExprReq->getReturnTypeRequirement();
480
5
        if (RetReq.isSubstitutionFailure()) {
481
0
          Record.push_back(2);
482
0
          addSubstitutionDiagnostic(Record, RetReq.getSubstitutionDiagnostic());
483
5
        } else if (RetReq.isTypeConstraint()) {
484
5
          Record.push_back(1);
485
5
          Record.AddTemplateParameterList(
486
5
              RetReq.getTypeConstraintTemplateParameterList());
487
5
          if (ExprReq->Status >=
488
5
              concepts::ExprRequirement::SS_ConstraintsNotSatisfied)
489
0
            Record.AddStmt(
490
0
                ExprReq->getReturnTypeRequirementSubstitutedConstraintExpr());
491
5
        } else {
492
0
          assert(RetReq.isEmpty());
493
0
          Record.push_back(0);
494
0
        }
495
5
      }
496
24
    } else {
497
4
      auto *NestedReq = cast<concepts::NestedRequirement>(R);
498
4
      Record.push_back(concepts::Requirement::RK_Nested);
499
4
      Record.push_back(NestedReq->hasInvalidConstraint());
500
4
      if (NestedReq->hasInvalidConstraint()) {
501
0
        Record.AddString(NestedReq->getInvalidConstraintEntity());
502
0
        addConstraintSatisfaction(Record, *NestedReq->Satisfaction);
503
4
      } else {
504
4
        Record.AddStmt(NestedReq->getConstraintExpr());
505
4
        if (!NestedReq->isDependent())
506
0
          addConstraintSatisfaction(Record, *NestedReq->Satisfaction);
507
4
      }
508
4
    }
509
34
  }
510
24
  Record.AddSourceLocation(E->getLParenLoc());
511
24
  Record.AddSourceLocation(E->getRParenLoc());
512
24
  Record.AddSourceLocation(E->getEndLoc());
513
514
24
  Code = serialization::EXPR_REQUIRES;
515
24
}
516
517
518
37.4k
void ASTStmtWriter::VisitCapturedStmt(CapturedStmt *S) {
519
37.4k
  VisitStmt(S);
520
  // NumCaptures
521
37.4k
  Record.push_back(std::distance(S->capture_begin(), S->capture_end()));
522
523
  // CapturedDecl and captured region kind
524
37.4k
  Record.AddDeclRef(S->getCapturedDecl());
525
37.4k
  Record.push_back(S->getCapturedRegionKind());
526
527
37.4k
  Record.AddDeclRef(S->getCapturedRecordDecl());
528
529
  // Capture inits
530
37.4k
  for (auto *I : S->capture_inits())
531
44.5k
    Record.AddStmt(I);
532
533
  // Body
534
37.4k
  Record.AddStmt(S->getCapturedStmt());
535
536
  // Captures
537
44.5k
  for (const auto &I : S->captures()) {
538
44.5k
    if (I.capturesThis() || 
I.capturesVariableArrayType()40.8k
)
539
7.51k
      Record.AddDeclRef(nullptr);
540
37.0k
    else
541
37.0k
      Record.AddDeclRef(I.getCapturedVar());
542
44.5k
    Record.push_back(I.getCaptureKind());
543
44.5k
    Record.AddSourceLocation(I.getLocation());
544
44.5k
  }
545
546
37.4k
  Code = serialization::STMT_CAPTURED;
547
37.4k
}
548
549
2.58M
void ASTStmtWriter::VisitExpr(Expr *E) {
550
2.58M
  VisitStmt(E);
551
2.58M
  Record.AddTypeRef(E->getType());
552
2.58M
  Record.push_back(E->getDependence());
553
2.58M
  Record.push_back(E->getValueKind());
554
2.58M
  Record.push_back(E->getObjectKind());
555
2.58M
}
556
557
106k
void ASTStmtWriter::VisitConstantExpr(ConstantExpr *E) {
558
106k
  VisitExpr(E);
559
106k
  Record.push_back(E->ConstantExprBits.ResultKind);
560
561
106k
  Record.push_back(E->ConstantExprBits.APValueKind);
562
106k
  Record.push_back(E->ConstantExprBits.IsUnsigned);
563
106k
  Record.push_back(E->ConstantExprBits.BitWidth);
564
  // HasCleanup not serialized since we can just query the APValue.
565
106k
  Record.push_back(E->ConstantExprBits.IsImmediateInvocation);
566
567
106k
  switch (E->ConstantExprBits.ResultKind) {
568
2.26k
  case ConstantExpr::RSK_None:
569
2.26k
    break;
570
103k
  case ConstantExpr::RSK_Int64:
571
103k
    Record.push_back(E->Int64Result());
572
103k
    break;
573
38
  case ConstantExpr::RSK_APValue:
574
38
    Record.AddAPValue(E->APValueResult());
575
38
    break;
576
0
  default:
577
0
    llvm_unreachable("unexpected ResultKind!");
578
106k
  }
579
580
106k
  Record.AddStmt(E->getSubExpr());
581
106k
  Code = serialization::EXPR_CONSTANT;
582
106k
}
583
584
0
void ASTStmtWriter::VisitSYCLUniqueStableNameExpr(SYCLUniqueStableNameExpr *E) {
585
0
  VisitExpr(E);
586
587
0
  Record.AddSourceLocation(E->getLocation());
588
0
  Record.AddSourceLocation(E->getLParenLocation());
589
0
  Record.AddSourceLocation(E->getRParenLocation());
590
0
  Record.AddTypeSourceInfo(E->getTypeSourceInfo());
591
592
0
  Code = serialization::EXPR_SYCL_UNIQUE_STABLE_NAME;
593
0
}
594
595
24
void ASTStmtWriter::VisitPredefinedExpr(PredefinedExpr *E) {
596
24
  VisitExpr(E);
597
598
24
  bool HasFunctionName = E->getFunctionName() != nullptr;
599
24
  Record.push_back(HasFunctionName);
600
24
  Record.push_back(E->getIdentKind()); // FIXME: stable encoding
601
24
  Record.push_back(E->isTransparent());
602
24
  Record.AddSourceLocation(E->getLocation());
603
24
  if (HasFunctionName)
604
16
    Record.AddStmt(E->getFunctionName());
605
24
  Code = serialization::EXPR_PREDEFINED;
606
24
}
607
608
634k
void ASTStmtWriter::VisitDeclRefExpr(DeclRefExpr *E) {
609
634k
  VisitExpr(E);
610
611
634k
  Record.push_back(E->hasQualifier());
612
634k
  Record.push_back(E->getDecl() != E->getFoundDecl());
613
634k
  Record.push_back(E->hasTemplateKWAndArgsInfo());
614
634k
  Record.push_back(E->hadMultipleCandidates());
615
634k
  Record.push_back(E->refersToEnclosingVariableOrCapture());
616
634k
  Record.push_back(E->isNonOdrUse());
617
634k
  Record.push_back(E->isImmediateEscalating());
618
619
634k
  if (E->hasTemplateKWAndArgsInfo()) {
620
2.61k
    unsigned NumTemplateArgs = E->getNumTemplateArgs();
621
2.61k
    Record.push_back(NumTemplateArgs);
622
2.61k
  }
623
624
634k
  DeclarationName::NameKind nk = (E->getDecl()->getDeclName().getNameKind());
625
626
634k
  if ((!E->hasTemplateKWAndArgsInfo()) && 
(!E->hasQualifier())632k
&&
627
634k
      
(E->getDecl() == E->getFoundDecl())618k
&&
628
634k
      
nk == DeclarationName::Identifier617k
&&
629
634k
      
!E->refersToEnclosingVariableOrCapture()615k
&&
!E->isNonOdrUse()548k
&&
630
634k
      
!E->isImmediateEscalating()543k
) {
631
543k
    AbbrevToUse = Writer.getDeclRefExprAbbrev();
632
543k
  }
633
634
634k
  if (E->hasQualifier())
635
14.3k
    Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
636
637
634k
  if (E->getDecl() != E->getFoundDecl())
638
4.16k
    Record.AddDeclRef(E->getFoundDecl());
639
640
634k
  if (E->hasTemplateKWAndArgsInfo())
641
2.61k
    AddTemplateKWAndArgsInfo(*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
642
2.61k
                             E->getTrailingObjects<TemplateArgumentLoc>());
643
644
634k
  Record.AddDeclRef(E->getDecl());
645
634k
  Record.AddSourceLocation(E->getLocation());
646
634k
  Record.AddDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName());
647
634k
  Code = serialization::EXPR_DECL_REF;
648
634k
}
649
650
266k
void ASTStmtWriter::VisitIntegerLiteral(IntegerLiteral *E) {
651
266k
  VisitExpr(E);
652
266k
  Record.AddSourceLocation(E->getLocation());
653
266k
  Record.AddAPInt(E->getValue());
654
655
266k
  if (E->getValue().getBitWidth() == 32) {
656
260k
    AbbrevToUse = Writer.getIntegerLiteralAbbrev();
657
260k
  }
658
659
266k
  Code = serialization::EXPR_INTEGER_LITERAL;
660
266k
}
661
662
56
void ASTStmtWriter::VisitFixedPointLiteral(FixedPointLiteral *E) {
663
56
  VisitExpr(E);
664
56
  Record.AddSourceLocation(E->getLocation());
665
56
  Record.push_back(E->getScale());
666
56
  Record.AddAPInt(E->getValue());
667
56
  Code = serialization::EXPR_FIXEDPOINT_LITERAL;
668
56
}
669
670
2.95k
void ASTStmtWriter::VisitFloatingLiteral(FloatingLiteral *E) {
671
2.95k
  VisitExpr(E);
672
2.95k
  Record.push_back(E->getRawSemantics());
673
2.95k
  Record.push_back(E->isExact());
674
2.95k
  Record.AddAPFloat(E->getValue());
675
2.95k
  Record.AddSourceLocation(E->getLocation());
676
2.95k
  Code = serialization::EXPR_FLOATING_LITERAL;
677
2.95k
}
678
679
5
void ASTStmtWriter::VisitImaginaryLiteral(ImaginaryLiteral *E) {
680
5
  VisitExpr(E);
681
5
  Record.AddStmt(E->getSubExpr());
682
5
  Code = serialization::EXPR_IMAGINARY_LITERAL;
683
5
}
684
685
2.36k
void ASTStmtWriter::VisitStringLiteral(StringLiteral *E) {
686
2.36k
  VisitExpr(E);
687
688
  // Store the various bits of data of StringLiteral.
689
2.36k
  Record.push_back(E->getNumConcatenated());
690
2.36k
  Record.push_back(E->getLength());
691
2.36k
  Record.push_back(E->getCharByteWidth());
692
2.36k
  Record.push_back(E->getKind());
693
2.36k
  Record.push_back(E->isPascal());
694
695
  // Store the trailing array of SourceLocation.
696
4.95k
  for (unsigned I = 0, N = E->getNumConcatenated(); I != N; 
++I2.59k
)
697
2.59k
    Record.AddSourceLocation(E->getStrTokenLoc(I));
698
699
  // Store the trailing array of char holding the string data.
700
2.36k
  StringRef StrData = E->getBytes();
701
76.3k
  for (unsigned I = 0, N = E->getByteLength(); I != N; 
++I73.9k
)
702
73.9k
    Record.push_back(StrData[I]);
703
704
2.36k
  Code = serialization::EXPR_STRING_LITERAL;
705
2.36k
}
706
707
8.71k
void ASTStmtWriter::VisitCharacterLiteral(CharacterLiteral *E) {
708
8.71k
  VisitExpr(E);
709
8.71k
  Record.push_back(E->getValue());
710
8.71k
  Record.AddSourceLocation(E->getLocation());
711
8.71k
  Record.push_back(E->getKind());
712
713
8.71k
  AbbrevToUse = Writer.getCharacterLiteralAbbrev();
714
715
8.71k
  Code = serialization::EXPR_CHARACTER_LITERAL;
716
8.71k
}
717
718
67.6k
void ASTStmtWriter::VisitParenExpr(ParenExpr *E) {
719
67.6k
  VisitExpr(E);
720
67.6k
  Record.AddSourceLocation(E->getLParen());
721
67.6k
  Record.AddSourceLocation(E->getRParen());
722
67.6k
  Record.AddStmt(E->getSubExpr());
723
67.6k
  Code = serialization::EXPR_PAREN;
724
67.6k
}
725
726
6.41k
void ASTStmtWriter::VisitParenListExpr(ParenListExpr *E) {
727
6.41k
  VisitExpr(E);
728
6.41k
  Record.push_back(E->getNumExprs());
729
6.41k
  for (auto *SubStmt : E->exprs())
730
7.95k
    Record.AddStmt(SubStmt);
731
6.41k
  Record.AddSourceLocation(E->getLParenLoc());
732
6.41k
  Record.AddSourceLocation(E->getRParenLoc());
733
6.41k
  Code = serialization::EXPR_PAREN_LIST;
734
6.41k
}
735
736
60.8k
void ASTStmtWriter::VisitUnaryOperator(UnaryOperator *E) {
737
60.8k
  VisitExpr(E);
738
60.8k
  bool HasFPFeatures = E->hasStoredFPFeatures();
739
  // Write this first for easy access when deserializing, as they affect the
740
  // size of the UnaryOperator.
741
60.8k
  Record.push_back(HasFPFeatures);
742
60.8k
  Record.AddStmt(E->getSubExpr());
743
60.8k
  Record.push_back(E->getOpcode()); // FIXME: stable encoding
744
60.8k
  Record.AddSourceLocation(E->getOperatorLoc());
745
60.8k
  Record.push_back(E->canOverflow());
746
60.8k
  if (HasFPFeatures)
747
4
    Record.push_back(E->getStoredFPFeatures().getAsOpaqueInt());
748
60.8k
  Code = serialization::EXPR_UNARY_OPERATOR;
749
60.8k
}
750
751
8
void ASTStmtWriter::VisitOffsetOfExpr(OffsetOfExpr *E) {
752
8
  VisitExpr(E);
753
8
  Record.push_back(E->getNumComponents());
754
8
  Record.push_back(E->getNumExpressions());
755
8
  Record.AddSourceLocation(E->getOperatorLoc());
756
8
  Record.AddSourceLocation(E->getRParenLoc());
757
8
  Record.AddTypeSourceInfo(E->getTypeSourceInfo());
758
22
  for (unsigned I = 0, N = E->getNumComponents(); I != N; 
++I14
) {
759
14
    const OffsetOfNode &ON = E->getComponent(I);
760
14
    Record.push_back(ON.getKind()); // FIXME: Stable encoding
761
14
    Record.AddSourceLocation(ON.getSourceRange().getBegin());
762
14
    Record.AddSourceLocation(ON.getSourceRange().getEnd());
763
14
    switch (ON.getKind()) {
764
2
    case OffsetOfNode::Array:
765
2
      Record.push_back(ON.getArrayExprIndex());
766
2
      break;
767
768
10
    case OffsetOfNode::Field:
769
10
      Record.AddDeclRef(ON.getField());
770
10
      break;
771
772
1
    case OffsetOfNode::Identifier:
773
1
      Record.AddIdentifierRef(ON.getFieldName());
774
1
      break;
775
776
1
    case OffsetOfNode::Base:
777
1
      Record.AddCXXBaseSpecifier(*ON.getBase());
778
1
      break;
779
14
    }
780
14
  }
781
10
  
for (unsigned I = 0, N = E->getNumExpressions(); 8
I != N;
++I2
)
782
2
    Record.AddStmt(E->getIndexExpr(I));
783
8
  Code = serialization::EXPR_OFFSETOF;
784
8
}
785
786
3.27k
void ASTStmtWriter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
787
3.27k
  VisitExpr(E);
788
3.27k
  Record.push_back(E->getKind());
789
3.27k
  if (E->isArgumentType())
790
2.97k
    Record.AddTypeSourceInfo(E->getArgumentTypeInfo());
791
305
  else {
792
305
    Record.push_back(0);
793
305
    Record.AddStmt(E->getArgumentExpr());
794
305
  }
795
3.27k
  Record.AddSourceLocation(E->getOperatorLoc());
796
3.27k
  Record.AddSourceLocation(E->getRParenLoc());
797
3.27k
  Code = serialization::EXPR_SIZEOF_ALIGN_OF;
798
3.27k
}
799
800
12.4k
void ASTStmtWriter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
801
12.4k
  VisitExpr(E);
802
12.4k
  Record.AddStmt(E->getLHS());
803
12.4k
  Record.AddStmt(E->getRHS());
804
12.4k
  Record.AddSourceLocation(E->getRBracketLoc());
805
12.4k
  Code = serialization::EXPR_ARRAY_SUBSCRIPT;
806
12.4k
}
807
808
0
void ASTStmtWriter::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
809
0
  VisitExpr(E);
810
0
  Record.AddStmt(E->getBase());
811
0
  Record.AddStmt(E->getRowIdx());
812
0
  Record.AddStmt(E->getColumnIdx());
813
0
  Record.AddSourceLocation(E->getRBracketLoc());
814
0
  Code = serialization::EXPR_ARRAY_SUBSCRIPT;
815
0
}
816
817
2.65k
void ASTStmtWriter::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
818
2.65k
  VisitExpr(E);
819
2.65k
  Record.AddStmt(E->getBase());
820
2.65k
  Record.AddStmt(E->getLowerBound());
821
2.65k
  Record.AddStmt(E->getLength());
822
2.65k
  Record.AddStmt(E->getStride());
823
2.65k
  Record.AddSourceLocation(E->getColonLocFirst());
824
2.65k
  Record.AddSourceLocation(E->getColonLocSecond());
825
2.65k
  Record.AddSourceLocation(E->getRBracketLoc());
826
2.65k
  Code = serialization::EXPR_OMP_ARRAY_SECTION;
827
2.65k
}
828
829
44
void ASTStmtWriter::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *E) {
830
44
  VisitExpr(E);
831
44
  Record.push_back(E->getDimensions().size());
832
44
  Record.AddStmt(E->getBase());
833
44
  for (Expr *Dim : E->getDimensions())
834
108
    Record.AddStmt(Dim);
835
44
  for (SourceRange SR : E->getBracketsRanges())
836
108
    Record.AddSourceRange(SR);
837
44
  Record.AddSourceLocation(E->getLParenLoc());
838
44
  Record.AddSourceLocation(E->getRParenLoc());
839
44
  Code = serialization::EXPR_OMP_ARRAY_SHAPING;
840
44
}
841
842
26
void ASTStmtWriter::VisitOMPIteratorExpr(OMPIteratorExpr *E) {
843
26
  VisitExpr(E);
844
26
  Record.push_back(E->numOfIterators());
845
26
  Record.AddSourceLocation(E->getIteratorKwLoc());
846
26
  Record.AddSourceLocation(E->getLParenLoc());
847
26
  Record.AddSourceLocation(E->getRParenLoc());
848
58
  for (unsigned I = 0, End = E->numOfIterators(); I < End; 
++I32
) {
849
32
    Record.AddDeclRef(E->getIteratorDecl(I));
850
32
    Record.AddSourceLocation(E->getAssignLoc(I));
851
32
    OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
852
32
    Record.AddStmt(Range.Begin);
853
32
    Record.AddStmt(Range.End);
854
32
    Record.AddStmt(Range.Step);
855
32
    Record.AddSourceLocation(E->getColonLoc(I));
856
32
    if (Range.Step)
857
20
      Record.AddSourceLocation(E->getSecondColonLoc(I));
858
    // Serialize helpers
859
32
    OMPIteratorHelperData &HD = E->getHelper(I);
860
32
    Record.AddDeclRef(HD.CounterVD);
861
32
    Record.AddStmt(HD.Upper);
862
32
    Record.AddStmt(HD.Update);
863
32
    Record.AddStmt(HD.CounterUpdate);
864
32
  }
865
26
  Code = serialization::EXPR_OMP_ITERATOR;
866
26
}
867
868
144k
void ASTStmtWriter::VisitCallExpr(CallExpr *E) {
869
144k
  VisitExpr(E);
870
144k
  Record.push_back(E->getNumArgs());
871
144k
  Record.push_back(E->hasStoredFPFeatures());
872
144k
  Record.AddSourceLocation(E->getRParenLoc());
873
144k
  Record.AddStmt(E->getCallee());
874
144k
  for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
875
369k
       Arg != ArgEnd; 
++Arg225k
)
876
225k
    Record.AddStmt(*Arg);
877
144k
  Record.push_back(static_cast<unsigned>(E->getADLCallKind()));
878
144k
  if (E->hasStoredFPFeatures())
879
7
    Record.push_back(E->getFPFeatures().getAsOpaqueInt());
880
144k
  Code = serialization::EXPR_CALL;
881
144k
}
882
883
1
void ASTStmtWriter::VisitRecoveryExpr(RecoveryExpr *E) {
884
1
  VisitExpr(E);
885
1
  Record.push_back(std::distance(E->children().begin(), E->children().end()));
886
1
  Record.AddSourceLocation(E->getBeginLoc());
887
1
  Record.AddSourceLocation(E->getEndLoc());
888
1
  for (Stmt *Child : E->children())
889
1
    Record.AddStmt(Child);
890
1
  Code = serialization::EXPR_RECOVERY;
891
1
}
892
893
37.1k
void ASTStmtWriter::VisitMemberExpr(MemberExpr *E) {
894
37.1k
  VisitExpr(E);
895
896
37.1k
  bool HasQualifier = E->hasQualifier();
897
37.1k
  bool HasFoundDecl =
898
37.1k
      E->hasQualifierOrFoundDecl() &&
899
37.1k
      
(1.03k
E->getFoundDecl().getDecl() != E->getMemberDecl()1.03k
||
900
1.03k
       
E->getFoundDecl().getAccess() != E->getMemberDecl()->getAccess()743
);
901
37.1k
  bool HasTemplateInfo = E->hasTemplateKWAndArgsInfo();
902
37.1k
  unsigned NumTemplateArgs = E->getNumTemplateArgs();
903
904
  // Write these first for easy access when deserializing, as they affect the
905
  // size of the MemberExpr.
906
37.1k
  Record.push_back(HasQualifier);
907
37.1k
  Record.push_back(HasFoundDecl);
908
37.1k
  Record.push_back(HasTemplateInfo);
909
37.1k
  Record.push_back(NumTemplateArgs);
910
911
37.1k
  Record.AddStmt(E->getBase());
912
37.1k
  Record.AddDeclRef(E->getMemberDecl());
913
37.1k
  Record.AddDeclarationNameLoc(E->MemberDNLoc,
914
37.1k
                               E->getMemberDecl()->getDeclName());
915
37.1k
  Record.AddSourceLocation(E->getMemberLoc());
916
37.1k
  Record.push_back(E->isArrow());
917
37.1k
  Record.push_back(E->hadMultipleCandidates());
918
37.1k
  Record.push_back(E->isNonOdrUse());
919
37.1k
  Record.AddSourceLocation(E->getOperatorLoc());
920
921
37.1k
  if (HasFoundDecl) {
922
730
    DeclAccessPair FoundDecl = E->getFoundDecl();
923
730
    Record.AddDeclRef(FoundDecl.getDecl());
924
730
    Record.push_back(FoundDecl.getAccess());
925
730
  }
926
927
37.1k
  if (HasQualifier)
928
307
    Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
929
930
37.1k
  if (HasTemplateInfo)
931
41
    AddTemplateKWAndArgsInfo(*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
932
41
                             E->getTrailingObjects<TemplateArgumentLoc>());
933
934
37.1k
  Code = serialization::EXPR_MEMBER;
935
37.1k
}
936
937
0
void ASTStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr *E) {
938
0
  VisitExpr(E);
939
0
  Record.AddStmt(E->getBase());
940
0
  Record.AddSourceLocation(E->getIsaMemberLoc());
941
0
  Record.AddSourceLocation(E->getOpLoc());
942
0
  Record.push_back(E->isArrow());
943
0
  Code = serialization::EXPR_OBJC_ISA;
944
0
}
945
946
void ASTStmtWriter::
947
0
VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
948
0
  VisitExpr(E);
949
0
  Record.AddStmt(E->getSubExpr());
950
0
  Record.push_back(E->shouldCopy());
951
0
  Code = serialization::EXPR_OBJC_INDIRECT_COPY_RESTORE;
952
0
}
953
954
7
void ASTStmtWriter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
955
7
  VisitExplicitCastExpr(E);
956
7
  Record.AddSourceLocation(E->getLParenLoc());
957
7
  Record.AddSourceLocation(E->getBridgeKeywordLoc());
958
7
  Record.push_back(E->getBridgeKind()); // FIXME: Stable encoding
959
7
  Code = serialization::EXPR_OBJC_BRIDGED_CAST;
960
7
}
961
962
707k
void ASTStmtWriter::VisitCastExpr(CastExpr *E) {
963
707k
  VisitExpr(E);
964
707k
  Record.push_back(E->path_size());
965
707k
  Record.push_back(E->hasStoredFPFeatures());
966
707k
  Record.AddStmt(E->getSubExpr());
967
707k
  Record.push_back(E->getCastKind()); // FIXME: stable encoding
968
969
707k
  for (CastExpr::path_iterator
970
709k
         PI = E->path_begin(), PE = E->path_end(); PI != PE; 
++PI1.93k
)
971
1.93k
    Record.AddCXXBaseSpecifier(**PI);
972
973
707k
  if (E->hasStoredFPFeatures())
974
56
    Record.push_back(E->getFPFeatures().getAsOpaqueInt());
975
707k
}
976
977
295k
void ASTStmtWriter::VisitBinaryOperator(BinaryOperator *E) {
978
295k
  VisitExpr(E);
979
295k
  bool HasFPFeatures = E->hasStoredFPFeatures();
980
  // Write this first for easy access when deserializing, as they affect the
981
  // size of the UnaryOperator.
982
295k
  Record.push_back(HasFPFeatures);
983
295k
  Record.push_back(E->getOpcode()); // FIXME: stable encoding
984
295k
  Record.AddStmt(E->getLHS());
985
295k
  Record.AddStmt(E->getRHS());
986
295k
  Record.AddSourceLocation(E->getOperatorLoc());
987
295k
  if (HasFPFeatures)
988
18
    Record.push_back(E->getStoredFPFeatures().getAsOpaqueInt());
989
295k
  Code = serialization::EXPR_BINARY_OPERATOR;
990
295k
}
991
992
10.3k
void ASTStmtWriter::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
993
10.3k
  VisitBinaryOperator(E);
994
10.3k
  Record.AddTypeRef(E->getComputationLHSType());
995
10.3k
  Record.AddTypeRef(E->getComputationResultType());
996
10.3k
  Code = serialization::EXPR_COMPOUND_ASSIGN_OPERATOR;
997
10.3k
}
998
999
11.4k
void ASTStmtWriter::VisitConditionalOperator(ConditionalOperator *E) {
1000
11.4k
  VisitExpr(E);
1001
11.4k
  Record.AddStmt(E->getCond());
1002
11.4k
  Record.AddStmt(E->getLHS());
1003
11.4k
  Record.AddStmt(E->getRHS());
1004
11.4k
  Record.AddSourceLocation(E->getQuestionLoc());
1005
11.4k
  Record.AddSourceLocation(E->getColonLoc());
1006
11.4k
  Code = serialization::EXPR_CONDITIONAL_OPERATOR;
1007
11.4k
}
1008
1009
void
1010
3
ASTStmtWriter::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
1011
3
  VisitExpr(E);
1012
3
  Record.AddStmt(E->getOpaqueValue());
1013
3
  Record.AddStmt(E->getCommon());
1014
3
  Record.AddStmt(E->getCond());
1015
3
  Record.AddStmt(E->getTrueExpr());
1016
3
  Record.AddStmt(E->getFalseExpr());
1017
3
  Record.AddSourceLocation(E->getQuestionLoc());
1018
3
  Record.AddSourceLocation(E->getColonLoc());
1019
3
  Code = serialization::EXPR_BINARY_CONDITIONAL_OPERATOR;
1020
3
}
1021
1022
558k
void ASTStmtWriter::VisitImplicitCastExpr(ImplicitCastExpr *E) {
1023
558k
  VisitCastExpr(E);
1024
558k
  Record.push_back(E->isPartOfExplicitCast());
1025
1026
558k
  if (E->path_size() == 0 && 
!E->hasStoredFPFeatures()556k
)
1027
556k
    AbbrevToUse = Writer.getExprImplicitCastAbbrev();
1028
1029
558k
  Code = serialization::EXPR_IMPLICIT_CAST;
1030
558k
}
1031
1032
149k
void ASTStmtWriter::VisitExplicitCastExpr(ExplicitCastExpr *E) {
1033
149k
  VisitCastExpr(E);
1034
149k
  Record.AddTypeSourceInfo(E->getTypeInfoAsWritten());
1035
149k
}
1036
1037
144k
void ASTStmtWriter::VisitCStyleCastExpr(CStyleCastExpr *E) {
1038
144k
  VisitExplicitCastExpr(E);
1039
144k
  Record.AddSourceLocation(E->getLParenLoc());
1040
144k
  Record.AddSourceLocation(E->getRParenLoc());
1041
144k
  Code = serialization::EXPR_CSTYLE_CAST;
1042
144k
}
1043
1044
987
void ASTStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
1045
987
  VisitExpr(E);
1046
987
  Record.AddSourceLocation(E->getLParenLoc());
1047
987
  Record.AddTypeSourceInfo(E->getTypeSourceInfo());
1048
987
  Record.AddStmt(E->getInitializer());
1049
987
  Record.push_back(E->isFileScope());
1050
987
  Code = serialization::EXPR_COMPOUND_LITERAL;
1051
987
}
1052
1053
21
void ASTStmtWriter::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
1054
21
  VisitExpr(E);
1055
21
  Record.AddStmt(E->getBase());
1056
21
  Record.AddIdentifierRef(&E->getAccessor());
1057
21
  Record.AddSourceLocation(E->getAccessorLoc());
1058
21
  Code = serialization::EXPR_EXT_VECTOR_ELEMENT;
1059
21
}
1060
1061
5.68k
void ASTStmtWriter::VisitInitListExpr(InitListExpr *E) {
1062
5.68k
  VisitExpr(E);
1063
  // NOTE: only add the (possibly null) syntactic form.
1064
  // No need to serialize the isSemanticForm flag and the semantic form.
1065
5.68k
  Record.AddStmt(E->getSyntacticForm());
1066
5.68k
  Record.AddSourceLocation(E->getLBraceLoc());
1067
5.68k
  Record.AddSourceLocation(E->getRBraceLoc());
1068
5.68k
  bool isArrayFiller = E->ArrayFillerOrUnionFieldInit.is<Expr*>();
1069
5.68k
  Record.push_back(isArrayFiller);
1070
5.68k
  if (isArrayFiller)
1071
5.64k
    Record.AddStmt(E->getArrayFiller());
1072
39
  else
1073
39
    Record.AddDeclRef(E->getInitializedFieldInUnion());
1074
5.68k
  Record.push_back(E->hadArrayRangeDesignator());
1075
5.68k
  Record.push_back(E->getNumInits());
1076
5.68k
  if (isArrayFiller) {
1077
    // ArrayFiller may have filled "holes" due to designated initializer.
1078
    // Replace them by 0 to indicate that the filler goes in that place.
1079
5.64k
    Expr *filler = E->getArrayFiller();
1080
30.2k
    for (unsigned I = 0, N = E->getNumInits(); I != N; 
++I24.5k
)
1081
24.5k
      Record.AddStmt(E->getInit(I) != filler ? 
E->getInit(I)24.5k
:
nullptr6
);
1082
5.64k
  } else {
1083
73
    for (unsigned I = 0, N = E->getNumInits(); I != N; 
++I34
)
1084
34
      Record.AddStmt(E->getInit(I));
1085
39
  }
1086
5.68k
  Code = serialization::EXPR_INIT_LIST;
1087
5.68k
}
1088
1089
71
void ASTStmtWriter::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
1090
71
  VisitExpr(E);
1091
71
  Record.push_back(E->getNumSubExprs());
1092
168
  for (unsigned I = 0, N = E->getNumSubExprs(); I != N; 
++I97
)
1093
97
    Record.AddStmt(E->getSubExpr(I));
1094
71
  Record.AddSourceLocation(E->getEqualOrColonLoc());
1095
71
  Record.push_back(E->usesGNUSyntax());
1096
82
  for (const DesignatedInitExpr::Designator &D : E->designators()) {
1097
82
    if (D.isFieldDesignator()) {
1098
56
      if (FieldDecl *Field = D.getFieldDecl()) {
1099
56
        Record.push_back(serialization::DESIG_FIELD_DECL);
1100
56
        Record.AddDeclRef(Field);
1101
56
      } else {
1102
0
        Record.push_back(serialization::DESIG_FIELD_NAME);
1103
0
        Record.AddIdentifierRef(D.getFieldName());
1104
0
      }
1105
56
      Record.AddSourceLocation(D.getDotLoc());
1106
56
      Record.AddSourceLocation(D.getFieldLoc());
1107
56
    } else 
if (26
D.isArrayDesignator()26
) {
1108
26
      Record.push_back(serialization::DESIG_ARRAY);
1109
26
      Record.push_back(D.getArrayIndex());
1110
26
      Record.AddSourceLocation(D.getLBracketLoc());
1111
26
      Record.AddSourceLocation(D.getRBracketLoc());
1112
26
    } else {
1113
0
      assert(D.isArrayRangeDesignator() && "Unknown designator");
1114
0
      Record.push_back(serialization::DESIG_ARRAY_RANGE);
1115
0
      Record.push_back(D.getArrayIndex());
1116
0
      Record.AddSourceLocation(D.getLBracketLoc());
1117
0
      Record.AddSourceLocation(D.getEllipsisLoc());
1118
0
      Record.AddSourceLocation(D.getRBracketLoc());
1119
0
    }
1120
82
  }
1121
71
  Code = serialization::EXPR_DESIGNATED_INIT;
1122
71
}
1123
1124
2
void ASTStmtWriter::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1125
2
  VisitExpr(E);
1126
2
  Record.AddStmt(E->getBase());
1127
2
  Record.AddStmt(E->getUpdater());
1128
2
  Code = serialization::EXPR_DESIGNATED_INIT_UPDATE;
1129
2
}
1130
1131
2
void ASTStmtWriter::VisitNoInitExpr(NoInitExpr *E) {
1132
2
  VisitExpr(E);
1133
2
  Code = serialization::EXPR_NO_INIT;
1134
2
}
1135
1136
13
void ASTStmtWriter::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1137
13
  VisitExpr(E);
1138
13
  Record.AddStmt(E->SubExprs[0]);
1139
13
  Record.AddStmt(E->SubExprs[1]);
1140
13
  Code = serialization::EXPR_ARRAY_INIT_LOOP;
1141
13
}
1142
1143
13
void ASTStmtWriter::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1144
13
  VisitExpr(E);
1145
13
  Code = serialization::EXPR_ARRAY_INIT_INDEX;
1146
13
}
1147
1148
179
void ASTStmtWriter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
1149
179
  VisitExpr(E);
1150
179
  Code = serialization::EXPR_IMPLICIT_VALUE_INIT;
1151
179
}
1152
1153
2
void ASTStmtWriter::VisitVAArgExpr(VAArgExpr *E) {
1154
2
  VisitExpr(E);
1155
2
  Record.AddStmt(E->getSubExpr());
1156
2
  Record.AddTypeSourceInfo(E->getWrittenTypeInfo());
1157
2
  Record.AddSourceLocation(E->getBuiltinLoc());
1158
2
  Record.AddSourceLocation(E->getRParenLoc());
1159
2
  Record.push_back(E->isMicrosoftABI());
1160
2
  Code = serialization::EXPR_VA_ARG;
1161
2
}
1162
1163
0
void ASTStmtWriter::VisitSourceLocExpr(SourceLocExpr *E) {
1164
0
  VisitExpr(E);
1165
0
  Record.AddDeclRef(cast_or_null<Decl>(E->getParentContext()));
1166
0
  Record.AddSourceLocation(E->getBeginLoc());
1167
0
  Record.AddSourceLocation(E->getEndLoc());
1168
0
  Record.push_back(E->getIdentKind());
1169
0
  Code = serialization::EXPR_SOURCE_LOC;
1170
0
}
1171
1172
7
void ASTStmtWriter::VisitAddrLabelExpr(AddrLabelExpr *E) {
1173
7
  VisitExpr(E);
1174
7
  Record.AddSourceLocation(E->getAmpAmpLoc());
1175
7
  Record.AddSourceLocation(E->getLabelLoc());
1176
7
  Record.AddDeclRef(E->getLabel());
1177
7
  Code = serialization::EXPR_ADDR_LABEL;
1178
7
}
1179
1180
41
void ASTStmtWriter::VisitStmtExpr(StmtExpr *E) {
1181
41
  VisitExpr(E);
1182
41
  Record.AddStmt(E->getSubStmt());
1183
41
  Record.AddSourceLocation(E->getLParenLoc());
1184
41
  Record.AddSourceLocation(E->getRParenLoc());
1185
41
  Record.push_back(E->getTemplateDepth());
1186
41
  Code = serialization::EXPR_STMT;
1187
41
}
1188
1189
3
void ASTStmtWriter::VisitChooseExpr(ChooseExpr *E) {
1190
3
  VisitExpr(E);
1191
3
  Record.AddStmt(E->getCond());
1192
3
  Record.AddStmt(E->getLHS());
1193
3
  Record.AddStmt(E->getRHS());
1194
3
  Record.AddSourceLocation(E->getBuiltinLoc());
1195
3
  Record.AddSourceLocation(E->getRParenLoc());
1196
3
  Record.push_back(E->isConditionDependent() ? 
false0
: E->isConditionTrue());
1197
3
  Code = serialization::EXPR_CHOOSE;
1198
3
}
1199
1200
9
void ASTStmtWriter::VisitGNUNullExpr(GNUNullExpr *E) {
1201
9
  VisitExpr(E);
1202
9
  Record.AddSourceLocation(E->getTokenLocation());
1203
9
  Code = serialization::EXPR_GNU_NULL;
1204
9
}
1205
1206
1.91k
void ASTStmtWriter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
1207
1.91k
  VisitExpr(E);
1208
1.91k
  Record.push_back(E->getNumSubExprs());
1209
22.8k
  for (unsigned I = 0, N = E->getNumSubExprs(); I != N; 
++I20.9k
)
1210
20.9k
    Record.AddStmt(E->getExpr(I));
1211
1.91k
  Record.AddSourceLocation(E->getBuiltinLoc());
1212
1.91k
  Record.AddSourceLocation(E->getRParenLoc());
1213
1.91k
  Code = serialization::EXPR_SHUFFLE_VECTOR;
1214
1.91k
}
1215
1216
676
void ASTStmtWriter::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1217
676
  VisitExpr(E);
1218
676
  Record.AddSourceLocation(E->getBuiltinLoc());
1219
676
  Record.AddSourceLocation(E->getRParenLoc());
1220
676
  Record.AddTypeSourceInfo(E->getTypeSourceInfo());
1221
676
  Record.AddStmt(E->getSrcExpr());
1222
676
  Code = serialization::EXPR_CONVERT_VECTOR;
1223
676
}
1224
1225
22
void ASTStmtWriter::VisitBlockExpr(BlockExpr *E) {
1226
22
  VisitExpr(E);
1227
22
  Record.AddDeclRef(E->getBlockDecl());
1228
22
  Code = serialization::EXPR_BLOCK;
1229
22
}
1230
1231
9
void ASTStmtWriter::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1232
9
  VisitExpr(E);
1233
1234
9
  Record.push_back(E->getNumAssocs());
1235
9
  Record.push_back(E->isExprPredicate());
1236
9
  Record.push_back(E->ResultIndex);
1237
9
  Record.AddSourceLocation(E->getGenericLoc());
1238
9
  Record.AddSourceLocation(E->getDefaultLoc());
1239
9
  Record.AddSourceLocation(E->getRParenLoc());
1240
1241
9
  Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1242
  // Add 1 to account for the controlling expression which is the first
1243
  // expression in the trailing array of Stmt *. This is not needed for
1244
  // the trailing array of TypeSourceInfo *.
1245
36
  for (unsigned I = 0, N = E->getNumAssocs() + 1; I < N; 
++I27
)
1246
27
    Record.AddStmt(Stmts[I]);
1247
1248
9
  TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1249
27
  for (unsigned I = 0, N = E->getNumAssocs(); I < N; 
++I18
)
1250
18
    Record.AddTypeSourceInfo(TSIs[I]);
1251
1252
9
  Code = serialization::EXPR_GENERIC_SELECTION;
1253
9
}
1254
1255
295
void ASTStmtWriter::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1256
295
  VisitExpr(E);
1257
295
  Record.push_back(E->getNumSemanticExprs());
1258
1259
  // Push the result index.  Currently, this needs to exactly match
1260
  // the encoding used internally for ResultIndex.
1261
295
  unsigned result = E->getResultExprIndex();
1262
295
  result = (result == PseudoObjectExpr::NoResult ? 
07
:
result + 1288
);
1263
295
  Record.push_back(result);
1264
1265
295
  Record.AddStmt(E->getSyntacticForm());
1266
295
  for (PseudoObjectExpr::semantics_iterator
1267
736
         i = E->semantics_begin(), e = E->semantics_end(); i != e; 
++i441
) {
1268
441
    Record.AddStmt(*i);
1269
441
  }
1270
295
  Code = serialization::EXPR_PSEUDO_OBJECT;
1271
295
}
1272
1273
173
void ASTStmtWriter::VisitAtomicExpr(AtomicExpr *E) {
1274
173
  VisitExpr(E);
1275
173
  Record.push_back(E->getOp());
1276
765
  for (unsigned I = 0, N = E->getNumSubExprs(); I != N; 
++I592
)
1277
592
    Record.AddStmt(E->getSubExprs()[I]);
1278
173
  Record.AddSourceLocation(E->getBuiltinLoc());
1279
173
  Record.AddSourceLocation(E->getRParenLoc());
1280
173
  Code = serialization::EXPR_ATOMIC;
1281
173
}
1282
1283
//===----------------------------------------------------------------------===//
1284
// Objective-C Expressions and Statements.
1285
//===----------------------------------------------------------------------===//
1286
1287
7
void ASTStmtWriter::VisitObjCStringLiteral(ObjCStringLiteral *E) {
1288
7
  VisitExpr(E);
1289
7
  Record.AddStmt(E->getString());
1290
7
  Record.AddSourceLocation(E->getAtLoc());
1291
7
  Code = serialization::EXPR_OBJC_STRING_LITERAL;
1292
7
}
1293
1294
11
void ASTStmtWriter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
1295
11
  VisitExpr(E);
1296
11
  Record.AddStmt(E->getSubExpr());
1297
11
  Record.AddDeclRef(E->getBoxingMethod());
1298
11
  Record.AddSourceRange(E->getSourceRange());
1299
11
  Code = serialization::EXPR_OBJC_BOXED_EXPRESSION;
1300
11
}
1301
1302
2
void ASTStmtWriter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1303
2
  VisitExpr(E);
1304
2
  Record.push_back(E->getNumElements());
1305
6
  for (unsigned i = 0; i < E->getNumElements(); 
i++4
)
1306
4
    Record.AddStmt(E->getElement(i));
1307
2
  Record.AddDeclRef(E->getArrayWithObjectsMethod());
1308
2
  Record.AddSourceRange(E->getSourceRange());
1309
2
  Code = serialization::EXPR_OBJC_ARRAY_LITERAL;
1310
2
}
1311
1312
3
void ASTStmtWriter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1313
3
  VisitExpr(E);
1314
3
  Record.push_back(E->getNumElements());
1315
3
  Record.push_back(E->HasPackExpansions);
1316
8
  for (unsigned i = 0; i < E->getNumElements(); 
i++5
) {
1317
5
    ObjCDictionaryElement Element = E->getKeyValueElement(i);
1318
5
    Record.AddStmt(Element.Key);
1319
5
    Record.AddStmt(Element.Value);
1320
5
    if (E->HasPackExpansions) {
1321
1
      Record.AddSourceLocation(Element.EllipsisLoc);
1322
1
      unsigned NumExpansions = 0;
1323
1
      if (Element.NumExpansions)
1324
0
        NumExpansions = *Element.NumExpansions + 1;
1325
1
      Record.push_back(NumExpansions);
1326
1
    }
1327
5
  }
1328
1329
3
  Record.AddDeclRef(E->getDictWithObjectsMethod());
1330
3
  Record.AddSourceRange(E->getSourceRange());
1331
3
  Code = serialization::EXPR_OBJC_DICTIONARY_LITERAL;
1332
3
}
1333
1334
1
void ASTStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
1335
1
  VisitExpr(E);
1336
1
  Record.AddTypeSourceInfo(E->getEncodedTypeSourceInfo());
1337
1
  Record.AddSourceLocation(E->getAtLoc());
1338
1
  Record.AddSourceLocation(E->getRParenLoc());
1339
1
  Code = serialization::EXPR_OBJC_ENCODE;
1340
1
}
1341
1342
15
void ASTStmtWriter::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
1343
15
  VisitExpr(E);
1344
15
  Record.AddSelectorRef(E->getSelector());
1345
15
  Record.AddSourceLocation(E->getAtLoc());
1346
15
  Record.AddSourceLocation(E->getRParenLoc());
1347
15
  Code = serialization::EXPR_OBJC_SELECTOR_EXPR;
1348
15
}
1349
1350
1
void ASTStmtWriter::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
1351
1
  VisitExpr(E);
1352
1
  Record.AddDeclRef(E->getProtocol());
1353
1
  Record.AddSourceLocation(E->getAtLoc());
1354
1
  Record.AddSourceLocation(E->ProtoLoc);
1355
1
  Record.AddSourceLocation(E->getRParenLoc());
1356
1
  Code = serialization::EXPR_OBJC_PROTOCOL_EXPR;
1357
1
}
1358
1359
13
void ASTStmtWriter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
1360
13
  VisitExpr(E);
1361
13
  Record.AddDeclRef(E->getDecl());
1362
13
  Record.AddSourceLocation(E->getLocation());
1363
13
  Record.AddSourceLocation(E->getOpLoc());
1364
13
  Record.AddStmt(E->getBase());
1365
13
  Record.push_back(E->isArrow());
1366
13
  Record.push_back(E->isFreeIvar());
1367
13
  Code = serialization::EXPR_OBJC_IVAR_REF_EXPR;
1368
13
}
1369
1370
2
void ASTStmtWriter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
1371
2
  VisitExpr(E);
1372
2
  Record.push_back(E->SetterAndMethodRefFlags.getInt());
1373
2
  Record.push_back(E->isImplicitProperty());
1374
2
  if (E->isImplicitProperty()) {
1375
1
    Record.AddDeclRef(E->getImplicitPropertyGetter());
1376
1
    Record.AddDeclRef(E->getImplicitPropertySetter());
1377
1
  } else {
1378
1
    Record.AddDeclRef(E->getExplicitProperty());
1379
1
  }
1380
2
  Record.AddSourceLocation(E->getLocation());
1381
2
  Record.AddSourceLocation(E->getReceiverLocation());
1382
2
  if (E->isObjectReceiver()) {
1383
1
    Record.push_back(0);
1384
1
    Record.AddStmt(E->getBase());
1385
1
  } else if (E->isSuperReceiver()) {
1386
0
    Record.push_back(1);
1387
0
    Record.AddTypeRef(E->getSuperReceiverType());
1388
1
  } else {
1389
1
    Record.push_back(2);
1390
1
    Record.AddDeclRef(E->getClassReceiver());
1391
1
  }
1392
1393
2
  Code = serialization::EXPR_OBJC_PROPERTY_REF_EXPR;
1394
2
}
1395
1396
8
void ASTStmtWriter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1397
8
  VisitExpr(E);
1398
8
  Record.AddSourceLocation(E->getRBracket());
1399
8
  Record.AddStmt(E->getBaseExpr());
1400
8
  Record.AddStmt(E->getKeyExpr());
1401
8
  Record.AddDeclRef(E->getAtIndexMethodDecl());
1402
8
  Record.AddDeclRef(E->setAtIndexMethodDecl());
1403
1404
8
  Code = serialization::EXPR_OBJC_SUBSCRIPT_REF_EXPR;
1405
8
}
1406
1407
35
void ASTStmtWriter::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1408
35
  VisitExpr(E);
1409
35
  Record.push_back(E->getNumArgs());
1410
35
  Record.push_back(E->getNumStoredSelLocs());
1411
35
  Record.push_back(E->SelLocsKind);
1412
35
  Record.push_back(E->isDelegateInitCall());
1413
35
  Record.push_back(E->IsImplicit);
1414
35
  Record.push_back((unsigned)E->getReceiverKind()); // FIXME: stable encoding
1415
35
  switch (E->getReceiverKind()) {
1416
28
  case ObjCMessageExpr::Instance:
1417
28
    Record.AddStmt(E->getInstanceReceiver());
1418
28
    break;
1419
1420
7
  case ObjCMessageExpr::Class:
1421
7
    Record.AddTypeSourceInfo(E->getClassReceiverTypeInfo());
1422
7
    break;
1423
1424
0
  case ObjCMessageExpr::SuperClass:
1425
0
  case ObjCMessageExpr::SuperInstance:
1426
0
    Record.AddTypeRef(E->getSuperType());
1427
0
    Record.AddSourceLocation(E->getSuperLoc());
1428
0
    break;
1429
35
  }
1430
1431
35
  if (E->getMethodDecl()) {
1432
35
    Record.push_back(1);
1433
35
    Record.AddDeclRef(E->getMethodDecl());
1434
35
  } else {
1435
0
    Record.push_back(0);
1436
0
    Record.AddSelectorRef(E->getSelector());
1437
0
  }
1438
1439
35
  Record.AddSourceLocation(E->getLeftLoc());
1440
35
  Record.AddSourceLocation(E->getRightLoc());
1441
1442
35
  for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
1443
59
       Arg != ArgEnd; 
++Arg24
)
1444
24
    Record.AddStmt(*Arg);
1445
1446
35
  SourceLocation *Locs = E->getStoredSelLocs();
1447
37
  for (unsigned i = 0, e = E->getNumStoredSelLocs(); i != e; 
++i2
)
1448
2
    Record.AddSourceLocation(Locs[i]);
1449
1450
35
  Code = serialization::EXPR_OBJC_MESSAGE_EXPR;
1451
35
}
1452
1453
0
void ASTStmtWriter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1454
0
  VisitStmt(S);
1455
0
  Record.AddStmt(S->getElement());
1456
0
  Record.AddStmt(S->getCollection());
1457
0
  Record.AddStmt(S->getBody());
1458
0
  Record.AddSourceLocation(S->getForLoc());
1459
0
  Record.AddSourceLocation(S->getRParenLoc());
1460
0
  Code = serialization::STMT_OBJC_FOR_COLLECTION;
1461
0
}
1462
1463
5
void ASTStmtWriter::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1464
5
  VisitStmt(S);
1465
5
  Record.AddStmt(S->getCatchBody());
1466
5
  Record.AddDeclRef(S->getCatchParamDecl());
1467
5
  Record.AddSourceLocation(S->getAtCatchLoc());
1468
5
  Record.AddSourceLocation(S->getRParenLoc());
1469
5
  Code = serialization::STMT_OBJC_CATCH;
1470
5
}
1471
1472
2
void ASTStmtWriter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1473
2
  VisitStmt(S);
1474
2
  Record.AddStmt(S->getFinallyBody());
1475
2
  Record.AddSourceLocation(S->getAtFinallyLoc());
1476
2
  Code = serialization::STMT_OBJC_FINALLY;
1477
2
}
1478
1479
0
void ASTStmtWriter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1480
0
  VisitStmt(S); // FIXME: no test coverage.
1481
0
  Record.AddStmt(S->getSubStmt());
1482
0
  Record.AddSourceLocation(S->getAtLoc());
1483
0
  Code = serialization::STMT_OBJC_AUTORELEASE_POOL;
1484
0
}
1485
1486
2
void ASTStmtWriter::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1487
2
  VisitStmt(S);
1488
2
  Record.push_back(S->getNumCatchStmts());
1489
2
  Record.push_back(S->getFinallyStmt() != nullptr);
1490
2
  Record.AddStmt(S->getTryBody());
1491
2
  for (ObjCAtCatchStmt *C : S->catch_stmts())
1492
5
    Record.AddStmt(C);
1493
2
  if (S->getFinallyStmt())
1494
2
    Record.AddStmt(S->getFinallyStmt());
1495
2
  Record.AddSourceLocation(S->getAtTryLoc());
1496
2
  Code = serialization::STMT_OBJC_AT_TRY;
1497
2
}
1498
1499
0
void ASTStmtWriter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1500
0
  VisitStmt(S); // FIXME: no test coverage.
1501
0
  Record.AddStmt(S->getSynchExpr());
1502
0
  Record.AddStmt(S->getSynchBody());
1503
0
  Record.AddSourceLocation(S->getAtSynchronizedLoc());
1504
0
  Code = serialization::STMT_OBJC_AT_SYNCHRONIZED;
1505
0
}
1506
1507
0
void ASTStmtWriter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1508
0
  VisitStmt(S); // FIXME: no test coverage.
1509
0
  Record.AddStmt(S->getThrowExpr());
1510
0
  Record.AddSourceLocation(S->getThrowLoc());
1511
0
  Code = serialization::STMT_OBJC_AT_THROW;
1512
0
}
1513
1514
18
void ASTStmtWriter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1515
18
  VisitExpr(E);
1516
18
  Record.push_back(E->getValue());
1517
18
  Record.AddSourceLocation(E->getLocation());
1518
18
  Code = serialization::EXPR_OBJC_BOOL_LITERAL;
1519
18
}
1520
1521
0
void ASTStmtWriter::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1522
0
  VisitExpr(E);
1523
0
  Record.AddSourceRange(E->getSourceRange());
1524
0
  Record.AddVersionTuple(E->getVersion());
1525
0
  Code = serialization::EXPR_OBJC_AVAILABILITY_CHECK;
1526
0
}
1527
1528
//===----------------------------------------------------------------------===//
1529
// C++ Expressions and Statements.
1530
//===----------------------------------------------------------------------===//
1531
1532
115
void ASTStmtWriter::VisitCXXCatchStmt(CXXCatchStmt *S) {
1533
115
  VisitStmt(S);
1534
115
  Record.AddSourceLocation(S->getCatchLoc());
1535
115
  Record.AddDeclRef(S->getExceptionDecl());
1536
115
  Record.AddStmt(S->getHandlerBlock());
1537
115
  Code = serialization::STMT_CXX_CATCH;
1538
115
}
1539
1540
115
void ASTStmtWriter::VisitCXXTryStmt(CXXTryStmt *S) {
1541
115
  VisitStmt(S);
1542
115
  Record.push_back(S->getNumHandlers());
1543
115
  Record.AddSourceLocation(S->getTryLoc());
1544
115
  Record.AddStmt(S->getTryBlock());
1545
230
  for (unsigned i = 0, e = S->getNumHandlers(); i != e; 
++i115
)
1546
115
    Record.AddStmt(S->getHandler(i));
1547
115
  Code = serialization::STMT_CXX_TRY;
1548
115
}
1549
1550
45
void ASTStmtWriter::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1551
45
  VisitStmt(S);
1552
45
  Record.AddSourceLocation(S->getForLoc());
1553
45
  Record.AddSourceLocation(S->getCoawaitLoc());
1554
45
  Record.AddSourceLocation(S->getColonLoc());
1555
45
  Record.AddSourceLocation(S->getRParenLoc());
1556
45
  Record.AddStmt(S->getInit());
1557
45
  Record.AddStmt(S->getRangeStmt());
1558
45
  Record.AddStmt(S->getBeginStmt());
1559
45
  Record.AddStmt(S->getEndStmt());
1560
45
  Record.AddStmt(S->getCond());
1561
45
  Record.AddStmt(S->getInc());
1562
45
  Record.AddStmt(S->getLoopVarStmt());
1563
45
  Record.AddStmt(S->getBody());
1564
45
  Code = serialization::STMT_CXX_FOR_RANGE;
1565
45
}
1566
1567
4
void ASTStmtWriter::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1568
4
  VisitStmt(S);
1569
4
  Record.AddSourceLocation(S->getKeywordLoc());
1570
4
  Record.push_back(S->isIfExists());
1571
4
  Record.AddNestedNameSpecifierLoc(S->getQualifierLoc());
1572
4
  Record.AddDeclarationNameInfo(S->getNameInfo());
1573
4
  Record.AddStmt(S->getSubStmt());
1574
4
  Code = serialization::STMT_MS_DEPENDENT_EXISTS;
1575
4
}
1576
1577
19.5k
void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1578
19.5k
  VisitCallExpr(E);
1579
19.5k
  Record.push_back(E->getOperator());
1580
19.5k
  Record.AddSourceRange(E->Range);
1581
19.5k
  Code = serialization::EXPR_CXX_OPERATOR_CALL;
1582
19.5k
}
1583
1584
5.97k
void ASTStmtWriter::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
1585
5.97k
  VisitCallExpr(E);
1586
5.97k
  Code = serialization::EXPR_CXX_MEMBER_CALL;
1587
5.97k
}
1588
1589
void ASTStmtWriter::VisitCXXRewrittenBinaryOperator(
1590
4
    CXXRewrittenBinaryOperator *E) {
1591
4
  VisitExpr(E);
1592
4
  Record.push_back(E->isReversed());
1593
4
  Record.AddStmt(E->getSemanticForm());
1594
4
  Code = serialization::EXPR_CXX_REWRITTEN_BINARY_OPERATOR;
1595
4
}
1596
1597
11.7k
void ASTStmtWriter::VisitCXXConstructExpr(CXXConstructExpr *E) {
1598
11.7k
  VisitExpr(E);
1599
1600
11.7k
  Record.push_back(E->getNumArgs());
1601
11.7k
  Record.push_back(E->isElidable());
1602
11.7k
  Record.push_back(E->hadMultipleCandidates());
1603
11.7k
  Record.push_back(E->isListInitialization());
1604
11.7k
  Record.push_back(E->isStdInitListInitialization());
1605
11.7k
  Record.push_back(E->requiresZeroInitialization());
1606
11.7k
  Record.push_back(E->getConstructionKind()); // FIXME: stable encoding
1607
11.7k
  Record.push_back(E->isImmediateEscalating());
1608
11.7k
  Record.AddSourceLocation(E->getLocation());
1609
11.7k
  Record.AddDeclRef(E->getConstructor());
1610
11.7k
  Record.AddSourceRange(E->getParenOrBraceRange());
1611
1612
18.2k
  for (unsigned I = 0, N = E->getNumArgs(); I != N; 
++I6.54k
)
1613
6.54k
    Record.AddStmt(E->getArg(I));
1614
1615
11.7k
  Code = serialization::EXPR_CXX_CONSTRUCT;
1616
11.7k
}
1617
1618
3
void ASTStmtWriter::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1619
3
  VisitExpr(E);
1620
3
  Record.AddDeclRef(E->getConstructor());
1621
3
  Record.AddSourceLocation(E->getLocation());
1622
3
  Record.push_back(E->constructsVBase());
1623
3
  Record.push_back(E->inheritedFromVBase());
1624
3
  Code = serialization::EXPR_CXX_INHERITED_CTOR_INIT;
1625
3
}
1626
1627
1.27k
void ASTStmtWriter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1628
1.27k
  VisitCXXConstructExpr(E);
1629
1.27k
  Record.AddTypeSourceInfo(E->getTypeSourceInfo());
1630
1.27k
  Code = serialization::EXPR_CXX_TEMPORARY_OBJECT;
1631
1.27k
}
1632
1633
768
void ASTStmtWriter::VisitLambdaExpr(LambdaExpr *E) {
1634
768
  VisitExpr(E);
1635
768
  Record.push_back(E->LambdaExprBits.NumCaptures);
1636
768
  Record.AddSourceRange(E->IntroducerRange);
1637
768
  Record.push_back(E->LambdaExprBits.CaptureDefault); // FIXME: stable encoding
1638
768
  Record.AddSourceLocation(E->CaptureDefaultLoc);
1639
768
  Record.push_back(E->LambdaExprBits.ExplicitParams);
1640
768
  Record.push_back(E->LambdaExprBits.ExplicitResultType);
1641
768
  Record.AddSourceLocation(E->ClosingBrace);
1642
1643
  // Add capture initializers.
1644
768
  for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1645
768
                                      CEnd = E->capture_init_end();
1646
1.99k
       C != CEnd; 
++C1.23k
) {
1647
1.23k
    Record.AddStmt(*C);
1648
1.23k
  }
1649
1650
  // Don't serialize the body. It belongs to the call operator declaration.
1651
  // LambdaExpr only stores a copy of the Stmt *.
1652
1653
768
  Code = serialization::EXPR_LAMBDA;
1654
768
}
1655
1656
5
void ASTStmtWriter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1657
5
  VisitExpr(E);
1658
5
  Record.AddStmt(E->getSubExpr());
1659
5
  Code = serialization::EXPR_CXX_STD_INITIALIZER_LIST;
1660
5
}
1661
1662
3.70k
void ASTStmtWriter::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1663
3.70k
  VisitExplicitCastExpr(E);
1664
3.70k
  Record.AddSourceRange(SourceRange(E->getOperatorLoc(), E->getRParenLoc()));
1665
3.70k
  Record.AddSourceRange(E->getAngleBrackets());
1666
3.70k
}
1667
1668
3.42k
void ASTStmtWriter::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1669
3.42k
  VisitCXXNamedCastExpr(E);
1670
3.42k
  Code = serialization::EXPR_CXX_STATIC_CAST;
1671
3.42k
}
1672
1673
12
void ASTStmtWriter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1674
12
  VisitCXXNamedCastExpr(E);
1675
12
  Code = serialization::EXPR_CXX_DYNAMIC_CAST;
1676
12
}
1677
1678
79
void ASTStmtWriter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1679
79
  VisitCXXNamedCastExpr(E);
1680
79
  Code = serialization::EXPR_CXX_REINTERPRET_CAST;
1681
79
}
1682
1683
188
void ASTStmtWriter::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1684
188
  VisitCXXNamedCastExpr(E);
1685
188
  Code = serialization::EXPR_CXX_CONST_CAST;
1686
188
}
1687
1688
0
void ASTStmtWriter::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *E) {
1689
0
  VisitCXXNamedCastExpr(E);
1690
0
  Code = serialization::EXPR_CXX_ADDRSPACE_CAST;
1691
0
}
1692
1693
1.08k
void ASTStmtWriter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1694
1.08k
  VisitExplicitCastExpr(E);
1695
1.08k
  Record.AddSourceLocation(E->getLParenLoc());
1696
1.08k
  Record.AddSourceLocation(E->getRParenLoc());
1697
1.08k
  Code = serialization::EXPR_CXX_FUNCTIONAL_CAST;
1698
1.08k
}
1699
1700
55
void ASTStmtWriter::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1701
55
  VisitExplicitCastExpr(E);
1702
55
  Record.AddSourceLocation(E->getBeginLoc());
1703
55
  Record.AddSourceLocation(E->getEndLoc());
1704
55
  Code = serialization::EXPR_BUILTIN_BIT_CAST;
1705
55
}
1706
1707
2
void ASTStmtWriter::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1708
2
  VisitCallExpr(E);
1709
2
  Record.AddSourceLocation(E->UDSuffixLoc);
1710
2
  Code = serialization::EXPR_USER_DEFINED_LITERAL;
1711
2
}
1712
1713
10.6k
void ASTStmtWriter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1714
10.6k
  VisitExpr(E);
1715
10.6k
  Record.push_back(E->getValue());
1716
10.6k
  Record.AddSourceLocation(E->getLocation());
1717
10.6k
  Code = serialization::EXPR_CXX_BOOL_LITERAL;
1718
10.6k
}
1719
1720
2.30k
void ASTStmtWriter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1721
2.30k
  VisitExpr(E);
1722
2.30k
  Record.AddSourceLocation(E->getLocation());
1723
2.30k
  Code = serialization::EXPR_CXX_NULL_PTR_LITERAL;
1724
2.30k
}
1725
1726
45
void ASTStmtWriter::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1727
45
  VisitExpr(E);
1728
45
  Record.AddSourceRange(E->getSourceRange());
1729
45
  if (E->isTypeOperand()) {
1730
41
    Record.AddTypeSourceInfo(E->getTypeOperandSourceInfo());
1731
41
    Code = serialization::EXPR_CXX_TYPEID_TYPE;
1732
41
  } else {
1733
4
    Record.AddStmt(E->getExprOperand());
1734
4
    Code = serialization::EXPR_CXX_TYPEID_EXPR;
1735
4
  }
1736
45
}
1737
1738
33.2k
void ASTStmtWriter::VisitCXXThisExpr(CXXThisExpr *E) {
1739
33.2k
  VisitExpr(E);
1740
33.2k
  Record.AddSourceLocation(E->getLocation());
1741
33.2k
  Record.push_back(E->isImplicit());
1742
33.2k
  Code = serialization::EXPR_CXX_THIS;
1743
33.2k
}
1744
1745
92
void ASTStmtWriter::VisitCXXThrowExpr(CXXThrowExpr *E) {
1746
92
  VisitExpr(E);
1747
92
  Record.AddSourceLocation(E->getThrowLoc());
1748
92
  Record.AddStmt(E->getSubExpr());
1749
92
  Record.push_back(E->isThrownVariableInScope());
1750
92
  Code = serialization::EXPR_CXX_THROW;
1751
92
}
1752
1753
1.10k
void ASTStmtWriter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1754
1.10k
  VisitExpr(E);
1755
1.10k
  Record.AddDeclRef(E->getParam());
1756
1.10k
  Record.AddDeclRef(cast_or_null<Decl>(E->getUsedContext()));
1757
1.10k
  Record.AddSourceLocation(E->getUsedLocation());
1758
1.10k
  Record.push_back(E->hasRewrittenInit());
1759
1.10k
  if (E->hasRewrittenInit())
1760
0
    Record.AddStmt(E->getRewrittenExpr());
1761
1.10k
  Code = serialization::EXPR_CXX_DEFAULT_ARG;
1762
1.10k
}
1763
1764
80
void ASTStmtWriter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1765
80
  VisitExpr(E);
1766
80
  Record.push_back(E->hasRewrittenInit());
1767
80
  Record.AddDeclRef(E->getField());
1768
80
  Record.AddDeclRef(cast_or_null<Decl>(E->getUsedContext()));
1769
80
  Record.AddSourceLocation(E->getExprLoc());
1770
80
  if (E->hasRewrittenInit())
1771
80
    Record.AddStmt(E->getRewrittenExpr());
1772
80
  Code = serialization::EXPR_CXX_DEFAULT_INIT;
1773
80
}
1774
1775
1.97k
void ASTStmtWriter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1776
1.97k
  VisitExpr(E);
1777
1.97k
  Record.AddCXXTemporary(E->getTemporary());
1778
1.97k
  Record.AddStmt(E->getSubExpr());
1779
1.97k
  Code = serialization::EXPR_CXX_BIND_TEMPORARY;
1780
1.97k
}
1781
1782
136
void ASTStmtWriter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1783
136
  VisitExpr(E);
1784
136
  Record.AddTypeSourceInfo(E->getTypeSourceInfo());
1785
136
  Record.AddSourceLocation(E->getRParenLoc());
1786
136
  Code = serialization::EXPR_CXX_SCALAR_VALUE_INIT;
1787
136
}
1788
1789
447
void ASTStmtWriter::VisitCXXNewExpr(CXXNewExpr *E) {
1790
447
  VisitExpr(E);
1791
1792
447
  Record.push_back(E->isArray());
1793
447
  Record.push_back(E->hasInitializer());
1794
447
  Record.push_back(E->getNumPlacementArgs());
1795
447
  Record.push_back(E->isParenTypeId());
1796
1797
447
  Record.push_back(E->isGlobalNew());
1798
447
  Record.push_back(E->passAlignment());
1799
447
  Record.push_back(E->doesUsualArrayDeleteWantSize());
1800
447
  Record.push_back(E->CXXNewExprBits.StoredInitializationStyle);
1801
1802
447
  Record.AddDeclRef(E->getOperatorNew());
1803
447
  Record.AddDeclRef(E->getOperatorDelete());
1804
447
  Record.AddTypeSourceInfo(E->getAllocatedTypeSourceInfo());
1805
447
  if (E->isParenTypeId())
1806
1
    Record.AddSourceRange(E->getTypeIdParens());
1807
447
  Record.AddSourceRange(E->getSourceRange());
1808
447
  Record.AddSourceRange(E->getDirectInitRange());
1809
1810
447
  for (CXXNewExpr::arg_iterator I = E->raw_arg_begin(), N = E->raw_arg_end();
1811
1.12k
       I != N; 
++I681
)
1812
681
    Record.AddStmt(*I);
1813
1814
447
  Code = serialization::EXPR_CXX_NEW;
1815
447
}
1816
1817
77
void ASTStmtWriter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1818
77
  VisitExpr(E);
1819
77
  Record.push_back(E->isGlobalDelete());
1820
77
  Record.push_back(E->isArrayForm());
1821
77
  Record.push_back(E->isArrayFormAsWritten());
1822
77
  Record.push_back(E->doesUsualArrayDeleteWantSize());
1823
77
  Record.AddDeclRef(E->getOperatorDelete());
1824
77
  Record.AddStmt(E->getArgument());
1825
77
  Record.AddSourceLocation(E->getBeginLoc());
1826
1827
77
  Code = serialization::EXPR_CXX_DELETE;
1828
77
}
1829
1830
85
void ASTStmtWriter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1831
85
  VisitExpr(E);
1832
1833
85
  Record.AddStmt(E->getBase());
1834
85
  Record.push_back(E->isArrow());
1835
85
  Record.AddSourceLocation(E->getOperatorLoc());
1836
85
  Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
1837
85
  Record.AddTypeSourceInfo(E->getScopeTypeInfo());
1838
85
  Record.AddSourceLocation(E->getColonColonLoc());
1839
85
  Record.AddSourceLocation(E->getTildeLoc());
1840
1841
  // PseudoDestructorTypeStorage.
1842
85
  Record.AddIdentifierRef(E->getDestroyedTypeIdentifier());
1843
85
  if (E->getDestroyedTypeIdentifier())
1844
0
    Record.AddSourceLocation(E->getDestroyedTypeLoc());
1845
85
  else
1846
85
    Record.AddTypeSourceInfo(E->getDestroyedTypeInfo());
1847
1848
85
  Code = serialization::EXPR_CXX_PSEUDO_DESTRUCTOR;
1849
85
}
1850
1851
2.71k
void ASTStmtWriter::VisitExprWithCleanups(ExprWithCleanups *E) {
1852
2.71k
  VisitExpr(E);
1853
2.71k
  Record.push_back(E->getNumObjects());
1854
2.71k
  for (auto &Obj : E->getObjects()) {
1855
13
    if (auto *BD = Obj.dyn_cast<BlockDecl *>()) {
1856
11
      Record.push_back(serialization::COK_Block);
1857
11
      Record.AddDeclRef(BD);
1858
11
    } else 
if (auto *2
CLE2
= Obj.dyn_cast<CompoundLiteralExpr *>()) {
1859
2
      Record.push_back(serialization::COK_CompoundLiteral);
1860
2
      Record.AddStmt(CLE);
1861
2
    }
1862
13
  }
1863
1864
2.71k
  Record.push_back(E->cleanupsHaveSideEffects());
1865
2.71k
  Record.AddStmt(E->getSubExpr());
1866
2.71k
  Code = serialization::EXPR_EXPR_WITH_CLEANUPS;
1867
2.71k
}
1868
1869
void ASTStmtWriter::VisitCXXDependentScopeMemberExpr(
1870
31.9k
    CXXDependentScopeMemberExpr *E) {
1871
31.9k
  VisitExpr(E);
1872
1873
  // Don't emit anything here (or if you do you will have to update
1874
  // the corresponding deserialization function).
1875
1876
31.9k
  Record.push_back(E->hasTemplateKWAndArgsInfo());
1877
31.9k
  Record.push_back(E->getNumTemplateArgs());
1878
31.9k
  Record.push_back(E->hasFirstQualifierFoundInScope());
1879
1880
31.9k
  if (E->hasTemplateKWAndArgsInfo()) {
1881
63
    const ASTTemplateKWAndArgsInfo &ArgInfo =
1882
63
        *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
1883
63
    AddTemplateKWAndArgsInfo(ArgInfo,
1884
63
                             E->getTrailingObjects<TemplateArgumentLoc>());
1885
63
  }
1886
1887
31.9k
  Record.push_back(E->isArrow());
1888
31.9k
  Record.AddSourceLocation(E->getOperatorLoc());
1889
31.9k
  Record.AddTypeRef(E->getBaseType());
1890
31.9k
  Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
1891
31.9k
  if (!E->isImplicitAccess())
1892
28.0k
    Record.AddStmt(E->getBase());
1893
3.93k
  else
1894
3.93k
    Record.AddStmt(nullptr);
1895
1896
31.9k
  if (E->hasFirstQualifierFoundInScope())
1897
6
    Record.AddDeclRef(E->getFirstQualifierFoundInScope());
1898
1899
31.9k
  Record.AddDeclarationNameInfo(E->MemberNameInfo);
1900
31.9k
  Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_MEMBER;
1901
31.9k
}
1902
1903
void
1904
32.4k
ASTStmtWriter::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
1905
32.4k
  VisitExpr(E);
1906
1907
  // Don't emit anything here, HasTemplateKWAndArgsInfo must be
1908
  // emitted first.
1909
1910
32.4k
  Record.push_back(E->DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo);
1911
32.4k
  if (E->DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo) {
1912
944
    const ASTTemplateKWAndArgsInfo &ArgInfo =
1913
944
        *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
1914
944
    Record.push_back(ArgInfo.NumTemplateArgs);
1915
944
    AddTemplateKWAndArgsInfo(ArgInfo,
1916
944
                             E->getTrailingObjects<TemplateArgumentLoc>());
1917
944
  }
1918
1919
32.4k
  Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
1920
32.4k
  Record.AddDeclarationNameInfo(E->NameInfo);
1921
32.4k
  Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_DECL_REF;
1922
32.4k
}
1923
1924
void
1925
7.85k
ASTStmtWriter::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
1926
7.85k
  VisitExpr(E);
1927
7.85k
  Record.push_back(E->getNumArgs());
1928
7.85k
  for (CXXUnresolvedConstructExpr::arg_iterator
1929
13.7k
         ArgI = E->arg_begin(), ArgE = E->arg_end(); ArgI != ArgE; 
++ArgI5.93k
)
1930
5.93k
    Record.AddStmt(*ArgI);
1931
7.85k
  Record.AddTypeSourceInfo(E->getTypeSourceInfo());
1932
7.85k
  Record.AddSourceLocation(E->getLParenLoc());
1933
7.85k
  Record.AddSourceLocation(E->getRParenLoc());
1934
7.85k
  Record.push_back(E->isListInitialization());
1935
7.85k
  Code = serialization::EXPR_CXX_UNRESOLVED_CONSTRUCT;
1936
7.85k
}
1937
1938
34.0k
void ASTStmtWriter::VisitOverloadExpr(OverloadExpr *E) {
1939
34.0k
  VisitExpr(E);
1940
1941
34.0k
  Record.push_back(E->getNumDecls());
1942
34.0k
  Record.push_back(E->hasTemplateKWAndArgsInfo());
1943
34.0k
  if (E->hasTemplateKWAndArgsInfo()) {
1944
3.85k
    const ASTTemplateKWAndArgsInfo &ArgInfo =
1945
3.85k
        *E->getTrailingASTTemplateKWAndArgsInfo();
1946
3.85k
    Record.push_back(ArgInfo.NumTemplateArgs);
1947
3.85k
    AddTemplateKWAndArgsInfo(ArgInfo, E->getTrailingTemplateArgumentLoc());
1948
3.85k
  }
1949
1950
34.0k
  for (OverloadExpr::decls_iterator OvI = E->decls_begin(),
1951
34.0k
                                    OvE = E->decls_end();
1952
349k
       OvI != OvE; 
++OvI315k
) {
1953
315k
    Record.AddDeclRef(OvI.getDecl());
1954
315k
    Record.push_back(OvI.getAccess());
1955
315k
  }
1956
1957
34.0k
  Record.AddDeclarationNameInfo(E->getNameInfo());
1958
34.0k
  Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
1959
34.0k
}
1960
1961
4.55k
void ASTStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
1962
4.55k
  VisitOverloadExpr(E);
1963
4.55k
  Record.push_back(E->isArrow());
1964
4.55k
  Record.push_back(E->hasUnresolvedUsing());
1965
4.55k
  Record.AddStmt(!E->isImplicitAccess() ? 
E->getBase()107
:
nullptr4.44k
);
1966
4.55k
  Record.AddTypeRef(E->getBaseType());
1967
4.55k
  Record.AddSourceLocation(E->getOperatorLoc());
1968
4.55k
  Code = serialization::EXPR_CXX_UNRESOLVED_MEMBER;
1969
4.55k
}
1970
1971
29.5k
void ASTStmtWriter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
1972
29.5k
  VisitOverloadExpr(E);
1973
29.5k
  Record.push_back(E->requiresADL());
1974
29.5k
  Record.push_back(E->isOverloaded());
1975
29.5k
  Record.AddDeclRef(E->getNamingClass());
1976
29.5k
  Code = serialization::EXPR_CXX_UNRESOLVED_LOOKUP;
1977
29.5k
}
1978
1979
5.64k
void ASTStmtWriter::VisitTypeTraitExpr(TypeTraitExpr *E) {
1980
5.64k
  VisitExpr(E);
1981
5.64k
  Record.push_back(E->TypeTraitExprBits.NumArgs);
1982
5.64k
  Record.push_back(E->TypeTraitExprBits.Kind); // FIXME: Stable encoding
1983
5.64k
  Record.push_back(E->TypeTraitExprBits.Value);
1984
5.64k
  Record.AddSourceRange(E->getSourceRange());
1985
14.6k
  for (unsigned I = 0, N = E->getNumArgs(); I != N; 
++I8.95k
)
1986
8.95k
    Record.AddTypeSourceInfo(E->getArg(I));
1987
5.64k
  Code = serialization::EXPR_TYPE_TRAIT;
1988
5.64k
}
1989
1990
16
void ASTStmtWriter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1991
16
  VisitExpr(E);
1992
16
  Record.push_back(E->getTrait());
1993
16
  Record.push_back(E->getValue());
1994
16
  Record.AddSourceRange(E->getSourceRange());
1995
16
  Record.AddTypeSourceInfo(E->getQueriedTypeSourceInfo());
1996
16
  Record.AddStmt(E->getDimensionExpression());
1997
16
  Code = serialization::EXPR_ARRAY_TYPE_TRAIT;
1998
16
}
1999
2000
2
void ASTStmtWriter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
2001
2
  VisitExpr(E);
2002
2
  Record.push_back(E->getTrait());
2003
2
  Record.push_back(E->getValue());
2004
2
  Record.AddSourceRange(E->getSourceRange());
2005
2
  Record.AddStmt(E->getQueriedExpression());
2006
2
  Code = serialization::EXPR_CXX_EXPRESSION_TRAIT;
2007
2
}
2008
2009
233
void ASTStmtWriter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
2010
233
  VisitExpr(E);
2011
233
  Record.push_back(E->getValue());
2012
233
  Record.AddSourceRange(E->getSourceRange());
2013
233
  Record.AddStmt(E->getOperand());
2014
233
  Code = serialization::EXPR_CXX_NOEXCEPT;
2015
233
}
2016
2017
2.10k
void ASTStmtWriter::VisitPackExpansionExpr(PackExpansionExpr *E) {
2018
2.10k
  VisitExpr(E);
2019
2.10k
  Record.AddSourceLocation(E->getEllipsisLoc());
2020
2.10k
  Record.push_back(E->NumExpansions);
2021
2.10k
  Record.AddStmt(E->getPattern());
2022
2.10k
  Code = serialization::EXPR_PACK_EXPANSION;
2023
2.10k
}
2024
2025
3.32k
void ASTStmtWriter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2026
3.32k
  VisitExpr(E);
2027
3.32k
  Record.push_back(E->isPartiallySubstituted() ? 
E->getPartialArguments().size()42
2028
3.32k
                                               : 
03.28k
);
2029
3.32k
  Record.AddSourceLocation(E->OperatorLoc);
2030
3.32k
  Record.AddSourceLocation(E->PackLoc);
2031
3.32k
  Record.AddSourceLocation(E->RParenLoc);
2032
3.32k
  Record.AddDeclRef(E->Pack);
2033
3.32k
  if (E->isPartiallySubstituted()) {
2034
42
    for (const auto &TA : E->getPartialArguments())
2035
42
      Record.AddTemplateArgument(TA);
2036
3.28k
  } else if (!E->isValueDependent()) {
2037
1.62k
    Record.push_back(E->getPackLength());
2038
1.62k
  }
2039
3.32k
  Code = serialization::EXPR_SIZEOF_PACK;
2040
3.32k
}
2041
2042
void ASTStmtWriter::VisitSubstNonTypeTemplateParmExpr(
2043
11.6k
                                              SubstNonTypeTemplateParmExpr *E) {
2044
11.6k
  VisitExpr(E);
2045
11.6k
  Record.AddDeclRef(E->getAssociatedDecl());
2046
11.6k
  Record.push_back(E->isReferenceParameter());
2047
11.6k
  Record.push_back(E->getIndex());
2048
11.6k
  if (auto PackIndex = E->getPackIndex())
2049
622
    Record.push_back(*PackIndex + 1);
2050
11.0k
  else
2051
11.0k
    Record.push_back(0);
2052
11.6k
  Record.AddSourceLocation(E->getNameLoc());
2053
11.6k
  Record.AddStmt(E->getReplacement());
2054
11.6k
  Code = serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM;
2055
11.6k
}
2056
2057
void ASTStmtWriter::VisitSubstNonTypeTemplateParmPackExpr(
2058
0
                                          SubstNonTypeTemplateParmPackExpr *E) {
2059
0
  VisitExpr(E);
2060
0
  Record.AddDeclRef(E->getAssociatedDecl());
2061
0
  Record.push_back(E->getIndex());
2062
0
  Record.AddTemplateArgument(E->getArgumentPack());
2063
0
  Record.AddSourceLocation(E->getParameterPackLocation());
2064
0
  Code = serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK;
2065
0
}
2066
2067
4
void ASTStmtWriter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2068
4
  VisitExpr(E);
2069
4
  Record.push_back(E->getNumExpansions());
2070
4
  Record.AddDeclRef(E->getParameterPack());
2071
4
  Record.AddSourceLocation(E->getParameterPackLocation());
2072
4
  for (FunctionParmPackExpr::iterator I = E->begin(), End = E->end();
2073
16
       I != End; 
++I12
)
2074
12
    Record.AddDeclRef(*I);
2075
4
  Code = serialization::EXPR_FUNCTION_PARM_PACK;
2076
4
}
2077
2078
3.22k
void ASTStmtWriter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
2079
3.22k
  VisitExpr(E);
2080
3.22k
  Record.push_back(static_cast<bool>(E->getLifetimeExtendedTemporaryDecl()));
2081
3.22k
  if (E->getLifetimeExtendedTemporaryDecl())
2082
19
    Record.AddDeclRef(E->getLifetimeExtendedTemporaryDecl());
2083
3.20k
  else
2084
3.20k
    Record.AddStmt(E->getSubExpr());
2085
3.22k
  Code = serialization::EXPR_MATERIALIZE_TEMPORARY;
2086
3.22k
}
2087
2088
18
void ASTStmtWriter::VisitCXXFoldExpr(CXXFoldExpr *E) {
2089
18
  VisitExpr(E);
2090
18
  Record.AddSourceLocation(E->LParenLoc);
2091
18
  Record.AddSourceLocation(E->EllipsisLoc);
2092
18
  Record.AddSourceLocation(E->RParenLoc);
2093
18
  Record.push_back(E->NumExpansions);
2094
18
  Record.AddStmt(E->SubExprs[0]);
2095
18
  Record.AddStmt(E->SubExprs[1]);
2096
18
  Record.AddStmt(E->SubExprs[2]);
2097
18
  Record.push_back(E->Opcode);
2098
18
  Code = serialization::EXPR_CXX_FOLD;
2099
18
}
2100
2101
3
void ASTStmtWriter::VisitCXXParenListInitExpr(CXXParenListInitExpr *E) {
2102
3
  VisitExpr(E);
2103
3
  ArrayRef<Expr *> InitExprs = E->getInitExprs();
2104
3
  Record.push_back(InitExprs.size());
2105
3
  Record.push_back(E->getUserSpecifiedInitExprs().size());
2106
3
  Record.AddSourceLocation(E->getInitLoc());
2107
3
  Record.AddSourceLocation(E->getBeginLoc());
2108
3
  Record.AddSourceLocation(E->getEndLoc());
2109
3
  for (Expr *InitExpr : E->getInitExprs())
2110
5
    Record.AddStmt(InitExpr);
2111
3
  Expr *ArrayFiller = E->getArrayFiller();
2112
3
  FieldDecl *UnionField = E->getInitializedFieldInUnion();
2113
3
  bool HasArrayFillerOrUnionDecl = ArrayFiller || 
UnionField2
;
2114
3
  Record.push_back(HasArrayFillerOrUnionDecl);
2115
3
  if (HasArrayFillerOrUnionDecl) {
2116
2
    Record.push_back(static_cast<bool>(ArrayFiller));
2117
2
    if (ArrayFiller)
2118
1
      Record.AddStmt(ArrayFiller);
2119
1
    else
2120
1
      Record.AddDeclRef(UnionField);
2121
2
  }
2122
3
  Code = serialization::EXPR_CXX_PAREN_LIST_INIT;
2123
3
}
2124
2125
1.39k
void ASTStmtWriter::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
2126
1.39k
  VisitExpr(E);
2127
1.39k
  Record.AddStmt(E->getSourceExpr());
2128
1.39k
  Record.AddSourceLocation(E->getLocation());
2129
1.39k
  Record.push_back(E->isUnique());
2130
1.39k
  Code = serialization::EXPR_OPAQUE_VALUE;
2131
1.39k
}
2132
2133
0
void ASTStmtWriter::VisitTypoExpr(TypoExpr *E) {
2134
0
  VisitExpr(E);
2135
  // TODO: Figure out sane writer behavior for a TypoExpr, if necessary
2136
0
  llvm_unreachable("Cannot write TypoExpr nodes");
2137
0
}
2138
2139
//===----------------------------------------------------------------------===//
2140
// CUDA Expressions and Statements.
2141
//===----------------------------------------------------------------------===//
2142
2143
1
void ASTStmtWriter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2144
1
  VisitCallExpr(E);
2145
1
  Record.AddStmt(E->getConfig());
2146
1
  Code = serialization::EXPR_CUDA_KERNEL_CALL;
2147
1
}
2148
2149
//===----------------------------------------------------------------------===//
2150
// OpenCL Expressions and Statements.
2151
//===----------------------------------------------------------------------===//
2152
0
void ASTStmtWriter::VisitAsTypeExpr(AsTypeExpr *E) {
2153
0
  VisitExpr(E);
2154
0
  Record.AddSourceLocation(E->getBuiltinLoc());
2155
0
  Record.AddSourceLocation(E->getRParenLoc());
2156
0
  Record.AddStmt(E->getSrcExpr());
2157
0
  Code = serialization::EXPR_ASTYPE;
2158
0
}
2159
2160
//===----------------------------------------------------------------------===//
2161
// Microsoft Expressions and Statements.
2162
//===----------------------------------------------------------------------===//
2163
36
void ASTStmtWriter::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
2164
36
  VisitExpr(E);
2165
36
  Record.push_back(E->isArrow());
2166
36
  Record.AddStmt(E->getBaseExpr());
2167
36
  Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
2168
36
  Record.AddSourceLocation(E->getMemberLoc());
2169
36
  Record.AddDeclRef(E->getPropertyDecl());
2170
36
  Code = serialization::EXPR_CXX_PROPERTY_REF_EXPR;
2171
36
}
2172
2173
70
void ASTStmtWriter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
2174
70
  VisitExpr(E);
2175
70
  Record.AddStmt(E->getBase());
2176
70
  Record.AddStmt(E->getIdx());
2177
70
  Record.AddSourceLocation(E->getRBracketLoc());
2178
70
  Code = serialization::EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR;
2179
70
}
2180
2181
1
void ASTStmtWriter::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
2182
1
  VisitExpr(E);
2183
1
  Record.AddSourceRange(E->getSourceRange());
2184
1
  Record.AddDeclRef(E->getGuidDecl());
2185
1
  if (E->isTypeOperand()) {
2186
0
    Record.AddTypeSourceInfo(E->getTypeOperandSourceInfo());
2187
0
    Code = serialization::EXPR_CXX_UUIDOF_TYPE;
2188
1
  } else {
2189
1
    Record.AddStmt(E->getExprOperand());
2190
1
    Code = serialization::EXPR_CXX_UUIDOF_EXPR;
2191
1
  }
2192
1
}
2193
2194
1
void ASTStmtWriter::VisitSEHExceptStmt(SEHExceptStmt *S) {
2195
1
  VisitStmt(S);
2196
1
  Record.AddSourceLocation(S->getExceptLoc());
2197
1
  Record.AddStmt(S->getFilterExpr());
2198
1
  Record.AddStmt(S->getBlock());
2199
1
  Code = serialization::STMT_SEH_EXCEPT;
2200
1
}
2201
2202
0
void ASTStmtWriter::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
2203
0
  VisitStmt(S);
2204
0
  Record.AddSourceLocation(S->getFinallyLoc());
2205
0
  Record.AddStmt(S->getBlock());
2206
0
  Code = serialization::STMT_SEH_FINALLY;
2207
0
}
2208
2209
1
void ASTStmtWriter::VisitSEHTryStmt(SEHTryStmt *S) {
2210
1
  VisitStmt(S);
2211
1
  Record.push_back(S->getIsCXXTry());
2212
1
  Record.AddSourceLocation(S->getTryLoc());
2213
1
  Record.AddStmt(S->getTryBlock());
2214
1
  Record.AddStmt(S->getHandler());
2215
1
  Code = serialization::STMT_SEH_TRY;
2216
1
}
2217
2218
0
void ASTStmtWriter::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
2219
0
  VisitStmt(S);
2220
0
  Record.AddSourceLocation(S->getLeaveLoc());
2221
0
  Code = serialization::STMT_SEH_LEAVE;
2222
0
}
2223
2224
//===----------------------------------------------------------------------===//
2225
// OpenMP Directives.
2226
//===----------------------------------------------------------------------===//
2227
2228
25
void ASTStmtWriter::VisitOMPCanonicalLoop(OMPCanonicalLoop *S) {
2229
25
  VisitStmt(S);
2230
25
  for (Stmt *SubStmt : S->SubStmts)
2231
100
    Record.AddStmt(SubStmt);
2232
25
  Code = serialization::STMT_OMP_CANONICAL_LOOP;
2233
25
}
2234
2235
25.8k
void ASTStmtWriter::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
2236
25.8k
  Record.writeOMPChildren(E->Data);
2237
25.8k
  Record.AddSourceLocation(E->getBeginLoc());
2238
25.8k
  Record.AddSourceLocation(E->getEndLoc());
2239
25.8k
  Record.writeEnum(E->getMappedDirective());
2240
25.8k
}
2241
2242
8.06k
void ASTStmtWriter::VisitOMPLoopBasedDirective(OMPLoopBasedDirective *D) {
2243
8.06k
  VisitStmt(D);
2244
8.06k
  Record.writeUInt32(D->getLoopsNumber());
2245
8.06k
  VisitOMPExecutableDirective(D);
2246
8.06k
}
2247
2248
8.02k
void ASTStmtWriter::VisitOMPLoopDirective(OMPLoopDirective *D) {
2249
8.02k
  VisitOMPLoopBasedDirective(D);
2250
8.02k
}
2251
2252
0
void ASTStmtWriter::VisitOMPMetaDirective(OMPMetaDirective *D) {
2253
0
  VisitStmt(D);
2254
0
  Record.push_back(D->getNumClauses());
2255
0
  VisitOMPExecutableDirective(D);
2256
0
  Code = serialization::STMT_OMP_META_DIRECTIVE;
2257
0
}
2258
2259
823
void ASTStmtWriter::VisitOMPParallelDirective(OMPParallelDirective *D) {
2260
823
  VisitStmt(D);
2261
823
  VisitOMPExecutableDirective(D);
2262
823
  Record.writeBool(D->hasCancel());
2263
823
  Code = serialization::STMT_OMP_PARALLEL_DIRECTIVE;
2264
823
}
2265
2266
198
void ASTStmtWriter::VisitOMPSimdDirective(OMPSimdDirective *D) {
2267
198
  VisitOMPLoopDirective(D);
2268
198
  Code = serialization::STMT_OMP_SIMD_DIRECTIVE;
2269
198
}
2270
2271
void ASTStmtWriter::VisitOMPLoopTransformationDirective(
2272
38
    OMPLoopTransformationDirective *D) {
2273
38
  VisitOMPLoopBasedDirective(D);
2274
38
  Record.writeUInt32(D->getNumGeneratedLoops());
2275
38
}
2276
2277
19
void ASTStmtWriter::VisitOMPTileDirective(OMPTileDirective *D) {
2278
19
  VisitOMPLoopTransformationDirective(D);
2279
19
  Code = serialization::STMT_OMP_TILE_DIRECTIVE;
2280
19
}
2281
2282
19
void ASTStmtWriter::VisitOMPUnrollDirective(OMPUnrollDirective *D) {
2283
19
  VisitOMPLoopTransformationDirective(D);
2284
19
  Code = serialization::STMT_OMP_UNROLL_DIRECTIVE;
2285
19
}
2286
2287
446
void ASTStmtWriter::VisitOMPForDirective(OMPForDirective *D) {
2288
446
  VisitOMPLoopDirective(D);
2289
446
  Record.writeBool(D->hasCancel());
2290
446
  Code = serialization::STMT_OMP_FOR_DIRECTIVE;
2291
446
}
2292
2293
135
void ASTStmtWriter::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2294
135
  VisitOMPLoopDirective(D);
2295
135
  Code = serialization::STMT_OMP_FOR_SIMD_DIRECTIVE;
2296
135
}
2297
2298
58
void ASTStmtWriter::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2299
58
  VisitStmt(D);
2300
58
  VisitOMPExecutableDirective(D);
2301
58
  Record.writeBool(D->hasCancel());
2302
58
  Code = serialization::STMT_OMP_SECTIONS_DIRECTIVE;
2303
58
}
2304
2305
50
void ASTStmtWriter::VisitOMPSectionDirective(OMPSectionDirective *D) {
2306
50
  VisitStmt(D);
2307
50
  VisitOMPExecutableDirective(D);
2308
50
  Record.writeBool(D->hasCancel());
2309
50
  Code = serialization::STMT_OMP_SECTION_DIRECTIVE;
2310
50
}
2311
2312
2
void ASTStmtWriter::VisitOMPScopeDirective(OMPScopeDirective *D) {
2313
2
  VisitStmt(D);
2314
2
  VisitOMPExecutableDirective(D);
2315
2
  Code = serialization::STMT_OMP_SCOPE_DIRECTIVE;
2316
2
}
2317
2318
46
void ASTStmtWriter::VisitOMPSingleDirective(OMPSingleDirective *D) {
2319
46
  VisitStmt(D);
2320
46
  VisitOMPExecutableDirective(D);
2321
46
  Code = serialization::STMT_OMP_SINGLE_DIRECTIVE;
2322
46
}
2323
2324
17
void ASTStmtWriter::VisitOMPMasterDirective(OMPMasterDirective *D) {
2325
17
  VisitStmt(D);
2326
17
  VisitOMPExecutableDirective(D);
2327
17
  Code = serialization::STMT_OMP_MASTER_DIRECTIVE;
2328
17
}
2329
2330
78
void ASTStmtWriter::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2331
78
  VisitStmt(D);
2332
78
  VisitOMPExecutableDirective(D);
2333
78
  Record.AddDeclarationNameInfo(D->getDirectiveName());
2334
78
  Code = serialization::STMT_OMP_CRITICAL_DIRECTIVE;
2335
78
}
2336
2337
123
void ASTStmtWriter::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
2338
123
  VisitOMPLoopDirective(D);
2339
123
  Record.writeBool(D->hasCancel());
2340
123
  Code = serialization::STMT_OMP_PARALLEL_FOR_DIRECTIVE;
2341
123
}
2342
2343
void ASTStmtWriter::VisitOMPParallelForSimdDirective(
2344
144
    OMPParallelForSimdDirective *D) {
2345
144
  VisitOMPLoopDirective(D);
2346
144
  Code = serialization::STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE;
2347
144
}
2348
2349
void ASTStmtWriter::VisitOMPParallelMasterDirective(
2350
77
    OMPParallelMasterDirective *D) {
2351
77
  VisitStmt(D);
2352
77
  VisitOMPExecutableDirective(D);
2353
77
  Code = serialization::STMT_OMP_PARALLEL_MASTER_DIRECTIVE;
2354
77
}
2355
2356
void ASTStmtWriter::VisitOMPParallelMaskedDirective(
2357
44
    OMPParallelMaskedDirective *D) {
2358
44
  VisitStmt(D);
2359
44
  VisitOMPExecutableDirective(D);
2360
44
  Code = serialization::STMT_OMP_PARALLEL_MASKED_DIRECTIVE;
2361
44
}
2362
2363
void ASTStmtWriter::VisitOMPParallelSectionsDirective(
2364
32
    OMPParallelSectionsDirective *D) {
2365
32
  VisitStmt(D);
2366
32
  VisitOMPExecutableDirective(D);
2367
32
  Record.writeBool(D->hasCancel());
2368
32
  Code = serialization::STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE;
2369
32
}
2370
2371
257
void ASTStmtWriter::VisitOMPTaskDirective(OMPTaskDirective *D) {
2372
257
  VisitStmt(D);
2373
257
  VisitOMPExecutableDirective(D);
2374
257
  Record.writeBool(D->hasCancel());
2375
257
  Code = serialization::STMT_OMP_TASK_DIRECTIVE;
2376
257
}
2377
2378
6.29k
void ASTStmtWriter::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2379
6.29k
  VisitStmt(D);
2380
6.29k
  VisitOMPExecutableDirective(D);
2381
6.29k
  Record.writeBool(D->isXLHSInRHSPart());
2382
6.29k
  Record.writeBool(D->isPostfixUpdate());
2383
6.29k
  Record.writeBool(D->isFailOnly());
2384
6.29k
  Code = serialization::STMT_OMP_ATOMIC_DIRECTIVE;
2385
6.29k
}
2386
2387
5.32k
void ASTStmtWriter::VisitOMPTargetDirective(OMPTargetDirective *D) {
2388
5.32k
  VisitStmt(D);
2389
5.32k
  VisitOMPExecutableDirective(D);
2390
5.32k
  Code = serialization::STMT_OMP_TARGET_DIRECTIVE;
2391
5.32k
}
2392
2393
278
void ASTStmtWriter::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2394
278
  VisitStmt(D);
2395
278
  VisitOMPExecutableDirective(D);
2396
278
  Code = serialization::STMT_OMP_TARGET_DATA_DIRECTIVE;
2397
278
}
2398
2399
void ASTStmtWriter::VisitOMPTargetEnterDataDirective(
2400
343
    OMPTargetEnterDataDirective *D) {
2401
343
  VisitStmt(D);
2402
343
  VisitOMPExecutableDirective(D);
2403
343
  Code = serialization::STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE;
2404
343
}
2405
2406
void ASTStmtWriter::VisitOMPTargetExitDataDirective(
2407
335
    OMPTargetExitDataDirective *D) {
2408
335
  VisitStmt(D);
2409
335
  VisitOMPExecutableDirective(D);
2410
335
  Code = serialization::STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE;
2411
335
}
2412
2413
void ASTStmtWriter::VisitOMPTargetParallelDirective(
2414
618
    OMPTargetParallelDirective *D) {
2415
618
  VisitStmt(D);
2416
618
  VisitOMPExecutableDirective(D);
2417
618
  Record.writeBool(D->hasCancel());
2418
618
  Code = serialization::STMT_OMP_TARGET_PARALLEL_DIRECTIVE;
2419
618
}
2420
2421
void ASTStmtWriter::VisitOMPTargetParallelForDirective(
2422
502
    OMPTargetParallelForDirective *D) {
2423
502
  VisitOMPLoopDirective(D);
2424
502
  Record.writeBool(D->hasCancel());
2425
502
  Code = serialization::STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE;
2426
502
}
2427
2428
16
void ASTStmtWriter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2429
16
  VisitStmt(D);
2430
16
  VisitOMPExecutableDirective(D);
2431
16
  Code = serialization::STMT_OMP_TASKYIELD_DIRECTIVE;
2432
16
}
2433
2434
30
void ASTStmtWriter::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2435
30
  VisitStmt(D);
2436
30
  VisitOMPExecutableDirective(D);
2437
30
  Code = serialization::STMT_OMP_BARRIER_DIRECTIVE;
2438
30
}
2439
2440
38
void ASTStmtWriter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2441
38
  VisitStmt(D);
2442
38
  Record.push_back(D->getNumClauses());
2443
38
  VisitOMPExecutableDirective(D);
2444
38
  Code = serialization::STMT_OMP_TASKWAIT_DIRECTIVE;
2445
38
}
2446
2447
10
void ASTStmtWriter::VisitOMPErrorDirective(OMPErrorDirective *D) {
2448
10
  VisitStmt(D);
2449
10
  Record.push_back(D->getNumClauses());
2450
10
  VisitOMPExecutableDirective(D);
2451
10
  Code = serialization::STMT_OMP_ERROR_DIRECTIVE;
2452
10
}
2453
2454
114
void ASTStmtWriter::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2455
114
  VisitStmt(D);
2456
114
  VisitOMPExecutableDirective(D);
2457
114
  Code = serialization::STMT_OMP_TASKGROUP_DIRECTIVE;
2458
114
}
2459
2460
50
void ASTStmtWriter::VisitOMPFlushDirective(OMPFlushDirective *D) {
2461
50
  VisitStmt(D);
2462
50
  VisitOMPExecutableDirective(D);
2463
50
  Code = serialization::STMT_OMP_FLUSH_DIRECTIVE;
2464
50
}
2465
2466
28
void ASTStmtWriter::VisitOMPDepobjDirective(OMPDepobjDirective *D) {
2467
28
  VisitStmt(D);
2468
28
  VisitOMPExecutableDirective(D);
2469
28
  Code = serialization::STMT_OMP_DEPOBJ_DIRECTIVE;
2470
28
}
2471
2472
24
void ASTStmtWriter::VisitOMPScanDirective(OMPScanDirective *D) {
2473
24
  VisitStmt(D);
2474
24
  VisitOMPExecutableDirective(D);
2475
24
  Code = serialization::STMT_OMP_SCAN_DIRECTIVE;
2476
24
}
2477
2478
114
void ASTStmtWriter::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2479
114
  VisitStmt(D);
2480
114
  VisitOMPExecutableDirective(D);
2481
114
  Code = serialization::STMT_OMP_ORDERED_DIRECTIVE;
2482
114
}
2483
2484
1.14k
void ASTStmtWriter::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2485
1.14k
  VisitStmt(D);
2486
1.14k
  VisitOMPExecutableDirective(D);
2487
1.14k
  Code = serialization::STMT_OMP_TEAMS_DIRECTIVE;
2488
1.14k
}
2489
2490
void ASTStmtWriter::VisitOMPCancellationPointDirective(
2491
78
    OMPCancellationPointDirective *D) {
2492
78
  VisitStmt(D);
2493
78
  VisitOMPExecutableDirective(D);
2494
78
  Record.writeEnum(D->getCancelRegion());
2495
78
  Code = serialization::STMT_OMP_CANCELLATION_POINT_DIRECTIVE;
2496
78
}
2497
2498
180
void ASTStmtWriter::VisitOMPCancelDirective(OMPCancelDirective *D) {
2499
180
  VisitStmt(D);
2500
180
  VisitOMPExecutableDirective(D);
2501
180
  Record.writeEnum(D->getCancelRegion());
2502
180
  Code = serialization::STMT_OMP_CANCEL_DIRECTIVE;
2503
180
}
2504
2505
48
void ASTStmtWriter::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2506
48
  VisitOMPLoopDirective(D);
2507
48
  Record.writeBool(D->hasCancel());
2508
48
  Code = serialization::STMT_OMP_TASKLOOP_DIRECTIVE;
2509
48
}
2510
2511
46
void ASTStmtWriter::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2512
46
  VisitOMPLoopDirective(D);
2513
46
  Code = serialization::STMT_OMP_TASKLOOP_SIMD_DIRECTIVE;
2514
46
}
2515
2516
void ASTStmtWriter::VisitOMPMasterTaskLoopDirective(
2517
36
    OMPMasterTaskLoopDirective *D) {
2518
36
  VisitOMPLoopDirective(D);
2519
36
  Record.writeBool(D->hasCancel());
2520
36
  Code = serialization::STMT_OMP_MASTER_TASKLOOP_DIRECTIVE;
2521
36
}
2522
2523
void ASTStmtWriter::VisitOMPMaskedTaskLoopDirective(
2524
12
    OMPMaskedTaskLoopDirective *D) {
2525
12
  VisitOMPLoopDirective(D);
2526
12
  Record.writeBool(D->hasCancel());
2527
12
  Code = serialization::STMT_OMP_MASKED_TASKLOOP_DIRECTIVE;
2528
12
}
2529
2530
void ASTStmtWriter::VisitOMPMasterTaskLoopSimdDirective(
2531
50
    OMPMasterTaskLoopSimdDirective *D) {
2532
50
  VisitOMPLoopDirective(D);
2533
50
  Code = serialization::STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE;
2534
50
}
2535
2536
void ASTStmtWriter::VisitOMPMaskedTaskLoopSimdDirective(
2537
20
    OMPMaskedTaskLoopSimdDirective *D) {
2538
20
  VisitOMPLoopDirective(D);
2539
20
  Code = serialization::STMT_OMP_MASKED_TASKLOOP_SIMD_DIRECTIVE;
2540
20
}
2541
2542
void ASTStmtWriter::VisitOMPParallelMasterTaskLoopDirective(
2543
34
    OMPParallelMasterTaskLoopDirective *D) {
2544
34
  VisitOMPLoopDirective(D);
2545
34
  Record.writeBool(D->hasCancel());
2546
34
  Code = serialization::STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE;
2547
34
}
2548
2549
void ASTStmtWriter::VisitOMPParallelMaskedTaskLoopDirective(
2550
12
    OMPParallelMaskedTaskLoopDirective *D) {
2551
12
  VisitOMPLoopDirective(D);
2552
12
  Record.writeBool(D->hasCancel());
2553
12
  Code = serialization::STMT_OMP_PARALLEL_MASKED_TASKLOOP_DIRECTIVE;
2554
12
}
2555
2556
void ASTStmtWriter::VisitOMPParallelMasterTaskLoopSimdDirective(
2557
48
    OMPParallelMasterTaskLoopSimdDirective *D) {
2558
48
  VisitOMPLoopDirective(D);
2559
48
  Code = serialization::STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE;
2560
48
}
2561
2562
void ASTStmtWriter::VisitOMPParallelMaskedTaskLoopSimdDirective(
2563
12
    OMPParallelMaskedTaskLoopSimdDirective *D) {
2564
12
  VisitOMPLoopDirective(D);
2565
12
  Code = serialization::STMT_OMP_PARALLEL_MASKED_TASKLOOP_SIMD_DIRECTIVE;
2566
12
}
2567
2568
156
void ASTStmtWriter::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2569
156
  VisitOMPLoopDirective(D);
2570
156
  Code = serialization::STMT_OMP_DISTRIBUTE_DIRECTIVE;
2571
156
}
2572
2573
406
void ASTStmtWriter::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2574
406
  VisitStmt(D);
2575
406
  VisitOMPExecutableDirective(D);
2576
406
  Code = serialization::STMT_OMP_TARGET_UPDATE_DIRECTIVE;
2577
406
}
2578
2579
void ASTStmtWriter::VisitOMPDistributeParallelForDirective(
2580
340
    OMPDistributeParallelForDirective *D) {
2581
340
  VisitOMPLoopDirective(D);
2582
340
  Record.writeBool(D->hasCancel());
2583
340
  Code = serialization::STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE;
2584
340
}
2585
2586
void ASTStmtWriter::VisitOMPDistributeParallelForSimdDirective(
2587
320
    OMPDistributeParallelForSimdDirective *D) {
2588
320
  VisitOMPLoopDirective(D);
2589
320
  Code = serialization::STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE;
2590
320
}
2591
2592
void ASTStmtWriter::VisitOMPDistributeSimdDirective(
2593
198
    OMPDistributeSimdDirective *D) {
2594
198
  VisitOMPLoopDirective(D);
2595
198
  Code = serialization::STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE;
2596
198
}
2597
2598
void ASTStmtWriter::VisitOMPTargetParallelForSimdDirective(
2599
600
    OMPTargetParallelForSimdDirective *D) {
2600
600
  VisitOMPLoopDirective(D);
2601
600
  Code = serialization::STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE;
2602
600
}
2603
2604
572
void ASTStmtWriter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2605
572
  VisitOMPLoopDirective(D);
2606
572
  Code = serialization::STMT_OMP_TARGET_SIMD_DIRECTIVE;
2607
572
}
2608
2609
void ASTStmtWriter::VisitOMPTeamsDistributeDirective(
2610
152
    OMPTeamsDistributeDirective *D) {
2611
152
  VisitOMPLoopDirective(D);
2612
152
  Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE;
2613
152
}
2614
2615
void ASTStmtWriter::VisitOMPTeamsDistributeSimdDirective(
2616
256
    OMPTeamsDistributeSimdDirective *D) {
2617
256
  VisitOMPLoopDirective(D);
2618
256
  Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE;
2619
256
}
2620
2621
void ASTStmtWriter::VisitOMPTeamsDistributeParallelForSimdDirective(
2622
420
    OMPTeamsDistributeParallelForSimdDirective *D) {
2623
420
  VisitOMPLoopDirective(D);
2624
420
  Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE;
2625
420
}
2626
2627
void ASTStmtWriter::VisitOMPTeamsDistributeParallelForDirective(
2628
378
    OMPTeamsDistributeParallelForDirective *D) {
2629
378
  VisitOMPLoopDirective(D);
2630
378
  Record.writeBool(D->hasCancel());
2631
378
  Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE;
2632
378
}
2633
2634
799
void ASTStmtWriter::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2635
799
  VisitStmt(D);
2636
799
  VisitOMPExecutableDirective(D);
2637
799
  Code = serialization::STMT_OMP_TARGET_TEAMS_DIRECTIVE;
2638
799
}
2639
2640
void ASTStmtWriter::VisitOMPTargetTeamsDistributeDirective(
2641
593
    OMPTargetTeamsDistributeDirective *D) {
2642
593
  VisitOMPLoopDirective(D);
2643
593
  Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE;
2644
593
}
2645
2646
void ASTStmtWriter::VisitOMPTargetTeamsDistributeParallelForDirective(
2647
501
    OMPTargetTeamsDistributeParallelForDirective *D) {
2648
501
  VisitOMPLoopDirective(D);
2649
501
  Record.writeBool(D->hasCancel());
2650
501
  Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE;
2651
501
}
2652
2653
void ASTStmtWriter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2654
643
    OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2655
643
  VisitOMPLoopDirective(D);
2656
643
  Code = serialization::
2657
643
      STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE;
2658
643
}
2659
2660
void ASTStmtWriter::VisitOMPTargetTeamsDistributeSimdDirective(
2661
597
    OMPTargetTeamsDistributeSimdDirective *D) {
2662
597
  VisitOMPLoopDirective(D);
2663
597
  Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE;
2664
597
}
2665
2666
34
void ASTStmtWriter::VisitOMPInteropDirective(OMPInteropDirective *D) {
2667
34
  VisitStmt(D);
2668
34
  VisitOMPExecutableDirective(D);
2669
34
  Code = serialization::STMT_OMP_INTEROP_DIRECTIVE;
2670
34
}
2671
2672
20
void ASTStmtWriter::VisitOMPDispatchDirective(OMPDispatchDirective *D) {
2673
20
  VisitStmt(D);
2674
20
  VisitOMPExecutableDirective(D);
2675
20
  Record.AddSourceLocation(D->getTargetCallLoc());
2676
20
  Code = serialization::STMT_OMP_DISPATCH_DIRECTIVE;
2677
20
}
2678
2679
30
void ASTStmtWriter::VisitOMPMaskedDirective(OMPMaskedDirective *D) {
2680
30
  VisitStmt(D);
2681
30
  VisitOMPExecutableDirective(D);
2682
30
  Code = serialization::STMT_OMP_MASKED_DIRECTIVE;
2683
30
}
2684
2685
0
void ASTStmtWriter::VisitOMPGenericLoopDirective(OMPGenericLoopDirective *D) {
2686
0
  VisitOMPLoopDirective(D);
2687
0
  Code = serialization::STMT_OMP_GENERIC_LOOP_DIRECTIVE;
2688
0
}
2689
2690
void ASTStmtWriter::VisitOMPTeamsGenericLoopDirective(
2691
67
    OMPTeamsGenericLoopDirective *D) {
2692
67
  VisitOMPLoopDirective(D);
2693
67
  Code = serialization::STMT_OMP_TEAMS_GENERIC_LOOP_DIRECTIVE;
2694
67
}
2695
2696
void ASTStmtWriter::VisitOMPTargetTeamsGenericLoopDirective(
2697
146
    OMPTargetTeamsGenericLoopDirective *D) {
2698
146
  VisitOMPLoopDirective(D);
2699
146
  Code = serialization::STMT_OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVE;
2700
146
}
2701
2702
void ASTStmtWriter::VisitOMPParallelGenericLoopDirective(
2703
8
    OMPParallelGenericLoopDirective *D) {
2704
8
  VisitOMPLoopDirective(D);
2705
8
  Code = serialization::STMT_OMP_PARALLEL_GENERIC_LOOP_DIRECTIVE;
2706
8
}
2707
2708
void ASTStmtWriter::VisitOMPTargetParallelGenericLoopDirective(
2709
211
    OMPTargetParallelGenericLoopDirective *D) {
2710
211
  VisitOMPLoopDirective(D);
2711
211
  Code = serialization::STMT_OMP_TARGET_PARALLEL_GENERIC_LOOP_DIRECTIVE;
2712
211
}
2713
2714
//===----------------------------------------------------------------------===//
2715
// ASTWriter Implementation
2716
//===----------------------------------------------------------------------===//
2717
2718
1.02k
unsigned ASTWriter::RecordSwitchCaseID(SwitchCase *S) {
2719
1.02k
  assert(!SwitchCaseIDs.contains(S) && "SwitchCase recorded twice");
2720
1.02k
  unsigned NextID = SwitchCaseIDs.size();
2721
1.02k
  SwitchCaseIDs[S] = NextID;
2722
1.02k
  return NextID;
2723
1.02k
}
2724
2725
1.02k
unsigned ASTWriter::getSwitchCaseID(SwitchCase *S) {
2726
1.02k
  assert(SwitchCaseIDs.contains(S) && "SwitchCase hasn't been seen yet");
2727
1.02k
  return SwitchCaseIDs[S];
2728
1.02k
}
2729
2730
94.2k
void ASTWriter::ClearSwitchCaseIDs() {
2731
94.2k
  SwitchCaseIDs.clear();
2732
94.2k
}
2733
2734
/// Write the given substatement or subexpression to the
2735
/// bitstream.
2736
3.39M
void ASTWriter::WriteSubStmt(Stmt *S) {
2737
3.39M
  RecordData Record;
2738
3.39M
  ASTStmtWriter Writer(*this, Record);
2739
3.39M
  ++NumStatements;
2740
2741
3.39M
  if (!S) {
2742
222k
    Stream.EmitRecord(serialization::STMT_NULL_PTR, Record);
2743
222k
    return;
2744
222k
  }
2745
2746
3.17M
  llvm::DenseMap<Stmt *, uint64_t>::iterator I = SubStmtEntries.find(S);
2747
3.17M
  if (I != SubStmtEntries.end()) {
2748
264k
    Record.push_back(I->second);
2749
264k
    Stream.EmitRecord(serialization::STMT_REF_PTR, Record);
2750
264k
    return;
2751
264k
  }
2752
2753
2.91M
#ifndef NDEBUG
2754
2.91M
  assert(!ParentStmts.count(S) && "There is a Stmt cycle!");
2755
2756
2.91M
  struct ParentStmtInserterRAII {
2757
2.91M
    Stmt *S;
2758
2.91M
    llvm::DenseSet<Stmt *> &ParentStmts;
2759
2760
2.91M
    ParentStmtInserterRAII(Stmt *S, llvm::DenseSet<Stmt *> &ParentStmts)
2761
2.91M
      : S(S), ParentStmts(ParentStmts) {
2762
2.91M
      ParentStmts.insert(S);
2763
2.91M
    }
2764
2.91M
    ~ParentStmtInserterRAII() {
2765
2.91M
      ParentStmts.erase(S);
2766
2.91M
    }
2767
2.91M
  };
2768
2769
2.91M
  ParentStmtInserterRAII ParentStmtInserter(S, ParentStmts);
2770
2.91M
#endif
2771
2772
2.91M
  Writer.Visit(S);
2773
2774
2.91M
  uint64_t Offset = Writer.Emit();
2775
2.91M
  SubStmtEntries[S] = Offset;
2776
2.91M
}
2777
2778
/// Flush all of the statements that have been added to the
2779
/// queue via AddStmt().
2780
2.64M
void ASTRecordWriter::FlushStmts() {
2781
  // We expect to be the only consumer of the two temporary statement maps,
2782
  // assert that they are empty.
2783
2.64M
  assert(Writer->SubStmtEntries.empty() && "unexpected entries in sub-stmt map");
2784
2.64M
  assert(Writer->ParentStmts.empty() && "unexpected entries in parent stmt map");
2785
2786
3.03M
  
for (unsigned I = 0, N = StmtsToEmit.size(); 2.64M
I != N;
++I383k
) {
2787
383k
    Writer->WriteSubStmt(StmtsToEmit[I]);
2788
2789
383k
    assert(N == StmtsToEmit.size() && "record modified while being written!");
2790
2791
    // Note that we are at the end of a full expression. Any
2792
    // expression records that follow this one are part of a different
2793
    // expression.
2794
383k
    Writer->Stream.EmitRecord(serialization::STMT_STOP, ArrayRef<uint32_t>());
2795
2796
383k
    Writer->SubStmtEntries.clear();
2797
383k
    Writer->ParentStmts.clear();
2798
383k
  }
2799
2800
2.64M
  StmtsToEmit.clear();
2801
2.64M
}
2802
2803
2.91M
void ASTRecordWriter::FlushSubStmts() {
2804
  // For a nested statement, write out the substatements in reverse order (so
2805
  // that a simple stack machine can be used when loading), and don't emit a
2806
  // STMT_STOP after each one.
2807
5.92M
  for (unsigned I = 0, N = StmtsToEmit.size(); I != N; 
++I3.01M
) {
2808
3.01M
    Writer->WriteSubStmt(StmtsToEmit[N - I - 1]);
2809
3.01M
    assert(N == StmtsToEmit.size() && "record modified while being written!");
2810
3.01M
  }
2811
2812
2.91M
  StmtsToEmit.clear();
2813
2.91M
}