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");
llvm::Value *IsNull = Builder.CreateIsNull(NewPtr, "new.isnull");
Builder.CreateCondBr(IsNull, NewEnd, NewNotNull);
EmitBlock(NewNotNull);
+
+ conditional.begin(*this);
}
assert((AllocSize == AllocSizeWithoutCookie) ==
DeactivateCleanupBlock(CallOperatorDelete);
if (NullCheckResult) {
+ conditional.end(*this);
+
Builder.CreateBr(NewEnd);
llvm::BasicBlock *NotNullSource = Builder.GetInsertBlock();
EmitBlock(NewEnd);
}
}
}
+
+// PR9298
+namespace test7 {
+ struct A { A(); ~A(); };
+ struct B {
+ // The throw() operator means that a bad allocation is signalled
+ // with a null return, which means that the initializer is
+ // evaluated conditionally.
+ static void *operator new(size_t size) throw();
+ B(const A&, B*);
+ ~B();
+ };
+
+ // Just make sure the result passes verification.
+ B *test() {
+ return new B(A(), new B(A(), 0));
+ }
+}