[cfe-commits] r88810 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGenCXX/reinterpret-cast.cpp
Anders Carlsson
andersca at mac.com
Sat Nov 14 13:21:42 PST 2009
Author: andersca
Date: Sat Nov 14 15:21:42 2009
New Revision: 88810
URL: http://llvm.org/viewvc/llvm-project?rev=88810&view=rev
Log:
Handle CK_BitCast in EmitCastLValue.
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/CodeGenCXX/reinterpret-cast.cpp
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=88810&r1=88809&r2=88810&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Sat Nov 14 15:21:42 2009
@@ -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()));
+ }
+
}
}
Modified: cfe/trunk/test/CodeGenCXX/reinterpret-cast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/reinterpret-cast.cpp?rev=88810&r1=88809&r2=88810&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/reinterpret-cast.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/reinterpret-cast.cpp Sat Nov 14 15:21:42 2009
@@ -10,3 +10,8 @@
unsigned long f3(void *p) {
return reinterpret_cast<unsigned long>(p);
}
+
+void f4(int*&);
+void f5(void*& u) {
+ f4(reinterpret_cast<int*&>(u));
+}
\ No newline at end of file
More information about the cfe-commits
mailing list