summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-08-07 11:51:51 +0000
committerDouglas Gregor <dgregor@apple.com>2010-08-07 11:51:51 +0000
commit8b2d2fe234163745794605ef643d60f0c4875207 (patch)
tree01f602455ca46905267e741786ccfd1c2cf2cfa8 /clang/lib/CodeGen
parentbe051731054256489b3d8571009f059b6ae2c3b4 (diff)
downloadbcm5719-llvm-8b2d2fe234163745794605ef643d60f0c4875207.tar.gz
bcm5719-llvm-8b2d2fe234163745794605ef643d60f0c4875207.zip
Allow reference binding of a reference of Objective-C object type to
an lvalue of another, compatible Objective-C object type (e.g., a subclass). Introduce a new initialization sequence step kind to describe this binding, along with a new cast kind. Fixes PR7741. llvm-svn: 110513
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp7
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp8
2 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 9424776898b..e2ccf55f937 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1851,6 +1851,13 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) {
ConvertType(CE->getTypeAsWritten()));
return LValue::MakeAddr(V, MakeQualifiers(E->getType()));
}
+ case CastExpr::CK_ObjCObjectLValueCast: {
+ LValue LV = EmitLValue(E->getSubExpr());
+ QualType ToType = getContext().getLValueReferenceType(E->getType());
+ llvm::Value *V = Builder.CreateBitCast(LV.getAddress(),
+ ConvertType(ToType));
+ return LValue::MakeAddr(V, MakeQualifiers(E->getType()));
+ }
}
llvm_unreachable("Unhandled lvalue cast kind?");
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index dbafd2bffe8..c9e4dbd1405 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -925,7 +925,8 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) {
//assert(0 && "Unknown cast kind!");
break;
- case CastExpr::CK_LValueBitCast: {
+ case CastExpr::CK_LValueBitCast:
+ case CastExpr::CK_ObjCObjectLValueCast: {
Value *V = EmitLValue(E).getAddress();
V = Builder.CreateBitCast(V,
ConvertType(CGF.getContext().getPointerType(DestTy)));
@@ -1044,7 +1045,10 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) {
return Builder.CreatePtrToInt(Src, ConvertType(DestTy));
}
case CastExpr::CK_ToVoid: {
- CGF.EmitAnyExpr(E, 0, false, true);
+ if (E->Classify(CGF.getContext()).isGLValue())
+ CGF.EmitLValue(E);
+ else
+ CGF.EmitAnyExpr(E, 0, false, true);
return 0;
}
case CastExpr::CK_VectorSplat: {
OpenPOWER on IntegriCloud