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!");
129 if (DeclLoc.isMacroID() && S.
getLangOpts().CPlusPlus &&
130 isa<TypedefDecl>(OffendingDecl)) {
132 if (MacroName ==
"CF_OPTIONS" || MacroName ==
"OBJC_OPTIONS" ||
133 MacroName ==
"SWIFT_OPTIONS" || MacroName ==
"NS_OPTIONS") {
139 auto CheckContext = [&](
const Decl *
C) {
142 if (AA->getIntroduced() >= DeclVersion)
145 if (
C->isDeprecated())
151 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(OffendingDecl)) {
152 if (
const auto *Impl = dyn_cast<ObjCImplDecl>(
C)) {
153 if (MD->getClassInterface() == Impl->getClassInterface())
159 if (
C->isUnavailable())
165 if (CheckContext(Ctx))
170 if (
const auto *MethodD = dyn_cast<ObjCMethodDecl>(Ctx))
171 if (MethodD->isClassMethod() &&
172 MethodD->getSelector().getAsString() ==
"load")
175 if (
const auto *CatOrImpl = dyn_cast<ObjCImplDecl>(Ctx)) {
177 if (CheckContext(Interface))
181 else if (
const auto *CatD = dyn_cast<ObjCCategoryDecl>(Ctx))
183 if (CheckContext(Interface))
192 const VersionTuple &DeploymentVersion,
193 const VersionTuple &DeclVersion) {
195 VersionTuple ForceAvailabilityFromVersion;
196 switch (Triple.getOS()) {
197 case llvm::Triple::IOS:
198 case llvm::Triple::TvOS:
199 ForceAvailabilityFromVersion = VersionTuple(11);
201 case llvm::Triple::WatchOS:
202 ForceAvailabilityFromVersion = VersionTuple(4);
204 case llvm::Triple::Darwin:
205 case llvm::Triple::MacOSX:
206 ForceAvailabilityFromVersion = VersionTuple(10, 13);
208 case llvm::Triple::ShaderModel:
213 return Triple.getVendor() == llvm::Triple::Apple;
215 return DeploymentVersion >= ForceAvailabilityFromVersion ||
216 DeclVersion >= ForceAvailabilityFromVersion;
220 for (
Decl *Ctx = OrigCtx; Ctx;
221 Ctx = cast_or_null<Decl>(Ctx->getDeclContext())) {
222 if (isa<TagDecl>(Ctx) || isa<FunctionDecl>(Ctx) || isa<ObjCMethodDecl>(Ctx))
223 return cast<NamedDecl>(Ctx);
224 if (
auto *CD = dyn_cast<ObjCContainerDecl>(Ctx)) {
225 if (
auto *Imp = dyn_cast<ObjCImplDecl>(Ctx))
226 return Imp->getClassInterface();
231 return dyn_cast<NamedDecl>(OrigCtx);
236struct AttributeInsertion {
241 static AttributeInsertion createInsertionAfter(
const NamedDecl *D) {
244 static AttributeInsertion createInsertionAfter(
SourceLocation Loc) {
245 return {
" ", Loc,
""};
247 static AttributeInsertion createInsertionBefore(
const NamedDecl *D) {
262static std::optional<unsigned>
266 if (!Name.empty() && (Name.front() ==
'-' || Name.front() ==
'+'))
267 Name = Name.drop_front(1);
270 Name.split(SlotNames,
':');
272 if (Name.back() ==
':') {
274 SlotNames.pop_back();
275 NumParams = SlotNames.size();
277 if (SlotNames.size() != 1)
283 bool AllowDollar = LangOpts.DollarIdents;
284 for (StringRef S : SlotNames) {
295static std::optional<AttributeInsertion>
298 if (isa<ObjCPropertyDecl>(D))
299 return AttributeInsertion::createInsertionAfter(D);
300 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
303 return AttributeInsertion::createInsertionAfter(D);
305 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
311 return AttributeInsertion::createInsertionAfter(Loc);
313 return AttributeInsertion::createInsertionBefore(D);
333 bool ObjCPropertyAccess) {
335 unsigned diag, diag_message, diag_fwdclass_message;
336 unsigned diag_available_here = diag::note_availability_specified_here;
340 unsigned property_note_select;
343 unsigned available_here_select_kind;
345 VersionTuple DeclVersion;
347 DeclVersion = AA->getIntroduced();
358 if (A && A->isInherited()) {
361 const AvailabilityAttr *AForRedecl =
363 if (AForRedecl && !AForRedecl->isInherited()) {
366 NoteLocation = Redecl->getLocation();
378 const AvailabilityAttr *AA =
380 VersionTuple Introduced = AA->getIntroduced();
385 unsigned Warning = UseNewWarning ? diag::warn_unguarded_availability_new
386 : diag::warn_unguarded_availability;
388 std::string PlatformName(AvailabilityAttr::getPrettyPlatformName(
391 S.
Diag(Loc,
Warning) << OffendingDecl << PlatformName
392 << Introduced.getAsString();
395 diag::note_partial_availability_specified_here)
396 << OffendingDecl << PlatformName << Introduced.getAsString()
400 if (
const auto *TD = dyn_cast<TagDecl>(Enclosing))
401 if (TD->getDeclName().isEmpty()) {
402 S.
Diag(TD->getLocation(),
403 diag::note_decl_unguarded_availability_silence)
404 << 1 << TD->getKindName();
408 S.
Diag(Enclosing->getLocation(),
409 diag::note_decl_unguarded_availability_silence)
412 if (Enclosing->hasAttr<AvailabilityAttr>())
420 std::string PlatformName =
421 AvailabilityAttr::getPlatformNameSourceSpelling(
424 std::string Introduced =
428 (llvm::Twine(Insertion->Prefix) +
"API_AVAILABLE(" + PlatformName +
429 "(" + Introduced +
"))" + Insertion->Suffix)
435 diag = !ObjCPropertyAccess ? diag::warn_deprecated
436 : diag::warn_property_method_deprecated;
437 diag_message = diag::warn_deprecated_message;
438 diag_fwdclass_message = diag::warn_deprecated_fwdclass_message;
439 property_note_select = 0;
440 available_here_select_kind = 2;
441 if (
const auto *AL = OffendingDecl->
getAttr<DeprecatedAttr>())
442 NoteLocation = AL->getLocation();
446 diag = !ObjCPropertyAccess ? diag::err_unavailable
447 : diag::err_property_method_unavailable;
448 diag_message = diag::err_unavailable_message;
449 diag_fwdclass_message = diag::warn_unavailable_fwdclass_message;
450 property_note_select = 1;
451 available_here_select_kind = 0;
453 if (
auto AL = OffendingDecl->
getAttr<UnavailableAttr>()) {
454 if (AL->isImplicit() && AL->getImplicitReason()) {
457 auto flagARCError = [&] {
461 diag = diag::err_unavailable_in_arc;
464 switch (AL->getImplicitReason()) {
465 case UnavailableAttr::IR_None:
break;
467 case UnavailableAttr::IR_ARCForbiddenType:
469 diag_available_here = diag::note_arc_forbidden_type;
472 case UnavailableAttr::IR_ForbiddenWeak:
474 diag_available_here = diag::note_arc_weak_disabled;
476 diag_available_here = diag::note_arc_weak_no_runtime;
479 case UnavailableAttr::IR_ARCForbiddenConversion:
481 diag_available_here = diag::note_performs_forbidden_arc_conversion;
484 case UnavailableAttr::IR_ARCInitReturnsUnrelated:
486 diag_available_here = diag::note_arc_init_returns_unrelated;
489 case UnavailableAttr::IR_ARCFieldWithOwnership:
491 diag_available_here = diag::note_arc_field_with_ownership;
499 llvm_unreachable(
"Warning for availability of available declaration?");
504 StringRef Replacement;
505 if (
auto AL = OffendingDecl->
getAttr<DeprecatedAttr>())
506 Replacement = AL->getReplacement();
508 Replacement = AL->getReplacement();
511 if (!Replacement.empty())
515 if (
const auto *MethodDecl = dyn_cast<ObjCMethodDecl>(ReferringDecl)) {
516 Selector Sel = MethodDecl->getSelector();
520 if (NumParams && *NumParams == Sel.
getNumArgs()) {
521 assert(SelectorSlotNames.size() == Locs.size());
522 for (
unsigned I = 0; I < Locs.size(); ++I) {
527 NameRange, SelectorSlotNames[I]));
539 if (!Message.empty()) {
540 S.
Diag(Loc, diag_message) << ReferringDecl << Message << FixIts;
543 << ObjCProperty->
getDeclName() << property_note_select;
544 }
else if (!UnknownObjCClass) {
545 S.
Diag(Loc, diag) << ReferringDecl << FixIts;
548 << ObjCProperty->
getDeclName() << property_note_select;
550 S.
Diag(Loc, diag_fwdclass_message) << ReferringDecl << FixIts;
554 S.
Diag(NoteLocation, diag_available_here)
555 << OffendingDecl << available_here_select_kind;
560 "Expected an availability diagnostic here");
577 bool ObjCPropertyAccess) {
582 AR, Locs, ReferringDecl, OffendingDecl, UnknownObjCClass,
583 ObjCProperty, Message, ObjCPropertyAccess));
589 Message, Locs, UnknownObjCClass, ObjCProperty,
597 switch (
Parent->getStmtClass()) {
598 case Stmt::IfStmtClass:
599 return cast<IfStmt>(
Parent)->getThen() == S ||
600 cast<IfStmt>(
Parent)->getElse() == S;
601 case Stmt::WhileStmtClass:
602 return cast<WhileStmt>(
Parent)->getBody() == S;
603 case Stmt::DoStmtClass:
604 return cast<DoStmt>(
Parent)->getBody() == S;
605 case Stmt::ForStmtClass:
606 return cast<ForStmt>(
Parent)->getBody() == S;
607 case Stmt::CXXForRangeStmtClass:
608 return cast<CXXForRangeStmt>(
Parent)->getBody() == S;
609 case Stmt::ObjCForCollectionStmtClass:
610 return cast<ObjCForCollectionStmt>(
Parent)->getBody() == S;
611 case Stmt::CaseStmtClass:
612 case Stmt::DefaultStmtClass:
613 return cast<SwitchCase>(
Parent)->getSubStmt() == S;
623 bool VisitStmt(
Stmt *S) {
return S !=
Target; }
626 static bool isContained(
const Stmt *Target,
const Decl *D) {
627 StmtUSEFinder Visitor;
629 return !Visitor.TraverseDecl(
const_cast<Decl *
>(D));
645 static const Stmt *findLastStmtThatUsesDecl(
const Decl *D,
647 LastDeclUSEFinder Visitor;
649 for (
const Stmt *S : llvm::reverse(
Scope->body())) {
650 if (!Visitor.TraverseStmt(
const_cast<Stmt *
>(S)))
663class DiagnoseUnguardedAvailability
678 DiagnoseUnguardedAvailability(
Sema &SemaRef,
Decl *Ctx)
679 : SemaRef(SemaRef), Ctx(Ctx) {
680 AvailabilityStack.push_back(
684 bool TraverseStmt(
Stmt *S) {
687 StmtStack.push_back(S);
688 bool Result = Base::TraverseStmt(S);
689 StmtStack.pop_back();
693 void IssueDiagnostics(
Stmt *S) { TraverseStmt(S); }
695 bool TraverseIfStmt(
IfStmt *If);
710 DiagnoseDeclAvailability(
717 DiagnoseDeclAvailability(DRE->
getDecl(),
737void DiagnoseUnguardedAvailability::DiagnoseDeclAvailability(
741 std::tie(
Result, OffendingDecl) =
749 const AvailabilityAttr *AA =
751 VersionTuple Introduced = AA->getIntroduced();
753 if (AvailabilityStack.back() >= Introduced)
770 ? diag::warn_unguarded_availability_new
771 : diag::warn_unguarded_availability;
773 std::string PlatformName(AvailabilityAttr::getPrettyPlatformName(
777 <<
Range << D << PlatformName << Introduced.getAsString();
780 diag::note_partial_availability_specified_here)
781 << OffendingDecl << PlatformName << Introduced.getAsString()
787 SemaRef.
Diag(
Range.getBegin(), diag::note_unguarded_available_silence)
793 if (StmtStack.empty())
795 const Stmt *StmtOfUse = StmtStack.back();
797 for (
const Stmt *S : llvm::reverse(StmtStack)) {
798 if (
const auto *CS = dyn_cast<CompoundStmt>(S)) {
802 if (isBodyLikeChildStmt(StmtOfUse, S)) {
810 const Stmt *LastStmtOfUse =
nullptr;
811 if (isa<DeclStmt>(StmtOfUse) &&
Scope) {
812 for (
const Decl *D : cast<DeclStmt>(StmtOfUse)->decls()) {
813 if (StmtUSEFinder::isContained(StmtStack.back(), D)) {
814 LastStmtOfUse = LastDeclUSEFinder::findLastStmtThatUsesDecl(D,
Scope);
824 SM.getExpansionRange(
825 (LastStmtOfUse ? LastStmtOfUse : StmtOfUse)->getEndLoc())
827 if (
SM.getFileID(IfInsertionLoc) !=
SM.getFileID(StmtEndLoc))
831 const char *ExtraIndentation =
" ";
832 std::string FixItString;
833 llvm::raw_string_ostream FixItOS(FixItString);
834 FixItOS <<
"if (" << (SemaRef.
getLangOpts().ObjC ?
"@available"
835 :
"__builtin_available")
837 << AvailabilityAttr::getPlatformNameSourceSpelling(
839 <<
" " << Introduced.getAsString() <<
", *)) {\n"
840 << Indentation << ExtraIndentation;
848 FixItOS.str().clear();
850 << Indentation <<
"} else {\n"
851 << Indentation << ExtraIndentation
852 <<
"// Fallback on earlier versions\n"
853 << Indentation <<
"}";
858bool DiagnoseUnguardedAvailability::VisitTypeLoc(
TypeLoc Ty) {
862 if (
Range.isInvalid())
865 if (
const auto *TT = dyn_cast<TagType>(TyPtr)) {
867 DiagnoseDeclAvailability(TD, Range);
869 }
else if (
const auto *TD = dyn_cast<TypedefType>(TyPtr)) {
871 DiagnoseDeclAvailability(D, Range);
873 }
else if (
const auto *ObjCO = dyn_cast<ObjCObjectType>(TyPtr)) {
874 if (
NamedDecl *D = ObjCO->getInterface())
875 DiagnoseDeclAvailability(D, Range);
881bool DiagnoseUnguardedAvailability::TraverseIfStmt(
IfStmt *If) {
882 VersionTuple CondVersion;
883 if (
auto *E = dyn_cast<ObjCAvailabilityCheckExpr>(If->
getCond())) {
888 if (CondVersion.empty() || CondVersion <= AvailabilityStack.back())
889 return TraverseStmt(If->
getThen()) && TraverseStmt(If->
getElse());
892 return Base::TraverseIfStmt(If);
895 AvailabilityStack.push_back(CondVersion);
896 bool ShouldContinue = TraverseStmt(If->
getThen());
897 AvailabilityStack.pop_back();
899 return ShouldContinue && TraverseStmt(If->
getElse());
905 Stmt *Body =
nullptr;
910 if (FD->isTemplateInstantiation())
913 Body = FD->getBody();
915 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD))
917 DiagnoseUnguardedAvailability(*
this, D).IssueDiagnostics(CI->getInit());
919 }
else if (
auto *MD = dyn_cast<ObjCMethodDecl>(D))
920 Body = MD->getBody();
921 else if (
auto *BD = dyn_cast<BlockDecl>(D))
922 Body = BD->getBody();
924 assert(Body &&
"Need a body here!");
926 DiagnoseUnguardedAvailability(*
this, D).IssueDiagnostics(Body);
943 bool ObjCPropertyAccess,
944 bool AvoidPartialAvailabilityChecks,
950 std::tie(
Result, OffendingDecl) =
956 if (AvoidPartialAvailabilityChecks)
963 Context->HasPotentialAvailabilityViolations =
true;
969 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
972 if (PDeclResult ==
Result)
978 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)
StringRef getImmediateMacroName(SourceLocation Loc)
Retrieve the name of the immediate macro expansion.
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.