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)) {
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)) {
181 else if (
const auto *CatD = dyn_cast<ObjCCategoryDecl>(Ctx))
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]));
545 bool ShouldAllowWarningInSystemHeader =
546 InstantiationLoc != Loc &&
548 struct AllowWarningInSystemHeaders {
550 bool AllowWarningInSystemHeaders)
554 ~AllowWarningInSystemHeaders() { Engine.setSuppressSystemWarnings(Prev); }
560 ShouldAllowWarningInSystemHeader);
562 if (!Message.empty()) {
563 S.
Diag(Loc, diag_message) << ReferringDecl << Message << FixIts;
566 << ObjCProperty->
getDeclName() << property_note_select;
567 }
else if (!UnknownObjCClass) {
568 S.
Diag(Loc, diag) << ReferringDecl << FixIts;
571 << ObjCProperty->
getDeclName() << property_note_select;
573 S.
Diag(Loc, diag_fwdclass_message) << ReferringDecl << FixIts;
577 S.
Diag(NoteLocation, diag_available_here)
578 << OffendingDecl << available_here_select_kind;
583 "Expected an availability diagnostic here");
600 bool ObjCPropertyAccess) {
605 AR, Locs, ReferringDecl, OffendingDecl, UnknownObjCClass,
606 ObjCProperty, Message, ObjCPropertyAccess));
612 Message, Locs, UnknownObjCClass, ObjCProperty,
620 switch (
Parent->getStmtClass()) {
621 case Stmt::IfStmtClass:
622 return cast<IfStmt>(
Parent)->getThen() == S ||
623 cast<IfStmt>(
Parent)->getElse() == S;
624 case Stmt::WhileStmtClass:
625 return cast<WhileStmt>(
Parent)->getBody() == S;
626 case Stmt::DoStmtClass:
627 return cast<DoStmt>(
Parent)->getBody() == S;
628 case Stmt::ForStmtClass:
629 return cast<ForStmt>(
Parent)->getBody() == S;
630 case Stmt::CXXForRangeStmtClass:
631 return cast<CXXForRangeStmt>(
Parent)->getBody() == S;
632 case Stmt::ObjCForCollectionStmtClass:
633 return cast<ObjCForCollectionStmt>(
Parent)->getBody() == S;
634 case Stmt::CaseStmtClass:
635 case Stmt::DefaultStmtClass:
636 return cast<SwitchCase>(
Parent)->getSubStmt() == S;
646 bool VisitStmt(
Stmt *S) {
return S !=
Target; }
650 StmtUSEFinder Visitor;
652 return !Visitor.TraverseDecl(
const_cast<Decl *
>(D));
668 static const Stmt *findLastStmtThatUsesDecl(
const Decl *D,
670 LastDeclUSEFinder Visitor;
672 for (
const Stmt *S : llvm::reverse(
Scope->body())) {
673 if (!Visitor.TraverseStmt(
const_cast<Stmt *
>(S)))
686class DiagnoseUnguardedAvailability
701 DiagnoseUnguardedAvailability(
Sema &SemaRef,
Decl *Ctx)
702 : SemaRef(SemaRef), Ctx(Ctx) {
703 AvailabilityStack.push_back(
707 bool TraverseStmt(
Stmt *S) {
710 StmtStack.push_back(S);
711 bool Result = Base::TraverseStmt(S);
712 StmtStack.pop_back();
716 void IssueDiagnostics(
Stmt *S) { TraverseStmt(S); }
733 DiagnoseDeclAvailability(
740 DiagnoseDeclAvailability(DRE->
getDecl(),
760void DiagnoseUnguardedAvailability::DiagnoseDeclAvailability(
764 std::tie(
Result, OffendingDecl) =
772 const AvailabilityAttr *AA =
774 VersionTuple Introduced = AA->getIntroduced();
776 if (AvailabilityStack.back() >= Introduced)
793 ? diag::warn_unguarded_availability_new
794 : diag::warn_unguarded_availability;
796 std::string PlatformName(AvailabilityAttr::getPrettyPlatformName(
800 <<
Range << D << PlatformName << Introduced.getAsString();
803 diag::note_partial_availability_specified_here)
804 << OffendingDecl << PlatformName << Introduced.getAsString()
810 SemaRef.
Diag(
Range.getBegin(), diag::note_unguarded_available_silence)
816 if (StmtStack.empty())
818 const Stmt *StmtOfUse = StmtStack.back();
820 for (
const Stmt *S : llvm::reverse(StmtStack)) {
821 if (
const auto *CS = dyn_cast<CompoundStmt>(S)) {
825 if (isBodyLikeChildStmt(StmtOfUse, S)) {
833 const Stmt *LastStmtOfUse =
nullptr;
834 if (isa<DeclStmt>(StmtOfUse) &&
Scope) {
835 for (
const Decl *D : cast<DeclStmt>(StmtOfUse)->decls()) {
836 if (StmtUSEFinder::isContained(StmtStack.back(), D)) {
837 LastStmtOfUse = LastDeclUSEFinder::findLastStmtThatUsesDecl(D,
Scope);
847 SM.getExpansionRange(
848 (LastStmtOfUse ? LastStmtOfUse : StmtOfUse)->getEndLoc())
850 if (
SM.getFileID(IfInsertionLoc) !=
SM.getFileID(StmtEndLoc))
854 const char *ExtraIndentation =
" ";
855 std::string FixItString;
856 llvm::raw_string_ostream FixItOS(FixItString);
857 FixItOS <<
"if (" << (SemaRef.
getLangOpts().ObjC ?
"@available"
858 :
"__builtin_available")
860 << AvailabilityAttr::getPlatformNameSourceSpelling(
862 <<
" " << Introduced.getAsString() <<
", *)) {\n"
863 << Indentation << ExtraIndentation;
871 FixItOS.str().clear();
873 << Indentation <<
"} else {\n"
874 << Indentation << ExtraIndentation
875 <<
"// Fallback on earlier versions\n"
876 << Indentation <<
"}";
881bool DiagnoseUnguardedAvailability::VisitTypeLoc(
TypeLoc Ty) {
885 if (
Range.isInvalid())
888 if (
const auto *TT = dyn_cast<TagType>(TyPtr)) {
890 DiagnoseDeclAvailability(TD, Range);
892 }
else if (
const auto *TD = dyn_cast<TypedefType>(TyPtr)) {
894 DiagnoseDeclAvailability(D, Range);
896 }
else if (
const auto *ObjCO = dyn_cast<ObjCObjectType>(TyPtr)) {
897 if (
NamedDecl *D = ObjCO->getInterface())
898 DiagnoseDeclAvailability(D, Range);
904bool DiagnoseUnguardedAvailability::TraverseIfStmt(
IfStmt *
If) {
905 VersionTuple CondVersion;
906 if (
auto *E = dyn_cast<ObjCAvailabilityCheckExpr>(
If->getCond())) {
911 if (CondVersion.empty() || CondVersion <= AvailabilityStack.back())
912 return TraverseStmt(
If->getThen()) && TraverseStmt(
If->getElse());
915 return Base::TraverseIfStmt(
If);
918 AvailabilityStack.push_back(CondVersion);
919 bool ShouldContinue = TraverseStmt(
If->getThen());
920 AvailabilityStack.pop_back();
922 return ShouldContinue && TraverseStmt(
If->getElse());
928 Stmt *Body =
nullptr;
933 if (FD->isTemplateInstantiation())
936 Body = FD->getBody();
938 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD))
940 DiagnoseUnguardedAvailability(*
this, D).IssueDiagnostics(CI->getInit());
942 }
else if (
auto *MD = dyn_cast<ObjCMethodDecl>(D))
943 Body = MD->getBody();
944 else if (
auto *BD = dyn_cast<BlockDecl>(D))
945 Body = BD->getBody();
947 assert(Body &&
"Need a body here!");
949 DiagnoseUnguardedAvailability(*
this, D).IssueDiagnostics(Body);
966 bool ObjCPropertyAccess,
967 bool AvoidPartialAvailabilityChecks,
973 std::tie(
Result, OffendingDecl) =
979 if (AvoidPartialAvailabilityChecks)
986 Context->HasPotentialAvailabilityViolations =
true;
992 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
995 if (PDeclResult ==
Result)
1001 UnknownObjCClass, ObjCPDecl, ObjCPropertyAccess);
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
llvm::MachO::Target Target
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.
Concrete class used by the front-end to report problems and issues.
void setSuppressSystemWarnings(bool Val)
When set to true mask warnings that come from system headers.
bool getSuppressSystemWarnings() const
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
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
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.
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
DiagnosticsEngine & getDiagnostics() const
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.
SourceLocation getTopMostPointOfInstantiation(const NamedDecl *) const
Returns the top most location responsible for the definition of N.
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.
The JSON file list parser is used to communicate input to InstallAPI.
@ If
'if' clause, allowed on all the Compute Constructs, Data Constructs, Executable Constructs,...
LLVM_READONLY bool isValidAsciiIdentifier(StringRef S, bool AllowDollar=false)
Return true if this is a valid ASCII identifier.
@ Result
The result type of a method or function.
AvailabilityResult
Captures the result of checking the availability of a declaration.
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.