]> granicus.if.org Git - clang/commitdiff
Patch to implement code gen for aggrgate-valued property used
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 12 Jan 2009 23:27:26 +0000 (23:27 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 12 Jan 2009 23:27:26 +0000 (23:27 +0000)
to access a field of its type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62123 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
test/CodeGenObjC/property-agrr-getter.m [new file with mode: 0644]

index 20a7693faf620c4109355957f0c2d3bd6b4861f0..2d51efa474ec431f27fd7f78eea10ee2d4269329 100644 (file)
@@ -802,6 +802,14 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
       isUnion = true;
     CVRQualifiers = PTy->getPointeeType().getCVRQualifiers();
   }
+  else if (BaseExpr->getStmtClass() == Expr::ObjCPropertyRefExprClass ||
+           BaseExpr->getStmtClass() == Expr::ObjCKVCRefExprClass) {
+    RValue RV = EmitObjCPropertyGet(BaseExpr);
+    BaseValue = RV.getAggregateAddr();
+    if (BaseExpr->getType()->isUnionType())
+      isUnion = true;
+    CVRQualifiers = BaseExpr->getType().getCVRQualifiers();
+  }
   else {
     LValue BaseLV = EmitLValue(BaseExpr);
     if (BaseLV.isObjCIvar())
diff --git a/test/CodeGenObjC/property-agrr-getter.m b/test/CodeGenObjC/property-agrr-getter.m
new file mode 100644 (file)
index 0000000..903dcc7
--- /dev/null
@@ -0,0 +1,17 @@
+// RUN: clang -emit-llvm -o %t %s
+
+typedef struct {
+  unsigned f0;
+} s0;
+
+@interface A
+- (s0) f0;
+@end
+
+@implementation A
+-(s0) f0{}
+- (unsigned) bar {
+  return self.f0.f0;
+}
+@end
+