SourceLocation EndLoc;
public:
- CXXNewExpr(bool globalNew, FunctionDecl *operatorNew, Expr **placementArgs,
- unsigned numPlaceArgs, bool ParenTypeId, Expr *arraySize,
- CXXConstructorDecl *constructor, bool initializer,
+ CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
+ Expr **placementArgs, unsigned numPlaceArgs, bool ParenTypeId,
+ Expr *arraySize, CXXConstructorDecl *constructor, bool initializer,
Expr **constructorArgs, unsigned numConsArgs,
FunctionDecl *operatorDelete, QualType ty,
SourceLocation startLoc, SourceLocation endLoc);
- ~CXXNewExpr() {
- delete[] SubExprs;
- }
+
+ virtual void DoDestroy(ASTContext &C);
QualType getAllocatedType() const {
assert(getType()->isPointerType());
}
// CXXNewExpr
-CXXNewExpr::CXXNewExpr(bool globalNew, FunctionDecl *operatorNew,
+CXXNewExpr::CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
Expr **placementArgs, unsigned numPlaceArgs,
bool parenTypeId, Expr *arraySize,
CXXConstructorDecl *constructor, bool initializer,
OperatorDelete(operatorDelete), Constructor(constructor),
StartLoc(startLoc), EndLoc(endLoc) {
unsigned TotalSize = Array + NumPlacementArgs + NumConstructorArgs;
- SubExprs = new Stmt*[TotalSize];
+ SubExprs = new (C) Stmt*[TotalSize];
unsigned i = 0;
if (Array)
SubExprs[i++] = arraySize;
assert(i == TotalSize);
}
+void CXXNewExpr::DoDestroy(ASTContext &C) {
+ DestroyChildren(C);
+ if (SubExprs)
+ C.Deallocate(SubExprs);
+ this->~CXXNewExpr();
+ C.Deallocate((void*)this);
+}
+
Stmt::child_iterator CXXNewExpr::child_begin() { return &SubExprs[0]; }
Stmt::child_iterator CXXNewExpr::child_end() {
return &SubExprs[0] + Array + getNumPlacementArgs() + getNumConstructorArgs();
PlacementArgs.release();
ConstructorArgs.release();
ArraySizeE.release();
- return Owned(new (Context) CXXNewExpr(UseGlobal, OperatorNew, PlaceArgs,
- NumPlaceArgs, ParenTypeId, ArraySize, Constructor, Init,
- ConsArgs, NumConsArgs, OperatorDelete, ResultType,
- StartLoc, Init ? ConstructorRParen : SourceLocation()));
+ return Owned(new (Context) CXXNewExpr(Context, UseGlobal, OperatorNew,
+ PlaceArgs, NumPlaceArgs, ParenTypeId,
+ ArraySize, Constructor, Init,
+ ConsArgs, NumConsArgs, OperatorDelete,
+ ResultType, StartLoc,
+ Init ? ConstructorRParen :
+ SourceLocation()));
}
/// CheckAllocatedType - Checks that a type is suitable as the allocated type