diff options
| author | Anders Carlsson <andersca@mac.com> | 2009-11-22 19:25:33 +0000 |
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2009-11-22 19:25:33 +0000 |
| commit | 5838108317e92649deee8a52e5463eb293ff1c0b (patch) | |
| tree | 14ca3725335de1e8e6a39fc13af984d0e76a0ff1 | |
| parent | 00e9c6103bb452a3681b960564983b343368456a (diff) | |
| download | bcm5719-llvm-5838108317e92649deee8a52e5463eb293ff1c0b.tar.gz bcm5719-llvm-5838108317e92649deee8a52e5463eb293ff1c0b.zip | |
Use EmitStoreOfScalar when copying the scalar to the space allocated by 'new'.
llvm-svn: 89613
| -rw-r--r-- | clang/lib/CodeGen/CGCXXExpr.cpp | 5 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/new.cpp | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGCXXExpr.cpp b/clang/lib/CodeGen/CGCXXExpr.cpp index 409296f7161..845669d4021 100644 --- a/clang/lib/CodeGen/CGCXXExpr.cpp +++ b/clang/lib/CodeGen/CGCXXExpr.cpp @@ -103,8 +103,9 @@ static void EmitNewInitializer(CodeGenFunction &CGF, const CXXNewExpr *E, const Expr *Init = E->getConstructorArg(0); - if (!CGF.hasAggregateLLVMType(AllocType)) - CGF.Builder.CreateStore(CGF.EmitScalarExpr(Init), NewPtr); + if (!CGF.hasAggregateLLVMType(AllocType)) + CGF.EmitStoreOfScalar(CGF.EmitScalarExpr(Init), NewPtr, + AllocType.isVolatileQualified(), AllocType); else if (AllocType->isAnyComplexType()) CGF.EmitComplexExprIntoAddr(Init, NewPtr, AllocType.isVolatileQualified()); diff --git a/clang/test/CodeGenCXX/new.cpp b/clang/test/CodeGenCXX/new.cpp index 3f191de23bc..ddf1f9b3c90 100644 --- a/clang/test/CodeGenCXX/new.cpp +++ b/clang/test/CodeGenCXX/new.cpp @@ -72,3 +72,10 @@ void t8(int n) { new U[10]; new U[n]; } + +void t9() { + bool b; + + new bool(true); + new (&b) bool(true); +} |

