diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -4331,6 +4331,11 @@ // If the true case is live, we need to track its region. if (CondExprBool) incrementProfileCounter(expr); + // If a throw expression we need to return dead as lvalue. + if (auto *ThrowExpr = dyn_cast(live->IgnoreParens())) { + EmitCXXThrowExpr(ThrowExpr); + return EmitLValue(dead); + } return EmitLValue(live); } } diff --git a/clang/test/CodeGenCXX/throw-expressions.cpp b/clang/test/CodeGenCXX/throw-expressions.cpp --- a/clang/test/CodeGenCXX/throw-expressions.cpp +++ b/clang/test/CodeGenCXX/throw-expressions.cpp @@ -79,6 +79,13 @@ // CHECK-NOT: call {{.*}}@_ZN6DR15601AD1Ev // CHECK: call {{.*}} @__cxa_atexit({{.*}} @_ZN6DR15601AD1Ev {{.*}} @_ZGRN6DR15601rE // CHECK-NOT: call {{.*}}@_ZN6DR15601AD1Ev + + // PR28184 + void conditional_throw() + { + int a, b; + (true ? throw 0 : a) = 0; + } } // CHECK-LABEL: define void @_Z5test7b(