[cfe-commits] r103182 - in /cfe/trunk: lib/CodeGen/CGObjC.cpp test/CodeGenObjCXX/property-objects.mm
Fariborz Jahanian
fjahanian at apple.com
Thu May 6 08:45:36 PDT 2010
Author: fjahanian
Date: Thu May 6 10:45:36 2010
New Revision: 103182
URL: http://llvm.org/viewvc/llvm-project?rev=103182&view=rev
Log:
Code Gen support for Getter/Setter synthesis of
C++ object properties. (still radar 7468090).
Added:
cfe/trunk/test/CodeGenObjCXX/property-objects.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=103182&r1=103181&r2=103182&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Thu May 6 10:45:36 2010
@@ -205,8 +205,9 @@
Types.ConvertType(PD->getType())));
EmitReturnOfRValue(RV, PD->getType());
} else {
- LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), Ivar, 0);
if (Ivar->getType()->isAnyComplexType()) {
+ LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(),
+ Ivar, 0);
ComplexPairTy Pair = LoadComplexFromAddr(LV.getAddress(),
LV.isVolatileQualified());
StoreComplexToAddr(Pair, ReturnValue, LV.isVolatileQualified());
@@ -216,6 +217,8 @@
if ((IsAtomic || (IsStrong = IvarTypeWithAggrGCObjects(Ivar->getType())))
&& CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect
&& CGM.getObjCRuntime().GetCopyStructFunction()) {
+ LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(),
+ Ivar, 0);
llvm::Value *GetCopyStructFn =
CGM.getObjCRuntime().GetCopyStructFunction();
CodeGenTypes &Types = CGM.getTypes();
@@ -248,9 +251,22 @@
FunctionType::ExtInfo()),
GetCopyStructFn, ReturnValueSlot(), Args);
}
- else
- EmitAggregateCopy(ReturnValue, LV.getAddress(), Ivar->getType());
+ else {
+ if (PID->getGetterCXXConstructor()) {
+ ReturnStmt *Stmt =
+ new (getContext()) ReturnStmt(SourceLocation(),
+ PID->getGetterCXXConstructor());
+ EmitReturnStmt(*Stmt);
+ }
+ else {
+ LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(),
+ Ivar, 0);
+ EmitAggregateCopy(ReturnValue, LV.getAddress(), Ivar->getType());
+ }
+ }
} else {
+ LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(),
+ Ivar, 0);
CodeGenTypes &Types = CGM.getTypes();
RValue RV = EmitLoadOfLValue(LV, Ivar->getType());
RV = RValue::get(Builder.CreateBitCast(RV.getScalarVal(),
@@ -362,6 +378,10 @@
EmitCall(Types.getFunctionInfo(getContext().VoidTy, Args,
FunctionType::ExtInfo()),
GetCopyStructFn, ReturnValueSlot(), Args);
+ } else if (PID->getSetterCXXAssignment()) {
+ EmitAnyExpr(PID->getSetterCXXAssignment(), (llvm::Value *)0, false, true,
+ false);
+
} else {
// FIXME: Find a clean way to avoid AST node creation.
SourceLocation Loc = PD->getLocation();
Added: cfe/trunk/test/CodeGenObjCXX/property-objects.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/property-objects.mm?rev=103182&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/property-objects.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/property-objects.mm Thu May 6 10:45:36 2010
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// CHECK: call void @_ZN1SC1ERKS_
+// CHECK: call %class.S* @_ZN1SaSERKS_
+
+class S {
+public:
+ S& operator = (const S&);
+ S (const S&);
+ S ();
+};
+
+ at interface I {
+ S position;
+}
+ at property(assign, nonatomic) S position;
+ at end
+
+ at implementation I
+ at synthesize position;
+ at end
More information about the cfe-commits
mailing list