Lines Matching +full:cs +full:- +full:extra +full:- +full:delay

1 //===--- SemaAvailability.cpp - Availability attribute handling -----------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
34 IdentifierInfo *IIEnvironment = AA->getEnvironment();
40 AvailabilityAttr::getEnvironmentType(IIEnvironment->getName());
53 D = FTD->getTemplatedDecl();
54 for (const auto *A : D->attrs()) {
57 // de-duplicate.
61 StringRef ActualPlatform = Avail->getPlatform()->getName();
87 /// \param Message If non-null, this will be populated with the message from
95 AvailabilityResult Result = D->getAvailability(Message);
101 if (const auto *TT = TD->getUnderlyingType()->getAs<TagType>()) {
102 D = TT->getDecl();
103 Result = D->getAvailability(Message);
112 D = ADecl->getTemplatedDecl();
113 Result = D->getAvailability(Message);
118 if (IDecl->getDefinition()) {
119 D = IDecl->getDefinition();
120 Result = D->getAvailability(Message);
126 const DeclContext *DC = ECD->getDeclContext();
128 Result = TheEnumDecl->getAvailability(Message);
133 // For +new, infer availability from -init.
136 ObjCMethodDecl *Init = ClassReceiver->lookupInstanceMethod(
137 S.ObjC().NSAPIObj->getInitSelector());
138 if (Init && Result == AR_Available && MD->isClassMethod() &&
139 MD->getSelector() == S.ObjC().NSAPIObj->getNewSelector() &&
140 MD->definedInNSObject(S.getASTContext())) {
141 Result = Init->getAvailability(Message);
160 auto DeclLoc = Ctx->getBeginLoc();
172 // strict (-fhlsl-strict-availability), or if the target is library and the
189 if (AA->getIntroduced() >= DeclVersion &&
190 AA->getEnvironment() == DeclEnv)
193 if (C->isDeprecated())
196 // It is perfectly fine to refer to an 'unavailable' Objective-C method
201 if (MD->getClassInterface() == Impl->getClassInterface())
207 if (C->isUnavailable())
219 if (MethodD->isClassMethod() &&
220 MethodD->getSelector().getAsString() == "load")
224 if (const ObjCInterfaceDecl *Interface = CatOrImpl->getClassInterface())
230 if (const ObjCInterfaceDecl *Interface = CatD->getClassInterface())
233 } while ((Ctx = cast_or_null<Decl>(Ctx->getDeclContext())));
244 // For iOS, emit the diagnostic even if -Wunguarded-availability is
261 // (-fhlsl-strict-availability) and as warnings in relaxed diagnostic
262 // mode (-Wno-error=hlsl-availability)
271 : VersionTuple(/*Major=*/(unsigned)-1, (unsigned)-1);
283 Ctx = cast_or_null<Decl>(Ctx->getDeclContext())) {
288 return Imp->getClassInterface();
304 return {" ", D->getEndLoc(), ""};
310 return {"", D->getBeginLoc(), "\n"};
327 // Accept replacements starting with - or + as valid ObjC method names.
328 if (!Name.empty() && (Name.front() == '-' || Name.front() == '+'))
340 // Not a valid method name, just a colon-separated string.
363 if (MD->hasBody())
369 Lexer::getLocForEndOfToken(TD->getInnerLocStart(), 0, SM, LangOpts);
399 SourceLocation NoteLocation = OffendingDecl->getLocation();
411 DeclVersion = AA->getIntroduced();
412 IIEnv = AA->getEnvironment();
423 if (AA && AA->isInherited()) {
424 for (const Decl *Redecl = OffendingDecl->getMostRecentDecl(); Redecl;
425 Redecl = Redecl->getPreviousDecl()) {
428 if (AForRedecl && !AForRedecl->isInherited()) {
431 NoteLocation = Redecl->getLocation();
439 // We would like to emit the diagnostic even if -Wunguarded-availability is
444 VersionTuple Introduced = AA->getIntroduced();
454 AA->getEnvironment() ? AA->getEnvironment()->getName() : "";
466 S.Diag(OffendingDecl->getLocation(),
478 if (TD->getDeclName().isEmpty()) {
479 S.Diag(TD->getLocation(),
481 << /*Anonymous*/ 1 << TD->getKindName();
485 S.Diag(Enclosing->getLocation(),
489 if (Enclosing->hasAttr<AvailabilityAttr>())
502 OffendingDecl->getVersionIntroduced().getAsString();
504 Insertion->Loc,
505 (llvm::Twine(Insertion->Prefix) + "API_AVAILABLE(" + PlatformName +
506 "(" + Introduced + "))" + Insertion->Suffix)
518 if (const auto *AL = OffendingDecl->getAttr<DeprecatedAttr>())
519 NoteLocation = AL->getLocation();
530 if (auto AL = OffendingDecl->getAttr<UnavailableAttr>()) {
531 if (AL->isImplicit() && AL->getImplicitReason()) {
532 // Most of these failures are due to extra restrictions in ARC;
537 OffendingDecl->getLocation()))
541 switch (AL->getImplicitReason()) {
582 if (auto AL = OffendingDecl->getAttr<DeprecatedAttr>())
583 Replacement = AL->getReplacement();
585 Replacement = AL->getReplacement();
593 Selector Sel = MethodDecl->getSelector();
642 S.Diag(ObjCProperty->getLocation(), diag::note_property_attribute)
643 << ObjCProperty->getDeclName() << property_note_select;
647 S.Diag(ObjCProperty->getLocation(), diag::note_property_attribute)
648 << ObjCProperty->getDeclName() << property_note_select;
651 S.Diag(UnknownObjCClass->getLocation(), diag::note_forward_class);
678 // Delay if we're currently parsing a declaration.
695 /// Returns true if the given statement can be a body-like child of \p Parent.
697 switch (Parent->getStmtClass()) {
699 return cast<IfStmt>(Parent)->getThen() == S ||
700 cast<IfStmt>(Parent)->getElse() == S;
702 return cast<WhileStmt>(Parent)->getBody() == S;
704 return cast<DoStmt>(Parent)->getBody() == S;
706 return cast<ForStmt>(Parent)->getBody() == S;
708 return cast<CXXForRangeStmt>(Parent)->getBody() == S;
710 return cast<ObjCForCollectionStmt>(Parent)->getBody() == S;
713 return cast<SwitchCase>(Parent)->getSubStmt() == S;
740 if (DRE->getDecl() == D)
749 for (const Stmt *S : llvm::reverse(Scope->body())) {
757 /// This class implements -Wunguarded-availability.
799 bool TraverseCaseStmt(CaseStmt *CS) { return TraverseStmt(CS->getSubStmt()); }
804 if (ObjCMethodDecl *D = Msg->getMethodDecl()) {
806 QualType ReceiverTy = Msg->getClassReceiver();
807 if (!ReceiverTy.isNull() && ReceiverTy->getAsObjCInterfaceType())
808 ID = ReceiverTy->getAsObjCInterfaceType()->getInterface();
811 D, SourceRange(Msg->getSelectorStartLoc(), Msg->getEndLoc()), ID);
817 DiagnoseDeclAvailability(DRE->getDecl(),
818 SourceRange(DRE->getBeginLoc(), DRE->getEndLoc()));
823 DiagnoseDeclAvailability(ME->getMemberDecl(),
824 SourceRange(ME->getBeginLoc(), ME->getEndLoc()));
829 SemaRef.Diag(E->getBeginLoc(), diag::warn_at_available_unchecked_use)
854 VersionTuple Introduced = AA->getIntroduced();
862 AA->getEnvironment(), Ctx,
871 AA->getEnvironment() ? AA->getEnvironment()->getName() : "";
884 SemaRef.Diag(OffendingDecl->getLocation(),
906 if (const auto *CS = dyn_cast<CompoundStmt>(S)) {
907 Scope = CS;
920 for (const Decl *D : cast<DeclStmt>(StmtOfUse)->decls()) {
930 SM.getExpansionLoc(StmtOfUse->getBeginLoc());
933 (LastStmtOfUse ? LastStmtOfUse : StmtOfUse)->getEndLoc())
974 TagDecl *TD = TT->getDecl();
978 TypedefNameDecl *D = TD->getDecl();
982 if (NamedDecl *D = ObjCO->getInterface())
991 if (auto *E = dyn_cast<ObjCAvailabilityCheckExpr>(If->getCond())) {
992 CondVersion = E->getVersion();
997 return TraverseStmt(If->getThen()) && TraverseStmt(If->getElse());
1004 bool ShouldContinue = TraverseStmt(If->getThen());
1007 return ShouldContinue && TraverseStmt(If->getElse());
1015 if (auto *FD = D->getAsFunction()) {
1016 Body = FD->getBody();
1019 for (const CXXCtorInitializer *CI : CD->inits())
1020 DiagnoseUnguardedAvailability(*this, D).IssueDiagnostics(CI->getInit());
1023 Body = MD->getBody();
1025 Body = BD->getBody();
1066 Context->HasPotentialAvailabilityViolations = true;
1073 if (const ObjCPropertyDecl *PD = MD->findPropertyDecl()) {
1074 AvailabilityResult PDeclResult = PD->getAvailability(nullptr);