[cfe-commits] r90800 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGenCXX/throw-expressions.cpp
Eli Friedman
eli.friedman at gmail.com
Mon Dec 7 12:25:53 PST 2009
Author: efriedma
Date: Mon Dec 7 14:25:53 2009
New Revision: 90800
URL: http://llvm.org/viewvc/llvm-project?rev=90800&view=rev
Log:
Correctly handle conditional operators involving throw.
Added:
cfe/trunk/test/CodeGenCXX/throw-expressions.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=90800&r1=90799&r2=90800&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Mon Dec 7 14:25:53 2009
@@ -1868,10 +1868,11 @@
CGF.EmitBlock(ContBlock);
- if (!LHS || !RHS) {
- assert(E->getType()->isVoidType() && "Non-void value should have a value");
- return 0;
- }
+ // If the LHS or RHS is a throw expression, it will be legitimately null.
+ if (!LHS)
+ return RHS;
+ if (!RHS)
+ return LHS;
// Create a PHI node for the real part.
llvm::PHINode *PN = Builder.CreatePHI(LHS->getType(), "cond");
Added: cfe/trunk/test/CodeGenCXX/throw-expressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/throw-expressions.cpp?rev=90800&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/throw-expressions.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/throw-expressions.cpp Mon Dec 7 14:25:53 2009
@@ -0,0 +1,10 @@
+// RUN: clang-cc -emit-llvm-only -verify %s
+
+int val = 42;
+int& test1() {
+ return throw val, val;
+}
+
+int test2() {
+ return val ? throw val : val;
+}
More information about the cfe-commits
mailing list