diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-10-15 17:52:29 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-10-15 17:52:29 +0000 |
commit | 20c77e995d5f1bad8fc59fe9e1883a563d94f535 (patch) | |
tree | 2178028fea32061fadee815c9047a799ae89dec3 /lib/AST/StmtSerialization.cpp | |
parent | bc4f4030e245e36642f894d848f6a8bf94426cc2 (diff) |
Use BatchEmitOwnedPtrs for writing multiple child exprs, per review.
Also added serialization support to OverloadExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57588 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/StmtSerialization.cpp')
-rw-r--r-- | lib/AST/StmtSerialization.cpp | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/lib/AST/StmtSerialization.cpp b/lib/AST/StmtSerialization.cpp index a6bcf7e8b5..baee030144 100644 --- a/lib/AST/StmtSerialization.cpp +++ b/lib/AST/StmtSerialization.cpp @@ -827,8 +827,7 @@ void ShuffleVectorExpr::EmitImpl(llvm::Serializer& S) const { S.Emit(BuiltinLoc); S.Emit(RParenLoc); S.EmitInt(NumExprs); - for (unsigned i = 0; i < NumExprs; ++i) - S.EmitOwnedPtr(getExpr(i)); + S.BatchEmitOwnedPtrs(NumExprs, &SubExprs[0]); } ShuffleVectorExpr* ShuffleVectorExpr::CreateImpl(llvm::Deserializer& D, @@ -837,10 +836,9 @@ ShuffleVectorExpr* ShuffleVectorExpr::CreateImpl(llvm::Deserializer& D, SourceLocation BL = SourceLocation::ReadVal(D); SourceLocation RP = SourceLocation::ReadVal(D); unsigned NumExprs = D.ReadInt(); + // FIXME: Avoid extra allocation. llvm::SmallVector<Expr*, 4> Exprs(NumExprs); - for (unsigned i = 0; i < NumExprs; ++i) - Exprs[i] = D.ReadOwnedPtr<Expr>(C); - + D.BatchReadOwnedPtrs(NumExprs, Exprs.begin(), C); return new ShuffleVectorExpr(Exprs.begin(), NumExprs, T, BL, RP); } @@ -848,19 +846,37 @@ void ChooseExpr::EmitImpl(llvm::Serializer& S) const { S.Emit(getType()); S.Emit(BuiltinLoc); S.Emit(RParenLoc); - S.EmitOwnedPtr(getCond()); - S.EmitOwnedPtr(getLHS()); - S.EmitOwnedPtr(getRHS()); + S.BatchEmitOwnedPtrs((unsigned) END_EXPR, &SubExprs[0]); } ChooseExpr* ChooseExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { QualType T = QualType::ReadVal(D); SourceLocation BL = SourceLocation::ReadVal(D); SourceLocation RP = SourceLocation::ReadVal(D); - Expr *Cond = D.ReadOwnedPtr<Expr>(C); - Expr *LHS = D.ReadOwnedPtr<Expr>(C); - Expr *RHS = D.ReadOwnedPtr<Expr>(C); - return new ChooseExpr(BL, Cond, LHS, RHS, T, RP); + ChooseExpr *CE = new ChooseExpr(BL, 0, 0, 0, T, RP); + D.BatchReadOwnedPtrs((unsigned) END_EXPR, &CE->SubExprs[0], C); + return CE; +} + +void OverloadExpr::EmitImpl(llvm::Serializer& S) const { + S.Emit(getType()); + S.Emit(BuiltinLoc); + S.Emit(RParenLoc); + S.EmitInt(FnIndex); + S.EmitInt(NumExprs); + S.BatchEmitOwnedPtrs(NumExprs, &SubExprs[0]); +} + +OverloadExpr* OverloadExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) { + QualType T = QualType::ReadVal(D); + SourceLocation BL = SourceLocation::ReadVal(D); + SourceLocation RP = SourceLocation::ReadVal(D); + unsigned FnIndex = D.ReadInt(); + unsigned NumExprs = D.ReadInt(); + // FIXME: Avoid extra allocation. + llvm::SmallVector<Expr*, 4> Exprs(NumExprs); + D.BatchReadOwnedPtrs(NumExprs, Exprs.begin(), C); + return new OverloadExpr(Exprs.begin(), NumExprs, FnIndex, T, BL, RP); } void VAArgExpr::EmitImpl(llvm::Serializer& S) const { |