[cfe-commits] r57502 - in /cfe/trunk: include/clang/AST/Expr.h include/clang/AST/ExprObjC.h lib/AST/StmtSerialization.cpp
Ted Kremenek
kremenek at apple.com
Tue Oct 14 16:48:00 PDT 2008
On Oct 14, 2008, at 9:57 AM, Daniel Dunbar wrote:
> +void ShuffleVectorExpr::EmitImpl(llvm::Serializer& S) const {
> + S.Emit(getType());
> + S.Emit(BuiltinLoc);
> + S.Emit(RParenLoc);
> + S.EmitInt(NumExprs);
> + for (unsigned i = 0; i < NumExprs; ++i)
> + S.EmitOwnedPtr(getExpr(i));
> +}
> +
> +ShuffleVectorExpr*
> ShuffleVectorExpr::CreateImpl(llvm::Deserializer& D,
> + ASTContext& C) {
> + QualType T = QualType::ReadVal(D);
> + SourceLocation BL = SourceLocation::ReadVal(D);
> + SourceLocation RP = SourceLocation::ReadVal(D);
> + unsigned NumExprs = D.ReadInt();
> + llvm::SmallVector<Expr*, 4> Exprs(NumExprs);
> + for (unsigned i = 0; i < NumExprs; ++i)
> + Exprs[i] = D.ReadOwnedPtr<Expr>(C);
> +
> + return new ShuffleVectorExpr(Exprs.begin(), NumExprs, T, BL, RP);
> +}
Daniel,
You might want to consider using BatchEmitOwnedPtr instead of emitting
each owned pointer out separately using EmitOwnedPtr. It has two
benefits:
(a) less code
(b) smaller footprint on disk (all of the persistent pointers are
stored together, followed by the separate records for each object they
point to).
Ted
More information about the cfe-commits
mailing list