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