[llvm-branch-commits] [cfe-branch] r71826 - in /cfe/branches/Apple/Dib: lib/Sema/Sema.h lib/Sema/SemaDeclObjC.cpp lib/Sema/SemaExprObjC.cpp test/SemaObjC/class-conforming-protocol-2.m test/SemaObjC/method-conflict.m

Mike Stump mrs at apple.com
Thu May 14 18:10:12 PDT 2009


Author: mrs
Date: Thu May 14 20:09:45 2009
New Revision: 71826

URL: http://llvm.org/viewvc/llvm-project?rev=71826&view=rev
Log:
Merge in 71817:

Don't warn if result/argument type of an implemented 
method is a qualified id which conforms to the matching type
of its method declaration.

Added:
    cfe/branches/Apple/Dib/test/SemaObjC/class-conforming-protocol-2.m
      - copied unchanged from r71817, cfe/trunk/test/SemaObjC/class-conforming-protocol-2.m
Modified:
    cfe/branches/Apple/Dib/lib/Sema/Sema.h
    cfe/branches/Apple/Dib/lib/Sema/SemaDeclObjC.cpp
    cfe/branches/Apple/Dib/lib/Sema/SemaExprObjC.cpp
    cfe/branches/Apple/Dib/test/SemaObjC/method-conflict.m

Modified: cfe/branches/Apple/Dib/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Sema/Sema.h?rev=71826&r1=71825&r2=71826&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Sema/Sema.h (original)
+++ cfe/branches/Apple/Dib/lib/Sema/Sema.h Thu May 14 20:09:45 2009
@@ -1103,6 +1103,7 @@
                            bool &IncompleteImpl);
   void WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethod,
                                    ObjCMethodDecl *IntfMethod);
+  bool QualifiedIdConformsQualifiedId(QualType LHS, QualType RHS);
 
   NamespaceDecl *GetStdNamespace();
   

Modified: cfe/branches/Apple/Dib/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Sema/SemaDeclObjC.cpp?rev=71826&r1=71825&r2=71826&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Sema/SemaDeclObjC.cpp Thu May 14 20:09:45 2009
@@ -775,7 +775,9 @@
 void Sema::WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethodDecl,
                                        ObjCMethodDecl *IntfMethodDecl) {
   if (!Context.typesAreCompatible(IntfMethodDecl->getResultType(),
-                                  ImpMethodDecl->getResultType())) {
+                                  ImpMethodDecl->getResultType()) &&
+      !QualifiedIdConformsQualifiedId(IntfMethodDecl->getResultType(),
+                                      ImpMethodDecl->getResultType())) {
     Diag(ImpMethodDecl->getLocation(), diag::warn_conflicting_ret_types) 
       << ImpMethodDecl->getDeclName() << IntfMethodDecl->getResultType()
       << ImpMethodDecl->getResultType();
@@ -785,7 +787,8 @@
   for (ObjCMethodDecl::param_iterator IM = ImpMethodDecl->param_begin(),
        IF = IntfMethodDecl->param_begin(), EM = ImpMethodDecl->param_end();
        IM != EM; ++IM, ++IF) {
-    if (Context.typesAreCompatible((*IF)->getType(), (*IM)->getType()))
+    if (Context.typesAreCompatible((*IF)->getType(), (*IM)->getType()) ||
+        QualifiedIdConformsQualifiedId((*IF)->getType(), (*IM)->getType()))
       continue;
     
     Diag((*IM)->getLocation(), diag::warn_conflicting_param_types) 

Modified: cfe/branches/Apple/Dib/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Sema/SemaExprObjC.cpp?rev=71826&r1=71825&r2=71826&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Sema/SemaExprObjC.cpp Thu May 14 20:09:45 2009
@@ -695,6 +695,15 @@
   return false;
 }
 
+/// QualifiedIdConformsQualifiedId - compare id<p,...> with id<p1,...>
+/// return true if lhs's protocols conform to rhs's protocol; false
+/// otherwise.
+bool Sema::QualifiedIdConformsQualifiedId(QualType lhs, QualType rhs) {
+  if (lhs->isObjCQualifiedIdType() && rhs->isObjCQualifiedIdType())
+    return ObjCQualifiedIdTypesAreCompatible(lhs, rhs, false);
+  return false;
+}
+
 /// ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an
 /// ObjCQualifiedIDType.
 /// FIXME: Move to ASTContext::typesAreCompatible() and friends.

Modified: cfe/branches/Apple/Dib/test/SemaObjC/method-conflict.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/test/SemaObjC/method-conflict.m?rev=71826&r1=71825&r2=71826&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/test/SemaObjC/method-conflict.m (original)
+++ cfe/branches/Apple/Dib/test/SemaObjC/method-conflict.m Thu May 14 20:09:45 2009
@@ -40,7 +40,7 @@
 @end  @class XDSCOperation;
 @interface XDSCClassFormatter : NSObject {
 }
-+ (NSUInteger) compartmentsForClassifier: (id <XDUMLClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec; // expected-note {{previous definition is here}}
++ (NSUInteger) compartmentsForClassifier: (id <XDUMLClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec; 
 @end  
 @class NSString;
 @implementation XDSCClassFormatter       
@@ -48,7 +48,6 @@
 + appendVisibility: (id <XDUMLNamedElement>) element withSpecification: (XDSCDisplaySpecification *) displaySpec to: (NSMutableAttributedString *) attributedString
 {
 }
-// GCC doesn't currently warn about this.
-+ (NSUInteger) compartmentsForClassifier: (id <XDSCClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec { // expected-warning {{conflicting parameter types in implementation of 'compartmentsForClassifier:withSpecification:': 'id<XDUMLClassifier>' vs 'id<XDSCClassifier>'}}
++ (NSUInteger) compartmentsForClassifier: (id <XDSCClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec { 
 }
 @end 





More information about the llvm-branch-commits mailing list