objc: issue deprecated/unavailable diagnostic when
methods with these attributes are sent to receivers
of 'id' type too. // rdar://10459930


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145999 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index cc94050..aeae666 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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>())
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index cc17e6b..fbae960 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -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.