From 35e20410aa73389564394fcbce71709250b744e5 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 7 Nov 2007 08:02:55 +0000 Subject: [PATCH] Implemented serialization for ForStmt. llvm-svn: 43817 --- clang/AST/StmtSerialization.cpp | 20 ++++++++++++++++++++ clang/include/clang/AST/Stmt.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/clang/AST/StmtSerialization.cpp b/clang/AST/StmtSerialization.cpp index d7b497155a40..61e70ecde822 100644 --- a/clang/AST/StmtSerialization.cpp +++ b/clang/AST/StmtSerialization.cpp @@ -54,6 +54,9 @@ Stmt* Stmt::Materialize(llvm::Deserializer& D) { case DoStmtClass: return DoStmt::directMaterialize(D); + + case ForStmtClass: + return ForStmt::directMaterialize(D); case IfStmtClass: return IfStmt::directMaterialize(D); @@ -204,6 +207,23 @@ DoStmt* DoStmt::directMaterialize(llvm::Deserializer& D) { return new DoStmt(Body,Cond,DoLoc); } +void ForStmt::directEmit(llvm::Serializer& S) const { + S.Emit(ForLoc); + S.EmitOwnedPtr(getInit()); + S.EmitOwnedPtr(getCond()); + S.EmitOwnedPtr(getInc()); + S.EmitOwnedPtr(getBody()); +} + +ForStmt* ForStmt::directMaterialize(llvm::Deserializer& D) { + SourceLocation ForLoc = SourceLocation::ReadVal(D); + Stmt* Init = D.ReadOwnedPtr(); + Expr* Cond = D.ReadOwnedPtr(); + Expr* Inc = D.ReadOwnedPtr(); + Stmt* Body = D.ReadOwnedPtr(); + return new ForStmt(Init,Cond,Inc,Body,ForLoc); +} + void IfStmt::directEmit(llvm::Serializer& S) const { S.Emit(IfLoc); S.EmitOwnedPtr(getCond()); diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h index 284501269d2f..ed44687da040 100644 --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -565,6 +565,9 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); + + virtual void directEmit(llvm::Serializer& S) const; + static ForStmt* directMaterialize(llvm::Deserializer& D); }; /// GotoStmt - This represents a direct goto.