[cfe-commits] r116846 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaObjC/provisional-ivar-lookup.m

Fariborz Jahanian fjahanian at apple.com
Tue Oct 19 12:08:23 PDT 2010


Author: fjahanian
Date: Tue Oct 19 14:08:23 2010
New Revision: 116846

URL: http://llvm.org/viewvc/llvm-project?rev=116846&view=rev
Log:
Fixes a bug in ivar lookup in the new objc's default
property synthesis mode, when dealing with legacy code.
Fixes //rdar: //8565343.


Added:
    cfe/trunk/test/SemaObjC/provisional-ivar-lookup.m
Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=116846&r1=116845&r2=116846&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Oct 19 14:08:23 2010
@@ -1068,9 +1068,14 @@
   ObjCPropertyDecl *property = SemaRef.LookupPropertyDecl(IDecl, II);
   if (!property)
     return 0;
-  if (ObjCPropertyImplDecl *PIDecl = ClassImpDecl->FindPropertyImplDecl(II))
+  if (ObjCPropertyImplDecl *PIDecl = ClassImpDecl->FindPropertyImplDecl(II)) {
     DynamicImplSeen = 
       (PIDecl->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic);
+    // property implementation has a designated ivar. No need to assume a new
+    // one.
+    if (!DynamicImplSeen && PIDecl->getPropertyIvarDecl())
+      return 0;
+  }
   if (!DynamicImplSeen) {
     QualType PropType = SemaRef.Context.getCanonicalType(property->getType());
     ObjCIvarDecl *Ivar = ObjCIvarDecl::Create(SemaRef.Context, ClassImpDecl, 

Added: cfe/trunk/test/SemaObjC/provisional-ivar-lookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/provisional-ivar-lookup.m?rev=116846&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/provisional-ivar-lookup.m (added)
+++ cfe/trunk/test/SemaObjC/provisional-ivar-lookup.m Tue Oct 19 14:08:23 2010
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1  -fsyntax-only -fobjc-nonfragile-abi2 -verify %s
+
+// rdar:// 8565343
+ at interface Foo  {
+ at private
+    int _foo;
+    int _foo2;
+}
+ at property (readwrite, nonatomic) int foo, foo1, foo2, foo3;
+ at property (readwrite, nonatomic) int PROP;
+ at end
+
+ at implementation Foo
+
+ at synthesize foo = _foo;
+ at synthesize foo1;
+
+- (void)setFoo:(int)value {
+    _foo = foo; // expected-error {{use of undeclared identifier 'foo'}}
+}
+
+- (void)setFoo1:(int)value {
+    _foo = foo1; // OK
+}
+
+- (void)setFoo2:(int)value {
+    _foo = foo2; // expected-error {{use of undeclared identifier 'foo2'}}
+}
+
+- (void)setFoo3:(int)value {
+    _foo = foo3;	// OK
+}
+
+ at synthesize foo2 = _foo2;
+ at synthesize foo3;
+
+ at synthesize PROP=PROP;
+- (void)setPROP:(int)value {
+    PROP = PROP;        // OK
+}
+
+ at end
+





More information about the cfe-commits mailing list