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