aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-06-17 23:00:29 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-06-17 23:00:29 +0000
commit353b33b2bbd9e8715c7a0231681921bcfdfe4cbf (patch)
treed638b82507641aa47333c6cbe5e1eb552adb2297
parentf521d6e151e0cf443bb767c6a83c06ea411530f8 (diff)
objective-C++ IRGen: property reference as an
lvalue when performing a derived-to-base conversion. Fixes radar 7501812. Added an executable test to llvm-test suite. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106247 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGExpr.cpp10
-rw-r--r--test/CodeGenObjCXX/property-derived-to-base-conv.mm19
2 files changed, 28 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index aab54099fd..8655a66bd9 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -1818,10 +1818,18 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) {
cast<CXXRecordDecl>(DerivedClassTy->getDecl());
LValue LV = EmitLValue(E->getSubExpr());
+ llvm::Value *This;
+ if (LV.isPropertyRef()) {
+ RValue RV = EmitLoadOfPropertyRefLValue(LV, E->getSubExpr()->getType());
+ assert (!RV.isScalar() && "EmitCastLValue");
+ This = RV.getAggregateAddr();
+ }
+ else
+ This = LV.getAddress();
// Perform the derived-to-base conversion
llvm::Value *Base =
- GetAddressOfBaseClass(LV.getAddress(), DerivedClassDecl,
+ GetAddressOfBaseClass(This, DerivedClassDecl,
E->getBasePath(), /*NullCheckValue=*/false);
return LValue::MakeAddr(Base, MakeQualifiers(E->getType()));
diff --git a/test/CodeGenObjCXX/property-derived-to-base-conv.mm b/test/CodeGenObjCXX/property-derived-to-base-conv.mm
new file mode 100644
index 0000000000..ada1202848
--- /dev/null
+++ b/test/CodeGenObjCXX/property-derived-to-base-conv.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -emit-llvm -o - %s
+// rdar: // 7501812
+
+struct A { int member; };
+struct B : A { };
+
+@interface BInt {
+@private
+ B *b;
+}
+- (B)value;
+- (void)setValue : (B) arg;
+@property B value;
+@end
+
+void g(BInt *bint) {
+ bint.value.member = 17;
+}
+