[cfe-commits] r145999 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Sema/SemaExpr.cpp lib/Sema/SemaExprObjC.cpp test/ARCMT/checking.m test/SemaObjC/attr-deprecated.m

Fariborz Jahanian fjahanian at apple.com
Tue Dec 6 16:30:01 PST 2011


Author: fjahanian
Date: Tue Dec  6 18:30:00 2011
New Revision: 145999

URL: http://llvm.org/viewvc/llvm-project?rev=145999&view=rev
Log:
objc: issue deprecated/unavailable diagnostic when
methods with these attributes are sent to receivers
of 'id' type too. // rdar://10459930

Modified:
    cfe/trunk/include/clang/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprObjC.cpp
    cfe/trunk/test/ARCMT/checking.m
    cfe/trunk/test/SemaObjC/attr-deprecated.m

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=145999&r1=145998&r2=145999&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Dec  6 18:30:00 2011
@@ -2276,6 +2276,9 @@
   bool CanUseDecl(NamedDecl *D);
   bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc,
                          const ObjCInterfaceDecl *UnknownObjCClass=0);
+  AvailabilityResult DiagnoseAvailabilityOfDecl(NamedDecl *D, 
+                              SourceLocation Loc,
+                              const ObjCInterfaceDecl *UnknownObjCClass);
   std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD);
   bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD,
                                         ObjCMethodDecl *Getter,

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=145999&r1=145998&r2=145999&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Dec  6 18:30:00 2011
@@ -62,7 +62,8 @@
   return true;
 }
 
-static AvailabilityResult DiagnoseAvailabilityOfDecl(Sema &S,
+AvailabilityResult 
+Sema::DiagnoseAvailabilityOfDecl(
                               NamedDecl *D, SourceLocation Loc,
                               const ObjCInterfaceDecl *UnknownObjCClass) {
   // See if this declaration is unavailable or deprecated.
@@ -81,22 +82,22 @@
       break;
             
     case AR_Deprecated:
-      S.EmitDeprecationWarning(D, Message, Loc, UnknownObjCClass);
+      EmitDeprecationWarning(D, Message, Loc, UnknownObjCClass);
       break;
             
     case AR_Unavailable:
-      if (S.getCurContextAvailability() != AR_Unavailable) {
+      if (getCurContextAvailability() != AR_Unavailable) {
         if (Message.empty()) {
           if (!UnknownObjCClass)
-            S.Diag(Loc, diag::err_unavailable) << D->getDeclName();
+            Diag(Loc, diag::err_unavailable) << D->getDeclName();
           else
-            S.Diag(Loc, diag::warn_unavailable_fwdclass_message) 
+            Diag(Loc, diag::warn_unavailable_fwdclass_message) 
               << D->getDeclName();
         }
         else 
-          S.Diag(Loc, diag::err_unavailable_message) 
+          Diag(Loc, diag::err_unavailable_message) 
             << D->getDeclName() << Message;
-          S.Diag(D->getLocation(), diag::note_unavailable_here) 
+          Diag(D->getLocation(), diag::note_unavailable_here) 
           << isa<FunctionDecl>(D) << false;
       }
       break;
@@ -151,7 +152,7 @@
       return true;
     }
   }
-  DiagnoseAvailabilityOfDecl(*this, D, Loc, UnknownObjCClass);
+  DiagnoseAvailabilityOfDecl(D, Loc, UnknownObjCClass);
 
   // Warn if this is used but marked unused.
   if (D->hasAttr<UnusedAttr>())

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=145999&r1=145998&r2=145999&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Tue Dec  6 18:30:00 2011
@@ -1254,6 +1254,9 @@
         Method = LookupFactoryMethodInGlobalPool(Sel, 
                                                  SourceRange(LBracLoc, RBracLoc),
                                                  receiverIsId);
+      if (Method)
+        DiagnoseAvailabilityOfDecl(Method, Loc, 0);
+      
     } else if (ReceiverType->isObjCClassType() ||
                ReceiverType->isObjCQualifiedClassType()) {
       // Handle messages to Class.

Modified: cfe/trunk/test/ARCMT/checking.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/checking.m?rev=145999&r1=145998&r2=145999&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/checking.m (original)
+++ cfe/trunk/test/ARCMT/checking.m Tue Dec  6 18:30:00 2011
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s
+// XFAIL: *
 
 #include "Common.h"
 

Modified: cfe/trunk/test/SemaObjC/attr-deprecated.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-deprecated.m?rev=145999&r1=145998&r2=145999&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/attr-deprecated.m (original)
+++ cfe/trunk/test/SemaObjC/attr-deprecated.m Tue Dec  6 18:30:00 2011
@@ -53,7 +53,7 @@
 
 void t2(id a)
 {
-  [a f];
+  [a f]; // expected-warning {{'f' is deprecated}}
 }
 
 void t3(A<P>* a)
@@ -121,3 +121,20 @@
 __attribute__((deprecated))
 @interface A(Blah) // expected-error{{attributes may not be specified on a category}}
 @end
+
+// rdar://10459930
+
+ at class NSString;
+ at interface NSDocumentController
+{
+  id iv;
+}
+- (void)fileExtensionsFromType:(NSString *)typeName __attribute__((deprecated));
+ at end
+
+ at implementation NSDocumentController
+- (void) Meth {
+  [iv fileExtensionsFromType:@"public.text"]; // expected-warning {{'fileExtensionsFromType:' is deprecated}}
+}
+- (void)fileExtensionsFromType:(NSString *)typeName {}
+ at end





More information about the cfe-commits mailing list