[cfe-commits] r106247 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGenObjCXX/property-derived-to-base-conv.mm

Fariborz Jahanian fjahanian at apple.com
Thu Jun 17 16:00:29 PDT 2010


Author: fjahanian
Date: Thu Jun 17 18:00:29 2010
New Revision: 106247

URL: http://llvm.org/viewvc/llvm-project?rev=106247&view=rev
Log:
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.

Added:
    cfe/trunk/test/CodeGenObjCXX/property-derived-to-base-conv.mm
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=106247&r1=106246&r2=106247&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jun 17 18:00:29 2010
@@ -1818,10 +1818,18 @@
       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()));

Added: cfe/trunk/test/CodeGenObjCXX/property-derived-to-base-conv.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/property-derived-to-base-conv.mm?rev=106247&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/property-derived-to-base-conv.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/property-derived-to-base-conv.mm Thu Jun 17 18:00:29 2010
@@ -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 { };
+
+ at interface BInt {
+ at private
+  B *b;
+}
+- (B)value;
+- (void)setValue : (B) arg;
+ at property B value;
+ at end
+
+void g(BInt *bint) {
+  bint.value.member = 17;
+}
+





More information about the cfe-commits mailing list