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