aboutsummaryrefslogtreecommitdiff
path: root/lib/AST
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AST')
-rw-r--r--lib/AST/Expr.cpp20
-rw-r--r--lib/AST/ExprCXX.cpp4
-rw-r--r--lib/AST/Stmt.cpp2
-rw-r--r--lib/AST/StmtSerialization.cpp25
4 files changed, 26 insertions, 25 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 89fdbe31f3..d686167cd0 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -54,8 +54,8 @@ StringLiteral::StringLiteral(ASTContext& C, const char *strData,
}
void StringLiteral::Destroy(ASTContext &C) {
- C.Deallocate(const_cast<char*>(StrData));
this->~StringLiteral();
+ C.Deallocate(const_cast<char*>(StrData));
}
bool UnaryOperator::isPostfix(Opcode Op) {
@@ -104,8 +104,8 @@ const char *UnaryOperator::getOpcodeStr(Opcode Op) {
// Postfix Operators.
//===----------------------------------------------------------------------===//
-CallExpr::CallExpr(StmtClass SC, Expr *fn, Expr **args, unsigned numargs,
- QualType t, SourceLocation rparenloc)
+CallExpr::CallExpr(StmtClass SC, Expr *fn, Expr **args,
+ unsigned numargs, QualType t, SourceLocation rparenloc)
: Expr(SC, t,
fn->isTypeDependent() || hasAnyTypeDependentArguments(args, numargs),
fn->isValueDependent() || hasAnyValueDependentArguments(args, numargs)),
@@ -133,14 +133,14 @@ CallExpr::CallExpr(Expr *fn, Expr **args, unsigned numargs, QualType t,
/// setNumArgs - This changes the number of arguments present in this call.
/// Any orphaned expressions are deleted by this, and any new operands are set
/// to null.
-void CallExpr::setNumArgs(unsigned NumArgs) {
+void CallExpr::setNumArgs(ASTContext& C, unsigned NumArgs) {
// No change, just return.
if (NumArgs == getNumArgs()) return;
// If shrinking # arguments, just delete the extras and forgot them.
if (NumArgs < getNumArgs()) {
for (unsigned i = NumArgs, e = getNumArgs(); i != e; ++i)
- delete getArg(i);
+ getArg(i)->Destroy(C);
this->NumArgs = NumArgs;
return;
}
@@ -154,7 +154,7 @@ void CallExpr::setNumArgs(unsigned NumArgs) {
for (unsigned i = getNumArgs()+ARGS_START; i != NumArgs+ARGS_START; ++i)
NewSubExprs[i] = 0;
- delete[] SubExprs;
+ delete [] SubExprs;
SubExprs = NewSubExprs;
this->NumArgs = NumArgs;
}
@@ -1391,10 +1391,10 @@ void SizeOfAlignOfExpr::Destroy(ASTContext& C) {
// will iterate over the size expression. However, this expression belongs
// to the type, not to this, so we don't want to delete it.
// We still want to delete this expression.
- // FIXME: Same as in Stmt::Destroy - will be eventually in ASTContext's
- // pool allocator.
- if (isArgumentType())
- delete this;
+ if (isArgumentType()) {
+ this->~SizeOfAlignOfExpr();
+ C.Deallocate(this);
+ }
else
Expr::Destroy(C);
}
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp
index b328c1ef3d..801a0f22e2 100644
--- a/lib/AST/ExprCXX.cpp
+++ b/lib/AST/ExprCXX.cpp
@@ -20,10 +20,10 @@ void CXXConditionDeclExpr::Destroy(ASTContext& C) {
// FIXME: Cannot destroy the decl here, because it is linked into the
// DeclContext's chain.
//getVarDecl()->Destroy(C);
- delete this;
+ this->~CXXConditionDeclExpr();
+ C.Deallocate(this);
}
-
//===----------------------------------------------------------------------===//
// Child Iterators for iterating over subexpressions/substatements
//===----------------------------------------------------------------------===//
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index 541bb0401c..49c8c80509 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -219,7 +219,7 @@ Stmt::child_iterator NullStmt::child_end() { return child_iterator(); }
// CompoundStmt
Stmt::child_iterator CompoundStmt::child_begin() { return &Body[0]; }
-Stmt::child_iterator CompoundStmt::child_end() { return &Body[0]+Body.size(); }
+Stmt::child_iterator CompoundStmt::child_end() { return &Body[0]+NumStmts; }
// CaseStmt
Stmt::child_iterator CaseStmt::child_begin() { return &SubExprs[0]; }
diff --git a/lib/AST/StmtSerialization.cpp b/lib/AST/StmtSerialization.cpp
index 8d6636d6a6..92713cc633 100644
--- a/lib/AST/StmtSerialization.cpp
+++ b/lib/AST/StmtSerialization.cpp
@@ -483,7 +483,8 @@ void CompoundLiteralExpr::EmitImpl(Serializer& S) const {
S.EmitOwnedPtr(Init);
}
-CompoundLiteralExpr* CompoundLiteralExpr::CreateImpl(Deserializer& D, ASTContext& C) {
+CompoundLiteralExpr* CompoundLiteralExpr::CreateImpl(Deserializer& D,
+ ASTContext& C) {
QualType Q = QualType::ReadVal(D);
SourceLocation L = SourceLocation::ReadVal(D);
bool fileScope = D.ReadBool();
@@ -495,10 +496,8 @@ CompoundLiteralExpr* CompoundLiteralExpr::CreateImpl(Deserializer& D, ASTContext
void CompoundStmt::EmitImpl(Serializer& S) const {
S.Emit(LBracLoc);
S.Emit(RBracLoc);
- S.Emit(Body.size());
-
- for (const_body_iterator I=body_begin(), E=body_end(); I!=E; ++I)
- S.EmitOwnedPtr(*I);
+ S.Emit(NumStmts);
+ if (NumStmts) S.BatchEmitOwnedPtrs(NumStmts, &Body[0]);
}
CompoundStmt* CompoundStmt::CreateImpl(Deserializer& D, ASTContext& C) {
@@ -507,13 +506,15 @@ CompoundStmt* CompoundStmt::CreateImpl(Deserializer& D, ASTContext& C) {
unsigned size = D.ReadInt();
CompoundStmt* stmt = new (C, llvm::alignof<CompoundStmt>())
- CompoundStmt(NULL, 0, LB, RB);
-
- stmt->Body.reserve(size);
-
- for (unsigned i = 0; i < size; ++i)
- stmt->Body.push_back(D.ReadOwnedPtr<Stmt>(C));
+ CompoundStmt(C, NULL, 0, LB, RB);
+
+ stmt->NumStmts = size;
+ if (size) {
+ stmt->Body = new (C) Stmt*[size];
+ D.BatchReadOwnedPtrs(size, &stmt->Body[0], C);
+ }
+
return stmt;
}
@@ -1306,7 +1307,7 @@ ExtVectorElementExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C) {
Expr *B = D.ReadOwnedPtr<Expr>(C);
IdentifierInfo *A = D.ReadPtr<IdentifierInfo>();
SourceLocation AL = SourceLocation::ReadVal(D);
- return new ExtVectorElementExpr(T, B, *A, AL);
+ return new (C) ExtVectorElementExpr(T, B, *A, AL);
}
void BlockExpr::EmitImpl(Serializer& S) const {