Ted Kremenek | e522d85 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 1 | //===--- StmtSerialization.cpp - Serialization of Statements --------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Ted Kremenek | e522d85 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the type-specific methods for serializing statements |
| 11 | // and expressions. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 15 | #include "clang/Basic/TypeTraits.h" |
Douglas Gregor | 506ae41 | 2009-01-16 18:33:17 +0000 | [diff] [blame] | 16 | #include "clang/AST/DeclCXX.h" |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 17 | #include "clang/AST/Expr.h" |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 18 | #include "clang/AST/ExprCXX.h" |
Steve Naroff | f494b57 | 2008-05-29 21:12:08 +0000 | [diff] [blame] | 19 | #include "clang/AST/ExprObjC.h" |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 20 | #include "clang/AST/ASTContext.h" |
Ted Kremenek | e522d85 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 21 | #include "llvm/Bitcode/Serialize.h" |
| 22 | #include "llvm/Bitcode/Deserialize.h" |
| 23 | |
Ted Kremenek | e522d85 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 24 | using namespace clang; |
Ted Kremenek | 96fa54f | 2007-11-07 22:53:01 +0000 | [diff] [blame] | 25 | using llvm::Serializer; |
| 26 | using llvm::Deserializer; |
Ted Kremenek | e522d85 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 27 | |
Ted Kremenek | 96fa54f | 2007-11-07 22:53:01 +0000 | [diff] [blame] | 28 | void Stmt::Emit(Serializer& S) const { |
Ted Kremenek | 28f3d80 | 2007-11-07 22:32:23 +0000 | [diff] [blame] | 29 | S.FlushRecord(); |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 30 | S.EmitInt(getStmtClass()); |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 31 | EmitImpl(S); |
Ted Kremenek | a7c20dd | 2007-11-07 22:39:17 +0000 | [diff] [blame] | 32 | S.FlushRecord(); |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 33 | } |
Ted Kremenek | e522d85 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 34 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 35 | Stmt* Stmt::Create(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 36 | StmtClass SC = static_cast<StmtClass>(D.ReadInt()); |
Ted Kremenek | e522d85 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 37 | |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 38 | switch (SC) { |
| 39 | default: |
| 40 | assert (false && "Not implemented."); |
| 41 | return NULL; |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 42 | |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 43 | case AddrLabelExprClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 44 | return AddrLabelExpr::CreateImpl(D, C); |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 45 | |
Ted Kremenek | 96fa54f | 2007-11-07 22:53:01 +0000 | [diff] [blame] | 46 | case ArraySubscriptExprClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 47 | return ArraySubscriptExpr::CreateImpl(D, C); |
Ted Kremenek | 96fa54f | 2007-11-07 22:53:01 +0000 | [diff] [blame] | 48 | |
Ted Kremenek | 1f85acd | 2007-11-13 22:55:51 +0000 | [diff] [blame] | 49 | case AsmStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 50 | return AsmStmt::CreateImpl(D, C); |
Ted Kremenek | 1f85acd | 2007-11-13 22:55:51 +0000 | [diff] [blame] | 51 | |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 52 | case BinaryOperatorClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 53 | return BinaryOperator::CreateImpl(D, C); |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 54 | |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 55 | case BreakStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 56 | return BreakStmt::CreateImpl(D, C); |
Ted Kremenek | d7fe4ea | 2007-11-07 23:32:20 +0000 | [diff] [blame] | 57 | |
| 58 | case CallExprClass: |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 59 | return CallExpr::CreateImpl(D, C, CallExprClass); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 60 | |
| 61 | case CaseStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 62 | return CaseStmt::CreateImpl(D, C); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 63 | |
Ted Kremenek | 7338a82 | 2007-11-07 17:15:49 +0000 | [diff] [blame] | 64 | case CharacterLiteralClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 65 | return CharacterLiteral::CreateImpl(D, C); |
Ted Kremenek | 7338a82 | 2007-11-07 17:15:49 +0000 | [diff] [blame] | 66 | |
Douglas Gregor | 2d8b273 | 2008-11-29 04:51:27 +0000 | [diff] [blame] | 67 | case ChooseExprClass: |
| 68 | return ChooseExpr::CreateImpl(D, C); |
| 69 | |
Ted Kremenek | 83efb15 | 2007-11-08 00:41:37 +0000 | [diff] [blame] | 70 | case CompoundAssignOperatorClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 71 | return CompoundAssignOperator::CreateImpl(D, C); |
Ted Kremenek | 83efb15 | 2007-11-08 00:41:37 +0000 | [diff] [blame] | 72 | |
Ted Kremenek | 4b7d9ca | 2007-11-14 21:18:36 +0000 | [diff] [blame] | 73 | case CompoundLiteralExprClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 74 | return CompoundLiteralExpr::CreateImpl(D, C); |
Ted Kremenek | 4b7d9ca | 2007-11-14 21:18:36 +0000 | [diff] [blame] | 75 | |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 76 | case CompoundStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 77 | return CompoundStmt::CreateImpl(D, C); |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 78 | |
| 79 | case ConditionalOperatorClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 80 | return ConditionalOperator::CreateImpl(D, C); |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 81 | |
Ted Kremenek | 96f2242 | 2007-11-07 17:05:07 +0000 | [diff] [blame] | 82 | case ContinueStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 83 | return ContinueStmt::CreateImpl(D, C); |
Ted Kremenek | 96f2242 | 2007-11-07 17:05:07 +0000 | [diff] [blame] | 84 | |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 85 | case DeclRefExprClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 86 | return DeclRefExpr::CreateImpl(D, C); |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 87 | |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 88 | case DeclStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 89 | return DeclStmt::CreateImpl(D, C); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 90 | |
| 91 | case DefaultStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 92 | return DefaultStmt::CreateImpl(D, C); |
Ted Kremenek | e3299ef | 2007-11-07 07:53:55 +0000 | [diff] [blame] | 93 | |
| 94 | case DoStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 95 | return DoStmt::CreateImpl(D, C); |
Ted Kremenek | 612c9b9 | 2007-11-07 18:45:55 +0000 | [diff] [blame] | 96 | |
| 97 | case FloatingLiteralClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 98 | return FloatingLiteral::CreateImpl(D, C); |
Ted Kremenek | 07ba046 | 2007-11-07 08:02:55 +0000 | [diff] [blame] | 99 | |
| 100 | case ForStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 101 | return ForStmt::CreateImpl(D, C); |
Ted Kremenek | 3f0767b | 2007-11-07 08:07:46 +0000 | [diff] [blame] | 102 | |
Douglas Gregor | 2d8b273 | 2008-11-29 04:51:27 +0000 | [diff] [blame] | 103 | case GNUNullExprClass: |
| 104 | return GNUNullExpr::CreateImpl(D, C); |
| 105 | |
Ted Kremenek | 3f0767b | 2007-11-07 08:07:46 +0000 | [diff] [blame] | 106 | case GotoStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 107 | return GotoStmt::CreateImpl(D, C); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 108 | |
Ted Kremenek | 4210f3d | 2007-11-07 07:19:30 +0000 | [diff] [blame] | 109 | case IfStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 110 | return IfStmt::CreateImpl(D, C); |
Ted Kremenek | 1c72de1 | 2007-11-07 18:53:02 +0000 | [diff] [blame] | 111 | |
| 112 | case ImaginaryLiteralClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 113 | return ImaginaryLiteral::CreateImpl(D, C); |
Ted Kremenek | 4210f3d | 2007-11-07 07:19:30 +0000 | [diff] [blame] | 114 | |
Ted Kremenek | a7c20dd | 2007-11-07 22:39:17 +0000 | [diff] [blame] | 115 | case ImplicitCastExprClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 116 | return ImplicitCastExpr::CreateImpl(D, C); |
Argyrios Kyrtzidis | 0835a3c | 2008-08-18 23:01:59 +0000 | [diff] [blame] | 117 | |
Douglas Gregor | 6eec8e8 | 2008-10-28 15:36:24 +0000 | [diff] [blame] | 118 | case CStyleCastExprClass: |
| 119 | return CStyleCastExpr::CreateImpl(D, C); |
Ted Kremenek | a7c20dd | 2007-11-07 22:39:17 +0000 | [diff] [blame] | 120 | |
Ted Kremenek | 225a2d9 | 2007-11-07 17:02:32 +0000 | [diff] [blame] | 121 | case IndirectGotoStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 122 | return IndirectGotoStmt::CreateImpl(D, C); |
Ted Kremenek | 6336f8d | 2007-11-14 21:31:46 +0000 | [diff] [blame] | 123 | |
| 124 | case InitListExprClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 125 | return InitListExpr::CreateImpl(D, C); |
Ted Kremenek | 225a2d9 | 2007-11-07 17:02:32 +0000 | [diff] [blame] | 126 | |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 127 | case IntegerLiteralClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 128 | return IntegerLiteral::CreateImpl(D, C); |
Ted Kremenek | 4927be6 | 2007-11-07 00:40:53 +0000 | [diff] [blame] | 129 | |
Ted Kremenek | b15132f | 2007-11-07 00:48:04 +0000 | [diff] [blame] | 130 | case LabelStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 131 | return LabelStmt::CreateImpl(D, C); |
Ted Kremenek | b15132f | 2007-11-07 00:48:04 +0000 | [diff] [blame] | 132 | |
Ted Kremenek | bd57e7c | 2007-11-13 22:16:23 +0000 | [diff] [blame] | 133 | case MemberExprClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 134 | return MemberExpr::CreateImpl(D, C); |
Ted Kremenek | bd57e7c | 2007-11-13 22:16:23 +0000 | [diff] [blame] | 135 | |
Ted Kremenek | 4927be6 | 2007-11-07 00:40:53 +0000 | [diff] [blame] | 136 | case NullStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 137 | return NullStmt::CreateImpl(D, C); |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 138 | |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 139 | case ParenExprClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 140 | return ParenExpr::CreateImpl(D, C); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 141 | |
Chris Lattner | d9f6910 | 2008-08-10 01:53:14 +0000 | [diff] [blame] | 142 | case PredefinedExprClass: |
| 143 | return PredefinedExpr::CreateImpl(D, C); |
Ted Kremenek | 1ba485e | 2007-11-07 17:11:58 +0000 | [diff] [blame] | 144 | |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 145 | case ReturnStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 146 | return ReturnStmt::CreateImpl(D, C); |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 147 | |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 148 | case SizeOfAlignOfExprClass: |
| 149 | return SizeOfAlignOfExpr::CreateImpl(D, C); |
Ted Kremenek | ea2fe9b | 2007-11-13 22:30:29 +0000 | [diff] [blame] | 150 | |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 151 | case StmtExprClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 152 | return StmtExpr::CreateImpl(D, C); |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 153 | |
Ted Kremenek | 7febad7 | 2007-11-07 19:08:19 +0000 | [diff] [blame] | 154 | case StringLiteralClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 155 | return StringLiteral::CreateImpl(D, C); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 156 | |
| 157 | case SwitchStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 158 | return SwitchStmt::CreateImpl(D, C); |
Ted Kremenek | 5572b94 | 2007-11-07 07:50:10 +0000 | [diff] [blame] | 159 | |
Ted Kremenek | 1049436 | 2007-11-08 00:26:24 +0000 | [diff] [blame] | 160 | case UnaryOperatorClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 161 | return UnaryOperator::CreateImpl(D, C); |
Ted Kremenek | 1049436 | 2007-11-08 00:26:24 +0000 | [diff] [blame] | 162 | |
Ted Kremenek | 5572b94 | 2007-11-07 07:50:10 +0000 | [diff] [blame] | 163 | case WhileStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 164 | return WhileStmt::CreateImpl(D, C); |
Ted Kremenek | 378c151 | 2007-11-15 18:10:29 +0000 | [diff] [blame] | 165 | |
| 166 | //==--------------------------------------==// |
| 167 | // Objective C |
| 168 | //==--------------------------------------==// |
Ted Kremenek | af52677 | 2007-12-04 00:28:54 +0000 | [diff] [blame] | 169 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 170 | case ObjCAtCatchStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 171 | return ObjCAtCatchStmt::CreateImpl(D, C); |
Ted Kremenek | 378c151 | 2007-11-15 18:10:29 +0000 | [diff] [blame] | 172 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 173 | case ObjCAtFinallyStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 174 | return ObjCAtFinallyStmt::CreateImpl(D, C); |
Ted Kremenek | b7e6bd7 | 2008-01-29 21:21:30 +0000 | [diff] [blame] | 175 | |
| 176 | case ObjCAtSynchronizedStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 177 | return ObjCAtSynchronizedStmt::CreateImpl(D, C); |
Ted Kremenek | 04be5aa | 2007-12-04 00:32:22 +0000 | [diff] [blame] | 178 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 179 | case ObjCAtThrowStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 180 | return ObjCAtThrowStmt::CreateImpl(D, C); |
Ted Kremenek | 5bdd4e3 | 2007-12-04 00:40:49 +0000 | [diff] [blame] | 181 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 182 | case ObjCAtTryStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 183 | return ObjCAtTryStmt::CreateImpl(D, C); |
Ted Kremenek | 8f6dc77 | 2007-12-05 00:43:08 +0000 | [diff] [blame] | 184 | |
| 185 | case ObjCEncodeExprClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 186 | return ObjCEncodeExpr::CreateImpl(D, C); |
Ted Kremenek | 9c1efff | 2007-12-04 00:38:30 +0000 | [diff] [blame] | 187 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 188 | case ObjCForCollectionStmtClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 189 | return ObjCForCollectionStmt::CreateImpl(D, C); |
Ted Kremenek | c3b59d3 | 2008-01-05 00:57:49 +0000 | [diff] [blame] | 190 | |
Ted Kremenek | 378c151 | 2007-11-15 18:10:29 +0000 | [diff] [blame] | 191 | case ObjCIvarRefExprClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 192 | return ObjCIvarRefExpr::CreateImpl(D, C); |
Ted Kremenek | 46dc0a5 | 2007-12-04 00:51:11 +0000 | [diff] [blame] | 193 | |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 194 | case ObjCMessageExprClass: |
| 195 | return ObjCMessageExpr::CreateImpl(D, C); |
| 196 | |
Ted Kremenek | 8f6dc77 | 2007-12-05 00:43:08 +0000 | [diff] [blame] | 197 | case ObjCSelectorExprClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 198 | return ObjCSelectorExpr::CreateImpl(D, C); |
Ted Kremenek | 8f6dc77 | 2007-12-05 00:43:08 +0000 | [diff] [blame] | 199 | |
Ted Kremenek | 46dc0a5 | 2007-12-04 00:51:11 +0000 | [diff] [blame] | 200 | case ObjCStringLiteralClass: |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 201 | return ObjCStringLiteral::CreateImpl(D, C); |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 202 | |
Douglas Gregor | cd9b46e | 2008-11-04 14:56:14 +0000 | [diff] [blame] | 203 | case ObjCSuperExprClass: |
| 204 | return ObjCSuperExpr::CreateImpl(D, C); |
| 205 | |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 206 | //==--------------------------------------==// |
| 207 | // C++ |
| 208 | //==--------------------------------------==// |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 209 | |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 210 | case CXXOperatorCallExprClass: |
| 211 | return CXXOperatorCallExpr::CreateImpl(D, C, CXXOperatorCallExprClass); |
| 212 | |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 213 | case CXXDefaultArgExprClass: |
| 214 | return CXXDefaultArgExpr::CreateImpl(D, C); |
Argyrios Kyrtzidis | 987a14b | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 215 | |
| 216 | case CXXFunctionalCastExprClass: |
| 217 | return CXXFunctionalCastExpr::CreateImpl(D, C); |
| 218 | |
Douglas Gregor | 49badde | 2008-10-27 19:41:14 +0000 | [diff] [blame] | 219 | case CXXStaticCastExprClass: |
| 220 | return CXXStaticCastExpr::CreateImpl(D, C, SC); |
| 221 | |
| 222 | case CXXDynamicCastExprClass: |
| 223 | return CXXDynamicCastExpr::CreateImpl(D, C, SC); |
| 224 | |
| 225 | case CXXReinterpretCastExprClass: |
| 226 | return CXXReinterpretCastExpr::CreateImpl(D, C, SC); |
| 227 | |
| 228 | case CXXConstCastExprClass: |
| 229 | return CXXConstCastExpr::CreateImpl(D, C, SC); |
Douglas Gregor | 796da18 | 2008-11-04 14:32:21 +0000 | [diff] [blame] | 230 | |
Sebastian Redl | c42e118 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 231 | case CXXTypeidExprClass: |
| 232 | return CXXTypeidExpr::CreateImpl(D, C); |
| 233 | |
Douglas Gregor | 796da18 | 2008-11-04 14:32:21 +0000 | [diff] [blame] | 234 | case CXXThisExprClass: |
| 235 | return CXXThisExpr::CreateImpl(D, C); |
| 236 | |
Douglas Gregor | 506ae41 | 2009-01-16 18:33:17 +0000 | [diff] [blame] | 237 | case CXXTemporaryObjectExprClass: |
| 238 | return CXXTemporaryObjectExpr::CreateImpl(D, C); |
| 239 | |
Argyrios Kyrtzidis | 987a14b | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 240 | case CXXZeroInitValueExprClass: |
| 241 | return CXXZeroInitValueExpr::CreateImpl(D, C); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 242 | |
| 243 | case CXXNewExprClass: |
| 244 | return CXXNewExpr::CreateImpl(D, C); |
| 245 | |
| 246 | case CXXDeleteExprClass: |
| 247 | return CXXDeleteExpr::CreateImpl(D, C); |
Douglas Gregor | 5c37de7 | 2008-12-06 00:22:45 +0000 | [diff] [blame] | 248 | |
Douglas Gregor | 1733001 | 2009-02-04 15:01:18 +0000 | [diff] [blame] | 249 | case UnresolvedFunctionNameExprClass: |
| 250 | return UnresolvedFunctionNameExpr::CreateImpl(D, C); |
Sebastian Redl | 4b07b29 | 2008-12-22 19:15:10 +0000 | [diff] [blame] | 251 | |
| 252 | case CXXCatchStmtClass: |
| 253 | return CXXCatchStmt::CreateImpl(D, C); |
Sebastian Redl | 7a89722 | 2008-12-24 13:02:38 +0000 | [diff] [blame] | 254 | |
| 255 | case CXXTryStmtClass: |
| 256 | return CXXTryStmt::CreateImpl(D, C); |
Douglas Gregor | 1a49af9 | 2009-01-06 05:10:23 +0000 | [diff] [blame] | 257 | |
| 258 | case QualifiedDeclRefExprClass: |
| 259 | return QualifiedDeclRefExpr::CreateImpl(D, C); |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 260 | } |
Ted Kremenek | e522d85 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Ted Kremenek | 378c151 | 2007-11-15 18:10:29 +0000 | [diff] [blame] | 263 | //===----------------------------------------------------------------------===// |
| 264 | // C Serialization |
| 265 | //===----------------------------------------------------------------------===// |
| 266 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 267 | void AddrLabelExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 268 | S.Emit(getType()); |
| 269 | S.Emit(AmpAmpLoc); |
| 270 | S.Emit(LabelLoc); |
| 271 | S.EmitPtr(Label); |
| 272 | } |
| 273 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 274 | AddrLabelExpr* AddrLabelExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 275 | QualType t = QualType::ReadVal(D); |
| 276 | SourceLocation AALoc = SourceLocation::ReadVal(D); |
| 277 | SourceLocation LLoc = SourceLocation::ReadVal(D); |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 278 | AddrLabelExpr* expr = new (C, llvm::alignof<AddrLabelExpr>()) |
| 279 | AddrLabelExpr(AALoc,LLoc,NULL,t); |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 280 | D.ReadPtr(expr->Label); // Pointer may be backpatched. |
| 281 | return expr; |
| 282 | } |
| 283 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 284 | void ArraySubscriptExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | 96fa54f | 2007-11-07 22:53:01 +0000 | [diff] [blame] | 285 | S.Emit(getType()); |
| 286 | S.Emit(RBracketLoc); |
| 287 | S.BatchEmitOwnedPtrs(getLHS(),getRHS()); |
| 288 | } |
| 289 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 290 | ArraySubscriptExpr* ArraySubscriptExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 96fa54f | 2007-11-07 22:53:01 +0000 | [diff] [blame] | 291 | QualType t = QualType::ReadVal(D); |
| 292 | SourceLocation L = SourceLocation::ReadVal(D); |
| 293 | Expr *LHS, *RHS; |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 294 | D.BatchReadOwnedPtrs(LHS, RHS, C); |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 295 | return new (C, llvm::alignof<ArraySubscriptExpr>()) |
| 296 | ArraySubscriptExpr(LHS,RHS,t,L); |
Ted Kremenek | 96fa54f | 2007-11-07 22:53:01 +0000 | [diff] [blame] | 297 | } |
| 298 | |
Ted Kremenek | 1f85acd | 2007-11-13 22:55:51 +0000 | [diff] [blame] | 299 | void AsmStmt::EmitImpl(Serializer& S) const { |
| 300 | S.Emit(AsmLoc); |
Anders Carlsson | b235fc2 | 2007-11-22 01:36:19 +0000 | [diff] [blame] | 301 | |
Anders Carlsson | 6a0ef4b | 2007-11-20 19:21:03 +0000 | [diff] [blame] | 302 | getAsmString()->EmitImpl(S); |
Ted Kremenek | 1f85acd | 2007-11-13 22:55:51 +0000 | [diff] [blame] | 303 | S.Emit(RParenLoc); |
Anders Carlsson | b235fc2 | 2007-11-22 01:36:19 +0000 | [diff] [blame] | 304 | |
Anders Carlsson | 39c47b5 | 2007-11-23 23:12:25 +0000 | [diff] [blame] | 305 | S.EmitBool(IsVolatile); |
Anders Carlsson | dfab34a | 2008-02-05 23:03:50 +0000 | [diff] [blame] | 306 | S.EmitBool(IsSimple); |
Anders Carlsson | b235fc2 | 2007-11-22 01:36:19 +0000 | [diff] [blame] | 307 | S.EmitInt(NumOutputs); |
| 308 | S.EmitInt(NumInputs); |
| 309 | |
| 310 | unsigned size = NumOutputs + NumInputs; |
| 311 | |
| 312 | for (unsigned i = 0; i < size; ++i) |
| 313 | S.EmitCStr(Names[i].c_str()); |
| 314 | |
| 315 | for (unsigned i = 0; i < size; ++i) |
| 316 | Constraints[i]->EmitImpl(S); |
| 317 | |
| 318 | for (unsigned i = 0; i < size; ++i) |
| 319 | S.EmitOwnedPtr(Exprs[i]); |
| 320 | |
| 321 | S.EmitInt(Clobbers.size()); |
| 322 | for (unsigned i = 0, e = Clobbers.size(); i != e; ++i) |
| 323 | Clobbers[i]->EmitImpl(S); |
Ted Kremenek | 1f85acd | 2007-11-13 22:55:51 +0000 | [diff] [blame] | 324 | } |
| 325 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 326 | AsmStmt* AsmStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 1f85acd | 2007-11-13 22:55:51 +0000 | [diff] [blame] | 327 | SourceLocation ALoc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 328 | StringLiteral *AsmStr = StringLiteral::CreateImpl(D, C); |
Ted Kremenek | 1f85acd | 2007-11-13 22:55:51 +0000 | [diff] [blame] | 329 | SourceLocation PLoc = SourceLocation::ReadVal(D); |
| 330 | |
Anders Carlsson | 39c47b5 | 2007-11-23 23:12:25 +0000 | [diff] [blame] | 331 | bool IsVolatile = D.ReadBool(); |
Anders Carlsson | dfab34a | 2008-02-05 23:03:50 +0000 | [diff] [blame] | 332 | bool IsSimple = D.ReadBool(); |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 333 | AsmStmt *Stmt = new (C, llvm::alignof<AsmStmt>()) |
| 334 | AsmStmt(ALoc, IsSimple, IsVolatile, 0, 0, 0, 0, 0, AsmStr, 0, 0, PLoc); |
Anders Carlsson | b235fc2 | 2007-11-22 01:36:19 +0000 | [diff] [blame] | 335 | |
| 336 | Stmt->NumOutputs = D.ReadInt(); |
| 337 | Stmt->NumInputs = D.ReadInt(); |
| 338 | |
| 339 | unsigned size = Stmt->NumOutputs + Stmt->NumInputs; |
| 340 | |
| 341 | Stmt->Names.reserve(size); |
| 342 | for (unsigned i = 0; i < size; ++i) { |
| 343 | std::vector<char> data; |
| 344 | D.ReadCStr(data, false); |
Eli Friedman | 10c5fa3 | 2008-02-23 07:32:49 +0000 | [diff] [blame] | 345 | |
| 346 | Stmt->Names.push_back(std::string(data.begin(), data.end())); |
Anders Carlsson | b235fc2 | 2007-11-22 01:36:19 +0000 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | Stmt->Constraints.reserve(size); |
| 350 | for (unsigned i = 0; i < size; ++i) |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 351 | Stmt->Constraints.push_back(StringLiteral::CreateImpl(D, C)); |
Anders Carlsson | b235fc2 | 2007-11-22 01:36:19 +0000 | [diff] [blame] | 352 | |
| 353 | Stmt->Exprs.reserve(size); |
| 354 | for (unsigned i = 0; i < size; ++i) |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 355 | Stmt->Exprs.push_back(D.ReadOwnedPtr<Expr>(C)); |
Anders Carlsson | b235fc2 | 2007-11-22 01:36:19 +0000 | [diff] [blame] | 356 | |
| 357 | unsigned NumClobbers = D.ReadInt(); |
| 358 | Stmt->Clobbers.reserve(NumClobbers); |
| 359 | for (unsigned i = 0; i < NumClobbers; ++i) |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 360 | Stmt->Clobbers.push_back(StringLiteral::CreateImpl(D, C)); |
Anders Carlsson | b235fc2 | 2007-11-22 01:36:19 +0000 | [diff] [blame] | 361 | |
| 362 | return Stmt; |
Ted Kremenek | 1f85acd | 2007-11-13 22:55:51 +0000 | [diff] [blame] | 363 | } |
| 364 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 365 | void BinaryOperator::EmitImpl(Serializer& S) const { |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 366 | S.EmitInt(Opc); |
| 367 | S.Emit(OpLoc);; |
| 368 | S.Emit(getType()); |
Ted Kremenek | 28f3d80 | 2007-11-07 22:32:23 +0000 | [diff] [blame] | 369 | S.BatchEmitOwnedPtrs(getLHS(),getRHS()); |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 370 | } |
| 371 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 372 | BinaryOperator* BinaryOperator::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 373 | Opcode Opc = static_cast<Opcode>(D.ReadInt()); |
| 374 | SourceLocation OpLoc = SourceLocation::ReadVal(D); |
| 375 | QualType Result = QualType::ReadVal(D); |
Ted Kremenek | 28f3d80 | 2007-11-07 22:32:23 +0000 | [diff] [blame] | 376 | Expr *LHS, *RHS; |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 377 | D.BatchReadOwnedPtrs(LHS, RHS, C); |
Ted Kremenek | 28f3d80 | 2007-11-07 22:32:23 +0000 | [diff] [blame] | 378 | |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 379 | return new (C, llvm::alignof<BinaryOperator>()) |
| 380 | BinaryOperator(LHS,RHS,Opc,Result,OpLoc); |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 381 | } |
Ted Kremenek | e522d85 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 382 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 383 | void BreakStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 384 | S.Emit(BreakLoc); |
| 385 | } |
| 386 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 387 | BreakStmt* BreakStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 388 | SourceLocation Loc = SourceLocation::ReadVal(D); |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 389 | return new (C, llvm::alignof<BreakStmt>()) BreakStmt(Loc); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 390 | } |
Ted Kremenek | d7fe4ea | 2007-11-07 23:32:20 +0000 | [diff] [blame] | 391 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 392 | void CallExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | d7fe4ea | 2007-11-07 23:32:20 +0000 | [diff] [blame] | 393 | S.Emit(getType()); |
| 394 | S.Emit(RParenLoc); |
| 395 | S.EmitInt(NumArgs); |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 396 | S.BatchEmitOwnedPtrs(NumArgs+1, SubExprs); |
Ted Kremenek | d7fe4ea | 2007-11-07 23:32:20 +0000 | [diff] [blame] | 397 | } |
| 398 | |
Douglas Gregor | b460980 | 2008-11-14 16:09:21 +0000 | [diff] [blame] | 399 | CallExpr* CallExpr::CreateImpl(Deserializer& D, ASTContext& C, StmtClass SC) { |
Ted Kremenek | d7fe4ea | 2007-11-07 23:32:20 +0000 | [diff] [blame] | 400 | QualType t = QualType::ReadVal(D); |
| 401 | SourceLocation L = SourceLocation::ReadVal(D); |
| 402 | unsigned NumArgs = D.ReadInt(); |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 403 | Stmt** SubExprs = new (C, llvm::alignof<Stmt*>()) Stmt*[NumArgs+1]; |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 404 | D.BatchReadOwnedPtrs(NumArgs+1, SubExprs, C); |
Ted Kremenek | d7fe4ea | 2007-11-07 23:32:20 +0000 | [diff] [blame] | 405 | |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 406 | return new (C, llvm::alignof<CallExpr>()) CallExpr(SC, SubExprs,NumArgs,t,L); |
Ted Kremenek | d7fe4ea | 2007-11-07 23:32:20 +0000 | [diff] [blame] | 407 | } |
| 408 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 409 | void CaseStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 410 | S.Emit(CaseLoc); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 411 | S.EmitPtr(getNextSwitchCase()); |
Ted Kremenek | 103fc81 | 2007-11-08 00:56:26 +0000 | [diff] [blame] | 412 | S.BatchEmitOwnedPtrs((unsigned) END_EXPR,&SubExprs[0]); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 413 | } |
| 414 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 415 | CaseStmt* CaseStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 416 | SourceLocation CaseLoc = SourceLocation::ReadVal(D); |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 417 | CaseStmt* stmt = new (C, llvm::alignof<CaseStmt>()) |
| 418 | CaseStmt(NULL,NULL,NULL,CaseLoc); |
Ted Kremenek | 103fc81 | 2007-11-08 00:56:26 +0000 | [diff] [blame] | 419 | D.ReadPtr(stmt->NextSwitchCase); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 420 | D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubExprs[0], C); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 421 | return stmt; |
| 422 | } |
Ted Kremenek | e522d85 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 423 | |
Douglas Gregor | 6eec8e8 | 2008-10-28 15:36:24 +0000 | [diff] [blame] | 424 | void CStyleCastExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | 9971c9a | 2007-11-07 22:42:34 +0000 | [diff] [blame] | 425 | S.Emit(getType()); |
Douglas Gregor | 49badde | 2008-10-27 19:41:14 +0000 | [diff] [blame] | 426 | S.Emit(getTypeAsWritten()); |
Steve Naroff | b2f9e51 | 2008-11-03 23:29:32 +0000 | [diff] [blame] | 427 | S.Emit(LPLoc); |
| 428 | S.Emit(RPLoc); |
Argyrios Kyrtzidis | 0835a3c | 2008-08-18 23:01:59 +0000 | [diff] [blame] | 429 | S.EmitOwnedPtr(getSubExpr()); |
Ted Kremenek | 9971c9a | 2007-11-07 22:42:34 +0000 | [diff] [blame] | 430 | } |
| 431 | |
Douglas Gregor | 6eec8e8 | 2008-10-28 15:36:24 +0000 | [diff] [blame] | 432 | CStyleCastExpr* CStyleCastExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 9971c9a | 2007-11-07 22:42:34 +0000 | [diff] [blame] | 433 | QualType t = QualType::ReadVal(D); |
Douglas Gregor | 49badde | 2008-10-27 19:41:14 +0000 | [diff] [blame] | 434 | QualType writtenTy = QualType::ReadVal(D); |
Steve Naroff | b2f9e51 | 2008-11-03 23:29:32 +0000 | [diff] [blame] | 435 | SourceLocation LPLoc = SourceLocation::ReadVal(D); |
| 436 | SourceLocation RPLoc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 437 | Expr* Op = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 438 | return new (C, llvm::alignof<CStyleCastExpr>()) |
| 439 | CStyleCastExpr(t,Op,writtenTy,LPLoc,RPLoc); |
Ted Kremenek | 9971c9a | 2007-11-07 22:42:34 +0000 | [diff] [blame] | 440 | } |
Ted Kremenek | 9971c9a | 2007-11-07 22:42:34 +0000 | [diff] [blame] | 441 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 442 | void CharacterLiteral::EmitImpl(Serializer& S) const { |
Ted Kremenek | 7338a82 | 2007-11-07 17:15:49 +0000 | [diff] [blame] | 443 | S.Emit(Value); |
| 444 | S.Emit(Loc); |
Chris Lattner | c250aae | 2008-06-07 22:35:38 +0000 | [diff] [blame] | 445 | S.EmitBool(IsWide); |
Ted Kremenek | 7338a82 | 2007-11-07 17:15:49 +0000 | [diff] [blame] | 446 | S.Emit(getType()); |
| 447 | } |
| 448 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 449 | CharacterLiteral* CharacterLiteral::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 7338a82 | 2007-11-07 17:15:49 +0000 | [diff] [blame] | 450 | unsigned value = D.ReadInt(); |
| 451 | SourceLocation Loc = SourceLocation::ReadVal(D); |
Chris Lattner | c250aae | 2008-06-07 22:35:38 +0000 | [diff] [blame] | 452 | bool iswide = D.ReadBool(); |
Ted Kremenek | 7338a82 | 2007-11-07 17:15:49 +0000 | [diff] [blame] | 453 | QualType T = QualType::ReadVal(D); |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 454 | return new (C, llvm::alignof<CharacterLiteral>()) |
| 455 | CharacterLiteral(value,iswide,T,Loc); |
Ted Kremenek | 7338a82 | 2007-11-07 17:15:49 +0000 | [diff] [blame] | 456 | } |
| 457 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 458 | void CompoundAssignOperator::EmitImpl(Serializer& S) const { |
Ted Kremenek | 83efb15 | 2007-11-08 00:41:37 +0000 | [diff] [blame] | 459 | S.Emit(getType()); |
| 460 | S.Emit(ComputationType); |
| 461 | S.Emit(getOperatorLoc()); |
| 462 | S.EmitInt(getOpcode()); |
| 463 | S.BatchEmitOwnedPtrs(getLHS(),getRHS()); |
| 464 | } |
| 465 | |
| 466 | CompoundAssignOperator* |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 467 | CompoundAssignOperator::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 83efb15 | 2007-11-08 00:41:37 +0000 | [diff] [blame] | 468 | QualType t = QualType::ReadVal(D); |
| 469 | QualType c = QualType::ReadVal(D); |
| 470 | SourceLocation L = SourceLocation::ReadVal(D); |
| 471 | Opcode Opc = static_cast<Opcode>(D.ReadInt()); |
| 472 | Expr* LHS, *RHS; |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 473 | D.BatchReadOwnedPtrs(LHS, RHS, C); |
Ted Kremenek | 83efb15 | 2007-11-08 00:41:37 +0000 | [diff] [blame] | 474 | |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 475 | return new (C, llvm::alignof<CompoundAssignOperator>()) |
| 476 | CompoundAssignOperator(LHS,RHS,Opc,t,c,L); |
Ted Kremenek | 83efb15 | 2007-11-08 00:41:37 +0000 | [diff] [blame] | 477 | } |
| 478 | |
Ted Kremenek | 4b7d9ca | 2007-11-14 21:18:36 +0000 | [diff] [blame] | 479 | void CompoundLiteralExpr::EmitImpl(Serializer& S) const { |
| 480 | S.Emit(getType()); |
Chris Lattner | 0fc53df | 2008-01-02 21:46:24 +0000 | [diff] [blame] | 481 | S.Emit(getLParenLoc()); |
Steve Naroff | e9b1219 | 2008-01-14 18:19:28 +0000 | [diff] [blame] | 482 | S.EmitBool(isFileScope()); |
Ted Kremenek | 34bc18b | 2008-01-14 18:29:39 +0000 | [diff] [blame] | 483 | S.EmitOwnedPtr(Init); |
Ted Kremenek | 4b7d9ca | 2007-11-14 21:18:36 +0000 | [diff] [blame] | 484 | } |
| 485 | |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame^] | 486 | CompoundLiteralExpr* CompoundLiteralExpr::CreateImpl(Deserializer& D, |
| 487 | ASTContext& C) { |
Ted Kremenek | 4b7d9ca | 2007-11-14 21:18:36 +0000 | [diff] [blame] | 488 | QualType Q = QualType::ReadVal(D); |
Chris Lattner | 0fc53df | 2008-01-02 21:46:24 +0000 | [diff] [blame] | 489 | SourceLocation L = SourceLocation::ReadVal(D); |
Steve Naroff | e9b1219 | 2008-01-14 18:19:28 +0000 | [diff] [blame] | 490 | bool fileScope = D.ReadBool(); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 491 | Expr* Init = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 492 | return new (C, llvm::alignof<CompoundLiteralExpr>()) |
| 493 | CompoundLiteralExpr(L, Q, Init, fileScope); |
Ted Kremenek | 4b7d9ca | 2007-11-14 21:18:36 +0000 | [diff] [blame] | 494 | } |
| 495 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 496 | void CompoundStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 497 | S.Emit(LBracLoc); |
| 498 | S.Emit(RBracLoc); |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame^] | 499 | S.Emit(NumStmts); |
| 500 | if (NumStmts) S.BatchEmitOwnedPtrs(NumStmts, &Body[0]); |
Ted Kremenek | e522d85 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 501 | } |
| 502 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 503 | CompoundStmt* CompoundStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 504 | SourceLocation LB = SourceLocation::ReadVal(D); |
| 505 | SourceLocation RB = SourceLocation::ReadVal(D); |
| 506 | unsigned size = D.ReadInt(); |
Ted Kremenek | e522d85 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 507 | |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 508 | CompoundStmt* stmt = new (C, llvm::alignof<CompoundStmt>()) |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame^] | 509 | CompoundStmt(C, NULL, 0, LB, RB); |
| 510 | |
| 511 | stmt->NumStmts = size; |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 512 | |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame^] | 513 | if (size) { |
| 514 | stmt->Body = new (C) Stmt*[size]; |
| 515 | D.BatchReadOwnedPtrs(size, &stmt->Body[0], C); |
| 516 | } |
| 517 | |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 518 | return stmt; |
Ted Kremenek | e522d85 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 519 | } |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 520 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 521 | void ConditionalOperator::EmitImpl(Serializer& S) const { |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 522 | S.Emit(getType()); |
| 523 | S.BatchEmitOwnedPtrs((unsigned) END_EXPR, SubExprs); |
| 524 | } |
| 525 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 526 | ConditionalOperator* ConditionalOperator::CreateImpl(Deserializer& D, |
| 527 | ASTContext& C) { |
| 528 | |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 529 | QualType t = QualType::ReadVal(D); |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 530 | ConditionalOperator* c = new (C, llvm::alignof<ConditionalOperator>()) |
| 531 | ConditionalOperator(NULL,NULL,NULL,t); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 532 | D.BatchReadOwnedPtrs((unsigned) END_EXPR, c->SubExprs, C); |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 533 | return c; |
| 534 | } |
| 535 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 536 | void ContinueStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 96f2242 | 2007-11-07 17:05:07 +0000 | [diff] [blame] | 537 | S.Emit(ContinueLoc); |
| 538 | } |
| 539 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 540 | ContinueStmt* ContinueStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 96f2242 | 2007-11-07 17:05:07 +0000 | [diff] [blame] | 541 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 542 | return new ContinueStmt(Loc); |
| 543 | } |
| 544 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 545 | void DeclStmt::EmitImpl(Serializer& S) const { |
Chris Lattner | 81c018d | 2008-03-13 06:29:04 +0000 | [diff] [blame] | 546 | S.Emit(StartLoc); |
| 547 | S.Emit(EndLoc); |
Ted Kremenek | 8ffb159 | 2008-10-07 23:09:49 +0000 | [diff] [blame] | 548 | S.Emit(DG); |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 549 | } |
Ted Kremenek | a1a7824 | 2008-08-06 15:50:59 +0000 | [diff] [blame] | 550 | |
| 551 | DeclStmt* DeclStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
| 552 | SourceLocation StartLoc = SourceLocation::ReadVal(D); |
Ted Kremenek | 8ffb159 | 2008-10-07 23:09:49 +0000 | [diff] [blame] | 553 | SourceLocation EndLoc = SourceLocation::ReadVal(D); |
| 554 | DeclGroupOwningRef DG; |
| 555 | return new DeclStmt(DG.Read(D, C), StartLoc, EndLoc); |
Ted Kremenek | a1a7824 | 2008-08-06 15:50:59 +0000 | [diff] [blame] | 556 | } |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 557 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 558 | void DeclRefExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 559 | S.Emit(Loc); |
| 560 | S.Emit(getType()); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 561 | S.EmitPtr(getDecl()); |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 562 | } |
| 563 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 564 | DeclRefExpr* DeclRefExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 565 | SourceLocation Loc = SourceLocation::ReadVal(D); |
Ted Kremenek | 767dd4b | 2007-11-15 18:26:39 +0000 | [diff] [blame] | 566 | QualType T = QualType::ReadVal(D); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 567 | DeclRefExpr *DRE = new DeclRefExpr(0, T, Loc); |
| 568 | D.ReadPtr(DRE->D); |
| 569 | return DRE; |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 570 | } |
| 571 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 572 | void DefaultStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 573 | S.Emit(DefaultLoc); |
| 574 | S.EmitOwnedPtr(getSubStmt()); |
| 575 | S.EmitPtr(getNextSwitchCase()); |
| 576 | } |
| 577 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 578 | DefaultStmt* DefaultStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 579 | SourceLocation Loc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 580 | Stmt* SubStmt = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 581 | |
| 582 | DefaultStmt* stmt = new DefaultStmt(Loc,SubStmt); |
| 583 | stmt->setNextSwitchCase(D.ReadPtr<SwitchCase>()); |
| 584 | |
| 585 | return stmt; |
| 586 | } |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 587 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 588 | void DoStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | e3299ef | 2007-11-07 07:53:55 +0000 | [diff] [blame] | 589 | S.Emit(DoLoc); |
| 590 | S.EmitOwnedPtr(getCond()); |
| 591 | S.EmitOwnedPtr(getBody()); |
| 592 | } |
| 593 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 594 | DoStmt* DoStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | e3299ef | 2007-11-07 07:53:55 +0000 | [diff] [blame] | 595 | SourceLocation DoLoc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 596 | Expr* Cond = D.ReadOwnedPtr<Expr>(C); |
| 597 | Stmt* Body = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | e3299ef | 2007-11-07 07:53:55 +0000 | [diff] [blame] | 598 | return new DoStmt(Body,Cond,DoLoc); |
| 599 | } |
| 600 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 601 | void FloatingLiteral::EmitImpl(Serializer& S) const { |
Ted Kremenek | 612c9b9 | 2007-11-07 18:45:55 +0000 | [diff] [blame] | 602 | S.Emit(Loc); |
| 603 | S.Emit(getType()); |
Ted Kremenek | 720c4ec | 2007-11-29 00:56:49 +0000 | [diff] [blame] | 604 | S.EmitBool(isExact()); |
Ted Kremenek | 612c9b9 | 2007-11-07 18:45:55 +0000 | [diff] [blame] | 605 | S.Emit(Value); |
| 606 | } |
| 607 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 608 | FloatingLiteral* FloatingLiteral::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 612c9b9 | 2007-11-07 18:45:55 +0000 | [diff] [blame] | 609 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 610 | QualType t = QualType::ReadVal(D); |
Ted Kremenek | 720c4ec | 2007-11-29 00:56:49 +0000 | [diff] [blame] | 611 | bool isExact = D.ReadBool(); |
Ted Kremenek | 612c9b9 | 2007-11-07 18:45:55 +0000 | [diff] [blame] | 612 | llvm::APFloat Val = llvm::APFloat::ReadVal(D); |
Ted Kremenek | 720c4ec | 2007-11-29 00:56:49 +0000 | [diff] [blame] | 613 | FloatingLiteral* expr = new FloatingLiteral(Val,&isExact,t,Loc); |
Ted Kremenek | 612c9b9 | 2007-11-07 18:45:55 +0000 | [diff] [blame] | 614 | return expr; |
| 615 | } |
| 616 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 617 | void ForStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 07ba046 | 2007-11-07 08:02:55 +0000 | [diff] [blame] | 618 | S.Emit(ForLoc); |
| 619 | S.EmitOwnedPtr(getInit()); |
| 620 | S.EmitOwnedPtr(getCond()); |
| 621 | S.EmitOwnedPtr(getInc()); |
| 622 | S.EmitOwnedPtr(getBody()); |
| 623 | } |
| 624 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 625 | ForStmt* ForStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 07ba046 | 2007-11-07 08:02:55 +0000 | [diff] [blame] | 626 | SourceLocation ForLoc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 627 | Stmt* Init = D.ReadOwnedPtr<Stmt>(C); |
| 628 | Expr* Cond = D.ReadOwnedPtr<Expr>(C); |
| 629 | Expr* Inc = D.ReadOwnedPtr<Expr>(C); |
| 630 | Stmt* Body = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | 07ba046 | 2007-11-07 08:02:55 +0000 | [diff] [blame] | 631 | return new ForStmt(Init,Cond,Inc,Body,ForLoc); |
| 632 | } |
| 633 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 634 | void GotoStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 3f0767b | 2007-11-07 08:07:46 +0000 | [diff] [blame] | 635 | S.Emit(GotoLoc); |
| 636 | S.Emit(LabelLoc); |
| 637 | S.EmitPtr(Label); |
| 638 | } |
| 639 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 640 | GotoStmt* GotoStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 3f0767b | 2007-11-07 08:07:46 +0000 | [diff] [blame] | 641 | SourceLocation GotoLoc = SourceLocation::ReadVal(D); |
| 642 | SourceLocation LabelLoc = SourceLocation::ReadVal(D); |
| 643 | GotoStmt* stmt = new GotoStmt(NULL,GotoLoc,LabelLoc); |
| 644 | D.ReadPtr(stmt->Label); // This pointer may be backpatched later. |
| 645 | return stmt; |
| 646 | } |
| 647 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 648 | void IfStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 4210f3d | 2007-11-07 07:19:30 +0000 | [diff] [blame] | 649 | S.Emit(IfLoc); |
| 650 | S.EmitOwnedPtr(getCond()); |
| 651 | S.EmitOwnedPtr(getThen()); |
| 652 | S.EmitOwnedPtr(getElse()); |
| 653 | } |
| 654 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 655 | IfStmt* IfStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 4210f3d | 2007-11-07 07:19:30 +0000 | [diff] [blame] | 656 | SourceLocation L = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 657 | Expr* Cond = D.ReadOwnedPtr<Expr>(C); |
| 658 | Stmt* Then = D.ReadOwnedPtr<Stmt>(C); |
| 659 | Stmt* Else = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | 4210f3d | 2007-11-07 07:19:30 +0000 | [diff] [blame] | 660 | return new IfStmt(L,Cond,Then,Else); |
| 661 | } |
| 662 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 663 | void ImaginaryLiteral::EmitImpl(Serializer& S) const { |
Ted Kremenek | 1c72de1 | 2007-11-07 18:53:02 +0000 | [diff] [blame] | 664 | S.Emit(getType()); |
| 665 | S.EmitOwnedPtr(Val); |
| 666 | } |
| 667 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 668 | ImaginaryLiteral* ImaginaryLiteral::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 1c72de1 | 2007-11-07 18:53:02 +0000 | [diff] [blame] | 669 | QualType t = QualType::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 670 | Expr* expr = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | 1c72de1 | 2007-11-07 18:53:02 +0000 | [diff] [blame] | 671 | assert (isa<FloatingLiteral>(expr) || isa<IntegerLiteral>(expr)); |
| 672 | return new ImaginaryLiteral(expr,t); |
| 673 | } |
| 674 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 675 | void ImplicitCastExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | a7c20dd | 2007-11-07 22:39:17 +0000 | [diff] [blame] | 676 | S.Emit(getType()); |
Argyrios Kyrtzidis | 0835a3c | 2008-08-18 23:01:59 +0000 | [diff] [blame] | 677 | S.EmitOwnedPtr(getSubExpr()); |
Douglas Gregor | eb8f306 | 2008-11-12 17:17:38 +0000 | [diff] [blame] | 678 | S.Emit(LvalueCast); |
Ted Kremenek | a7c20dd | 2007-11-07 22:39:17 +0000 | [diff] [blame] | 679 | } |
| 680 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 681 | ImplicitCastExpr* ImplicitCastExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | a7c20dd | 2007-11-07 22:39:17 +0000 | [diff] [blame] | 682 | QualType t = QualType::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 683 | Expr* Op = D.ReadOwnedPtr<Expr>(C); |
Douglas Gregor | eb8f306 | 2008-11-12 17:17:38 +0000 | [diff] [blame] | 684 | bool isLvalue = D.ReadBool(); |
| 685 | return new ImplicitCastExpr(t,Op,isLvalue); |
Ted Kremenek | a7c20dd | 2007-11-07 22:39:17 +0000 | [diff] [blame] | 686 | } |
| 687 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 688 | void IndirectGotoStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 689 | S.EmitOwnedPtr(Target); |
Ted Kremenek | 225a2d9 | 2007-11-07 17:02:32 +0000 | [diff] [blame] | 690 | } |
| 691 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 692 | IndirectGotoStmt* IndirectGotoStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
| 693 | Expr* Target = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 694 | return new IndirectGotoStmt(Target); |
Ted Kremenek | 225a2d9 | 2007-11-07 17:02:32 +0000 | [diff] [blame] | 695 | } |
| 696 | |
Ted Kremenek | 6336f8d | 2007-11-14 21:31:46 +0000 | [diff] [blame] | 697 | void InitListExpr::EmitImpl(Serializer& S) const { |
| 698 | S.Emit(LBraceLoc); |
| 699 | S.Emit(RBraceLoc); |
Steve Naroff | c5ae899 | 2008-05-01 02:04:18 +0000 | [diff] [blame] | 700 | S.EmitInt(InitExprs.size()); |
| 701 | if (!InitExprs.empty()) S.BatchEmitOwnedPtrs(InitExprs.size(), &InitExprs[0]); |
Ted Kremenek | 6336f8d | 2007-11-14 21:31:46 +0000 | [diff] [blame] | 702 | } |
| 703 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 704 | InitListExpr* InitListExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 6336f8d | 2007-11-14 21:31:46 +0000 | [diff] [blame] | 705 | InitListExpr* expr = new InitListExpr(); |
| 706 | expr->LBraceLoc = SourceLocation::ReadVal(D); |
| 707 | expr->RBraceLoc = SourceLocation::ReadVal(D); |
Steve Naroff | c5ae899 | 2008-05-01 02:04:18 +0000 | [diff] [blame] | 708 | unsigned size = D.ReadInt(); |
| 709 | assert(size); |
| 710 | expr->InitExprs.reserve(size); |
| 711 | for (unsigned i = 0 ; i < size; ++i) expr->InitExprs.push_back(0); |
| 712 | |
| 713 | D.BatchReadOwnedPtrs(size, &expr->InitExprs[0], C); |
Ted Kremenek | 6336f8d | 2007-11-14 21:31:46 +0000 | [diff] [blame] | 714 | return expr; |
| 715 | } |
| 716 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 717 | void IntegerLiteral::EmitImpl(Serializer& S) const { |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 718 | S.Emit(Loc); |
| 719 | S.Emit(getType()); |
| 720 | S.Emit(getValue()); |
| 721 | } |
| 722 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 723 | IntegerLiteral* IntegerLiteral::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 724 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 725 | QualType T = QualType::ReadVal(D); |
| 726 | |
| 727 | // Create a dummy APInt because it is more efficient to deserialize |
| 728 | // it in place with the deserialized IntegerLiteral. (fewer copies) |
| 729 | llvm::APInt temp; |
| 730 | IntegerLiteral* expr = new IntegerLiteral(temp,T,Loc); |
| 731 | D.Read(expr->Value); |
| 732 | |
| 733 | return expr; |
| 734 | } |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 735 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 736 | void LabelStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | b15132f | 2007-11-07 00:48:04 +0000 | [diff] [blame] | 737 | S.EmitPtr(Label); |
| 738 | S.Emit(IdentLoc); |
| 739 | S.EmitOwnedPtr(SubStmt); |
| 740 | } |
| 741 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 742 | LabelStmt* LabelStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | b15132f | 2007-11-07 00:48:04 +0000 | [diff] [blame] | 743 | IdentifierInfo* Label = D.ReadPtr<IdentifierInfo>(); |
| 744 | SourceLocation IdentLoc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 745 | Stmt* SubStmt = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | b15132f | 2007-11-07 00:48:04 +0000 | [diff] [blame] | 746 | return new LabelStmt(IdentLoc,Label,SubStmt); |
| 747 | } |
| 748 | |
Ted Kremenek | bd57e7c | 2007-11-13 22:16:23 +0000 | [diff] [blame] | 749 | void MemberExpr::EmitImpl(Serializer& S) const { |
| 750 | S.Emit(MemberLoc); |
| 751 | S.EmitPtr(MemberDecl); |
| 752 | S.EmitBool(IsArrow); |
Eli Friedman | 5101907 | 2008-02-06 22:48:16 +0000 | [diff] [blame] | 753 | S.Emit(getType()); |
Ted Kremenek | d073987 | 2008-02-06 23:03:14 +0000 | [diff] [blame] | 754 | S.EmitOwnedPtr(Base); |
Ted Kremenek | bd57e7c | 2007-11-13 22:16:23 +0000 | [diff] [blame] | 755 | } |
| 756 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 757 | MemberExpr* MemberExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | bd57e7c | 2007-11-13 22:16:23 +0000 | [diff] [blame] | 758 | SourceLocation L = SourceLocation::ReadVal(D); |
Douglas Gregor | 86f1940 | 2008-12-20 23:49:58 +0000 | [diff] [blame] | 759 | NamedDecl* MemberDecl = cast<NamedDecl>(D.ReadPtr<Decl>()); |
Ted Kremenek | bd57e7c | 2007-11-13 22:16:23 +0000 | [diff] [blame] | 760 | bool IsArrow = D.ReadBool(); |
Eli Friedman | 5101907 | 2008-02-06 22:48:16 +0000 | [diff] [blame] | 761 | QualType T = QualType::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 762 | Expr* base = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | bd57e7c | 2007-11-13 22:16:23 +0000 | [diff] [blame] | 763 | |
Eli Friedman | 5101907 | 2008-02-06 22:48:16 +0000 | [diff] [blame] | 764 | return new MemberExpr(base,IsArrow,MemberDecl,L,T); |
Ted Kremenek | bd57e7c | 2007-11-13 22:16:23 +0000 | [diff] [blame] | 765 | } |
| 766 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 767 | void NullStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 4927be6 | 2007-11-07 00:40:53 +0000 | [diff] [blame] | 768 | S.Emit(SemiLoc); |
| 769 | } |
| 770 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 771 | NullStmt* NullStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 4927be6 | 2007-11-07 00:40:53 +0000 | [diff] [blame] | 772 | SourceLocation SemiLoc = SourceLocation::ReadVal(D); |
| 773 | return new NullStmt(SemiLoc); |
| 774 | } |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 775 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 776 | void ParenExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 777 | S.Emit(L); |
| 778 | S.Emit(R); |
| 779 | S.EmitOwnedPtr(Val); |
| 780 | } |
| 781 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 782 | ParenExpr* ParenExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 783 | SourceLocation L = SourceLocation::ReadVal(D); |
| 784 | SourceLocation R = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 785 | Expr* val = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 786 | return new ParenExpr(L,R,val); |
Ted Kremenek | 1ba485e | 2007-11-07 17:11:58 +0000 | [diff] [blame] | 787 | } |
| 788 | |
Chris Lattner | d9f6910 | 2008-08-10 01:53:14 +0000 | [diff] [blame] | 789 | void PredefinedExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | 1ba485e | 2007-11-07 17:11:58 +0000 | [diff] [blame] | 790 | S.Emit(Loc); |
| 791 | S.EmitInt(getIdentType()); |
| 792 | S.Emit(getType()); |
| 793 | } |
| 794 | |
Chris Lattner | d9f6910 | 2008-08-10 01:53:14 +0000 | [diff] [blame] | 795 | PredefinedExpr* PredefinedExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 1ba485e | 2007-11-07 17:11:58 +0000 | [diff] [blame] | 796 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 797 | IdentType it = static_cast<IdentType>(D.ReadInt()); |
| 798 | QualType Q = QualType::ReadVal(D); |
Chris Lattner | d9f6910 | 2008-08-10 01:53:14 +0000 | [diff] [blame] | 799 | return new PredefinedExpr(Loc,Q,it); |
Ted Kremenek | 1ba485e | 2007-11-07 17:11:58 +0000 | [diff] [blame] | 800 | } |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 801 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 802 | void ReturnStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 803 | S.Emit(RetLoc); |
| 804 | S.EmitOwnedPtr(RetExpr); |
| 805 | } |
| 806 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 807 | ReturnStmt* ReturnStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 808 | SourceLocation RetLoc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 809 | Expr* RetExpr = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 810 | return new ReturnStmt(RetLoc,RetExpr); |
| 811 | } |
| 812 | |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 813 | void SizeOfAlignOfExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | ea2fe9b | 2007-11-13 22:30:29 +0000 | [diff] [blame] | 814 | S.EmitBool(isSizeof); |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 815 | S.EmitBool(isType); |
| 816 | if (isType) |
| 817 | S.Emit(getArgumentType()); |
| 818 | else |
| 819 | S.EmitOwnedPtr(getArgumentExpr()); |
Ted Kremenek | ea2fe9b | 2007-11-13 22:30:29 +0000 | [diff] [blame] | 820 | S.Emit(getType()); |
| 821 | S.Emit(OpLoc); |
| 822 | S.Emit(RParenLoc); |
| 823 | } |
| 824 | |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 825 | SizeOfAlignOfExpr* |
| 826 | SizeOfAlignOfExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | ea2fe9b | 2007-11-13 22:30:29 +0000 | [diff] [blame] | 827 | bool isSizeof = D.ReadBool(); |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 828 | bool isType = D.ReadBool(); |
| 829 | void *Argument; |
| 830 | if (isType) |
| 831 | Argument = QualType::ReadVal(D).getAsOpaquePtr(); |
| 832 | else |
| 833 | Argument = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | ea2fe9b | 2007-11-13 22:30:29 +0000 | [diff] [blame] | 834 | QualType Res = QualType::ReadVal(D); |
| 835 | SourceLocation OpLoc = SourceLocation::ReadVal(D); |
| 836 | SourceLocation RParenLoc = SourceLocation::ReadVal(D); |
| 837 | |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 838 | return new SizeOfAlignOfExpr(isSizeof, isType, Argument, Res, |
| 839 | OpLoc, RParenLoc); |
Ted Kremenek | ea2fe9b | 2007-11-13 22:30:29 +0000 | [diff] [blame] | 840 | } |
| 841 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 842 | void StmtExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 843 | S.Emit(getType()); |
| 844 | S.Emit(LParenLoc); |
| 845 | S.Emit(RParenLoc); |
| 846 | S.EmitOwnedPtr(SubStmt); |
| 847 | } |
| 848 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 849 | StmtExpr* StmtExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 850 | QualType t = QualType::ReadVal(D); |
| 851 | SourceLocation L = SourceLocation::ReadVal(D); |
| 852 | SourceLocation R = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 853 | CompoundStmt* SubStmt = cast<CompoundStmt>(D.ReadOwnedPtr<Stmt>(C)); |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 854 | return new StmtExpr(SubStmt,t,L,R); |
| 855 | } |
| 856 | |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 857 | void TypesCompatibleExpr::EmitImpl(llvm::Serializer& S) const { |
| 858 | S.Emit(getType()); |
| 859 | S.Emit(BuiltinLoc); |
| 860 | S.Emit(RParenLoc); |
| 861 | S.Emit(Type1); |
| 862 | S.Emit(Type2); |
| 863 | } |
| 864 | |
| 865 | TypesCompatibleExpr* TypesCompatibleExpr::CreateImpl(llvm::Deserializer& D, |
| 866 | ASTContext& C) { |
| 867 | QualType RT = QualType::ReadVal(D); |
| 868 | SourceLocation BL = SourceLocation::ReadVal(D); |
| 869 | SourceLocation RP = SourceLocation::ReadVal(D); |
| 870 | QualType T1 = QualType::ReadVal(D); |
| 871 | QualType T2 = QualType::ReadVal(D); |
| 872 | return new TypesCompatibleExpr(RT, BL, T1, T2, RP); |
| 873 | } |
| 874 | |
| 875 | void ShuffleVectorExpr::EmitImpl(llvm::Serializer& S) const { |
| 876 | S.Emit(getType()); |
| 877 | S.Emit(BuiltinLoc); |
| 878 | S.Emit(RParenLoc); |
| 879 | S.EmitInt(NumExprs); |
Daniel Dunbar | 20c77e9 | 2008-10-15 17:52:29 +0000 | [diff] [blame] | 880 | S.BatchEmitOwnedPtrs(NumExprs, &SubExprs[0]); |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 881 | } |
| 882 | |
| 883 | ShuffleVectorExpr* ShuffleVectorExpr::CreateImpl(llvm::Deserializer& D, |
| 884 | ASTContext& C) { |
| 885 | QualType T = QualType::ReadVal(D); |
| 886 | SourceLocation BL = SourceLocation::ReadVal(D); |
| 887 | SourceLocation RP = SourceLocation::ReadVal(D); |
| 888 | unsigned NumExprs = D.ReadInt(); |
Daniel Dunbar | 20c77e9 | 2008-10-15 17:52:29 +0000 | [diff] [blame] | 889 | // FIXME: Avoid extra allocation. |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 890 | llvm::SmallVector<Expr*, 4> Exprs(NumExprs); |
Daniel Dunbar | 20c77e9 | 2008-10-15 17:52:29 +0000 | [diff] [blame] | 891 | D.BatchReadOwnedPtrs(NumExprs, Exprs.begin(), C); |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 892 | return new ShuffleVectorExpr(Exprs.begin(), NumExprs, T, BL, RP); |
| 893 | } |
| 894 | |
| 895 | void ChooseExpr::EmitImpl(llvm::Serializer& S) const { |
| 896 | S.Emit(getType()); |
| 897 | S.Emit(BuiltinLoc); |
| 898 | S.Emit(RParenLoc); |
Daniel Dunbar | 20c77e9 | 2008-10-15 17:52:29 +0000 | [diff] [blame] | 899 | S.BatchEmitOwnedPtrs((unsigned) END_EXPR, &SubExprs[0]); |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 900 | } |
| 901 | |
| 902 | ChooseExpr* ChooseExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 903 | QualType T = QualType::ReadVal(D); |
| 904 | SourceLocation BL = SourceLocation::ReadVal(D); |
| 905 | SourceLocation RP = SourceLocation::ReadVal(D); |
Daniel Dunbar | 20c77e9 | 2008-10-15 17:52:29 +0000 | [diff] [blame] | 906 | ChooseExpr *CE = new ChooseExpr(BL, 0, 0, 0, T, RP); |
| 907 | D.BatchReadOwnedPtrs((unsigned) END_EXPR, &CE->SubExprs[0], C); |
| 908 | return CE; |
| 909 | } |
| 910 | |
Douglas Gregor | 2d8b273 | 2008-11-29 04:51:27 +0000 | [diff] [blame] | 911 | void GNUNullExpr::EmitImpl(llvm::Serializer &S) const { |
| 912 | S.Emit(getType()); |
| 913 | S.Emit(TokenLoc); |
| 914 | } |
| 915 | |
| 916 | GNUNullExpr *GNUNullExpr::CreateImpl(llvm::Deserializer &D, ASTContext &C) { |
| 917 | QualType T = QualType::ReadVal(D); |
| 918 | SourceLocation TL = SourceLocation::ReadVal(D); |
| 919 | return new GNUNullExpr(T, TL); |
| 920 | } |
| 921 | |
Daniel Dunbar | 20c77e9 | 2008-10-15 17:52:29 +0000 | [diff] [blame] | 922 | void OverloadExpr::EmitImpl(llvm::Serializer& S) const { |
| 923 | S.Emit(getType()); |
| 924 | S.Emit(BuiltinLoc); |
| 925 | S.Emit(RParenLoc); |
| 926 | S.EmitInt(FnIndex); |
| 927 | S.EmitInt(NumExprs); |
| 928 | S.BatchEmitOwnedPtrs(NumExprs, &SubExprs[0]); |
| 929 | } |
| 930 | |
| 931 | OverloadExpr* OverloadExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 932 | QualType T = QualType::ReadVal(D); |
| 933 | SourceLocation BL = SourceLocation::ReadVal(D); |
| 934 | SourceLocation RP = SourceLocation::ReadVal(D); |
| 935 | unsigned FnIndex = D.ReadInt(); |
| 936 | unsigned NumExprs = D.ReadInt(); |
| 937 | // FIXME: Avoid extra allocation. |
| 938 | llvm::SmallVector<Expr*, 4> Exprs(NumExprs); |
| 939 | D.BatchReadOwnedPtrs(NumExprs, Exprs.begin(), C); |
| 940 | return new OverloadExpr(Exprs.begin(), NumExprs, FnIndex, T, BL, RP); |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 941 | } |
| 942 | |
| 943 | void VAArgExpr::EmitImpl(llvm::Serializer& S) const { |
| 944 | S.Emit(getType()); |
| 945 | S.Emit(BuiltinLoc); |
| 946 | S.Emit(RParenLoc); |
| 947 | S.EmitOwnedPtr(getSubExpr()); |
| 948 | } |
| 949 | |
| 950 | VAArgExpr* VAArgExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 951 | QualType T = QualType::ReadVal(D); |
| 952 | SourceLocation BL = SourceLocation::ReadVal(D); |
| 953 | SourceLocation RP = SourceLocation::ReadVal(D); |
| 954 | Expr *E = D.ReadOwnedPtr<Expr>(C); |
| 955 | return new VAArgExpr(BL, E, T, RP); |
| 956 | } |
| 957 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 958 | void StringLiteral::EmitImpl(Serializer& S) const { |
Ted Kremenek | 7febad7 | 2007-11-07 19:08:19 +0000 | [diff] [blame] | 959 | S.Emit(getType()); |
| 960 | S.Emit(firstTokLoc); |
| 961 | S.Emit(lastTokLoc); |
| 962 | S.EmitBool(isWide()); |
| 963 | S.Emit(getByteLength()); |
| 964 | |
| 965 | for (unsigned i = 0 ; i < ByteLength; ++i) |
| 966 | S.EmitInt(StrData[i]); |
| 967 | } |
| 968 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 969 | StringLiteral* StringLiteral::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 7febad7 | 2007-11-07 19:08:19 +0000 | [diff] [blame] | 970 | QualType t = QualType::ReadVal(D); |
| 971 | SourceLocation firstTokLoc = SourceLocation::ReadVal(D); |
| 972 | SourceLocation lastTokLoc = SourceLocation::ReadVal(D); |
| 973 | bool isWide = D.ReadBool(); |
| 974 | unsigned ByteLength = D.ReadInt(); |
| 975 | |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 976 | StringLiteral* sl = new (C, llvm::alignof<StringLiteral>()) |
| 977 | StringLiteral(C, NULL, 0, isWide, t, firstTokLoc, lastTokLoc); |
Ted Kremenek | 7febad7 | 2007-11-07 19:08:19 +0000 | [diff] [blame] | 978 | |
Ted Kremenek | 6e94ef5 | 2009-02-06 19:55:15 +0000 | [diff] [blame] | 979 | char* StrData = new (C, llvm::alignof<char>()) char[ByteLength]; |
Ted Kremenek | 7febad7 | 2007-11-07 19:08:19 +0000 | [diff] [blame] | 980 | for (unsigned i = 0; i < ByteLength; ++i) |
| 981 | StrData[i] = (char) D.ReadInt(); |
| 982 | |
| 983 | sl->ByteLength = ByteLength; |
| 984 | sl->StrData = StrData; |
| 985 | |
| 986 | return sl; |
| 987 | } |
| 988 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 989 | void SwitchStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 990 | S.Emit(SwitchLoc); |
| 991 | S.EmitOwnedPtr(getCond()); |
| 992 | S.EmitOwnedPtr(getBody()); |
| 993 | S.EmitPtr(FirstCase); |
| 994 | } |
| 995 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 996 | SwitchStmt* SwitchStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 997 | SourceLocation Loc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 998 | Stmt* Cond = D.ReadOwnedPtr<Stmt>(C); |
| 999 | Stmt* Body = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 1000 | SwitchCase* FirstCase = cast<SwitchCase>(D.ReadPtr<Stmt>()); |
| 1001 | |
| 1002 | SwitchStmt* stmt = new SwitchStmt(cast<Expr>(Cond)); |
| 1003 | stmt->setBody(Body,Loc); |
| 1004 | stmt->FirstCase = FirstCase; |
| 1005 | |
| 1006 | return stmt; |
| 1007 | } |
Ted Kremenek | 5572b94 | 2007-11-07 07:50:10 +0000 | [diff] [blame] | 1008 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 1009 | void UnaryOperator::EmitImpl(Serializer& S) const { |
Ted Kremenek | 1049436 | 2007-11-08 00:26:24 +0000 | [diff] [blame] | 1010 | S.Emit(getType()); |
| 1011 | S.Emit(Loc); |
| 1012 | S.EmitInt(Opc); |
| 1013 | S.EmitOwnedPtr(Val); |
| 1014 | } |
| 1015 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1016 | UnaryOperator* UnaryOperator::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 1049436 | 2007-11-08 00:26:24 +0000 | [diff] [blame] | 1017 | QualType t = QualType::ReadVal(D); |
| 1018 | SourceLocation L = SourceLocation::ReadVal(D); |
| 1019 | Opcode Opc = static_cast<Opcode>(D.ReadInt()); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1020 | Expr* Val = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | 1049436 | 2007-11-08 00:26:24 +0000 | [diff] [blame] | 1021 | return new UnaryOperator(Val,Opc,t,L); |
| 1022 | } |
| 1023 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 1024 | void WhileStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 5572b94 | 2007-11-07 07:50:10 +0000 | [diff] [blame] | 1025 | S.Emit(WhileLoc); |
| 1026 | S.EmitOwnedPtr(getCond()); |
| 1027 | S.EmitOwnedPtr(getBody()); |
| 1028 | } |
| 1029 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1030 | WhileStmt* WhileStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 5572b94 | 2007-11-07 07:50:10 +0000 | [diff] [blame] | 1031 | SourceLocation WhileLoc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1032 | Expr* Cond = D.ReadOwnedPtr<Expr>(C); |
| 1033 | Stmt* Body = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | 5572b94 | 2007-11-07 07:50:10 +0000 | [diff] [blame] | 1034 | return new WhileStmt(Cond,Body,WhileLoc); |
| 1035 | } |
Ted Kremenek | 378c151 | 2007-11-15 18:10:29 +0000 | [diff] [blame] | 1036 | |
| 1037 | //===----------------------------------------------------------------------===// |
| 1038 | // Objective C Serialization |
| 1039 | //===----------------------------------------------------------------------===// |
| 1040 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1041 | void ObjCAtCatchStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | af52677 | 2007-12-04 00:28:54 +0000 | [diff] [blame] | 1042 | S.Emit(AtCatchLoc); |
| 1043 | S.Emit(RParenLoc); |
Ted Kremenek | ff98102 | 2008-02-01 21:28:59 +0000 | [diff] [blame] | 1044 | S.BatchEmitOwnedPtrs((unsigned) END_EXPR, &SubExprs[0]); |
Ted Kremenek | af52677 | 2007-12-04 00:28:54 +0000 | [diff] [blame] | 1045 | } |
| 1046 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1047 | ObjCAtCatchStmt* ObjCAtCatchStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | af52677 | 2007-12-04 00:28:54 +0000 | [diff] [blame] | 1048 | SourceLocation AtCatchLoc = SourceLocation::ReadVal(D); |
| 1049 | SourceLocation RParenLoc = SourceLocation::ReadVal(D); |
| 1050 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1051 | ObjCAtCatchStmt* stmt = new ObjCAtCatchStmt(AtCatchLoc,RParenLoc); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1052 | D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubExprs[0], C); |
Ted Kremenek | af52677 | 2007-12-04 00:28:54 +0000 | [diff] [blame] | 1053 | |
| 1054 | return stmt; |
| 1055 | } |
| 1056 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1057 | void ObjCAtFinallyStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 04be5aa | 2007-12-04 00:32:22 +0000 | [diff] [blame] | 1058 | S.Emit(AtFinallyLoc); |
| 1059 | S.EmitOwnedPtr(AtFinallyStmt); |
| 1060 | } |
| 1061 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1062 | ObjCAtFinallyStmt* ObjCAtFinallyStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 04be5aa | 2007-12-04 00:32:22 +0000 | [diff] [blame] | 1063 | SourceLocation Loc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1064 | Stmt* AtFinallyStmt = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1065 | return new ObjCAtFinallyStmt(Loc,AtFinallyStmt); |
Ted Kremenek | 04be5aa | 2007-12-04 00:32:22 +0000 | [diff] [blame] | 1066 | } |
| 1067 | |
Ted Kremenek | b7e6bd7 | 2008-01-29 21:21:30 +0000 | [diff] [blame] | 1068 | void ObjCAtSynchronizedStmt::EmitImpl(Serializer& S) const { |
| 1069 | S.Emit(AtSynchronizedLoc); |
Fariborz Jahanian | a0f5579 | 2008-01-29 22:59:37 +0000 | [diff] [blame] | 1070 | S.BatchEmitOwnedPtrs((unsigned) END_EXPR,&SubStmts[0]); |
| 1071 | } |
Ted Kremenek | b7e6bd7 | 2008-01-29 21:21:30 +0000 | [diff] [blame] | 1072 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1073 | ObjCAtSynchronizedStmt* ObjCAtSynchronizedStmt::CreateImpl(Deserializer& D, |
| 1074 | ASTContext& C) { |
| 1075 | |
Ted Kremenek | b7e6bd7 | 2008-01-29 21:21:30 +0000 | [diff] [blame] | 1076 | SourceLocation L = SourceLocation::ReadVal(D); |
Fariborz Jahanian | a0f5579 | 2008-01-29 22:59:37 +0000 | [diff] [blame] | 1077 | ObjCAtSynchronizedStmt* stmt = new ObjCAtSynchronizedStmt(L,0,0); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1078 | D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubStmts[0], C); |
Ted Kremenek | b7e6bd7 | 2008-01-29 21:21:30 +0000 | [diff] [blame] | 1079 | return stmt; |
| 1080 | } |
| 1081 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1082 | void ObjCAtThrowStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 5bdd4e3 | 2007-12-04 00:40:49 +0000 | [diff] [blame] | 1083 | S.Emit(AtThrowLoc); |
| 1084 | S.EmitOwnedPtr(Throw); |
| 1085 | } |
| 1086 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1087 | ObjCAtThrowStmt* ObjCAtThrowStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 5bdd4e3 | 2007-12-04 00:40:49 +0000 | [diff] [blame] | 1088 | SourceLocation L = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1089 | Stmt* Throw = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1090 | return new ObjCAtThrowStmt(L,Throw); |
Ted Kremenek | 5bdd4e3 | 2007-12-04 00:40:49 +0000 | [diff] [blame] | 1091 | } |
| 1092 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1093 | void ObjCAtTryStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 9c1efff | 2007-12-04 00:38:30 +0000 | [diff] [blame] | 1094 | S.Emit(AtTryLoc); |
| 1095 | S.BatchEmitOwnedPtrs((unsigned) END_EXPR, &SubStmts[0]); |
| 1096 | } |
| 1097 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1098 | ObjCAtTryStmt* ObjCAtTryStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 9c1efff | 2007-12-04 00:38:30 +0000 | [diff] [blame] | 1099 | SourceLocation L = SourceLocation::ReadVal(D); |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1100 | ObjCAtTryStmt* stmt = new ObjCAtTryStmt(L,NULL,NULL,NULL); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1101 | D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubStmts[0], C); |
Ted Kremenek | 9c1efff | 2007-12-04 00:38:30 +0000 | [diff] [blame] | 1102 | return stmt; |
| 1103 | } |
| 1104 | |
Ted Kremenek | 8f6dc77 | 2007-12-05 00:43:08 +0000 | [diff] [blame] | 1105 | void ObjCEncodeExpr::EmitImpl(Serializer& S) const { |
| 1106 | S.Emit(AtLoc); |
| 1107 | S.Emit(RParenLoc); |
| 1108 | S.Emit(getType()); |
| 1109 | S.Emit(EncType); |
| 1110 | } |
| 1111 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1112 | ObjCEncodeExpr* ObjCEncodeExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 8f6dc77 | 2007-12-05 00:43:08 +0000 | [diff] [blame] | 1113 | SourceLocation AtLoc = SourceLocation::ReadVal(D); |
| 1114 | SourceLocation RParenLoc = SourceLocation::ReadVal(D); |
| 1115 | QualType T = QualType::ReadVal(D); |
| 1116 | QualType ET = QualType::ReadVal(D); |
| 1117 | return new ObjCEncodeExpr(T,ET,AtLoc,RParenLoc); |
| 1118 | } |
| 1119 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1120 | void ObjCForCollectionStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | c3b59d3 | 2008-01-05 00:57:49 +0000 | [diff] [blame] | 1121 | S.Emit(ForLoc); |
Fariborz Jahanian | 7571228 | 2008-01-10 00:24:29 +0000 | [diff] [blame] | 1122 | S.Emit(RParenLoc); |
Ted Kremenek | 205712a | 2008-01-07 18:35:04 +0000 | [diff] [blame] | 1123 | S.BatchEmitOwnedPtrs(getElement(),getCollection(),getBody()); |
Ted Kremenek | c3b59d3 | 2008-01-05 00:57:49 +0000 | [diff] [blame] | 1124 | } |
| 1125 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1126 | ObjCForCollectionStmt* ObjCForCollectionStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | c3b59d3 | 2008-01-05 00:57:49 +0000 | [diff] [blame] | 1127 | SourceLocation ForLoc = SourceLocation::ReadVal(D); |
Fariborz Jahanian | 7571228 | 2008-01-10 00:24:29 +0000 | [diff] [blame] | 1128 | SourceLocation RParenLoc = SourceLocation::ReadVal(D); |
Ted Kremenek | 205712a | 2008-01-07 18:35:04 +0000 | [diff] [blame] | 1129 | Stmt* Element; |
| 1130 | Expr* Collection; |
| 1131 | Stmt* Body; |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1132 | D.BatchReadOwnedPtrs(Element, Collection, Body, C); |
Fariborz Jahanian | 7571228 | 2008-01-10 00:24:29 +0000 | [diff] [blame] | 1133 | return new ObjCForCollectionStmt(Element,Collection,Body,ForLoc, RParenLoc); |
Ted Kremenek | c3b59d3 | 2008-01-05 00:57:49 +0000 | [diff] [blame] | 1134 | } |
| 1135 | |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 1136 | void ObjCProtocolExpr::EmitImpl(llvm::Serializer& S) const { |
| 1137 | S.Emit(getType()); |
| 1138 | S.EmitPtr(Protocol); |
| 1139 | S.Emit(AtLoc); |
| 1140 | S.Emit(RParenLoc); |
| 1141 | } |
| 1142 | |
| 1143 | ObjCProtocolExpr* ObjCProtocolExpr::CreateImpl(llvm::Deserializer& D, |
| 1144 | ASTContext& C) { |
| 1145 | QualType T = QualType::ReadVal(D); |
| 1146 | ObjCProtocolDecl *PD = D.ReadPtr<ObjCProtocolDecl>(); |
| 1147 | SourceLocation AL = SourceLocation::ReadVal(D); |
| 1148 | SourceLocation RP = SourceLocation::ReadVal(D); |
| 1149 | return new ObjCProtocolExpr(T, PD, AL, RP); |
| 1150 | } |
| 1151 | |
Ted Kremenek | 378c151 | 2007-11-15 18:10:29 +0000 | [diff] [blame] | 1152 | void ObjCIvarRefExpr::EmitImpl(Serializer& S) const { |
| 1153 | S.Emit(Loc); |
| 1154 | S.Emit(getType()); |
| 1155 | S.EmitPtr(getDecl()); |
| 1156 | } |
Ted Kremenek | 9c1efff | 2007-12-04 00:38:30 +0000 | [diff] [blame] | 1157 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1158 | ObjCIvarRefExpr* ObjCIvarRefExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 378c151 | 2007-11-15 18:10:29 +0000 | [diff] [blame] | 1159 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1160 | QualType T = QualType::ReadVal(D); |
Fariborz Jahanian | efc4c4b | 2008-12-18 17:29:46 +0000 | [diff] [blame] | 1161 | ObjCIvarRefExpr* dr = new ObjCIvarRefExpr(NULL,T,Loc); |
Ted Kremenek | 378c151 | 2007-11-15 18:10:29 +0000 | [diff] [blame] | 1162 | D.ReadPtr(dr->D,false); |
| 1163 | return dr; |
| 1164 | } |
Ted Kremenek | 46dc0a5 | 2007-12-04 00:51:11 +0000 | [diff] [blame] | 1165 | |
Steve Naroff | ae78407 | 2008-05-30 00:40:33 +0000 | [diff] [blame] | 1166 | void ObjCPropertyRefExpr::EmitImpl(Serializer& S) const { |
Steve Naroff | c77a636 | 2008-12-04 16:24:46 +0000 | [diff] [blame] | 1167 | S.Emit(IdLoc); |
Steve Naroff | ae78407 | 2008-05-30 00:40:33 +0000 | [diff] [blame] | 1168 | S.Emit(getType()); |
Fariborz Jahanian | 5daf570 | 2008-11-22 18:39:36 +0000 | [diff] [blame] | 1169 | S.EmitPtr(getProperty()); |
| 1170 | } |
| 1171 | |
| 1172 | void ObjCKVCRefExpr::EmitImpl(Serializer& S) const { |
| 1173 | S.Emit(Loc); |
| 1174 | S.Emit(getType()); |
| 1175 | S.EmitPtr(getGetterMethod()); |
| 1176 | S.EmitPtr(getSetterMethod()); |
Steve Naroff | ae78407 | 2008-05-30 00:40:33 +0000 | [diff] [blame] | 1177 | } |
| 1178 | |
| 1179 | ObjCPropertyRefExpr* ObjCPropertyRefExpr::CreateImpl(Deserializer& D, |
| 1180 | ASTContext& C) { |
| 1181 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1182 | QualType T = QualType::ReadVal(D); |
| 1183 | ObjCPropertyRefExpr* dr = new ObjCPropertyRefExpr(NULL,T,Loc,0); |
Fariborz Jahanian | 5daf570 | 2008-11-22 18:39:36 +0000 | [diff] [blame] | 1184 | D.ReadPtr(dr->AsProperty,false); |
| 1185 | return dr; |
| 1186 | } |
| 1187 | |
| 1188 | ObjCKVCRefExpr* ObjCKVCRefExpr::CreateImpl(Deserializer& D, |
| 1189 | ASTContext& C) { |
| 1190 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1191 | QualType T = QualType::ReadVal(D); |
Fariborz Jahanian | ba8d2d6 | 2008-11-22 20:25:50 +0000 | [diff] [blame] | 1192 | ObjCKVCRefExpr* dr = new ObjCKVCRefExpr(NULL,T,NULL,Loc,0); |
Fariborz Jahanian | 5daf570 | 2008-11-22 18:39:36 +0000 | [diff] [blame] | 1193 | D.ReadPtr(dr->Setter,false); |
| 1194 | D.ReadPtr(dr->Getter,false); |
Steve Naroff | ae78407 | 2008-05-30 00:40:33 +0000 | [diff] [blame] | 1195 | return dr; |
| 1196 | } |
| 1197 | |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1198 | void ObjCMessageExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | be78424 | 2008-06-24 17:00:08 +0000 | [diff] [blame] | 1199 | S.EmitInt(getFlag()); |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1200 | S.Emit(getType()); |
| 1201 | S.Emit(SelName); |
| 1202 | S.Emit(LBracloc); |
| 1203 | S.Emit(RBracloc); |
| 1204 | S.EmitInt(NumArgs); |
| 1205 | S.EmitPtr(MethodProto); |
| 1206 | |
| 1207 | if (getReceiver()) |
| 1208 | S.BatchEmitOwnedPtrs(NumArgs+1, SubExprs); |
Ted Kremenek | be78424 | 2008-06-24 17:00:08 +0000 | [diff] [blame] | 1209 | else { |
| 1210 | ClassInfo Info = getClassInfo(); |
| 1211 | |
| 1212 | if (Info.first) S.EmitPtr(Info.first); |
| 1213 | else S.EmitPtr(Info.second); |
| 1214 | |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1215 | S.BatchEmitOwnedPtrs(NumArgs, &SubExprs[ARGS_START]); |
| 1216 | } |
| 1217 | } |
| 1218 | |
| 1219 | ObjCMessageExpr* ObjCMessageExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | be78424 | 2008-06-24 17:00:08 +0000 | [diff] [blame] | 1220 | unsigned flags = D.ReadInt(); |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1221 | QualType t = QualType::ReadVal(D); |
| 1222 | Selector S = Selector::ReadVal(D); |
| 1223 | SourceLocation L = SourceLocation::ReadVal(D); |
| 1224 | SourceLocation R = SourceLocation::ReadVal(D); |
| 1225 | |
| 1226 | // Construct an array for the subexpressions. |
| 1227 | unsigned NumArgs = D.ReadInt(); |
Ted Kremenek | be78424 | 2008-06-24 17:00:08 +0000 | [diff] [blame] | 1228 | Stmt** SubExprs = new Stmt*[NumArgs+1]; |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1229 | |
| 1230 | // Construct the ObjCMessageExpr object using the special ctor. |
| 1231 | ObjCMessageExpr* ME = new ObjCMessageExpr(S, t, L, R, SubExprs, NumArgs); |
| 1232 | |
| 1233 | // Read in the MethodProto. Read the instance variable directly |
| 1234 | // allows it to be backpatched. |
| 1235 | D.ReadPtr(ME->MethodProto); |
| 1236 | |
| 1237 | // Now read in the arguments. |
| 1238 | |
Eli Friedman | e8e3205 | 2008-12-16 20:06:41 +0000 | [diff] [blame] | 1239 | if ((flags & Flags) == IsInstMeth) |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1240 | D.BatchReadOwnedPtrs(NumArgs+1, SubExprs, C); |
| 1241 | else { |
Ted Kremenek | be78424 | 2008-06-24 17:00:08 +0000 | [diff] [blame] | 1242 | // Read the pointer for Cls/ClassName. The Deserializer will handle the |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1243 | // bit-mangling automatically. |
Ted Kremenek | be78424 | 2008-06-24 17:00:08 +0000 | [diff] [blame] | 1244 | SubExprs[RECEIVER] = (Stmt*) ((uintptr_t) flags); |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1245 | D.ReadUIntPtr((uintptr_t&) SubExprs[RECEIVER]); |
| 1246 | |
| 1247 | // Read the arguments. |
| 1248 | D.BatchReadOwnedPtrs(NumArgs, &SubExprs[ARGS_START], C); |
| 1249 | } |
| 1250 | |
| 1251 | return ME; |
| 1252 | } |
| 1253 | |
Ted Kremenek | 8f6dc77 | 2007-12-05 00:43:08 +0000 | [diff] [blame] | 1254 | void ObjCSelectorExpr::EmitImpl(Serializer& S) const { |
| 1255 | S.Emit(AtLoc); |
| 1256 | S.Emit(RParenLoc); |
| 1257 | S.Emit(getType()); |
| 1258 | S.Emit(SelName); |
| 1259 | } |
| 1260 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1261 | ObjCSelectorExpr* ObjCSelectorExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 8f6dc77 | 2007-12-05 00:43:08 +0000 | [diff] [blame] | 1262 | SourceLocation AtLoc = SourceLocation::ReadVal(D); |
| 1263 | SourceLocation RParenLoc = SourceLocation::ReadVal(D); |
| 1264 | QualType T = QualType::ReadVal(D); |
| 1265 | Selector SelName = Selector::ReadVal(D); |
| 1266 | |
| 1267 | return new ObjCSelectorExpr(T,SelName,AtLoc,RParenLoc); |
| 1268 | } |
| 1269 | |
Ted Kremenek | 46dc0a5 | 2007-12-04 00:51:11 +0000 | [diff] [blame] | 1270 | void ObjCStringLiteral::EmitImpl(Serializer& S) const { |
| 1271 | S.Emit(AtLoc); |
| 1272 | S.Emit(getType()); |
| 1273 | S.EmitOwnedPtr(String); |
| 1274 | } |
| 1275 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1276 | ObjCStringLiteral* ObjCStringLiteral::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 46dc0a5 | 2007-12-04 00:51:11 +0000 | [diff] [blame] | 1277 | SourceLocation L = SourceLocation::ReadVal(D); |
| 1278 | QualType T = QualType::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1279 | StringLiteral* String = cast<StringLiteral>(D.ReadOwnedPtr<Stmt>(C)); |
Ted Kremenek | 46dc0a5 | 2007-12-04 00:51:11 +0000 | [diff] [blame] | 1280 | return new ObjCStringLiteral(String,T,L); |
| 1281 | } |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 1282 | |
Douglas Gregor | cd9b46e | 2008-11-04 14:56:14 +0000 | [diff] [blame] | 1283 | void ObjCSuperExpr::EmitImpl(llvm::Serializer& S) const { |
| 1284 | S.Emit(getType()); |
| 1285 | S.Emit(Loc); |
| 1286 | } |
| 1287 | |
| 1288 | ObjCSuperExpr* ObjCSuperExpr::CreateImpl(llvm::Deserializer& D, ASTContext&) { |
| 1289 | QualType Ty = QualType::ReadVal(D); |
| 1290 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1291 | return new ObjCSuperExpr(Loc, Ty); |
| 1292 | } |
| 1293 | |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 1294 | //===----------------------------------------------------------------------===// |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1295 | // Serialization for Clang Extensions. |
| 1296 | //===----------------------------------------------------------------------===// |
| 1297 | |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 1298 | void ExtVectorElementExpr::EmitImpl(llvm::Serializer& S) const { |
| 1299 | S.Emit(getType()); |
| 1300 | S.EmitOwnedPtr(getBase()); |
| 1301 | S.EmitPtr(&Accessor); |
| 1302 | S.Emit(AccessorLoc); |
| 1303 | } |
| 1304 | |
| 1305 | ExtVectorElementExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 1306 | QualType T = QualType::ReadVal(D); |
| 1307 | Expr *B = D.ReadOwnedPtr<Expr>(C); |
| 1308 | IdentifierInfo *A = D.ReadPtr<IdentifierInfo>(); |
| 1309 | SourceLocation AL = SourceLocation::ReadVal(D); |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame^] | 1310 | return new (C) ExtVectorElementExpr(T, B, *A, AL); |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 1311 | } |
| 1312 | |
Steve Naroff | 9c3c902 | 2008-09-17 18:37:59 +0000 | [diff] [blame] | 1313 | void BlockExpr::EmitImpl(Serializer& S) const { |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1314 | S.Emit(getType()); |
Steve Naroff | 56ee689 | 2008-10-08 17:01:13 +0000 | [diff] [blame] | 1315 | S.EmitOwnedPtr(TheBlock); |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1316 | } |
| 1317 | |
Steve Naroff | 9c3c902 | 2008-09-17 18:37:59 +0000 | [diff] [blame] | 1318 | BlockExpr* BlockExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Steve Naroff | 56ee689 | 2008-10-08 17:01:13 +0000 | [diff] [blame] | 1319 | QualType T = QualType::ReadVal(D); |
| 1320 | return new BlockExpr(cast<BlockDecl>(D.ReadOwnedPtr<Decl>(C)),T); |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1321 | } |
| 1322 | |
| 1323 | void BlockDeclRefExpr::EmitImpl(Serializer& S) const { |
| 1324 | S.Emit(Loc); |
| 1325 | S.Emit(getType()); |
| 1326 | S.EmitBool(false); |
| 1327 | S.EmitPtr(getDecl()); |
| 1328 | } |
| 1329 | |
| 1330 | BlockDeclRefExpr* BlockDeclRefExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
| 1331 | assert(0 && "Cannot deserialize BlockDeclRefExpr yet"); |
| 1332 | return 0; |
| 1333 | } |
| 1334 | |
| 1335 | //===----------------------------------------------------------------------===// |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 1336 | // C++ Serialization |
| 1337 | //===----------------------------------------------------------------------===// |
| 1338 | void CXXDefaultArgExpr::EmitImpl(Serializer& S) const { |
| 1339 | S.EmitPtr(Param); |
| 1340 | } |
| 1341 | |
| 1342 | CXXDefaultArgExpr *CXXDefaultArgExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
| 1343 | ParmVarDecl* Param = 0; |
| 1344 | D.ReadPtr(Param, false); |
| 1345 | return new CXXDefaultArgExpr(Param); |
| 1346 | } |
Argyrios Kyrtzidis | 987a14b | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 1347 | |
| 1348 | void CXXFunctionalCastExpr::EmitImpl(Serializer& S) const { |
| 1349 | S.Emit(getType()); |
Douglas Gregor | 49badde | 2008-10-27 19:41:14 +0000 | [diff] [blame] | 1350 | S.Emit(getTypeAsWritten()); |
Argyrios Kyrtzidis | 987a14b | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 1351 | S.Emit(TyBeginLoc); |
| 1352 | S.Emit(RParenLoc); |
| 1353 | S.EmitOwnedPtr(getSubExpr()); |
| 1354 | } |
| 1355 | |
| 1356 | CXXFunctionalCastExpr * |
| 1357 | CXXFunctionalCastExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
| 1358 | QualType Ty = QualType::ReadVal(D); |
Douglas Gregor | 49badde | 2008-10-27 19:41:14 +0000 | [diff] [blame] | 1359 | QualType WrittenTy = QualType::ReadVal(D); |
Argyrios Kyrtzidis | 987a14b | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 1360 | SourceLocation TyBeginLoc = SourceLocation::ReadVal(D); |
| 1361 | SourceLocation RParenLoc = SourceLocation::ReadVal(D); |
| 1362 | Expr* SubExpr = D.ReadOwnedPtr<Expr>(C); |
Douglas Gregor | 49badde | 2008-10-27 19:41:14 +0000 | [diff] [blame] | 1363 | return new CXXFunctionalCastExpr(Ty, WrittenTy, TyBeginLoc, SubExpr, RParenLoc); |
| 1364 | } |
| 1365 | |
| 1366 | void CXXNamedCastExpr::EmitImpl(Serializer& S) const { |
| 1367 | S.Emit(getType()); |
| 1368 | S.Emit(getTypeAsWritten()); |
| 1369 | S.Emit(Loc); |
| 1370 | S.EmitOwnedPtr(getSubExpr()); |
| 1371 | } |
| 1372 | |
| 1373 | CXXNamedCastExpr * |
| 1374 | CXXNamedCastExpr::CreateImpl(Deserializer& D, ASTContext& C, StmtClass SC) { |
| 1375 | QualType Ty = QualType::ReadVal(D); |
| 1376 | QualType WrittenTy = QualType::ReadVal(D); |
| 1377 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1378 | Expr* SubExpr = D.ReadOwnedPtr<Expr>(C); |
| 1379 | switch (SC) { |
| 1380 | case CXXStaticCastExprClass: |
| 1381 | return new CXXStaticCastExpr(Ty, SubExpr, WrittenTy, Loc); |
| 1382 | case CXXDynamicCastExprClass: |
| 1383 | return new CXXDynamicCastExpr(Ty, SubExpr, WrittenTy, Loc); |
| 1384 | case CXXReinterpretCastExprClass: |
| 1385 | return new CXXReinterpretCastExpr(Ty, SubExpr, WrittenTy, Loc); |
| 1386 | case CXXConstCastExprClass: |
| 1387 | return new CXXConstCastExpr(Ty, SubExpr, WrittenTy, Loc); |
| 1388 | default: |
| 1389 | assert(false && "Unknown cast type!"); |
| 1390 | return 0; |
| 1391 | } |
Argyrios Kyrtzidis | 987a14b | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 1392 | } |
| 1393 | |
Sebastian Redl | c42e118 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 1394 | void CXXTypeidExpr::EmitImpl(llvm::Serializer& S) const { |
| 1395 | S.Emit(getType()); |
Sebastian Redl | d457589 | 2008-12-03 23:17:54 +0000 | [diff] [blame] | 1396 | S.EmitBool(isTypeOperand()); |
Sebastian Redl | c42e118 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 1397 | if (isTypeOperand()) { |
| 1398 | S.Emit(getTypeOperand()); |
| 1399 | } else { |
| 1400 | S.EmitOwnedPtr(getExprOperand()); |
| 1401 | } |
| 1402 | S.Emit(Range); |
| 1403 | } |
| 1404 | |
| 1405 | CXXTypeidExpr* |
| 1406 | CXXTypeidExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 1407 | QualType Ty = QualType::ReadVal(D); |
| 1408 | bool isTypeOp = D.ReadBool(); |
| 1409 | void *Operand; |
| 1410 | if (isTypeOp) { |
| 1411 | Operand = QualType::ReadVal(D).getAsOpaquePtr(); |
| 1412 | } else { |
| 1413 | Operand = D.ReadOwnedPtr<Expr>(C); |
| 1414 | } |
| 1415 | SourceRange Range = SourceRange::ReadVal(D); |
| 1416 | return new CXXTypeidExpr(isTypeOp, Operand, Ty, Range); |
| 1417 | } |
| 1418 | |
Douglas Gregor | 796da18 | 2008-11-04 14:32:21 +0000 | [diff] [blame] | 1419 | void CXXThisExpr::EmitImpl(llvm::Serializer& S) const { |
| 1420 | S.Emit(getType()); |
| 1421 | S.Emit(Loc); |
| 1422 | } |
| 1423 | |
| 1424 | CXXThisExpr* CXXThisExpr::CreateImpl(llvm::Deserializer& D, ASTContext&) { |
| 1425 | QualType Ty = QualType::ReadVal(D); |
| 1426 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1427 | return new CXXThisExpr(Loc, Ty); |
| 1428 | } |
| 1429 | |
Douglas Gregor | 506ae41 | 2009-01-16 18:33:17 +0000 | [diff] [blame] | 1430 | void CXXTemporaryObjectExpr::EmitImpl(llvm::Serializer& S) const { |
| 1431 | S.Emit(getType()); |
| 1432 | S.Emit(TyBeginLoc); |
| 1433 | S.Emit(RParenLoc); |
| 1434 | S.EmitPtr(cast<Decl>(Constructor)); |
| 1435 | S.EmitInt(NumArgs); |
| 1436 | if (NumArgs > 0) |
| 1437 | S.BatchEmitOwnedPtrs(NumArgs, Args); |
| 1438 | } |
| 1439 | |
| 1440 | CXXTemporaryObjectExpr * |
| 1441 | CXXTemporaryObjectExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 1442 | QualType writtenTy = QualType::ReadVal(D); |
| 1443 | SourceLocation tyBeginLoc = SourceLocation::ReadVal(D); |
| 1444 | SourceLocation rParenLoc = SourceLocation::ReadVal(D); |
| 1445 | CXXConstructorDecl * Cons = cast_or_null<CXXConstructorDecl>(D.ReadPtr<Decl>()); |
| 1446 | unsigned NumArgs = D.ReadInt(); |
| 1447 | Stmt** Args = 0; |
| 1448 | if (NumArgs > 0) { |
| 1449 | Args = new Stmt*[NumArgs]; |
| 1450 | D.BatchReadOwnedPtrs(NumArgs, Args, C); |
| 1451 | } |
| 1452 | |
| 1453 | CXXTemporaryObjectExpr * Result |
| 1454 | = new CXXTemporaryObjectExpr(Cons, writtenTy, tyBeginLoc, |
| 1455 | (Expr**)Args, NumArgs, rParenLoc); |
| 1456 | |
| 1457 | if (NumArgs > 0) |
| 1458 | delete [] Args; |
| 1459 | |
| 1460 | return Result; |
| 1461 | } |
| 1462 | |
| 1463 | |
Argyrios Kyrtzidis | 987a14b | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 1464 | void CXXZeroInitValueExpr::EmitImpl(Serializer& S) const { |
| 1465 | S.Emit(getType()); |
| 1466 | S.Emit(TyBeginLoc); |
| 1467 | S.Emit(RParenLoc); |
| 1468 | } |
| 1469 | |
| 1470 | CXXZeroInitValueExpr * |
| 1471 | CXXZeroInitValueExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
| 1472 | QualType Ty = QualType::ReadVal(D); |
| 1473 | SourceLocation TyBeginLoc = SourceLocation::ReadVal(D); |
| 1474 | SourceLocation RParenLoc = SourceLocation::ReadVal(D); |
| 1475 | return new CXXZeroInitValueExpr(Ty, TyBeginLoc, RParenLoc); |
| 1476 | } |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1477 | |
| 1478 | void CXXNewExpr::EmitImpl(Serializer& S) const { |
| 1479 | S.Emit(getType()); |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 1480 | S.EmitBool(GlobalNew); |
| 1481 | S.EmitBool(ParenTypeId); |
| 1482 | S.EmitBool(Initializer); |
| 1483 | S.EmitBool(Array); |
Douglas Gregor | 19ac6ff | 2008-12-01 19:45:16 +0000 | [diff] [blame] | 1484 | S.EmitInt(NumPlacementArgs); |
| 1485 | S.EmitInt(NumConstructorArgs); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1486 | S.BatchEmitOwnedPtrs(NumPlacementArgs + NumConstructorArgs, SubExprs); |
| 1487 | assert((OperatorNew == 0 || S.isRegistered(OperatorNew)) && |
| 1488 | (OperatorDelete == 0 || S.isRegistered(OperatorDelete)) && |
| 1489 | (Constructor == 0 || S.isRegistered(Constructor)) && |
| 1490 | "CXXNewExpr cannot own declarations"); |
| 1491 | S.EmitPtr(OperatorNew); |
| 1492 | S.EmitPtr(OperatorDelete); |
| 1493 | S.EmitPtr(Constructor); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1494 | S.Emit(StartLoc); |
| 1495 | S.Emit(EndLoc); |
| 1496 | } |
| 1497 | |
| 1498 | CXXNewExpr * |
| 1499 | CXXNewExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
| 1500 | QualType T = QualType::ReadVal(D); |
| 1501 | bool GlobalNew = D.ReadBool(); |
| 1502 | bool ParenTypeId = D.ReadBool(); |
| 1503 | bool Initializer = D.ReadBool(); |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 1504 | bool Array = D.ReadBool(); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1505 | unsigned NumPlacementArgs = D.ReadInt(); |
| 1506 | unsigned NumConstructorArgs = D.ReadInt(); |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 1507 | unsigned TotalExprs = Array + NumPlacementArgs + NumConstructorArgs; |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1508 | Stmt** SubExprs = new Stmt*[TotalExprs]; |
| 1509 | D.BatchReadOwnedPtrs(TotalExprs, SubExprs, C); |
| 1510 | FunctionDecl *OperatorNew = D.ReadPtr<FunctionDecl>(); |
| 1511 | FunctionDecl *OperatorDelete = D.ReadPtr<FunctionDecl>(); |
| 1512 | CXXConstructorDecl *Constructor = D.ReadPtr<CXXConstructorDecl>(); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1513 | SourceLocation StartLoc = SourceLocation::ReadVal(D); |
| 1514 | SourceLocation EndLoc = SourceLocation::ReadVal(D); |
| 1515 | |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 1516 | return new CXXNewExpr(T, GlobalNew, ParenTypeId, Initializer, Array, |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1517 | NumPlacementArgs, NumConstructorArgs, SubExprs, |
| 1518 | OperatorNew, OperatorDelete, Constructor, StartLoc, |
| 1519 | EndLoc); |
| 1520 | } |
| 1521 | |
| 1522 | void CXXDeleteExpr::EmitImpl(Serializer& S) const { |
| 1523 | S.Emit(getType()); |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 1524 | S.EmitBool(GlobalDelete); |
| 1525 | S.EmitBool(ArrayForm); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1526 | S.EmitPtr(OperatorDelete); |
| 1527 | S.EmitOwnedPtr(Argument); |
| 1528 | S.Emit(Loc); |
| 1529 | } |
| 1530 | |
| 1531 | CXXDeleteExpr * |
| 1532 | CXXDeleteExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
| 1533 | QualType Ty = QualType::ReadVal(D); |
| 1534 | bool GlobalDelete = D.ReadBool(); |
| 1535 | bool ArrayForm = D.ReadBool(); |
| 1536 | FunctionDecl *OperatorDelete = D.ReadPtr<FunctionDecl>(); |
| 1537 | Stmt *Argument = D.ReadOwnedPtr<Stmt>(C); |
| 1538 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1539 | return new CXXDeleteExpr(Ty, GlobalDelete, ArrayForm, OperatorDelete, |
| 1540 | cast<Expr>(Argument), Loc); |
| 1541 | } |
Douglas Gregor | 5c37de7 | 2008-12-06 00:22:45 +0000 | [diff] [blame] | 1542 | |
Douglas Gregor | 1733001 | 2009-02-04 15:01:18 +0000 | [diff] [blame] | 1543 | void UnresolvedFunctionNameExpr::EmitImpl(llvm::Serializer& S) const { |
Douglas Gregor | 5c37de7 | 2008-12-06 00:22:45 +0000 | [diff] [blame] | 1544 | S.Emit(getType()); |
Douglas Gregor | 1733001 | 2009-02-04 15:01:18 +0000 | [diff] [blame] | 1545 | S.EmitPtr(Name.getAsIdentifierInfo()); // FIXME: WRONG! |
Douglas Gregor | 5c37de7 | 2008-12-06 00:22:45 +0000 | [diff] [blame] | 1546 | S.Emit(Loc); |
| 1547 | } |
| 1548 | |
Douglas Gregor | 1733001 | 2009-02-04 15:01:18 +0000 | [diff] [blame] | 1549 | UnresolvedFunctionNameExpr * |
| 1550 | UnresolvedFunctionNameExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
Douglas Gregor | 5c37de7 | 2008-12-06 00:22:45 +0000 | [diff] [blame] | 1551 | QualType Ty = QualType::ReadVal(D); |
| 1552 | IdentifierInfo *N = D.ReadPtr<IdentifierInfo>(); |
| 1553 | SourceLocation L = SourceLocation::ReadVal(D); |
Douglas Gregor | 1733001 | 2009-02-04 15:01:18 +0000 | [diff] [blame] | 1554 | return new UnresolvedFunctionNameExpr(N, Ty, L); |
Douglas Gregor | 5c37de7 | 2008-12-06 00:22:45 +0000 | [diff] [blame] | 1555 | } |
Sebastian Redl | 4b07b29 | 2008-12-22 19:15:10 +0000 | [diff] [blame] | 1556 | |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 1557 | void UnaryTypeTraitExpr::EmitImpl(llvm::Serializer& S) const { |
| 1558 | S.EmitInt(UTT); |
| 1559 | S.Emit(Loc); |
| 1560 | S.Emit(RParen); |
| 1561 | S.Emit(QueriedType); |
| 1562 | S.Emit(getType()); |
| 1563 | } |
| 1564 | |
| 1565 | UnaryTypeTraitExpr * |
| 1566 | UnaryTypeTraitExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 1567 | UnaryTypeTrait UTT = static_cast<UnaryTypeTrait>(D.ReadInt()); |
| 1568 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1569 | SourceLocation RParen = SourceLocation::ReadVal(D); |
| 1570 | QualType QueriedType = QualType::ReadVal(D); |
| 1571 | QualType Ty = QualType::ReadVal(D); |
| 1572 | return new UnaryTypeTraitExpr(Loc, UTT, QueriedType, RParen, Ty); |
| 1573 | } |
| 1574 | |
Sebastian Redl | 4b07b29 | 2008-12-22 19:15:10 +0000 | [diff] [blame] | 1575 | void CXXCatchStmt::EmitImpl(llvm::Serializer& S) const { |
| 1576 | S.Emit(CatchLoc); |
| 1577 | S.EmitOwnedPtr(ExceptionDecl); |
| 1578 | S.EmitOwnedPtr(HandlerBlock); |
| 1579 | } |
| 1580 | |
| 1581 | CXXCatchStmt * |
| 1582 | CXXCatchStmt::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 1583 | SourceLocation CatchLoc = SourceLocation::ReadVal(D); |
| 1584 | Decl *ExDecl = D.ReadOwnedPtr<Decl>(C); |
| 1585 | Stmt *HandlerBlock = D.ReadOwnedPtr<Stmt>(C); |
| 1586 | return new CXXCatchStmt(CatchLoc, ExDecl, HandlerBlock); |
| 1587 | } |
Sebastian Redl | 8351da0 | 2008-12-22 21:35:02 +0000 | [diff] [blame] | 1588 | |
| 1589 | void CXXTryStmt::EmitImpl(llvm::Serializer& S) const { |
| 1590 | S.Emit(TryLoc); |
| 1591 | S.EmitInt(Stmts.size()); |
| 1592 | S.BatchEmitOwnedPtrs(Stmts.size(), &Stmts[0]); |
| 1593 | } |
| 1594 | |
| 1595 | CXXTryStmt * |
| 1596 | CXXTryStmt::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 1597 | SourceLocation TryLoc = SourceLocation::ReadVal(D); |
| 1598 | unsigned size = D.ReadInt(); |
| 1599 | llvm::SmallVector<Stmt*, 4> Stmts(size); |
| 1600 | D.BatchReadOwnedPtrs<Stmt>(size, &Stmts[0], C); |
| 1601 | |
| 1602 | return new CXXTryStmt(TryLoc, Stmts[0], &Stmts[1], size - 1); |
| 1603 | } |
Douglas Gregor | 1a49af9 | 2009-01-06 05:10:23 +0000 | [diff] [blame] | 1604 | |
| 1605 | void QualifiedDeclRefExpr::EmitImpl(llvm::Serializer& S) const { |
| 1606 | DeclRefExpr::EmitImpl(S); |
| 1607 | S.Emit(NestedNameLoc); |
| 1608 | } |
| 1609 | |
| 1610 | QualifiedDeclRefExpr* |
| 1611 | QualifiedDeclRefExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 1612 | assert(false && "Cannot deserialize qualified decl references"); |
| 1613 | return 0; |
| 1614 | } |