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()); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame^] | 550 | S.EmitPtr(getDecl()); |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 551 | } |
| 552 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 553 | DeclRefExpr* DeclRefExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 554 | SourceLocation Loc = SourceLocation::ReadVal(D); |
Ted Kremenek | 767dd4b | 2007-11-15 18:26:39 +0000 | [diff] [blame] | 555 | QualType T = QualType::ReadVal(D); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame^] | 556 | DeclRefExpr *DRE = new DeclRefExpr(0, T, Loc); |
| 557 | D.ReadPtr(DRE->D); |
| 558 | return DRE; |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 559 | } |
| 560 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 561 | void DefaultStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 562 | S.Emit(DefaultLoc); |
| 563 | S.EmitOwnedPtr(getSubStmt()); |
| 564 | S.EmitPtr(getNextSwitchCase()); |
| 565 | } |
| 566 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 567 | DefaultStmt* DefaultStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 568 | SourceLocation Loc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 569 | Stmt* SubStmt = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 570 | |
| 571 | DefaultStmt* stmt = new DefaultStmt(Loc,SubStmt); |
| 572 | stmt->setNextSwitchCase(D.ReadPtr<SwitchCase>()); |
| 573 | |
| 574 | return stmt; |
| 575 | } |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 576 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 577 | void DoStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | e3299ef | 2007-11-07 07:53:55 +0000 | [diff] [blame] | 578 | S.Emit(DoLoc); |
| 579 | S.EmitOwnedPtr(getCond()); |
| 580 | S.EmitOwnedPtr(getBody()); |
| 581 | } |
| 582 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 583 | DoStmt* DoStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | e3299ef | 2007-11-07 07:53:55 +0000 | [diff] [blame] | 584 | SourceLocation DoLoc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 585 | Expr* Cond = D.ReadOwnedPtr<Expr>(C); |
| 586 | Stmt* Body = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | e3299ef | 2007-11-07 07:53:55 +0000 | [diff] [blame] | 587 | return new DoStmt(Body,Cond,DoLoc); |
| 588 | } |
| 589 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 590 | void FloatingLiteral::EmitImpl(Serializer& S) const { |
Ted Kremenek | 612c9b9 | 2007-11-07 18:45:55 +0000 | [diff] [blame] | 591 | S.Emit(Loc); |
| 592 | S.Emit(getType()); |
Ted Kremenek | 720c4ec | 2007-11-29 00:56:49 +0000 | [diff] [blame] | 593 | S.EmitBool(isExact()); |
Ted Kremenek | 612c9b9 | 2007-11-07 18:45:55 +0000 | [diff] [blame] | 594 | S.Emit(Value); |
| 595 | } |
| 596 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 597 | FloatingLiteral* FloatingLiteral::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 612c9b9 | 2007-11-07 18:45:55 +0000 | [diff] [blame] | 598 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 599 | QualType t = QualType::ReadVal(D); |
Ted Kremenek | 720c4ec | 2007-11-29 00:56:49 +0000 | [diff] [blame] | 600 | bool isExact = D.ReadBool(); |
Ted Kremenek | 612c9b9 | 2007-11-07 18:45:55 +0000 | [diff] [blame] | 601 | llvm::APFloat Val = llvm::APFloat::ReadVal(D); |
Ted Kremenek | 720c4ec | 2007-11-29 00:56:49 +0000 | [diff] [blame] | 602 | FloatingLiteral* expr = new FloatingLiteral(Val,&isExact,t,Loc); |
Ted Kremenek | 612c9b9 | 2007-11-07 18:45:55 +0000 | [diff] [blame] | 603 | return expr; |
| 604 | } |
| 605 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 606 | void ForStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 07ba046 | 2007-11-07 08:02:55 +0000 | [diff] [blame] | 607 | S.Emit(ForLoc); |
| 608 | S.EmitOwnedPtr(getInit()); |
| 609 | S.EmitOwnedPtr(getCond()); |
| 610 | S.EmitOwnedPtr(getInc()); |
| 611 | S.EmitOwnedPtr(getBody()); |
| 612 | } |
| 613 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 614 | ForStmt* ForStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 07ba046 | 2007-11-07 08:02:55 +0000 | [diff] [blame] | 615 | SourceLocation ForLoc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 616 | Stmt* Init = D.ReadOwnedPtr<Stmt>(C); |
| 617 | Expr* Cond = D.ReadOwnedPtr<Expr>(C); |
| 618 | Expr* Inc = D.ReadOwnedPtr<Expr>(C); |
| 619 | Stmt* Body = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | 07ba046 | 2007-11-07 08:02:55 +0000 | [diff] [blame] | 620 | return new ForStmt(Init,Cond,Inc,Body,ForLoc); |
| 621 | } |
| 622 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 623 | void GotoStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 3f0767b | 2007-11-07 08:07:46 +0000 | [diff] [blame] | 624 | S.Emit(GotoLoc); |
| 625 | S.Emit(LabelLoc); |
| 626 | S.EmitPtr(Label); |
| 627 | } |
| 628 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 629 | GotoStmt* GotoStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 3f0767b | 2007-11-07 08:07:46 +0000 | [diff] [blame] | 630 | SourceLocation GotoLoc = SourceLocation::ReadVal(D); |
| 631 | SourceLocation LabelLoc = SourceLocation::ReadVal(D); |
| 632 | GotoStmt* stmt = new GotoStmt(NULL,GotoLoc,LabelLoc); |
| 633 | D.ReadPtr(stmt->Label); // This pointer may be backpatched later. |
| 634 | return stmt; |
| 635 | } |
| 636 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 637 | void IfStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 4210f3d | 2007-11-07 07:19:30 +0000 | [diff] [blame] | 638 | S.Emit(IfLoc); |
| 639 | S.EmitOwnedPtr(getCond()); |
| 640 | S.EmitOwnedPtr(getThen()); |
| 641 | S.EmitOwnedPtr(getElse()); |
| 642 | } |
| 643 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 644 | IfStmt* IfStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 4210f3d | 2007-11-07 07:19:30 +0000 | [diff] [blame] | 645 | SourceLocation L = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 646 | Expr* Cond = D.ReadOwnedPtr<Expr>(C); |
| 647 | Stmt* Then = D.ReadOwnedPtr<Stmt>(C); |
| 648 | Stmt* Else = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | 4210f3d | 2007-11-07 07:19:30 +0000 | [diff] [blame] | 649 | return new IfStmt(L,Cond,Then,Else); |
| 650 | } |
| 651 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 652 | void ImaginaryLiteral::EmitImpl(Serializer& S) const { |
Ted Kremenek | 1c72de1 | 2007-11-07 18:53:02 +0000 | [diff] [blame] | 653 | S.Emit(getType()); |
| 654 | S.EmitOwnedPtr(Val); |
| 655 | } |
| 656 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 657 | ImaginaryLiteral* ImaginaryLiteral::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 1c72de1 | 2007-11-07 18:53:02 +0000 | [diff] [blame] | 658 | QualType t = QualType::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 659 | Expr* expr = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | 1c72de1 | 2007-11-07 18:53:02 +0000 | [diff] [blame] | 660 | assert (isa<FloatingLiteral>(expr) || isa<IntegerLiteral>(expr)); |
| 661 | return new ImaginaryLiteral(expr,t); |
| 662 | } |
| 663 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 664 | void ImplicitCastExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | a7c20dd | 2007-11-07 22:39:17 +0000 | [diff] [blame] | 665 | S.Emit(getType()); |
Argyrios Kyrtzidis | 0835a3c | 2008-08-18 23:01:59 +0000 | [diff] [blame] | 666 | S.EmitOwnedPtr(getSubExpr()); |
Douglas Gregor | eb8f306 | 2008-11-12 17:17:38 +0000 | [diff] [blame] | 667 | S.Emit(LvalueCast); |
Ted Kremenek | a7c20dd | 2007-11-07 22:39:17 +0000 | [diff] [blame] | 668 | } |
| 669 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 670 | ImplicitCastExpr* ImplicitCastExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | a7c20dd | 2007-11-07 22:39:17 +0000 | [diff] [blame] | 671 | QualType t = QualType::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 672 | Expr* Op = D.ReadOwnedPtr<Expr>(C); |
Douglas Gregor | eb8f306 | 2008-11-12 17:17:38 +0000 | [diff] [blame] | 673 | bool isLvalue = D.ReadBool(); |
| 674 | return new ImplicitCastExpr(t,Op,isLvalue); |
Ted Kremenek | a7c20dd | 2007-11-07 22:39:17 +0000 | [diff] [blame] | 675 | } |
| 676 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 677 | void IndirectGotoStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 678 | S.EmitOwnedPtr(Target); |
Ted Kremenek | 225a2d9 | 2007-11-07 17:02:32 +0000 | [diff] [blame] | 679 | } |
| 680 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 681 | IndirectGotoStmt* IndirectGotoStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
| 682 | Expr* Target = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 683 | return new IndirectGotoStmt(Target); |
Ted Kremenek | 225a2d9 | 2007-11-07 17:02:32 +0000 | [diff] [blame] | 684 | } |
| 685 | |
Ted Kremenek | 6336f8d | 2007-11-14 21:31:46 +0000 | [diff] [blame] | 686 | void InitListExpr::EmitImpl(Serializer& S) const { |
| 687 | S.Emit(LBraceLoc); |
| 688 | S.Emit(RBraceLoc); |
Steve Naroff | c5ae899 | 2008-05-01 02:04:18 +0000 | [diff] [blame] | 689 | S.EmitInt(InitExprs.size()); |
| 690 | if (!InitExprs.empty()) S.BatchEmitOwnedPtrs(InitExprs.size(), &InitExprs[0]); |
Ted Kremenek | 6336f8d | 2007-11-14 21:31:46 +0000 | [diff] [blame] | 691 | } |
| 692 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 693 | InitListExpr* InitListExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 6336f8d | 2007-11-14 21:31:46 +0000 | [diff] [blame] | 694 | InitListExpr* expr = new InitListExpr(); |
| 695 | expr->LBraceLoc = SourceLocation::ReadVal(D); |
| 696 | expr->RBraceLoc = SourceLocation::ReadVal(D); |
Steve Naroff | c5ae899 | 2008-05-01 02:04:18 +0000 | [diff] [blame] | 697 | unsigned size = D.ReadInt(); |
| 698 | assert(size); |
| 699 | expr->InitExprs.reserve(size); |
| 700 | for (unsigned i = 0 ; i < size; ++i) expr->InitExprs.push_back(0); |
| 701 | |
| 702 | D.BatchReadOwnedPtrs(size, &expr->InitExprs[0], C); |
Ted Kremenek | 6336f8d | 2007-11-14 21:31:46 +0000 | [diff] [blame] | 703 | return expr; |
| 704 | } |
| 705 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 706 | void IntegerLiteral::EmitImpl(Serializer& S) const { |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 707 | S.Emit(Loc); |
| 708 | S.Emit(getType()); |
| 709 | S.Emit(getValue()); |
| 710 | } |
| 711 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 712 | IntegerLiteral* IntegerLiteral::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 2dc9ac7 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 713 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 714 | QualType T = QualType::ReadVal(D); |
| 715 | |
| 716 | // Create a dummy APInt because it is more efficient to deserialize |
| 717 | // it in place with the deserialized IntegerLiteral. (fewer copies) |
| 718 | llvm::APInt temp; |
| 719 | IntegerLiteral* expr = new IntegerLiteral(temp,T,Loc); |
| 720 | D.Read(expr->Value); |
| 721 | |
| 722 | return expr; |
| 723 | } |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 724 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 725 | void LabelStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | b15132f | 2007-11-07 00:48:04 +0000 | [diff] [blame] | 726 | S.EmitPtr(Label); |
| 727 | S.Emit(IdentLoc); |
| 728 | S.EmitOwnedPtr(SubStmt); |
| 729 | } |
| 730 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 731 | LabelStmt* LabelStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | b15132f | 2007-11-07 00:48:04 +0000 | [diff] [blame] | 732 | IdentifierInfo* Label = D.ReadPtr<IdentifierInfo>(); |
| 733 | SourceLocation IdentLoc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 734 | Stmt* SubStmt = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | b15132f | 2007-11-07 00:48:04 +0000 | [diff] [blame] | 735 | return new LabelStmt(IdentLoc,Label,SubStmt); |
| 736 | } |
| 737 | |
Ted Kremenek | bd57e7c | 2007-11-13 22:16:23 +0000 | [diff] [blame] | 738 | void MemberExpr::EmitImpl(Serializer& S) const { |
| 739 | S.Emit(MemberLoc); |
| 740 | S.EmitPtr(MemberDecl); |
| 741 | S.EmitBool(IsArrow); |
Eli Friedman | 5101907 | 2008-02-06 22:48:16 +0000 | [diff] [blame] | 742 | S.Emit(getType()); |
Ted Kremenek | d073987 | 2008-02-06 23:03:14 +0000 | [diff] [blame] | 743 | S.EmitOwnedPtr(Base); |
Ted Kremenek | bd57e7c | 2007-11-13 22:16:23 +0000 | [diff] [blame] | 744 | } |
| 745 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 746 | MemberExpr* MemberExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | bd57e7c | 2007-11-13 22:16:23 +0000 | [diff] [blame] | 747 | SourceLocation L = SourceLocation::ReadVal(D); |
Douglas Gregor | 86f1940 | 2008-12-20 23:49:58 +0000 | [diff] [blame] | 748 | NamedDecl* MemberDecl = cast<NamedDecl>(D.ReadPtr<Decl>()); |
Ted Kremenek | bd57e7c | 2007-11-13 22:16:23 +0000 | [diff] [blame] | 749 | bool IsArrow = D.ReadBool(); |
Eli Friedman | 5101907 | 2008-02-06 22:48:16 +0000 | [diff] [blame] | 750 | QualType T = QualType::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 751 | Expr* base = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | bd57e7c | 2007-11-13 22:16:23 +0000 | [diff] [blame] | 752 | |
Eli Friedman | 5101907 | 2008-02-06 22:48:16 +0000 | [diff] [blame] | 753 | return new MemberExpr(base,IsArrow,MemberDecl,L,T); |
Ted Kremenek | bd57e7c | 2007-11-13 22:16:23 +0000 | [diff] [blame] | 754 | } |
| 755 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 756 | void NullStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 4927be6 | 2007-11-07 00:40:53 +0000 | [diff] [blame] | 757 | S.Emit(SemiLoc); |
| 758 | } |
| 759 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 760 | NullStmt* NullStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 4927be6 | 2007-11-07 00:40:53 +0000 | [diff] [blame] | 761 | SourceLocation SemiLoc = SourceLocation::ReadVal(D); |
| 762 | return new NullStmt(SemiLoc); |
| 763 | } |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 764 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 765 | void ParenExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 766 | S.Emit(L); |
| 767 | S.Emit(R); |
| 768 | S.EmitOwnedPtr(Val); |
| 769 | } |
| 770 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 771 | ParenExpr* ParenExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 772 | SourceLocation L = SourceLocation::ReadVal(D); |
| 773 | SourceLocation R = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 774 | Expr* val = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 775 | return new ParenExpr(L,R,val); |
Ted Kremenek | 1ba485e | 2007-11-07 17:11:58 +0000 | [diff] [blame] | 776 | } |
| 777 | |
Chris Lattner | d9f6910 | 2008-08-10 01:53:14 +0000 | [diff] [blame] | 778 | void PredefinedExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | 1ba485e | 2007-11-07 17:11:58 +0000 | [diff] [blame] | 779 | S.Emit(Loc); |
| 780 | S.EmitInt(getIdentType()); |
| 781 | S.Emit(getType()); |
| 782 | } |
| 783 | |
Chris Lattner | d9f6910 | 2008-08-10 01:53:14 +0000 | [diff] [blame] | 784 | PredefinedExpr* PredefinedExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 1ba485e | 2007-11-07 17:11:58 +0000 | [diff] [blame] | 785 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 786 | IdentType it = static_cast<IdentType>(D.ReadInt()); |
| 787 | QualType Q = QualType::ReadVal(D); |
Chris Lattner | d9f6910 | 2008-08-10 01:53:14 +0000 | [diff] [blame] | 788 | return new PredefinedExpr(Loc,Q,it); |
Ted Kremenek | 1ba485e | 2007-11-07 17:11:58 +0000 | [diff] [blame] | 789 | } |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 790 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 791 | void ReturnStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 792 | S.Emit(RetLoc); |
| 793 | S.EmitOwnedPtr(RetExpr); |
| 794 | } |
| 795 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 796 | ReturnStmt* ReturnStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 797 | SourceLocation RetLoc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 798 | Expr* RetExpr = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | 0965f44 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 799 | return new ReturnStmt(RetLoc,RetExpr); |
| 800 | } |
| 801 | |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 802 | void SizeOfAlignOfExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | ea2fe9b | 2007-11-13 22:30:29 +0000 | [diff] [blame] | 803 | S.EmitBool(isSizeof); |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 804 | S.EmitBool(isType); |
| 805 | if (isType) |
| 806 | S.Emit(getArgumentType()); |
| 807 | else |
| 808 | S.EmitOwnedPtr(getArgumentExpr()); |
Ted Kremenek | ea2fe9b | 2007-11-13 22:30:29 +0000 | [diff] [blame] | 809 | S.Emit(getType()); |
| 810 | S.Emit(OpLoc); |
| 811 | S.Emit(RParenLoc); |
| 812 | } |
| 813 | |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 814 | SizeOfAlignOfExpr* |
| 815 | SizeOfAlignOfExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | ea2fe9b | 2007-11-13 22:30:29 +0000 | [diff] [blame] | 816 | bool isSizeof = D.ReadBool(); |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 817 | bool isType = D.ReadBool(); |
| 818 | void *Argument; |
| 819 | if (isType) |
| 820 | Argument = QualType::ReadVal(D).getAsOpaquePtr(); |
| 821 | else |
| 822 | Argument = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | ea2fe9b | 2007-11-13 22:30:29 +0000 | [diff] [blame] | 823 | QualType Res = QualType::ReadVal(D); |
| 824 | SourceLocation OpLoc = SourceLocation::ReadVal(D); |
| 825 | SourceLocation RParenLoc = SourceLocation::ReadVal(D); |
| 826 | |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 827 | return new SizeOfAlignOfExpr(isSizeof, isType, Argument, Res, |
| 828 | OpLoc, RParenLoc); |
Ted Kremenek | ea2fe9b | 2007-11-13 22:30:29 +0000 | [diff] [blame] | 829 | } |
| 830 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 831 | void StmtExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 832 | S.Emit(getType()); |
| 833 | S.Emit(LParenLoc); |
| 834 | S.Emit(RParenLoc); |
| 835 | S.EmitOwnedPtr(SubStmt); |
| 836 | } |
| 837 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 838 | StmtExpr* StmtExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 839 | QualType t = QualType::ReadVal(D); |
| 840 | SourceLocation L = SourceLocation::ReadVal(D); |
| 841 | SourceLocation R = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 842 | CompoundStmt* SubStmt = cast<CompoundStmt>(D.ReadOwnedPtr<Stmt>(C)); |
Ted Kremenek | aa33763 | 2007-11-08 16:32:00 +0000 | [diff] [blame] | 843 | return new StmtExpr(SubStmt,t,L,R); |
| 844 | } |
| 845 | |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 846 | void TypesCompatibleExpr::EmitImpl(llvm::Serializer& S) const { |
| 847 | S.Emit(getType()); |
| 848 | S.Emit(BuiltinLoc); |
| 849 | S.Emit(RParenLoc); |
| 850 | S.Emit(Type1); |
| 851 | S.Emit(Type2); |
| 852 | } |
| 853 | |
| 854 | TypesCompatibleExpr* TypesCompatibleExpr::CreateImpl(llvm::Deserializer& D, |
| 855 | ASTContext& C) { |
| 856 | QualType RT = QualType::ReadVal(D); |
| 857 | SourceLocation BL = SourceLocation::ReadVal(D); |
| 858 | SourceLocation RP = SourceLocation::ReadVal(D); |
| 859 | QualType T1 = QualType::ReadVal(D); |
| 860 | QualType T2 = QualType::ReadVal(D); |
| 861 | return new TypesCompatibleExpr(RT, BL, T1, T2, RP); |
| 862 | } |
| 863 | |
| 864 | void ShuffleVectorExpr::EmitImpl(llvm::Serializer& S) const { |
| 865 | S.Emit(getType()); |
| 866 | S.Emit(BuiltinLoc); |
| 867 | S.Emit(RParenLoc); |
| 868 | S.EmitInt(NumExprs); |
Daniel Dunbar | 20c77e9 | 2008-10-15 17:52:29 +0000 | [diff] [blame] | 869 | S.BatchEmitOwnedPtrs(NumExprs, &SubExprs[0]); |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 870 | } |
| 871 | |
| 872 | ShuffleVectorExpr* ShuffleVectorExpr::CreateImpl(llvm::Deserializer& D, |
| 873 | ASTContext& C) { |
| 874 | QualType T = QualType::ReadVal(D); |
| 875 | SourceLocation BL = SourceLocation::ReadVal(D); |
| 876 | SourceLocation RP = SourceLocation::ReadVal(D); |
| 877 | unsigned NumExprs = D.ReadInt(); |
Daniel Dunbar | 20c77e9 | 2008-10-15 17:52:29 +0000 | [diff] [blame] | 878 | // FIXME: Avoid extra allocation. |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 879 | llvm::SmallVector<Expr*, 4> Exprs(NumExprs); |
Daniel Dunbar | 20c77e9 | 2008-10-15 17:52:29 +0000 | [diff] [blame] | 880 | D.BatchReadOwnedPtrs(NumExprs, Exprs.begin(), C); |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 881 | return new ShuffleVectorExpr(Exprs.begin(), NumExprs, T, BL, RP); |
| 882 | } |
| 883 | |
| 884 | void ChooseExpr::EmitImpl(llvm::Serializer& S) const { |
| 885 | S.Emit(getType()); |
| 886 | S.Emit(BuiltinLoc); |
| 887 | S.Emit(RParenLoc); |
Daniel Dunbar | 20c77e9 | 2008-10-15 17:52:29 +0000 | [diff] [blame] | 888 | S.BatchEmitOwnedPtrs((unsigned) END_EXPR, &SubExprs[0]); |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 889 | } |
| 890 | |
| 891 | ChooseExpr* ChooseExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 892 | QualType T = QualType::ReadVal(D); |
| 893 | SourceLocation BL = SourceLocation::ReadVal(D); |
| 894 | SourceLocation RP = SourceLocation::ReadVal(D); |
Daniel Dunbar | 20c77e9 | 2008-10-15 17:52:29 +0000 | [diff] [blame] | 895 | ChooseExpr *CE = new ChooseExpr(BL, 0, 0, 0, T, RP); |
| 896 | D.BatchReadOwnedPtrs((unsigned) END_EXPR, &CE->SubExprs[0], C); |
| 897 | return CE; |
| 898 | } |
| 899 | |
Douglas Gregor | 2d8b273 | 2008-11-29 04:51:27 +0000 | [diff] [blame] | 900 | void GNUNullExpr::EmitImpl(llvm::Serializer &S) const { |
| 901 | S.Emit(getType()); |
| 902 | S.Emit(TokenLoc); |
| 903 | } |
| 904 | |
| 905 | GNUNullExpr *GNUNullExpr::CreateImpl(llvm::Deserializer &D, ASTContext &C) { |
| 906 | QualType T = QualType::ReadVal(D); |
| 907 | SourceLocation TL = SourceLocation::ReadVal(D); |
| 908 | return new GNUNullExpr(T, TL); |
| 909 | } |
| 910 | |
Daniel Dunbar | 20c77e9 | 2008-10-15 17:52:29 +0000 | [diff] [blame] | 911 | void OverloadExpr::EmitImpl(llvm::Serializer& S) const { |
| 912 | S.Emit(getType()); |
| 913 | S.Emit(BuiltinLoc); |
| 914 | S.Emit(RParenLoc); |
| 915 | S.EmitInt(FnIndex); |
| 916 | S.EmitInt(NumExprs); |
| 917 | S.BatchEmitOwnedPtrs(NumExprs, &SubExprs[0]); |
| 918 | } |
| 919 | |
| 920 | OverloadExpr* OverloadExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 921 | QualType T = QualType::ReadVal(D); |
| 922 | SourceLocation BL = SourceLocation::ReadVal(D); |
| 923 | SourceLocation RP = SourceLocation::ReadVal(D); |
| 924 | unsigned FnIndex = D.ReadInt(); |
| 925 | unsigned NumExprs = D.ReadInt(); |
| 926 | // FIXME: Avoid extra allocation. |
| 927 | llvm::SmallVector<Expr*, 4> Exprs(NumExprs); |
| 928 | D.BatchReadOwnedPtrs(NumExprs, Exprs.begin(), C); |
| 929 | return new OverloadExpr(Exprs.begin(), NumExprs, FnIndex, T, BL, RP); |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 930 | } |
| 931 | |
| 932 | void VAArgExpr::EmitImpl(llvm::Serializer& S) const { |
| 933 | S.Emit(getType()); |
| 934 | S.Emit(BuiltinLoc); |
| 935 | S.Emit(RParenLoc); |
| 936 | S.EmitOwnedPtr(getSubExpr()); |
| 937 | } |
| 938 | |
| 939 | VAArgExpr* VAArgExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 940 | QualType T = QualType::ReadVal(D); |
| 941 | SourceLocation BL = SourceLocation::ReadVal(D); |
| 942 | SourceLocation RP = SourceLocation::ReadVal(D); |
| 943 | Expr *E = D.ReadOwnedPtr<Expr>(C); |
| 944 | return new VAArgExpr(BL, E, T, RP); |
| 945 | } |
| 946 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 947 | void StringLiteral::EmitImpl(Serializer& S) const { |
Ted Kremenek | 7febad7 | 2007-11-07 19:08:19 +0000 | [diff] [blame] | 948 | S.Emit(getType()); |
| 949 | S.Emit(firstTokLoc); |
| 950 | S.Emit(lastTokLoc); |
| 951 | S.EmitBool(isWide()); |
| 952 | S.Emit(getByteLength()); |
| 953 | |
| 954 | for (unsigned i = 0 ; i < ByteLength; ++i) |
| 955 | S.EmitInt(StrData[i]); |
| 956 | } |
| 957 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 958 | StringLiteral* StringLiteral::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 7febad7 | 2007-11-07 19:08:19 +0000 | [diff] [blame] | 959 | QualType t = QualType::ReadVal(D); |
| 960 | SourceLocation firstTokLoc = SourceLocation::ReadVal(D); |
| 961 | SourceLocation lastTokLoc = SourceLocation::ReadVal(D); |
| 962 | bool isWide = D.ReadBool(); |
| 963 | unsigned ByteLength = D.ReadInt(); |
| 964 | |
| 965 | StringLiteral* sl = new StringLiteral(NULL,0,isWide,t,firstTokLoc,lastTokLoc); |
| 966 | |
| 967 | char* StrData = new char[ByteLength]; |
| 968 | for (unsigned i = 0; i < ByteLength; ++i) |
| 969 | StrData[i] = (char) D.ReadInt(); |
| 970 | |
| 971 | sl->ByteLength = ByteLength; |
| 972 | sl->StrData = StrData; |
| 973 | |
| 974 | return sl; |
| 975 | } |
| 976 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 977 | void SwitchStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 978 | S.Emit(SwitchLoc); |
| 979 | S.EmitOwnedPtr(getCond()); |
| 980 | S.EmitOwnedPtr(getBody()); |
| 981 | S.EmitPtr(FirstCase); |
| 982 | } |
| 983 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 984 | SwitchStmt* SwitchStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 985 | SourceLocation Loc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 986 | Stmt* Cond = D.ReadOwnedPtr<Stmt>(C); |
| 987 | Stmt* Body = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | 9eea2ca | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 988 | SwitchCase* FirstCase = cast<SwitchCase>(D.ReadPtr<Stmt>()); |
| 989 | |
| 990 | SwitchStmt* stmt = new SwitchStmt(cast<Expr>(Cond)); |
| 991 | stmt->setBody(Body,Loc); |
| 992 | stmt->FirstCase = FirstCase; |
| 993 | |
| 994 | return stmt; |
| 995 | } |
Ted Kremenek | 5572b94 | 2007-11-07 07:50:10 +0000 | [diff] [blame] | 996 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 997 | void UnaryOperator::EmitImpl(Serializer& S) const { |
Ted Kremenek | 1049436 | 2007-11-08 00:26:24 +0000 | [diff] [blame] | 998 | S.Emit(getType()); |
| 999 | S.Emit(Loc); |
| 1000 | S.EmitInt(Opc); |
| 1001 | S.EmitOwnedPtr(Val); |
| 1002 | } |
| 1003 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1004 | UnaryOperator* UnaryOperator::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 1049436 | 2007-11-08 00:26:24 +0000 | [diff] [blame] | 1005 | QualType t = QualType::ReadVal(D); |
| 1006 | SourceLocation L = SourceLocation::ReadVal(D); |
| 1007 | Opcode Opc = static_cast<Opcode>(D.ReadInt()); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1008 | Expr* Val = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | 1049436 | 2007-11-08 00:26:24 +0000 | [diff] [blame] | 1009 | return new UnaryOperator(Val,Opc,t,L); |
| 1010 | } |
| 1011 | |
Ted Kremenek | ec0aa78 | 2007-11-12 18:04:32 +0000 | [diff] [blame] | 1012 | void WhileStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 5572b94 | 2007-11-07 07:50:10 +0000 | [diff] [blame] | 1013 | S.Emit(WhileLoc); |
| 1014 | S.EmitOwnedPtr(getCond()); |
| 1015 | S.EmitOwnedPtr(getBody()); |
| 1016 | } |
| 1017 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1018 | WhileStmt* WhileStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 5572b94 | 2007-11-07 07:50:10 +0000 | [diff] [blame] | 1019 | SourceLocation WhileLoc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1020 | Expr* Cond = D.ReadOwnedPtr<Expr>(C); |
| 1021 | Stmt* Body = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | 5572b94 | 2007-11-07 07:50:10 +0000 | [diff] [blame] | 1022 | return new WhileStmt(Cond,Body,WhileLoc); |
| 1023 | } |
Ted Kremenek | 378c151 | 2007-11-15 18:10:29 +0000 | [diff] [blame] | 1024 | |
| 1025 | //===----------------------------------------------------------------------===// |
| 1026 | // Objective C Serialization |
| 1027 | //===----------------------------------------------------------------------===// |
| 1028 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1029 | void ObjCAtCatchStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | af52677 | 2007-12-04 00:28:54 +0000 | [diff] [blame] | 1030 | S.Emit(AtCatchLoc); |
| 1031 | S.Emit(RParenLoc); |
Ted Kremenek | ff98102 | 2008-02-01 21:28:59 +0000 | [diff] [blame] | 1032 | S.BatchEmitOwnedPtrs((unsigned) END_EXPR, &SubExprs[0]); |
Ted Kremenek | af52677 | 2007-12-04 00:28:54 +0000 | [diff] [blame] | 1033 | } |
| 1034 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1035 | ObjCAtCatchStmt* ObjCAtCatchStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | af52677 | 2007-12-04 00:28:54 +0000 | [diff] [blame] | 1036 | SourceLocation AtCatchLoc = SourceLocation::ReadVal(D); |
| 1037 | SourceLocation RParenLoc = SourceLocation::ReadVal(D); |
| 1038 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1039 | ObjCAtCatchStmt* stmt = new ObjCAtCatchStmt(AtCatchLoc,RParenLoc); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1040 | D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubExprs[0], C); |
Ted Kremenek | af52677 | 2007-12-04 00:28:54 +0000 | [diff] [blame] | 1041 | |
| 1042 | return stmt; |
| 1043 | } |
| 1044 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1045 | void ObjCAtFinallyStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 04be5aa | 2007-12-04 00:32:22 +0000 | [diff] [blame] | 1046 | S.Emit(AtFinallyLoc); |
| 1047 | S.EmitOwnedPtr(AtFinallyStmt); |
| 1048 | } |
| 1049 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1050 | ObjCAtFinallyStmt* ObjCAtFinallyStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 04be5aa | 2007-12-04 00:32:22 +0000 | [diff] [blame] | 1051 | SourceLocation Loc = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1052 | Stmt* AtFinallyStmt = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1053 | return new ObjCAtFinallyStmt(Loc,AtFinallyStmt); |
Ted Kremenek | 04be5aa | 2007-12-04 00:32:22 +0000 | [diff] [blame] | 1054 | } |
| 1055 | |
Ted Kremenek | b7e6bd7 | 2008-01-29 21:21:30 +0000 | [diff] [blame] | 1056 | void ObjCAtSynchronizedStmt::EmitImpl(Serializer& S) const { |
| 1057 | S.Emit(AtSynchronizedLoc); |
Fariborz Jahanian | a0f5579 | 2008-01-29 22:59:37 +0000 | [diff] [blame] | 1058 | S.BatchEmitOwnedPtrs((unsigned) END_EXPR,&SubStmts[0]); |
| 1059 | } |
Ted Kremenek | b7e6bd7 | 2008-01-29 21:21:30 +0000 | [diff] [blame] | 1060 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1061 | ObjCAtSynchronizedStmt* ObjCAtSynchronizedStmt::CreateImpl(Deserializer& D, |
| 1062 | ASTContext& C) { |
| 1063 | |
Ted Kremenek | b7e6bd7 | 2008-01-29 21:21:30 +0000 | [diff] [blame] | 1064 | SourceLocation L = SourceLocation::ReadVal(D); |
Fariborz Jahanian | a0f5579 | 2008-01-29 22:59:37 +0000 | [diff] [blame] | 1065 | ObjCAtSynchronizedStmt* stmt = new ObjCAtSynchronizedStmt(L,0,0); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1066 | D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubStmts[0], C); |
Ted Kremenek | b7e6bd7 | 2008-01-29 21:21:30 +0000 | [diff] [blame] | 1067 | return stmt; |
| 1068 | } |
| 1069 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1070 | void ObjCAtThrowStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 5bdd4e3 | 2007-12-04 00:40:49 +0000 | [diff] [blame] | 1071 | S.Emit(AtThrowLoc); |
| 1072 | S.EmitOwnedPtr(Throw); |
| 1073 | } |
| 1074 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1075 | ObjCAtThrowStmt* ObjCAtThrowStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 5bdd4e3 | 2007-12-04 00:40:49 +0000 | [diff] [blame] | 1076 | SourceLocation L = SourceLocation::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1077 | Stmt* Throw = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1078 | return new ObjCAtThrowStmt(L,Throw); |
Ted Kremenek | 5bdd4e3 | 2007-12-04 00:40:49 +0000 | [diff] [blame] | 1079 | } |
| 1080 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1081 | void ObjCAtTryStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | 9c1efff | 2007-12-04 00:38:30 +0000 | [diff] [blame] | 1082 | S.Emit(AtTryLoc); |
| 1083 | S.BatchEmitOwnedPtrs((unsigned) END_EXPR, &SubStmts[0]); |
| 1084 | } |
| 1085 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1086 | ObjCAtTryStmt* ObjCAtTryStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 9c1efff | 2007-12-04 00:38:30 +0000 | [diff] [blame] | 1087 | SourceLocation L = SourceLocation::ReadVal(D); |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1088 | ObjCAtTryStmt* stmt = new ObjCAtTryStmt(L,NULL,NULL,NULL); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1089 | D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubStmts[0], C); |
Ted Kremenek | 9c1efff | 2007-12-04 00:38:30 +0000 | [diff] [blame] | 1090 | return stmt; |
| 1091 | } |
| 1092 | |
Ted Kremenek | 8f6dc77 | 2007-12-05 00:43:08 +0000 | [diff] [blame] | 1093 | void ObjCEncodeExpr::EmitImpl(Serializer& S) const { |
| 1094 | S.Emit(AtLoc); |
| 1095 | S.Emit(RParenLoc); |
| 1096 | S.Emit(getType()); |
| 1097 | S.Emit(EncType); |
| 1098 | } |
| 1099 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1100 | ObjCEncodeExpr* ObjCEncodeExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 8f6dc77 | 2007-12-05 00:43:08 +0000 | [diff] [blame] | 1101 | SourceLocation AtLoc = SourceLocation::ReadVal(D); |
| 1102 | SourceLocation RParenLoc = SourceLocation::ReadVal(D); |
| 1103 | QualType T = QualType::ReadVal(D); |
| 1104 | QualType ET = QualType::ReadVal(D); |
| 1105 | return new ObjCEncodeExpr(T,ET,AtLoc,RParenLoc); |
| 1106 | } |
| 1107 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1108 | void ObjCForCollectionStmt::EmitImpl(Serializer& S) const { |
Ted Kremenek | c3b59d3 | 2008-01-05 00:57:49 +0000 | [diff] [blame] | 1109 | S.Emit(ForLoc); |
Fariborz Jahanian | 7571228 | 2008-01-10 00:24:29 +0000 | [diff] [blame] | 1110 | S.Emit(RParenLoc); |
Ted Kremenek | 205712a | 2008-01-07 18:35:04 +0000 | [diff] [blame] | 1111 | S.BatchEmitOwnedPtrs(getElement(),getCollection(),getBody()); |
Ted Kremenek | c3b59d3 | 2008-01-05 00:57:49 +0000 | [diff] [blame] | 1112 | } |
| 1113 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1114 | ObjCForCollectionStmt* ObjCForCollectionStmt::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | c3b59d3 | 2008-01-05 00:57:49 +0000 | [diff] [blame] | 1115 | SourceLocation ForLoc = SourceLocation::ReadVal(D); |
Fariborz Jahanian | 7571228 | 2008-01-10 00:24:29 +0000 | [diff] [blame] | 1116 | SourceLocation RParenLoc = SourceLocation::ReadVal(D); |
Ted Kremenek | 205712a | 2008-01-07 18:35:04 +0000 | [diff] [blame] | 1117 | Stmt* Element; |
| 1118 | Expr* Collection; |
| 1119 | Stmt* Body; |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1120 | D.BatchReadOwnedPtrs(Element, Collection, Body, C); |
Fariborz Jahanian | 7571228 | 2008-01-10 00:24:29 +0000 | [diff] [blame] | 1121 | return new ObjCForCollectionStmt(Element,Collection,Body,ForLoc, RParenLoc); |
Ted Kremenek | c3b59d3 | 2008-01-05 00:57:49 +0000 | [diff] [blame] | 1122 | } |
| 1123 | |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 1124 | void ObjCProtocolExpr::EmitImpl(llvm::Serializer& S) const { |
| 1125 | S.Emit(getType()); |
| 1126 | S.EmitPtr(Protocol); |
| 1127 | S.Emit(AtLoc); |
| 1128 | S.Emit(RParenLoc); |
| 1129 | } |
| 1130 | |
| 1131 | ObjCProtocolExpr* ObjCProtocolExpr::CreateImpl(llvm::Deserializer& D, |
| 1132 | ASTContext& C) { |
| 1133 | QualType T = QualType::ReadVal(D); |
| 1134 | ObjCProtocolDecl *PD = D.ReadPtr<ObjCProtocolDecl>(); |
| 1135 | SourceLocation AL = SourceLocation::ReadVal(D); |
| 1136 | SourceLocation RP = SourceLocation::ReadVal(D); |
| 1137 | return new ObjCProtocolExpr(T, PD, AL, RP); |
| 1138 | } |
| 1139 | |
Ted Kremenek | 378c151 | 2007-11-15 18:10:29 +0000 | [diff] [blame] | 1140 | void ObjCIvarRefExpr::EmitImpl(Serializer& S) const { |
| 1141 | S.Emit(Loc); |
| 1142 | S.Emit(getType()); |
| 1143 | S.EmitPtr(getDecl()); |
| 1144 | } |
Ted Kremenek | 9c1efff | 2007-12-04 00:38:30 +0000 | [diff] [blame] | 1145 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1146 | ObjCIvarRefExpr* ObjCIvarRefExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 378c151 | 2007-11-15 18:10:29 +0000 | [diff] [blame] | 1147 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1148 | QualType T = QualType::ReadVal(D); |
Fariborz Jahanian | efc4c4b | 2008-12-18 17:29:46 +0000 | [diff] [blame] | 1149 | ObjCIvarRefExpr* dr = new ObjCIvarRefExpr(NULL,T,Loc); |
Ted Kremenek | 378c151 | 2007-11-15 18:10:29 +0000 | [diff] [blame] | 1150 | D.ReadPtr(dr->D,false); |
| 1151 | return dr; |
| 1152 | } |
Ted Kremenek | 46dc0a5 | 2007-12-04 00:51:11 +0000 | [diff] [blame] | 1153 | |
Steve Naroff | ae78407 | 2008-05-30 00:40:33 +0000 | [diff] [blame] | 1154 | void ObjCPropertyRefExpr::EmitImpl(Serializer& S) const { |
Steve Naroff | c77a636 | 2008-12-04 16:24:46 +0000 | [diff] [blame] | 1155 | S.Emit(IdLoc); |
Steve Naroff | ae78407 | 2008-05-30 00:40:33 +0000 | [diff] [blame] | 1156 | S.Emit(getType()); |
Fariborz Jahanian | 5daf570 | 2008-11-22 18:39:36 +0000 | [diff] [blame] | 1157 | S.EmitPtr(getProperty()); |
| 1158 | } |
| 1159 | |
| 1160 | void ObjCKVCRefExpr::EmitImpl(Serializer& S) const { |
| 1161 | S.Emit(Loc); |
| 1162 | S.Emit(getType()); |
| 1163 | S.EmitPtr(getGetterMethod()); |
| 1164 | S.EmitPtr(getSetterMethod()); |
Steve Naroff | ae78407 | 2008-05-30 00:40:33 +0000 | [diff] [blame] | 1165 | } |
| 1166 | |
| 1167 | ObjCPropertyRefExpr* ObjCPropertyRefExpr::CreateImpl(Deserializer& D, |
| 1168 | ASTContext& C) { |
| 1169 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1170 | QualType T = QualType::ReadVal(D); |
| 1171 | ObjCPropertyRefExpr* dr = new ObjCPropertyRefExpr(NULL,T,Loc,0); |
Fariborz Jahanian | 5daf570 | 2008-11-22 18:39:36 +0000 | [diff] [blame] | 1172 | D.ReadPtr(dr->AsProperty,false); |
| 1173 | return dr; |
| 1174 | } |
| 1175 | |
| 1176 | ObjCKVCRefExpr* ObjCKVCRefExpr::CreateImpl(Deserializer& D, |
| 1177 | ASTContext& C) { |
| 1178 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1179 | QualType T = QualType::ReadVal(D); |
Fariborz Jahanian | ba8d2d6 | 2008-11-22 20:25:50 +0000 | [diff] [blame] | 1180 | ObjCKVCRefExpr* dr = new ObjCKVCRefExpr(NULL,T,NULL,Loc,0); |
Fariborz Jahanian | 5daf570 | 2008-11-22 18:39:36 +0000 | [diff] [blame] | 1181 | D.ReadPtr(dr->Setter,false); |
| 1182 | D.ReadPtr(dr->Getter,false); |
Steve Naroff | ae78407 | 2008-05-30 00:40:33 +0000 | [diff] [blame] | 1183 | return dr; |
| 1184 | } |
| 1185 | |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1186 | void ObjCMessageExpr::EmitImpl(Serializer& S) const { |
Ted Kremenek | be78424 | 2008-06-24 17:00:08 +0000 | [diff] [blame] | 1187 | S.EmitInt(getFlag()); |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1188 | S.Emit(getType()); |
| 1189 | S.Emit(SelName); |
| 1190 | S.Emit(LBracloc); |
| 1191 | S.Emit(RBracloc); |
| 1192 | S.EmitInt(NumArgs); |
| 1193 | S.EmitPtr(MethodProto); |
| 1194 | |
| 1195 | if (getReceiver()) |
| 1196 | S.BatchEmitOwnedPtrs(NumArgs+1, SubExprs); |
Ted Kremenek | be78424 | 2008-06-24 17:00:08 +0000 | [diff] [blame] | 1197 | else { |
| 1198 | ClassInfo Info = getClassInfo(); |
| 1199 | |
| 1200 | if (Info.first) S.EmitPtr(Info.first); |
| 1201 | else S.EmitPtr(Info.second); |
| 1202 | |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1203 | S.BatchEmitOwnedPtrs(NumArgs, &SubExprs[ARGS_START]); |
| 1204 | } |
| 1205 | } |
| 1206 | |
| 1207 | ObjCMessageExpr* ObjCMessageExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | be78424 | 2008-06-24 17:00:08 +0000 | [diff] [blame] | 1208 | unsigned flags = D.ReadInt(); |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1209 | QualType t = QualType::ReadVal(D); |
| 1210 | Selector S = Selector::ReadVal(D); |
| 1211 | SourceLocation L = SourceLocation::ReadVal(D); |
| 1212 | SourceLocation R = SourceLocation::ReadVal(D); |
| 1213 | |
| 1214 | // Construct an array for the subexpressions. |
| 1215 | unsigned NumArgs = D.ReadInt(); |
Ted Kremenek | be78424 | 2008-06-24 17:00:08 +0000 | [diff] [blame] | 1216 | Stmt** SubExprs = new Stmt*[NumArgs+1]; |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1217 | |
| 1218 | // Construct the ObjCMessageExpr object using the special ctor. |
| 1219 | ObjCMessageExpr* ME = new ObjCMessageExpr(S, t, L, R, SubExprs, NumArgs); |
| 1220 | |
| 1221 | // Read in the MethodProto. Read the instance variable directly |
| 1222 | // allows it to be backpatched. |
| 1223 | D.ReadPtr(ME->MethodProto); |
| 1224 | |
| 1225 | // Now read in the arguments. |
| 1226 | |
Eli Friedman | e8e3205 | 2008-12-16 20:06:41 +0000 | [diff] [blame] | 1227 | if ((flags & Flags) == IsInstMeth) |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1228 | D.BatchReadOwnedPtrs(NumArgs+1, SubExprs, C); |
| 1229 | else { |
Ted Kremenek | be78424 | 2008-06-24 17:00:08 +0000 | [diff] [blame] | 1230 | // Read the pointer for Cls/ClassName. The Deserializer will handle the |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1231 | // bit-mangling automatically. |
Ted Kremenek | be78424 | 2008-06-24 17:00:08 +0000 | [diff] [blame] | 1232 | SubExprs[RECEIVER] = (Stmt*) ((uintptr_t) flags); |
Ted Kremenek | ea958e57 | 2008-05-01 17:26:20 +0000 | [diff] [blame] | 1233 | D.ReadUIntPtr((uintptr_t&) SubExprs[RECEIVER]); |
| 1234 | |
| 1235 | // Read the arguments. |
| 1236 | D.BatchReadOwnedPtrs(NumArgs, &SubExprs[ARGS_START], C); |
| 1237 | } |
| 1238 | |
| 1239 | return ME; |
| 1240 | } |
| 1241 | |
Ted Kremenek | 8f6dc77 | 2007-12-05 00:43:08 +0000 | [diff] [blame] | 1242 | void ObjCSelectorExpr::EmitImpl(Serializer& S) const { |
| 1243 | S.Emit(AtLoc); |
| 1244 | S.Emit(RParenLoc); |
| 1245 | S.Emit(getType()); |
| 1246 | S.Emit(SelName); |
| 1247 | } |
| 1248 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1249 | ObjCSelectorExpr* ObjCSelectorExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 8f6dc77 | 2007-12-05 00:43:08 +0000 | [diff] [blame] | 1250 | SourceLocation AtLoc = SourceLocation::ReadVal(D); |
| 1251 | SourceLocation RParenLoc = SourceLocation::ReadVal(D); |
| 1252 | QualType T = QualType::ReadVal(D); |
| 1253 | Selector SelName = Selector::ReadVal(D); |
| 1254 | |
| 1255 | return new ObjCSelectorExpr(T,SelName,AtLoc,RParenLoc); |
| 1256 | } |
| 1257 | |
Ted Kremenek | 46dc0a5 | 2007-12-04 00:51:11 +0000 | [diff] [blame] | 1258 | void ObjCStringLiteral::EmitImpl(Serializer& S) const { |
| 1259 | S.Emit(AtLoc); |
| 1260 | S.Emit(getType()); |
| 1261 | S.EmitOwnedPtr(String); |
| 1262 | } |
| 1263 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1264 | ObjCStringLiteral* ObjCStringLiteral::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 46dc0a5 | 2007-12-04 00:51:11 +0000 | [diff] [blame] | 1265 | SourceLocation L = SourceLocation::ReadVal(D); |
| 1266 | QualType T = QualType::ReadVal(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 1267 | StringLiteral* String = cast<StringLiteral>(D.ReadOwnedPtr<Stmt>(C)); |
Ted Kremenek | 46dc0a5 | 2007-12-04 00:51:11 +0000 | [diff] [blame] | 1268 | return new ObjCStringLiteral(String,T,L); |
| 1269 | } |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 1270 | |
Douglas Gregor | cd9b46e | 2008-11-04 14:56:14 +0000 | [diff] [blame] | 1271 | void ObjCSuperExpr::EmitImpl(llvm::Serializer& S) const { |
| 1272 | S.Emit(getType()); |
| 1273 | S.Emit(Loc); |
| 1274 | } |
| 1275 | |
| 1276 | ObjCSuperExpr* ObjCSuperExpr::CreateImpl(llvm::Deserializer& D, ASTContext&) { |
| 1277 | QualType Ty = QualType::ReadVal(D); |
| 1278 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1279 | return new ObjCSuperExpr(Loc, Ty); |
| 1280 | } |
| 1281 | |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 1282 | //===----------------------------------------------------------------------===// |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1283 | // Serialization for Clang Extensions. |
| 1284 | //===----------------------------------------------------------------------===// |
| 1285 | |
Daniel Dunbar | d17c24f | 2008-10-14 16:57:09 +0000 | [diff] [blame] | 1286 | void ExtVectorElementExpr::EmitImpl(llvm::Serializer& S) const { |
| 1287 | S.Emit(getType()); |
| 1288 | S.EmitOwnedPtr(getBase()); |
| 1289 | S.EmitPtr(&Accessor); |
| 1290 | S.Emit(AccessorLoc); |
| 1291 | } |
| 1292 | |
| 1293 | ExtVectorElementExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 1294 | QualType T = QualType::ReadVal(D); |
| 1295 | Expr *B = D.ReadOwnedPtr<Expr>(C); |
| 1296 | IdentifierInfo *A = D.ReadPtr<IdentifierInfo>(); |
| 1297 | SourceLocation AL = SourceLocation::ReadVal(D); |
| 1298 | return new ExtVectorElementExpr(T, B, *A, AL); |
| 1299 | } |
| 1300 | |
Steve Naroff | 9c3c902 | 2008-09-17 18:37:59 +0000 | [diff] [blame] | 1301 | void BlockExpr::EmitImpl(Serializer& S) const { |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1302 | S.Emit(getType()); |
Steve Naroff | 56ee689 | 2008-10-08 17:01:13 +0000 | [diff] [blame] | 1303 | S.EmitOwnedPtr(TheBlock); |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1304 | } |
| 1305 | |
Steve Naroff | 9c3c902 | 2008-09-17 18:37:59 +0000 | [diff] [blame] | 1306 | BlockExpr* BlockExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
Steve Naroff | 56ee689 | 2008-10-08 17:01:13 +0000 | [diff] [blame] | 1307 | QualType T = QualType::ReadVal(D); |
| 1308 | return new BlockExpr(cast<BlockDecl>(D.ReadOwnedPtr<Decl>(C)),T); |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1309 | } |
| 1310 | |
| 1311 | void BlockDeclRefExpr::EmitImpl(Serializer& S) const { |
| 1312 | S.Emit(Loc); |
| 1313 | S.Emit(getType()); |
| 1314 | S.EmitBool(false); |
| 1315 | S.EmitPtr(getDecl()); |
| 1316 | } |
| 1317 | |
| 1318 | BlockDeclRefExpr* BlockDeclRefExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
| 1319 | assert(0 && "Cannot deserialize BlockDeclRefExpr yet"); |
| 1320 | return 0; |
| 1321 | } |
| 1322 | |
| 1323 | //===----------------------------------------------------------------------===// |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 1324 | // C++ Serialization |
| 1325 | //===----------------------------------------------------------------------===// |
| 1326 | void CXXDefaultArgExpr::EmitImpl(Serializer& S) const { |
| 1327 | S.EmitPtr(Param); |
| 1328 | } |
| 1329 | |
| 1330 | CXXDefaultArgExpr *CXXDefaultArgExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
| 1331 | ParmVarDecl* Param = 0; |
| 1332 | D.ReadPtr(Param, false); |
| 1333 | return new CXXDefaultArgExpr(Param); |
| 1334 | } |
Argyrios Kyrtzidis | 987a14b | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 1335 | |
| 1336 | void CXXFunctionalCastExpr::EmitImpl(Serializer& S) const { |
| 1337 | S.Emit(getType()); |
Douglas Gregor | 49badde | 2008-10-27 19:41:14 +0000 | [diff] [blame] | 1338 | S.Emit(getTypeAsWritten()); |
Argyrios Kyrtzidis | 987a14b | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 1339 | S.Emit(TyBeginLoc); |
| 1340 | S.Emit(RParenLoc); |
| 1341 | S.EmitOwnedPtr(getSubExpr()); |
| 1342 | } |
| 1343 | |
| 1344 | CXXFunctionalCastExpr * |
| 1345 | CXXFunctionalCastExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
| 1346 | QualType Ty = QualType::ReadVal(D); |
Douglas Gregor | 49badde | 2008-10-27 19:41:14 +0000 | [diff] [blame] | 1347 | QualType WrittenTy = QualType::ReadVal(D); |
Argyrios Kyrtzidis | 987a14b | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 1348 | SourceLocation TyBeginLoc = SourceLocation::ReadVal(D); |
| 1349 | SourceLocation RParenLoc = SourceLocation::ReadVal(D); |
| 1350 | Expr* SubExpr = D.ReadOwnedPtr<Expr>(C); |
Douglas Gregor | 49badde | 2008-10-27 19:41:14 +0000 | [diff] [blame] | 1351 | return new CXXFunctionalCastExpr(Ty, WrittenTy, TyBeginLoc, SubExpr, RParenLoc); |
| 1352 | } |
| 1353 | |
| 1354 | void CXXNamedCastExpr::EmitImpl(Serializer& S) const { |
| 1355 | S.Emit(getType()); |
| 1356 | S.Emit(getTypeAsWritten()); |
| 1357 | S.Emit(Loc); |
| 1358 | S.EmitOwnedPtr(getSubExpr()); |
| 1359 | } |
| 1360 | |
| 1361 | CXXNamedCastExpr * |
| 1362 | CXXNamedCastExpr::CreateImpl(Deserializer& D, ASTContext& C, StmtClass SC) { |
| 1363 | QualType Ty = QualType::ReadVal(D); |
| 1364 | QualType WrittenTy = QualType::ReadVal(D); |
| 1365 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1366 | Expr* SubExpr = D.ReadOwnedPtr<Expr>(C); |
| 1367 | switch (SC) { |
| 1368 | case CXXStaticCastExprClass: |
| 1369 | return new CXXStaticCastExpr(Ty, SubExpr, WrittenTy, Loc); |
| 1370 | case CXXDynamicCastExprClass: |
| 1371 | return new CXXDynamicCastExpr(Ty, SubExpr, WrittenTy, Loc); |
| 1372 | case CXXReinterpretCastExprClass: |
| 1373 | return new CXXReinterpretCastExpr(Ty, SubExpr, WrittenTy, Loc); |
| 1374 | case CXXConstCastExprClass: |
| 1375 | return new CXXConstCastExpr(Ty, SubExpr, WrittenTy, Loc); |
| 1376 | default: |
| 1377 | assert(false && "Unknown cast type!"); |
| 1378 | return 0; |
| 1379 | } |
Argyrios Kyrtzidis | 987a14b | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 1380 | } |
| 1381 | |
Sebastian Redl | c42e118 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 1382 | void CXXTypeidExpr::EmitImpl(llvm::Serializer& S) const { |
| 1383 | S.Emit(getType()); |
Sebastian Redl | d457589 | 2008-12-03 23:17:54 +0000 | [diff] [blame] | 1384 | S.EmitBool(isTypeOperand()); |
Sebastian Redl | c42e118 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 1385 | if (isTypeOperand()) { |
| 1386 | S.Emit(getTypeOperand()); |
| 1387 | } else { |
| 1388 | S.EmitOwnedPtr(getExprOperand()); |
| 1389 | } |
| 1390 | S.Emit(Range); |
| 1391 | } |
| 1392 | |
| 1393 | CXXTypeidExpr* |
| 1394 | CXXTypeidExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 1395 | QualType Ty = QualType::ReadVal(D); |
| 1396 | bool isTypeOp = D.ReadBool(); |
| 1397 | void *Operand; |
| 1398 | if (isTypeOp) { |
| 1399 | Operand = QualType::ReadVal(D).getAsOpaquePtr(); |
| 1400 | } else { |
| 1401 | Operand = D.ReadOwnedPtr<Expr>(C); |
| 1402 | } |
| 1403 | SourceRange Range = SourceRange::ReadVal(D); |
| 1404 | return new CXXTypeidExpr(isTypeOp, Operand, Ty, Range); |
| 1405 | } |
| 1406 | |
Douglas Gregor | 796da18 | 2008-11-04 14:32:21 +0000 | [diff] [blame] | 1407 | void CXXThisExpr::EmitImpl(llvm::Serializer& S) const { |
| 1408 | S.Emit(getType()); |
| 1409 | S.Emit(Loc); |
| 1410 | } |
| 1411 | |
| 1412 | CXXThisExpr* CXXThisExpr::CreateImpl(llvm::Deserializer& D, ASTContext&) { |
| 1413 | QualType Ty = QualType::ReadVal(D); |
| 1414 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1415 | return new CXXThisExpr(Loc, Ty); |
| 1416 | } |
| 1417 | |
Douglas Gregor | 506ae41 | 2009-01-16 18:33:17 +0000 | [diff] [blame] | 1418 | void CXXTemporaryObjectExpr::EmitImpl(llvm::Serializer& S) const { |
| 1419 | S.Emit(getType()); |
| 1420 | S.Emit(TyBeginLoc); |
| 1421 | S.Emit(RParenLoc); |
| 1422 | S.EmitPtr(cast<Decl>(Constructor)); |
| 1423 | S.EmitInt(NumArgs); |
| 1424 | if (NumArgs > 0) |
| 1425 | S.BatchEmitOwnedPtrs(NumArgs, Args); |
| 1426 | } |
| 1427 | |
| 1428 | CXXTemporaryObjectExpr * |
| 1429 | CXXTemporaryObjectExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 1430 | QualType writtenTy = QualType::ReadVal(D); |
| 1431 | SourceLocation tyBeginLoc = SourceLocation::ReadVal(D); |
| 1432 | SourceLocation rParenLoc = SourceLocation::ReadVal(D); |
| 1433 | CXXConstructorDecl * Cons = cast_or_null<CXXConstructorDecl>(D.ReadPtr<Decl>()); |
| 1434 | unsigned NumArgs = D.ReadInt(); |
| 1435 | Stmt** Args = 0; |
| 1436 | if (NumArgs > 0) { |
| 1437 | Args = new Stmt*[NumArgs]; |
| 1438 | D.BatchReadOwnedPtrs(NumArgs, Args, C); |
| 1439 | } |
| 1440 | |
| 1441 | CXXTemporaryObjectExpr * Result |
| 1442 | = new CXXTemporaryObjectExpr(Cons, writtenTy, tyBeginLoc, |
| 1443 | (Expr**)Args, NumArgs, rParenLoc); |
| 1444 | |
| 1445 | if (NumArgs > 0) |
| 1446 | delete [] Args; |
| 1447 | |
| 1448 | return Result; |
| 1449 | } |
| 1450 | |
| 1451 | |
Argyrios Kyrtzidis | 987a14b | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 1452 | void CXXZeroInitValueExpr::EmitImpl(Serializer& S) const { |
| 1453 | S.Emit(getType()); |
| 1454 | S.Emit(TyBeginLoc); |
| 1455 | S.Emit(RParenLoc); |
| 1456 | } |
| 1457 | |
| 1458 | CXXZeroInitValueExpr * |
| 1459 | CXXZeroInitValueExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
| 1460 | QualType Ty = QualType::ReadVal(D); |
| 1461 | SourceLocation TyBeginLoc = SourceLocation::ReadVal(D); |
| 1462 | SourceLocation RParenLoc = SourceLocation::ReadVal(D); |
| 1463 | return new CXXZeroInitValueExpr(Ty, TyBeginLoc, RParenLoc); |
| 1464 | } |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1465 | |
| 1466 | void CXXNewExpr::EmitImpl(Serializer& S) const { |
| 1467 | S.Emit(getType()); |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 1468 | S.EmitBool(GlobalNew); |
| 1469 | S.EmitBool(ParenTypeId); |
| 1470 | S.EmitBool(Initializer); |
| 1471 | S.EmitBool(Array); |
Douglas Gregor | 19ac6ff | 2008-12-01 19:45:16 +0000 | [diff] [blame] | 1472 | S.EmitInt(NumPlacementArgs); |
| 1473 | S.EmitInt(NumConstructorArgs); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1474 | S.BatchEmitOwnedPtrs(NumPlacementArgs + NumConstructorArgs, SubExprs); |
| 1475 | assert((OperatorNew == 0 || S.isRegistered(OperatorNew)) && |
| 1476 | (OperatorDelete == 0 || S.isRegistered(OperatorDelete)) && |
| 1477 | (Constructor == 0 || S.isRegistered(Constructor)) && |
| 1478 | "CXXNewExpr cannot own declarations"); |
| 1479 | S.EmitPtr(OperatorNew); |
| 1480 | S.EmitPtr(OperatorDelete); |
| 1481 | S.EmitPtr(Constructor); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1482 | S.Emit(StartLoc); |
| 1483 | S.Emit(EndLoc); |
| 1484 | } |
| 1485 | |
| 1486 | CXXNewExpr * |
| 1487 | CXXNewExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
| 1488 | QualType T = QualType::ReadVal(D); |
| 1489 | bool GlobalNew = D.ReadBool(); |
| 1490 | bool ParenTypeId = D.ReadBool(); |
| 1491 | bool Initializer = D.ReadBool(); |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 1492 | bool Array = D.ReadBool(); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1493 | unsigned NumPlacementArgs = D.ReadInt(); |
| 1494 | unsigned NumConstructorArgs = D.ReadInt(); |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 1495 | unsigned TotalExprs = Array + NumPlacementArgs + NumConstructorArgs; |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1496 | Stmt** SubExprs = new Stmt*[TotalExprs]; |
| 1497 | D.BatchReadOwnedPtrs(TotalExprs, SubExprs, C); |
| 1498 | FunctionDecl *OperatorNew = D.ReadPtr<FunctionDecl>(); |
| 1499 | FunctionDecl *OperatorDelete = D.ReadPtr<FunctionDecl>(); |
| 1500 | CXXConstructorDecl *Constructor = D.ReadPtr<CXXConstructorDecl>(); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1501 | SourceLocation StartLoc = SourceLocation::ReadVal(D); |
| 1502 | SourceLocation EndLoc = SourceLocation::ReadVal(D); |
| 1503 | |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 1504 | return new CXXNewExpr(T, GlobalNew, ParenTypeId, Initializer, Array, |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1505 | NumPlacementArgs, NumConstructorArgs, SubExprs, |
| 1506 | OperatorNew, OperatorDelete, Constructor, StartLoc, |
| 1507 | EndLoc); |
| 1508 | } |
| 1509 | |
| 1510 | void CXXDeleteExpr::EmitImpl(Serializer& S) const { |
| 1511 | S.Emit(getType()); |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 1512 | S.EmitBool(GlobalDelete); |
| 1513 | S.EmitBool(ArrayForm); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1514 | S.EmitPtr(OperatorDelete); |
| 1515 | S.EmitOwnedPtr(Argument); |
| 1516 | S.Emit(Loc); |
| 1517 | } |
| 1518 | |
| 1519 | CXXDeleteExpr * |
| 1520 | CXXDeleteExpr::CreateImpl(Deserializer& D, ASTContext& C) { |
| 1521 | QualType Ty = QualType::ReadVal(D); |
| 1522 | bool GlobalDelete = D.ReadBool(); |
| 1523 | bool ArrayForm = D.ReadBool(); |
| 1524 | FunctionDecl *OperatorDelete = D.ReadPtr<FunctionDecl>(); |
| 1525 | Stmt *Argument = D.ReadOwnedPtr<Stmt>(C); |
| 1526 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1527 | return new CXXDeleteExpr(Ty, GlobalDelete, ArrayForm, OperatorDelete, |
| 1528 | cast<Expr>(Argument), Loc); |
| 1529 | } |
Douglas Gregor | 5c37de7 | 2008-12-06 00:22:45 +0000 | [diff] [blame] | 1530 | |
| 1531 | void CXXDependentNameExpr::EmitImpl(llvm::Serializer& S) const { |
| 1532 | S.Emit(getType()); |
| 1533 | S.EmitPtr(Name); |
| 1534 | S.Emit(Loc); |
| 1535 | } |
| 1536 | |
| 1537 | CXXDependentNameExpr * |
| 1538 | CXXDependentNameExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 1539 | QualType Ty = QualType::ReadVal(D); |
| 1540 | IdentifierInfo *N = D.ReadPtr<IdentifierInfo>(); |
| 1541 | SourceLocation L = SourceLocation::ReadVal(D); |
| 1542 | return new CXXDependentNameExpr(N, Ty, L); |
| 1543 | } |
Sebastian Redl | 4b07b29 | 2008-12-22 19:15:10 +0000 | [diff] [blame] | 1544 | |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 1545 | void UnaryTypeTraitExpr::EmitImpl(llvm::Serializer& S) const { |
| 1546 | S.EmitInt(UTT); |
| 1547 | S.Emit(Loc); |
| 1548 | S.Emit(RParen); |
| 1549 | S.Emit(QueriedType); |
| 1550 | S.Emit(getType()); |
| 1551 | } |
| 1552 | |
| 1553 | UnaryTypeTraitExpr * |
| 1554 | UnaryTypeTraitExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 1555 | UnaryTypeTrait UTT = static_cast<UnaryTypeTrait>(D.ReadInt()); |
| 1556 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 1557 | SourceLocation RParen = SourceLocation::ReadVal(D); |
| 1558 | QualType QueriedType = QualType::ReadVal(D); |
| 1559 | QualType Ty = QualType::ReadVal(D); |
| 1560 | return new UnaryTypeTraitExpr(Loc, UTT, QueriedType, RParen, Ty); |
| 1561 | } |
| 1562 | |
Sebastian Redl | 4b07b29 | 2008-12-22 19:15:10 +0000 | [diff] [blame] | 1563 | void CXXCatchStmt::EmitImpl(llvm::Serializer& S) const { |
| 1564 | S.Emit(CatchLoc); |
| 1565 | S.EmitOwnedPtr(ExceptionDecl); |
| 1566 | S.EmitOwnedPtr(HandlerBlock); |
| 1567 | } |
| 1568 | |
| 1569 | CXXCatchStmt * |
| 1570 | CXXCatchStmt::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 1571 | SourceLocation CatchLoc = SourceLocation::ReadVal(D); |
| 1572 | Decl *ExDecl = D.ReadOwnedPtr<Decl>(C); |
| 1573 | Stmt *HandlerBlock = D.ReadOwnedPtr<Stmt>(C); |
| 1574 | return new CXXCatchStmt(CatchLoc, ExDecl, HandlerBlock); |
| 1575 | } |
Sebastian Redl | 8351da0 | 2008-12-22 21:35:02 +0000 | [diff] [blame] | 1576 | |
| 1577 | void CXXTryStmt::EmitImpl(llvm::Serializer& S) const { |
| 1578 | S.Emit(TryLoc); |
| 1579 | S.EmitInt(Stmts.size()); |
| 1580 | S.BatchEmitOwnedPtrs(Stmts.size(), &Stmts[0]); |
| 1581 | } |
| 1582 | |
| 1583 | CXXTryStmt * |
| 1584 | CXXTryStmt::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 1585 | SourceLocation TryLoc = SourceLocation::ReadVal(D); |
| 1586 | unsigned size = D.ReadInt(); |
| 1587 | llvm::SmallVector<Stmt*, 4> Stmts(size); |
| 1588 | D.BatchReadOwnedPtrs<Stmt>(size, &Stmts[0], C); |
| 1589 | |
| 1590 | return new CXXTryStmt(TryLoc, Stmts[0], &Stmts[1], size - 1); |
| 1591 | } |
Douglas Gregor | 1a49af9 | 2009-01-06 05:10:23 +0000 | [diff] [blame] | 1592 | |
| 1593 | void QualifiedDeclRefExpr::EmitImpl(llvm::Serializer& S) const { |
| 1594 | DeclRefExpr::EmitImpl(S); |
| 1595 | S.Emit(NestedNameLoc); |
| 1596 | } |
| 1597 | |
| 1598 | QualifiedDeclRefExpr* |
| 1599 | QualifiedDeclRefExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { |
| 1600 | assert(false && "Cannot deserialize qualified decl references"); |
| 1601 | return 0; |
| 1602 | } |