2007-11-01 02:41:19 +08:00
|
|
|
//===--- StmtSerialization.cpp - Serialization of Statements --------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 03:59:25 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-11-01 02:41:19 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the type-specific methods for serializing statements
|
|
|
|
// and expressions.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-01-06 04:52:13 +08:00
|
|
|
#include "clang/Basic/TypeTraits.h"
|
2009-01-17 02:33:17 +08:00
|
|
|
#include "clang/AST/DeclCXX.h"
|
2007-11-07 08:17:35 +08:00
|
|
|
#include "clang/AST/Expr.h"
|
2008-04-08 12:40:51 +08:00
|
|
|
#include "clang/AST/ExprCXX.h"
|
2008-05-30 05:12:08 +08:00
|
|
|
#include "clang/AST/ExprObjC.h"
|
2009-02-07 03:55:15 +08:00
|
|
|
#include "clang/AST/ASTContext.h"
|
2007-11-01 02:41:19 +08:00
|
|
|
#include "llvm/Bitcode/Serialize.h"
|
|
|
|
#include "llvm/Bitcode/Deserialize.h"
|
|
|
|
|
|
|
|
using namespace clang;
|
2007-11-08 06:53:01 +08:00
|
|
|
using llvm::Serializer;
|
|
|
|
using llvm::Deserializer;
|
2007-11-01 02:41:19 +08:00
|
|
|
|
2007-11-08 06:53:01 +08:00
|
|
|
void Stmt::Emit(Serializer& S) const {
|
2007-11-08 06:32:23 +08:00
|
|
|
S.FlushRecord();
|
2007-11-07 08:17:35 +08:00
|
|
|
S.EmitInt(getStmtClass());
|
2007-11-13 02:04:32 +08:00
|
|
|
EmitImpl(S);
|
2007-11-08 06:39:17 +08:00
|
|
|
S.FlushRecord();
|
2007-11-07 08:17:35 +08:00
|
|
|
}
|
2007-11-01 02:41:19 +08:00
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
Stmt* Stmt::Create(Deserializer& D, ASTContext& C) {
|
2007-11-07 08:17:35 +08:00
|
|
|
StmtClass SC = static_cast<StmtClass>(D.ReadInt());
|
2007-11-01 02:41:19 +08:00
|
|
|
|
2007-11-07 08:17:35 +08:00
|
|
|
switch (SC) {
|
|
|
|
default:
|
|
|
|
assert (false && "Not implemented.");
|
|
|
|
return NULL;
|
2007-11-07 08:37:40 +08:00
|
|
|
|
2007-11-09 00:32:00 +08:00
|
|
|
case AddrLabelExprClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return AddrLabelExpr::CreateImpl(D, C);
|
2007-11-09 00:32:00 +08:00
|
|
|
|
2007-11-08 06:53:01 +08:00
|
|
|
case ArraySubscriptExprClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ArraySubscriptExpr::CreateImpl(D, C);
|
2007-11-08 06:53:01 +08:00
|
|
|
|
2007-11-14 06:55:51 +08:00
|
|
|
case AsmStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return AsmStmt::CreateImpl(D, C);
|
2007-11-14 06:55:51 +08:00
|
|
|
|
2007-11-07 08:37:40 +08:00
|
|
|
case BinaryOperatorClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return BinaryOperator::CreateImpl(D, C);
|
2007-11-07 08:17:35 +08:00
|
|
|
|
2007-11-07 13:25:31 +08:00
|
|
|
case BreakStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return BreakStmt::CreateImpl(D, C);
|
2007-11-08 07:32:20 +08:00
|
|
|
|
|
|
|
case CallExprClass:
|
2008-11-15 00:09:21 +08:00
|
|
|
return CallExpr::CreateImpl(D, C, CallExprClass);
|
2007-11-07 13:25:31 +08:00
|
|
|
|
|
|
|
case CaseStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return CaseStmt::CreateImpl(D, C);
|
2007-11-07 13:25:31 +08:00
|
|
|
|
2007-11-08 01:15:49 +08:00
|
|
|
case CharacterLiteralClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return CharacterLiteral::CreateImpl(D, C);
|
2007-11-08 01:15:49 +08:00
|
|
|
|
2008-11-29 12:51:27 +08:00
|
|
|
case ChooseExprClass:
|
|
|
|
return ChooseExpr::CreateImpl(D, C);
|
|
|
|
|
2007-11-08 08:41:37 +08:00
|
|
|
case CompoundAssignOperatorClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return CompoundAssignOperator::CreateImpl(D, C);
|
2007-11-08 08:41:37 +08:00
|
|
|
|
2007-11-15 05:18:36 +08:00
|
|
|
case CompoundLiteralExprClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return CompoundLiteralExpr::CreateImpl(D, C);
|
2007-11-15 05:18:36 +08:00
|
|
|
|
2007-11-07 08:17:35 +08:00
|
|
|
case CompoundStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return CompoundStmt::CreateImpl(D, C);
|
2007-11-09 00:32:00 +08:00
|
|
|
|
|
|
|
case ConditionalOperatorClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ConditionalOperator::CreateImpl(D, C);
|
2007-11-07 08:17:35 +08:00
|
|
|
|
2007-11-08 01:05:07 +08:00
|
|
|
case ContinueStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ContinueStmt::CreateImpl(D, C);
|
2007-11-08 01:05:07 +08:00
|
|
|
|
2007-11-07 08:17:35 +08:00
|
|
|
case DeclRefExprClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return DeclRefExpr::CreateImpl(D, C);
|
2007-11-07 08:17:35 +08:00
|
|
|
|
2007-11-07 08:37:40 +08:00
|
|
|
case DeclStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return DeclStmt::CreateImpl(D, C);
|
2007-11-07 13:25:31 +08:00
|
|
|
|
|
|
|
case DefaultStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return DefaultStmt::CreateImpl(D, C);
|
2007-11-07 15:53:55 +08:00
|
|
|
|
|
|
|
case DoStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return DoStmt::CreateImpl(D, C);
|
2007-11-08 02:45:55 +08:00
|
|
|
|
|
|
|
case FloatingLiteralClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return FloatingLiteral::CreateImpl(D, C);
|
2007-11-07 16:02:55 +08:00
|
|
|
|
|
|
|
case ForStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ForStmt::CreateImpl(D, C);
|
2007-11-07 16:07:46 +08:00
|
|
|
|
2008-11-29 12:51:27 +08:00
|
|
|
case GNUNullExprClass:
|
|
|
|
return GNUNullExpr::CreateImpl(D, C);
|
|
|
|
|
2007-11-07 16:07:46 +08:00
|
|
|
case GotoStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return GotoStmt::CreateImpl(D, C);
|
2007-11-07 13:25:31 +08:00
|
|
|
|
2007-11-07 15:19:30 +08:00
|
|
|
case IfStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return IfStmt::CreateImpl(D, C);
|
2007-11-08 02:53:02 +08:00
|
|
|
|
|
|
|
case ImaginaryLiteralClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ImaginaryLiteral::CreateImpl(D, C);
|
2007-11-07 15:19:30 +08:00
|
|
|
|
2007-11-08 06:39:17 +08:00
|
|
|
case ImplicitCastExprClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ImplicitCastExpr::CreateImpl(D, C);
|
2008-08-19 07:01:59 +08:00
|
|
|
|
2008-10-28 23:36:24 +08:00
|
|
|
case CStyleCastExprClass:
|
|
|
|
return CStyleCastExpr::CreateImpl(D, C);
|
2007-11-08 06:39:17 +08:00
|
|
|
|
2007-11-08 01:02:32 +08:00
|
|
|
case IndirectGotoStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return IndirectGotoStmt::CreateImpl(D, C);
|
2007-11-15 05:31:46 +08:00
|
|
|
|
|
|
|
case InitListExprClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return InitListExpr::CreateImpl(D, C);
|
2007-11-08 01:02:32 +08:00
|
|
|
|
2007-11-07 08:17:35 +08:00
|
|
|
case IntegerLiteralClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return IntegerLiteral::CreateImpl(D, C);
|
2007-11-07 08:40:53 +08:00
|
|
|
|
2007-11-07 08:48:04 +08:00
|
|
|
case LabelStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return LabelStmt::CreateImpl(D, C);
|
2007-11-07 08:48:04 +08:00
|
|
|
|
2007-11-14 06:16:23 +08:00
|
|
|
case MemberExprClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return MemberExpr::CreateImpl(D, C);
|
2007-11-14 06:16:23 +08:00
|
|
|
|
2007-11-07 08:40:53 +08:00
|
|
|
case NullStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return NullStmt::CreateImpl(D, C);
|
2007-11-07 08:37:40 +08:00
|
|
|
|
2007-11-07 13:25:31 +08:00
|
|
|
case ParenExprClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ParenExpr::CreateImpl(D, C);
|
2007-11-07 13:25:31 +08:00
|
|
|
|
2008-08-10 09:53:14 +08:00
|
|
|
case PredefinedExprClass:
|
|
|
|
return PredefinedExpr::CreateImpl(D, C);
|
2007-11-08 01:11:58 +08:00
|
|
|
|
2007-11-07 08:37:40 +08:00
|
|
|
case ReturnStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ReturnStmt::CreateImpl(D, C);
|
2007-11-09 00:32:00 +08:00
|
|
|
|
2008-11-12 01:56:53 +08:00
|
|
|
case SizeOfAlignOfExprClass:
|
|
|
|
return SizeOfAlignOfExpr::CreateImpl(D, C);
|
2007-11-14 06:30:29 +08:00
|
|
|
|
2007-11-09 00:32:00 +08:00
|
|
|
case StmtExprClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return StmtExpr::CreateImpl(D, C);
|
2007-11-09 00:32:00 +08:00
|
|
|
|
2007-11-08 03:08:19 +08:00
|
|
|
case StringLiteralClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return StringLiteral::CreateImpl(D, C);
|
2007-11-07 13:25:31 +08:00
|
|
|
|
|
|
|
case SwitchStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return SwitchStmt::CreateImpl(D, C);
|
2007-11-07 15:50:10 +08:00
|
|
|
|
2007-11-08 08:26:24 +08:00
|
|
|
case UnaryOperatorClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return UnaryOperator::CreateImpl(D, C);
|
2007-11-08 08:26:24 +08:00
|
|
|
|
2007-11-07 15:50:10 +08:00
|
|
|
case WhileStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return WhileStmt::CreateImpl(D, C);
|
2007-11-16 02:10:29 +08:00
|
|
|
|
|
|
|
//==--------------------------------------==//
|
|
|
|
// Objective C
|
|
|
|
//==--------------------------------------==//
|
2007-12-04 08:28:54 +08:00
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
case ObjCAtCatchStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ObjCAtCatchStmt::CreateImpl(D, C);
|
2007-11-16 02:10:29 +08:00
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
case ObjCAtFinallyStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ObjCAtFinallyStmt::CreateImpl(D, C);
|
2008-01-30 05:21:30 +08:00
|
|
|
|
|
|
|
case ObjCAtSynchronizedStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ObjCAtSynchronizedStmt::CreateImpl(D, C);
|
2007-12-04 08:32:22 +08:00
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
case ObjCAtThrowStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ObjCAtThrowStmt::CreateImpl(D, C);
|
2007-12-04 08:40:49 +08:00
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
case ObjCAtTryStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ObjCAtTryStmt::CreateImpl(D, C);
|
2007-12-05 08:43:08 +08:00
|
|
|
|
|
|
|
case ObjCEncodeExprClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ObjCEncodeExpr::CreateImpl(D, C);
|
2007-12-04 08:38:30 +08:00
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
case ObjCForCollectionStmtClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ObjCForCollectionStmt::CreateImpl(D, C);
|
2008-01-05 08:57:49 +08:00
|
|
|
|
2007-11-16 02:10:29 +08:00
|
|
|
case ObjCIvarRefExprClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ObjCIvarRefExpr::CreateImpl(D, C);
|
2007-12-04 08:51:11 +08:00
|
|
|
|
2008-05-02 01:26:20 +08:00
|
|
|
case ObjCMessageExprClass:
|
|
|
|
return ObjCMessageExpr::CreateImpl(D, C);
|
|
|
|
|
2007-12-05 08:43:08 +08:00
|
|
|
case ObjCSelectorExprClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ObjCSelectorExpr::CreateImpl(D, C);
|
2007-12-05 08:43:08 +08:00
|
|
|
|
2007-12-04 08:51:11 +08:00
|
|
|
case ObjCStringLiteralClass:
|
2008-04-08 05:55:54 +08:00
|
|
|
return ObjCStringLiteral::CreateImpl(D, C);
|
2008-04-08 12:40:51 +08:00
|
|
|
|
2008-11-04 22:56:14 +08:00
|
|
|
case ObjCSuperExprClass:
|
|
|
|
return ObjCSuperExpr::CreateImpl(D, C);
|
|
|
|
|
2008-04-08 12:40:51 +08:00
|
|
|
//==--------------------------------------==//
|
|
|
|
// C++
|
|
|
|
//==--------------------------------------==//
|
|
|
|
|
2008-11-15 00:09:21 +08:00
|
|
|
case CXXOperatorCallExprClass:
|
|
|
|
return CXXOperatorCallExpr::CreateImpl(D, C, CXXOperatorCallExprClass);
|
|
|
|
|
2008-05-02 01:26:20 +08:00
|
|
|
case CXXDefaultArgExprClass:
|
|
|
|
return CXXDefaultArgExpr::CreateImpl(D, C);
|
2008-08-22 23:38:55 +08:00
|
|
|
|
|
|
|
case CXXFunctionalCastExprClass:
|
|
|
|
return CXXFunctionalCastExpr::CreateImpl(D, C);
|
|
|
|
|
2008-10-28 03:41:14 +08:00
|
|
|
case CXXStaticCastExprClass:
|
|
|
|
return CXXStaticCastExpr::CreateImpl(D, C, SC);
|
|
|
|
|
|
|
|
case CXXDynamicCastExprClass:
|
|
|
|
return CXXDynamicCastExpr::CreateImpl(D, C, SC);
|
|
|
|
|
|
|
|
case CXXReinterpretCastExprClass:
|
|
|
|
return CXXReinterpretCastExpr::CreateImpl(D, C, SC);
|
|
|
|
|
|
|
|
case CXXConstCastExprClass:
|
|
|
|
return CXXConstCastExpr::CreateImpl(D, C, SC);
|
2008-11-04 22:32:21 +08:00
|
|
|
|
2008-11-11 19:37:55 +08:00
|
|
|
case CXXTypeidExprClass:
|
|
|
|
return CXXTypeidExpr::CreateImpl(D, C);
|
|
|
|
|
2008-11-04 22:32:21 +08:00
|
|
|
case CXXThisExprClass:
|
|
|
|
return CXXThisExpr::CreateImpl(D, C);
|
|
|
|
|
2009-01-17 02:33:17 +08:00
|
|
|
case CXXTemporaryObjectExprClass:
|
|
|
|
return CXXTemporaryObjectExpr::CreateImpl(D, C);
|
|
|
|
|
2008-08-22 23:38:55 +08:00
|
|
|
case CXXZeroInitValueExprClass:
|
|
|
|
return CXXZeroInitValueExpr::CreateImpl(D, C);
|
2008-11-22 03:14:01 +08:00
|
|
|
|
|
|
|
case CXXNewExprClass:
|
|
|
|
return CXXNewExpr::CreateImpl(D, C);
|
|
|
|
|
|
|
|
case CXXDeleteExprClass:
|
|
|
|
return CXXDeleteExpr::CreateImpl(D, C);
|
2008-12-06 08:22:45 +08:00
|
|
|
|
2009-02-04 23:01:18 +08:00
|
|
|
case UnresolvedFunctionNameExprClass:
|
|
|
|
return UnresolvedFunctionNameExpr::CreateImpl(D, C);
|
2008-12-23 03:15:10 +08:00
|
|
|
|
|
|
|
case CXXCatchStmtClass:
|
|
|
|
return CXXCatchStmt::CreateImpl(D, C);
|
2008-12-24 21:02:38 +08:00
|
|
|
|
|
|
|
case CXXTryStmtClass:
|
|
|
|
return CXXTryStmt::CreateImpl(D, C);
|
2009-01-06 13:10:23 +08:00
|
|
|
|
|
|
|
case QualifiedDeclRefExprClass:
|
|
|
|
return QualifiedDeclRefExpr::CreateImpl(D, C);
|
2007-11-07 08:17:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-16 02:10:29 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// C Serialization
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void AddrLabelExpr::EmitImpl(Serializer& S) const {
|
2007-11-09 00:32:00 +08:00
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(AmpAmpLoc);
|
|
|
|
S.Emit(LabelLoc);
|
|
|
|
S.EmitPtr(Label);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
AddrLabelExpr* AddrLabelExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-09 00:32:00 +08:00
|
|
|
QualType t = QualType::ReadVal(D);
|
|
|
|
SourceLocation AALoc = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation LLoc = SourceLocation::ReadVal(D);
|
2009-02-07 03:55:15 +08:00
|
|
|
AddrLabelExpr* expr = new (C, llvm::alignof<AddrLabelExpr>())
|
|
|
|
AddrLabelExpr(AALoc,LLoc,NULL,t);
|
2007-11-09 00:32:00 +08:00
|
|
|
D.ReadPtr(expr->Label); // Pointer may be backpatched.
|
|
|
|
return expr;
|
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void ArraySubscriptExpr::EmitImpl(Serializer& S) const {
|
2007-11-08 06:53:01 +08:00
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(RBracketLoc);
|
|
|
|
S.BatchEmitOwnedPtrs(getLHS(),getRHS());
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ArraySubscriptExpr* ArraySubscriptExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-08 06:53:01 +08:00
|
|
|
QualType t = QualType::ReadVal(D);
|
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
|
|
|
Expr *LHS, *RHS;
|
2008-04-08 05:55:54 +08:00
|
|
|
D.BatchReadOwnedPtrs(LHS, RHS, C);
|
2009-02-07 03:55:15 +08:00
|
|
|
return new (C, llvm::alignof<ArraySubscriptExpr>())
|
|
|
|
ArraySubscriptExpr(LHS,RHS,t,L);
|
2007-11-08 06:53:01 +08:00
|
|
|
}
|
|
|
|
|
2007-11-14 06:55:51 +08:00
|
|
|
void AsmStmt::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(AsmLoc);
|
2007-11-22 09:36:19 +08:00
|
|
|
|
2007-11-21 03:21:03 +08:00
|
|
|
getAsmString()->EmitImpl(S);
|
2007-11-14 06:55:51 +08:00
|
|
|
S.Emit(RParenLoc);
|
2007-11-22 09:36:19 +08:00
|
|
|
|
2007-11-24 07:12:25 +08:00
|
|
|
S.EmitBool(IsVolatile);
|
2008-02-06 07:03:50 +08:00
|
|
|
S.EmitBool(IsSimple);
|
2007-11-22 09:36:19 +08:00
|
|
|
S.EmitInt(NumOutputs);
|
|
|
|
S.EmitInt(NumInputs);
|
|
|
|
|
|
|
|
unsigned size = NumOutputs + NumInputs;
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < size; ++i)
|
|
|
|
S.EmitCStr(Names[i].c_str());
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < size; ++i)
|
|
|
|
Constraints[i]->EmitImpl(S);
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < size; ++i)
|
|
|
|
S.EmitOwnedPtr(Exprs[i]);
|
|
|
|
|
|
|
|
S.EmitInt(Clobbers.size());
|
|
|
|
for (unsigned i = 0, e = Clobbers.size(); i != e; ++i)
|
|
|
|
Clobbers[i]->EmitImpl(S);
|
2007-11-14 06:55:51 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
AsmStmt* AsmStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-14 06:55:51 +08:00
|
|
|
SourceLocation ALoc = SourceLocation::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
StringLiteral *AsmStr = StringLiteral::CreateImpl(D, C);
|
2007-11-14 06:55:51 +08:00
|
|
|
SourceLocation PLoc = SourceLocation::ReadVal(D);
|
|
|
|
|
2007-11-24 07:12:25 +08:00
|
|
|
bool IsVolatile = D.ReadBool();
|
2008-02-06 07:03:50 +08:00
|
|
|
bool IsSimple = D.ReadBool();
|
2009-02-07 03:55:15 +08:00
|
|
|
AsmStmt *Stmt = new (C, llvm::alignof<AsmStmt>())
|
|
|
|
AsmStmt(ALoc, IsSimple, IsVolatile, 0, 0, 0, 0, 0, AsmStr, 0, 0, PLoc);
|
2007-11-22 09:36:19 +08:00
|
|
|
|
|
|
|
Stmt->NumOutputs = D.ReadInt();
|
|
|
|
Stmt->NumInputs = D.ReadInt();
|
|
|
|
|
|
|
|
unsigned size = Stmt->NumOutputs + Stmt->NumInputs;
|
|
|
|
|
|
|
|
Stmt->Names.reserve(size);
|
|
|
|
for (unsigned i = 0; i < size; ++i) {
|
|
|
|
std::vector<char> data;
|
|
|
|
D.ReadCStr(data, false);
|
2008-02-23 15:32:49 +08:00
|
|
|
|
|
|
|
Stmt->Names.push_back(std::string(data.begin(), data.end()));
|
2007-11-22 09:36:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Stmt->Constraints.reserve(size);
|
|
|
|
for (unsigned i = 0; i < size; ++i)
|
2008-04-08 05:55:54 +08:00
|
|
|
Stmt->Constraints.push_back(StringLiteral::CreateImpl(D, C));
|
2007-11-22 09:36:19 +08:00
|
|
|
|
|
|
|
Stmt->Exprs.reserve(size);
|
|
|
|
for (unsigned i = 0; i < size; ++i)
|
2008-04-08 05:55:54 +08:00
|
|
|
Stmt->Exprs.push_back(D.ReadOwnedPtr<Expr>(C));
|
2007-11-22 09:36:19 +08:00
|
|
|
|
|
|
|
unsigned NumClobbers = D.ReadInt();
|
|
|
|
Stmt->Clobbers.reserve(NumClobbers);
|
|
|
|
for (unsigned i = 0; i < NumClobbers; ++i)
|
2008-04-08 05:55:54 +08:00
|
|
|
Stmt->Clobbers.push_back(StringLiteral::CreateImpl(D, C));
|
2007-11-22 09:36:19 +08:00
|
|
|
|
|
|
|
return Stmt;
|
2007-11-14 06:55:51 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void BinaryOperator::EmitImpl(Serializer& S) const {
|
2007-11-07 08:37:40 +08:00
|
|
|
S.EmitInt(Opc);
|
|
|
|
S.Emit(OpLoc);;
|
|
|
|
S.Emit(getType());
|
2007-11-08 06:32:23 +08:00
|
|
|
S.BatchEmitOwnedPtrs(getLHS(),getRHS());
|
2007-11-07 08:37:40 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
BinaryOperator* BinaryOperator::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 08:37:40 +08:00
|
|
|
Opcode Opc = static_cast<Opcode>(D.ReadInt());
|
|
|
|
SourceLocation OpLoc = SourceLocation::ReadVal(D);
|
|
|
|
QualType Result = QualType::ReadVal(D);
|
2007-11-08 06:32:23 +08:00
|
|
|
Expr *LHS, *RHS;
|
2008-04-08 05:55:54 +08:00
|
|
|
D.BatchReadOwnedPtrs(LHS, RHS, C);
|
2007-11-08 06:32:23 +08:00
|
|
|
|
2009-02-07 03:55:15 +08:00
|
|
|
return new (C, llvm::alignof<BinaryOperator>())
|
|
|
|
BinaryOperator(LHS,RHS,Opc,Result,OpLoc);
|
2007-11-07 08:37:40 +08:00
|
|
|
}
|
2007-11-01 02:41:19 +08:00
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void BreakStmt::EmitImpl(Serializer& S) const {
|
2007-11-07 13:25:31 +08:00
|
|
|
S.Emit(BreakLoc);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
BreakStmt* BreakStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 13:25:31 +08:00
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
2009-02-07 03:55:15 +08:00
|
|
|
return new (C, llvm::alignof<BreakStmt>()) BreakStmt(Loc);
|
2007-11-07 13:25:31 +08:00
|
|
|
}
|
2007-11-08 07:32:20 +08:00
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void CallExpr::EmitImpl(Serializer& S) const {
|
2007-11-08 07:32:20 +08:00
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(RParenLoc);
|
|
|
|
S.EmitInt(NumArgs);
|
2008-05-02 01:26:20 +08:00
|
|
|
S.BatchEmitOwnedPtrs(NumArgs+1, SubExprs);
|
2007-11-08 07:32:20 +08:00
|
|
|
}
|
|
|
|
|
2008-11-15 00:09:21 +08:00
|
|
|
CallExpr* CallExpr::CreateImpl(Deserializer& D, ASTContext& C, StmtClass SC) {
|
2007-11-08 07:32:20 +08:00
|
|
|
QualType t = QualType::ReadVal(D);
|
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
|
|
|
unsigned NumArgs = D.ReadInt();
|
2009-02-07 03:55:15 +08:00
|
|
|
Stmt** SubExprs = new (C, llvm::alignof<Stmt*>()) Stmt*[NumArgs+1];
|
2008-04-08 05:55:54 +08:00
|
|
|
D.BatchReadOwnedPtrs(NumArgs+1, SubExprs, C);
|
2009-02-07 03:55:15 +08:00
|
|
|
return new (C, llvm::alignof<CallExpr>()) CallExpr(SC, SubExprs,NumArgs,t,L);
|
2007-11-08 07:32:20 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void CaseStmt::EmitImpl(Serializer& S) const {
|
2007-11-07 13:25:31 +08:00
|
|
|
S.Emit(CaseLoc);
|
|
|
|
S.EmitPtr(getNextSwitchCase());
|
2007-11-08 08:56:26 +08:00
|
|
|
S.BatchEmitOwnedPtrs((unsigned) END_EXPR,&SubExprs[0]);
|
2007-11-07 13:25:31 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
CaseStmt* CaseStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 13:25:31 +08:00
|
|
|
SourceLocation CaseLoc = SourceLocation::ReadVal(D);
|
2009-02-07 03:55:15 +08:00
|
|
|
CaseStmt* stmt = new (C, llvm::alignof<CaseStmt>())
|
2009-03-04 12:23:07 +08:00
|
|
|
CaseStmt(NULL,NULL,CaseLoc);
|
2007-11-08 08:56:26 +08:00
|
|
|
D.ReadPtr(stmt->NextSwitchCase);
|
2008-04-08 05:55:54 +08:00
|
|
|
D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubExprs[0], C);
|
2007-11-07 13:25:31 +08:00
|
|
|
return stmt;
|
|
|
|
}
|
2007-11-01 02:41:19 +08:00
|
|
|
|
2008-10-28 23:36:24 +08:00
|
|
|
void CStyleCastExpr::EmitImpl(Serializer& S) const {
|
2007-11-08 06:42:34 +08:00
|
|
|
S.Emit(getType());
|
2008-10-28 03:41:14 +08:00
|
|
|
S.Emit(getTypeAsWritten());
|
2008-11-04 07:29:32 +08:00
|
|
|
S.Emit(LPLoc);
|
|
|
|
S.Emit(RPLoc);
|
2008-08-19 07:01:59 +08:00
|
|
|
S.EmitOwnedPtr(getSubExpr());
|
2007-11-08 06:42:34 +08:00
|
|
|
}
|
|
|
|
|
2008-10-28 23:36:24 +08:00
|
|
|
CStyleCastExpr* CStyleCastExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-08 06:42:34 +08:00
|
|
|
QualType t = QualType::ReadVal(D);
|
2008-10-28 03:41:14 +08:00
|
|
|
QualType writtenTy = QualType::ReadVal(D);
|
2008-11-04 07:29:32 +08:00
|
|
|
SourceLocation LPLoc = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation RPLoc = SourceLocation::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
Expr* Op = D.ReadOwnedPtr<Expr>(C);
|
2009-02-07 03:55:15 +08:00
|
|
|
return new (C, llvm::alignof<CStyleCastExpr>())
|
|
|
|
CStyleCastExpr(t,Op,writtenTy,LPLoc,RPLoc);
|
2007-11-08 06:42:34 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void CharacterLiteral::EmitImpl(Serializer& S) const {
|
2007-11-08 01:15:49 +08:00
|
|
|
S.Emit(Value);
|
|
|
|
S.Emit(Loc);
|
2008-06-08 06:35:38 +08:00
|
|
|
S.EmitBool(IsWide);
|
2007-11-08 01:15:49 +08:00
|
|
|
S.Emit(getType());
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
CharacterLiteral* CharacterLiteral::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-08 01:15:49 +08:00
|
|
|
unsigned value = D.ReadInt();
|
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
2008-06-08 06:35:38 +08:00
|
|
|
bool iswide = D.ReadBool();
|
2007-11-08 01:15:49 +08:00
|
|
|
QualType T = QualType::ReadVal(D);
|
2009-02-07 03:55:15 +08:00
|
|
|
return new (C, llvm::alignof<CharacterLiteral>())
|
|
|
|
CharacterLiteral(value,iswide,T,Loc);
|
2007-11-08 01:15:49 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void CompoundAssignOperator::EmitImpl(Serializer& S) const {
|
2007-11-08 08:41:37 +08:00
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(ComputationType);
|
|
|
|
S.Emit(getOperatorLoc());
|
|
|
|
S.EmitInt(getOpcode());
|
|
|
|
S.BatchEmitOwnedPtrs(getLHS(),getRHS());
|
|
|
|
}
|
|
|
|
|
|
|
|
CompoundAssignOperator*
|
2008-04-08 05:55:54 +08:00
|
|
|
CompoundAssignOperator::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-08 08:41:37 +08:00
|
|
|
QualType t = QualType::ReadVal(D);
|
|
|
|
QualType c = QualType::ReadVal(D);
|
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
|
|
|
Opcode Opc = static_cast<Opcode>(D.ReadInt());
|
|
|
|
Expr* LHS, *RHS;
|
2008-04-08 05:55:54 +08:00
|
|
|
D.BatchReadOwnedPtrs(LHS, RHS, C);
|
2007-11-08 08:41:37 +08:00
|
|
|
|
2009-02-07 03:55:15 +08:00
|
|
|
return new (C, llvm::alignof<CompoundAssignOperator>())
|
|
|
|
CompoundAssignOperator(LHS,RHS,Opc,t,c,L);
|
2007-11-08 08:41:37 +08:00
|
|
|
}
|
|
|
|
|
2007-11-15 05:18:36 +08:00
|
|
|
void CompoundLiteralExpr::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
2008-01-03 05:46:24 +08:00
|
|
|
S.Emit(getLParenLoc());
|
2008-01-15 02:19:28 +08:00
|
|
|
S.EmitBool(isFileScope());
|
2008-01-15 02:29:39 +08:00
|
|
|
S.EmitOwnedPtr(Init);
|
2007-11-15 05:18:36 +08:00
|
|
|
}
|
|
|
|
|
2009-02-07 09:47:29 +08:00
|
|
|
CompoundLiteralExpr* CompoundLiteralExpr::CreateImpl(Deserializer& D,
|
|
|
|
ASTContext& C) {
|
2007-11-15 05:18:36 +08:00
|
|
|
QualType Q = QualType::ReadVal(D);
|
2008-01-03 05:46:24 +08:00
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
2008-01-15 02:19:28 +08:00
|
|
|
bool fileScope = D.ReadBool();
|
2008-04-08 05:55:54 +08:00
|
|
|
Expr* Init = D.ReadOwnedPtr<Expr>(C);
|
2009-02-07 03:55:15 +08:00
|
|
|
return new (C, llvm::alignof<CompoundLiteralExpr>())
|
|
|
|
CompoundLiteralExpr(L, Q, Init, fileScope);
|
2007-11-15 05:18:36 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void CompoundStmt::EmitImpl(Serializer& S) const {
|
2007-11-07 08:17:35 +08:00
|
|
|
S.Emit(LBracLoc);
|
|
|
|
S.Emit(RBracLoc);
|
2009-02-07 09:47:29 +08:00
|
|
|
S.Emit(NumStmts);
|
|
|
|
if (NumStmts) S.BatchEmitOwnedPtrs(NumStmts, &Body[0]);
|
2007-11-07 08:17:35 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
CompoundStmt* CompoundStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 08:17:35 +08:00
|
|
|
SourceLocation LB = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation RB = SourceLocation::ReadVal(D);
|
|
|
|
unsigned size = D.ReadInt();
|
|
|
|
|
2009-02-07 03:55:15 +08:00
|
|
|
CompoundStmt* stmt = new (C, llvm::alignof<CompoundStmt>())
|
2009-02-07 09:47:29 +08:00
|
|
|
CompoundStmt(C, NULL, 0, LB, RB);
|
|
|
|
|
|
|
|
stmt->NumStmts = size;
|
2007-11-07 08:17:35 +08:00
|
|
|
|
2009-02-07 09:47:29 +08:00
|
|
|
if (size) {
|
|
|
|
stmt->Body = new (C) Stmt*[size];
|
|
|
|
D.BatchReadOwnedPtrs(size, &stmt->Body[0], C);
|
|
|
|
}
|
|
|
|
|
2007-11-07 08:17:35 +08:00
|
|
|
return stmt;
|
2007-11-01 02:41:19 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void ConditionalOperator::EmitImpl(Serializer& S) const {
|
2007-11-09 00:32:00 +08:00
|
|
|
S.Emit(getType());
|
|
|
|
S.BatchEmitOwnedPtrs((unsigned) END_EXPR, SubExprs);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ConditionalOperator* ConditionalOperator::CreateImpl(Deserializer& D,
|
|
|
|
ASTContext& C) {
|
|
|
|
|
2007-11-09 00:32:00 +08:00
|
|
|
QualType t = QualType::ReadVal(D);
|
2009-02-07 03:55:15 +08:00
|
|
|
ConditionalOperator* c = new (C, llvm::alignof<ConditionalOperator>())
|
|
|
|
ConditionalOperator(NULL,NULL,NULL,t);
|
2008-04-08 05:55:54 +08:00
|
|
|
D.BatchReadOwnedPtrs((unsigned) END_EXPR, c->SubExprs, C);
|
2007-11-09 00:32:00 +08:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void ContinueStmt::EmitImpl(Serializer& S) const {
|
2007-11-08 01:05:07 +08:00
|
|
|
S.Emit(ContinueLoc);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ContinueStmt* ContinueStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-08 01:05:07 +08:00
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
|
|
|
return new ContinueStmt(Loc);
|
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void DeclStmt::EmitImpl(Serializer& S) const {
|
2008-03-13 14:29:04 +08:00
|
|
|
S.Emit(StartLoc);
|
|
|
|
S.Emit(EndLoc);
|
2008-10-08 07:09:49 +08:00
|
|
|
S.Emit(DG);
|
2008-08-06 23:50:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
DeclStmt* DeclStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
|
|
|
SourceLocation StartLoc = SourceLocation::ReadVal(D);
|
2008-10-08 07:09:49 +08:00
|
|
|
SourceLocation EndLoc = SourceLocation::ReadVal(D);
|
2009-02-14 03:06:18 +08:00
|
|
|
return new DeclStmt(DeclGroupRef::ReadVal(D), StartLoc, EndLoc);
|
2007-11-07 08:17:35 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void DeclRefExpr::EmitImpl(Serializer& S) const {
|
2007-11-07 08:17:35 +08:00
|
|
|
S.Emit(Loc);
|
|
|
|
S.Emit(getType());
|
2009-01-20 09:17:11 +08:00
|
|
|
S.EmitPtr(getDecl());
|
2007-11-07 08:17:35 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
DeclRefExpr* DeclRefExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 08:17:35 +08:00
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
2007-11-16 02:26:39 +08:00
|
|
|
QualType T = QualType::ReadVal(D);
|
2009-01-20 09:17:11 +08:00
|
|
|
DeclRefExpr *DRE = new DeclRefExpr(0, T, Loc);
|
|
|
|
D.ReadPtr(DRE->D);
|
|
|
|
return DRE;
|
2007-11-01 02:41:19 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void DefaultStmt::EmitImpl(Serializer& S) const {
|
2007-11-07 13:25:31 +08:00
|
|
|
S.Emit(DefaultLoc);
|
|
|
|
S.EmitOwnedPtr(getSubStmt());
|
|
|
|
S.EmitPtr(getNextSwitchCase());
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
DefaultStmt* DefaultStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 13:25:31 +08:00
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
Stmt* SubStmt = D.ReadOwnedPtr<Stmt>(C);
|
2007-11-07 13:25:31 +08:00
|
|
|
|
|
|
|
DefaultStmt* stmt = new DefaultStmt(Loc,SubStmt);
|
|
|
|
stmt->setNextSwitchCase(D.ReadPtr<SwitchCase>());
|
|
|
|
|
|
|
|
return stmt;
|
|
|
|
}
|
2007-11-07 08:37:40 +08:00
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void DoStmt::EmitImpl(Serializer& S) const {
|
2007-11-07 15:53:55 +08:00
|
|
|
S.Emit(DoLoc);
|
|
|
|
S.EmitOwnedPtr(getCond());
|
|
|
|
S.EmitOwnedPtr(getBody());
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
DoStmt* DoStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 15:53:55 +08:00
|
|
|
SourceLocation DoLoc = SourceLocation::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
Expr* Cond = D.ReadOwnedPtr<Expr>(C);
|
|
|
|
Stmt* Body = D.ReadOwnedPtr<Stmt>(C);
|
2007-11-07 15:53:55 +08:00
|
|
|
return new DoStmt(Body,Cond,DoLoc);
|
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void FloatingLiteral::EmitImpl(Serializer& S) const {
|
2007-11-08 02:45:55 +08:00
|
|
|
S.Emit(Loc);
|
|
|
|
S.Emit(getType());
|
2007-11-29 08:56:49 +08:00
|
|
|
S.EmitBool(isExact());
|
2007-11-08 02:45:55 +08:00
|
|
|
S.Emit(Value);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
FloatingLiteral* FloatingLiteral::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-08 02:45:55 +08:00
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
|
|
|
QualType t = QualType::ReadVal(D);
|
2007-11-29 08:56:49 +08:00
|
|
|
bool isExact = D.ReadBool();
|
2007-11-08 02:45:55 +08:00
|
|
|
llvm::APFloat Val = llvm::APFloat::ReadVal(D);
|
2007-11-29 08:56:49 +08:00
|
|
|
FloatingLiteral* expr = new FloatingLiteral(Val,&isExact,t,Loc);
|
2007-11-08 02:45:55 +08:00
|
|
|
return expr;
|
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void ForStmt::EmitImpl(Serializer& S) const {
|
2007-11-07 16:02:55 +08:00
|
|
|
S.Emit(ForLoc);
|
|
|
|
S.EmitOwnedPtr(getInit());
|
|
|
|
S.EmitOwnedPtr(getCond());
|
|
|
|
S.EmitOwnedPtr(getInc());
|
|
|
|
S.EmitOwnedPtr(getBody());
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ForStmt* ForStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 16:02:55 +08:00
|
|
|
SourceLocation ForLoc = SourceLocation::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
Stmt* Init = D.ReadOwnedPtr<Stmt>(C);
|
|
|
|
Expr* Cond = D.ReadOwnedPtr<Expr>(C);
|
|
|
|
Expr* Inc = D.ReadOwnedPtr<Expr>(C);
|
|
|
|
Stmt* Body = D.ReadOwnedPtr<Stmt>(C);
|
2007-11-07 16:02:55 +08:00
|
|
|
return new ForStmt(Init,Cond,Inc,Body,ForLoc);
|
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void GotoStmt::EmitImpl(Serializer& S) const {
|
2007-11-07 16:07:46 +08:00
|
|
|
S.Emit(GotoLoc);
|
|
|
|
S.Emit(LabelLoc);
|
|
|
|
S.EmitPtr(Label);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
GotoStmt* GotoStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 16:07:46 +08:00
|
|
|
SourceLocation GotoLoc = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation LabelLoc = SourceLocation::ReadVal(D);
|
|
|
|
GotoStmt* stmt = new GotoStmt(NULL,GotoLoc,LabelLoc);
|
|
|
|
D.ReadPtr(stmt->Label); // This pointer may be backpatched later.
|
|
|
|
return stmt;
|
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void IfStmt::EmitImpl(Serializer& S) const {
|
2007-11-07 15:19:30 +08:00
|
|
|
S.Emit(IfLoc);
|
|
|
|
S.EmitOwnedPtr(getCond());
|
|
|
|
S.EmitOwnedPtr(getThen());
|
|
|
|
S.EmitOwnedPtr(getElse());
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
IfStmt* IfStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 15:19:30 +08:00
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
Expr* Cond = D.ReadOwnedPtr<Expr>(C);
|
|
|
|
Stmt* Then = D.ReadOwnedPtr<Stmt>(C);
|
|
|
|
Stmt* Else = D.ReadOwnedPtr<Stmt>(C);
|
2007-11-07 15:19:30 +08:00
|
|
|
return new IfStmt(L,Cond,Then,Else);
|
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void ImaginaryLiteral::EmitImpl(Serializer& S) const {
|
2007-11-08 02:53:02 +08:00
|
|
|
S.Emit(getType());
|
|
|
|
S.EmitOwnedPtr(Val);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ImaginaryLiteral* ImaginaryLiteral::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-08 02:53:02 +08:00
|
|
|
QualType t = QualType::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
Expr* expr = D.ReadOwnedPtr<Expr>(C);
|
2007-11-08 02:53:02 +08:00
|
|
|
assert (isa<FloatingLiteral>(expr) || isa<IntegerLiteral>(expr));
|
|
|
|
return new ImaginaryLiteral(expr,t);
|
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void ImplicitCastExpr::EmitImpl(Serializer& S) const {
|
2007-11-08 06:39:17 +08:00
|
|
|
S.Emit(getType());
|
2008-08-19 07:01:59 +08:00
|
|
|
S.EmitOwnedPtr(getSubExpr());
|
Implement support for operator overloading using candidate operator
functions for built-in operators, e.g., the builtin
bool operator==(int const*, int const*)
can be used for the expression "x1 == x2" given:
struct X {
operator int const*();
} x1, x2;
The scheme for handling these built-in operators is relatively simple:
for each candidate required by the standard, create a special kind of
candidate function for the built-in. If overload resolution picks the
built-in operator, we perform the appropriate conversions on the
arguments and then let the normal built-in operator take care of it.
There may be some optimization opportunity left: if we can reduce the
number of built-in operator overloads we generate, overload resolution
for these cases will go faster. However, one must be careful when
doing this: GCC generates too few operator overloads in our little
test program, and fails to compile it because none of the overloads it
generates match.
Note that we only support operator overload for non-member binary
operators at the moment. The other operators will follow.
As part of this change, ImplicitCastExpr can now be an lvalue.
llvm-svn: 59148
2008-11-13 01:17:38 +08:00
|
|
|
S.Emit(LvalueCast);
|
2007-11-08 06:39:17 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ImplicitCastExpr* ImplicitCastExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-08 06:39:17 +08:00
|
|
|
QualType t = QualType::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
Expr* Op = D.ReadOwnedPtr<Expr>(C);
|
Implement support for operator overloading using candidate operator
functions for built-in operators, e.g., the builtin
bool operator==(int const*, int const*)
can be used for the expression "x1 == x2" given:
struct X {
operator int const*();
} x1, x2;
The scheme for handling these built-in operators is relatively simple:
for each candidate required by the standard, create a special kind of
candidate function for the built-in. If overload resolution picks the
built-in operator, we perform the appropriate conversions on the
arguments and then let the normal built-in operator take care of it.
There may be some optimization opportunity left: if we can reduce the
number of built-in operator overloads we generate, overload resolution
for these cases will go faster. However, one must be careful when
doing this: GCC generates too few operator overloads in our little
test program, and fails to compile it because none of the overloads it
generates match.
Note that we only support operator overload for non-member binary
operators at the moment. The other operators will follow.
As part of this change, ImplicitCastExpr can now be an lvalue.
llvm-svn: 59148
2008-11-13 01:17:38 +08:00
|
|
|
bool isLvalue = D.ReadBool();
|
|
|
|
return new ImplicitCastExpr(t,Op,isLvalue);
|
2007-11-08 06:39:17 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void IndirectGotoStmt::EmitImpl(Serializer& S) const {
|
2007-11-09 00:32:00 +08:00
|
|
|
S.EmitOwnedPtr(Target);
|
2007-11-08 01:02:32 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
IndirectGotoStmt* IndirectGotoStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
|
|
|
Expr* Target = D.ReadOwnedPtr<Expr>(C);
|
2007-11-09 00:32:00 +08:00
|
|
|
return new IndirectGotoStmt(Target);
|
2007-11-08 01:02:32 +08:00
|
|
|
}
|
|
|
|
|
2007-11-15 05:31:46 +08:00
|
|
|
void InitListExpr::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(LBraceLoc);
|
|
|
|
S.Emit(RBraceLoc);
|
2008-05-01 10:04:18 +08:00
|
|
|
S.EmitInt(InitExprs.size());
|
|
|
|
if (!InitExprs.empty()) S.BatchEmitOwnedPtrs(InitExprs.size(), &InitExprs[0]);
|
2007-11-15 05:31:46 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
InitListExpr* InitListExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-15 05:31:46 +08:00
|
|
|
InitListExpr* expr = new InitListExpr();
|
|
|
|
expr->LBraceLoc = SourceLocation::ReadVal(D);
|
|
|
|
expr->RBraceLoc = SourceLocation::ReadVal(D);
|
2008-05-01 10:04:18 +08:00
|
|
|
unsigned size = D.ReadInt();
|
|
|
|
assert(size);
|
|
|
|
expr->InitExprs.reserve(size);
|
|
|
|
for (unsigned i = 0 ; i < size; ++i) expr->InitExprs.push_back(0);
|
|
|
|
|
|
|
|
D.BatchReadOwnedPtrs(size, &expr->InitExprs[0], C);
|
2007-11-15 05:31:46 +08:00
|
|
|
return expr;
|
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void IntegerLiteral::EmitImpl(Serializer& S) const {
|
2007-11-07 08:17:35 +08:00
|
|
|
S.Emit(Loc);
|
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(getValue());
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
IntegerLiteral* IntegerLiteral::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 08:17:35 +08:00
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
|
|
|
QualType T = QualType::ReadVal(D);
|
2007-11-01 02:41:19 +08:00
|
|
|
|
2007-11-07 08:17:35 +08:00
|
|
|
// Create a dummy APInt because it is more efficient to deserialize
|
|
|
|
// it in place with the deserialized IntegerLiteral. (fewer copies)
|
|
|
|
llvm::APInt temp;
|
|
|
|
IntegerLiteral* expr = new IntegerLiteral(temp,T,Loc);
|
|
|
|
D.Read(expr->Value);
|
|
|
|
|
|
|
|
return expr;
|
2007-11-01 02:41:19 +08:00
|
|
|
}
|
2007-11-07 08:37:40 +08:00
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void LabelStmt::EmitImpl(Serializer& S) const {
|
2007-11-07 08:48:04 +08:00
|
|
|
S.EmitPtr(Label);
|
|
|
|
S.Emit(IdentLoc);
|
|
|
|
S.EmitOwnedPtr(SubStmt);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
LabelStmt* LabelStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 08:48:04 +08:00
|
|
|
IdentifierInfo* Label = D.ReadPtr<IdentifierInfo>();
|
|
|
|
SourceLocation IdentLoc = SourceLocation::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
Stmt* SubStmt = D.ReadOwnedPtr<Stmt>(C);
|
2007-11-07 08:48:04 +08:00
|
|
|
return new LabelStmt(IdentLoc,Label,SubStmt);
|
|
|
|
}
|
|
|
|
|
2007-11-14 06:16:23 +08:00
|
|
|
void MemberExpr::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(MemberLoc);
|
|
|
|
S.EmitPtr(MemberDecl);
|
|
|
|
S.EmitBool(IsArrow);
|
2008-02-07 06:48:16 +08:00
|
|
|
S.Emit(getType());
|
2008-02-07 07:03:14 +08:00
|
|
|
S.EmitOwnedPtr(Base);
|
2007-11-14 06:16:23 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
MemberExpr* MemberExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-14 06:16:23 +08:00
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
2008-12-21 07:49:58 +08:00
|
|
|
NamedDecl* MemberDecl = cast<NamedDecl>(D.ReadPtr<Decl>());
|
2007-11-14 06:16:23 +08:00
|
|
|
bool IsArrow = D.ReadBool();
|
2008-02-07 06:48:16 +08:00
|
|
|
QualType T = QualType::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
Expr* base = D.ReadOwnedPtr<Expr>(C);
|
2007-11-14 06:16:23 +08:00
|
|
|
|
2008-02-07 06:48:16 +08:00
|
|
|
return new MemberExpr(base,IsArrow,MemberDecl,L,T);
|
2007-11-14 06:16:23 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void NullStmt::EmitImpl(Serializer& S) const {
|
2007-11-07 08:40:53 +08:00
|
|
|
S.Emit(SemiLoc);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
NullStmt* NullStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 08:40:53 +08:00
|
|
|
SourceLocation SemiLoc = SourceLocation::ReadVal(D);
|
|
|
|
return new NullStmt(SemiLoc);
|
|
|
|
}
|
2007-11-07 08:37:40 +08:00
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void ParenExpr::EmitImpl(Serializer& S) const {
|
2007-11-07 13:25:31 +08:00
|
|
|
S.Emit(L);
|
|
|
|
S.Emit(R);
|
|
|
|
S.EmitOwnedPtr(Val);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ParenExpr* ParenExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 13:25:31 +08:00
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation R = SourceLocation::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
Expr* val = D.ReadOwnedPtr<Expr>(C);
|
2007-11-07 13:25:31 +08:00
|
|
|
return new ParenExpr(L,R,val);
|
2007-11-08 01:11:58 +08:00
|
|
|
}
|
|
|
|
|
2008-08-10 09:53:14 +08:00
|
|
|
void PredefinedExpr::EmitImpl(Serializer& S) const {
|
2007-11-08 01:11:58 +08:00
|
|
|
S.Emit(Loc);
|
|
|
|
S.EmitInt(getIdentType());
|
|
|
|
S.Emit(getType());
|
|
|
|
}
|
|
|
|
|
2008-08-10 09:53:14 +08:00
|
|
|
PredefinedExpr* PredefinedExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-08 01:11:58 +08:00
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
|
|
|
IdentType it = static_cast<IdentType>(D.ReadInt());
|
|
|
|
QualType Q = QualType::ReadVal(D);
|
2008-08-10 09:53:14 +08:00
|
|
|
return new PredefinedExpr(Loc,Q,it);
|
2007-11-08 01:11:58 +08:00
|
|
|
}
|
2007-11-07 13:25:31 +08:00
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void ReturnStmt::EmitImpl(Serializer& S) const {
|
2007-11-07 08:37:40 +08:00
|
|
|
S.Emit(RetLoc);
|
|
|
|
S.EmitOwnedPtr(RetExpr);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ReturnStmt* ReturnStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 08:37:40 +08:00
|
|
|
SourceLocation RetLoc = SourceLocation::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
Expr* RetExpr = D.ReadOwnedPtr<Expr>(C);
|
2007-11-07 08:37:40 +08:00
|
|
|
return new ReturnStmt(RetLoc,RetExpr);
|
|
|
|
}
|
|
|
|
|
2008-11-12 01:56:53 +08:00
|
|
|
void SizeOfAlignOfExpr::EmitImpl(Serializer& S) const {
|
2007-11-14 06:30:29 +08:00
|
|
|
S.EmitBool(isSizeof);
|
2008-11-12 01:56:53 +08:00
|
|
|
S.EmitBool(isType);
|
|
|
|
if (isType)
|
|
|
|
S.Emit(getArgumentType());
|
|
|
|
else
|
|
|
|
S.EmitOwnedPtr(getArgumentExpr());
|
2007-11-14 06:30:29 +08:00
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(OpLoc);
|
|
|
|
S.Emit(RParenLoc);
|
|
|
|
}
|
|
|
|
|
2008-11-12 01:56:53 +08:00
|
|
|
SizeOfAlignOfExpr*
|
|
|
|
SizeOfAlignOfExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-14 06:30:29 +08:00
|
|
|
bool isSizeof = D.ReadBool();
|
2008-11-12 01:56:53 +08:00
|
|
|
bool isType = D.ReadBool();
|
|
|
|
void *Argument;
|
|
|
|
if (isType)
|
|
|
|
Argument = QualType::ReadVal(D).getAsOpaquePtr();
|
|
|
|
else
|
|
|
|
Argument = D.ReadOwnedPtr<Expr>(C);
|
2007-11-14 06:30:29 +08:00
|
|
|
QualType Res = QualType::ReadVal(D);
|
|
|
|
SourceLocation OpLoc = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation RParenLoc = SourceLocation::ReadVal(D);
|
|
|
|
|
2008-11-12 01:56:53 +08:00
|
|
|
return new SizeOfAlignOfExpr(isSizeof, isType, Argument, Res,
|
|
|
|
OpLoc, RParenLoc);
|
2007-11-14 06:30:29 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void StmtExpr::EmitImpl(Serializer& S) const {
|
2007-11-09 00:32:00 +08:00
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(LParenLoc);
|
|
|
|
S.Emit(RParenLoc);
|
|
|
|
S.EmitOwnedPtr(SubStmt);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
StmtExpr* StmtExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-09 00:32:00 +08:00
|
|
|
QualType t = QualType::ReadVal(D);
|
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation R = SourceLocation::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
CompoundStmt* SubStmt = cast<CompoundStmt>(D.ReadOwnedPtr<Stmt>(C));
|
2007-11-09 00:32:00 +08:00
|
|
|
return new StmtExpr(SubStmt,t,L,R);
|
|
|
|
}
|
|
|
|
|
2008-10-15 00:57:09 +08:00
|
|
|
void TypesCompatibleExpr::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(BuiltinLoc);
|
|
|
|
S.Emit(RParenLoc);
|
|
|
|
S.Emit(Type1);
|
|
|
|
S.Emit(Type2);
|
|
|
|
}
|
|
|
|
|
|
|
|
TypesCompatibleExpr* TypesCompatibleExpr::CreateImpl(llvm::Deserializer& D,
|
|
|
|
ASTContext& C) {
|
|
|
|
QualType RT = QualType::ReadVal(D);
|
|
|
|
SourceLocation BL = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation RP = SourceLocation::ReadVal(D);
|
|
|
|
QualType T1 = QualType::ReadVal(D);
|
|
|
|
QualType T2 = QualType::ReadVal(D);
|
|
|
|
return new TypesCompatibleExpr(RT, BL, T1, T2, RP);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShuffleVectorExpr::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(BuiltinLoc);
|
|
|
|
S.Emit(RParenLoc);
|
|
|
|
S.EmitInt(NumExprs);
|
2008-10-16 01:52:29 +08:00
|
|
|
S.BatchEmitOwnedPtrs(NumExprs, &SubExprs[0]);
|
2008-10-15 00:57:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ShuffleVectorExpr* ShuffleVectorExpr::CreateImpl(llvm::Deserializer& D,
|
|
|
|
ASTContext& C) {
|
|
|
|
QualType T = QualType::ReadVal(D);
|
|
|
|
SourceLocation BL = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation RP = SourceLocation::ReadVal(D);
|
|
|
|
unsigned NumExprs = D.ReadInt();
|
2008-10-16 01:52:29 +08:00
|
|
|
// FIXME: Avoid extra allocation.
|
2008-10-15 00:57:09 +08:00
|
|
|
llvm::SmallVector<Expr*, 4> Exprs(NumExprs);
|
2008-10-16 01:52:29 +08:00
|
|
|
D.BatchReadOwnedPtrs(NumExprs, Exprs.begin(), C);
|
2008-10-15 00:57:09 +08:00
|
|
|
return new ShuffleVectorExpr(Exprs.begin(), NumExprs, T, BL, RP);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChooseExpr::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(BuiltinLoc);
|
|
|
|
S.Emit(RParenLoc);
|
2008-10-16 01:52:29 +08:00
|
|
|
S.BatchEmitOwnedPtrs((unsigned) END_EXPR, &SubExprs[0]);
|
2008-10-15 00:57:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ChooseExpr* ChooseExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) {
|
|
|
|
QualType T = QualType::ReadVal(D);
|
|
|
|
SourceLocation BL = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation RP = SourceLocation::ReadVal(D);
|
2008-10-16 01:52:29 +08:00
|
|
|
ChooseExpr *CE = new ChooseExpr(BL, 0, 0, 0, T, RP);
|
|
|
|
D.BatchReadOwnedPtrs((unsigned) END_EXPR, &CE->SubExprs[0], C);
|
|
|
|
return CE;
|
|
|
|
}
|
|
|
|
|
2008-11-29 12:51:27 +08:00
|
|
|
void GNUNullExpr::EmitImpl(llvm::Serializer &S) const {
|
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(TokenLoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
GNUNullExpr *GNUNullExpr::CreateImpl(llvm::Deserializer &D, ASTContext &C) {
|
|
|
|
QualType T = QualType::ReadVal(D);
|
|
|
|
SourceLocation TL = SourceLocation::ReadVal(D);
|
|
|
|
return new GNUNullExpr(T, TL);
|
|
|
|
}
|
|
|
|
|
2008-10-15 00:57:09 +08:00
|
|
|
void VAArgExpr::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(BuiltinLoc);
|
|
|
|
S.Emit(RParenLoc);
|
|
|
|
S.EmitOwnedPtr(getSubExpr());
|
|
|
|
}
|
|
|
|
|
|
|
|
VAArgExpr* VAArgExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) {
|
|
|
|
QualType T = QualType::ReadVal(D);
|
|
|
|
SourceLocation BL = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation RP = SourceLocation::ReadVal(D);
|
|
|
|
Expr *E = D.ReadOwnedPtr<Expr>(C);
|
|
|
|
return new VAArgExpr(BL, E, T, RP);
|
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void StringLiteral::EmitImpl(Serializer& S) const {
|
2007-11-08 03:08:19 +08:00
|
|
|
S.Emit(getType());
|
2009-02-18 13:49:11 +08:00
|
|
|
assert(0 && "Unimpl loc serialization");
|
2007-11-08 03:08:19 +08:00
|
|
|
S.EmitBool(isWide());
|
|
|
|
S.Emit(getByteLength());
|
|
|
|
|
|
|
|
for (unsigned i = 0 ; i < ByteLength; ++i)
|
|
|
|
S.EmitInt(StrData[i]);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
StringLiteral* StringLiteral::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-08 03:08:19 +08:00
|
|
|
QualType t = QualType::ReadVal(D);
|
2009-02-18 13:49:11 +08:00
|
|
|
assert(0 && "Unimpl loc serialization");
|
|
|
|
//SourceLocation firstTokLoc = SourceLocation::ReadVal(D);
|
|
|
|
//SourceLocation lastTokLoc = SourceLocation::ReadVal(D);
|
2007-11-08 03:08:19 +08:00
|
|
|
bool isWide = D.ReadBool();
|
|
|
|
unsigned ByteLength = D.ReadInt();
|
|
|
|
|
2009-02-18 14:40:38 +08:00
|
|
|
StringLiteral* sl = StringLiteral::Create(C, NULL, 0, isWide, t,
|
|
|
|
SourceLocation());
|
2007-11-08 03:08:19 +08:00
|
|
|
|
2009-02-07 03:55:15 +08:00
|
|
|
char* StrData = new (C, llvm::alignof<char>()) char[ByteLength];
|
2007-11-08 03:08:19 +08:00
|
|
|
for (unsigned i = 0; i < ByteLength; ++i)
|
|
|
|
StrData[i] = (char) D.ReadInt();
|
|
|
|
|
|
|
|
sl->ByteLength = ByteLength;
|
|
|
|
sl->StrData = StrData;
|
|
|
|
|
|
|
|
return sl;
|
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void SwitchStmt::EmitImpl(Serializer& S) const {
|
2007-11-07 13:25:31 +08:00
|
|
|
S.Emit(SwitchLoc);
|
|
|
|
S.EmitOwnedPtr(getCond());
|
|
|
|
S.EmitOwnedPtr(getBody());
|
|
|
|
S.EmitPtr(FirstCase);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
SwitchStmt* SwitchStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 13:25:31 +08:00
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
Stmt* Cond = D.ReadOwnedPtr<Stmt>(C);
|
|
|
|
Stmt* Body = D.ReadOwnedPtr<Stmt>(C);
|
2007-11-07 13:25:31 +08:00
|
|
|
SwitchCase* FirstCase = cast<SwitchCase>(D.ReadPtr<Stmt>());
|
|
|
|
|
|
|
|
SwitchStmt* stmt = new SwitchStmt(cast<Expr>(Cond));
|
|
|
|
stmt->setBody(Body,Loc);
|
|
|
|
stmt->FirstCase = FirstCase;
|
|
|
|
|
|
|
|
return stmt;
|
|
|
|
}
|
2007-11-07 15:50:10 +08:00
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void UnaryOperator::EmitImpl(Serializer& S) const {
|
2007-11-08 08:26:24 +08:00
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(Loc);
|
|
|
|
S.EmitInt(Opc);
|
|
|
|
S.EmitOwnedPtr(Val);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
UnaryOperator* UnaryOperator::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-08 08:26:24 +08:00
|
|
|
QualType t = QualType::ReadVal(D);
|
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
|
|
|
Opcode Opc = static_cast<Opcode>(D.ReadInt());
|
2008-04-08 05:55:54 +08:00
|
|
|
Expr* Val = D.ReadOwnedPtr<Expr>(C);
|
2007-11-08 08:26:24 +08:00
|
|
|
return new UnaryOperator(Val,Opc,t,L);
|
|
|
|
}
|
|
|
|
|
2007-11-13 02:04:32 +08:00
|
|
|
void WhileStmt::EmitImpl(Serializer& S) const {
|
2007-11-07 15:50:10 +08:00
|
|
|
S.Emit(WhileLoc);
|
|
|
|
S.EmitOwnedPtr(getCond());
|
|
|
|
S.EmitOwnedPtr(getBody());
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
WhileStmt* WhileStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-07 15:50:10 +08:00
|
|
|
SourceLocation WhileLoc = SourceLocation::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
Expr* Cond = D.ReadOwnedPtr<Expr>(C);
|
|
|
|
Stmt* Body = D.ReadOwnedPtr<Stmt>(C);
|
2007-11-07 15:50:10 +08:00
|
|
|
return new WhileStmt(Cond,Body,WhileLoc);
|
|
|
|
}
|
2007-11-16 02:10:29 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Objective C Serialization
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
void ObjCAtCatchStmt::EmitImpl(Serializer& S) const {
|
2007-12-04 08:28:54 +08:00
|
|
|
S.Emit(AtCatchLoc);
|
|
|
|
S.Emit(RParenLoc);
|
2008-02-02 05:28:59 +08:00
|
|
|
S.BatchEmitOwnedPtrs((unsigned) END_EXPR, &SubExprs[0]);
|
2007-12-04 08:28:54 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ObjCAtCatchStmt* ObjCAtCatchStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-12-04 08:28:54 +08:00
|
|
|
SourceLocation AtCatchLoc = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation RParenLoc = SourceLocation::ReadVal(D);
|
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
ObjCAtCatchStmt* stmt = new ObjCAtCatchStmt(AtCatchLoc,RParenLoc);
|
2008-04-08 05:55:54 +08:00
|
|
|
D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubExprs[0], C);
|
2007-12-04 08:28:54 +08:00
|
|
|
|
|
|
|
return stmt;
|
|
|
|
}
|
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
void ObjCAtFinallyStmt::EmitImpl(Serializer& S) const {
|
2007-12-04 08:32:22 +08:00
|
|
|
S.Emit(AtFinallyLoc);
|
|
|
|
S.EmitOwnedPtr(AtFinallyStmt);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ObjCAtFinallyStmt* ObjCAtFinallyStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-12-04 08:32:22 +08:00
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
Stmt* AtFinallyStmt = D.ReadOwnedPtr<Stmt>(C);
|
2008-01-08 03:49:32 +08:00
|
|
|
return new ObjCAtFinallyStmt(Loc,AtFinallyStmt);
|
2007-12-04 08:32:22 +08:00
|
|
|
}
|
|
|
|
|
2008-01-30 05:21:30 +08:00
|
|
|
void ObjCAtSynchronizedStmt::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(AtSynchronizedLoc);
|
2008-01-30 06:59:37 +08:00
|
|
|
S.BatchEmitOwnedPtrs((unsigned) END_EXPR,&SubStmts[0]);
|
|
|
|
}
|
2008-01-30 05:21:30 +08:00
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ObjCAtSynchronizedStmt* ObjCAtSynchronizedStmt::CreateImpl(Deserializer& D,
|
|
|
|
ASTContext& C) {
|
|
|
|
|
2008-01-30 05:21:30 +08:00
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
2008-01-30 06:59:37 +08:00
|
|
|
ObjCAtSynchronizedStmt* stmt = new ObjCAtSynchronizedStmt(L,0,0);
|
2008-04-08 05:55:54 +08:00
|
|
|
D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubStmts[0], C);
|
2008-01-30 05:21:30 +08:00
|
|
|
return stmt;
|
|
|
|
}
|
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
void ObjCAtThrowStmt::EmitImpl(Serializer& S) const {
|
2007-12-04 08:40:49 +08:00
|
|
|
S.Emit(AtThrowLoc);
|
|
|
|
S.EmitOwnedPtr(Throw);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ObjCAtThrowStmt* ObjCAtThrowStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-12-04 08:40:49 +08:00
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
Stmt* Throw = D.ReadOwnedPtr<Stmt>(C);
|
2008-01-08 03:49:32 +08:00
|
|
|
return new ObjCAtThrowStmt(L,Throw);
|
2007-12-04 08:40:49 +08:00
|
|
|
}
|
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
void ObjCAtTryStmt::EmitImpl(Serializer& S) const {
|
2007-12-04 08:38:30 +08:00
|
|
|
S.Emit(AtTryLoc);
|
|
|
|
S.BatchEmitOwnedPtrs((unsigned) END_EXPR, &SubStmts[0]);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ObjCAtTryStmt* ObjCAtTryStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-12-04 08:38:30 +08:00
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
2008-01-08 03:49:32 +08:00
|
|
|
ObjCAtTryStmt* stmt = new ObjCAtTryStmt(L,NULL,NULL,NULL);
|
2008-04-08 05:55:54 +08:00
|
|
|
D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubStmts[0], C);
|
2007-12-04 08:38:30 +08:00
|
|
|
return stmt;
|
|
|
|
}
|
|
|
|
|
2007-12-05 08:43:08 +08:00
|
|
|
void ObjCEncodeExpr::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(AtLoc);
|
|
|
|
S.Emit(RParenLoc);
|
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(EncType);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ObjCEncodeExpr* ObjCEncodeExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-12-05 08:43:08 +08:00
|
|
|
SourceLocation AtLoc = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation RParenLoc = SourceLocation::ReadVal(D);
|
|
|
|
QualType T = QualType::ReadVal(D);
|
|
|
|
QualType ET = QualType::ReadVal(D);
|
|
|
|
return new ObjCEncodeExpr(T,ET,AtLoc,RParenLoc);
|
|
|
|
}
|
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
void ObjCForCollectionStmt::EmitImpl(Serializer& S) const {
|
2008-01-05 08:57:49 +08:00
|
|
|
S.Emit(ForLoc);
|
2008-01-10 08:24:29 +08:00
|
|
|
S.Emit(RParenLoc);
|
2008-01-08 02:35:04 +08:00
|
|
|
S.BatchEmitOwnedPtrs(getElement(),getCollection(),getBody());
|
2008-01-05 08:57:49 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ObjCForCollectionStmt* ObjCForCollectionStmt::CreateImpl(Deserializer& D, ASTContext& C) {
|
2008-01-05 08:57:49 +08:00
|
|
|
SourceLocation ForLoc = SourceLocation::ReadVal(D);
|
2008-01-10 08:24:29 +08:00
|
|
|
SourceLocation RParenLoc = SourceLocation::ReadVal(D);
|
2008-01-08 02:35:04 +08:00
|
|
|
Stmt* Element;
|
|
|
|
Expr* Collection;
|
|
|
|
Stmt* Body;
|
2008-04-08 05:55:54 +08:00
|
|
|
D.BatchReadOwnedPtrs(Element, Collection, Body, C);
|
2008-01-10 08:24:29 +08:00
|
|
|
return new ObjCForCollectionStmt(Element,Collection,Body,ForLoc, RParenLoc);
|
2008-01-05 08:57:49 +08:00
|
|
|
}
|
|
|
|
|
2008-10-15 00:57:09 +08:00
|
|
|
void ObjCProtocolExpr::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
|
|
|
S.EmitPtr(Protocol);
|
|
|
|
S.Emit(AtLoc);
|
|
|
|
S.Emit(RParenLoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjCProtocolExpr* ObjCProtocolExpr::CreateImpl(llvm::Deserializer& D,
|
|
|
|
ASTContext& C) {
|
|
|
|
QualType T = QualType::ReadVal(D);
|
|
|
|
ObjCProtocolDecl *PD = D.ReadPtr<ObjCProtocolDecl>();
|
|
|
|
SourceLocation AL = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation RP = SourceLocation::ReadVal(D);
|
|
|
|
return new ObjCProtocolExpr(T, PD, AL, RP);
|
|
|
|
}
|
|
|
|
|
2007-11-16 02:10:29 +08:00
|
|
|
void ObjCIvarRefExpr::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(Loc);
|
|
|
|
S.Emit(getType());
|
|
|
|
S.EmitPtr(getDecl());
|
|
|
|
}
|
2007-12-04 08:38:30 +08:00
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ObjCIvarRefExpr* ObjCIvarRefExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-16 02:10:29 +08:00
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
|
|
|
QualType T = QualType::ReadVal(D);
|
2008-12-19 01:29:46 +08:00
|
|
|
ObjCIvarRefExpr* dr = new ObjCIvarRefExpr(NULL,T,Loc);
|
2007-11-16 02:10:29 +08:00
|
|
|
D.ReadPtr(dr->D,false);
|
|
|
|
return dr;
|
|
|
|
}
|
2007-12-04 08:51:11 +08:00
|
|
|
|
2008-05-30 08:40:33 +08:00
|
|
|
void ObjCPropertyRefExpr::EmitImpl(Serializer& S) const {
|
2008-12-05 00:24:46 +08:00
|
|
|
S.Emit(IdLoc);
|
2008-05-30 08:40:33 +08:00
|
|
|
S.Emit(getType());
|
2008-11-23 02:39:36 +08:00
|
|
|
S.EmitPtr(getProperty());
|
|
|
|
}
|
|
|
|
|
|
|
|
void ObjCKVCRefExpr::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(Loc);
|
|
|
|
S.Emit(getType());
|
|
|
|
S.EmitPtr(getGetterMethod());
|
|
|
|
S.EmitPtr(getSetterMethod());
|
2008-05-30 08:40:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ObjCPropertyRefExpr* ObjCPropertyRefExpr::CreateImpl(Deserializer& D,
|
|
|
|
ASTContext& C) {
|
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
|
|
|
QualType T = QualType::ReadVal(D);
|
|
|
|
ObjCPropertyRefExpr* dr = new ObjCPropertyRefExpr(NULL,T,Loc,0);
|
2008-11-23 02:39:36 +08:00
|
|
|
D.ReadPtr(dr->AsProperty,false);
|
|
|
|
return dr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjCKVCRefExpr* ObjCKVCRefExpr::CreateImpl(Deserializer& D,
|
|
|
|
ASTContext& C) {
|
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
|
|
|
QualType T = QualType::ReadVal(D);
|
2008-11-23 04:25:50 +08:00
|
|
|
ObjCKVCRefExpr* dr = new ObjCKVCRefExpr(NULL,T,NULL,Loc,0);
|
2008-11-23 02:39:36 +08:00
|
|
|
D.ReadPtr(dr->Setter,false);
|
|
|
|
D.ReadPtr(dr->Getter,false);
|
2008-05-30 08:40:33 +08:00
|
|
|
return dr;
|
|
|
|
}
|
|
|
|
|
2008-05-02 01:26:20 +08:00
|
|
|
void ObjCMessageExpr::EmitImpl(Serializer& S) const {
|
2008-06-25 01:00:08 +08:00
|
|
|
S.EmitInt(getFlag());
|
2008-05-02 01:26:20 +08:00
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(SelName);
|
|
|
|
S.Emit(LBracloc);
|
|
|
|
S.Emit(RBracloc);
|
|
|
|
S.EmitInt(NumArgs);
|
|
|
|
S.EmitPtr(MethodProto);
|
|
|
|
|
|
|
|
if (getReceiver())
|
|
|
|
S.BatchEmitOwnedPtrs(NumArgs+1, SubExprs);
|
2008-06-25 01:00:08 +08:00
|
|
|
else {
|
|
|
|
ClassInfo Info = getClassInfo();
|
|
|
|
|
|
|
|
if (Info.first) S.EmitPtr(Info.first);
|
|
|
|
else S.EmitPtr(Info.second);
|
|
|
|
|
2008-05-02 01:26:20 +08:00
|
|
|
S.BatchEmitOwnedPtrs(NumArgs, &SubExprs[ARGS_START]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjCMessageExpr* ObjCMessageExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2008-06-25 01:00:08 +08:00
|
|
|
unsigned flags = D.ReadInt();
|
2008-05-02 01:26:20 +08:00
|
|
|
QualType t = QualType::ReadVal(D);
|
|
|
|
Selector S = Selector::ReadVal(D);
|
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation R = SourceLocation::ReadVal(D);
|
|
|
|
|
|
|
|
// Construct an array for the subexpressions.
|
|
|
|
unsigned NumArgs = D.ReadInt();
|
2008-06-25 01:00:08 +08:00
|
|
|
Stmt** SubExprs = new Stmt*[NumArgs+1];
|
2008-05-02 01:26:20 +08:00
|
|
|
|
|
|
|
// Construct the ObjCMessageExpr object using the special ctor.
|
|
|
|
ObjCMessageExpr* ME = new ObjCMessageExpr(S, t, L, R, SubExprs, NumArgs);
|
|
|
|
|
|
|
|
// Read in the MethodProto. Read the instance variable directly
|
|
|
|
// allows it to be backpatched.
|
|
|
|
D.ReadPtr(ME->MethodProto);
|
|
|
|
|
|
|
|
// Now read in the arguments.
|
|
|
|
|
2008-12-17 04:06:41 +08:00
|
|
|
if ((flags & Flags) == IsInstMeth)
|
2008-05-02 01:26:20 +08:00
|
|
|
D.BatchReadOwnedPtrs(NumArgs+1, SubExprs, C);
|
|
|
|
else {
|
2008-06-25 01:00:08 +08:00
|
|
|
// Read the pointer for Cls/ClassName. The Deserializer will handle the
|
2008-05-02 01:26:20 +08:00
|
|
|
// bit-mangling automatically.
|
2008-06-25 01:00:08 +08:00
|
|
|
SubExprs[RECEIVER] = (Stmt*) ((uintptr_t) flags);
|
2008-05-02 01:26:20 +08:00
|
|
|
D.ReadUIntPtr((uintptr_t&) SubExprs[RECEIVER]);
|
|
|
|
|
|
|
|
// Read the arguments.
|
|
|
|
D.BatchReadOwnedPtrs(NumArgs, &SubExprs[ARGS_START], C);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ME;
|
|
|
|
}
|
|
|
|
|
2007-12-05 08:43:08 +08:00
|
|
|
void ObjCSelectorExpr::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(AtLoc);
|
|
|
|
S.Emit(RParenLoc);
|
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(SelName);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ObjCSelectorExpr* ObjCSelectorExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-12-05 08:43:08 +08:00
|
|
|
SourceLocation AtLoc = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation RParenLoc = SourceLocation::ReadVal(D);
|
|
|
|
QualType T = QualType::ReadVal(D);
|
|
|
|
Selector SelName = Selector::ReadVal(D);
|
|
|
|
|
|
|
|
return new ObjCSelectorExpr(T,SelName,AtLoc,RParenLoc);
|
|
|
|
}
|
|
|
|
|
2007-12-04 08:51:11 +08:00
|
|
|
void ObjCStringLiteral::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(AtLoc);
|
|
|
|
S.Emit(getType());
|
|
|
|
S.EmitOwnedPtr(String);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ObjCStringLiteral* ObjCStringLiteral::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-12-04 08:51:11 +08:00
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
|
|
|
QualType T = QualType::ReadVal(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
StringLiteral* String = cast<StringLiteral>(D.ReadOwnedPtr<Stmt>(C));
|
2007-12-04 08:51:11 +08:00
|
|
|
return new ObjCStringLiteral(String,T,L);
|
|
|
|
}
|
2008-04-08 12:40:51 +08:00
|
|
|
|
2008-11-04 22:56:14 +08:00
|
|
|
void ObjCSuperExpr::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(Loc);
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjCSuperExpr* ObjCSuperExpr::CreateImpl(llvm::Deserializer& D, ASTContext&) {
|
|
|
|
QualType Ty = QualType::ReadVal(D);
|
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
|
|
|
return new ObjCSuperExpr(Loc, Ty);
|
|
|
|
}
|
|
|
|
|
2008-09-04 02:15:37 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Serialization for Clang Extensions.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-10-15 00:57:09 +08:00
|
|
|
void ExtVectorElementExpr::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
|
|
|
S.EmitOwnedPtr(getBase());
|
|
|
|
S.EmitPtr(&Accessor);
|
|
|
|
S.Emit(AccessorLoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
ExtVectorElementExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C) {
|
|
|
|
QualType T = QualType::ReadVal(D);
|
|
|
|
Expr *B = D.ReadOwnedPtr<Expr>(C);
|
|
|
|
IdentifierInfo *A = D.ReadPtr<IdentifierInfo>();
|
|
|
|
SourceLocation AL = SourceLocation::ReadVal(D);
|
2009-02-07 09:47:29 +08:00
|
|
|
return new (C) ExtVectorElementExpr(T, B, *A, AL);
|
2008-10-15 00:57:09 +08:00
|
|
|
}
|
|
|
|
|
2008-09-18 02:37:59 +08:00
|
|
|
void BlockExpr::EmitImpl(Serializer& S) const {
|
2008-09-04 02:15:37 +08:00
|
|
|
S.Emit(getType());
|
2008-10-09 01:01:13 +08:00
|
|
|
S.EmitOwnedPtr(TheBlock);
|
2009-02-20 06:01:56 +08:00
|
|
|
S.EmitBool(HasBlockDeclRefExprs);
|
2008-09-04 02:15:37 +08:00
|
|
|
}
|
|
|
|
|
2008-09-18 02:37:59 +08:00
|
|
|
BlockExpr* BlockExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
2008-10-09 01:01:13 +08:00
|
|
|
QualType T = QualType::ReadVal(D);
|
2009-02-20 06:01:56 +08:00
|
|
|
BlockDecl *B = cast<BlockDecl>(D.ReadOwnedPtr<Decl>(C));
|
|
|
|
bool H = D.ReadBool();
|
|
|
|
return new BlockExpr(B,T,H);
|
2008-09-04 02:15:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void BlockDeclRefExpr::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(Loc);
|
|
|
|
S.Emit(getType());
|
|
|
|
S.EmitBool(false);
|
|
|
|
S.EmitPtr(getDecl());
|
|
|
|
}
|
|
|
|
|
|
|
|
BlockDeclRefExpr* BlockDeclRefExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
|
|
|
assert(0 && "Cannot deserialize BlockDeclRefExpr yet");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-08 12:40:51 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// C++ Serialization
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
void CXXDefaultArgExpr::EmitImpl(Serializer& S) const {
|
|
|
|
S.EmitPtr(Param);
|
|
|
|
}
|
|
|
|
|
|
|
|
CXXDefaultArgExpr *CXXDefaultArgExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
|
|
|
ParmVarDecl* Param = 0;
|
|
|
|
D.ReadPtr(Param, false);
|
|
|
|
return new CXXDefaultArgExpr(Param);
|
|
|
|
}
|
2008-08-22 23:38:55 +08:00
|
|
|
|
|
|
|
void CXXFunctionalCastExpr::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
2008-10-28 03:41:14 +08:00
|
|
|
S.Emit(getTypeAsWritten());
|
2008-08-22 23:38:55 +08:00
|
|
|
S.Emit(TyBeginLoc);
|
|
|
|
S.Emit(RParenLoc);
|
|
|
|
S.EmitOwnedPtr(getSubExpr());
|
|
|
|
}
|
|
|
|
|
|
|
|
CXXFunctionalCastExpr *
|
|
|
|
CXXFunctionalCastExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
|
|
|
QualType Ty = QualType::ReadVal(D);
|
2008-10-28 03:41:14 +08:00
|
|
|
QualType WrittenTy = QualType::ReadVal(D);
|
2008-08-22 23:38:55 +08:00
|
|
|
SourceLocation TyBeginLoc = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation RParenLoc = SourceLocation::ReadVal(D);
|
|
|
|
Expr* SubExpr = D.ReadOwnedPtr<Expr>(C);
|
2008-10-28 03:41:14 +08:00
|
|
|
return new CXXFunctionalCastExpr(Ty, WrittenTy, TyBeginLoc, SubExpr, RParenLoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CXXNamedCastExpr::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(getTypeAsWritten());
|
|
|
|
S.Emit(Loc);
|
|
|
|
S.EmitOwnedPtr(getSubExpr());
|
|
|
|
}
|
|
|
|
|
|
|
|
CXXNamedCastExpr *
|
|
|
|
CXXNamedCastExpr::CreateImpl(Deserializer& D, ASTContext& C, StmtClass SC) {
|
|
|
|
QualType Ty = QualType::ReadVal(D);
|
|
|
|
QualType WrittenTy = QualType::ReadVal(D);
|
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
|
|
|
Expr* SubExpr = D.ReadOwnedPtr<Expr>(C);
|
|
|
|
switch (SC) {
|
|
|
|
case CXXStaticCastExprClass:
|
|
|
|
return new CXXStaticCastExpr(Ty, SubExpr, WrittenTy, Loc);
|
|
|
|
case CXXDynamicCastExprClass:
|
|
|
|
return new CXXDynamicCastExpr(Ty, SubExpr, WrittenTy, Loc);
|
|
|
|
case CXXReinterpretCastExprClass:
|
|
|
|
return new CXXReinterpretCastExpr(Ty, SubExpr, WrittenTy, Loc);
|
|
|
|
case CXXConstCastExprClass:
|
|
|
|
return new CXXConstCastExpr(Ty, SubExpr, WrittenTy, Loc);
|
|
|
|
default:
|
|
|
|
assert(false && "Unknown cast type!");
|
|
|
|
return 0;
|
|
|
|
}
|
2008-08-22 23:38:55 +08:00
|
|
|
}
|
|
|
|
|
2008-11-11 19:37:55 +08:00
|
|
|
void CXXTypeidExpr::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
2008-12-04 07:17:54 +08:00
|
|
|
S.EmitBool(isTypeOperand());
|
2008-11-11 19:37:55 +08:00
|
|
|
if (isTypeOperand()) {
|
|
|
|
S.Emit(getTypeOperand());
|
|
|
|
} else {
|
|
|
|
S.EmitOwnedPtr(getExprOperand());
|
|
|
|
}
|
|
|
|
S.Emit(Range);
|
|
|
|
}
|
|
|
|
|
|
|
|
CXXTypeidExpr*
|
|
|
|
CXXTypeidExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) {
|
|
|
|
QualType Ty = QualType::ReadVal(D);
|
|
|
|
bool isTypeOp = D.ReadBool();
|
|
|
|
void *Operand;
|
|
|
|
if (isTypeOp) {
|
|
|
|
Operand = QualType::ReadVal(D).getAsOpaquePtr();
|
|
|
|
} else {
|
|
|
|
Operand = D.ReadOwnedPtr<Expr>(C);
|
|
|
|
}
|
|
|
|
SourceRange Range = SourceRange::ReadVal(D);
|
|
|
|
return new CXXTypeidExpr(isTypeOp, Operand, Ty, Range);
|
|
|
|
}
|
|
|
|
|
2008-11-04 22:32:21 +08:00
|
|
|
void CXXThisExpr::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(Loc);
|
|
|
|
}
|
|
|
|
|
|
|
|
CXXThisExpr* CXXThisExpr::CreateImpl(llvm::Deserializer& D, ASTContext&) {
|
|
|
|
QualType Ty = QualType::ReadVal(D);
|
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
|
|
|
return new CXXThisExpr(Loc, Ty);
|
|
|
|
}
|
|
|
|
|
2009-01-17 02:33:17 +08:00
|
|
|
void CXXTemporaryObjectExpr::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(TyBeginLoc);
|
|
|
|
S.Emit(RParenLoc);
|
|
|
|
S.EmitPtr(cast<Decl>(Constructor));
|
|
|
|
S.EmitInt(NumArgs);
|
|
|
|
if (NumArgs > 0)
|
|
|
|
S.BatchEmitOwnedPtrs(NumArgs, Args);
|
|
|
|
}
|
|
|
|
|
|
|
|
CXXTemporaryObjectExpr *
|
|
|
|
CXXTemporaryObjectExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) {
|
|
|
|
QualType writtenTy = QualType::ReadVal(D);
|
|
|
|
SourceLocation tyBeginLoc = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation rParenLoc = SourceLocation::ReadVal(D);
|
|
|
|
CXXConstructorDecl * Cons = cast_or_null<CXXConstructorDecl>(D.ReadPtr<Decl>());
|
|
|
|
unsigned NumArgs = D.ReadInt();
|
|
|
|
Stmt** Args = 0;
|
|
|
|
if (NumArgs > 0) {
|
|
|
|
Args = new Stmt*[NumArgs];
|
|
|
|
D.BatchReadOwnedPtrs(NumArgs, Args, C);
|
|
|
|
}
|
|
|
|
|
|
|
|
CXXTemporaryObjectExpr * Result
|
|
|
|
= new CXXTemporaryObjectExpr(Cons, writtenTy, tyBeginLoc,
|
|
|
|
(Expr**)Args, NumArgs, rParenLoc);
|
|
|
|
|
|
|
|
if (NumArgs > 0)
|
|
|
|
delete [] Args;
|
|
|
|
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-22 23:38:55 +08:00
|
|
|
void CXXZeroInitValueExpr::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
|
|
|
S.Emit(TyBeginLoc);
|
|
|
|
S.Emit(RParenLoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
CXXZeroInitValueExpr *
|
|
|
|
CXXZeroInitValueExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
|
|
|
QualType Ty = QualType::ReadVal(D);
|
|
|
|
SourceLocation TyBeginLoc = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation RParenLoc = SourceLocation::ReadVal(D);
|
|
|
|
return new CXXZeroInitValueExpr(Ty, TyBeginLoc, RParenLoc);
|
|
|
|
}
|
2008-11-22 03:14:01 +08:00
|
|
|
|
|
|
|
void CXXNewExpr::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
2008-12-02 22:43:59 +08:00
|
|
|
S.EmitBool(GlobalNew);
|
|
|
|
S.EmitBool(ParenTypeId);
|
|
|
|
S.EmitBool(Initializer);
|
|
|
|
S.EmitBool(Array);
|
2008-12-02 03:45:16 +08:00
|
|
|
S.EmitInt(NumPlacementArgs);
|
|
|
|
S.EmitInt(NumConstructorArgs);
|
2008-11-22 03:14:01 +08:00
|
|
|
S.BatchEmitOwnedPtrs(NumPlacementArgs + NumConstructorArgs, SubExprs);
|
|
|
|
assert((OperatorNew == 0 || S.isRegistered(OperatorNew)) &&
|
|
|
|
(OperatorDelete == 0 || S.isRegistered(OperatorDelete)) &&
|
|
|
|
(Constructor == 0 || S.isRegistered(Constructor)) &&
|
|
|
|
"CXXNewExpr cannot own declarations");
|
|
|
|
S.EmitPtr(OperatorNew);
|
|
|
|
S.EmitPtr(OperatorDelete);
|
|
|
|
S.EmitPtr(Constructor);
|
|
|
|
S.Emit(StartLoc);
|
|
|
|
S.Emit(EndLoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
CXXNewExpr *
|
|
|
|
CXXNewExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
|
|
|
QualType T = QualType::ReadVal(D);
|
|
|
|
bool GlobalNew = D.ReadBool();
|
|
|
|
bool ParenTypeId = D.ReadBool();
|
|
|
|
bool Initializer = D.ReadBool();
|
2008-12-02 22:43:59 +08:00
|
|
|
bool Array = D.ReadBool();
|
2008-11-22 03:14:01 +08:00
|
|
|
unsigned NumPlacementArgs = D.ReadInt();
|
|
|
|
unsigned NumConstructorArgs = D.ReadInt();
|
2008-12-02 22:43:59 +08:00
|
|
|
unsigned TotalExprs = Array + NumPlacementArgs + NumConstructorArgs;
|
2008-11-22 03:14:01 +08:00
|
|
|
Stmt** SubExprs = new Stmt*[TotalExprs];
|
|
|
|
D.BatchReadOwnedPtrs(TotalExprs, SubExprs, C);
|
|
|
|
FunctionDecl *OperatorNew = D.ReadPtr<FunctionDecl>();
|
|
|
|
FunctionDecl *OperatorDelete = D.ReadPtr<FunctionDecl>();
|
|
|
|
CXXConstructorDecl *Constructor = D.ReadPtr<CXXConstructorDecl>();
|
|
|
|
SourceLocation StartLoc = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation EndLoc = SourceLocation::ReadVal(D);
|
|
|
|
|
2008-12-02 22:43:59 +08:00
|
|
|
return new CXXNewExpr(T, GlobalNew, ParenTypeId, Initializer, Array,
|
2008-11-22 03:14:01 +08:00
|
|
|
NumPlacementArgs, NumConstructorArgs, SubExprs,
|
|
|
|
OperatorNew, OperatorDelete, Constructor, StartLoc,
|
|
|
|
EndLoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CXXDeleteExpr::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(getType());
|
2008-12-02 22:43:59 +08:00
|
|
|
S.EmitBool(GlobalDelete);
|
|
|
|
S.EmitBool(ArrayForm);
|
2008-11-22 03:14:01 +08:00
|
|
|
S.EmitPtr(OperatorDelete);
|
|
|
|
S.EmitOwnedPtr(Argument);
|
|
|
|
S.Emit(Loc);
|
|
|
|
}
|
|
|
|
|
|
|
|
CXXDeleteExpr *
|
|
|
|
CXXDeleteExpr::CreateImpl(Deserializer& D, ASTContext& C) {
|
|
|
|
QualType Ty = QualType::ReadVal(D);
|
|
|
|
bool GlobalDelete = D.ReadBool();
|
|
|
|
bool ArrayForm = D.ReadBool();
|
|
|
|
FunctionDecl *OperatorDelete = D.ReadPtr<FunctionDecl>();
|
|
|
|
Stmt *Argument = D.ReadOwnedPtr<Stmt>(C);
|
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
|
|
|
return new CXXDeleteExpr(Ty, GlobalDelete, ArrayForm, OperatorDelete,
|
|
|
|
cast<Expr>(Argument), Loc);
|
|
|
|
}
|
2008-12-06 08:22:45 +08:00
|
|
|
|
2009-02-04 23:01:18 +08:00
|
|
|
void UnresolvedFunctionNameExpr::EmitImpl(llvm::Serializer& S) const {
|
2008-12-06 08:22:45 +08:00
|
|
|
S.Emit(getType());
|
2009-02-04 23:01:18 +08:00
|
|
|
S.EmitPtr(Name.getAsIdentifierInfo()); // FIXME: WRONG!
|
2008-12-06 08:22:45 +08:00
|
|
|
S.Emit(Loc);
|
|
|
|
}
|
|
|
|
|
2009-02-04 23:01:18 +08:00
|
|
|
UnresolvedFunctionNameExpr *
|
|
|
|
UnresolvedFunctionNameExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) {
|
2008-12-06 08:22:45 +08:00
|
|
|
QualType Ty = QualType::ReadVal(D);
|
|
|
|
IdentifierInfo *N = D.ReadPtr<IdentifierInfo>();
|
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
2009-02-04 23:01:18 +08:00
|
|
|
return new UnresolvedFunctionNameExpr(N, Ty, L);
|
2008-12-06 08:22:45 +08:00
|
|
|
}
|
2008-12-23 03:15:10 +08:00
|
|
|
|
2009-01-06 04:52:13 +08:00
|
|
|
void UnaryTypeTraitExpr::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
S.EmitInt(UTT);
|
|
|
|
S.Emit(Loc);
|
|
|
|
S.Emit(RParen);
|
|
|
|
S.Emit(QueriedType);
|
|
|
|
S.Emit(getType());
|
|
|
|
}
|
|
|
|
|
|
|
|
UnaryTypeTraitExpr *
|
|
|
|
UnaryTypeTraitExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) {
|
|
|
|
UnaryTypeTrait UTT = static_cast<UnaryTypeTrait>(D.ReadInt());
|
|
|
|
SourceLocation Loc = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation RParen = SourceLocation::ReadVal(D);
|
|
|
|
QualType QueriedType = QualType::ReadVal(D);
|
|
|
|
QualType Ty = QualType::ReadVal(D);
|
|
|
|
return new UnaryTypeTraitExpr(Loc, UTT, QueriedType, RParen, Ty);
|
|
|
|
}
|
|
|
|
|
2008-12-23 03:15:10 +08:00
|
|
|
void CXXCatchStmt::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
S.Emit(CatchLoc);
|
|
|
|
S.EmitOwnedPtr(ExceptionDecl);
|
|
|
|
S.EmitOwnedPtr(HandlerBlock);
|
|
|
|
}
|
|
|
|
|
|
|
|
CXXCatchStmt *
|
|
|
|
CXXCatchStmt::CreateImpl(llvm::Deserializer& D, ASTContext& C) {
|
|
|
|
SourceLocation CatchLoc = SourceLocation::ReadVal(D);
|
|
|
|
Decl *ExDecl = D.ReadOwnedPtr<Decl>(C);
|
|
|
|
Stmt *HandlerBlock = D.ReadOwnedPtr<Stmt>(C);
|
|
|
|
return new CXXCatchStmt(CatchLoc, ExDecl, HandlerBlock);
|
|
|
|
}
|
2008-12-23 05:35:02 +08:00
|
|
|
|
|
|
|
void CXXTryStmt::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
S.Emit(TryLoc);
|
|
|
|
S.EmitInt(Stmts.size());
|
|
|
|
S.BatchEmitOwnedPtrs(Stmts.size(), &Stmts[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
CXXTryStmt *
|
|
|
|
CXXTryStmt::CreateImpl(llvm::Deserializer& D, ASTContext& C) {
|
|
|
|
SourceLocation TryLoc = SourceLocation::ReadVal(D);
|
|
|
|
unsigned size = D.ReadInt();
|
|
|
|
llvm::SmallVector<Stmt*, 4> Stmts(size);
|
|
|
|
D.BatchReadOwnedPtrs<Stmt>(size, &Stmts[0], C);
|
|
|
|
|
|
|
|
return new CXXTryStmt(TryLoc, Stmts[0], &Stmts[1], size - 1);
|
|
|
|
}
|
2009-01-06 13:10:23 +08:00
|
|
|
|
|
|
|
void QualifiedDeclRefExpr::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
DeclRefExpr::EmitImpl(S);
|
|
|
|
S.Emit(NestedNameLoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
QualifiedDeclRefExpr*
|
|
|
|
QualifiedDeclRefExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) {
|
|
|
|
assert(false && "Cannot deserialize qualified decl references");
|
|
|
|
return 0;
|
|
|
|
}
|