2010-08-19 07:56:31 +08:00
|
|
|
//===--- ASTWriterStmt.cpp - Statement and Expression Serialization -------===//
|
2009-04-27 14:20:01 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements serialization for Statements and Expressions.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-08-19 07:56:37 +08:00
|
|
|
#include "clang/Serialization/ASTWriter.h"
|
2009-09-10 07:08:42 +08:00
|
|
|
#include "clang/AST/DeclCXX.h"
|
2009-04-27 14:20:01 +08:00
|
|
|
#include "clang/AST/DeclObjC.h"
|
|
|
|
#include "clang/AST/StmtVisitor.h"
|
|
|
|
#include "llvm/Bitcode/BitstreamWriter.h"
|
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Statement/expression serialization
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-06-30 16:49:18 +08:00
|
|
|
namespace clang {
|
2010-08-19 07:56:27 +08:00
|
|
|
class ASTStmtWriter : public StmtVisitor<ASTStmtWriter, void> {
|
2010-08-19 07:56:21 +08:00
|
|
|
ASTWriter &Writer;
|
|
|
|
ASTWriter::RecordData &Record;
|
2009-04-27 14:20:01 +08:00
|
|
|
|
|
|
|
public:
|
2010-08-19 07:57:32 +08:00
|
|
|
serialization::StmtCode Code;
|
2009-04-27 14:20:01 +08:00
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
ASTStmtWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
|
2009-04-27 14:20:01 +08:00
|
|
|
: Writer(Writer), Record(Record) { }
|
2010-06-28 17:31:48 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
AddExplicitTemplateArgumentList(const ExplicitTemplateArgumentList &Args);
|
2009-04-27 14:20:01 +08:00
|
|
|
|
|
|
|
void VisitStmt(Stmt *S);
|
|
|
|
void VisitNullStmt(NullStmt *S);
|
|
|
|
void VisitCompoundStmt(CompoundStmt *S);
|
|
|
|
void VisitSwitchCase(SwitchCase *S);
|
|
|
|
void VisitCaseStmt(CaseStmt *S);
|
|
|
|
void VisitDefaultStmt(DefaultStmt *S);
|
|
|
|
void VisitLabelStmt(LabelStmt *S);
|
|
|
|
void VisitIfStmt(IfStmt *S);
|
|
|
|
void VisitSwitchStmt(SwitchStmt *S);
|
|
|
|
void VisitWhileStmt(WhileStmt *S);
|
|
|
|
void VisitDoStmt(DoStmt *S);
|
|
|
|
void VisitForStmt(ForStmt *S);
|
|
|
|
void VisitGotoStmt(GotoStmt *S);
|
|
|
|
void VisitIndirectGotoStmt(IndirectGotoStmt *S);
|
|
|
|
void VisitContinueStmt(ContinueStmt *S);
|
|
|
|
void VisitBreakStmt(BreakStmt *S);
|
|
|
|
void VisitReturnStmt(ReturnStmt *S);
|
|
|
|
void VisitDeclStmt(DeclStmt *S);
|
|
|
|
void VisitAsmStmt(AsmStmt *S);
|
|
|
|
void VisitExpr(Expr *E);
|
|
|
|
void VisitPredefinedExpr(PredefinedExpr *E);
|
|
|
|
void VisitDeclRefExpr(DeclRefExpr *E);
|
|
|
|
void VisitIntegerLiteral(IntegerLiteral *E);
|
|
|
|
void VisitFloatingLiteral(FloatingLiteral *E);
|
|
|
|
void VisitImaginaryLiteral(ImaginaryLiteral *E);
|
|
|
|
void VisitStringLiteral(StringLiteral *E);
|
|
|
|
void VisitCharacterLiteral(CharacterLiteral *E);
|
|
|
|
void VisitParenExpr(ParenExpr *E);
|
2010-06-30 16:49:18 +08:00
|
|
|
void VisitParenListExpr(ParenListExpr *E);
|
2009-04-27 14:20:01 +08:00
|
|
|
void VisitUnaryOperator(UnaryOperator *E);
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
void VisitOffsetOfExpr(OffsetOfExpr *E);
|
2009-04-27 14:20:01 +08:00
|
|
|
void VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E);
|
|
|
|
void VisitArraySubscriptExpr(ArraySubscriptExpr *E);
|
|
|
|
void VisitCallExpr(CallExpr *E);
|
|
|
|
void VisitMemberExpr(MemberExpr *E);
|
|
|
|
void VisitCastExpr(CastExpr *E);
|
|
|
|
void VisitBinaryOperator(BinaryOperator *E);
|
|
|
|
void VisitCompoundAssignOperator(CompoundAssignOperator *E);
|
|
|
|
void VisitConditionalOperator(ConditionalOperator *E);
|
|
|
|
void VisitImplicitCastExpr(ImplicitCastExpr *E);
|
|
|
|
void VisitExplicitCastExpr(ExplicitCastExpr *E);
|
|
|
|
void VisitCStyleCastExpr(CStyleCastExpr *E);
|
|
|
|
void VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
|
|
|
|
void VisitExtVectorElementExpr(ExtVectorElementExpr *E);
|
|
|
|
void VisitInitListExpr(InitListExpr *E);
|
|
|
|
void VisitDesignatedInitExpr(DesignatedInitExpr *E);
|
|
|
|
void VisitImplicitValueInitExpr(ImplicitValueInitExpr *E);
|
|
|
|
void VisitVAArgExpr(VAArgExpr *E);
|
|
|
|
void VisitAddrLabelExpr(AddrLabelExpr *E);
|
|
|
|
void VisitStmtExpr(StmtExpr *E);
|
|
|
|
void VisitChooseExpr(ChooseExpr *E);
|
|
|
|
void VisitGNUNullExpr(GNUNullExpr *E);
|
|
|
|
void VisitShuffleVectorExpr(ShuffleVectorExpr *E);
|
|
|
|
void VisitBlockExpr(BlockExpr *E);
|
|
|
|
void VisitBlockDeclRefExpr(BlockDeclRefExpr *E);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-27 14:20:01 +08:00
|
|
|
// Objective-C Expressions
|
|
|
|
void VisitObjCStringLiteral(ObjCStringLiteral *E);
|
|
|
|
void VisitObjCEncodeExpr(ObjCEncodeExpr *E);
|
|
|
|
void VisitObjCSelectorExpr(ObjCSelectorExpr *E);
|
|
|
|
void VisitObjCProtocolExpr(ObjCProtocolExpr *E);
|
|
|
|
void VisitObjCIvarRefExpr(ObjCIvarRefExpr *E);
|
|
|
|
void VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E);
|
|
|
|
void VisitObjCMessageExpr(ObjCMessageExpr *E);
|
2009-07-25 01:54:45 +08:00
|
|
|
void VisitObjCIsaExpr(ObjCIsaExpr *E);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
// Objective-C Statements
|
2009-04-27 14:20:01 +08:00
|
|
|
void VisitObjCForCollectionStmt(ObjCForCollectionStmt *);
|
|
|
|
void VisitObjCAtCatchStmt(ObjCAtCatchStmt *);
|
|
|
|
void VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *);
|
|
|
|
void VisitObjCAtTryStmt(ObjCAtTryStmt *);
|
|
|
|
void VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *);
|
|
|
|
void VisitObjCAtThrowStmt(ObjCAtThrowStmt *);
|
2009-07-14 11:19:21 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
// C++ Statements
|
2010-07-23 00:03:56 +08:00
|
|
|
void VisitCXXCatchStmt(CXXCatchStmt *S);
|
|
|
|
void VisitCXXTryStmt(CXXTryStmt *S);
|
|
|
|
|
2009-07-14 11:19:21 +08:00
|
|
|
void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E);
|
2010-05-09 13:36:05 +08:00
|
|
|
void VisitCXXMemberCallExpr(CXXMemberCallExpr *E);
|
2009-09-10 07:08:42 +08:00
|
|
|
void VisitCXXConstructExpr(CXXConstructExpr *E);
|
2010-07-10 19:46:15 +08:00
|
|
|
void VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E);
|
2010-01-17 05:21:01 +08:00
|
|
|
void VisitCXXNamedCastExpr(CXXNamedCastExpr *E);
|
|
|
|
void VisitCXXStaticCastExpr(CXXStaticCastExpr *E);
|
|
|
|
void VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E);
|
|
|
|
void VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E);
|
|
|
|
void VisitCXXConstCastExpr(CXXConstCastExpr *E);
|
|
|
|
void VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E);
|
2010-02-07 14:32:43 +08:00
|
|
|
void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
|
|
|
|
void VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E);
|
2010-05-09 14:03:39 +08:00
|
|
|
void VisitCXXTypeidExpr(CXXTypeidExpr *E);
|
2010-09-08 20:20:18 +08:00
|
|
|
void VisitCXXUuidofExpr(CXXUuidofExpr *E);
|
2010-05-09 14:15:05 +08:00
|
|
|
void VisitCXXThisExpr(CXXThisExpr *E);
|
|
|
|
void VisitCXXThrowExpr(CXXThrowExpr *E);
|
2010-05-09 14:40:08 +08:00
|
|
|
void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E);
|
2010-05-10 08:25:06 +08:00
|
|
|
void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E);
|
2010-06-24 16:57:31 +08:00
|
|
|
|
2010-07-08 14:14:04 +08:00
|
|
|
void VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E);
|
2010-05-10 09:22:27 +08:00
|
|
|
void VisitCXXNewExpr(CXXNewExpr *E);
|
2010-06-23 01:07:59 +08:00
|
|
|
void VisitCXXDeleteExpr(CXXDeleteExpr *E);
|
2010-06-28 17:32:03 +08:00
|
|
|
void VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E);
|
2010-06-24 16:57:31 +08:00
|
|
|
|
2010-12-06 16:20:24 +08:00
|
|
|
void VisitExprWithCleanups(ExprWithCleanups *E);
|
2010-06-24 16:57:31 +08:00
|
|
|
void VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E);
|
2010-06-28 17:31:56 +08:00
|
|
|
void VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E);
|
2010-06-24 16:57:31 +08:00
|
|
|
void VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E);
|
2010-06-25 17:03:26 +08:00
|
|
|
|
|
|
|
void VisitOverloadExpr(OverloadExpr *E);
|
|
|
|
void VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E);
|
2010-06-25 17:03:34 +08:00
|
|
|
void VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E);
|
2010-07-10 19:46:15 +08:00
|
|
|
|
|
|
|
void VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E);
|
2010-12-07 08:08:36 +08:00
|
|
|
void VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E);
|
2010-09-11 04:55:54 +08:00
|
|
|
void VisitCXXNoexceptExpr(CXXNoexceptExpr *E);
|
2011-01-04 01:17:50 +08:00
|
|
|
void VisitPackExpansionExpr(PackExpansionExpr *E);
|
2011-01-05 01:33:58 +08:00
|
|
|
void VisitSizeOfPackExpr(SizeOfPackExpr *E);
|
2010-11-16 07:31:06 +08:00
|
|
|
void VisitOpaqueValueExpr(OpaqueValueExpr *E);
|
2009-04-27 14:20:01 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::
|
2010-06-28 17:31:48 +08:00
|
|
|
AddExplicitTemplateArgumentList(const ExplicitTemplateArgumentList &Args) {
|
|
|
|
Writer.AddSourceLocation(Args.LAngleLoc, Record);
|
|
|
|
Writer.AddSourceLocation(Args.RAngleLoc, Record);
|
|
|
|
for (unsigned i=0; i != Args.NumTemplateArgs; ++i)
|
|
|
|
Writer.AddTemplateArgumentLoc(Args.getTemplateArgs()[i], Record);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitStmt(Stmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitNullStmt(NullStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
Writer.AddSourceLocation(S->getSemiLoc(), Record);
|
2010-11-20 10:04:01 +08:00
|
|
|
Record.push_back(S->LeadingEmptyMacro);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_NULL;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCompoundStmt(CompoundStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
Record.push_back(S->size());
|
|
|
|
for (CompoundStmt::body_iterator CS = S->body_begin(), CSEnd = S->body_end();
|
|
|
|
CS != CSEnd; ++CS)
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(*CS);
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(S->getLBracLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(S->getRBracLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_COMPOUND;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitSwitchCase(SwitchCase *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
2010-06-29 06:28:35 +08:00
|
|
|
Record.push_back(Writer.getSwitchCaseID(S));
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCaseStmt(CaseStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitSwitchCase(S);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getLHS());
|
|
|
|
Writer.AddStmt(S->getRHS());
|
|
|
|
Writer.AddStmt(S->getSubStmt());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(S->getCaseLoc(), Record);
|
2009-05-16 07:57:33 +08:00
|
|
|
Writer.AddSourceLocation(S->getEllipsisLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(S->getColonLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_CASE;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitDefaultStmt(DefaultStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitSwitchCase(S);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getSubStmt());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(S->getDefaultLoc(), Record);
|
2009-05-16 07:57:33 +08:00
|
|
|
Writer.AddSourceLocation(S->getColonLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_DEFAULT;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitLabelStmt(LabelStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
Writer.AddIdentifierRef(S->getID(), Record);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getSubStmt());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(S->getIdentLoc(), Record);
|
2010-09-20 05:21:25 +08:00
|
|
|
Record.push_back(S->isUsed());
|
2010-09-28 22:54:07 +08:00
|
|
|
Record.push_back(S->HasUnusedAttribute());
|
2009-04-27 14:20:01 +08:00
|
|
|
Record.push_back(Writer.GetLabelID(S));
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_LABEL;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitIfStmt(IfStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
2009-11-24 07:44:04 +08:00
|
|
|
Writer.AddDeclRef(S->getConditionVariable(), Record);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getCond());
|
|
|
|
Writer.AddStmt(S->getThen());
|
|
|
|
Writer.AddStmt(S->getElse());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(S->getIfLoc(), Record);
|
2009-05-16 02:53:42 +08:00
|
|
|
Writer.AddSourceLocation(S->getElseLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_IF;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitSwitchStmt(SwitchStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
2009-11-25 01:07:59 +08:00
|
|
|
Writer.AddDeclRef(S->getConditionVariable(), Record);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getCond());
|
|
|
|
Writer.AddStmt(S->getBody());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(S->getSwitchLoc(), Record);
|
2010-09-09 08:05:53 +08:00
|
|
|
Record.push_back(S->isAllEnumCasesCovered());
|
2009-09-09 23:08:12 +08:00
|
|
|
for (SwitchCase *SC = S->getSwitchCaseList(); SC;
|
2009-04-27 14:20:01 +08:00
|
|
|
SC = SC->getNextSwitchCase())
|
2010-06-29 06:28:35 +08:00
|
|
|
Record.push_back(Writer.RecordSwitchCaseID(SC));
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_SWITCH;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitWhileStmt(WhileStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
2009-11-25 05:15:44 +08:00
|
|
|
Writer.AddDeclRef(S->getConditionVariable(), Record);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getCond());
|
|
|
|
Writer.AddStmt(S->getBody());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(S->getWhileLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_WHILE;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitDoStmt(DoStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getCond());
|
|
|
|
Writer.AddStmt(S->getBody());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(S->getDoLoc(), Record);
|
2009-05-16 05:56:04 +08:00
|
|
|
Writer.AddSourceLocation(S->getWhileLoc(), Record);
|
2009-06-13 07:04:47 +08:00
|
|
|
Writer.AddSourceLocation(S->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_DO;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitForStmt(ForStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getInit());
|
|
|
|
Writer.AddStmt(S->getCond());
|
2009-11-25 08:27:52 +08:00
|
|
|
Writer.AddDeclRef(S->getConditionVariable(), Record);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getInc());
|
|
|
|
Writer.AddStmt(S->getBody());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(S->getForLoc(), Record);
|
2009-05-16 06:12:32 +08:00
|
|
|
Writer.AddSourceLocation(S->getLParenLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(S->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_FOR;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitGotoStmt(GotoStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
Record.push_back(Writer.GetLabelID(S->getLabel()));
|
|
|
|
Writer.AddSourceLocation(S->getGotoLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(S->getLabelLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_GOTO;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
Writer.AddSourceLocation(S->getGotoLoc(), Record);
|
2009-05-16 08:20:29 +08:00
|
|
|
Writer.AddSourceLocation(S->getStarLoc(), Record);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getTarget());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_INDIRECT_GOTO;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitContinueStmt(ContinueStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
Writer.AddSourceLocation(S->getContinueLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_CONTINUE;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitBreakStmt(BreakStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
Writer.AddSourceLocation(S->getBreakLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_BREAK;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitReturnStmt(ReturnStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getRetValue());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(S->getReturnLoc(), Record);
|
2010-05-15 14:01:05 +08:00
|
|
|
Writer.AddDeclRef(S->getNRVOCandidate(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_RETURN;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitDeclStmt(DeclStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
Writer.AddSourceLocation(S->getStartLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(S->getEndLoc(), Record);
|
|
|
|
DeclGroupRef DG = S->getDeclGroup();
|
|
|
|
for (DeclGroupRef::iterator D = DG.begin(), DEnd = DG.end(); D != DEnd; ++D)
|
|
|
|
Writer.AddDeclRef(*D, Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_DECL;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitAsmStmt(AsmStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
Record.push_back(S->getNumOutputs());
|
|
|
|
Record.push_back(S->getNumInputs());
|
|
|
|
Record.push_back(S->getNumClobbers());
|
|
|
|
Writer.AddSourceLocation(S->getAsmLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(S->getRParenLoc(), Record);
|
|
|
|
Record.push_back(S->isVolatile());
|
|
|
|
Record.push_back(S->isSimple());
|
2010-01-05 06:37:17 +08:00
|
|
|
Record.push_back(S->isMSAsm());
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getAsmString());
|
2009-04-27 14:20:01 +08:00
|
|
|
|
|
|
|
// Outputs
|
2010-01-31 06:25:16 +08:00
|
|
|
for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
|
|
|
|
Writer.AddIdentifierRef(S->getOutputIdentifier(I), Record);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getOutputConstraintLiteral(I));
|
|
|
|
Writer.AddStmt(S->getOutputExpr(I));
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Inputs
|
|
|
|
for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
|
2010-01-31 06:25:16 +08:00
|
|
|
Writer.AddIdentifierRef(S->getInputIdentifier(I), Record);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getInputConstraintLiteral(I));
|
|
|
|
Writer.AddStmt(S->getInputExpr(I));
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Clobbers
|
|
|
|
for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getClobber(I));
|
2009-04-27 14:20:01 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_ASM;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitExpr(Expr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(E);
|
|
|
|
Writer.AddTypeRef(E->getType(), Record);
|
|
|
|
Record.push_back(E->isTypeDependent());
|
|
|
|
Record.push_back(E->isValueDependent());
|
Variadic templates: extend Type, NestedNameSpecifier, TemplateName,
and TemplateArgument with an operation that determines whether there
are any unexpanded parameter packs within that construct. Use this
information to diagnose the appearance of the names of parameter packs
that have not been expanded (C++ [temp.variadic]p5). Since this
property is checked often (every declaration, ever expression
statement, etc.), we extend Type and Expr with a bit storing the
result of this computation, rather than walking the AST each time to
determine whether any unexpanded parameter packs occur.
This commit is deficient in several ways, which will be remedied with
future commits:
- Expr has a bit to store the presence of an unexpanded parameter
pack, but it is never set.
- The error messages don't point out where the unexpanded parameter
packs were named in the type/expression, but they should.
- We don't check for unexpanded parameter packs in all of the places
where we should.
- Testing is sparse, pending the resolution of the above three
issues.
llvm-svn: 121724
2010-12-14 06:49:22 +08:00
|
|
|
Record.push_back(E->containsUnexpandedParameterPack());
|
2010-11-18 14:31:45 +08:00
|
|
|
Record.push_back(E->getValueKind());
|
|
|
|
Record.push_back(E->getObjectKind());
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitPredefinedExpr(PredefinedExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddSourceLocation(E->getLocation(), Record);
|
|
|
|
Record.push_back(E->getIdentType()); // FIXME: stable encoding
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_PREDEFINED;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitDeclRefExpr(DeclRefExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
2010-07-08 21:09:47 +08:00
|
|
|
|
|
|
|
Record.push_back(E->hasQualifier());
|
|
|
|
unsigned NumTemplateArgs = E->getNumTemplateArgs();
|
2010-08-20 07:49:38 +08:00
|
|
|
assert((NumTemplateArgs != 0) == E->hasExplicitTemplateArgs() &&
|
2010-07-08 21:09:47 +08:00
|
|
|
"Template args list with no args ?");
|
|
|
|
Record.push_back(NumTemplateArgs);
|
|
|
|
|
|
|
|
if (E->hasQualifier()) {
|
|
|
|
Writer.AddNestedNameSpecifier(E->getQualifier(), Record);
|
|
|
|
Writer.AddSourceRange(E->getQualifierRange(), Record);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NumTemplateArgs)
|
2010-08-20 07:49:38 +08:00
|
|
|
AddExplicitTemplateArgumentList(E->getExplicitTemplateArgs());
|
2010-07-08 21:09:47 +08:00
|
|
|
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddDeclRef(E->getDecl(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getLocation(), Record);
|
2010-10-16 02:21:24 +08:00
|
|
|
Writer.AddDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_DECL_REF;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitIntegerLiteral(IntegerLiteral *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddSourceLocation(E->getLocation(), Record);
|
|
|
|
Writer.AddAPInt(E->getValue(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_INTEGER_LITERAL;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitFloatingLiteral(FloatingLiteral *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddAPFloat(E->getValue(), Record);
|
|
|
|
Record.push_back(E->isExact());
|
|
|
|
Writer.AddSourceLocation(E->getLocation(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_FLOATING_LITERAL;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitImaginaryLiteral(ImaginaryLiteral *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getSubExpr());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_IMAGINARY_LITERAL;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitStringLiteral(StringLiteral *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->getByteLength());
|
|
|
|
Record.push_back(E->getNumConcatenated());
|
|
|
|
Record.push_back(E->isWide());
|
|
|
|
// FIXME: String data should be stored as a blob at the end of the
|
|
|
|
// StringLiteral. However, we can't do so now because we have no
|
|
|
|
// provision for coping with abbreviations when we're jumping around
|
2010-08-19 07:56:27 +08:00
|
|
|
// the AST file during deserialization.
|
2010-08-17 20:54:38 +08:00
|
|
|
Record.append(E->getString().begin(), E->getString().end());
|
2009-04-27 14:20:01 +08:00
|
|
|
for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
|
|
|
|
Writer.AddSourceLocation(E->getStrTokenLoc(I), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_STRING_LITERAL;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCharacterLiteral(CharacterLiteral *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->getValue());
|
2009-08-25 01:39:36 +08:00
|
|
|
Writer.AddSourceLocation(E->getLocation(), Record);
|
2009-04-27 14:20:01 +08:00
|
|
|
Record.push_back(E->isWide());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CHARACTER_LITERAL;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitParenExpr(ParenExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddSourceLocation(E->getLParen(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRParen(), Record);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getSubExpr());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_PAREN;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitParenListExpr(ParenListExpr *E) {
|
2010-06-30 16:49:18 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->NumExprs);
|
|
|
|
for (unsigned i=0; i != E->NumExprs; ++i)
|
|
|
|
Writer.AddStmt(E->Exprs[i]);
|
|
|
|
Writer.AddSourceLocation(E->LParenLoc, Record);
|
|
|
|
Writer.AddSourceLocation(E->RParenLoc, Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_PAREN_LIST;
|
2010-06-30 16:49:18 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitUnaryOperator(UnaryOperator *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getSubExpr());
|
2009-04-27 14:20:01 +08:00
|
|
|
Record.push_back(E->getOpcode()); // FIXME: stable encoding
|
|
|
|
Writer.AddSourceLocation(E->getOperatorLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_UNARY_OPERATOR;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitOffsetOfExpr(OffsetOfExpr *E) {
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->getNumComponents());
|
|
|
|
Record.push_back(E->getNumExpressions());
|
|
|
|
Writer.AddSourceLocation(E->getOperatorLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRParenLoc(), Record);
|
|
|
|
Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
|
|
|
|
for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
|
|
|
|
const OffsetOfExpr::OffsetOfNode &ON = E->getComponent(I);
|
|
|
|
Record.push_back(ON.getKind()); // FIXME: Stable encoding
|
|
|
|
Writer.AddSourceLocation(ON.getRange().getBegin(), Record);
|
|
|
|
Writer.AddSourceLocation(ON.getRange().getEnd(), Record);
|
|
|
|
switch (ON.getKind()) {
|
|
|
|
case OffsetOfExpr::OffsetOfNode::Array:
|
|
|
|
Record.push_back(ON.getArrayExprIndex());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OffsetOfExpr::OffsetOfNode::Field:
|
|
|
|
Writer.AddDeclRef(ON.getField(), Record);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OffsetOfExpr::OffsetOfNode::Identifier:
|
|
|
|
Writer.AddIdentifierRef(ON.getFieldName(), Record);
|
|
|
|
break;
|
2010-04-29 08:18:15 +08:00
|
|
|
|
|
|
|
case OffsetOfExpr::OffsetOfNode::Base:
|
2010-07-30 02:16:10 +08:00
|
|
|
Writer.AddCXXBaseSpecifier(*ON.getBase(), Record);
|
2010-04-29 08:18:15 +08:00
|
|
|
break;
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getIndexExpr(I));
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_OFFSETOF;
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->isSizeOf());
|
|
|
|
if (E->isArgumentType())
|
2009-12-07 10:54:59 +08:00
|
|
|
Writer.AddTypeSourceInfo(E->getArgumentTypeInfo(), Record);
|
2009-04-27 14:20:01 +08:00
|
|
|
else {
|
|
|
|
Record.push_back(0);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getArgumentExpr());
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
Writer.AddSourceLocation(E->getOperatorLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_SIZEOF_ALIGN_OF;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getLHS());
|
|
|
|
Writer.AddStmt(E->getRHS());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(E->getRBracketLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_ARRAY_SUBSCRIPT;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCallExpr(CallExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->getNumArgs());
|
|
|
|
Writer.AddSourceLocation(E->getRParenLoc(), Record);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getCallee());
|
2009-04-27 14:20:01 +08:00
|
|
|
for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
|
|
|
|
Arg != ArgEnd; ++Arg)
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(*Arg);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CALL;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitMemberExpr(MemberExpr *E) {
|
2010-07-08 21:09:47 +08:00
|
|
|
// Don't call VisitExpr, we'll write everything here.
|
|
|
|
|
|
|
|
Record.push_back(E->hasQualifier());
|
|
|
|
if (E->hasQualifier()) {
|
|
|
|
Writer.AddNestedNameSpecifier(E->getQualifier(), Record);
|
|
|
|
Writer.AddSourceRange(E->getQualifierRange(), Record);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned NumTemplateArgs = E->getNumTemplateArgs();
|
2010-08-20 07:49:38 +08:00
|
|
|
assert((NumTemplateArgs != 0) == E->hasExplicitTemplateArgs() &&
|
2010-07-08 21:09:47 +08:00
|
|
|
"Template args list with no args ?");
|
|
|
|
Record.push_back(NumTemplateArgs);
|
|
|
|
if (NumTemplateArgs) {
|
|
|
|
Writer.AddSourceLocation(E->getLAngleLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRAngleLoc(), Record);
|
|
|
|
for (unsigned i=0; i != NumTemplateArgs; ++i)
|
|
|
|
Writer.AddTemplateArgumentLoc(E->getTemplateArgs()[i], Record);
|
|
|
|
}
|
|
|
|
|
|
|
|
DeclAccessPair FoundDecl = E->getFoundDecl();
|
|
|
|
Writer.AddDeclRef(FoundDecl.getDecl(), Record);
|
|
|
|
Record.push_back(FoundDecl.getAccess());
|
|
|
|
|
|
|
|
Writer.AddTypeRef(E->getType(), Record);
|
2010-11-18 14:31:45 +08:00
|
|
|
Record.push_back(E->getValueKind());
|
|
|
|
Record.push_back(E->getObjectKind());
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getBase());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddDeclRef(E->getMemberDecl(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getMemberLoc(), Record);
|
|
|
|
Record.push_back(E->isArrow());
|
2010-10-16 02:21:24 +08:00
|
|
|
Writer.AddDeclarationNameLoc(E->MemberDNLoc,
|
|
|
|
E->getMemberDecl()->getDeclName(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_MEMBER;
|
2009-07-25 01:54:45 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr *E) {
|
2009-07-25 01:54:45 +08:00
|
|
|
VisitExpr(E);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getBase());
|
2009-07-25 01:54:45 +08:00
|
|
|
Writer.AddSourceLocation(E->getIsaMemberLoc(), Record);
|
|
|
|
Record.push_back(E->isArrow());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_OBJC_ISA;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCastExpr(CastExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
2010-08-07 14:22:56 +08:00
|
|
|
Record.push_back(E->path_size());
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getSubExpr());
|
2009-07-31 08:48:10 +08:00
|
|
|
Record.push_back(E->getCastKind()); // FIXME: stable encoding
|
2010-08-07 14:22:56 +08:00
|
|
|
|
|
|
|
for (CastExpr::path_iterator
|
|
|
|
PI = E->path_begin(), PE = E->path_end(); PI != PE; ++PI)
|
|
|
|
Writer.AddCXXBaseSpecifier(**PI, Record);
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitBinaryOperator(BinaryOperator *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getLHS());
|
|
|
|
Writer.AddStmt(E->getRHS());
|
2009-04-27 14:20:01 +08:00
|
|
|
Record.push_back(E->getOpcode()); // FIXME: stable encoding
|
|
|
|
Writer.AddSourceLocation(E->getOperatorLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_BINARY_OPERATOR;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitBinaryOperator(E);
|
|
|
|
Writer.AddTypeRef(E->getComputationLHSType(), Record);
|
|
|
|
Writer.AddTypeRef(E->getComputationResultType(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_COMPOUND_ASSIGN_OPERATOR;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitConditionalOperator(ConditionalOperator *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getCond());
|
|
|
|
Writer.AddStmt(E->getLHS());
|
|
|
|
Writer.AddStmt(E->getRHS());
|
2010-09-01 02:02:20 +08:00
|
|
|
Writer.AddStmt(E->getSAVE());
|
2009-08-26 22:37:04 +08:00
|
|
|
Writer.AddSourceLocation(E->getQuestionLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getColonLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CONDITIONAL_OPERATOR;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitImplicitCastExpr(ImplicitCastExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitCastExpr(E);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_IMPLICIT_CAST;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitExplicitCastExpr(ExplicitCastExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitCastExpr(E);
|
2010-01-16 02:39:57 +08:00
|
|
|
Writer.AddTypeSourceInfo(E->getTypeInfoAsWritten(), Record);
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCStyleCastExpr(CStyleCastExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExplicitCastExpr(E);
|
|
|
|
Writer.AddSourceLocation(E->getLParenLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CSTYLE_CAST;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddSourceLocation(E->getLParenLoc(), Record);
|
2010-01-19 03:35:47 +08:00
|
|
|
Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getInitializer());
|
2009-04-27 14:20:01 +08:00
|
|
|
Record.push_back(E->isFileScope());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_COMPOUND_LITERAL;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getBase());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddIdentifierRef(&E->getAccessor(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getAccessorLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_EXT_VECTOR_ELEMENT;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitInitListExpr(InitListExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->getNumInits());
|
|
|
|
for (unsigned I = 0, N = E->getNumInits(); I != N; ++I)
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getInit(I));
|
|
|
|
Writer.AddStmt(E->getSyntacticForm());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(E->getLBraceLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRBraceLoc(), Record);
|
|
|
|
Writer.AddDeclRef(E->getInitializedFieldInUnion(), Record);
|
|
|
|
Record.push_back(E->hadArrayRangeDesignator());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_INIT_LIST;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->getNumSubExprs());
|
|
|
|
for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getSubExpr(I));
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(E->getEqualOrColonLoc(), Record);
|
|
|
|
Record.push_back(E->usesGNUSyntax());
|
|
|
|
for (DesignatedInitExpr::designators_iterator D = E->designators_begin(),
|
|
|
|
DEnd = E->designators_end();
|
|
|
|
D != DEnd; ++D) {
|
|
|
|
if (D->isFieldDesignator()) {
|
|
|
|
if (FieldDecl *Field = D->getField()) {
|
2010-08-19 07:57:32 +08:00
|
|
|
Record.push_back(serialization::DESIG_FIELD_DECL);
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddDeclRef(Field, Record);
|
|
|
|
} else {
|
2010-08-19 07:57:32 +08:00
|
|
|
Record.push_back(serialization::DESIG_FIELD_NAME);
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddIdentifierRef(D->getFieldName(), Record);
|
|
|
|
}
|
|
|
|
Writer.AddSourceLocation(D->getDotLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(D->getFieldLoc(), Record);
|
|
|
|
} else if (D->isArrayDesignator()) {
|
2010-08-19 07:57:32 +08:00
|
|
|
Record.push_back(serialization::DESIG_ARRAY);
|
2009-04-27 14:20:01 +08:00
|
|
|
Record.push_back(D->getFirstExprIndex());
|
|
|
|
Writer.AddSourceLocation(D->getLBracketLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(D->getRBracketLoc(), Record);
|
|
|
|
} else {
|
|
|
|
assert(D->isArrayRangeDesignator() && "Unknown designator");
|
2010-08-19 07:57:32 +08:00
|
|
|
Record.push_back(serialization::DESIG_ARRAY_RANGE);
|
2009-04-27 14:20:01 +08:00
|
|
|
Record.push_back(D->getFirstExprIndex());
|
|
|
|
Writer.AddSourceLocation(D->getLBracketLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(D->getEllipsisLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(D->getRBracketLoc(), Record);
|
|
|
|
}
|
|
|
|
}
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_DESIGNATED_INIT;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_IMPLICIT_VALUE_INIT;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitVAArgExpr(VAArgExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getSubExpr());
|
2010-08-10 18:06:15 +08:00
|
|
|
Writer.AddTypeSourceInfo(E->getWrittenTypeInfo(), Record);
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_VA_ARG;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitAddrLabelExpr(AddrLabelExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddSourceLocation(E->getAmpAmpLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getLabelLoc(), Record);
|
|
|
|
Record.push_back(Writer.GetLabelID(E->getLabel()));
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_ADDR_LABEL;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitStmtExpr(StmtExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getSubStmt());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(E->getLParenLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_STMT;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitChooseExpr(ChooseExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getCond());
|
|
|
|
Writer.AddStmt(E->getLHS());
|
|
|
|
Writer.AddStmt(E->getRHS());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CHOOSE;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitGNUNullExpr(GNUNullExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddSourceLocation(E->getTokenLocation(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_GNU_NULL;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->getNumSubExprs());
|
|
|
|
for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getExpr(I));
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_SHUFFLE_VECTOR;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitBlockExpr(BlockExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddDeclRef(E->getBlockDecl(), Record);
|
|
|
|
Record.push_back(E->hasBlockDeclRefExprs());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_BLOCK;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddDeclRef(E->getDecl(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getLocation(), Record);
|
|
|
|
Record.push_back(E->isByRef());
|
2009-06-20 08:02:26 +08:00
|
|
|
Record.push_back(E->isConstQualAdded());
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getCopyConstructorExpr());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_BLOCK_DECL_REF;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Objective-C Expressions and Statements.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitObjCStringLiteral(ObjCStringLiteral *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getString());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(E->getAtLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_OBJC_STRING_LITERAL;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
2010-04-20 23:39:42 +08:00
|
|
|
Writer.AddTypeSourceInfo(E->getEncodedTypeSourceInfo(), Record);
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(E->getAtLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_OBJC_ENCODE;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddSelectorRef(E->getSelector(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getAtLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_OBJC_SELECTOR_EXPR;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddDeclRef(E->getProtocol(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getAtLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_OBJC_PROTOCOL_EXPR;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddDeclRef(E->getDecl(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getLocation(), Record);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getBase());
|
2009-04-27 14:20:01 +08:00
|
|
|
Record.push_back(E->isArrow());
|
|
|
|
Record.push_back(E->isFreeIvar());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_OBJC_IVAR_REF_EXPR;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
2010-12-02 09:19:52 +08:00
|
|
|
Record.push_back(E->isImplicitProperty());
|
|
|
|
if (E->isImplicitProperty()) {
|
|
|
|
Writer.AddDeclRef(E->getImplicitPropertyGetter(), Record);
|
|
|
|
Writer.AddDeclRef(E->getImplicitPropertySetter(), Record);
|
|
|
|
} else {
|
|
|
|
Writer.AddDeclRef(E->getExplicitProperty(), Record);
|
|
|
|
}
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(E->getLocation(), Record);
|
2010-12-02 09:19:52 +08:00
|
|
|
Writer.AddSourceLocation(E->getReceiverLocation(), Record);
|
|
|
|
if (E->isObjectReceiver()) {
|
|
|
|
Record.push_back(0);
|
2010-10-15 00:04:05 +08:00
|
|
|
Writer.AddStmt(E->getBase());
|
2010-12-02 09:19:52 +08:00
|
|
|
} else if (E->isSuperReceiver()) {
|
|
|
|
Record.push_back(1);
|
|
|
|
Writer.AddTypeRef(E->getSuperReceiverType(), Record);
|
|
|
|
} else {
|
|
|
|
Record.push_back(2);
|
|
|
|
Writer.AddDeclRef(E->getClassReceiver(), Record);
|
|
|
|
}
|
2010-10-15 00:04:05 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_OBJC_PROPERTY_REF_EXPR;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitObjCMessageExpr(ObjCMessageExpr *E) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->getNumArgs());
|
Overhaul the AST representation of Objective-C message send
expressions, to improve source-location information, clarify the
actual receiver of the message, and pave the way for proper C++
support. The ObjCMessageExpr node represents four different kinds of
message sends in a single AST node:
1) Send to a object instance described by an expression (e.g., [x method:5])
2) Send to a class described by the class name (e.g., [NSString method:5])
3) Send to a superclass class (e.g, [super method:5] in class method)
4) Send to a superclass instance (e.g., [super method:5] in instance method)
Previously these four cases where tangled together. Now, they have
more distinct representations. Specific changes:
1) Unchanged; the object instance is represented by an Expr*.
2) Previously stored the ObjCInterfaceDecl* referring to the class
receiving the message. Now stores a TypeSourceInfo* so that we know
how the class was spelled. This both maintains typedef information
and opens the door for more complicated C++ types (e.g., dependent
types). There was an alternative, unused representation of these
sends by naming the class via an IdentifierInfo *. In practice, we
either had an ObjCInterfaceDecl *, from which we would get the
IdentifierInfo *, or we fell into the case below...
3) Previously represented by a class message whose IdentifierInfo *
referred to "super". Sema and CodeGen would use isStr("super") to
determine if they had a send to super. Now represented as a
"class super" send, where we have both the location of the "super"
keyword and the ObjCInterfaceDecl* of the superclass we're
targetting (statically).
4) Previously represented by an instance message whose receiver is a
an ObjCSuperExpr, which Sema and CodeGen would check for via
isa<ObjCSuperExpr>(). Now represented as an "instance super" send,
where we have both the location of the "super" keyword and the
ObjCInterfaceDecl* of the superclass we're targetting
(statically). Note that ObjCSuperExpr only has one remaining use in
the AST, which is for "super.prop" references.
The new representation of ObjCMessageExpr is 2 pointers smaller than
the old one, since it combines more storage. It also eliminates a leak
when we loaded message-send expressions from a precompiled header. The
representation also feels much cleaner to me; comments welcome!
This patch attempts to maintain the same semantics we previously had
with Objective-C message sends. In several places, there are massive
changes that boil down to simply replacing a nested-if structure such
as:
if (message has a receiver expression) {
// instance message
if (isa<ObjCSuperExpr>(...)) {
// send to super
} else {
// send to an object
}
} else {
// class message
if (name->isStr("super")) {
// class send to super
} else {
// send to class
}
}
with a switch
switch (E->getReceiverKind()) {
case ObjCMessageExpr::SuperInstance: ...
case ObjCMessageExpr::Instance: ...
case ObjCMessageExpr::SuperClass: ...
case ObjCMessageExpr::Class:...
}
There are quite a few places (particularly in the checkers) where
send-to-super is effectively ignored. I've placed FIXMEs in most of
them, and attempted to address send-to-super in a reasonable way. This
could use some review.
llvm-svn: 101972
2010-04-21 08:45:42 +08:00
|
|
|
Record.push_back((unsigned)E->getReceiverKind()); // FIXME: stable encoding
|
|
|
|
switch (E->getReceiverKind()) {
|
|
|
|
case ObjCMessageExpr::Instance:
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getInstanceReceiver());
|
Overhaul the AST representation of Objective-C message send
expressions, to improve source-location information, clarify the
actual receiver of the message, and pave the way for proper C++
support. The ObjCMessageExpr node represents four different kinds of
message sends in a single AST node:
1) Send to a object instance described by an expression (e.g., [x method:5])
2) Send to a class described by the class name (e.g., [NSString method:5])
3) Send to a superclass class (e.g, [super method:5] in class method)
4) Send to a superclass instance (e.g., [super method:5] in instance method)
Previously these four cases where tangled together. Now, they have
more distinct representations. Specific changes:
1) Unchanged; the object instance is represented by an Expr*.
2) Previously stored the ObjCInterfaceDecl* referring to the class
receiving the message. Now stores a TypeSourceInfo* so that we know
how the class was spelled. This both maintains typedef information
and opens the door for more complicated C++ types (e.g., dependent
types). There was an alternative, unused representation of these
sends by naming the class via an IdentifierInfo *. In practice, we
either had an ObjCInterfaceDecl *, from which we would get the
IdentifierInfo *, or we fell into the case below...
3) Previously represented by a class message whose IdentifierInfo *
referred to "super". Sema and CodeGen would use isStr("super") to
determine if they had a send to super. Now represented as a
"class super" send, where we have both the location of the "super"
keyword and the ObjCInterfaceDecl* of the superclass we're
targetting (statically).
4) Previously represented by an instance message whose receiver is a
an ObjCSuperExpr, which Sema and CodeGen would check for via
isa<ObjCSuperExpr>(). Now represented as an "instance super" send,
where we have both the location of the "super" keyword and the
ObjCInterfaceDecl* of the superclass we're targetting
(statically). Note that ObjCSuperExpr only has one remaining use in
the AST, which is for "super.prop" references.
The new representation of ObjCMessageExpr is 2 pointers smaller than
the old one, since it combines more storage. It also eliminates a leak
when we loaded message-send expressions from a precompiled header. The
representation also feels much cleaner to me; comments welcome!
This patch attempts to maintain the same semantics we previously had
with Objective-C message sends. In several places, there are massive
changes that boil down to simply replacing a nested-if structure such
as:
if (message has a receiver expression) {
// instance message
if (isa<ObjCSuperExpr>(...)) {
// send to super
} else {
// send to an object
}
} else {
// class message
if (name->isStr("super")) {
// class send to super
} else {
// send to class
}
}
with a switch
switch (E->getReceiverKind()) {
case ObjCMessageExpr::SuperInstance: ...
case ObjCMessageExpr::Instance: ...
case ObjCMessageExpr::SuperClass: ...
case ObjCMessageExpr::Class:...
}
There are quite a few places (particularly in the checkers) where
send-to-super is effectively ignored. I've placed FIXMEs in most of
them, and attempted to address send-to-super in a reasonable way. This
could use some review.
llvm-svn: 101972
2010-04-21 08:45:42 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ObjCMessageExpr::Class:
|
|
|
|
Writer.AddTypeSourceInfo(E->getClassReceiverTypeInfo(), Record);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ObjCMessageExpr::SuperClass:
|
|
|
|
case ObjCMessageExpr::SuperInstance:
|
|
|
|
Writer.AddTypeRef(E->getSuperType(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getSuperLoc(), Record);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (E->getMethodDecl()) {
|
|
|
|
Record.push_back(1);
|
|
|
|
Writer.AddDeclRef(E->getMethodDecl(), Record);
|
|
|
|
} else {
|
|
|
|
Record.push_back(0);
|
|
|
|
Writer.AddSelectorRef(E->getSelector(), Record);
|
|
|
|
}
|
|
|
|
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(E->getLeftLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRightLoc(), Record);
|
2010-12-11 04:08:27 +08:00
|
|
|
Writer.AddSourceLocation(E->getSelectorLoc(), Record);
|
2009-04-27 14:20:01 +08:00
|
|
|
|
|
|
|
for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
|
|
|
|
Arg != ArgEnd; ++Arg)
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(*Arg);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_OBJC_MESSAGE_EXPR;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
VisitStmt(S);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getElement());
|
|
|
|
Writer.AddStmt(S->getCollection());
|
|
|
|
Writer.AddStmt(S->getBody());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(S->getForLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(S->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_OBJC_FOR_COLLECTION;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getCatchBody());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddDeclRef(S->getCatchParamDecl(), Record);
|
|
|
|
Writer.AddSourceLocation(S->getAtCatchLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(S->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_OBJC_CATCH;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getFinallyBody());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(S->getAtFinallyLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_OBJC_FINALLY;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
|
2010-04-24 06:50:49 +08:00
|
|
|
Record.push_back(S->getNumCatchStmts());
|
|
|
|
Record.push_back(S->getFinallyStmt() != 0);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getTryBody());
|
2010-04-24 06:50:49 +08:00
|
|
|
for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getCatchStmt(I));
|
2010-04-24 06:50:49 +08:00
|
|
|
if (S->getFinallyStmt())
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getFinallyStmt());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(S->getAtTryLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_OBJC_AT_TRY;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getSynchExpr());
|
|
|
|
Writer.AddStmt(S->getSynchBody());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(S->getAtSynchronizedLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_OBJC_AT_SYNCHRONIZED;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(S->getThrowExpr());
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.AddSourceLocation(S->getThrowLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_OBJC_AT_THROW;
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
2009-07-14 11:19:21 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// C++ Expressions and Statements.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXCatchStmt(CXXCatchStmt *S) {
|
2010-07-23 00:03:56 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
Writer.AddSourceLocation(S->getCatchLoc(), Record);
|
|
|
|
Writer.AddDeclRef(S->getExceptionDecl(), Record);
|
|
|
|
Writer.AddStmt(S->getHandlerBlock());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_CXX_CATCH;
|
2010-07-23 00:03:56 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXTryStmt(CXXTryStmt *S) {
|
2010-07-23 00:03:56 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
Record.push_back(S->getNumHandlers());
|
|
|
|
Writer.AddSourceLocation(S->getTryLoc(), Record);
|
|
|
|
Writer.AddStmt(S->getTryBlock());
|
|
|
|
for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
|
|
|
|
Writer.AddStmt(S->getHandler(i));
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::STMT_CXX_TRY;
|
2010-07-23 00:03:56 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
|
2009-07-14 11:19:21 +08:00
|
|
|
VisitCallExpr(E);
|
|
|
|
Record.push_back(E->getOperator());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_OPERATOR_CALL;
|
2009-07-14 11:19:21 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
|
2010-05-09 13:36:05 +08:00
|
|
|
VisitCallExpr(E);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_MEMBER_CALL;
|
2010-05-09 13:36:05 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXConstructExpr(CXXConstructExpr *E) {
|
2009-09-10 07:08:42 +08:00
|
|
|
VisitExpr(E);
|
2010-06-24 16:57:09 +08:00
|
|
|
Record.push_back(E->getNumArgs());
|
|
|
|
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getArg(I));
|
2009-09-10 07:08:42 +08:00
|
|
|
Writer.AddDeclRef(E->getConstructor(), Record);
|
2009-12-16 09:38:02 +08:00
|
|
|
Writer.AddSourceLocation(E->getLocation(), Record);
|
2009-09-10 07:08:42 +08:00
|
|
|
Record.push_back(E->isElidable());
|
2009-12-17 02:50:27 +08:00
|
|
|
Record.push_back(E->requiresZeroInitialization());
|
2010-05-15 08:13:29 +08:00
|
|
|
Record.push_back(E->getConstructionKind()); // FIXME: stable encoding
|
2010-10-25 16:47:36 +08:00
|
|
|
Writer.AddSourceRange(E->getParenRange(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_CONSTRUCT;
|
2009-09-10 07:08:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
|
2010-07-10 19:46:15 +08:00
|
|
|
VisitCXXConstructExpr(E);
|
2010-09-08 08:15:04 +08:00
|
|
|
Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_TEMPORARY_OBJECT;
|
2010-07-10 19:46:15 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
|
2010-01-17 05:21:01 +08:00
|
|
|
VisitExplicitCastExpr(E);
|
|
|
|
Writer.AddSourceLocation(E->getOperatorLoc(), Record);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
|
2010-01-17 05:21:01 +08:00
|
|
|
VisitCXXNamedCastExpr(E);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_STATIC_CAST;
|
2010-01-17 05:21:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
|
2010-01-17 05:21:01 +08:00
|
|
|
VisitCXXNamedCastExpr(E);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_DYNAMIC_CAST;
|
2010-01-17 05:21:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
|
2010-01-17 05:21:01 +08:00
|
|
|
VisitCXXNamedCastExpr(E);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_REINTERPRET_CAST;
|
2010-01-17 05:21:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
|
2010-01-17 05:21:01 +08:00
|
|
|
VisitCXXNamedCastExpr(E);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_CONST_CAST;
|
2010-01-17 05:21:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
|
2010-01-17 05:21:01 +08:00
|
|
|
VisitExplicitCastExpr(E);
|
|
|
|
Writer.AddSourceLocation(E->getTypeBeginLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_FUNCTIONAL_CAST;
|
2010-01-17 05:21:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
|
2010-02-07 14:32:43 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->getValue());
|
|
|
|
Writer.AddSourceLocation(E->getLocation(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_BOOL_LITERAL;
|
2010-02-07 14:32:43 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
|
2010-02-07 14:32:43 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddSourceLocation(E->getLocation(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_NULL_PTR_LITERAL;
|
2010-02-07 14:32:43 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
|
2010-05-09 14:03:39 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddSourceRange(E->getSourceRange(), Record);
|
|
|
|
if (E->isTypeOperand()) {
|
|
|
|
Writer.AddTypeSourceInfo(E->getTypeOperandSourceInfo(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_TYPEID_TYPE;
|
2010-05-09 14:03:39 +08:00
|
|
|
} else {
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getExprOperand());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_TYPEID_EXPR;
|
2010-05-09 14:03:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-08 20:20:18 +08:00
|
|
|
void ASTStmtWriter::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
|
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddSourceRange(E->getSourceRange(), Record);
|
|
|
|
if (E->isTypeOperand()) {
|
|
|
|
Writer.AddTypeSourceInfo(E->getTypeOperandSourceInfo(), Record);
|
|
|
|
Code = serialization::EXPR_CXX_UUIDOF_TYPE;
|
|
|
|
} else {
|
|
|
|
Writer.AddStmt(E->getExprOperand());
|
|
|
|
Code = serialization::EXPR_CXX_UUIDOF_EXPR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXThisExpr(CXXThisExpr *E) {
|
2010-05-09 14:15:05 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddSourceLocation(E->getLocation(), Record);
|
|
|
|
Record.push_back(E->isImplicit());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_THIS;
|
2010-05-09 14:15:05 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXThrowExpr(CXXThrowExpr *E) {
|
2010-05-09 14:40:08 +08:00
|
|
|
VisitExpr(E);
|
2010-05-09 14:15:05 +08:00
|
|
|
Writer.AddSourceLocation(E->getThrowLoc(), Record);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getSubExpr());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_THROW;
|
2010-05-09 14:15:05 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
|
2010-05-09 14:40:08 +08:00
|
|
|
VisitExpr(E);
|
2010-07-03 07:30:15 +08:00
|
|
|
|
|
|
|
bool HasOtherExprStored = E->Param.getInt();
|
|
|
|
// Store these first, the reader reads them before creation.
|
|
|
|
Record.push_back(HasOtherExprStored);
|
|
|
|
if (HasOtherExprStored)
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getExpr());
|
2010-07-03 07:30:15 +08:00
|
|
|
Writer.AddDeclRef(E->getParam(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getUsedLocation(), Record);
|
2010-05-09 14:40:08 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_DEFAULT_ARG;
|
2010-05-09 14:40:08 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
|
2010-05-10 08:25:06 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddCXXTemporary(E->getTemporary(), Record);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getSubExpr());
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_BIND_TEMPORARY;
|
2010-05-10 08:25:06 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
|
2010-05-10 09:22:27 +08:00
|
|
|
VisitExpr(E);
|
2010-09-08 08:15:04 +08:00
|
|
|
Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
|
2010-05-10 09:22:27 +08:00
|
|
|
Writer.AddSourceLocation(E->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_SCALAR_VALUE_INIT;
|
2010-05-10 09:22:27 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXNewExpr(CXXNewExpr *E) {
|
2010-05-10 09:22:27 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->isGlobalNew());
|
|
|
|
Record.push_back(E->hasInitializer());
|
|
|
|
Record.push_back(E->isArray());
|
|
|
|
Record.push_back(E->getNumPlacementArgs());
|
|
|
|
Record.push_back(E->getNumConstructorArgs());
|
|
|
|
Writer.AddDeclRef(E->getOperatorNew(), Record);
|
|
|
|
Writer.AddDeclRef(E->getOperatorDelete(), Record);
|
|
|
|
Writer.AddDeclRef(E->getConstructor(), Record);
|
2010-09-08 05:49:58 +08:00
|
|
|
Writer.AddTypeSourceInfo(E->getAllocatedTypeSourceInfo(), Record);
|
2010-07-13 23:54:32 +08:00
|
|
|
Writer.AddSourceRange(E->getTypeIdParens(), Record);
|
2010-05-10 09:22:27 +08:00
|
|
|
Writer.AddSourceLocation(E->getStartLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getEndLoc(), Record);
|
2010-10-25 16:47:36 +08:00
|
|
|
Writer.AddSourceLocation(E->getConstructorLParen(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getConstructorRParen(), Record);
|
2010-05-10 09:22:27 +08:00
|
|
|
for (CXXNewExpr::arg_iterator I = E->raw_arg_begin(), e = E->raw_arg_end();
|
|
|
|
I != e; ++I)
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(*I);
|
2010-05-10 09:22:27 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_NEW;
|
2010-05-10 09:22:27 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
|
2010-06-23 01:07:59 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->isGlobalDelete());
|
|
|
|
Record.push_back(E->isArrayForm());
|
2010-09-14 04:15:54 +08:00
|
|
|
Record.push_back(E->isArrayFormAsWritten());
|
2010-06-23 01:07:59 +08:00
|
|
|
Writer.AddDeclRef(E->getOperatorDelete(), Record);
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getArgument());
|
2010-06-23 01:07:59 +08:00
|
|
|
Writer.AddSourceLocation(E->getSourceRange().getBegin(), Record);
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_DELETE;
|
2010-06-23 01:07:59 +08:00
|
|
|
}
|
2010-05-10 09:22:27 +08:00
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
|
2010-06-28 17:32:03 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
|
|
|
|
Writer.AddStmt(E->getBase());
|
|
|
|
Record.push_back(E->isArrow());
|
|
|
|
Writer.AddSourceLocation(E->getOperatorLoc(), Record);
|
|
|
|
Writer.AddNestedNameSpecifier(E->getQualifier(), Record);
|
|
|
|
Writer.AddSourceRange(E->getQualifierRange(), Record);
|
|
|
|
Writer.AddTypeSourceInfo(E->getScopeTypeInfo(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getColonColonLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getTildeLoc(), Record);
|
|
|
|
|
|
|
|
// PseudoDestructorTypeStorage.
|
|
|
|
Writer.AddIdentifierRef(E->getDestroyedTypeIdentifier(), Record);
|
|
|
|
if (E->getDestroyedTypeIdentifier())
|
|
|
|
Writer.AddSourceLocation(E->getDestroyedTypeLoc(), Record);
|
|
|
|
else
|
|
|
|
Writer.AddTypeSourceInfo(E->getDestroyedTypeInfo(), Record);
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_PSEUDO_DESTRUCTOR;
|
2010-06-28 17:32:03 +08:00
|
|
|
}
|
|
|
|
|
2010-12-06 16:20:24 +08:00
|
|
|
void ASTStmtWriter::VisitExprWithCleanups(ExprWithCleanups *E) {
|
2010-05-10 08:25:06 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->getNumTemporaries());
|
|
|
|
for (unsigned i = 0, e = E->getNumTemporaries(); i != e; ++i)
|
|
|
|
Writer.AddCXXTemporary(E->getTemporary(i), Record);
|
|
|
|
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getSubExpr());
|
2010-12-06 16:20:24 +08:00
|
|
|
Code = serialization::EXPR_EXPR_WITH_CLEANUPS;
|
2010-05-10 08:25:06 +08:00
|
|
|
}
|
|
|
|
|
2010-06-24 16:57:31 +08:00
|
|
|
void
|
2010-08-19 07:56:27 +08:00
|
|
|
ASTStmtWriter::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
|
2010-06-24 16:57:31 +08:00
|
|
|
VisitExpr(E);
|
2010-06-28 17:31:48 +08:00
|
|
|
|
|
|
|
// Don't emit anything here, NumTemplateArgs must be emitted first.
|
2010-06-24 16:57:31 +08:00
|
|
|
|
|
|
|
if (E->hasExplicitTemplateArgs()) {
|
2010-08-20 07:49:38 +08:00
|
|
|
const ExplicitTemplateArgumentList &Args = E->getExplicitTemplateArgs();
|
2010-06-28 17:31:48 +08:00
|
|
|
assert(Args.NumTemplateArgs &&
|
2010-08-19 07:56:27 +08:00
|
|
|
"Num of template args was zero! AST reading will mess up!");
|
2010-06-28 17:31:48 +08:00
|
|
|
Record.push_back(Args.NumTemplateArgs);
|
|
|
|
AddExplicitTemplateArgumentList(Args);
|
2010-06-24 16:57:31 +08:00
|
|
|
} else {
|
|
|
|
Record.push_back(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!E->isImplicitAccess())
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(E->getBase());
|
2010-06-24 16:57:31 +08:00
|
|
|
else
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(0);
|
2010-06-24 16:57:31 +08:00
|
|
|
Writer.AddTypeRef(E->getBaseType(), Record);
|
|
|
|
Record.push_back(E->isArrow());
|
|
|
|
Writer.AddSourceLocation(E->getOperatorLoc(), Record);
|
|
|
|
Writer.AddNestedNameSpecifier(E->getQualifier(), Record);
|
|
|
|
Writer.AddSourceRange(E->getQualifierRange(), Record);
|
|
|
|
Writer.AddDeclRef(E->getFirstQualifierFoundInScope(), Record);
|
2010-10-16 02:21:24 +08:00
|
|
|
Writer.AddDeclarationNameInfo(E->MemberNameInfo, Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_MEMBER;
|
2010-06-24 16:57:31 +08:00
|
|
|
}
|
|
|
|
|
2010-06-28 17:31:56 +08:00
|
|
|
void
|
2010-08-19 07:56:27 +08:00
|
|
|
ASTStmtWriter::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
|
2010-06-28 17:31:56 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
|
|
|
|
// Don't emit anything here, NumTemplateArgs must be emitted first.
|
|
|
|
|
|
|
|
if (E->hasExplicitTemplateArgs()) {
|
|
|
|
const ExplicitTemplateArgumentList &Args = E->getExplicitTemplateArgs();
|
|
|
|
assert(Args.NumTemplateArgs &&
|
2010-08-19 07:56:27 +08:00
|
|
|
"Num of template args was zero! AST reading will mess up!");
|
2010-06-28 17:31:56 +08:00
|
|
|
Record.push_back(Args.NumTemplateArgs);
|
|
|
|
AddExplicitTemplateArgumentList(Args);
|
|
|
|
} else {
|
|
|
|
Record.push_back(0);
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:21:24 +08:00
|
|
|
Writer.AddDeclarationNameInfo(E->NameInfo, Record);
|
2010-06-28 17:31:56 +08:00
|
|
|
Writer.AddSourceRange(E->getQualifierRange(), Record);
|
|
|
|
Writer.AddNestedNameSpecifier(E->getQualifier(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_DECL_REF;
|
2010-06-28 17:31:56 +08:00
|
|
|
}
|
|
|
|
|
2010-06-24 16:57:31 +08:00
|
|
|
void
|
2010-08-19 07:56:27 +08:00
|
|
|
ASTStmtWriter::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
|
2010-06-24 16:57:31 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->arg_size());
|
|
|
|
for (CXXUnresolvedConstructExpr::arg_iterator
|
|
|
|
ArgI = E->arg_begin(), ArgE = E->arg_end(); ArgI != ArgE; ++ArgI)
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(*ArgI);
|
2010-09-08 08:15:04 +08:00
|
|
|
Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
|
2010-06-24 16:57:31 +08:00
|
|
|
Writer.AddSourceLocation(E->getLParenLoc(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getRParenLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_UNRESOLVED_CONSTRUCT;
|
2010-06-24 16:57:31 +08:00
|
|
|
}
|
2010-05-09 14:15:05 +08:00
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitOverloadExpr(OverloadExpr *E) {
|
2010-06-25 17:03:26 +08:00
|
|
|
VisitExpr(E);
|
2010-06-28 17:31:48 +08:00
|
|
|
|
|
|
|
// Don't emit anything here, NumTemplateArgs must be emitted first.
|
2010-06-25 17:03:26 +08:00
|
|
|
|
|
|
|
if (E->hasExplicitTemplateArgs()) {
|
|
|
|
const ExplicitTemplateArgumentList &Args = E->getExplicitTemplateArgs();
|
|
|
|
assert(Args.NumTemplateArgs &&
|
2010-08-19 07:56:27 +08:00
|
|
|
"Num of template args was zero! AST reading will mess up!");
|
2010-06-25 17:03:26 +08:00
|
|
|
Record.push_back(Args.NumTemplateArgs);
|
2010-06-28 17:31:48 +08:00
|
|
|
AddExplicitTemplateArgumentList(Args);
|
2010-06-25 17:03:26 +08:00
|
|
|
} else {
|
|
|
|
Record.push_back(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
Record.push_back(E->getNumDecls());
|
|
|
|
for (OverloadExpr::decls_iterator
|
|
|
|
OvI = E->decls_begin(), OvE = E->decls_end(); OvI != OvE; ++OvI) {
|
|
|
|
Writer.AddDeclRef(OvI.getDecl(), Record);
|
|
|
|
Record.push_back(OvI.getAccess());
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:21:24 +08:00
|
|
|
Writer.AddDeclarationNameInfo(E->NameInfo, Record);
|
2010-06-25 17:03:26 +08:00
|
|
|
Writer.AddNestedNameSpecifier(E->getQualifier(), Record);
|
|
|
|
Writer.AddSourceRange(E->getQualifierRange(), Record);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
|
2010-06-25 17:03:26 +08:00
|
|
|
VisitOverloadExpr(E);
|
|
|
|
Record.push_back(E->isArrow());
|
|
|
|
Record.push_back(E->hasUnresolvedUsing());
|
2010-06-29 06:28:35 +08:00
|
|
|
Writer.AddStmt(!E->isImplicitAccess() ? E->getBase() : 0);
|
2010-06-25 17:03:26 +08:00
|
|
|
Writer.AddTypeRef(E->getBaseType(), Record);
|
|
|
|
Writer.AddSourceLocation(E->getOperatorLoc(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_UNRESOLVED_MEMBER;
|
2010-06-25 17:03:26 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
|
2010-06-25 17:03:34 +08:00
|
|
|
VisitOverloadExpr(E);
|
|
|
|
Record.push_back(E->requiresADL());
|
|
|
|
Record.push_back(E->isOverloaded());
|
|
|
|
Writer.AddDeclRef(E->getNamingClass(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_UNRESOLVED_LOOKUP;
|
2010-06-25 17:03:34 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:27 +08:00
|
|
|
void ASTStmtWriter::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
|
2010-07-10 19:46:15 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->getTrait());
|
2010-09-14 04:56:31 +08:00
|
|
|
Record.push_back(E->getValue());
|
2010-07-10 19:46:15 +08:00
|
|
|
Writer.AddSourceRange(E->getSourceRange(), Record);
|
2010-09-10 00:14:44 +08:00
|
|
|
Writer.AddTypeSourceInfo(E->getQueriedTypeSourceInfo(), Record);
|
2010-08-19 07:57:32 +08:00
|
|
|
Code = serialization::EXPR_CXX_UNARY_TYPE_TRAIT;
|
2010-07-10 19:46:15 +08:00
|
|
|
}
|
|
|
|
|
2010-12-07 08:08:36 +08:00
|
|
|
void ASTStmtWriter::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
|
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->getTrait());
|
|
|
|
Record.push_back(E->getValue());
|
|
|
|
Writer.AddSourceRange(E->getSourceRange(), Record);
|
|
|
|
Writer.AddTypeSourceInfo(E->getLhsTypeSourceInfo(), Record);
|
|
|
|
Writer.AddTypeSourceInfo(E->getRhsTypeSourceInfo(), Record);
|
2010-12-09 06:35:30 +08:00
|
|
|
Code = serialization::EXPR_BINARY_TYPE_TRAIT;
|
2010-12-07 08:08:36 +08:00
|
|
|
}
|
|
|
|
|
2010-09-11 04:55:54 +08:00
|
|
|
void ASTStmtWriter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
|
|
|
|
VisitExpr(E);
|
|
|
|
Record.push_back(E->getValue());
|
|
|
|
Writer.AddSourceRange(E->getSourceRange(), Record);
|
|
|
|
Writer.AddStmt(E->getOperand());
|
|
|
|
Code = serialization::EXPR_CXX_NOEXCEPT;
|
|
|
|
}
|
|
|
|
|
2011-01-04 01:17:50 +08:00
|
|
|
void ASTStmtWriter::VisitPackExpansionExpr(PackExpansionExpr *E) {
|
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddSourceLocation(E->getEllipsisLoc(), Record);
|
|
|
|
Writer.AddStmt(E->getPattern());
|
|
|
|
Code = serialization::EXPR_PACK_EXPANSION;
|
|
|
|
}
|
|
|
|
|
2011-01-05 01:33:58 +08:00
|
|
|
void ASTStmtWriter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
|
|
|
|
VisitExpr(E);
|
|
|
|
Writer.AddSourceLocation(E->OperatorLoc, Record);
|
|
|
|
Writer.AddSourceLocation(E->PackLoc, Record);
|
|
|
|
Writer.AddSourceLocation(E->RParenLoc, Record);
|
|
|
|
Record.push_back(E->Length);
|
|
|
|
Writer.AddDeclRef(E->Pack, Record);
|
|
|
|
Code = serialization::EXPR_SIZEOF_PACK;
|
|
|
|
}
|
|
|
|
|
2010-11-16 07:31:06 +08:00
|
|
|
void ASTStmtWriter::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
|
|
|
|
VisitExpr(E);
|
|
|
|
Code = serialization::EXPR_OPAQUE_VALUE;
|
|
|
|
}
|
|
|
|
|
2009-04-27 14:20:01 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2010-08-19 07:56:21 +08:00
|
|
|
// ASTWriter Implementation
|
2009-04-27 14:20:01 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-08-19 07:56:21 +08:00
|
|
|
unsigned ASTWriter::RecordSwitchCaseID(SwitchCase *S) {
|
2009-09-09 23:08:12 +08:00
|
|
|
assert(SwitchCaseIDs.find(S) == SwitchCaseIDs.end() &&
|
2009-04-27 14:20:01 +08:00
|
|
|
"SwitchCase recorded twice");
|
|
|
|
unsigned NextID = SwitchCaseIDs.size();
|
|
|
|
SwitchCaseIDs[S] = NextID;
|
|
|
|
return NextID;
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:21 +08:00
|
|
|
unsigned ASTWriter::getSwitchCaseID(SwitchCase *S) {
|
2009-09-09 23:08:12 +08:00
|
|
|
assert(SwitchCaseIDs.find(S) != SwitchCaseIDs.end() &&
|
2009-04-27 14:20:01 +08:00
|
|
|
"SwitchCase hasn't been seen yet");
|
|
|
|
return SwitchCaseIDs[S];
|
|
|
|
}
|
|
|
|
|
2010-10-28 17:29:32 +08:00
|
|
|
void ASTWriter::ClearSwitchCaseIDs() {
|
|
|
|
SwitchCaseIDs.clear();
|
|
|
|
}
|
|
|
|
|
2009-04-27 14:20:01 +08:00
|
|
|
/// \brief Retrieve the ID for the given label statement, which may
|
|
|
|
/// or may not have been emitted yet.
|
2010-08-19 07:56:21 +08:00
|
|
|
unsigned ASTWriter::GetLabelID(LabelStmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
std::map<LabelStmt *, unsigned>::iterator Pos = LabelIDs.find(S);
|
|
|
|
if (Pos != LabelIDs.end())
|
|
|
|
return Pos->second;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-27 14:20:01 +08:00
|
|
|
unsigned NextID = LabelIDs.size();
|
|
|
|
LabelIDs[S] = NextID;
|
|
|
|
return NextID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Write the given substatement or subexpression to the
|
|
|
|
/// bitstream.
|
2010-08-19 07:56:21 +08:00
|
|
|
void ASTWriter::WriteSubStmt(Stmt *S) {
|
2009-04-27 14:20:01 +08:00
|
|
|
RecordData Record;
|
2010-08-19 07:56:27 +08:00
|
|
|
ASTStmtWriter Writer(*this, Record);
|
2009-04-27 14:20:01 +08:00
|
|
|
++NumStatements;
|
2010-06-29 06:28:35 +08:00
|
|
|
|
2009-04-27 14:20:01 +08:00
|
|
|
if (!S) {
|
2010-08-19 07:57:32 +08:00
|
|
|
Stream.EmitRecord(serialization::STMT_NULL_PTR, Record);
|
2009-04-27 14:20:01 +08:00
|
|
|
return;
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-08-19 07:56:21 +08:00
|
|
|
// Redirect ASTWriter::AddStmt to collect sub stmts.
|
2010-06-29 06:28:35 +08:00
|
|
|
llvm::SmallVector<Stmt *, 16> SubStmts;
|
|
|
|
CollectedStmts = &SubStmts;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
Writer.Code = serialization::STMT_NULL_PTR;
|
2009-04-27 14:20:01 +08:00
|
|
|
Writer.Visit(S);
|
2010-05-10 09:22:27 +08:00
|
|
|
|
|
|
|
#ifndef NDEBUG
|
2010-08-19 07:57:32 +08:00
|
|
|
if (Writer.Code == serialization::STMT_NULL_PTR) {
|
2010-06-25 17:03:12 +08:00
|
|
|
SourceManager &SrcMgr
|
|
|
|
= DeclIDs.begin()->first->getASTContext().getSourceManager();
|
|
|
|
S->dump(SrcMgr);
|
2010-08-19 07:56:27 +08:00
|
|
|
assert(0 && "Unhandled sub statement writing AST file");
|
2010-05-10 09:22:27 +08:00
|
|
|
}
|
|
|
|
#endif
|
2010-06-29 06:28:35 +08:00
|
|
|
|
2010-08-19 07:56:21 +08:00
|
|
|
// Revert ASTWriter::AddStmt.
|
2010-06-29 06:28:35 +08:00
|
|
|
CollectedStmts = &StmtsToEmit;
|
|
|
|
|
|
|
|
// Write the sub stmts in reverse order, last to first. When reading them back
|
|
|
|
// we will read them in correct order by "pop"ing them from the Stmts stack.
|
|
|
|
// This simplifies reading and allows to store a variable number of sub stmts
|
|
|
|
// without knowing it in advance.
|
|
|
|
while (!SubStmts.empty())
|
|
|
|
WriteSubStmt(SubStmts.pop_back_val());
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
Stream.EmitRecord(Writer.Code, Record);
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Flush all of the statements that have been added to the
|
|
|
|
/// queue via AddStmt().
|
2010-08-19 07:56:21 +08:00
|
|
|
void ASTWriter::FlushStmts() {
|
2009-04-27 14:20:01 +08:00
|
|
|
RecordData Record;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-27 14:20:01 +08:00
|
|
|
for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) {
|
2010-06-29 06:28:35 +08:00
|
|
|
WriteSubStmt(StmtsToEmit[I]);
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
assert(N == StmtsToEmit.size() &&
|
2009-04-27 14:20:01 +08:00
|
|
|
"Substatement writen via AddStmt rather than WriteSubStmt!");
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-27 14:20:01 +08:00
|
|
|
// Note that we are at the end of a full expression. Any
|
|
|
|
// expression records that follow this one are part of a different
|
|
|
|
// expression.
|
2010-08-19 07:57:32 +08:00
|
|
|
Stream.EmitRecord(serialization::STMT_STOP, Record);
|
2009-04-27 14:20:01 +08:00
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-27 14:20:01 +08:00
|
|
|
StmtsToEmit.clear();
|
|
|
|
}
|