[cfe-commits] r147573 - in /cfe/trunk: lib/CodeGen/CGObjC.cpp test/CodeGenObjCXX/property-object-reference-1.mm

Fariborz Jahanian fjahanian at apple.com
Wed Jan 4 16:10:16 PST 2012


Author: fjahanian
Date: Wed Jan  4 18:10:16 2012
New Revision: 147573

URL: http://llvm.org/viewvc/llvm-project?rev=147573&view=rev
Log:
Fixes a code gen bug for setter code for a property of
c++ object reference type with trivial copy constructor.
This causes an assert crash and bad code gen. when assert 
is off. // rdar://6137845

Added:
    cfe/trunk/test/CodeGenObjCXX/property-object-reference-1.mm
Modified:
    cfe/trunk/lib/CodeGen/CGObjC.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=147573&r1=147572&r2=147573&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Wed Jan  4 18:10:16 2012
@@ -752,7 +752,8 @@
 
   // The second argument is the address of the parameter variable.
   ParmVarDecl *argVar = *OMD->param_begin();
-  DeclRefExpr argRef(argVar, argVar->getType(), VK_LValue, SourceLocation());
+  DeclRefExpr argRef(argVar, argVar->getType().getNonReferenceType(), 
+                     VK_LValue, SourceLocation());
   llvm::Value *argAddr = CGF.EmitLValue(&argRef).getAddress();
   argAddr = CGF.Builder.CreateBitCast(argAddr, CGF.Int8PtrTy);
   args.add(RValue::get(argAddr), CGF.getContext().VoidPtrTy);

Added: cfe/trunk/test/CodeGenObjCXX/property-object-reference-1.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/property-object-reference-1.mm?rev=147573&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/property-object-reference-1.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/property-object-reference-1.mm Wed Jan  4 18:10:16 2012
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -x objective-c++ %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// rdar://6137845
+
+struct TCPPObject
+{
+ TCPPObject(const TCPPObject& inObj);
+ TCPPObject();
+ ~TCPPObject();
+ int filler[64];
+};
+
+
+ at interface MyDocument 
+{
+ at private
+ TCPPObject _cppObject;
+}
+ at property (atomic, assign, readwrite) const TCPPObject& cppObject;
+ at end
+
+ at implementation MyDocument
+
+ at synthesize cppObject = _cppObject;
+
+ at end
+
+// CHECK: [[cppObjectaddr:%.*]] = alloca %struct.TCPPObject*, align 8
+// CHECK: store %struct.TCPPObject* [[cppObject:%.*]], %struct.TCPPObject** [[cppObjectaddr]], align 8
+// CHECK:  [[THREE:%.*]] = load %struct.TCPPObject** [[cppObjectaddr]], align 8
+// CHECK:  [[FOUR:%.*]] = bitcast %struct.TCPPObject* [[THREE]] to i8*
+// CHECK:  call void @objc_copyStruct(i8* [[TWO:%.*]], i8* [[FOUR]], i64 256, i1 zeroext true, i1 zeroext false)





More information about the cfe-commits mailing list