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