[cfe-commits] r138714 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaObjCProperty.cpp test/SemaObjC/default-synthesize.m test/SemaObjC/property-category-1.m test/SemaObjC/property-category-2.m test/SemaObjC/property-category-impl.m test/SemaObjC/property.m test/SemaObjC/super-class-protocol-conformance.m test/SemaObjC/unimplemented-protocol-prop.m

Fariborz Jahanian fjahanian at apple.com
Sat Aug 27 14:55:47 PDT 2011


Author: fjahanian
Date: Sat Aug 27 16:55:47 2011
New Revision: 138714

URL: http://llvm.org/viewvc/llvm-project?rev=138714&view=rev
Log:
objective-c - Make warning on unimplemented protocols point
to class implementation where it is supposed to be
implemented. // rdar://10009982.


Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaObjCProperty.cpp
    cfe/trunk/test/SemaObjC/default-synthesize.m
    cfe/trunk/test/SemaObjC/property-category-1.m
    cfe/trunk/test/SemaObjC/property-category-2.m
    cfe/trunk/test/SemaObjC/property-category-impl.m
    cfe/trunk/test/SemaObjC/property.m
    cfe/trunk/test/SemaObjC/super-class-protocol-conformance.m
    cfe/trunk/test/SemaObjC/unimplemented-protocol-prop.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=138714&r1=138713&r2=138714&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Aug 27 16:55:47 2011
@@ -3372,10 +3372,11 @@
 
 def warn_setter_getter_impl_required : Warning<
   "property %0 requires method %1 to be defined - "
-  "use @synthesize, @dynamic or provide a method implementation">;
+  "use @synthesize, @dynamic or provide a method implementation "
+  "in this class implementation">;
 def warn_setter_getter_impl_required_in_category : Warning<
   "property %0 requires method %1 to be defined - "
-  "use @dynamic or provide a method implementation in category">;
+  "use @dynamic or provide a method implementation in this category">;
 def note_property_impl_required : Note<
   "implementation is here">;
 def note_parameter_named_here : Note<

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=138714&r1=138713&r2=138714&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Sat Aug 27 16:55:47 2011
@@ -1316,23 +1316,23 @@
         PropImplMap.count(Prop) || Prop->hasAttr<UnavailableAttr>())
       continue;
     if (!InsMap.count(Prop->getGetterName())) {
-      Diag(Prop->getLocation(),
+      Diag(IMPDecl->getLocation(),
            isa<ObjCCategoryDecl>(CDecl) ?
             diag::warn_setter_getter_impl_required_in_category :
             diag::warn_setter_getter_impl_required)
       << Prop->getDeclName() << Prop->getGetterName();
-      Diag(IMPDecl->getLocation(),
-           diag::note_property_impl_required);
+      Diag(Prop->getLocation(),
+           diag::note_property_declare);
     }
 
     if (!Prop->isReadOnly() && !InsMap.count(Prop->getSetterName())) {
-      Diag(Prop->getLocation(),
+      Diag(IMPDecl->getLocation(),
            isa<ObjCCategoryDecl>(CDecl) ?
            diag::warn_setter_getter_impl_required_in_category :
            diag::warn_setter_getter_impl_required)
       << Prop->getDeclName() << Prop->getSetterName();
-      Diag(IMPDecl->getLocation(),
-           diag::note_property_impl_required);
+      Diag(Prop->getLocation(),
+           diag::note_property_declare);
     }
   }
 }

Modified: cfe/trunk/test/SemaObjC/default-synthesize.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/default-synthesize.m?rev=138714&r1=138713&r2=138714&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/default-synthesize.m (original)
+++ cfe/trunk/test/SemaObjC/default-synthesize.m Sat Aug 27 16:55:47 2011
@@ -97,10 +97,10 @@
 // rdar://7920807
 @interface C @end
 @interface C (Category)
- at property int p; // expected-warning {{property 'p' requires method 'p' to be defined }} \
-                 // expected-warning {{property 'p' requires method 'setP:' to be defined}}
+ at property int p; // expected-note 2 {{property declared here}}
 @end
- at implementation C (Category) // expected-note 2 {{implementation is here}}
+ at implementation C (Category) // expected-warning {{property 'p' requires method 'p' to be defined}} \
+                             // expected-warning {{property 'p' requires method 'setP:' to be defined}}
 @end
 
 // Don't complain if a property is already @synthesized by usr.

Modified: cfe/trunk/test/SemaObjC/property-category-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-category-1.m?rev=138714&r1=138713&r2=138714&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-category-1.m (original)
+++ cfe/trunk/test/SemaObjC/property-category-1.m Sat Aug 27 16:55:47 2011
@@ -37,7 +37,7 @@
 ///
 
 @interface I0
- at property(readonly) int p0;	// expected-warning {{property 'p0' requires method 'p0' to be defined}}
+ at property(readonly) int p0;	// expected-note {{property declared here}}
 @end 
 
 @interface I0 (Cat0)
@@ -46,7 +46,7 @@
 @interface I0 (Cat1)
 @end 
   
- at implementation I0	// expected-note {{implementation is here}}
+ at implementation I0	// expected-warning {{property 'p0' requires method 'p0' to be define}}
 - (void) foo {
   self.p0 = 0; // expected-error {{assigning to property with 'readonly' attribute not allowed}}
 }

Modified: cfe/trunk/test/SemaObjC/property-category-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-category-2.m?rev=138714&r1=138713&r2=138714&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-category-2.m (original)
+++ cfe/trunk/test/SemaObjC/property-category-2.m Sat Aug 27 16:55:47 2011
@@ -4,8 +4,7 @@
 
 @protocol MyProtocol
 @property float  myFloat;
- at property float  anotherFloat; // expected-warning {{property 'anotherFloat' requires method 'anotherFloat' to be defined - use @dynamic}} \
-                               // expected-warning {{property 'anotherFloat' requires method 'setAnotherFloat:' to be defined }}
+ at property float  anotherFloat; // expected-note 2 {{property declared}}
 @end
 
 @interface MyObject { float anotherFloat; }
@@ -14,7 +13,8 @@
 @interface MyObject (CAT) <MyProtocol>
 @end
 
- at implementation MyObject (CAT)	// expected-note 2 {{implementation is here}}
+ at implementation MyObject (CAT)	// expected-warning  {{property 'anotherFloat' requires method}} \
+                                // expected-warning {{property 'anotherFloat' requires method 'setAnotherFloat:'}}
 @dynamic myFloat;	// OK
 @synthesize anotherFloat; // expected-error {{@synthesize not allowed in a category's implementation}}
 @end

Modified: cfe/trunk/test/SemaObjC/property-category-impl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-category-impl.m?rev=138714&r1=138713&r2=138714&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-category-impl.m (original)
+++ cfe/trunk/test/SemaObjC/property-category-impl.m Sat Aug 27 16:55:47 2011
@@ -24,8 +24,8 @@
 @end
 
 @interface MyClass (public)
- at property(readwrite)    int        foo;	// expected-warning {{property 'foo' requires method 'setFoo:' to be defined }}
+ at property(readwrite)    int        foo;	// expected-note {{property declared here}}
 @end
 
- at implementation MyClass (public)// expected-note {{implementation is here}}
+ at implementation MyClass (public)// expected-warning {{property 'foo' requires method 'setFoo:' to be defined }}
 @end 

Modified: cfe/trunk/test/SemaObjC/property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property.m?rev=138714&r1=138713&r2=138714&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property.m (original)
+++ cfe/trunk/test/SemaObjC/property.m Sat Aug 27 16:55:47 2011
@@ -11,8 +11,7 @@
 @end
 
 @interface I(CAT)
- at property int d1;	// expected-warning {{property 'd1' requires method 'd1' to be defined }} \
-			// expected-warning {{property 'd1' requires method 'setD1:' to be defined }}
+ at property int d1;	// expected-note 2 {{property declared here}}
 @end
 
 @implementation I
@@ -23,7 +22,8 @@
 @synthesize name;	// OK! property with same name as an accessible ivar of same name
 @end
 
- at implementation I(CAT)  // expected-note 2 {{implementation is here}}
+ at implementation I(CAT)  // expected-warning {{property 'd1' requires method 'd1' to be defined }} \
+                        // expected-warning {{property 'd1' requires method 'setD1:' to be defined }}
 @synthesize d1;		// expected-error {{@synthesize not allowed in a category's implementation}}
 @dynamic bad;		// expected-error {{property implementation must have its declaration in the category 'CAT'}}
 @end

Modified: cfe/trunk/test/SemaObjC/super-class-protocol-conformance.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/super-class-protocol-conformance.m?rev=138714&r1=138713&r2=138714&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/super-class-protocol-conformance.m (original)
+++ cfe/trunk/test/SemaObjC/super-class-protocol-conformance.m Sat Aug 27 16:55:47 2011
@@ -4,7 +4,7 @@
 @interface NSObject @end
 
 @protocol TopProtocol
-  @property (readonly) id myString; // expected-warning {{property 'myString' requires method 'myString' to be defined}}
+  @property (readonly) id myString; // expected-note {{property}}
 @end
 
 @protocol SubProtocol <TopProtocol>
@@ -21,7 +21,7 @@
 
 @implementation SubClass1 @end // Test1 - No Warning
 
- at implementation TopClass  // expected-note {{implementation is here}}
+ at implementation TopClass  // expected-warning {{property 'myString' requires method 'myString' to be defined}}
 @end
 
 @implementation SubClass // Test3 - No Warning 
@@ -39,11 +39,11 @@
 @implementation SubClass4 @end	// Test 5 - No Warning
 
 @protocol NewProtocol
-  @property (readonly) id myNewString; // expected-warning {{property 'myNewString' requires method 'myNewString' to be defined}}
+  @property (readonly) id myNewString;  // expected-note {{property}}
 @end
 
 @interface SubClass5 : SubClass4 <NewProtocol> @end
- at implementation SubClass5 @end   // expected-note {{implementation is here}}
+ at implementation SubClass5 @end   // expected-warning {{property 'myNewString' requires method 'myNewString' to be defined}}
 
 
 // Radar 8035776
@@ -54,10 +54,10 @@
 @end
 
 @protocol ProtocolWithProperty <SuperProtocol>
- at property (readonly, assign) id invalidationBacktrace; // expected-warning {{property 'invalidationBacktrace' requires method 'invalidationBacktrace' to be defined}}
+ at property (readonly, assign) id invalidationBacktrace; // expected-note {{property}}
 @end
 
 @interface INTF : Super <ProtocolWithProperty> 
 @end
 
- at implementation INTF @end // expected-note {{implementation is here}}
+ at implementation INTF @end // expected-warning{{property 'invalidationBacktrace' requires method 'invalidationBacktrace' to be defined}}

Modified: cfe/trunk/test/SemaObjC/unimplemented-protocol-prop.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/unimplemented-protocol-prop.m?rev=138714&r1=138713&r2=138714&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/unimplemented-protocol-prop.m (original)
+++ cfe/trunk/test/SemaObjC/unimplemented-protocol-prop.m Sat Aug 27 16:55:47 2011
@@ -2,14 +2,12 @@
 
 @protocol PROTOCOL0
 @required
- at property float MyProperty0; // expected-warning {{property 'MyProperty0' requires method 'MyProperty0' to be defined }} \
-			     // expected-warning {{property 'MyProperty0' requires method 'setMyProperty0:' to be defined}}
+ at property float MyProperty0; // expected-note 2 {{property declared}}
 @end
 
 @protocol PROTOCOL<PROTOCOL0>
 @required
- at property float MyProperty; // expected-warning {{property 'MyProperty' requires method 'MyProperty' to be defined}} \
-			// expected-warning {{property 'MyProperty' requires method 'setMyProperty:' to be defined}}
+ at property float MyProperty; // expected-note 2 {{property declared}}
 @optional
 @property float OptMyProperty;
 @end
@@ -17,4 +15,7 @@
 @interface I <PROTOCOL>
 @end
 
- at implementation I @end // expected-note 4 {{implementation is here}}
+ at implementation I @end // expected-warning {{property 'MyProperty0' requires method 'MyProperty0' to be defined}} \
+                       // expected-warning {{property 'MyProperty0' requires method 'setMyProperty0:' to be defined}}\
+                       // expected-warning {{property 'MyProperty' requires method 'MyProperty' to be defined}} \
+                       // expected-warning {{property 'MyProperty' requires method 'setMyProperty:' to be defined}}





More information about the cfe-commits mailing list