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