]> granicus.if.org Git - clang/commitdiff
Allocate the subexpression array for OberloadExpr from ASTContext's allocator.
authorTed Kremenek <kremenek@apple.com>
Mon, 9 Feb 2009 17:08:14 +0000 (17:08 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 9 Feb 2009 17:08:14 +0000 (17:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64145 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Expr.h
lib/AST/Expr.cpp
lib/AST/StmtSerialization.cpp
lib/Sema/SemaExpr.cpp

index 68e486c21ba06a575436658f3741e4cd12a2da41..55b31b4369861a892a902c285ee1c1a8e40b1447 100644 (file)
@@ -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
index 904fe5f99c345176297bd7edfae409b1d3a7d7cb..e541bb8a825f5d1b8a9ec96b7bc65f3dd4855a55 100644 (file)
@@ -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
 //===----------------------------------------------------------------------===//
index 92713cc633126743e1660f6432f48ad891588a30..4d92245f7525dd7657119ac2c2e40bacc5541502 100644 (file)
@@ -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 {
index c12440322d0a55ad6367f3ad733c35b2be353f27..f881e81bf4592e69d17c4bda82ab99c066515446 100644 (file)
@@ -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);
     }