summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprCXX.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CGExprCXX.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprCXX.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index bba7864bff9..2b8efa0e39f 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -993,6 +993,10 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
llvm::Value *NewPtr = RV.getScalarVal();
unsigned AS = cast<llvm::PointerType>(NewPtr->getType())->getAddressSpace();
+ // The null-check means that the initializer is conditionally
+ // evaluated.
+ ConditionalEvaluation conditional(*this);
+
if (NullCheckResult) {
NullCheckSource = Builder.GetInsertBlock();
NewNotNull = createBasicBlock("new.notnull");
@@ -1001,6 +1005,8 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
llvm::Value *IsNull = Builder.CreateIsNull(NewPtr, "new.isnull");
Builder.CreateCondBr(IsNull, NewEnd, NewNotNull);
EmitBlock(NewNotNull);
+
+ conditional.begin(*this);
}
assert((AllocSize == AllocSizeWithoutCookie) ==
@@ -1042,6 +1048,8 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
DeactivateCleanupBlock(CallOperatorDelete);
if (NullCheckResult) {
+ conditional.end(*this);
+
Builder.CreateBr(NewEnd);
llvm::BasicBlock *NotNullSource = Builder.GetInsertBlock();
EmitBlock(NewEnd);
OpenPOWER on IntegriCloud