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