diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-05-08 09:20:56 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-05-08 09:20:56 +0000 |
commit | 6acf861cfca57327d2bb91027f75e3e6f73249b5 (patch) | |
tree | 0890d2178878359a2c5fd6aab07dcc5506f1bc2f /lib/CodeGen/CodeGenFunction.cpp | |
parent | 4066c53654fa11fc2e72e4b3b7f4be9153fadc08 (diff) |
Merging r181368:
------------------------------------------------------------------------
r181368 | rsmith | 2013-05-07 14:53:22 -0700 (Tue, 07 May 2013) | 3 lines
Don't crash in IRGen if a conditional with 'throw' in one of its branches is
used as a branch condition.
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_33@181401 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 791c1a8152..75c60edbba 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/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); |