aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ExprCXX.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-05-10 01:22:27 +0000
committerChris Lattner <sabre@nondot.org>2010-05-10 01:22:27 +0000
commit5921863d8f24084797863b5df37842113bac4352 (patch)
tree99e795337ccbfeb966464e5109b4e297c2eae6d7 /lib/AST/ExprCXX.cpp
parentddfe960d252a93525692b547945236d361d1929f (diff)
pch'ify CXXNewExpr and CXXZeroInitValueExpr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103390 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprCXX.cpp')
-rw-r--r--lib/AST/ExprCXX.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp
index 11d9cf4055..f7d93de015 100644
--- a/lib/AST/ExprCXX.cpp
+++ b/lib/AST/ExprCXX.cpp
@@ -92,12 +92,11 @@ CXXNewExpr::CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
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 @@ CXXNewExpr::CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
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)