]> granicus.if.org Git - clang/commitdiff
Fix for PR5454: make sure to use the right block as the predecessor in the
authorEli Friedman <eli.friedman@gmail.com>
Tue, 10 Nov 2009 22:39:09 +0000 (22:39 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 10 Nov 2009 22:39:09 +0000 (22:39 +0000)
generated PHI node for the null check of a new operator.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86738 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXXExpr.cpp
test/CodeGenCXX/new-operator-phi.cpp [new file with mode: 0644]

index 2d62df6c58a44f1b618374e79fb4127a88eb1433..8b0490fe323c2c4d86a7bf7860e15bfcbe6a2f11 100644 (file)
@@ -218,6 +218,7 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
 
   if (NullCheckResult) {
     Builder.CreateBr(NewEnd);
+    NewNotNull = Builder.GetInsertBlock();
     EmitBlock(NewNull);
     Builder.CreateBr(NewEnd);
     EmitBlock(NewEnd);
diff --git a/test/CodeGenCXX/new-operator-phi.cpp b/test/CodeGenCXX/new-operator-phi.cpp
new file mode 100644 (file)
index 0000000..d4c698d
--- /dev/null
@@ -0,0 +1,10 @@
+// RUN: clang-cc -emit-llvm-only -verify %s
+// PR5454
+
+class X {static void * operator new(unsigned size) throw(); X(int); };
+int a(), b();
+void b(int x)
+{
+  new X(x ? a() : b());
+}
+