diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-05-07 21:53:22 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-05-07 21:53:22 +0000 |
commit | ea85232c4096cc7967cc8e79218d443402bf9be6 (patch) | |
tree | 0b0c74deeadc636a660410107cc447a344273626 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 78f05f13ad1289d0b005dfc4ca3a42c781b0712a (diff) | |
download | bcm5719-llvm-ea85232c4096cc7967cc8e79218d443402bf9be6.tar.gz bcm5719-llvm-ea85232c4096cc7967cc8e79218d443402bf9be6.zip |
Don't crash in IRGen if a conditional with 'throw' in one of its branches is
used as a branch condition.
llvm-svn: 181368
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 791c1a81525..75c60edbba5 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -928,6 +928,16 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond, return; } + if (const CXXThrowExpr *Throw = dyn_cast<CXXThrowExpr>(Cond)) { + // Conditional operator handling can give us a throw expression as a + // condition for a case like: + // br(c ? throw x : y, t, f) -> br(c, br(throw x, t, f), br(y, t, f) + // Fold this to: + // br(c, throw x, br(y, t, f)) + EmitCXXThrowExpr(Throw, /*KeepInsertionPoint*/false); + return; + } + // Emit the code with the fully general case. llvm::Value *CondV = EvaluateExprAsBool(Cond); Builder.CreateCondBr(CondV, TrueBlock, FalseBlock); |