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