[cfe-commits] r171777 - in /cfe/trunk: lib/AST/DeclObjC.cpp lib/Sema/SemaDeclObjC.cpp test/SemaObjC/forward-protocol-incomplete-impl-warn.m

Fariborz Jahanian fjahanian at apple.com
Mon Jan 7 11:21:03 PST 2013


Author: fjahanian
Date: Mon Jan  7 13:21:03 2013
New Revision: 171777

URL: http://llvm.org/viewvc/llvm-project?rev=171777&view=rev
Log:
objective-C: when searching for declarations in protocol
list of classes, etc., make sure to look into protocol
definitions. // rdar://12958878

Added:
    cfe/trunk/test/SemaObjC/forward-protocol-incomplete-impl-warn.m
Modified:
    cfe/trunk/lib/AST/DeclObjC.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=171777&r1=171776&r2=171777&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Mon Jan  7 13:21:03 2013
@@ -1352,15 +1352,19 @@
 }
 
 void ObjCProtocolDecl::collectPropertiesToImplement(PropertyMap &PM) const {
-  for (ObjCProtocolDecl::prop_iterator P = prop_begin(),
-      E = prop_end(); P != E; ++P) {
+  const ObjCProtocolDecl *PDecl = this;
+  if (!isThisDeclarationADefinition() && getDefinition())
+    PDecl = getDefinition();
+
+  for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
+       E = PDecl->prop_end(); P != E; ++P) {
     ObjCPropertyDecl *Prop = *P;
     // Insert into PM if not there already.
     PM.insert(std::make_pair(Prop->getIdentifier(), Prop));
   }
   // Scan through protocol's protocols.
-  for (ObjCProtocolDecl::protocol_iterator PI = protocol_begin(),
-      E = protocol_end(); PI != E; ++PI)
+  for (ObjCProtocolDecl::protocol_iterator PI = PDecl->protocol_begin(),
+      E = PDecl->protocol_end(); PI != E; ++PI)
     (*PI)->collectPropertiesToImplement(PM);
 }
 

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=171777&r1=171776&r2=171777&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Mon Jan  7 13:21:03 2013
@@ -1593,6 +1593,11 @@
       NSIDecl = IDecl->lookupInheritedClass(&Context.Idents.get("NSProxy"));
   }
 
+  // If this is a forward protocol declaration, get its definition.
+  if (!PDecl->isThisDeclarationADefinition() &&
+      PDecl->getDefinition())
+    PDecl = PDecl->getDefinition();
+  
   // If a method lookup fails locally we still need to look and see if
   // the method was implemented by a base class or an inherited
   // protocol. This lookup is slow, but occurs rarely in correct code

Added: cfe/trunk/test/SemaObjC/forward-protocol-incomplete-impl-warn.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/forward-protocol-incomplete-impl-warn.m?rev=171777&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/forward-protocol-incomplete-impl-warn.m (added)
+++ cfe/trunk/test/SemaObjC/forward-protocol-incomplete-impl-warn.m Mon Jan  7 13:21:03 2013
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-default-synthesize-properties %s
+// rdar://12958878
+
+ at interface NSObject @end
+
+ at protocol DVTInvalidation
+- (void)invalidate;  // expected-note {{method 'invalidate' declared here}}
+ at property int Prop; // expected-note {{property declared here}}
+ at end
+
+
+
+ at protocol DVTInvalidation;
+
+ at interface IBImageCatalogDocument : NSObject <DVTInvalidation> // expected-note {{required for direct or indirect protocol 'DVTInvalidation'}}
+ at end
+
+ at implementation IBImageCatalogDocument // expected-warning {{auto property synthesis will not synthesize property declared in a protocol}} \ 
+				       // expected-warning {{incomplete implementation}} \
+				       // expected-warning {{method 'invalidate' in protocol not implemented}}
+ at end





More information about the cfe-commits mailing list