30 for (
const auto *A : D->
attrs()) {
31 if (
const auto *Avail = dyn_cast<AvailabilityAttr>(A)) {
37 StringRef ActualPlatform = Avail->getPlatform()->getName();
38 StringRef RealizedPlatform = ActualPlatform;
40 size_t suffix = RealizedPlatform.rfind(
"_app_extension");
41 if (suffix != StringRef::npos)
42 RealizedPlatform = RealizedPlatform.slice(0, suffix);
48 if (RealizedPlatform == TargetPlatform)
63static std::pair<AvailabilityResult, const NamedDecl *>
71 while (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
73 if (
const auto *TT = TD->getUnderlyingType()->getAs<
TagType>()) {
83 if (
const auto *IDecl = dyn_cast<ObjCInterfaceDecl>(D)) {
84 if (IDecl->getDefinition()) {
85 D = IDecl->getDefinition();
90 if (
const auto *ECD = dyn_cast<EnumConstantDecl>(D))
93 if (
const auto *TheEnumDecl = dyn_cast<EnumDecl>(DC)) {
100 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
104 if (Init && Result ==
AR_Available && MD->isClassMethod() &&
105 MD->getSelector() == S.
NSAPIObj->getNewSelector() &&
107 Result = Init->getAvailability(Message);
122 VersionTuple DeclVersion,
Decl *Ctx,
124 assert(K !=
AR_Available &&
"Expected an unavailable declaration here!");
127 auto CheckContext = [&](
const Decl *
C) {
130 if (AA->getIntroduced() >= DeclVersion)
133 if (
C->isDeprecated())
139 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(OffendingDecl)) {
140 if (
const auto *Impl = dyn_cast<ObjCImplDecl>(
C)) {
141 if (MD->getClassInterface() == Impl->getClassInterface())
147 if (
C->isUnavailable())
153 if (CheckContext(Ctx))
158 if (
const auto *MethodD = dyn_cast<ObjCMethodDecl>(Ctx))
159 if (MethodD->isClassMethod() &&
160 MethodD->getSelector().getAsString() ==
"load")
163 if (
const auto *CatOrImpl = dyn_cast<ObjCImplDecl>(Ctx)) {
165 if (CheckContext(Interface))
169 else if (
const auto *CatD = dyn_cast<ObjCCategoryDecl>(Ctx))
171 if (CheckContext(Interface))
180 const VersionTuple &DeploymentVersion,
181 const VersionTuple &DeclVersion) {
183 VersionTuple ForceAvailabilityFromVersion;
184 switch (Triple.getOS()) {
185 case llvm::Triple::IOS:
186 case llvm::Triple::TvOS:
187 ForceAvailabilityFromVersion = VersionTuple(11);
189 case llvm::Triple::WatchOS:
190 ForceAvailabilityFromVersion = VersionTuple(4);
192 case llvm::Triple::Darwin:
193 case llvm::Triple::MacOSX:
194 ForceAvailabilityFromVersion = VersionTuple(10, 13);
196 case llvm::Triple::ShaderModel:
201 return Triple.getVendor() == llvm::Triple::Apple;
203 return DeploymentVersion >= ForceAvailabilityFromVersion ||
204 DeclVersion >= ForceAvailabilityFromVersion;
208 for (
Decl *Ctx = OrigCtx; Ctx;
209 Ctx = cast_or_null<Decl>(Ctx->getDeclContext())) {
210 if (isa<TagDecl>(Ctx) || isa<FunctionDecl>(Ctx) || isa<ObjCMethodDecl>(Ctx))
211 return cast<NamedDecl>(Ctx);
212 if (
auto *CD = dyn_cast<ObjCContainerDecl>(Ctx)) {
213 if (
auto *Imp = dyn_cast<ObjCImplDecl>(Ctx))
214 return Imp->getClassInterface();
219 return dyn_cast<NamedDecl>(OrigCtx);
224struct AttributeInsertion {
229 static AttributeInsertion createInsertionAfter(
const NamedDecl *D) {
232 static AttributeInsertion createInsertionAfter(
SourceLocation Loc) {
233 return {
" ", Loc,
""};
235 static AttributeInsertion createInsertionBefore(
const NamedDecl *D) {
250static std::optional<unsigned>
254 if (!Name.empty() && (Name.front() ==
'-' || Name.front() ==
'+'))
255 Name = Name.drop_front(1);
258 Name.split(SlotNames,
':');
260 if (Name.back() ==
':') {
262 SlotNames.pop_back();
263 NumParams = SlotNames.size();
265 if (SlotNames.size() != 1)
271 bool AllowDollar = LangOpts.DollarIdents;
272 for (StringRef S : SlotNames) {
283static std::optional<AttributeInsertion>
286 if (isa<ObjCPropertyDecl>(D))
287 return AttributeInsertion::createInsertionAfter(D);
288 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
291 return AttributeInsertion::createInsertionAfter(D);
293 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
299 return AttributeInsertion::createInsertionAfter(Loc);
301 return AttributeInsertion::createInsertionBefore(D);
321 bool ObjCPropertyAccess) {
323 unsigned diag, diag_message, diag_fwdclass_message;
324 unsigned diag_available_here = diag::note_availability_specified_here;
328 unsigned property_note_select;
331 unsigned available_here_select_kind;
333 VersionTuple DeclVersion;
335 DeclVersion = AA->getIntroduced();
346 if (A && A->isInherited()) {
349 const AvailabilityAttr *AForRedecl =
351 if (AForRedecl && !AForRedecl->isInherited()) {
354 NoteLocation = Redecl->getLocation();
366 const AvailabilityAttr *AA =
368 VersionTuple Introduced = AA->getIntroduced();
373 unsigned Warning = UseNewWarning ? diag::warn_unguarded_availability_new
374 : diag::warn_unguarded_availability;
376 std::string PlatformName(AvailabilityAttr::getPrettyPlatformName(
379 S.
Diag(Loc,
Warning) << OffendingDecl << PlatformName
380 << Introduced.getAsString();
383 diag::note_partial_availability_specified_here)
384 << OffendingDecl << PlatformName << Introduced.getAsString()
388 if (
const auto *TD = dyn_cast<TagDecl>(Enclosing))
389 if (TD->getDeclName().isEmpty()) {
390 S.
Diag(TD->getLocation(),
391 diag::note_decl_unguarded_availability_silence)
392 << 1 << TD->getKindName();
396 S.
Diag(Enclosing->getLocation(),
397 diag::note_decl_unguarded_availability_silence)
400 if (Enclosing->hasAttr<AvailabilityAttr>())
408 std::string PlatformName =
409 AvailabilityAttr::getPlatformNameSourceSpelling(
412 std::string Introduced =
416 (llvm::Twine(Insertion->Prefix) +
"API_AVAILABLE(" + PlatformName +
417 "(" + Introduced +
"))" + Insertion->Suffix)
423 diag = !ObjCPropertyAccess ? diag::warn_deprecated
424 : diag::warn_property_method_deprecated;
425 diag_message = diag::warn_deprecated_message;
426 diag_fwdclass_message = diag::warn_deprecated_fwdclass_message;
427 property_note_select = 0;
428 available_here_select_kind = 2;
429 if (
const auto *AL = OffendingDecl->
getAttr<DeprecatedAttr>())
430 NoteLocation = AL->getLocation();
434 diag = !ObjCPropertyAccess ? diag::err_unavailable
435 : diag::err_property_method_unavailable;
436 diag_message = diag::err_unavailable_message;
437 diag_fwdclass_message = diag::warn_unavailable_fwdclass_message;
438 property_note_select = 1;
439 available_here_select_kind = 0;
441 if (
auto AL = OffendingDecl->
getAttr<UnavailableAttr>()) {
442 if (AL->isImplicit() && AL->getImplicitReason()) {
445 auto flagARCError = [&] {
449 diag = diag::err_unavailable_in_arc;
452 switch (AL->getImplicitReason()) {
453 case UnavailableAttr::IR_None:
break;
455 case UnavailableAttr::IR_ARCForbiddenType:
457 diag_available_here = diag::note_arc_forbidden_type;
460 case UnavailableAttr::IR_ForbiddenWeak:
462 diag_available_here = diag::note_arc_weak_disabled;
464 diag_available_here = diag::note_arc_weak_no_runtime;
467 case UnavailableAttr::IR_ARCForbiddenConversion:
469 diag_available_here = diag::note_performs_forbidden_arc_conversion;
472 case UnavailableAttr::IR_ARCInitReturnsUnrelated:
474 diag_available_here = diag::note_arc_init_returns_unrelated;
477 case UnavailableAttr::IR_ARCFieldWithOwnership:
479 diag_available_here = diag::note_arc_field_with_ownership;
487 llvm_unreachable(
"Warning for availability of available declaration?");
492 StringRef Replacement;
493 if (
auto AL = OffendingDecl->
getAttr<DeprecatedAttr>())
494 Replacement = AL->getReplacement();
496 Replacement = AL->getReplacement();
499 if (!Replacement.empty())
503 if (
const auto *MethodDecl = dyn_cast<ObjCMethodDecl>(ReferringDecl)) {
504 Selector Sel = MethodDecl->getSelector();
508 if (NumParams && *NumParams == Sel.
getNumArgs()) {
509 assert(SelectorSlotNames.size() == Locs.size());
510 for (
unsigned I = 0; I < Locs.size(); ++I) {
515 NameRange, SelectorSlotNames[I]));
527 if (!Message.empty()) {
528 S.
Diag(Loc, diag_message) << ReferringDecl << Message << FixIts;
531 << ObjCProperty->
getDeclName() << property_note_select;
532 }
else if (!UnknownObjCClass) {
533 S.
Diag(Loc, diag) << ReferringDecl << FixIts;
536 << ObjCProperty->
getDeclName() << property_note_select;
538 S.
Diag(Loc, diag_fwdclass_message) << ReferringDecl << FixIts;
542 S.
Diag(NoteLocation, diag_available_here)
543 << OffendingDecl << available_here_select_kind;
548 "Expected an availability diagnostic here");
565 bool ObjCPropertyAccess) {
570 AR, Locs, ReferringDecl, OffendingDecl, UnknownObjCClass,
571 ObjCProperty, Message, ObjCPropertyAccess));
577 Message, Locs, UnknownObjCClass, ObjCProperty,
585 switch (
Parent->getStmtClass()) {
586 case Stmt::IfStmtClass:
587 return cast<IfStmt>(
Parent)->getThen() == S ||
588 cast<IfStmt>(
Parent)->getElse() == S;
589 case Stmt::WhileStmtClass:
590 return cast<WhileStmt>(
Parent)->getBody() == S;
591 case Stmt::DoStmtClass:
592 return cast<DoStmt>(
Parent)->getBody() == S;
593 case Stmt::ForStmtClass:
594 return cast<ForStmt>(
Parent)->getBody() == S;
595 case Stmt::CXXForRangeStmtClass:
596 return cast<CXXForRangeStmt>(
Parent)->getBody() == S;
597 case Stmt::ObjCForCollectionStmtClass:
598 return cast<ObjCForCollectionStmt>(
Parent)->getBody() == S;
599 case Stmt::CaseStmtClass:
600 case Stmt::DefaultStmtClass:
601 return cast<SwitchCase>(
Parent)->getSubStmt() == S;
611 bool VisitStmt(
Stmt *S) {
return S !=
Target; }
614 static bool isContained(
const Stmt *Target,
const Decl *D) {
615 StmtUSEFinder Visitor;
617 return !Visitor.TraverseDecl(
const_cast<Decl *
>(D));
633 static const Stmt *findLastStmtThatUsesDecl(
const Decl *D,
635 LastDeclUSEFinder Visitor;
637 for (
const Stmt *S : llvm::reverse(
Scope->body())) {
638 if (!Visitor.TraverseStmt(
const_cast<Stmt *
>(S)))
651class DiagnoseUnguardedAvailability
666 DiagnoseUnguardedAvailability(
Sema &SemaRef,
Decl *Ctx)
667 : SemaRef(SemaRef), Ctx(Ctx) {
668 AvailabilityStack.push_back(
672 bool TraverseStmt(
Stmt *S) {
675 StmtStack.push_back(S);
676 bool Result = Base::TraverseStmt(S);
677 StmtStack.pop_back();
681 void IssueDiagnostics(
Stmt *S) { TraverseStmt(S); }
683 bool TraverseIfStmt(
IfStmt *If);
698 DiagnoseDeclAvailability(
705 DiagnoseDeclAvailability(DRE->
getDecl(),
725void DiagnoseUnguardedAvailability::DiagnoseDeclAvailability(
729 std::tie(
Result, OffendingDecl) =
737 const AvailabilityAttr *AA =
739 VersionTuple Introduced = AA->getIntroduced();
741 if (AvailabilityStack.back() >= Introduced)
758 ? diag::warn_unguarded_availability_new
759 : diag::warn_unguarded_availability;
761 std::string PlatformName(AvailabilityAttr::getPrettyPlatformName(
765 <<
Range << D << PlatformName << Introduced.getAsString();
768 diag::note_partial_availability_specified_here)
769 << OffendingDecl << PlatformName << Introduced.getAsString()
775 SemaRef.
Diag(
Range.getBegin(), diag::note_unguarded_available_silence)
781 if (StmtStack.empty())
783 const Stmt *StmtOfUse = StmtStack.back();
785 for (
const Stmt *S : llvm::reverse(StmtStack)) {
786 if (
const auto *CS = dyn_cast<CompoundStmt>(S)) {
790 if (isBodyLikeChildStmt(StmtOfUse, S)) {
798 const Stmt *LastStmtOfUse =
nullptr;
799 if (isa<DeclStmt>(StmtOfUse) &&
Scope) {
800 for (
const Decl *D : cast<DeclStmt>(StmtOfUse)->decls()) {
801 if (StmtUSEFinder::isContained(StmtStack.back(), D)) {
802 LastStmtOfUse = LastDeclUSEFinder::findLastStmtThatUsesDecl(D,
Scope);
812 SM.getExpansionRange(
813 (LastStmtOfUse ? LastStmtOfUse : StmtOfUse)->getEndLoc())
815 if (
SM.getFileID(IfInsertionLoc) !=
SM.getFileID(StmtEndLoc))
819 const char *ExtraIndentation =
" ";
820 std::string FixItString;
821 llvm::raw_string_ostream FixItOS(FixItString);
822 FixItOS <<
"if (" << (SemaRef.
getLangOpts().ObjC ?
"@available"
823 :
"__builtin_available")
825 << AvailabilityAttr::getPlatformNameSourceSpelling(
827 <<
" " << Introduced.getAsString() <<
", *)) {\n"
828 << Indentation << ExtraIndentation;
836 FixItOS.str().clear();
838 << Indentation <<
"} else {\n"
839 << Indentation << ExtraIndentation
840 <<
"// Fallback on earlier versions\n"
841 << Indentation <<
"}";
846bool DiagnoseUnguardedAvailability::VisitTypeLoc(
TypeLoc Ty) {
850 if (
Range.isInvalid())
853 if (
const auto *TT = dyn_cast<TagType>(TyPtr)) {
855 DiagnoseDeclAvailability(TD, Range);
857 }
else if (
const auto *TD = dyn_cast<TypedefType>(TyPtr)) {
859 DiagnoseDeclAvailability(D, Range);
861 }
else if (
const auto *ObjCO = dyn_cast<ObjCObjectType>(TyPtr)) {
862 if (
NamedDecl *D = ObjCO->getInterface())
863 DiagnoseDeclAvailability(D, Range);
869bool DiagnoseUnguardedAvailability::TraverseIfStmt(
IfStmt *If) {
870 VersionTuple CondVersion;
871 if (
auto *E = dyn_cast<ObjCAvailabilityCheckExpr>(If->
getCond())) {
876 if (CondVersion.empty() || CondVersion <= AvailabilityStack.back())
877 return TraverseStmt(If->
getThen()) && TraverseStmt(If->
getElse());
880 return Base::TraverseIfStmt(If);
883 AvailabilityStack.push_back(CondVersion);
884 bool ShouldContinue = TraverseStmt(If->
getThen());
885 AvailabilityStack.pop_back();
887 return ShouldContinue && TraverseStmt(If->
getElse());
893 Stmt *Body =
nullptr;
898 if (FD->isTemplateInstantiation())
901 Body = FD->getBody();
903 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD))
905 DiagnoseUnguardedAvailability(*
this, D).IssueDiagnostics(CI->getInit());
907 }
else if (
auto *MD = dyn_cast<ObjCMethodDecl>(D))
908 Body = MD->getBody();
909 else if (
auto *BD = dyn_cast<BlockDecl>(D))
910 Body = BD->getBody();
912 assert(Body &&
"Need a body here!");
914 DiagnoseUnguardedAvailability(*
this, D).IssueDiagnostics(Body);
931 bool ObjCPropertyAccess,
932 bool AvoidPartialAvailabilityChecks,
938 std::tie(
Result, OffendingDecl) =
944 if (AvoidPartialAvailabilityChecks)
951 Context->HasPotentialAvailabilityViolations =
true;
957 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
960 if (PDeclResult ==
Result)
966 UnknownObjCClass, ObjCPDecl, ObjCPropertyAccess);
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Defines the clang::Preprocessor interface.
static std::pair< AvailabilityResult, const NamedDecl * > ShouldDiagnoseAvailabilityOfDecl(Sema &S, const NamedDecl *D, std::string *Message, ObjCInterfaceDecl *ClassReceiver)
The diagnostic we should emit for D, and the declaration that originated it, or AR_Available.
static bool ShouldDiagnoseAvailabilityInContext(Sema &S, AvailabilityResult K, VersionTuple DeclVersion, Decl *Ctx, const NamedDecl *OffendingDecl)
whether we should emit a diagnostic for K and DeclVersion in the context of Ctx.
static std::optional< AttributeInsertion > createAttributeInsertion(const NamedDecl *D, const SourceManager &SM, const LangOptions &LangOpts)
Returns a source location in which it's appropriate to insert a new attribute for the given declarati...
static void EmitAvailabilityWarning(Sema &S, AvailabilityResult AR, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, StringRef Message, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, bool ObjCPropertyAccess)
static void DoEmitAvailabilityWarning(Sema &S, AvailabilityResult K, Decl *Ctx, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, StringRef Message, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, bool ObjCPropertyAccess)
Actually emit an availability diagnostic for a reference to an unavailable decl.
static bool shouldDiagnoseAvailabilityByDefault(const ASTContext &Context, const VersionTuple &DeploymentVersion, const VersionTuple &DeclVersion)
static NamedDecl * findEnclosingDeclToAnnotate(Decl *OrigCtx)
static std::optional< unsigned > tryParseObjCMethodName(StringRef Name, SmallVectorImpl< StringRef > &SlotNames, const LangOptions &LangOpts)
Tries to parse a string as ObjC method name.
static const AvailabilityAttr * getAttrForPlatform(ASTContext &Context, const Decl *D)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const LangOptions & getLangOpts() const
const TargetInfo & getTargetInfo() const
Represents a C++ base or member initializer.
CaseStmt - Represent a case statement.
Represents a character-granular source range.
static CharSourceRange getCharRange(SourceRange R)
CompoundStmt - This represents a group of statements like { stmt stmt }.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
A reference to a declared variable, function, enum, etc.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getEndLoc() const LLVM_READONLY
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
SourceLocation getEndLoc() const LLVM_READONLY
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
SourceLocation getLocation() const
DeclContext * getDeclContext()
SourceLocation getBeginLoc() const LLVM_READONLY
VersionTuple getVersionIntroduced() const
Retrieve the version of the target platform in which this declaration was introduced.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
IfStmt - This represents an if/then/else.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
static SourceLocation findLocationAfterToken(SourceLocation loc, tok::TokenKind TKind, const SourceManager &SM, const LangOptions &LangOpts, bool SkipTrailingWhitespaceAndNewLine)
Checks that the given token is the first token that occurs after the given location (this excludes co...
static StringRef getIndentationForLine(SourceLocation Loc, const SourceManager &SM)
Returns the leading whitespace for line that corresponds to the given location Loc.
static SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset, const SourceManager &SM, const LangOptions &LangOpts)
Computes the source location just past the end of the token at this source location.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
This represents a decl that may have a name.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
NamedDecl * getMostRecentDecl()
A runtime availability query.
SourceLocation getBeginLoc() const
VersionTuple getVersion() const
Represents an ObjC class declaration.
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Lookup an instance method for a given selector.
An expression that sends a message to the given Objective-C object or class.
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
const ObjCMethodDecl * getMethodDecl() const
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getSelectorStartLoc() const
ObjCMethodDecl - Represents an instance or class method declaration.
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface.
Represents one property declaration in an Objective-C interface.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
bool isMacroDefined(StringRef Id)
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
Scope - A scope is a transient data structure that is used while parsing the program.
Smart pointer class that efficiently represents Objective-C method names.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
unsigned getNumArgs() const
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
Sema - This implements semantic analysis and AST building for C.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Preprocessor & getPreprocessor() const
class clang::Sema::DelayedDiagnostics DelayedDiagnostics
ASTContext & getASTContext() const
void DiagnoseUnguardedAvailabilityViolations(Decl *FD)
Issue any -Wunguarded-availability warnings in FD.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
const LangOptions & getLangOpts() const
DeclContext * getCurLexicalContext() const
SourceManager & getSourceManager() const
sema::FunctionScopeInfo * getCurFunctionAvailabilityContext()
Retrieve the current function, if any, that should be analyzed for potential availability violations.
void DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass, bool ObjCPropertyAccess, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr)
void handleDelayedAvailabilityCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
Encodes a location in the source.
This class handles loading and caching of source files into memory.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
SourceLocation getBeginLoc() const LLVM_READONLY
Represents the declaration of a struct/union/class/enum.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
VersionTuple getPlatformMinVersion() const
Retrieve the minimum desired version of the platform, to which the program should be compiled.
Base wrapper for a particular "section" of type source info.
SourceLocation getEndLoc() const
Get the end source location.
SourceLocation getBeginLoc() const
Get the begin source location.
const Type * getTypePtr() const
The base class of the type hierarchy.
const ObjCObjectType * getAsObjCInterfaceType() const
Base class for declarations which introduce a typedef-name.
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
static DelayedDiagnostic makeAvailability(AvailabilityResult AR, ArrayRef< SourceLocation > Locs, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, StringRef Msg, bool ObjCPropertyAccess)
const ObjCInterfaceDecl * getUnknownObjCClass() const
const NamedDecl * getAvailabilityOffendingDecl() const
const ObjCPropertyDecl * getObjCProperty() const
StringRef getAvailabilityMessage() const
ArrayRef< SourceLocation > getAvailabilitySelectorLocs() const
AvailabilityResult getAvailabilityResult() const
const NamedDecl * getAvailabilityReferringDecl() const
Retains information about a function, method, or block that is currently being parsed.
Defines the clang::TargetInfo interface.
LLVM_READONLY bool isValidAsciiIdentifier(StringRef S, bool AllowDollar=false)
Return true if this is a valid ASCII identifier.
@ C
Languages that the frontend can parse and compile.
@ Result
The result type of a method or function.
AvailabilityResult
Captures the result of checking the availability of a declaration.