forked from OSchip/llvm-project
Clean up CodeGenFunction::EmitCastLValue to use the cast kind. Error
out for user-defined conversions instead of crashing. llvm-svn: 80282
This commit is contained in:
parent
e91191630b
commit
ff083ef429
|
@ -1174,12 +1174,22 @@ LValue CodeGenFunction::EmitConditionalOperator(const ConditionalOperator* E) {
|
|||
LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) {
|
||||
// If this is an aggregate-to-aggregate cast, just use the input's address as
|
||||
// the lvalue.
|
||||
if (getContext().hasSameUnqualifiedType(E->getType(),
|
||||
E->getSubExpr()->getType()))
|
||||
if (E->getCastKind() == CastExpr::CK_NoOp)
|
||||
return EmitLValue(E->getSubExpr());
|
||||
|
||||
// If this is an lvalue cast, treat it as a no-op.
|
||||
// FIXME: We shouldn't need to check for this explicitly!
|
||||
if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E))
|
||||
if (ICE->isLvalueCast())
|
||||
return EmitLValue(E->getSubExpr());
|
||||
|
||||
// FIXME: Implement this properly!
|
||||
if (E->getCastKind() == CastExpr::CK_UserDefinedConversion)
|
||||
return EmitUnsupportedLValue(E, "user-defined conversion");
|
||||
|
||||
// Otherwise, we must have a cast from scalar to union.
|
||||
assert(E->getType()->isUnionType() && "Expected scalar-to-union cast");
|
||||
assert(E->getCastKind() == CastExpr::CK_ToUnion &&
|
||||
"Expected scalar-to-union cast");
|
||||
|
||||
// Casts are only lvalues when the source and destination types are the same.
|
||||
llvm::Value *Temp = CreateTempAlloca(ConvertType(E->getType()));
|
||||
|
|
Loading…
Reference in New Issue