From a34b0577629e3a63bc018fa6da903d2617ef71d7 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 8 Nov 2007 00:56:26 +0000 Subject: [PATCH] Revised serialization of CaseStmt to emit all of the owned pointers (its subexpressions) all together in one block at the end. llvm-svn: 43862 --- clang/AST/StmtSerialization.cpp | 11 ++++------- clang/include/clang/AST/Stmt.h | 3 ++- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/clang/AST/StmtSerialization.cpp b/clang/AST/StmtSerialization.cpp index 86d52a4f6811..99a14f2a30fb 100644 --- a/clang/AST/StmtSerialization.cpp +++ b/clang/AST/StmtSerialization.cpp @@ -190,17 +190,14 @@ CallExpr* CallExpr::directMaterialize(Deserializer& D) { void CaseStmt::directEmit(Serializer& S) const { S.Emit(CaseLoc); S.EmitPtr(getNextSwitchCase()); - S.BatchEmitOwnedPtrs(getLHS(),getRHS(),getSubStmt()); + S.BatchEmitOwnedPtrs((unsigned) END_EXPR,&SubExprs[0]); } CaseStmt* CaseStmt::directMaterialize(Deserializer& D) { SourceLocation CaseLoc = SourceLocation::ReadVal(D); - Expr *LHS, *RHS; - Stmt* SubStmt; - D.BatchReadOwnedPtrs(LHS,RHS,SubStmt); - - CaseStmt* stmt = new CaseStmt(LHS,RHS,SubStmt,CaseLoc); - stmt->setNextSwitchCase(D.ReadPtr()); + CaseStmt* stmt = new CaseStmt(NULL,NULL,NULL,CaseLoc); + D.ReadPtr(stmt->NextSwitchCase); + D.BatchReadOwnedPtrs((unsigned) END_EXPR,&stmt->SubExprs[0]); return stmt; } diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h index 7f927b12e13d..c1eeefd5074d 100644 --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -231,10 +231,11 @@ public: // SwitchCase is the base class for CaseStmt and DefaultStmt, class SwitchCase : public Stmt { +protected: // A pointer to the following CaseStmt or DefaultStmt class, // used by SwitchStmt. SwitchCase *NextSwitchCase; -protected: + SwitchCase(StmtClass SC) : Stmt(SC), NextSwitchCase(0) {} public: