1 //===--- ASTWriterStmt.cpp - Statement and Expression Serialization -------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// Implements serialization for Statements and Expressions.
13 //===----------------------------------------------------------------------===//
15 #include "clang/Serialization/ASTWriter.h"
16 #include "clang/AST/ASTContext.h"
17 #include "clang/AST/DeclCXX.h"
18 #include "clang/AST/DeclObjC.h"
19 #include "clang/AST/DeclTemplate.h"
20 #include "clang/AST/StmtVisitor.h"
21 #include "clang/Lex/Token.h"
22 #include "llvm/Bitcode/BitstreamWriter.h"
23 using namespace clang;
25 //===----------------------------------------------------------------------===//
26 // Statement/expression serialization
27 //===----------------------------------------------------------------------===//
31 class ASTStmtWriter : public StmtVisitor<ASTStmtWriter, void> {
33 ASTRecordWriter Record;
35 serialization::StmtCode Code;
39 ASTStmtWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
40 : Writer(Writer), Record(Writer, Record),
41 Code(serialization::STMT_NULL_PTR), AbbrevToUse(0) {}
43 ASTStmtWriter(const ASTStmtWriter&) = delete;
46 assert(Code != serialization::STMT_NULL_PTR &&
47 "unhandled sub-statement writing AST file");
48 return Record.EmitStmt(Code, AbbrevToUse);
51 void AddTemplateKWAndArgsInfo(const ASTTemplateKWAndArgsInfo &ArgInfo,
52 const TemplateArgumentLoc *Args);
54 void VisitStmt(Stmt *S);
55 #define STMT(Type, Base) \
56 void Visit##Type(Type *);
57 #include "clang/AST/StmtNodes.inc"
61 void ASTStmtWriter::AddTemplateKWAndArgsInfo(
62 const ASTTemplateKWAndArgsInfo &ArgInfo, const TemplateArgumentLoc *Args) {
63 Record.AddSourceLocation(ArgInfo.TemplateKWLoc);
64 Record.AddSourceLocation(ArgInfo.LAngleLoc);
65 Record.AddSourceLocation(ArgInfo.RAngleLoc);
66 for (unsigned i = 0; i != ArgInfo.NumTemplateArgs; ++i)
67 Record.AddTemplateArgumentLoc(Args[i]);
70 void ASTStmtWriter::VisitStmt(Stmt *S) {
73 void ASTStmtWriter::VisitNullStmt(NullStmt *S) {
75 Record.AddSourceLocation(S->getSemiLoc());
76 Record.push_back(S->NullStmtBits.HasLeadingEmptyMacro);
77 Code = serialization::STMT_NULL;
80 void ASTStmtWriter::VisitCompoundStmt(CompoundStmt *S) {
82 Record.push_back(S->size());
83 for (auto *CS : S->body())
85 Record.AddSourceLocation(S->getLBracLoc());
86 Record.AddSourceLocation(S->getRBracLoc());
87 Code = serialization::STMT_COMPOUND;
90 void ASTStmtWriter::VisitSwitchCase(SwitchCase *S) {
92 Record.push_back(Writer.getSwitchCaseID(S));
93 Record.AddSourceLocation(S->getKeywordLoc());
94 Record.AddSourceLocation(S->getColonLoc());
97 void ASTStmtWriter::VisitCaseStmt(CaseStmt *S) {
99 Record.push_back(S->caseStmtIsGNURange());
100 Record.AddStmt(S->getLHS());
101 Record.AddStmt(S->getSubStmt());
102 if (S->caseStmtIsGNURange()) {
103 Record.AddStmt(S->getRHS());
104 Record.AddSourceLocation(S->getEllipsisLoc());
106 Code = serialization::STMT_CASE;
109 void ASTStmtWriter::VisitDefaultStmt(DefaultStmt *S) {
111 Record.AddStmt(S->getSubStmt());
112 Code = serialization::STMT_DEFAULT;
115 void ASTStmtWriter::VisitLabelStmt(LabelStmt *S) {
117 Record.AddDeclRef(S->getDecl());
118 Record.AddStmt(S->getSubStmt());
119 Record.AddSourceLocation(S->getIdentLoc());
120 Code = serialization::STMT_LABEL;
123 void ASTStmtWriter::VisitAttributedStmt(AttributedStmt *S) {
125 Record.push_back(S->getAttrs().size());
126 Record.AddAttributes(S->getAttrs());
127 Record.AddStmt(S->getSubStmt());
128 Record.AddSourceLocation(S->getAttrLoc());
129 Code = serialization::STMT_ATTRIBUTED;
132 void ASTStmtWriter::VisitIfStmt(IfStmt *S) {
135 bool HasElse = S->getElse() != nullptr;
136 bool HasVar = S->getConditionVariableDeclStmt() != nullptr;
137 bool HasInit = S->getInit() != nullptr;
139 Record.push_back(S->isConstexpr());
140 Record.push_back(HasElse);
141 Record.push_back(HasVar);
142 Record.push_back(HasInit);
144 Record.AddStmt(S->getCond());
145 Record.AddStmt(S->getThen());
147 Record.AddStmt(S->getElse());
149 Record.AddDeclRef(S->getConditionVariable());
151 Record.AddStmt(S->getInit());
153 Record.AddSourceLocation(S->getIfLoc());
155 Record.AddSourceLocation(S->getElseLoc());
157 Code = serialization::STMT_IF;
160 void ASTStmtWriter::VisitSwitchStmt(SwitchStmt *S) {
163 bool HasInit = S->getInit() != nullptr;
164 bool HasVar = S->getConditionVariableDeclStmt() != nullptr;
165 Record.push_back(HasInit);
166 Record.push_back(HasVar);
167 Record.push_back(S->isAllEnumCasesCovered());
169 Record.AddStmt(S->getCond());
170 Record.AddStmt(S->getBody());
172 Record.AddStmt(S->getInit());
174 Record.AddDeclRef(S->getConditionVariable());
176 Record.AddSourceLocation(S->getSwitchLoc());
178 for (SwitchCase *SC = S->getSwitchCaseList(); SC;
179 SC = SC->getNextSwitchCase())
180 Record.push_back(Writer.RecordSwitchCaseID(SC));
181 Code = serialization::STMT_SWITCH;
184 void ASTStmtWriter::VisitWhileStmt(WhileStmt *S) {
187 bool HasVar = S->getConditionVariableDeclStmt() != nullptr;
188 Record.push_back(HasVar);
190 Record.AddStmt(S->getCond());
191 Record.AddStmt(S->getBody());
193 Record.AddDeclRef(S->getConditionVariable());
195 Record.AddSourceLocation(S->getWhileLoc());
196 Code = serialization::STMT_WHILE;
199 void ASTStmtWriter::VisitDoStmt(DoStmt *S) {
201 Record.AddStmt(S->getCond());
202 Record.AddStmt(S->getBody());
203 Record.AddSourceLocation(S->getDoLoc());
204 Record.AddSourceLocation(S->getWhileLoc());
205 Record.AddSourceLocation(S->getRParenLoc());
206 Code = serialization::STMT_DO;
209 void ASTStmtWriter::VisitForStmt(ForStmt *S) {
211 Record.AddStmt(S->getInit());
212 Record.AddStmt(S->getCond());
213 Record.AddDeclRef(S->getConditionVariable());
214 Record.AddStmt(S->getInc());
215 Record.AddStmt(S->getBody());
216 Record.AddSourceLocation(S->getForLoc());
217 Record.AddSourceLocation(S->getLParenLoc());
218 Record.AddSourceLocation(S->getRParenLoc());
219 Code = serialization::STMT_FOR;
222 void ASTStmtWriter::VisitGotoStmt(GotoStmt *S) {
224 Record.AddDeclRef(S->getLabel());
225 Record.AddSourceLocation(S->getGotoLoc());
226 Record.AddSourceLocation(S->getLabelLoc());
227 Code = serialization::STMT_GOTO;
230 void ASTStmtWriter::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
232 Record.AddSourceLocation(S->getGotoLoc());
233 Record.AddSourceLocation(S->getStarLoc());
234 Record.AddStmt(S->getTarget());
235 Code = serialization::STMT_INDIRECT_GOTO;
238 void ASTStmtWriter::VisitContinueStmt(ContinueStmt *S) {
240 Record.AddSourceLocation(S->getContinueLoc());
241 Code = serialization::STMT_CONTINUE;
244 void ASTStmtWriter::VisitBreakStmt(BreakStmt *S) {
246 Record.AddSourceLocation(S->getBreakLoc());
247 Code = serialization::STMT_BREAK;
250 void ASTStmtWriter::VisitReturnStmt(ReturnStmt *S) {
253 bool HasNRVOCandidate = S->getNRVOCandidate() != nullptr;
254 Record.push_back(HasNRVOCandidate);
256 Record.AddStmt(S->getRetValue());
257 if (HasNRVOCandidate)
258 Record.AddDeclRef(S->getNRVOCandidate());
260 Record.AddSourceLocation(S->getReturnLoc());
261 Code = serialization::STMT_RETURN;
264 void ASTStmtWriter::VisitDeclStmt(DeclStmt *S) {
266 Record.AddSourceLocation(S->getBeginLoc());
267 Record.AddSourceLocation(S->getEndLoc());
268 DeclGroupRef DG = S->getDeclGroup();
269 for (DeclGroupRef::iterator D = DG.begin(), DEnd = DG.end(); D != DEnd; ++D)
270 Record.AddDeclRef(*D);
271 Code = serialization::STMT_DECL;
274 void ASTStmtWriter::VisitAsmStmt(AsmStmt *S) {
276 Record.push_back(S->getNumOutputs());
277 Record.push_back(S->getNumInputs());
278 Record.push_back(S->getNumClobbers());
279 Record.AddSourceLocation(S->getAsmLoc());
280 Record.push_back(S->isVolatile());
281 Record.push_back(S->isSimple());
284 void ASTStmtWriter::VisitGCCAsmStmt(GCCAsmStmt *S) {
286 Record.AddSourceLocation(S->getRParenLoc());
287 Record.AddStmt(S->getAsmString());
290 for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
291 Record.AddIdentifierRef(S->getOutputIdentifier(I));
292 Record.AddStmt(S->getOutputConstraintLiteral(I));
293 Record.AddStmt(S->getOutputExpr(I));
297 for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
298 Record.AddIdentifierRef(S->getInputIdentifier(I));
299 Record.AddStmt(S->getInputConstraintLiteral(I));
300 Record.AddStmt(S->getInputExpr(I));
304 for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
305 Record.AddStmt(S->getClobberStringLiteral(I));
307 Code = serialization::STMT_GCCASM;
310 void ASTStmtWriter::VisitMSAsmStmt(MSAsmStmt *S) {
312 Record.AddSourceLocation(S->getLBraceLoc());
313 Record.AddSourceLocation(S->getEndLoc());
314 Record.push_back(S->getNumAsmToks());
315 Record.AddString(S->getAsmString());
318 for (unsigned I = 0, N = S->getNumAsmToks(); I != N; ++I) {
319 // FIXME: Move this to ASTRecordWriter?
320 Writer.AddToken(S->getAsmToks()[I], Record.getRecordData());
324 for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I) {
325 Record.AddString(S->getClobber(I));
329 for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
330 Record.AddStmt(S->getOutputExpr(I));
331 Record.AddString(S->getOutputConstraint(I));
335 for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
336 Record.AddStmt(S->getInputExpr(I));
337 Record.AddString(S->getInputConstraint(I));
340 Code = serialization::STMT_MSASM;
343 void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt *CoroStmt) {
345 Record.push_back(CoroStmt->getParamMoves().size());
346 for (Stmt *S : CoroStmt->children())
348 Code = serialization::STMT_COROUTINE_BODY;
351 void ASTStmtWriter::VisitCoreturnStmt(CoreturnStmt *S) {
353 Record.AddSourceLocation(S->getKeywordLoc());
354 Record.AddStmt(S->getOperand());
355 Record.AddStmt(S->getPromiseCall());
356 Record.push_back(S->isImplicit());
357 Code = serialization::STMT_CORETURN;
360 void ASTStmtWriter::VisitCoroutineSuspendExpr(CoroutineSuspendExpr *E) {
362 Record.AddSourceLocation(E->getKeywordLoc());
363 for (Stmt *S : E->children())
365 Record.AddStmt(E->getOpaqueValue());
368 void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr *E) {
369 VisitCoroutineSuspendExpr(E);
370 Record.push_back(E->isImplicit());
371 Code = serialization::EXPR_COAWAIT;
374 void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr *E) {
375 VisitCoroutineSuspendExpr(E);
376 Code = serialization::EXPR_COYIELD;
379 void ASTStmtWriter::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
381 Record.AddSourceLocation(E->getKeywordLoc());
382 for (Stmt *S : E->children())
384 Code = serialization::EXPR_DEPENDENT_COAWAIT;
387 void ASTStmtWriter::VisitCapturedStmt(CapturedStmt *S) {
390 Record.push_back(std::distance(S->capture_begin(), S->capture_end()));
392 // CapturedDecl and captured region kind
393 Record.AddDeclRef(S->getCapturedDecl());
394 Record.push_back(S->getCapturedRegionKind());
396 Record.AddDeclRef(S->getCapturedRecordDecl());
399 for (auto *I : S->capture_inits())
403 Record.AddStmt(S->getCapturedStmt());
406 for (const auto &I : S->captures()) {
407 if (I.capturesThis() || I.capturesVariableArrayType())
408 Record.AddDeclRef(nullptr);
410 Record.AddDeclRef(I.getCapturedVar());
411 Record.push_back(I.getCaptureKind());
412 Record.AddSourceLocation(I.getLocation());
415 Code = serialization::STMT_CAPTURED;
418 void ASTStmtWriter::VisitExpr(Expr *E) {
420 Record.AddTypeRef(E->getType());
421 Record.push_back(E->isTypeDependent());
422 Record.push_back(E->isValueDependent());
423 Record.push_back(E->isInstantiationDependent());
424 Record.push_back(E->containsUnexpandedParameterPack());
425 Record.push_back(E->getValueKind());
426 Record.push_back(E->getObjectKind());
429 void ASTStmtWriter::VisitConstantExpr(ConstantExpr *E) {
431 Record.AddStmt(E->getSubExpr());
432 Code = serialization::EXPR_CONSTANT;
435 void ASTStmtWriter::VisitPredefinedExpr(PredefinedExpr *E) {
438 bool HasFunctionName = E->getFunctionName() != nullptr;
439 Record.push_back(HasFunctionName);
440 Record.push_back(E->getIdentKind()); // FIXME: stable encoding
441 Record.AddSourceLocation(E->getLocation());
443 Record.AddStmt(E->getFunctionName());
444 Code = serialization::EXPR_PREDEFINED;
447 void ASTStmtWriter::VisitDeclRefExpr(DeclRefExpr *E) {
450 Record.push_back(E->hasQualifier());
451 Record.push_back(E->getDecl() != E->getFoundDecl());
452 Record.push_back(E->hasTemplateKWAndArgsInfo());
453 Record.push_back(E->hadMultipleCandidates());
454 Record.push_back(E->refersToEnclosingVariableOrCapture());
456 if (E->hasTemplateKWAndArgsInfo()) {
457 unsigned NumTemplateArgs = E->getNumTemplateArgs();
458 Record.push_back(NumTemplateArgs);
461 DeclarationName::NameKind nk = (E->getDecl()->getDeclName().getNameKind());
463 if ((!E->hasTemplateKWAndArgsInfo()) && (!E->hasQualifier()) &&
464 (E->getDecl() == E->getFoundDecl()) &&
465 nk == DeclarationName::Identifier) {
466 AbbrevToUse = Writer.getDeclRefExprAbbrev();
469 if (E->hasQualifier())
470 Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
472 if (E->getDecl() != E->getFoundDecl())
473 Record.AddDeclRef(E->getFoundDecl());
475 if (E->hasTemplateKWAndArgsInfo())
476 AddTemplateKWAndArgsInfo(*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
477 E->getTrailingObjects<TemplateArgumentLoc>());
479 Record.AddDeclRef(E->getDecl());
480 Record.AddSourceLocation(E->getLocation());
481 Record.AddDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName());
482 Code = serialization::EXPR_DECL_REF;
485 void ASTStmtWriter::VisitIntegerLiteral(IntegerLiteral *E) {
487 Record.AddSourceLocation(E->getLocation());
488 Record.AddAPInt(E->getValue());
490 if (E->getValue().getBitWidth() == 32) {
491 AbbrevToUse = Writer.getIntegerLiteralAbbrev();
494 Code = serialization::EXPR_INTEGER_LITERAL;
497 void ASTStmtWriter::VisitFixedPointLiteral(FixedPointLiteral *E) {
499 Record.AddSourceLocation(E->getLocation());
500 Record.AddAPInt(E->getValue());
501 Code = serialization::EXPR_INTEGER_LITERAL;
504 void ASTStmtWriter::VisitFloatingLiteral(FloatingLiteral *E) {
506 Record.push_back(E->getRawSemantics());
507 Record.push_back(E->isExact());
508 Record.AddAPFloat(E->getValue());
509 Record.AddSourceLocation(E->getLocation());
510 Code = serialization::EXPR_FLOATING_LITERAL;
513 void ASTStmtWriter::VisitImaginaryLiteral(ImaginaryLiteral *E) {
515 Record.AddStmt(E->getSubExpr());
516 Code = serialization::EXPR_IMAGINARY_LITERAL;
519 void ASTStmtWriter::VisitStringLiteral(StringLiteral *E) {
522 // Store the various bits of data of StringLiteral.
523 Record.push_back(E->getNumConcatenated());
524 Record.push_back(E->getLength());
525 Record.push_back(E->getCharByteWidth());
526 Record.push_back(E->getKind());
527 Record.push_back(E->isPascal());
529 // Store the trailing array of SourceLocation.
530 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
531 Record.AddSourceLocation(E->getStrTokenLoc(I));
533 // Store the trailing array of char holding the string data.
534 StringRef StrData = E->getBytes();
535 for (unsigned I = 0, N = E->getByteLength(); I != N; ++I)
536 Record.push_back(StrData[I]);
538 Code = serialization::EXPR_STRING_LITERAL;
541 void ASTStmtWriter::VisitCharacterLiteral(CharacterLiteral *E) {
543 Record.push_back(E->getValue());
544 Record.AddSourceLocation(E->getLocation());
545 Record.push_back(E->getKind());
547 AbbrevToUse = Writer.getCharacterLiteralAbbrev();
549 Code = serialization::EXPR_CHARACTER_LITERAL;
552 void ASTStmtWriter::VisitParenExpr(ParenExpr *E) {
554 Record.AddSourceLocation(E->getLParen());
555 Record.AddSourceLocation(E->getRParen());
556 Record.AddStmt(E->getSubExpr());
557 Code = serialization::EXPR_PAREN;
560 void ASTStmtWriter::VisitParenListExpr(ParenListExpr *E) {
562 Record.push_back(E->getNumExprs());
563 for (auto *SubStmt : E->exprs())
564 Record.AddStmt(SubStmt);
565 Record.AddSourceLocation(E->getLParenLoc());
566 Record.AddSourceLocation(E->getRParenLoc());
567 Code = serialization::EXPR_PAREN_LIST;
570 void ASTStmtWriter::VisitUnaryOperator(UnaryOperator *E) {
572 Record.AddStmt(E->getSubExpr());
573 Record.push_back(E->getOpcode()); // FIXME: stable encoding
574 Record.AddSourceLocation(E->getOperatorLoc());
575 Record.push_back(E->canOverflow());
576 Code = serialization::EXPR_UNARY_OPERATOR;
579 void ASTStmtWriter::VisitOffsetOfExpr(OffsetOfExpr *E) {
581 Record.push_back(E->getNumComponents());
582 Record.push_back(E->getNumExpressions());
583 Record.AddSourceLocation(E->getOperatorLoc());
584 Record.AddSourceLocation(E->getRParenLoc());
585 Record.AddTypeSourceInfo(E->getTypeSourceInfo());
586 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
587 const OffsetOfNode &ON = E->getComponent(I);
588 Record.push_back(ON.getKind()); // FIXME: Stable encoding
589 Record.AddSourceLocation(ON.getSourceRange().getBegin());
590 Record.AddSourceLocation(ON.getSourceRange().getEnd());
591 switch (ON.getKind()) {
592 case OffsetOfNode::Array:
593 Record.push_back(ON.getArrayExprIndex());
596 case OffsetOfNode::Field:
597 Record.AddDeclRef(ON.getField());
600 case OffsetOfNode::Identifier:
601 Record.AddIdentifierRef(ON.getFieldName());
604 case OffsetOfNode::Base:
605 Record.AddCXXBaseSpecifier(*ON.getBase());
609 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
610 Record.AddStmt(E->getIndexExpr(I));
611 Code = serialization::EXPR_OFFSETOF;
614 void ASTStmtWriter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
616 Record.push_back(E->getKind());
617 if (E->isArgumentType())
618 Record.AddTypeSourceInfo(E->getArgumentTypeInfo());
621 Record.AddStmt(E->getArgumentExpr());
623 Record.AddSourceLocation(E->getOperatorLoc());
624 Record.AddSourceLocation(E->getRParenLoc());
625 Code = serialization::EXPR_SIZEOF_ALIGN_OF;
628 void ASTStmtWriter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
630 Record.AddStmt(E->getLHS());
631 Record.AddStmt(E->getRHS());
632 Record.AddSourceLocation(E->getRBracketLoc());
633 Code = serialization::EXPR_ARRAY_SUBSCRIPT;
636 void ASTStmtWriter::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
638 Record.AddStmt(E->getBase());
639 Record.AddStmt(E->getLowerBound());
640 Record.AddStmt(E->getLength());
641 Record.AddSourceLocation(E->getColonLoc());
642 Record.AddSourceLocation(E->getRBracketLoc());
643 Code = serialization::EXPR_OMP_ARRAY_SECTION;
646 void ASTStmtWriter::VisitCallExpr(CallExpr *E) {
648 Record.push_back(E->getNumArgs());
649 Record.AddSourceLocation(E->getRParenLoc());
650 Record.AddStmt(E->getCallee());
651 for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
652 Arg != ArgEnd; ++Arg)
653 Record.AddStmt(*Arg);
654 Record.push_back(static_cast<unsigned>(E->getADLCallKind()));
655 Code = serialization::EXPR_CALL;
658 void ASTStmtWriter::VisitMemberExpr(MemberExpr *E) {
659 // Don't call VisitExpr, we'll write everything here.
661 Record.push_back(E->hasQualifier());
662 if (E->hasQualifier())
663 Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
665 Record.push_back(E->hasTemplateKWAndArgsInfo());
666 if (E->hasTemplateKWAndArgsInfo()) {
667 Record.AddSourceLocation(E->getTemplateKeywordLoc());
668 unsigned NumTemplateArgs = E->getNumTemplateArgs();
669 Record.push_back(NumTemplateArgs);
670 Record.AddSourceLocation(E->getLAngleLoc());
671 Record.AddSourceLocation(E->getRAngleLoc());
672 for (unsigned i=0; i != NumTemplateArgs; ++i)
673 Record.AddTemplateArgumentLoc(E->getTemplateArgs()[i]);
676 Record.push_back(E->hadMultipleCandidates());
678 DeclAccessPair FoundDecl = E->getFoundDecl();
679 Record.AddDeclRef(FoundDecl.getDecl());
680 Record.push_back(FoundDecl.getAccess());
682 Record.AddTypeRef(E->getType());
683 Record.push_back(E->getValueKind());
684 Record.push_back(E->getObjectKind());
685 Record.AddStmt(E->getBase());
686 Record.AddDeclRef(E->getMemberDecl());
687 Record.AddSourceLocation(E->getMemberLoc());
688 Record.push_back(E->isArrow());
689 Record.AddSourceLocation(E->getOperatorLoc());
690 Record.AddDeclarationNameLoc(E->MemberDNLoc,
691 E->getMemberDecl()->getDeclName());
692 Code = serialization::EXPR_MEMBER;
695 void ASTStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr *E) {
697 Record.AddStmt(E->getBase());
698 Record.AddSourceLocation(E->getIsaMemberLoc());
699 Record.AddSourceLocation(E->getOpLoc());
700 Record.push_back(E->isArrow());
701 Code = serialization::EXPR_OBJC_ISA;
705 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
707 Record.AddStmt(E->getSubExpr());
708 Record.push_back(E->shouldCopy());
709 Code = serialization::EXPR_OBJC_INDIRECT_COPY_RESTORE;
712 void ASTStmtWriter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
713 VisitExplicitCastExpr(E);
714 Record.AddSourceLocation(E->getLParenLoc());
715 Record.AddSourceLocation(E->getBridgeKeywordLoc());
716 Record.push_back(E->getBridgeKind()); // FIXME: Stable encoding
717 Code = serialization::EXPR_OBJC_BRIDGED_CAST;
720 void ASTStmtWriter::VisitCastExpr(CastExpr *E) {
722 Record.push_back(E->path_size());
723 Record.AddStmt(E->getSubExpr());
724 Record.push_back(E->getCastKind()); // FIXME: stable encoding
726 for (CastExpr::path_iterator
727 PI = E->path_begin(), PE = E->path_end(); PI != PE; ++PI)
728 Record.AddCXXBaseSpecifier(**PI);
731 void ASTStmtWriter::VisitBinaryOperator(BinaryOperator *E) {
733 Record.AddStmt(E->getLHS());
734 Record.AddStmt(E->getRHS());
735 Record.push_back(E->getOpcode()); // FIXME: stable encoding
736 Record.AddSourceLocation(E->getOperatorLoc());
737 Record.push_back(E->getFPFeatures().getInt());
738 Code = serialization::EXPR_BINARY_OPERATOR;
741 void ASTStmtWriter::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
742 VisitBinaryOperator(E);
743 Record.AddTypeRef(E->getComputationLHSType());
744 Record.AddTypeRef(E->getComputationResultType());
745 Code = serialization::EXPR_COMPOUND_ASSIGN_OPERATOR;
748 void ASTStmtWriter::VisitConditionalOperator(ConditionalOperator *E) {
750 Record.AddStmt(E->getCond());
751 Record.AddStmt(E->getLHS());
752 Record.AddStmt(E->getRHS());
753 Record.AddSourceLocation(E->getQuestionLoc());
754 Record.AddSourceLocation(E->getColonLoc());
755 Code = serialization::EXPR_CONDITIONAL_OPERATOR;
759 ASTStmtWriter::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
761 Record.AddStmt(E->getOpaqueValue());
762 Record.AddStmt(E->getCommon());
763 Record.AddStmt(E->getCond());
764 Record.AddStmt(E->getTrueExpr());
765 Record.AddStmt(E->getFalseExpr());
766 Record.AddSourceLocation(E->getQuestionLoc());
767 Record.AddSourceLocation(E->getColonLoc());
768 Code = serialization::EXPR_BINARY_CONDITIONAL_OPERATOR;
771 void ASTStmtWriter::VisitImplicitCastExpr(ImplicitCastExpr *E) {
773 Record.push_back(E->isPartOfExplicitCast());
775 if (E->path_size() == 0)
776 AbbrevToUse = Writer.getExprImplicitCastAbbrev();
778 Code = serialization::EXPR_IMPLICIT_CAST;
781 void ASTStmtWriter::VisitExplicitCastExpr(ExplicitCastExpr *E) {
783 Record.AddTypeSourceInfo(E->getTypeInfoAsWritten());
786 void ASTStmtWriter::VisitCStyleCastExpr(CStyleCastExpr *E) {
787 VisitExplicitCastExpr(E);
788 Record.AddSourceLocation(E->getLParenLoc());
789 Record.AddSourceLocation(E->getRParenLoc());
790 Code = serialization::EXPR_CSTYLE_CAST;
793 void ASTStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
795 Record.AddSourceLocation(E->getLParenLoc());
796 Record.AddTypeSourceInfo(E->getTypeSourceInfo());
797 Record.AddStmt(E->getInitializer());
798 Record.push_back(E->isFileScope());
799 Code = serialization::EXPR_COMPOUND_LITERAL;
802 void ASTStmtWriter::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
804 Record.AddStmt(E->getBase());
805 Record.AddIdentifierRef(&E->getAccessor());
806 Record.AddSourceLocation(E->getAccessorLoc());
807 Code = serialization::EXPR_EXT_VECTOR_ELEMENT;
810 void ASTStmtWriter::VisitInitListExpr(InitListExpr *E) {
812 // NOTE: only add the (possibly null) syntactic form.
813 // No need to serialize the isSemanticForm flag and the semantic form.
814 Record.AddStmt(E->getSyntacticForm());
815 Record.AddSourceLocation(E->getLBraceLoc());
816 Record.AddSourceLocation(E->getRBraceLoc());
817 bool isArrayFiller = E->ArrayFillerOrUnionFieldInit.is<Expr*>();
818 Record.push_back(isArrayFiller);
820 Record.AddStmt(E->getArrayFiller());
822 Record.AddDeclRef(E->getInitializedFieldInUnion());
823 Record.push_back(E->hadArrayRangeDesignator());
824 Record.push_back(E->getNumInits());
826 // ArrayFiller may have filled "holes" due to designated initializer.
827 // Replace them by 0 to indicate that the filler goes in that place.
828 Expr *filler = E->getArrayFiller();
829 for (unsigned I = 0, N = E->getNumInits(); I != N; ++I)
830 Record.AddStmt(E->getInit(I) != filler ? E->getInit(I) : nullptr);
832 for (unsigned I = 0, N = E->getNumInits(); I != N; ++I)
833 Record.AddStmt(E->getInit(I));
835 Code = serialization::EXPR_INIT_LIST;
838 void ASTStmtWriter::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
840 Record.push_back(E->getNumSubExprs());
841 for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
842 Record.AddStmt(E->getSubExpr(I));
843 Record.AddSourceLocation(E->getEqualOrColonLoc());
844 Record.push_back(E->usesGNUSyntax());
845 for (const DesignatedInitExpr::Designator &D : E->designators()) {
846 if (D.isFieldDesignator()) {
847 if (FieldDecl *Field = D.getField()) {
848 Record.push_back(serialization::DESIG_FIELD_DECL);
849 Record.AddDeclRef(Field);
851 Record.push_back(serialization::DESIG_FIELD_NAME);
852 Record.AddIdentifierRef(D.getFieldName());
854 Record.AddSourceLocation(D.getDotLoc());
855 Record.AddSourceLocation(D.getFieldLoc());
856 } else if (D.isArrayDesignator()) {
857 Record.push_back(serialization::DESIG_ARRAY);
858 Record.push_back(D.getFirstExprIndex());
859 Record.AddSourceLocation(D.getLBracketLoc());
860 Record.AddSourceLocation(D.getRBracketLoc());
862 assert(D.isArrayRangeDesignator() && "Unknown designator");
863 Record.push_back(serialization::DESIG_ARRAY_RANGE);
864 Record.push_back(D.getFirstExprIndex());
865 Record.AddSourceLocation(D.getLBracketLoc());
866 Record.AddSourceLocation(D.getEllipsisLoc());
867 Record.AddSourceLocation(D.getRBracketLoc());
870 Code = serialization::EXPR_DESIGNATED_INIT;
873 void ASTStmtWriter::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
875 Record.AddStmt(E->getBase());
876 Record.AddStmt(E->getUpdater());
877 Code = serialization::EXPR_DESIGNATED_INIT_UPDATE;
880 void ASTStmtWriter::VisitNoInitExpr(NoInitExpr *E) {
882 Code = serialization::EXPR_NO_INIT;
885 void ASTStmtWriter::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
887 Record.AddStmt(E->SubExprs[0]);
888 Record.AddStmt(E->SubExprs[1]);
889 Code = serialization::EXPR_ARRAY_INIT_LOOP;
892 void ASTStmtWriter::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
894 Code = serialization::EXPR_ARRAY_INIT_INDEX;
897 void ASTStmtWriter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
899 Code = serialization::EXPR_IMPLICIT_VALUE_INIT;
902 void ASTStmtWriter::VisitVAArgExpr(VAArgExpr *E) {
904 Record.AddStmt(E->getSubExpr());
905 Record.AddTypeSourceInfo(E->getWrittenTypeInfo());
906 Record.AddSourceLocation(E->getBuiltinLoc());
907 Record.AddSourceLocation(E->getRParenLoc());
908 Record.push_back(E->isMicrosoftABI());
909 Code = serialization::EXPR_VA_ARG;
912 void ASTStmtWriter::VisitAddrLabelExpr(AddrLabelExpr *E) {
914 Record.AddSourceLocation(E->getAmpAmpLoc());
915 Record.AddSourceLocation(E->getLabelLoc());
916 Record.AddDeclRef(E->getLabel());
917 Code = serialization::EXPR_ADDR_LABEL;
920 void ASTStmtWriter::VisitStmtExpr(StmtExpr *E) {
922 Record.AddStmt(E->getSubStmt());
923 Record.AddSourceLocation(E->getLParenLoc());
924 Record.AddSourceLocation(E->getRParenLoc());
925 Code = serialization::EXPR_STMT;
928 void ASTStmtWriter::VisitChooseExpr(ChooseExpr *E) {
930 Record.AddStmt(E->getCond());
931 Record.AddStmt(E->getLHS());
932 Record.AddStmt(E->getRHS());
933 Record.AddSourceLocation(E->getBuiltinLoc());
934 Record.AddSourceLocation(E->getRParenLoc());
935 Record.push_back(E->isConditionDependent() ? false : E->isConditionTrue());
936 Code = serialization::EXPR_CHOOSE;
939 void ASTStmtWriter::VisitGNUNullExpr(GNUNullExpr *E) {
941 Record.AddSourceLocation(E->getTokenLocation());
942 Code = serialization::EXPR_GNU_NULL;
945 void ASTStmtWriter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
947 Record.push_back(E->getNumSubExprs());
948 for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
949 Record.AddStmt(E->getExpr(I));
950 Record.AddSourceLocation(E->getBuiltinLoc());
951 Record.AddSourceLocation(E->getRParenLoc());
952 Code = serialization::EXPR_SHUFFLE_VECTOR;
955 void ASTStmtWriter::VisitConvertVectorExpr(ConvertVectorExpr *E) {
957 Record.AddSourceLocation(E->getBuiltinLoc());
958 Record.AddSourceLocation(E->getRParenLoc());
959 Record.AddTypeSourceInfo(E->getTypeSourceInfo());
960 Record.AddStmt(E->getSrcExpr());
961 Code = serialization::EXPR_CONVERT_VECTOR;
964 void ASTStmtWriter::VisitBlockExpr(BlockExpr *E) {
966 Record.AddDeclRef(E->getBlockDecl());
967 Code = serialization::EXPR_BLOCK;
970 void ASTStmtWriter::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
972 Record.push_back(E->getNumAssocs());
974 Record.AddStmt(E->getControllingExpr());
975 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
976 Record.AddTypeSourceInfo(E->getAssocTypeSourceInfo(I));
977 Record.AddStmt(E->getAssocExpr(I));
979 Record.push_back(E->isResultDependent() ? -1U : E->getResultIndex());
981 Record.AddSourceLocation(E->getGenericLoc());
982 Record.AddSourceLocation(E->getDefaultLoc());
983 Record.AddSourceLocation(E->getRParenLoc());
984 Code = serialization::EXPR_GENERIC_SELECTION;
987 void ASTStmtWriter::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
989 Record.push_back(E->getNumSemanticExprs());
991 // Push the result index. Currently, this needs to exactly match
992 // the encoding used internally for ResultIndex.
993 unsigned result = E->getResultExprIndex();
994 result = (result == PseudoObjectExpr::NoResult ? 0 : result + 1);
995 Record.push_back(result);
997 Record.AddStmt(E->getSyntacticForm());
998 for (PseudoObjectExpr::semantics_iterator
999 i = E->semantics_begin(), e = E->semantics_end(); i != e; ++i) {
1002 Code = serialization::EXPR_PSEUDO_OBJECT;
1005 void ASTStmtWriter::VisitAtomicExpr(AtomicExpr *E) {
1007 Record.push_back(E->getOp());
1008 for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
1009 Record.AddStmt(E->getSubExprs()[I]);
1010 Record.AddSourceLocation(E->getBuiltinLoc());
1011 Record.AddSourceLocation(E->getRParenLoc());
1012 Code = serialization::EXPR_ATOMIC;
1015 //===----------------------------------------------------------------------===//
1016 // Objective-C Expressions and Statements.
1017 //===----------------------------------------------------------------------===//
1019 void ASTStmtWriter::VisitObjCStringLiteral(ObjCStringLiteral *E) {
1021 Record.AddStmt(E->getString());
1022 Record.AddSourceLocation(E->getAtLoc());
1023 Code = serialization::EXPR_OBJC_STRING_LITERAL;
1026 void ASTStmtWriter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
1028 Record.AddStmt(E->getSubExpr());
1029 Record.AddDeclRef(E->getBoxingMethod());
1030 Record.AddSourceRange(E->getSourceRange());
1031 Code = serialization::EXPR_OBJC_BOXED_EXPRESSION;
1034 void ASTStmtWriter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1036 Record.push_back(E->getNumElements());
1037 for (unsigned i = 0; i < E->getNumElements(); i++)
1038 Record.AddStmt(E->getElement(i));
1039 Record.AddDeclRef(E->getArrayWithObjectsMethod());
1040 Record.AddSourceRange(E->getSourceRange());
1041 Code = serialization::EXPR_OBJC_ARRAY_LITERAL;
1044 void ASTStmtWriter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1046 Record.push_back(E->getNumElements());
1047 Record.push_back(E->HasPackExpansions);
1048 for (unsigned i = 0; i < E->getNumElements(); i++) {
1049 ObjCDictionaryElement Element = E->getKeyValueElement(i);
1050 Record.AddStmt(Element.Key);
1051 Record.AddStmt(Element.Value);
1052 if (E->HasPackExpansions) {
1053 Record.AddSourceLocation(Element.EllipsisLoc);
1054 unsigned NumExpansions = 0;
1055 if (Element.NumExpansions)
1056 NumExpansions = *Element.NumExpansions + 1;
1057 Record.push_back(NumExpansions);
1061 Record.AddDeclRef(E->getDictWithObjectsMethod());
1062 Record.AddSourceRange(E->getSourceRange());
1063 Code = serialization::EXPR_OBJC_DICTIONARY_LITERAL;
1066 void ASTStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
1068 Record.AddTypeSourceInfo(E->getEncodedTypeSourceInfo());
1069 Record.AddSourceLocation(E->getAtLoc());
1070 Record.AddSourceLocation(E->getRParenLoc());
1071 Code = serialization::EXPR_OBJC_ENCODE;
1074 void ASTStmtWriter::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
1076 Record.AddSelectorRef(E->getSelector());
1077 Record.AddSourceLocation(E->getAtLoc());
1078 Record.AddSourceLocation(E->getRParenLoc());
1079 Code = serialization::EXPR_OBJC_SELECTOR_EXPR;
1082 void ASTStmtWriter::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
1084 Record.AddDeclRef(E->getProtocol());
1085 Record.AddSourceLocation(E->getAtLoc());
1086 Record.AddSourceLocation(E->ProtoLoc);
1087 Record.AddSourceLocation(E->getRParenLoc());
1088 Code = serialization::EXPR_OBJC_PROTOCOL_EXPR;
1091 void ASTStmtWriter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
1093 Record.AddDeclRef(E->getDecl());
1094 Record.AddSourceLocation(E->getLocation());
1095 Record.AddSourceLocation(E->getOpLoc());
1096 Record.AddStmt(E->getBase());
1097 Record.push_back(E->isArrow());
1098 Record.push_back(E->isFreeIvar());
1099 Code = serialization::EXPR_OBJC_IVAR_REF_EXPR;
1102 void ASTStmtWriter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
1104 Record.push_back(E->SetterAndMethodRefFlags.getInt());
1105 Record.push_back(E->isImplicitProperty());
1106 if (E->isImplicitProperty()) {
1107 Record.AddDeclRef(E->getImplicitPropertyGetter());
1108 Record.AddDeclRef(E->getImplicitPropertySetter());
1110 Record.AddDeclRef(E->getExplicitProperty());
1112 Record.AddSourceLocation(E->getLocation());
1113 Record.AddSourceLocation(E->getReceiverLocation());
1114 if (E->isObjectReceiver()) {
1115 Record.push_back(0);
1116 Record.AddStmt(E->getBase());
1117 } else if (E->isSuperReceiver()) {
1118 Record.push_back(1);
1119 Record.AddTypeRef(E->getSuperReceiverType());
1121 Record.push_back(2);
1122 Record.AddDeclRef(E->getClassReceiver());
1125 Code = serialization::EXPR_OBJC_PROPERTY_REF_EXPR;
1128 void ASTStmtWriter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1130 Record.AddSourceLocation(E->getRBracket());
1131 Record.AddStmt(E->getBaseExpr());
1132 Record.AddStmt(E->getKeyExpr());
1133 Record.AddDeclRef(E->getAtIndexMethodDecl());
1134 Record.AddDeclRef(E->setAtIndexMethodDecl());
1136 Code = serialization::EXPR_OBJC_SUBSCRIPT_REF_EXPR;
1139 void ASTStmtWriter::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1141 Record.push_back(E->getNumArgs());
1142 Record.push_back(E->getNumStoredSelLocs());
1143 Record.push_back(E->SelLocsKind);
1144 Record.push_back(E->isDelegateInitCall());
1145 Record.push_back(E->IsImplicit);
1146 Record.push_back((unsigned)E->getReceiverKind()); // FIXME: stable encoding
1147 switch (E->getReceiverKind()) {
1148 case ObjCMessageExpr::Instance:
1149 Record.AddStmt(E->getInstanceReceiver());
1152 case ObjCMessageExpr::Class:
1153 Record.AddTypeSourceInfo(E->getClassReceiverTypeInfo());
1156 case ObjCMessageExpr::SuperClass:
1157 case ObjCMessageExpr::SuperInstance:
1158 Record.AddTypeRef(E->getSuperType());
1159 Record.AddSourceLocation(E->getSuperLoc());
1163 if (E->getMethodDecl()) {
1164 Record.push_back(1);
1165 Record.AddDeclRef(E->getMethodDecl());
1167 Record.push_back(0);
1168 Record.AddSelectorRef(E->getSelector());
1171 Record.AddSourceLocation(E->getLeftLoc());
1172 Record.AddSourceLocation(E->getRightLoc());
1174 for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
1175 Arg != ArgEnd; ++Arg)
1176 Record.AddStmt(*Arg);
1178 SourceLocation *Locs = E->getStoredSelLocs();
1179 for (unsigned i = 0, e = E->getNumStoredSelLocs(); i != e; ++i)
1180 Record.AddSourceLocation(Locs[i]);
1182 Code = serialization::EXPR_OBJC_MESSAGE_EXPR;
1185 void ASTStmtWriter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1187 Record.AddStmt(S->getElement());
1188 Record.AddStmt(S->getCollection());
1189 Record.AddStmt(S->getBody());
1190 Record.AddSourceLocation(S->getForLoc());
1191 Record.AddSourceLocation(S->getRParenLoc());
1192 Code = serialization::STMT_OBJC_FOR_COLLECTION;
1195 void ASTStmtWriter::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1196 Record.AddStmt(S->getCatchBody());
1197 Record.AddDeclRef(S->getCatchParamDecl());
1198 Record.AddSourceLocation(S->getAtCatchLoc());
1199 Record.AddSourceLocation(S->getRParenLoc());
1200 Code = serialization::STMT_OBJC_CATCH;
1203 void ASTStmtWriter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1204 Record.AddStmt(S->getFinallyBody());
1205 Record.AddSourceLocation(S->getAtFinallyLoc());
1206 Code = serialization::STMT_OBJC_FINALLY;
1209 void ASTStmtWriter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1210 Record.AddStmt(S->getSubStmt());
1211 Record.AddSourceLocation(S->getAtLoc());
1212 Code = serialization::STMT_OBJC_AUTORELEASE_POOL;
1215 void ASTStmtWriter::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1216 Record.push_back(S->getNumCatchStmts());
1217 Record.push_back(S->getFinallyStmt() != nullptr);
1218 Record.AddStmt(S->getTryBody());
1219 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
1220 Record.AddStmt(S->getCatchStmt(I));
1221 if (S->getFinallyStmt())
1222 Record.AddStmt(S->getFinallyStmt());
1223 Record.AddSourceLocation(S->getAtTryLoc());
1224 Code = serialization::STMT_OBJC_AT_TRY;
1227 void ASTStmtWriter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1228 Record.AddStmt(S->getSynchExpr());
1229 Record.AddStmt(S->getSynchBody());
1230 Record.AddSourceLocation(S->getAtSynchronizedLoc());
1231 Code = serialization::STMT_OBJC_AT_SYNCHRONIZED;
1234 void ASTStmtWriter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1235 Record.AddStmt(S->getThrowExpr());
1236 Record.AddSourceLocation(S->getThrowLoc());
1237 Code = serialization::STMT_OBJC_AT_THROW;
1240 void ASTStmtWriter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1242 Record.push_back(E->getValue());
1243 Record.AddSourceLocation(E->getLocation());
1244 Code = serialization::EXPR_OBJC_BOOL_LITERAL;
1247 void ASTStmtWriter::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1249 Record.AddSourceRange(E->getSourceRange());
1250 Record.AddVersionTuple(E->getVersion());
1251 Code = serialization::EXPR_OBJC_AVAILABILITY_CHECK;
1254 //===----------------------------------------------------------------------===//
1255 // C++ Expressions and Statements.
1256 //===----------------------------------------------------------------------===//
1258 void ASTStmtWriter::VisitCXXCatchStmt(CXXCatchStmt *S) {
1260 Record.AddSourceLocation(S->getCatchLoc());
1261 Record.AddDeclRef(S->getExceptionDecl());
1262 Record.AddStmt(S->getHandlerBlock());
1263 Code = serialization::STMT_CXX_CATCH;
1266 void ASTStmtWriter::VisitCXXTryStmt(CXXTryStmt *S) {
1268 Record.push_back(S->getNumHandlers());
1269 Record.AddSourceLocation(S->getTryLoc());
1270 Record.AddStmt(S->getTryBlock());
1271 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1272 Record.AddStmt(S->getHandler(i));
1273 Code = serialization::STMT_CXX_TRY;
1276 void ASTStmtWriter::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1278 Record.AddSourceLocation(S->getForLoc());
1279 Record.AddSourceLocation(S->getCoawaitLoc());
1280 Record.AddSourceLocation(S->getColonLoc());
1281 Record.AddSourceLocation(S->getRParenLoc());
1282 Record.AddStmt(S->getInit());
1283 Record.AddStmt(S->getRangeStmt());
1284 Record.AddStmt(S->getBeginStmt());
1285 Record.AddStmt(S->getEndStmt());
1286 Record.AddStmt(S->getCond());
1287 Record.AddStmt(S->getInc());
1288 Record.AddStmt(S->getLoopVarStmt());
1289 Record.AddStmt(S->getBody());
1290 Code = serialization::STMT_CXX_FOR_RANGE;
1293 void ASTStmtWriter::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1295 Record.AddSourceLocation(S->getKeywordLoc());
1296 Record.push_back(S->isIfExists());
1297 Record.AddNestedNameSpecifierLoc(S->getQualifierLoc());
1298 Record.AddDeclarationNameInfo(S->getNameInfo());
1299 Record.AddStmt(S->getSubStmt());
1300 Code = serialization::STMT_MS_DEPENDENT_EXISTS;
1303 void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1305 Record.push_back(E->getOperator());
1306 Record.push_back(E->getFPFeatures().getInt());
1307 Record.AddSourceRange(E->Range);
1308 Code = serialization::EXPR_CXX_OPERATOR_CALL;
1311 void ASTStmtWriter::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
1313 Code = serialization::EXPR_CXX_MEMBER_CALL;
1316 void ASTStmtWriter::VisitCXXConstructExpr(CXXConstructExpr *E) {
1319 Record.push_back(E->getNumArgs());
1320 Record.push_back(E->isElidable());
1321 Record.push_back(E->hadMultipleCandidates());
1322 Record.push_back(E->isListInitialization());
1323 Record.push_back(E->isStdInitListInitialization());
1324 Record.push_back(E->requiresZeroInitialization());
1325 Record.push_back(E->getConstructionKind()); // FIXME: stable encoding
1326 Record.AddSourceLocation(E->getLocation());
1327 Record.AddDeclRef(E->getConstructor());
1328 Record.AddSourceRange(E->getParenOrBraceRange());
1330 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1331 Record.AddStmt(E->getArg(I));
1333 Code = serialization::EXPR_CXX_CONSTRUCT;
1336 void ASTStmtWriter::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1338 Record.AddDeclRef(E->getConstructor());
1339 Record.AddSourceLocation(E->getLocation());
1340 Record.push_back(E->constructsVBase());
1341 Record.push_back(E->inheritedFromVBase());
1342 Code = serialization::EXPR_CXX_INHERITED_CTOR_INIT;
1345 void ASTStmtWriter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1346 VisitCXXConstructExpr(E);
1347 Record.AddTypeSourceInfo(E->getTypeSourceInfo());
1348 Code = serialization::EXPR_CXX_TEMPORARY_OBJECT;
1351 void ASTStmtWriter::VisitLambdaExpr(LambdaExpr *E) {
1353 Record.push_back(E->NumCaptures);
1354 Record.AddSourceRange(E->IntroducerRange);
1355 Record.push_back(E->CaptureDefault); // FIXME: stable encoding
1356 Record.AddSourceLocation(E->CaptureDefaultLoc);
1357 Record.push_back(E->ExplicitParams);
1358 Record.push_back(E->ExplicitResultType);
1359 Record.AddSourceLocation(E->ClosingBrace);
1361 // Add capture initializers.
1362 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1363 CEnd = E->capture_init_end();
1368 Code = serialization::EXPR_LAMBDA;
1371 void ASTStmtWriter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1373 Record.AddStmt(E->getSubExpr());
1374 Code = serialization::EXPR_CXX_STD_INITIALIZER_LIST;
1377 void ASTStmtWriter::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1378 VisitExplicitCastExpr(E);
1379 Record.AddSourceRange(SourceRange(E->getOperatorLoc(), E->getRParenLoc()));
1380 Record.AddSourceRange(E->getAngleBrackets());
1383 void ASTStmtWriter::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1384 VisitCXXNamedCastExpr(E);
1385 Code = serialization::EXPR_CXX_STATIC_CAST;
1388 void ASTStmtWriter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1389 VisitCXXNamedCastExpr(E);
1390 Code = serialization::EXPR_CXX_DYNAMIC_CAST;
1393 void ASTStmtWriter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1394 VisitCXXNamedCastExpr(E);
1395 Code = serialization::EXPR_CXX_REINTERPRET_CAST;
1398 void ASTStmtWriter::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1399 VisitCXXNamedCastExpr(E);
1400 Code = serialization::EXPR_CXX_CONST_CAST;
1403 void ASTStmtWriter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1404 VisitExplicitCastExpr(E);
1405 Record.AddSourceLocation(E->getLParenLoc());
1406 Record.AddSourceLocation(E->getRParenLoc());
1407 Code = serialization::EXPR_CXX_FUNCTIONAL_CAST;
1410 void ASTStmtWriter::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1412 Record.AddSourceLocation(E->UDSuffixLoc);
1413 Code = serialization::EXPR_USER_DEFINED_LITERAL;
1416 void ASTStmtWriter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1418 Record.push_back(E->getValue());
1419 Record.AddSourceLocation(E->getLocation());
1420 Code = serialization::EXPR_CXX_BOOL_LITERAL;
1423 void ASTStmtWriter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1425 Record.AddSourceLocation(E->getLocation());
1426 Code = serialization::EXPR_CXX_NULL_PTR_LITERAL;
1429 void ASTStmtWriter::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1431 Record.AddSourceRange(E->getSourceRange());
1432 if (E->isTypeOperand()) {
1433 Record.AddTypeSourceInfo(E->getTypeOperandSourceInfo());
1434 Code = serialization::EXPR_CXX_TYPEID_TYPE;
1436 Record.AddStmt(E->getExprOperand());
1437 Code = serialization::EXPR_CXX_TYPEID_EXPR;
1441 void ASTStmtWriter::VisitCXXThisExpr(CXXThisExpr *E) {
1443 Record.AddSourceLocation(E->getLocation());
1444 Record.push_back(E->isImplicit());
1445 Code = serialization::EXPR_CXX_THIS;
1448 void ASTStmtWriter::VisitCXXThrowExpr(CXXThrowExpr *E) {
1450 Record.AddSourceLocation(E->getThrowLoc());
1451 Record.AddStmt(E->getSubExpr());
1452 Record.push_back(E->isThrownVariableInScope());
1453 Code = serialization::EXPR_CXX_THROW;
1456 void ASTStmtWriter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1458 Record.AddDeclRef(E->getParam());
1459 Record.AddSourceLocation(E->getUsedLocation());
1460 Code = serialization::EXPR_CXX_DEFAULT_ARG;
1463 void ASTStmtWriter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1465 Record.AddDeclRef(E->getField());
1466 Record.AddSourceLocation(E->getExprLoc());
1467 Code = serialization::EXPR_CXX_DEFAULT_INIT;
1470 void ASTStmtWriter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1472 Record.AddCXXTemporary(E->getTemporary());
1473 Record.AddStmt(E->getSubExpr());
1474 Code = serialization::EXPR_CXX_BIND_TEMPORARY;
1477 void ASTStmtWriter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1479 Record.AddTypeSourceInfo(E->getTypeSourceInfo());
1480 Record.AddSourceLocation(E->getRParenLoc());
1481 Code = serialization::EXPR_CXX_SCALAR_VALUE_INIT;
1484 void ASTStmtWriter::VisitCXXNewExpr(CXXNewExpr *E) {
1487 Record.push_back(E->isArray());
1488 Record.push_back(E->hasInitializer());
1489 Record.push_back(E->getNumPlacementArgs());
1490 Record.push_back(E->isParenTypeId());
1492 Record.push_back(E->isGlobalNew());
1493 Record.push_back(E->passAlignment());
1494 Record.push_back(E->doesUsualArrayDeleteWantSize());
1495 Record.push_back(E->CXXNewExprBits.StoredInitializationStyle);
1497 Record.AddDeclRef(E->getOperatorNew());
1498 Record.AddDeclRef(E->getOperatorDelete());
1499 Record.AddTypeSourceInfo(E->getAllocatedTypeSourceInfo());
1500 if (E->isParenTypeId())
1501 Record.AddSourceRange(E->getTypeIdParens());
1502 Record.AddSourceRange(E->getSourceRange());
1503 Record.AddSourceRange(E->getDirectInitRange());
1505 for (CXXNewExpr::arg_iterator I = E->raw_arg_begin(), N = E->raw_arg_end();
1509 Code = serialization::EXPR_CXX_NEW;
1512 void ASTStmtWriter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1514 Record.push_back(E->isGlobalDelete());
1515 Record.push_back(E->isArrayForm());
1516 Record.push_back(E->isArrayFormAsWritten());
1517 Record.push_back(E->doesUsualArrayDeleteWantSize());
1518 Record.AddDeclRef(E->getOperatorDelete());
1519 Record.AddStmt(E->getArgument());
1520 Record.AddSourceLocation(E->getBeginLoc());
1522 Code = serialization::EXPR_CXX_DELETE;
1525 void ASTStmtWriter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1528 Record.AddStmt(E->getBase());
1529 Record.push_back(E->isArrow());
1530 Record.AddSourceLocation(E->getOperatorLoc());
1531 Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
1532 Record.AddTypeSourceInfo(E->getScopeTypeInfo());
1533 Record.AddSourceLocation(E->getColonColonLoc());
1534 Record.AddSourceLocation(E->getTildeLoc());
1536 // PseudoDestructorTypeStorage.
1537 Record.AddIdentifierRef(E->getDestroyedTypeIdentifier());
1538 if (E->getDestroyedTypeIdentifier())
1539 Record.AddSourceLocation(E->getDestroyedTypeLoc());
1541 Record.AddTypeSourceInfo(E->getDestroyedTypeInfo());
1543 Code = serialization::EXPR_CXX_PSEUDO_DESTRUCTOR;
1546 void ASTStmtWriter::VisitExprWithCleanups(ExprWithCleanups *E) {
1548 Record.push_back(E->getNumObjects());
1549 for (unsigned i = 0, e = E->getNumObjects(); i != e; ++i)
1550 Record.AddDeclRef(E->getObject(i));
1552 Record.push_back(E->cleanupsHaveSideEffects());
1553 Record.AddStmt(E->getSubExpr());
1554 Code = serialization::EXPR_EXPR_WITH_CLEANUPS;
1557 void ASTStmtWriter::VisitCXXDependentScopeMemberExpr(
1558 CXXDependentScopeMemberExpr *E) {
1561 // Don't emit anything here (or if you do you will have to update
1562 // the corresponding deserialization function).
1564 Record.push_back(E->hasTemplateKWAndArgsInfo());
1565 Record.push_back(E->getNumTemplateArgs());
1566 Record.push_back(E->hasFirstQualifierFoundInScope());
1568 if (E->hasTemplateKWAndArgsInfo()) {
1569 const ASTTemplateKWAndArgsInfo &ArgInfo =
1570 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
1571 AddTemplateKWAndArgsInfo(ArgInfo,
1572 E->getTrailingObjects<TemplateArgumentLoc>());
1575 Record.push_back(E->isArrow());
1576 Record.AddSourceLocation(E->getOperatorLoc());
1577 Record.AddTypeRef(E->getBaseType());
1578 Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
1579 if (!E->isImplicitAccess())
1580 Record.AddStmt(E->getBase());
1582 Record.AddStmt(nullptr);
1584 if (E->hasFirstQualifierFoundInScope())
1585 Record.AddDeclRef(E->getFirstQualifierFoundInScope());
1587 Record.AddDeclarationNameInfo(E->MemberNameInfo);
1588 Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_MEMBER;
1592 ASTStmtWriter::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
1595 // Don't emit anything here, HasTemplateKWAndArgsInfo must be
1598 Record.push_back(E->DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo);
1599 if (E->DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo) {
1600 const ASTTemplateKWAndArgsInfo &ArgInfo =
1601 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
1602 Record.push_back(ArgInfo.NumTemplateArgs);
1603 AddTemplateKWAndArgsInfo(ArgInfo,
1604 E->getTrailingObjects<TemplateArgumentLoc>());
1607 Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
1608 Record.AddDeclarationNameInfo(E->NameInfo);
1609 Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_DECL_REF;
1613 ASTStmtWriter::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
1615 Record.push_back(E->arg_size());
1616 for (CXXUnresolvedConstructExpr::arg_iterator
1617 ArgI = E->arg_begin(), ArgE = E->arg_end(); ArgI != ArgE; ++ArgI)
1618 Record.AddStmt(*ArgI);
1619 Record.AddTypeSourceInfo(E->getTypeSourceInfo());
1620 Record.AddSourceLocation(E->getLParenLoc());
1621 Record.AddSourceLocation(E->getRParenLoc());
1622 Code = serialization::EXPR_CXX_UNRESOLVED_CONSTRUCT;
1625 void ASTStmtWriter::VisitOverloadExpr(OverloadExpr *E) {
1628 Record.push_back(E->getNumDecls());
1629 Record.push_back(E->hasTemplateKWAndArgsInfo());
1630 if (E->hasTemplateKWAndArgsInfo()) {
1631 const ASTTemplateKWAndArgsInfo &ArgInfo =
1632 *E->getTrailingASTTemplateKWAndArgsInfo();
1633 Record.push_back(ArgInfo.NumTemplateArgs);
1634 AddTemplateKWAndArgsInfo(ArgInfo, E->getTrailingTemplateArgumentLoc());
1637 for (OverloadExpr::decls_iterator OvI = E->decls_begin(),
1638 OvE = E->decls_end();
1639 OvI != OvE; ++OvI) {
1640 Record.AddDeclRef(OvI.getDecl());
1641 Record.push_back(OvI.getAccess());
1644 Record.AddDeclarationNameInfo(E->getNameInfo());
1645 Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
1648 void ASTStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
1649 VisitOverloadExpr(E);
1650 Record.push_back(E->isArrow());
1651 Record.push_back(E->hasUnresolvedUsing());
1652 Record.AddStmt(!E->isImplicitAccess() ? E->getBase() : nullptr);
1653 Record.AddTypeRef(E->getBaseType());
1654 Record.AddSourceLocation(E->getOperatorLoc());
1655 Code = serialization::EXPR_CXX_UNRESOLVED_MEMBER;
1658 void ASTStmtWriter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
1659 VisitOverloadExpr(E);
1660 Record.push_back(E->requiresADL());
1661 Record.push_back(E->isOverloaded());
1662 Record.AddDeclRef(E->getNamingClass());
1663 Code = serialization::EXPR_CXX_UNRESOLVED_LOOKUP;
1666 void ASTStmtWriter::VisitTypeTraitExpr(TypeTraitExpr *E) {
1668 Record.push_back(E->TypeTraitExprBits.NumArgs);
1669 Record.push_back(E->TypeTraitExprBits.Kind); // FIXME: Stable encoding
1670 Record.push_back(E->TypeTraitExprBits.Value);
1671 Record.AddSourceRange(E->getSourceRange());
1672 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1673 Record.AddTypeSourceInfo(E->getArg(I));
1674 Code = serialization::EXPR_TYPE_TRAIT;
1677 void ASTStmtWriter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1679 Record.push_back(E->getTrait());
1680 Record.push_back(E->getValue());
1681 Record.AddSourceRange(E->getSourceRange());
1682 Record.AddTypeSourceInfo(E->getQueriedTypeSourceInfo());
1683 Record.AddStmt(E->getDimensionExpression());
1684 Code = serialization::EXPR_ARRAY_TYPE_TRAIT;
1687 void ASTStmtWriter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1689 Record.push_back(E->getTrait());
1690 Record.push_back(E->getValue());
1691 Record.AddSourceRange(E->getSourceRange());
1692 Record.AddStmt(E->getQueriedExpression());
1693 Code = serialization::EXPR_CXX_EXPRESSION_TRAIT;
1696 void ASTStmtWriter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1698 Record.push_back(E->getValue());
1699 Record.AddSourceRange(E->getSourceRange());
1700 Record.AddStmt(E->getOperand());
1701 Code = serialization::EXPR_CXX_NOEXCEPT;
1704 void ASTStmtWriter::VisitPackExpansionExpr(PackExpansionExpr *E) {
1706 Record.AddSourceLocation(E->getEllipsisLoc());
1707 Record.push_back(E->NumExpansions);
1708 Record.AddStmt(E->getPattern());
1709 Code = serialization::EXPR_PACK_EXPANSION;
1712 void ASTStmtWriter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1714 Record.push_back(E->isPartiallySubstituted() ? E->getPartialArguments().size()
1716 Record.AddSourceLocation(E->OperatorLoc);
1717 Record.AddSourceLocation(E->PackLoc);
1718 Record.AddSourceLocation(E->RParenLoc);
1719 Record.AddDeclRef(E->Pack);
1720 if (E->isPartiallySubstituted()) {
1721 for (const auto &TA : E->getPartialArguments())
1722 Record.AddTemplateArgument(TA);
1723 } else if (!E->isValueDependent()) {
1724 Record.push_back(E->getPackLength());
1726 Code = serialization::EXPR_SIZEOF_PACK;
1729 void ASTStmtWriter::VisitSubstNonTypeTemplateParmExpr(
1730 SubstNonTypeTemplateParmExpr *E) {
1732 Record.AddDeclRef(E->getParameter());
1733 Record.AddSourceLocation(E->getNameLoc());
1734 Record.AddStmt(E->getReplacement());
1735 Code = serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM;
1738 void ASTStmtWriter::VisitSubstNonTypeTemplateParmPackExpr(
1739 SubstNonTypeTemplateParmPackExpr *E) {
1741 Record.AddDeclRef(E->getParameterPack());
1742 Record.AddTemplateArgument(E->getArgumentPack());
1743 Record.AddSourceLocation(E->getParameterPackLocation());
1744 Code = serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK;
1747 void ASTStmtWriter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1749 Record.push_back(E->getNumExpansions());
1750 Record.AddDeclRef(E->getParameterPack());
1751 Record.AddSourceLocation(E->getParameterPackLocation());
1752 for (FunctionParmPackExpr::iterator I = E->begin(), End = E->end();
1754 Record.AddDeclRef(*I);
1755 Code = serialization::EXPR_FUNCTION_PARM_PACK;
1758 void ASTStmtWriter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1760 Record.AddStmt(E->getTemporary());
1761 Record.AddDeclRef(E->getExtendingDecl());
1762 Record.push_back(E->getManglingNumber());
1763 Code = serialization::EXPR_MATERIALIZE_TEMPORARY;
1766 void ASTStmtWriter::VisitCXXFoldExpr(CXXFoldExpr *E) {
1768 Record.AddSourceLocation(E->LParenLoc);
1769 Record.AddSourceLocation(E->EllipsisLoc);
1770 Record.AddSourceLocation(E->RParenLoc);
1771 Record.AddStmt(E->SubExprs[0]);
1772 Record.AddStmt(E->SubExprs[1]);
1773 Record.push_back(E->Opcode);
1774 Code = serialization::EXPR_CXX_FOLD;
1777 void ASTStmtWriter::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1779 Record.AddStmt(E->getSourceExpr());
1780 Record.AddSourceLocation(E->getLocation());
1781 Record.push_back(E->isUnique());
1782 Code = serialization::EXPR_OPAQUE_VALUE;
1785 void ASTStmtWriter::VisitTypoExpr(TypoExpr *E) {
1787 // TODO: Figure out sane writer behavior for a TypoExpr, if necessary
1788 llvm_unreachable("Cannot write TypoExpr nodes");
1791 //===----------------------------------------------------------------------===//
1792 // CUDA Expressions and Statements.
1793 //===----------------------------------------------------------------------===//
1795 void ASTStmtWriter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1797 Record.AddStmt(E->getConfig());
1798 Code = serialization::EXPR_CUDA_KERNEL_CALL;
1801 //===----------------------------------------------------------------------===//
1802 // OpenCL Expressions and Statements.
1803 //===----------------------------------------------------------------------===//
1804 void ASTStmtWriter::VisitAsTypeExpr(AsTypeExpr *E) {
1806 Record.AddSourceLocation(E->getBuiltinLoc());
1807 Record.AddSourceLocation(E->getRParenLoc());
1808 Record.AddStmt(E->getSrcExpr());
1809 Code = serialization::EXPR_ASTYPE;
1812 //===----------------------------------------------------------------------===//
1813 // Microsoft Expressions and Statements.
1814 //===----------------------------------------------------------------------===//
1815 void ASTStmtWriter::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1817 Record.push_back(E->isArrow());
1818 Record.AddStmt(E->getBaseExpr());
1819 Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
1820 Record.AddSourceLocation(E->getMemberLoc());
1821 Record.AddDeclRef(E->getPropertyDecl());
1822 Code = serialization::EXPR_CXX_PROPERTY_REF_EXPR;
1825 void ASTStmtWriter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
1827 Record.AddStmt(E->getBase());
1828 Record.AddStmt(E->getIdx());
1829 Record.AddSourceLocation(E->getRBracketLoc());
1830 Code = serialization::EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR;
1833 void ASTStmtWriter::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1835 Record.AddSourceRange(E->getSourceRange());
1836 Record.AddString(E->getUuidStr());
1837 if (E->isTypeOperand()) {
1838 Record.AddTypeSourceInfo(E->getTypeOperandSourceInfo());
1839 Code = serialization::EXPR_CXX_UUIDOF_TYPE;
1841 Record.AddStmt(E->getExprOperand());
1842 Code = serialization::EXPR_CXX_UUIDOF_EXPR;
1846 void ASTStmtWriter::VisitSEHExceptStmt(SEHExceptStmt *S) {
1848 Record.AddSourceLocation(S->getExceptLoc());
1849 Record.AddStmt(S->getFilterExpr());
1850 Record.AddStmt(S->getBlock());
1851 Code = serialization::STMT_SEH_EXCEPT;
1854 void ASTStmtWriter::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1856 Record.AddSourceLocation(S->getFinallyLoc());
1857 Record.AddStmt(S->getBlock());
1858 Code = serialization::STMT_SEH_FINALLY;
1861 void ASTStmtWriter::VisitSEHTryStmt(SEHTryStmt *S) {
1863 Record.push_back(S->getIsCXXTry());
1864 Record.AddSourceLocation(S->getTryLoc());
1865 Record.AddStmt(S->getTryBlock());
1866 Record.AddStmt(S->getHandler());
1867 Code = serialization::STMT_SEH_TRY;
1870 void ASTStmtWriter::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1872 Record.AddSourceLocation(S->getLeaveLoc());
1873 Code = serialization::STMT_SEH_LEAVE;
1876 //===----------------------------------------------------------------------===//
1877 // OpenMP Directives.
1878 //===----------------------------------------------------------------------===//
1879 void ASTStmtWriter::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
1880 Record.AddSourceLocation(E->getBeginLoc());
1881 Record.AddSourceLocation(E->getEndLoc());
1882 OMPClauseWriter ClauseWriter(Record);
1883 for (unsigned i = 0; i < E->getNumClauses(); ++i) {
1884 ClauseWriter.writeClause(E->getClause(i));
1886 if (E->hasAssociatedStmt())
1887 Record.AddStmt(E->getAssociatedStmt());
1890 void ASTStmtWriter::VisitOMPLoopDirective(OMPLoopDirective *D) {
1892 Record.push_back(D->getNumClauses());
1893 Record.push_back(D->getCollapsedNumber());
1894 VisitOMPExecutableDirective(D);
1895 Record.AddStmt(D->getIterationVariable());
1896 Record.AddStmt(D->getLastIteration());
1897 Record.AddStmt(D->getCalcLastIteration());
1898 Record.AddStmt(D->getPreCond());
1899 Record.AddStmt(D->getCond());
1900 Record.AddStmt(D->getInit());
1901 Record.AddStmt(D->getInc());
1902 Record.AddStmt(D->getPreInits());
1903 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
1904 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
1905 isOpenMPDistributeDirective(D->getDirectiveKind())) {
1906 Record.AddStmt(D->getIsLastIterVariable());
1907 Record.AddStmt(D->getLowerBoundVariable());
1908 Record.AddStmt(D->getUpperBoundVariable());
1909 Record.AddStmt(D->getStrideVariable());
1910 Record.AddStmt(D->getEnsureUpperBound());
1911 Record.AddStmt(D->getNextLowerBound());
1912 Record.AddStmt(D->getNextUpperBound());
1913 Record.AddStmt(D->getNumIterations());
1915 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
1916 Record.AddStmt(D->getPrevLowerBoundVariable());
1917 Record.AddStmt(D->getPrevUpperBoundVariable());
1918 Record.AddStmt(D->getDistInc());
1919 Record.AddStmt(D->getPrevEnsureUpperBound());
1920 Record.AddStmt(D->getCombinedLowerBoundVariable());
1921 Record.AddStmt(D->getCombinedUpperBoundVariable());
1922 Record.AddStmt(D->getCombinedEnsureUpperBound());
1923 Record.AddStmt(D->getCombinedInit());
1924 Record.AddStmt(D->getCombinedCond());
1925 Record.AddStmt(D->getCombinedNextLowerBound());
1926 Record.AddStmt(D->getCombinedNextUpperBound());
1927 Record.AddStmt(D->getCombinedDistCond());
1928 Record.AddStmt(D->getCombinedParForInDistCond());
1930 for (auto I : D->counters()) {
1933 for (auto I : D->private_counters()) {
1936 for (auto I : D->inits()) {
1939 for (auto I : D->updates()) {
1942 for (auto I : D->finals()) {
1947 void ASTStmtWriter::VisitOMPParallelDirective(OMPParallelDirective *D) {
1949 Record.push_back(D->getNumClauses());
1950 VisitOMPExecutableDirective(D);
1951 Record.push_back(D->hasCancel() ? 1 : 0);
1952 Code = serialization::STMT_OMP_PARALLEL_DIRECTIVE;
1955 void ASTStmtWriter::VisitOMPSimdDirective(OMPSimdDirective *D) {
1956 VisitOMPLoopDirective(D);
1957 Code = serialization::STMT_OMP_SIMD_DIRECTIVE;
1960 void ASTStmtWriter::VisitOMPForDirective(OMPForDirective *D) {
1961 VisitOMPLoopDirective(D);
1962 Record.push_back(D->hasCancel() ? 1 : 0);
1963 Code = serialization::STMT_OMP_FOR_DIRECTIVE;
1966 void ASTStmtWriter::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
1967 VisitOMPLoopDirective(D);
1968 Code = serialization::STMT_OMP_FOR_SIMD_DIRECTIVE;
1971 void ASTStmtWriter::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
1973 Record.push_back(D->getNumClauses());
1974 VisitOMPExecutableDirective(D);
1975 Record.push_back(D->hasCancel() ? 1 : 0);
1976 Code = serialization::STMT_OMP_SECTIONS_DIRECTIVE;
1979 void ASTStmtWriter::VisitOMPSectionDirective(OMPSectionDirective *D) {
1981 VisitOMPExecutableDirective(D);
1982 Record.push_back(D->hasCancel() ? 1 : 0);
1983 Code = serialization::STMT_OMP_SECTION_DIRECTIVE;
1986 void ASTStmtWriter::VisitOMPSingleDirective(OMPSingleDirective *D) {
1988 Record.push_back(D->getNumClauses());
1989 VisitOMPExecutableDirective(D);
1990 Code = serialization::STMT_OMP_SINGLE_DIRECTIVE;
1993 void ASTStmtWriter::VisitOMPMasterDirective(OMPMasterDirective *D) {
1995 VisitOMPExecutableDirective(D);
1996 Code = serialization::STMT_OMP_MASTER_DIRECTIVE;
1999 void ASTStmtWriter::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2001 Record.push_back(D->getNumClauses());
2002 VisitOMPExecutableDirective(D);
2003 Record.AddDeclarationNameInfo(D->getDirectiveName());
2004 Code = serialization::STMT_OMP_CRITICAL_DIRECTIVE;
2007 void ASTStmtWriter::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
2008 VisitOMPLoopDirective(D);
2009 Record.push_back(D->hasCancel() ? 1 : 0);
2010 Code = serialization::STMT_OMP_PARALLEL_FOR_DIRECTIVE;
2013 void ASTStmtWriter::VisitOMPParallelForSimdDirective(
2014 OMPParallelForSimdDirective *D) {
2015 VisitOMPLoopDirective(D);
2016 Code = serialization::STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE;
2019 void ASTStmtWriter::VisitOMPParallelSectionsDirective(
2020 OMPParallelSectionsDirective *D) {
2022 Record.push_back(D->getNumClauses());
2023 VisitOMPExecutableDirective(D);
2024 Record.push_back(D->hasCancel() ? 1 : 0);
2025 Code = serialization::STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE;
2028 void ASTStmtWriter::VisitOMPTaskDirective(OMPTaskDirective *D) {
2030 Record.push_back(D->getNumClauses());
2031 VisitOMPExecutableDirective(D);
2032 Record.push_back(D->hasCancel() ? 1 : 0);
2033 Code = serialization::STMT_OMP_TASK_DIRECTIVE;
2036 void ASTStmtWriter::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2038 Record.push_back(D->getNumClauses());
2039 VisitOMPExecutableDirective(D);
2040 Record.AddStmt(D->getX());
2041 Record.AddStmt(D->getV());
2042 Record.AddStmt(D->getExpr());
2043 Record.AddStmt(D->getUpdateExpr());
2044 Record.push_back(D->isXLHSInRHSPart() ? 1 : 0);
2045 Record.push_back(D->isPostfixUpdate() ? 1 : 0);
2046 Code = serialization::STMT_OMP_ATOMIC_DIRECTIVE;
2049 void ASTStmtWriter::VisitOMPTargetDirective(OMPTargetDirective *D) {
2051 Record.push_back(D->getNumClauses());
2052 VisitOMPExecutableDirective(D);
2053 Code = serialization::STMT_OMP_TARGET_DIRECTIVE;
2056 void ASTStmtWriter::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2058 Record.push_back(D->getNumClauses());
2059 VisitOMPExecutableDirective(D);
2060 Code = serialization::STMT_OMP_TARGET_DATA_DIRECTIVE;
2063 void ASTStmtWriter::VisitOMPTargetEnterDataDirective(
2064 OMPTargetEnterDataDirective *D) {
2066 Record.push_back(D->getNumClauses());
2067 VisitOMPExecutableDirective(D);
2068 Code = serialization::STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE;
2071 void ASTStmtWriter::VisitOMPTargetExitDataDirective(
2072 OMPTargetExitDataDirective *D) {
2074 Record.push_back(D->getNumClauses());
2075 VisitOMPExecutableDirective(D);
2076 Code = serialization::STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE;
2079 void ASTStmtWriter::VisitOMPTargetParallelDirective(
2080 OMPTargetParallelDirective *D) {
2082 Record.push_back(D->getNumClauses());
2083 VisitOMPExecutableDirective(D);
2084 Code = serialization::STMT_OMP_TARGET_PARALLEL_DIRECTIVE;
2087 void ASTStmtWriter::VisitOMPTargetParallelForDirective(
2088 OMPTargetParallelForDirective *D) {
2089 VisitOMPLoopDirective(D);
2090 Record.push_back(D->hasCancel() ? 1 : 0);
2091 Code = serialization::STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE;
2094 void ASTStmtWriter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2096 VisitOMPExecutableDirective(D);
2097 Code = serialization::STMT_OMP_TASKYIELD_DIRECTIVE;
2100 void ASTStmtWriter::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2102 VisitOMPExecutableDirective(D);
2103 Code = serialization::STMT_OMP_BARRIER_DIRECTIVE;
2106 void ASTStmtWriter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2108 VisitOMPExecutableDirective(D);
2109 Code = serialization::STMT_OMP_TASKWAIT_DIRECTIVE;
2112 void ASTStmtWriter::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2114 Record.push_back(D->getNumClauses());
2115 VisitOMPExecutableDirective(D);
2116 Record.AddStmt(D->getReductionRef());
2117 Code = serialization::STMT_OMP_TASKGROUP_DIRECTIVE;
2120 void ASTStmtWriter::VisitOMPFlushDirective(OMPFlushDirective *D) {
2122 Record.push_back(D->getNumClauses());
2123 VisitOMPExecutableDirective(D);
2124 Code = serialization::STMT_OMP_FLUSH_DIRECTIVE;
2127 void ASTStmtWriter::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2129 Record.push_back(D->getNumClauses());
2130 VisitOMPExecutableDirective(D);
2131 Code = serialization::STMT_OMP_ORDERED_DIRECTIVE;
2134 void ASTStmtWriter::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2136 Record.push_back(D->getNumClauses());
2137 VisitOMPExecutableDirective(D);
2138 Code = serialization::STMT_OMP_TEAMS_DIRECTIVE;
2141 void ASTStmtWriter::VisitOMPCancellationPointDirective(
2142 OMPCancellationPointDirective *D) {
2144 VisitOMPExecutableDirective(D);
2145 Record.push_back(D->getCancelRegion());
2146 Code = serialization::STMT_OMP_CANCELLATION_POINT_DIRECTIVE;
2149 void ASTStmtWriter::VisitOMPCancelDirective(OMPCancelDirective *D) {
2151 Record.push_back(D->getNumClauses());
2152 VisitOMPExecutableDirective(D);
2153 Record.push_back(D->getCancelRegion());
2154 Code = serialization::STMT_OMP_CANCEL_DIRECTIVE;
2157 void ASTStmtWriter::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2158 VisitOMPLoopDirective(D);
2159 Code = serialization::STMT_OMP_TASKLOOP_DIRECTIVE;
2162 void ASTStmtWriter::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2163 VisitOMPLoopDirective(D);
2164 Code = serialization::STMT_OMP_TASKLOOP_SIMD_DIRECTIVE;
2167 void ASTStmtWriter::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2168 VisitOMPLoopDirective(D);
2169 Code = serialization::STMT_OMP_DISTRIBUTE_DIRECTIVE;
2172 void ASTStmtWriter::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2174 Record.push_back(D->getNumClauses());
2175 VisitOMPExecutableDirective(D);
2176 Code = serialization::STMT_OMP_TARGET_UPDATE_DIRECTIVE;
2179 void ASTStmtWriter::VisitOMPDistributeParallelForDirective(
2180 OMPDistributeParallelForDirective *D) {
2181 VisitOMPLoopDirective(D);
2182 Record.push_back(D->hasCancel() ? 1 : 0);
2183 Code = serialization::STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE;
2186 void ASTStmtWriter::VisitOMPDistributeParallelForSimdDirective(
2187 OMPDistributeParallelForSimdDirective *D) {
2188 VisitOMPLoopDirective(D);
2189 Code = serialization::STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE;
2192 void ASTStmtWriter::VisitOMPDistributeSimdDirective(
2193 OMPDistributeSimdDirective *D) {
2194 VisitOMPLoopDirective(D);
2195 Code = serialization::STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE;
2198 void ASTStmtWriter::VisitOMPTargetParallelForSimdDirective(
2199 OMPTargetParallelForSimdDirective *D) {
2200 VisitOMPLoopDirective(D);
2201 Code = serialization::STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE;
2204 void ASTStmtWriter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2205 VisitOMPLoopDirective(D);
2206 Code = serialization::STMT_OMP_TARGET_SIMD_DIRECTIVE;
2209 void ASTStmtWriter::VisitOMPTeamsDistributeDirective(
2210 OMPTeamsDistributeDirective *D) {
2211 VisitOMPLoopDirective(D);
2212 Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE;
2215 void ASTStmtWriter::VisitOMPTeamsDistributeSimdDirective(
2216 OMPTeamsDistributeSimdDirective *D) {
2217 VisitOMPLoopDirective(D);
2218 Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE;
2221 void ASTStmtWriter::VisitOMPTeamsDistributeParallelForSimdDirective(
2222 OMPTeamsDistributeParallelForSimdDirective *D) {
2223 VisitOMPLoopDirective(D);
2224 Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE;
2227 void ASTStmtWriter::VisitOMPTeamsDistributeParallelForDirective(
2228 OMPTeamsDistributeParallelForDirective *D) {
2229 VisitOMPLoopDirective(D);
2230 Record.push_back(D->hasCancel() ? 1 : 0);
2231 Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE;
2234 void ASTStmtWriter::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2236 Record.push_back(D->getNumClauses());
2237 VisitOMPExecutableDirective(D);
2238 Code = serialization::STMT_OMP_TARGET_TEAMS_DIRECTIVE;
2241 void ASTStmtWriter::VisitOMPTargetTeamsDistributeDirective(
2242 OMPTargetTeamsDistributeDirective *D) {
2243 VisitOMPLoopDirective(D);
2244 Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE;
2247 void ASTStmtWriter::VisitOMPTargetTeamsDistributeParallelForDirective(
2248 OMPTargetTeamsDistributeParallelForDirective *D) {
2249 VisitOMPLoopDirective(D);
2250 Record.push_back(D->hasCancel() ? 1 : 0);
2251 Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE;
2254 void ASTStmtWriter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2255 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2256 VisitOMPLoopDirective(D);
2257 Code = serialization::
2258 STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE;
2261 void ASTStmtWriter::VisitOMPTargetTeamsDistributeSimdDirective(
2262 OMPTargetTeamsDistributeSimdDirective *D) {
2263 VisitOMPLoopDirective(D);
2264 Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE;
2267 //===----------------------------------------------------------------------===//
2268 // ASTWriter Implementation
2269 //===----------------------------------------------------------------------===//
2271 unsigned ASTWriter::RecordSwitchCaseID(SwitchCase *S) {
2272 assert(SwitchCaseIDs.find(S) == SwitchCaseIDs.end() &&
2273 "SwitchCase recorded twice");
2274 unsigned NextID = SwitchCaseIDs.size();
2275 SwitchCaseIDs[S] = NextID;
2279 unsigned ASTWriter::getSwitchCaseID(SwitchCase *S) {
2280 assert(SwitchCaseIDs.find(S) != SwitchCaseIDs.end() &&
2281 "SwitchCase hasn't been seen yet");
2282 return SwitchCaseIDs[S];
2285 void ASTWriter::ClearSwitchCaseIDs() {
2286 SwitchCaseIDs.clear();
2289 /// Write the given substatement or subexpression to the
2291 void ASTWriter::WriteSubStmt(Stmt *S) {
2293 ASTStmtWriter Writer(*this, Record);
2297 Stream.EmitRecord(serialization::STMT_NULL_PTR, Record);
2301 llvm::DenseMap<Stmt *, uint64_t>::iterator I = SubStmtEntries.find(S);
2302 if (I != SubStmtEntries.end()) {
2303 Record.push_back(I->second);
2304 Stream.EmitRecord(serialization::STMT_REF_PTR, Record);
2309 assert(!ParentStmts.count(S) && "There is a Stmt cycle!");
2311 struct ParentStmtInserterRAII {
2313 llvm::DenseSet<Stmt *> &ParentStmts;
2315 ParentStmtInserterRAII(Stmt *S, llvm::DenseSet<Stmt *> &ParentStmts)
2316 : S(S), ParentStmts(ParentStmts) {
2317 ParentStmts.insert(S);
2319 ~ParentStmtInserterRAII() {
2320 ParentStmts.erase(S);
2324 ParentStmtInserterRAII ParentStmtInserter(S, ParentStmts);
2329 uint64_t Offset = Writer.Emit();
2330 SubStmtEntries[S] = Offset;
2333 /// Flush all of the statements that have been added to the
2334 /// queue via AddStmt().
2335 void ASTRecordWriter::FlushStmts() {
2336 // We expect to be the only consumer of the two temporary statement maps,
2337 // assert that they are empty.
2338 assert(Writer->SubStmtEntries.empty() && "unexpected entries in sub-stmt map");
2339 assert(Writer->ParentStmts.empty() && "unexpected entries in parent stmt map");
2341 for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) {
2342 Writer->WriteSubStmt(StmtsToEmit[I]);
2344 assert(N == StmtsToEmit.size() && "record modified while being written!");
2346 // Note that we are at the end of a full expression. Any
2347 // expression records that follow this one are part of a different
2349 Writer->Stream.EmitRecord(serialization::STMT_STOP, ArrayRef<uint32_t>());
2351 Writer->SubStmtEntries.clear();
2352 Writer->ParentStmts.clear();
2355 StmtsToEmit.clear();
2358 void ASTRecordWriter::FlushSubStmts() {
2359 // For a nested statement, write out the substatements in reverse order (so
2360 // that a simple stack machine can be used when loading), and don't emit a
2361 // STMT_STOP after each one.
2362 for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) {
2363 Writer->WriteSubStmt(StmtsToEmit[N - I - 1]);
2364 assert(N == StmtsToEmit.size() && "record modified while being written!");
2367 StmtsToEmit.clear();