aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/Expr.h13
-rw-r--r--lib/AST/Expr.cpp7
-rw-r--r--lib/AST/StmtSerialization.cpp2
-rw-r--r--lib/Sema/SemaExpr.cpp2
4 files changed, 16 insertions, 8 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 68e486c21b..55b31b4369 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -1533,17 +1533,18 @@ class OverloadExpr : public Expr {
SourceLocation BuiltinLoc;
SourceLocation RParenLoc;
public:
- OverloadExpr(Expr **args, unsigned nexprs, unsigned idx, QualType t,
- SourceLocation bloc, SourceLocation rploc)
+ OverloadExpr(ASTContext& C, Expr **args, unsigned nexprs, unsigned idx,
+ QualType t, SourceLocation bloc, SourceLocation rploc)
: Expr(OverloadExprClass, t), NumExprs(nexprs), FnIndex(idx),
BuiltinLoc(bloc), RParenLoc(rploc) {
- SubExprs = new Stmt*[nexprs];
+ SubExprs = new (C) Stmt*[nexprs];
for (unsigned i = 0; i != nexprs; ++i)
SubExprs[i] = args[i];
}
- ~OverloadExpr() {
- delete [] SubExprs;
- }
+
+ ~OverloadExpr() {}
+
+ void Destroy(ASTContext& C);
/// arg_begin - Return a pointer to the list of arguments that will be passed
/// to the matching candidate function, skipping over the initial constant
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 904fe5f99c..e541bb8a82 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -1410,6 +1410,13 @@ void SizeOfAlignOfExpr::Destroy(ASTContext& C) {
Expr::Destroy(C);
}
+void OverloadExpr::Destroy(ASTContext& C) {
+ DestroyChildren(C);
+ C.Deallocate(SubExprs);
+ this->~OverloadExpr();
+ C.Deallocate(this);
+}
+
//===----------------------------------------------------------------------===//
// DesignatedInitExpr
//===----------------------------------------------------------------------===//
diff --git a/lib/AST/StmtSerialization.cpp b/lib/AST/StmtSerialization.cpp
index 92713cc633..4d92245f75 100644
--- a/lib/AST/StmtSerialization.cpp
+++ b/lib/AST/StmtSerialization.cpp
@@ -937,7 +937,7 @@ OverloadExpr* OverloadExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) {
// 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);
+ return new OverloadExpr(C, Exprs.begin(), NumExprs, FnIndex, T, BL, RP);
}
void VAArgExpr::EmitImpl(llvm::Serializer& S) const {
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index c12440322d..f881e81bf4 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -4369,7 +4369,7 @@ Sema::ExprResult Sema::ActOnOverloadExpr(ExprTy **args, unsigned NumArgs,
<< OE->getFn()->getSourceRange();
// Remember our match, and continue processing the remaining arguments
// to catch any errors.
- OE = new (Context) OverloadExpr(Args, NumArgs, i,
+ OE = new (Context) OverloadExpr(Context, Args, NumArgs, i,
FnType->getResultType().getNonReferenceType(),
BuiltinLoc, RParenLoc);
}