r191395 - ObjectiveC: Handle the case of qualifying protocols

Fariborz Jahanian fjahanian at apple.com
Wed Sep 25 12:36:32 PDT 2013


Author: fjahanian
Date: Wed Sep 25 14:36:32 2013
New Revision: 191395

URL: http://llvm.org/viewvc/llvm-project?rev=191395&view=rev
Log:
ObjectiveC: Handle the case of qualifying protocols
declared in a typedef declaraton used as super
class of an ObjC class. Curretnly, these protocols
are dropped from the class hierarchy. Test shows that
it is now included. // rdar://15051465

Modified:
    cfe/trunk/include/clang/Sema/Sema.h
    cfe/trunk/lib/Parse/ParseObjc.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/default-synthesize-3.m

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=191395&r1=191394&r2=191395&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Sep 25 14:36:32 2013
@@ -6513,6 +6513,10 @@ public:
                                  const SourceLocation *ProtoLocs,
                                  SourceLocation EndProtoLoc,
                                  AttributeList *AttrList);
+  
+  void ActOnTypedefedProtocols(SmallVectorImpl<Decl *> &ProtocolRefs,
+                               IdentifierInfo *SuperName,
+                               SourceLocation SuperLoc);
 
   Decl *ActOnCompatibilityAlias(
                     SourceLocation AtCompatibilityAliasLoc,

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=191395&r1=191394&r2=191395&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Wed Sep 25 14:36:32 2013
@@ -289,6 +289,9 @@ Decl *Parser::ParseObjCAtInterfaceDeclar
                                   LAngleLoc, EndProtoLoc))
     return 0;
 
+  if (Tok.isNot(tok::less))
+    Actions.ActOnTypedefedProtocols(ProtocolRefs, superClassId, superClassLoc);
+  
   Decl *ClsType =
     Actions.ActOnStartClassInterface(AtLoc, nameId, nameLoc,
                                      superClassId, superClassLoc,

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=191395&r1=191394&r2=191395&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Sep 25 14:36:32 2013
@@ -592,6 +592,29 @@ ActOnStartClassInterface(SourceLocation
   return ActOnObjCContainerStartDefinition(IDecl);
 }
 
+/// ActOnTypedefedProtocols - this action finds protocol list as part of the
+/// typedef'ed use for a qualified super class and adds them to the list
+/// of the protocols.
+void Sema::ActOnTypedefedProtocols(SmallVectorImpl<Decl *> &ProtocolRefs,
+                                   IdentifierInfo *SuperName,
+                                   SourceLocation SuperLoc) {
+  if (!SuperName)
+    return;
+  NamedDecl* IDecl = LookupSingleName(TUScope, SuperName, SuperLoc,
+                                      LookupOrdinaryName);
+  if (!IDecl)
+    return;
+  
+  if (const TypedefNameDecl *TDecl = dyn_cast_or_null<TypedefNameDecl>(IDecl)) {
+    QualType T = TDecl->getUnderlyingType();
+    if (T->isObjCObjectType())
+      if (const ObjCObjectType *OPT = T->getAs<ObjCObjectType>())
+        for (ObjCObjectType::qual_iterator I = OPT->qual_begin(),
+             E = OPT->qual_end(); I != E; ++I)
+          ProtocolRefs.push_back(*I);
+  }
+}
+
 /// ActOnCompatibilityAlias - this action is called after complete parsing of
 /// a \@compatibility_alias declaration. It sets up the alias relationships.
 Decl *Sema::ActOnCompatibilityAlias(SourceLocation AtLoc,

Modified: cfe/trunk/test/SemaObjC/default-synthesize-3.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/default-synthesize-3.m?rev=191395&r1=191394&r2=191395&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/default-synthesize-3.m (original)
+++ cfe/trunk/test/SemaObjC/default-synthesize-3.m Wed Sep 25 14:36:32 2013
@@ -157,3 +157,27 @@ __attribute ((objc_requires_property_def
 __attribute ((objc_requires_property_definitions(1))) // expected-error {{'objc_requires_property_definitions' attribute takes no arguments}}
 @interface I1
 @end
+
+// rdar://15051465
+ at protocol SubFooling
+  @property(nonatomic, readonly) id hoho; // expected-note 2 {{property declared here}}
+ at end
+
+ at protocol Fooing<SubFooling>
+  @property(nonatomic, readonly) id muahahaha; // expected-note 2 {{property declared here}}
+ at end
+
+typedef NSObject<Fooing> FooObject;
+
+ at interface Okay : NSObject<Fooing>
+ at end
+
+ at implementation Okay // expected-warning 2 {{auto property synthesis will not synthesize property declared in a protocol}}
+ at end
+
+ at interface Fail : FooObject
+ at end
+
+ at implementation Fail // expected-warning 2 {{auto property synthesis will not synthesize property declared in a protocol}}
+ at end
+





More information about the cfe-commits mailing list