aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprScalar.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2011-10-15 02:10:40 +0000
committerEli Friedman <eli.friedman@gmail.com>2011-10-15 02:10:40 +0000
commitc8645e38bfe5ab46e424b7aaca53c064105c4265 (patch)
tree942995b142ce538fcd236f64a33a76d87cbc8042 /lib/CodeGen/CGExprScalar.cpp
parentd79e4628da88b58e9913008ff32f2e1ca785a4e7 (diff)
Handle an edge case involving the conditional operator and throw expressions. PR10582.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142047 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r--lib/CodeGen/CGExprScalar.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 3a9fbeed9d..b088103aa3 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -2503,11 +2503,18 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
Expr *live = lhsExpr, *dead = rhsExpr;
if (!CondExprBool) std::swap(live, dead);
- // If the dead side doesn't have labels we need, and if the Live side isn't
- // the gnu missing ?: extension (which we could handle, but don't bother
- // to), just emit the Live part.
- if (!CGF.ContainsLabel(dead))
- return Visit(live);
+ // If the dead side doesn't have labels we need, just emit the Live part.
+ if (!CGF.ContainsLabel(dead)) {
+ Value *Result = Visit(live);
+
+ // If the live part is a throw expression, it acts like it has a void
+ // type, so evaluating it returns a null Value*. However, a conditional
+ // with non-void type must return a non-null Value*.
+ if (!Result && !E->getType()->isVoidType())
+ Result = llvm::UndefValue::get(CGF.ConvertType(E->getType()));
+
+ return Result;
+ }
}
// OpenCL: If the condition is a vector, we can treat this condition like