[cfe-commits] r104281 - in /cfe/trunk: lib/CodeGen/CGExprCXX.cpp test/CodeGenObjC/objc-gc-aggr-assign.m
Fariborz Jahanian
fjahanian at apple.com
Thu May 20 14:38:57 PDT 2010
Author: fjahanian
Date: Thu May 20 16:38:57 2010
New Revision: 104281
URL: http://llvm.org/viewvc/llvm-project?rev=104281&view=rev
Log:
Adds support for generation of objc_memmove_collectable API
in Objective-C++ mode.
Added:
cfe/trunk/test/CodeGenObjC/objc-gc-aggr-assign.m
Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=104281&r1=104280&r2=104281&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Thu May 20 16:38:57 2010
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "CodeGenFunction.h"
+#include "CGObjCRuntime.h"
using namespace clang;
using namespace CodeGen;
@@ -274,7 +275,10 @@
llvm::Value *Src = EmitLValue(E->getArg(1)).getAddress();
QualType Ty = E->getType();
- EmitAggregateCopy(This, Src, Ty);
+ if (ClassDecl->hasObjectMember())
+ CGM.getObjCRuntime().EmitGCMemmoveCollectable(*this, This, Src, Ty);
+ else
+ EmitAggregateCopy(This, Src, Ty);
return RValue::get(This);
}
}
Added: cfe/trunk/test/CodeGenObjC/objc-gc-aggr-assign.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc-gc-aggr-assign.m?rev=104281&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/objc-gc-aggr-assign.m (added)
+++ cfe/trunk/test/CodeGenObjC/objc-gc-aggr-assign.m Thu May 20 16:38:57 2010
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep objc_memmove_collectable %t | grep call | count 3
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep objc_memmove_collectable %t | grep call | count 3
+
+static int count;
+
+typedef struct S {
+ int ii;
+} SS;
+
+struct type_s {
+ SS may_recurse;
+ id id_val;
+};
+
+ at interface NamedObject
+{
+ struct type_s type_s_ivar;
+}
+- (void) setSome : (struct type_s) arg;
+- (struct type_s) getSome;
+ at property(assign) struct type_s aggre_prop;
+ at end
+
+ at implementation NamedObject
+- (void) setSome : (struct type_s) arg
+ {
+ type_s_ivar = arg;
+ }
+- (struct type_s) getSome
+ {
+ return type_s_ivar;
+ }
+ at synthesize aggre_prop = type_s_ivar;
+ at end
+
+struct type_s some = {{1234}, (id)0};
+
+struct type_s get(void)
+{
+ return some;
+}
+
+void f(const struct type_s *in, struct type_s *out) {
+ *out = *in;
+}
+
More information about the cfe-commits
mailing list