[cfe-commits] r80282 - /cfe/trunk/lib/CodeGen/CGExpr.cpp
Eli Friedman
eli.friedman at gmail.com
Thu Aug 27 14:19:33 PDT 2009
Author: efriedma
Date: Thu Aug 27 16:19:33 2009
New Revision: 80282
URL: http://llvm.org/viewvc/llvm-project?rev=80282&view=rev
Log:
Clean up CodeGenFunction::EmitCastLValue to use the cast kind. Error
out for user-defined conversions instead of crashing.
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=80282&r1=80281&r2=80282&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Aug 27 16:19:33 2009
@@ -1174,12 +1174,22 @@
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()));
More information about the cfe-commits
mailing list