diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-11-10 22:39:09 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-11-10 22:39:09 +0000 |
commit | 7f1de456fe6b6fb6d3fb8144df6173d2354f595a (patch) | |
tree | c9ec8c29e098eac40ec9fe666129c57cb3dc2a2f | |
parent | 69a2c268dbc2844bbdecfbbbb82602e6bb4bd1df (diff) |
Fix for PR5454: make sure to use the right block as the predecessor in the
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
-rw-r--r-- | lib/CodeGen/CGCXXExpr.cpp | 1 | ||||
-rw-r--r-- | test/CodeGenCXX/new-operator-phi.cpp | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/CodeGen/CGCXXExpr.cpp b/lib/CodeGen/CGCXXExpr.cpp index 2d62df6c58..8b0490fe32 100644 --- a/lib/CodeGen/CGCXXExpr.cpp +++ b/lib/CodeGen/CGCXXExpr.cpp @@ -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 index 0000000000..d4c698d063 --- /dev/null +++ b/test/CodeGenCXX/new-operator-phi.cpp @@ -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()); +} + |