Ted Kremenek | 215c2c8 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 1 | //===--- StmtSerialization.cpp - Serialization of Statements --------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Ted Kremenek and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the type-specific methods for serializing statements |
| 11 | // and expressions. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 15 | #include "clang/AST/Expr.h" |
Ted Kremenek | 215c2c8 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 16 | #include "llvm/Bitcode/Serialize.h" |
| 17 | #include "llvm/Bitcode/Deserialize.h" |
| 18 | |
Ted Kremenek | 215c2c8 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 19 | using namespace clang; |
| 20 | |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 21 | void Stmt::Emit(llvm::Serializer& S) const { |
| 22 | S.EmitInt(getStmtClass()); |
| 23 | directEmit(S); |
| 24 | } |
Ted Kremenek | 215c2c8 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 25 | |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 26 | Stmt* Stmt::Materialize(llvm::Deserializer& D) { |
| 27 | StmtClass SC = static_cast<StmtClass>(D.ReadInt()); |
Ted Kremenek | 215c2c8 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 28 | |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 29 | switch (SC) { |
| 30 | default: |
| 31 | assert (false && "Not implemented."); |
| 32 | return NULL; |
Ted Kremenek | 2bd6e65 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 33 | |
| 34 | case BinaryOperatorClass: |
| 35 | return BinaryOperator::directMaterialize(D); |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 36 | |
Ted Kremenek | 249d7cd | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 37 | case BreakStmtClass: |
| 38 | return BreakStmt::directMaterialize(D); |
| 39 | |
| 40 | case CaseStmtClass: |
| 41 | return CaseStmt::directMaterialize(D); |
| 42 | |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 43 | case CompoundStmtClass: |
| 44 | return CompoundStmt::directMaterialize(D); |
| 45 | |
Ted Kremenek | 6c4dba7 | 2007-11-07 17:05:07 +0000 | [diff] [blame^] | 46 | case ContinueStmtClass: |
| 47 | return ContinueStmt::directMaterialize(D); |
| 48 | |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 49 | case DeclRefExprClass: |
| 50 | return DeclRefExpr::directMaterialize(D); |
| 51 | |
Ted Kremenek | 2bd6e65 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 52 | case DeclStmtClass: |
| 53 | return DeclStmt::directMaterialize(D); |
Ted Kremenek | 249d7cd | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 54 | |
| 55 | case DefaultStmtClass: |
| 56 | return DefaultStmt::directMaterialize(D); |
Ted Kremenek | ab97f4d | 2007-11-07 07:53:55 +0000 | [diff] [blame] | 57 | |
| 58 | case DoStmtClass: |
| 59 | return DoStmt::directMaterialize(D); |
Ted Kremenek | f34da90 | 2007-11-07 08:02:55 +0000 | [diff] [blame] | 60 | |
| 61 | case ForStmtClass: |
| 62 | return ForStmt::directMaterialize(D); |
Ted Kremenek | affd8be | 2007-11-07 08:07:46 +0000 | [diff] [blame] | 63 | |
| 64 | case GotoStmtClass: |
| 65 | return GotoStmt::directMaterialize(D); |
Ted Kremenek | 249d7cd | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 66 | |
Ted Kremenek | ca22d35 | 2007-11-07 07:19:30 +0000 | [diff] [blame] | 67 | case IfStmtClass: |
| 68 | return IfStmt::directMaterialize(D); |
| 69 | |
Ted Kremenek | e7d27d5 | 2007-11-07 17:02:32 +0000 | [diff] [blame] | 70 | case IndirectGotoStmtClass: |
| 71 | return IndirectGotoStmt::directMaterialize(D); |
| 72 | |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 73 | case IntegerLiteralClass: |
Ted Kremenek | 25aaa26 | 2007-11-07 00:40:53 +0000 | [diff] [blame] | 74 | return IntegerLiteral::directMaterialize(D); |
| 75 | |
Ted Kremenek | 56a74bb | 2007-11-07 00:48:04 +0000 | [diff] [blame] | 76 | case LabelStmtClass: |
| 77 | return LabelStmt::directMaterialize(D); |
| 78 | |
Ted Kremenek | 25aaa26 | 2007-11-07 00:40:53 +0000 | [diff] [blame] | 79 | case NullStmtClass: |
| 80 | return NullStmt::directMaterialize(D); |
Ted Kremenek | 2bd6e65 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 81 | |
Ted Kremenek | 249d7cd | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 82 | case ParenExprClass: |
| 83 | return ParenExpr::directMaterialize(D); |
| 84 | |
Ted Kremenek | 2bd6e65 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 85 | case ReturnStmtClass: |
Ted Kremenek | 249d7cd | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 86 | return ReturnStmt::directMaterialize(D); |
| 87 | |
| 88 | case SwitchStmtClass: |
| 89 | return SwitchStmt::directMaterialize(D); |
Ted Kremenek | 55e559a | 2007-11-07 07:50:10 +0000 | [diff] [blame] | 90 | |
| 91 | case WhileStmtClass: |
| 92 | return WhileStmt::directMaterialize(D); |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 93 | } |
Ted Kremenek | 215c2c8 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 94 | } |
| 95 | |
Ted Kremenek | 2bd6e65 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 96 | void BinaryOperator::directEmit(llvm::Serializer& S) const { |
| 97 | S.EmitInt(Opc); |
| 98 | S.Emit(OpLoc);; |
| 99 | S.Emit(getType()); |
| 100 | S.EmitOwnedPtr(getLHS()); |
| 101 | S.EmitOwnedPtr(getRHS()); |
| 102 | } |
| 103 | |
| 104 | BinaryOperator* BinaryOperator::directMaterialize(llvm::Deserializer& D) { |
| 105 | Opcode Opc = static_cast<Opcode>(D.ReadInt()); |
| 106 | SourceLocation OpLoc = SourceLocation::ReadVal(D); |
| 107 | QualType Result = QualType::ReadVal(D); |
| 108 | Expr* LHS = D.ReadOwnedPtr<Expr>(); |
| 109 | Expr* RHS = D.ReadOwnedPtr<Expr>(); |
| 110 | return new BinaryOperator(LHS,RHS,Opc,Result,OpLoc); |
| 111 | } |
Ted Kremenek | 215c2c8 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 112 | |
Ted Kremenek | 249d7cd | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 113 | void BreakStmt::directEmit(llvm::Serializer& S) const { |
| 114 | S.Emit(BreakLoc); |
| 115 | } |
| 116 | |
| 117 | BreakStmt* BreakStmt::directMaterialize(llvm::Deserializer& D) { |
| 118 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 119 | return new BreakStmt(Loc); |
| 120 | } |
| 121 | |
| 122 | void CaseStmt::directEmit(llvm::Serializer& S) const { |
| 123 | S.Emit(CaseLoc); |
| 124 | S.EmitOwnedPtr(getLHS()); |
| 125 | S.EmitOwnedPtr(getRHS()); |
| 126 | S.EmitOwnedPtr(getSubStmt()); |
| 127 | S.EmitPtr(getNextSwitchCase()); |
| 128 | } |
| 129 | |
| 130 | CaseStmt* CaseStmt::directMaterialize(llvm::Deserializer& D) { |
| 131 | SourceLocation CaseLoc = SourceLocation::ReadVal(D); |
| 132 | Expr* LHS = D.ReadOwnedPtr<Expr>(); |
| 133 | Expr* RHS = D.ReadOwnedPtr<Expr>(); |
| 134 | Stmt* SubStmt = D.ReadOwnedPtr<Stmt>(); |
| 135 | |
| 136 | CaseStmt* stmt = new CaseStmt(LHS,RHS,SubStmt,CaseLoc); |
| 137 | stmt->setNextSwitchCase(D.ReadPtr<SwitchCase>()); |
| 138 | |
| 139 | return stmt; |
| 140 | } |
Ted Kremenek | 215c2c8 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 141 | |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 142 | void CompoundStmt::directEmit(llvm::Serializer& S) const { |
| 143 | S.Emit(LBracLoc); |
| 144 | S.Emit(RBracLoc); |
| 145 | S.Emit(Body.size()); |
Ted Kremenek | 215c2c8 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 146 | |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 147 | for (const_body_iterator I=body_begin(), E=body_end(); I!=E; ++I) |
Ted Kremenek | 215c2c8 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 148 | S.EmitOwnedPtr(*I); |
| 149 | } |
| 150 | |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 151 | CompoundStmt* CompoundStmt::directMaterialize(llvm::Deserializer& D) { |
| 152 | SourceLocation LB = SourceLocation::ReadVal(D); |
| 153 | SourceLocation RB = SourceLocation::ReadVal(D); |
| 154 | unsigned size = D.ReadInt(); |
Ted Kremenek | 215c2c8 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 155 | |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 156 | CompoundStmt* stmt = new CompoundStmt(NULL,0,LB,RB); |
| 157 | |
| 158 | stmt->Body.reserve(size); |
| 159 | |
| 160 | for (unsigned i = 0; i < size; ++i) |
| 161 | stmt->Body.push_back(D.ReadOwnedPtr<Stmt>()); |
| 162 | |
| 163 | return stmt; |
Ted Kremenek | 215c2c8 | 2007-10-31 18:41:19 +0000 | [diff] [blame] | 164 | } |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 165 | |
Ted Kremenek | 6c4dba7 | 2007-11-07 17:05:07 +0000 | [diff] [blame^] | 166 | void ContinueStmt::directEmit(llvm::Serializer& S) const { |
| 167 | S.Emit(ContinueLoc); |
| 168 | } |
| 169 | |
| 170 | ContinueStmt* ContinueStmt::directMaterialize(llvm::Deserializer& D) { |
| 171 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 172 | return new ContinueStmt(Loc); |
| 173 | } |
| 174 | |
Ted Kremenek | 2bd6e65 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 175 | void DeclStmt::directEmit(llvm::Serializer& S) const { |
| 176 | // FIXME: special handling for struct decls. |
| 177 | S.EmitOwnedPtr(getDecl()); |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | void DeclRefExpr::directEmit(llvm::Serializer& S) const { |
| 181 | S.Emit(Loc); |
| 182 | S.Emit(getType()); |
| 183 | S.EmitPtr(getDecl()); |
| 184 | } |
| 185 | |
| 186 | DeclRefExpr* DeclRefExpr::directMaterialize(llvm::Deserializer& D) { |
| 187 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 188 | QualType T = QualType::ReadVal(D); |
| 189 | DeclRefExpr* dr = new DeclRefExpr(NULL,T,Loc); |
| 190 | D.ReadPtr(dr->D,false); |
| 191 | return dr; |
| 192 | } |
| 193 | |
Ted Kremenek | 2bd6e65 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 194 | DeclStmt* DeclStmt::directMaterialize(llvm::Deserializer& D) { |
| 195 | ScopedDecl* decl = cast<ScopedDecl>(D.ReadOwnedPtr<Decl>()); |
| 196 | return new DeclStmt(decl); |
| 197 | } |
| 198 | |
Ted Kremenek | 249d7cd | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 199 | void DefaultStmt::directEmit(llvm::Serializer& S) const { |
| 200 | S.Emit(DefaultLoc); |
| 201 | S.EmitOwnedPtr(getSubStmt()); |
| 202 | S.EmitPtr(getNextSwitchCase()); |
| 203 | } |
| 204 | |
| 205 | DefaultStmt* DefaultStmt::directMaterialize(llvm::Deserializer& D) { |
| 206 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 207 | Stmt* SubStmt = D.ReadOwnedPtr<Stmt>(); |
| 208 | |
| 209 | DefaultStmt* stmt = new DefaultStmt(Loc,SubStmt); |
| 210 | stmt->setNextSwitchCase(D.ReadPtr<SwitchCase>()); |
| 211 | |
| 212 | return stmt; |
| 213 | } |
Ted Kremenek | 2bd6e65 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 214 | |
Ted Kremenek | ab97f4d | 2007-11-07 07:53:55 +0000 | [diff] [blame] | 215 | void DoStmt::directEmit(llvm::Serializer& S) const { |
| 216 | S.Emit(DoLoc); |
| 217 | S.EmitOwnedPtr(getCond()); |
| 218 | S.EmitOwnedPtr(getBody()); |
| 219 | } |
| 220 | |
| 221 | DoStmt* DoStmt::directMaterialize(llvm::Deserializer& D) { |
| 222 | SourceLocation DoLoc = SourceLocation::ReadVal(D); |
| 223 | Expr* Cond = D.ReadOwnedPtr<Expr>(); |
| 224 | Stmt* Body = D.ReadOwnedPtr<Stmt>(); |
| 225 | return new DoStmt(Body,Cond,DoLoc); |
| 226 | } |
| 227 | |
Ted Kremenek | f34da90 | 2007-11-07 08:02:55 +0000 | [diff] [blame] | 228 | void ForStmt::directEmit(llvm::Serializer& S) const { |
| 229 | S.Emit(ForLoc); |
| 230 | S.EmitOwnedPtr(getInit()); |
| 231 | S.EmitOwnedPtr(getCond()); |
| 232 | S.EmitOwnedPtr(getInc()); |
| 233 | S.EmitOwnedPtr(getBody()); |
| 234 | } |
| 235 | |
| 236 | ForStmt* ForStmt::directMaterialize(llvm::Deserializer& D) { |
| 237 | SourceLocation ForLoc = SourceLocation::ReadVal(D); |
| 238 | Stmt* Init = D.ReadOwnedPtr<Stmt>(); |
| 239 | Expr* Cond = D.ReadOwnedPtr<Expr>(); |
| 240 | Expr* Inc = D.ReadOwnedPtr<Expr>(); |
| 241 | Stmt* Body = D.ReadOwnedPtr<Stmt>(); |
| 242 | return new ForStmt(Init,Cond,Inc,Body,ForLoc); |
| 243 | } |
| 244 | |
Ted Kremenek | affd8be | 2007-11-07 08:07:46 +0000 | [diff] [blame] | 245 | void GotoStmt::directEmit(llvm::Serializer& S) const { |
| 246 | S.Emit(GotoLoc); |
| 247 | S.Emit(LabelLoc); |
| 248 | S.EmitPtr(Label); |
| 249 | } |
| 250 | |
| 251 | GotoStmt* GotoStmt::directMaterialize(llvm::Deserializer& D) { |
| 252 | SourceLocation GotoLoc = SourceLocation::ReadVal(D); |
| 253 | SourceLocation LabelLoc = SourceLocation::ReadVal(D); |
| 254 | GotoStmt* stmt = new GotoStmt(NULL,GotoLoc,LabelLoc); |
| 255 | D.ReadPtr(stmt->Label); // This pointer may be backpatched later. |
| 256 | return stmt; |
| 257 | } |
| 258 | |
Ted Kremenek | ca22d35 | 2007-11-07 07:19:30 +0000 | [diff] [blame] | 259 | void IfStmt::directEmit(llvm::Serializer& S) const { |
| 260 | S.Emit(IfLoc); |
| 261 | S.EmitOwnedPtr(getCond()); |
| 262 | S.EmitOwnedPtr(getThen()); |
| 263 | S.EmitOwnedPtr(getElse()); |
| 264 | } |
| 265 | |
| 266 | IfStmt* IfStmt::directMaterialize(llvm::Deserializer& D) { |
| 267 | SourceLocation L = SourceLocation::ReadVal(D); |
| 268 | Expr* Cond = D.ReadOwnedPtr<Expr>(); |
| 269 | Stmt* Then = D.ReadOwnedPtr<Stmt>(); |
| 270 | Stmt* Else = D.ReadOwnedPtr<Stmt>(); |
| 271 | return new IfStmt(L,Cond,Then,Else); |
| 272 | } |
| 273 | |
Ted Kremenek | e7d27d5 | 2007-11-07 17:02:32 +0000 | [diff] [blame] | 274 | void IndirectGotoStmt::directEmit(llvm::Serializer& S) const { |
| 275 | S.EmitPtr(Target); |
| 276 | } |
| 277 | |
| 278 | IndirectGotoStmt* IndirectGotoStmt::directMaterialize(llvm::Deserializer& D) { |
| 279 | IndirectGotoStmt* stmt = new IndirectGotoStmt(NULL); |
| 280 | D.ReadPtr(stmt->Target); // The target may be backpatched. |
| 281 | return stmt; |
| 282 | } |
| 283 | |
Ted Kremenek | 4728110 | 2007-11-07 00:17:35 +0000 | [diff] [blame] | 284 | void IntegerLiteral::directEmit(llvm::Serializer& S) const { |
| 285 | S.Emit(Loc); |
| 286 | S.Emit(getType()); |
| 287 | S.Emit(getValue()); |
| 288 | } |
| 289 | |
| 290 | IntegerLiteral* IntegerLiteral::directMaterialize(llvm::Deserializer& D) { |
| 291 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 292 | QualType T = QualType::ReadVal(D); |
| 293 | |
| 294 | // Create a dummy APInt because it is more efficient to deserialize |
| 295 | // it in place with the deserialized IntegerLiteral. (fewer copies) |
| 296 | llvm::APInt temp; |
| 297 | IntegerLiteral* expr = new IntegerLiteral(temp,T,Loc); |
| 298 | D.Read(expr->Value); |
| 299 | |
| 300 | return expr; |
| 301 | } |
Ted Kremenek | 2bd6e65 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 302 | |
Ted Kremenek | 56a74bb | 2007-11-07 00:48:04 +0000 | [diff] [blame] | 303 | void LabelStmt::directEmit(llvm::Serializer& S) const { |
| 304 | S.EmitPtr(Label); |
| 305 | S.Emit(IdentLoc); |
| 306 | S.EmitOwnedPtr(SubStmt); |
| 307 | } |
| 308 | |
| 309 | LabelStmt* LabelStmt::directMaterialize(llvm::Deserializer& D) { |
| 310 | IdentifierInfo* Label = D.ReadPtr<IdentifierInfo>(); |
| 311 | SourceLocation IdentLoc = SourceLocation::ReadVal(D); |
| 312 | Stmt* SubStmt = D.ReadOwnedPtr<Stmt>(); |
| 313 | return new LabelStmt(IdentLoc,Label,SubStmt); |
| 314 | } |
| 315 | |
Ted Kremenek | 25aaa26 | 2007-11-07 00:40:53 +0000 | [diff] [blame] | 316 | void NullStmt::directEmit(llvm::Serializer& S) const { |
| 317 | S.Emit(SemiLoc); |
| 318 | } |
| 319 | |
| 320 | NullStmt* NullStmt::directMaterialize(llvm::Deserializer& D) { |
| 321 | SourceLocation SemiLoc = SourceLocation::ReadVal(D); |
| 322 | return new NullStmt(SemiLoc); |
| 323 | } |
Ted Kremenek | 2bd6e65 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 324 | |
Ted Kremenek | 249d7cd | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 325 | void ParenExpr::directEmit(llvm::Serializer& S) const { |
| 326 | S.Emit(L); |
| 327 | S.Emit(R); |
| 328 | S.EmitOwnedPtr(Val); |
| 329 | } |
| 330 | |
| 331 | ParenExpr* ParenExpr::directMaterialize(llvm::Deserializer& D) { |
| 332 | SourceLocation L = SourceLocation::ReadVal(D); |
| 333 | SourceLocation R = SourceLocation::ReadVal(D); |
| 334 | Expr* val = D.ReadOwnedPtr<Expr>(); |
| 335 | return new ParenExpr(L,R,val); |
| 336 | } |
| 337 | |
Ted Kremenek | 2bd6e65 | 2007-11-07 00:37:40 +0000 | [diff] [blame] | 338 | void ReturnStmt::directEmit(llvm::Serializer& S) const { |
| 339 | S.Emit(RetLoc); |
| 340 | S.EmitOwnedPtr(RetExpr); |
| 341 | } |
| 342 | |
| 343 | ReturnStmt* ReturnStmt::directMaterialize(llvm::Deserializer& D) { |
| 344 | SourceLocation RetLoc = SourceLocation::ReadVal(D); |
| 345 | Expr* RetExpr = D.ReadOwnedPtr<Expr>(); |
| 346 | return new ReturnStmt(RetLoc,RetExpr); |
| 347 | } |
| 348 | |
Ted Kremenek | 249d7cd | 2007-11-07 05:25:31 +0000 | [diff] [blame] | 349 | void SwitchStmt::directEmit(llvm::Serializer& S) const { |
| 350 | S.Emit(SwitchLoc); |
| 351 | S.EmitOwnedPtr(getCond()); |
| 352 | S.EmitOwnedPtr(getBody()); |
| 353 | S.EmitPtr(FirstCase); |
| 354 | } |
| 355 | |
| 356 | SwitchStmt* SwitchStmt::directMaterialize(llvm::Deserializer& D) { |
| 357 | SourceLocation Loc = SourceLocation::ReadVal(D); |
| 358 | Stmt* Cond = D.ReadOwnedPtr<Stmt>(); |
| 359 | Stmt* Body = D.ReadOwnedPtr<Stmt>(); |
| 360 | SwitchCase* FirstCase = cast<SwitchCase>(D.ReadPtr<Stmt>()); |
| 361 | |
| 362 | SwitchStmt* stmt = new SwitchStmt(cast<Expr>(Cond)); |
| 363 | stmt->setBody(Body,Loc); |
| 364 | stmt->FirstCase = FirstCase; |
| 365 | |
| 366 | return stmt; |
| 367 | } |
Ted Kremenek | 55e559a | 2007-11-07 07:50:10 +0000 | [diff] [blame] | 368 | |
| 369 | void WhileStmt::directEmit(llvm::Serializer& S) const { |
| 370 | S.Emit(WhileLoc); |
| 371 | S.EmitOwnedPtr(getCond()); |
| 372 | S.EmitOwnedPtr(getBody()); |
| 373 | } |
| 374 | |
| 375 | WhileStmt* WhileStmt::directMaterialize(llvm::Deserializer& D) { |
| 376 | SourceLocation WhileLoc = SourceLocation::ReadVal(D); |
| 377 | Expr* Cond = D.ReadOwnedPtr<Expr>(); |
| 378 | Stmt* Body = D.ReadOwnedPtr<Stmt>(); |
| 379 | return new WhileStmt(Cond,Body,WhileLoc); |
| 380 | } |