From: Ted Kremenek Date: Wed, 14 Nov 2007 21:31:46 +0000 (+0000) Subject: Implemented serialization of InitListExpr. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6336f8dbae5145eb7b1429a8ec424c44e668f7cb;p=clang Implemented serialization of InitListExpr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44137 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/AST/StmtSerialization.cpp b/AST/StmtSerialization.cpp index 2c1205ef7a..d4ddf4c57f 100644 --- a/AST/StmtSerialization.cpp +++ b/AST/StmtSerialization.cpp @@ -108,7 +108,10 @@ Stmt* Stmt::Create(Deserializer& D) { return ImplicitCastExpr::CreateImpl(D); case IndirectGotoStmtClass: - return IndirectGotoStmt::CreateImpl(D); + return IndirectGotoStmt::CreateImpl(D); + + case InitListExprClass: + return InitListExpr::CreateImpl(D); case IntegerLiteralClass: return IntegerLiteral::CreateImpl(D); @@ -512,6 +515,24 @@ IndirectGotoStmt* IndirectGotoStmt::CreateImpl(Deserializer& D) { return new IndirectGotoStmt(Target); } +void InitListExpr::EmitImpl(Serializer& S) const { + S.Emit(LBraceLoc); + S.Emit(RBraceLoc); + S.EmitInt(NumInits); + S.BatchEmitOwnedPtrs(NumInits,InitExprs); +} + +InitListExpr* InitListExpr::CreateImpl(Deserializer& D) { + InitListExpr* expr = new InitListExpr(); + expr->LBraceLoc = SourceLocation::ReadVal(D); + expr->RBraceLoc = SourceLocation::ReadVal(D); + expr->NumInits = D.ReadInt(); + assert(expr->NumInits); + expr->InitExprs = new Expr*[expr->NumInits]; + D.BatchReadOwnedPtrs(expr->NumInits,expr->InitExprs); + return expr; +} + void IntegerLiteral::EmitImpl(Serializer& S) const { S.Emit(Loc); S.Emit(getType()); diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 6216de7039..7dead68a57 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -1126,6 +1126,14 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); + + virtual void EmitImpl(llvm::Serializer& S) const; + static InitListExpr* CreateImpl(llvm::Deserializer& D); + +private: + // Used by serializer. + InitListExpr() : Expr(InitListExprClass, QualType()), + InitExprs(NULL), NumInits(0) {} }; /// ObjCStringLiteral, used for Objective-C string literals