diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-10-18 02:43:19 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-10-18 02:43:19 +0000 |
commit | 4e8ea0b2e163aa9681e2f14ad75ab4990a69d39b (patch) | |
tree | b0159e120678920c424a071eb9cb8cb2f63ab489 /lib/Sema/TreeTransform.h | |
parent | 3e2e91e934ecf083a7c0835b58d9627ca2faddc9 (diff) |
When transforming the arguments for a C++ "new" expression, make sure
to drop the implicitly-generated value initialization expression used
for initializing scalars. Fixes <rdar://problem/10283928>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142330 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/TreeTransform.h')
-rw-r--r-- | lib/Sema/TreeTransform.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index bb49eee2f3..64315ea15d 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -6927,9 +6927,14 @@ TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) { PlacementArgs, &ArgumentChanged)) return ExprError(); - // transform the constructor arguments (if any). + // Transform the constructor arguments (if any). + // As an annoying corner case, we may have introduced an implicit value- + // initialization expression when allocating a new array, which we implicitly + // drop. It will be re-created during type checking. ASTOwningVector<Expr*> ConstructorArgs(SemaRef); - if (TransformExprs(E->getConstructorArgs(), E->getNumConstructorArgs(), true, + if (!(E->isArray() && E->getNumConstructorArgs() == 1 && + isa<ImplicitValueInitExpr>(E->getConstructorArgs()[0])) && + TransformExprs(E->getConstructorArgs(), E->getNumConstructorArgs(), true, ConstructorArgs, &ArgumentChanged)) return ExprError(); @@ -7028,13 +7033,9 @@ TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) { AllocType, AllocTypeInfo, ArraySize.get(), - /*FIXME:*/E->hasInitializer() - ? E->getLocStart() - : SourceLocation(), + E->getConstructorLParen(), move_arg(ConstructorArgs), - /*FIXME:*/E->hasInitializer() - ? E->getLocEnd() - : SourceLocation()); + E->getConstructorRParen()); } template<typename Derived> |