Handle CK_BitCast in EmitCastLValue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88810 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index c297903..c446c03 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -1302,7 +1302,7 @@
if (ICE->isLvalueCast())
return EmitLValue(E->getSubExpr());
- assert(0 && "Unhandled cast!");
+ assert(false && "Unhandled cast!");
case CastExpr::CK_NoOp:
case CastExpr::CK_ConstructorConversion:
@@ -1327,13 +1327,22 @@
return LValue::MakeAddr(Base, MakeQualifiers(E->getType()));
}
-
case CastExpr::CK_ToUnion: {
llvm::Value *Temp = CreateTempAlloca(ConvertType(E->getType()));
EmitAnyExpr(E->getSubExpr(), Temp, false);
return LValue::MakeAddr(Temp, MakeQualifiers(E->getType()));
- }
+ }
+ case CastExpr::CK_BitCast: {
+ // This must be a reinterpret_cast.
+ const CXXReinterpretCastExpr *CE = cast<CXXReinterpretCastExpr>(E);
+
+ LValue LV = EmitLValue(E->getSubExpr());
+ llvm::Value *V = Builder.CreateBitCast(LV.getAddress(),
+ ConvertType(CE->getTypeAsWritten()));
+ return LValue::MakeAddr(V, MakeQualifiers(E->getType()));
+ }
+
}
}