@@ -90,10 +90,9 @@ static const AvailabilityAttr *getAttrForPlatform(ASTContext &Context,
9090// / the availability attribute that is selected.
9191// / \param ClassReceiver If we're checking the method of a class message
9292// / send, the class. Otherwise nullptr.
93- static std::pair<AvailabilityResult, const NamedDecl *>
94- ShouldDiagnoseAvailabilityOfDecl (Sema &S, const NamedDecl *D,
95- std::string *Message,
96- ObjCInterfaceDecl *ClassReceiver) {
93+ std::pair<AvailabilityResult, const NamedDecl *>
94+ Sema::ShouldDiagnoseAvailabilityOfDecl (const NamedDecl *D, std::string *Message,
95+ ObjCInterfaceDecl *ClassReceiver) {
9796 AvailabilityResult Result = D->getAvailability (Message);
9897
9998 // For typedefs, if the typedef declaration appears available look
@@ -147,12 +146,12 @@ ShouldDiagnoseAvailabilityOfDecl(Sema &S, const NamedDecl *D,
147146
148147 // For +new, infer availability from -init.
149148 if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
150- if (S. ObjC ().NSAPIObj && ClassReceiver) {
149+ if (ObjC ().NSAPIObj && ClassReceiver) {
151150 ObjCMethodDecl *Init = ClassReceiver->lookupInstanceMethod (
152- S. ObjC ().NSAPIObj ->getInitSelector ());
151+ ObjC ().NSAPIObj ->getInitSelector ());
153152 if (Init && Result == AR_Available && MD->isClassMethod () &&
154- MD->getSelector () == S. ObjC ().NSAPIObj ->getNewSelector () &&
155- MD->definedInNSObject (S. getASTContext ())) {
153+ MD->getSelector () == ObjC ().NSAPIObj ->getNewSelector () &&
154+ MD->definedInNSObject (getASTContext ())) {
156155 Result = Init->getAvailability (Message);
157156 D = Init;
158157 }
@@ -162,7 +161,6 @@ ShouldDiagnoseAvailabilityOfDecl(Sema &S, const NamedDecl *D,
162161 return {Result, D};
163162}
164163
165-
166164// / whether we should emit a diagnostic for \c K and \c DeclVersion in
167165// / the context of \c Ctx. For example, we should emit an unavailable diagnostic
168166// / in a deprecated context, but not the other way around.
@@ -876,7 +874,7 @@ void DiagnoseUnguardedAvailability::DiagnoseDeclAvailability(
876874 AvailabilityResult Result;
877875 const NamedDecl *OffendingDecl;
878876 std::tie (Result, OffendingDecl) =
879- ShouldDiagnoseAvailabilityOfDecl (SemaRef, D, nullptr , ReceiverClass);
877+ SemaRef. ShouldDiagnoseAvailabilityOfDecl (D, nullptr , ReceiverClass);
880878 if (Result != AR_Available) {
881879 // All other diagnostic kinds have already been handled in
882880 // DiagnoseAvailabilityOfDecl.
@@ -1112,12 +1110,13 @@ void Sema::DiagnoseAvailabilityOfDecl(NamedDecl *D,
11121110 bool ObjCPropertyAccess,
11131111 bool AvoidPartialAvailabilityChecks,
11141112 ObjCInterfaceDecl *ClassReceiver) {
1113+
11151114 std::string Message;
11161115 AvailabilityResult Result;
11171116 const NamedDecl* OffendingDecl;
11181117 // See if this declaration is unavailable, deprecated, or partial.
11191118 std::tie (Result, OffendingDecl) =
1120- ShouldDiagnoseAvailabilityOfDecl (* this , D, &Message, ClassReceiver);
1119+ ShouldDiagnoseAvailabilityOfDecl (D, &Message, ClassReceiver);
11211120 if (Result == AR_Available)
11221121 return ;
11231122
@@ -1146,3 +1145,11 @@ void Sema::DiagnoseAvailabilityOfDecl(NamedDecl *D,
11461145 EmitAvailabilityWarning (*this , Result, D, OffendingDecl, Message, Locs,
11471146 UnknownObjCClass, ObjCPDecl, ObjCPropertyAccess);
11481147}
1148+
1149+ void Sema::DiagnoseAvailabilityOfDecl (NamedDecl *D,
1150+ ArrayRef<SourceLocation> Locs) {
1151+ DiagnoseAvailabilityOfDecl (D, Locs, /* UnknownObjCClass=*/ nullptr ,
1152+ /* ObjCPropertyAccess=*/ false ,
1153+ /* AvoidPartialAvailabilityChecks=*/ false ,
1154+ /* ClassReceiver=*/ nullptr );
1155+ }
0 commit comments