aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/CGExprCXX.cpp5
-rw-r--r--test/CodeGenCXX/new.cpp4
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp
index 79e3b220ef..a5c1691307 100644
--- a/lib/CodeGen/CGExprCXX.cpp
+++ b/lib/CodeGen/CGExprCXX.cpp
@@ -754,7 +754,8 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
AllocType);
}
- const llvm::Type *ElementPtrTy = ConvertType(AllocType)->getPointerTo(AS);
+ const llvm::Type *ElementPtrTy
+ = ConvertTypeForMem(AllocType)->getPointerTo(AS);
NewPtr = Builder.CreateBitCast(NewPtr, ElementPtrTy);
if (E->isArray()) {
EmitNewInitializer(*this, E, NewPtr, NumElements, AllocSizeWithoutCookie);
@@ -762,7 +763,7 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
// NewPtr is a pointer to the base element type. If we're
// allocating an array of arrays, we'll need to cast back to the
// array pointer type.
- const llvm::Type *ResultTy = ConvertType(E->getType());
+ const llvm::Type *ResultTy = ConvertTypeForMem(E->getType());
if (NewPtr->getType() != ResultTy)
NewPtr = Builder.CreateBitCast(NewPtr, ResultTy);
} else {
diff --git a/test/CodeGenCXX/new.cpp b/test/CodeGenCXX/new.cpp
index d52ebbe450..10a6f7f489 100644
--- a/test/CodeGenCXX/new.cpp
+++ b/test/CodeGenCXX/new.cpp
@@ -158,4 +158,8 @@ void f() {
// CHECK: call void @_ZN5AllocD1Ev(
// CHECK: call void @_ZN5AllocdaEPv(i8*
delete[] new Alloc[10][20];
+ // CHECK: call noalias i8* @_Znwm
+ // CHECK: call void @_ZdlPv(i8*
+ delete new bool;
+ // CHECK: ret void
}