pch'ify CXXNewExpr and CXXZeroInitValueExpr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103390 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp
index 11d9cf4..f7d93de 100644
--- a/lib/AST/ExprCXX.cpp
+++ b/lib/AST/ExprCXX.cpp
@@ -92,12 +92,11 @@
SourceLocation startLoc, SourceLocation endLoc)
: Expr(CXXNewExprClass, ty, ty->isDependentType(), ty->isDependentType()),
GlobalNew(globalNew), ParenTypeId(parenTypeId),
- Initializer(initializer), Array(arraySize), NumPlacementArgs(numPlaceArgs),
- NumConstructorArgs(numConsArgs), OperatorNew(operatorNew),
+ Initializer(initializer), SubExprs(0), OperatorNew(operatorNew),
OperatorDelete(operatorDelete), Constructor(constructor),
StartLoc(startLoc), EndLoc(endLoc) {
- unsigned TotalSize = Array + NumPlacementArgs + NumConstructorArgs;
- SubExprs = new (C) Stmt*[TotalSize];
+
+ AllocateArgsArray(C, arraySize != 0, numPlaceArgs, numConsArgs);
unsigned i = 0;
if (Array)
SubExprs[i++] = arraySize;
@@ -105,9 +104,20 @@
SubExprs[i++] = placementArgs[j];
for (unsigned j = 0; j < NumConstructorArgs; ++j)
SubExprs[i++] = constructorArgs[j];
- assert(i == TotalSize);
}
+void CXXNewExpr::AllocateArgsArray(ASTContext &C, bool isArray,
+ unsigned numPlaceArgs, unsigned numConsArgs){
+ assert(SubExprs == 0 && "SubExprs already allocated");
+ Array = isArray;
+ NumPlacementArgs = numPlaceArgs;
+ NumConstructorArgs = numConsArgs;
+
+ unsigned TotalSize = Array + NumPlacementArgs + NumConstructorArgs;
+ SubExprs = new (C) Stmt*[TotalSize];
+}
+
+
void CXXNewExpr::DoDestroy(ASTContext &C) {
DestroyChildren(C);
if (SubExprs)