summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
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
commit27ef75b0be63c87322ff564948bc857825ff91d4 (patch)
tree923e4935c4a94664161c96abc06c9ffd117862d7 /clang/lib/CodeGen
parent559b8f2ae9d77a262a01af1051f363dd2822d153 (diff)
downloadbcm5719-llvm-27ef75b0be63c87322ff564948bc857825ff91d4.tar.gz
bcm5719-llvm-27ef75b0be63c87322ff564948bc857825ff91d4.zip
Handle an edge case involving the conditional operator and throw expressions. PR10582.
llvm-svn: 142047
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 3a9fbeed9d6..b088103aa35 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/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
OpenPOWER on IntegriCloud