;
35 constAvailabilityAttr *AA) {
38 if(!IIEnvironment || Environment == llvm::Triple::UnknownEnvironment)
41llvm::Triple::EnvironmentType ET =
42AvailabilityAttr::getEnvironmentType(IIEnvironment->
getName());
43 returnEnvironment == ET;
48AvailabilityAttr
const*PartialMatch =
nullptr;
54 if(
const auto*FTD = dyn_cast<FunctionTemplateDecl>(
D))
55 D= FTD->getTemplatedDecl();
56 for(
const auto*A :
D->
attrs()) {
57 if(
const auto*Avail = dyn_cast<AvailabilityAttr>(A)) {
63StringRef ActualPlatform = Avail->getPlatform()->getName();
64StringRef RealizedPlatform = ActualPlatform;
66 size_tsuffix = RealizedPlatform.rfind(
"_app_extension");
67 if(suffix != StringRef::npos)
68RealizedPlatform = RealizedPlatform.slice(0, suffix);
74 if(RealizedPlatform == TargetPlatform) {
93staticstd::pair<AvailabilityResult, const NamedDecl *>
101 while(
const auto*TD = dyn_cast<TypedefNameDecl>(
D)) {
103 if(
const auto*TT = TD->getUnderlyingType()->getAs<
TagType>()) {
113 if(
const auto*ADecl = dyn_cast<TypeAliasTemplateDecl>(
D)) {
114 D= ADecl->getTemplatedDecl();
119 if(
const auto*IDecl = dyn_cast<ObjCInterfaceDecl>(
D)) {
120 if(IDecl->getDefinition()) {
121 D= IDecl->getDefinition();
126 if(
const auto*ECD = dyn_cast<EnumConstantDecl>(
D))
129 if(
const auto*TheEnumDecl = dyn_cast<EnumDecl>(DC)) {
136 if(
const auto*MD = dyn_cast<ObjCMethodDecl>(
D)) {
141MD->getSelector() == S.
ObjC().
NSAPIObj->getNewSelector() &&
143Result =
Init->getAvailability(Message);
159assert(K !=
AR_Available&&
"Expected an unavailable declaration here!");
162 autoDeclLoc = Ctx->getBeginLoc();
164 if(DeclLoc.isMacroID() && S.
getLangOpts().CPlusPlus &&
165isa<TypedefDecl>(OffendingDecl)) {
167 if(MacroName ==
"CF_OPTIONS"|| MacroName ==
"OBJC_OPTIONS"||
168MacroName ==
"SWIFT_OPTIONS"|| MacroName ==
"NS_OPTIONS") {
181(DeclEnv !=
nullptr&&
183llvm::Triple::EnvironmentType::Library))
188 if(
const auto*VD = dyn_cast<VarDecl>(OffendingDecl))
189 if(VD->isLocalVarDeclOrParm() && VD->isDeprecated())
194 autoCheckContext = [&](
const Decl*
C) {
197 if(AA->getIntroduced() >= DeclVersion &&
198AA->getEnvironment() == DeclEnv)
201 if(
C->isDeprecated())
207 if(
const auto*MD = dyn_cast<ObjCMethodDecl>(OffendingDecl)) {
208 if(
const auto*Impl = dyn_cast<ObjCImplDecl>(
C)) {
209 if(MD->getClassInterface() == Impl->getClassInterface())
215 if(
C->isUnavailable())
221 if(CheckContext(Ctx))
226 if(
const auto*MethodD = dyn_cast<ObjCMethodDecl>(Ctx))
227 if(MethodD->isClassMethod() &&
228MethodD->getSelector().getAsString() ==
"load")
231 if(
const auto*CatOrImpl = dyn_cast<ObjCImplDecl>(Ctx)) {
237 else if(
const auto*CatD = dyn_cast<ObjCCategoryDecl>(Ctx))
241}
while((Ctx = cast_or_null<Decl>(Ctx->getDeclContext())));
247 const ASTContext&Context,
constVersionTuple &DeploymentVersion,
248 constVersionTuple &DeclVersion,
boolHasMatchingEnv) {
250VersionTuple ForceAvailabilityFromVersion;
251 switch(Triple.getOS()) {
256 casellvm::Triple::IOS:
257 casellvm::Triple::TvOS:
258ForceAvailabilityFromVersion = VersionTuple(
11);
260 casellvm::Triple::WatchOS:
261ForceAvailabilityFromVersion = VersionTuple(
4);
263 casellvm::Triple::Darwin:
264 casellvm::Triple::MacOSX:
265ForceAvailabilityFromVersion = VersionTuple(
10,
13);
271 casellvm::Triple::ShaderModel:
272 returnHasMatchingEnv ? diag::warn_hlsl_availability
273: diag::warn_hlsl_availability_unavailable;
276ForceAvailabilityFromVersion =
277(Triple.getVendor() == llvm::Triple::Apple)
278? VersionTuple(
0, 0)
279: VersionTuple(
(
unsigned)-1, (
unsigned)-1);
281 if(DeploymentVersion >= ForceAvailabilityFromVersion ||
282DeclVersion >= ForceAvailabilityFromVersion)
283 returnHasMatchingEnv ? diag::warn_unguarded_availability_new
284: diag::warn_unguarded_availability_unavailable_new;
285 returnHasMatchingEnv ? diag::warn_unguarded_availability
286: diag::warn_unguarded_availability_unavailable;
290 for(
Decl*Ctx = OrigCtx; Ctx;
291Ctx = cast_or_null<Decl>(Ctx->getDeclContext())) {
292 if(isa<TagDecl>(Ctx) || isa<FunctionDecl>(Ctx) || isa<ObjCMethodDecl>(Ctx))
293 returncast<NamedDecl>(Ctx);
294 if(
auto*CD = dyn_cast<ObjCContainerDecl>(Ctx)) {
295 if(
auto*Imp = dyn_cast<ObjCImplDecl>(Ctx))
296 returnImp->getClassInterface();
301 returndyn_cast<NamedDecl>(OrigCtx);
306structAttributeInsertion {
311 staticAttributeInsertion createInsertionAfter(
const NamedDecl*
D) {
314 staticAttributeInsertion createInsertionAfter(
SourceLocationLoc) {
315 return{
" ",
Loc,
""};
317 staticAttributeInsertion createInsertionBefore(
const NamedDecl*
D) {
332staticstd::optional<unsigned>
336 if(!Name.empty() && (Name.front() ==
'-'|| Name.front() ==
'+'))
337Name = Name.drop_front(1);
340Name.split(SlotNames,
':');
342 if(Name.back() ==
':') {
344SlotNames.pop_back();
345NumParams = SlotNames.size();
347 if(SlotNames.size() != 1)
353 boolAllowDollar = LangOpts.DollarIdents;
354 for(StringRef S : SlotNames) {
365staticstd::optional<AttributeInsertion>
368 if(isa<ObjCPropertyDecl>(
D))
369 returnAttributeInsertion::createInsertionAfter(
D);
370 if(
const auto*MD = dyn_cast<ObjCMethodDecl>(
D)) {
373 returnAttributeInsertion::createInsertionAfter(
D);
375 if(
const auto*TD = dyn_cast<TagDecl>(
D)) {
381 returnAttributeInsertion::createInsertionAfter(
Loc);
383 returnAttributeInsertion::createInsertionBefore(
D);
403 boolObjCPropertyAccess) {
405 unsigneddiag, diag_message, diag_fwdclass_message;
406 unsigneddiag_available_here = diag::note_availability_specified_here;
410 unsignedproperty_note_select;
413 unsignedavailable_here_select_kind;
415VersionTuple DeclVersion;
419DeclVersion = AA->getIntroduced();
420IIEnv = AA->getEnvironment();
431 if(AA && AA->isInherited()) {
434 constAvailabilityAttr *AForRedecl =
436 if(AForRedecl && !AForRedecl->isInherited()) {
439NoteLocation = Redecl->getLocation();
451assert(AA !=
nullptr&&
"expecting valid availability attribute");
452VersionTuple Introduced = AA->getIntroduced();
453 boolEnvironmentMatchesOrNone =
457std::string PlatformName(
459llvm::StringRef TargetEnvironment(
460llvm::Triple::getEnvironmentTypeName(TI.
getTriple().getEnvironment()));
461llvm::StringRef AttrEnvironment =
462AA->getEnvironment() ? AA->getEnvironment()->getName() :
"";
463 boolUseEnvironment =
464(!AttrEnvironment.empty() && !TargetEnvironment.empty());
468Introduced, EnvironmentMatchesOrNone);
470S.
Diag(
Loc, DiagKind) << OffendingDecl << PlatformName
471<< Introduced.getAsString() << UseEnvironment
472<< TargetEnvironment;
475diag::note_partial_availability_specified_here)
476<< OffendingDecl << PlatformName << Introduced.getAsString()
478<< UseEnvironment << AttrEnvironment << TargetEnvironment;
485 if(
const auto*TD = dyn_cast<TagDecl>(Enclosing))
486 if(TD->getDeclName().isEmpty()) {
487S.
Diag(TD->getLocation(),
488diag::note_decl_unguarded_availability_silence)
489<<
1 << TD->getKindName();
493S.
Diag(Enclosing->getLocation(),
494diag::note_decl_unguarded_availability_silence)
497 if(Enclosing->hasAttr<AvailabilityAttr>())
506StringRef PlatformName =
519std::vector<StringRef> EquivalentPlatforms =
520AvailabilityAttr::equivalentPlatformNames(PlatformName);
521llvm::Twine MacroPrefix =
"__API_AVAILABLE_PLATFORM_";
522 autoAvailablePlatform =
523llvm::find_if(EquivalentPlatforms, [&](StringRef EquivalentPlatform) {
524 returnPP.
isMacroDefined((MacroPrefix + EquivalentPlatform).str());
526 if(AvailablePlatform == EquivalentPlatforms.end())
528std::string Introduced =
532(llvm::Twine(Insertion->Prefix) +
"API_AVAILABLE("+
533*AvailablePlatform +
"("+ Introduced +
"))"+ Insertion->Suffix)
539diag = !ObjCPropertyAccess ? diag::warn_deprecated
540: diag::warn_property_method_deprecated;
541diag_message = diag::warn_deprecated_message;
542diag_fwdclass_message = diag::warn_deprecated_fwdclass_message;
543property_note_select =
0;
544available_here_select_kind =
2;
545 if(
const auto*AL = OffendingDecl->
getAttr<DeprecatedAttr>())
546NoteLocation = AL->getLocation();
550diag = !ObjCPropertyAccess ? diag::err_unavailable
551: diag::err_property_method_unavailable;
552diag_message = diag::err_unavailable_message;
553diag_fwdclass_message = diag::warn_unavailable_fwdclass_message;
554property_note_select =
1;
555available_here_select_kind =
0;
557 if(
autoAL = OffendingDecl->
getAttr<UnavailableAttr>()) {
558 if(AL->isImplicit() && AL->getImplicitReason()) {
561 autoflagARCError = [&] {
565diag = diag::err_unavailable_in_arc;
568 switch(AL->getImplicitReason()) {
569 caseUnavailableAttr::IR_None:
break;
571 caseUnavailableAttr::IR_ARCForbiddenType:
573diag_available_here = diag::note_arc_forbidden_type;
576 caseUnavailableAttr::IR_ForbiddenWeak:
578diag_available_here = diag::note_arc_weak_disabled;
580diag_available_here = diag::note_arc_weak_no_runtime;
583 caseUnavailableAttr::IR_ARCForbiddenConversion:
585diag_available_here = diag::note_performs_forbidden_arc_conversion;
588 caseUnavailableAttr::IR_ARCInitReturnsUnrelated:
590diag_available_here = diag::note_arc_init_returns_unrelated;
593 caseUnavailableAttr::IR_ARCFieldWithOwnership:
595diag_available_here = diag::note_arc_field_with_ownership;
603llvm_unreachable(
"Warning for availability of available declaration?");
608StringRef Replacement;
609 if(
autoAL = OffendingDecl->
getAttr<DeprecatedAttr>())
610Replacement = AL->getReplacement();
612Replacement = AL->getReplacement();
615 if(!Replacement.empty())
619 if(
const auto*MethodDecl = dyn_cast<ObjCMethodDecl>(ReferringDecl)) {
620 SelectorSel = MethodDecl->getSelector();
623Replacement, SelectorSlotNames, S.
getLangOpts());
624 if(NumParams && *NumParams == Sel.
getNumArgs()) {
625assert(SelectorSlotNames.size() == Locs.size());
626 for(
unsignedI = 0; I < Locs.size(); ++I) {
631NameRange, SelectorSlotNames[I]));
649 boolShouldAllowWarningInSystemHeader =
650InstantiationLoc !=
Loc&&
652 structAllowWarningInSystemHeaders {
654 boolAllowWarningInSystemHeaders)
655: Engine(
E), Prev(
E.getSuppressSystemWarnings()) {
656 E.setSuppressSystemWarnings(!AllowWarningInSystemHeaders);
658~AllowWarningInSystemHeaders() { Engine.setSuppressSystemWarnings(Prev); }
664ShouldAllowWarningInSystemHeader);
666 if(!Message.empty()) {
667S.
Diag(
Loc, diag_message) << ReferringDecl << Message << FixIts;
670<< ObjCProperty->
getDeclName() << property_note_select;
671}
else if(!UnknownObjCClass) {
672S.
Diag(
Loc, diag) << ReferringDecl << FixIts;
675<< ObjCProperty->
getDeclName() << property_note_select;
677S.
Diag(
Loc, diag_fwdclass_message) << ReferringDecl << FixIts;
681S.
Diag(NoteLocation, diag_available_here)
682<< OffendingDecl << available_here_select_kind;
687 "Expected an availability diagnostic here");
704 boolObjCPropertyAccess) {
709AR, Locs, ReferringDecl, OffendingDecl, UnknownObjCClass,
710ObjCProperty, Message, ObjCPropertyAccess));
716Message, Locs, UnknownObjCClass, ObjCProperty,
724 switch(
Parent->getStmtClass()) {
725 caseStmt::IfStmtClass:
726 returncast<IfStmt>(
Parent)->getThen() == S ||
727cast<IfStmt>(
Parent)->getElse() == S;
728 caseStmt::WhileStmtClass:
729 returncast<WhileStmt>(
Parent)->getBody() == S;
730 caseStmt::DoStmtClass:
731 returncast<DoStmt>(
Parent)->getBody() == S;
732 caseStmt::ForStmtClass:
733 returncast<ForStmt>(
Parent)->getBody() == S;
734 caseStmt::CXXForRangeStmtClass:
735 returncast<CXXForRangeStmt>(
Parent)->getBody() == S;
736 caseStmt::ObjCForCollectionStmtClass:
737 returncast<ObjCForCollectionStmt>(
Parent)->getBody() == S;
738 caseStmt::CaseStmtClass:
739 caseStmt::DefaultStmtClass:
740 returncast<SwitchCase>(
Parent)->getSubStmt() == S;
750 boolVisitStmt(
Stmt*S)
override{
returnS !=
Target; }
754StmtUSEFinder Visitor;
756 return!Visitor.TraverseDecl(
const_cast<Decl*
>(
D));
766 boolVisitDeclRefExpr(
DeclRefExpr*DRE)
override{
772 static const Stmt*findLastStmtThatUsesDecl(
const Decl*
D,
774LastDeclUSEFinder Visitor;
776 for(
const Stmt*S : llvm::reverse(
Scope->body())) {
777 if(!Visitor.TraverseStmt(
const_cast<Stmt*
>(S)))
802DiagnoseUnguardedAvailability(
Sema&SemaRef,
Decl*Ctx)
803: SemaRef(SemaRef), Ctx(Ctx) {
804AvailabilityStack.push_back(
808 boolTraverseStmt(
Stmt*S)
override{
811StmtStack.push_back(S);
813StmtStack.pop_back();
817 voidIssueDiagnostics(
Stmt*S) { TraverseStmt(S); }
819 boolTraverseIfStmt(
IfStmt*
If)
override;
823 boolTraverseCaseStmt(
CaseStmt*CS)
override{
834DiagnoseDeclAvailability(
840 boolVisitDeclRefExpr(
DeclRefExpr*DRE)
override{
841DiagnoseDeclAvailability(DRE->
getDecl(),
846 boolVisitMemberExpr(
MemberExpr*ME)
override{
858 boolVisitTypeLoc(
TypeLocTy)
override;
861voidDiagnoseUnguardedAvailability::DiagnoseDeclAvailability(
865std::tie(
Result, OffendingDecl) =
873 constAvailabilityAttr *AA =
875assert(AA !=
nullptr&&
"expecting valid availability attribute");
876 boolEnvironmentMatchesOrNone =
878VersionTuple Introduced = AA->getIntroduced();
880 if(EnvironmentMatchesOrNone && AvailabilityStack.back() >= Introduced)
886AA->getEnvironment(), Ctx,
891std::string PlatformName(
893llvm::StringRef TargetEnvironment(TI.
getTriple().getEnvironmentName());
894llvm::StringRef AttrEnvironment =
895AA->getEnvironment() ? AA->getEnvironment()->getName() :
"";
896 boolUseEnvironment =
897(!AttrEnvironment.empty() && !TargetEnvironment.empty());
902EnvironmentMatchesOrNone);
905<<
Range<<
D<< PlatformName << Introduced.getAsString()
906<< UseEnvironment << TargetEnvironment;
909diag::note_partial_availability_specified_here)
910<< OffendingDecl << PlatformName << Introduced.getAsString()
912<< UseEnvironment << AttrEnvironment << TargetEnvironment;
925 if(StmtStack.empty())
927 const Stmt*StmtOfUse = StmtStack.back();
929 for(
const Stmt*S : llvm::reverse(StmtStack)) {
930 if(
const auto*CS = dyn_cast<CompoundStmt>(S)) {
934 if(isBodyLikeChildStmt(StmtOfUse, S)) {
942 const Stmt*LastStmtOfUse =
nullptr;
943 if(isa<DeclStmt>(StmtOfUse) &&
Scope) {
944 for(
const Decl*
D: cast<DeclStmt>(StmtOfUse)->decls()) {
945 if(StmtUSEFinder::isContained(StmtStack.back(),
D)) {
946LastStmtOfUse = LastDeclUSEFinder::findLastStmtThatUsesDecl(
D,
Scope);
956 SM.getExpansionRange(
957(LastStmtOfUse ? LastStmtOfUse : StmtOfUse)->getEndLoc())
959 if(
SM.getFileID(IfInsertionLoc) !=
SM.getFileID(StmtEndLoc))
963 const char*ExtraIndentation =
" ";
964std::string FixItString;
965llvm::raw_string_ostream FixItOS(FixItString);
966FixItOS <<
"if ("<< (SemaRef.
getLangOpts().ObjC ?
"@available" 967:
"__builtin_available")
969<< AvailabilityAttr::getPlatformNameSourceSpelling(
971<<
" "<< Introduced.getAsString() <<
", *)) {\n" 972<< Indentation << ExtraIndentation;
980FixItOS.str().clear();
982<< Indentation <<
"} else {\n" 983<< Indentation << ExtraIndentation
984<<
"// Fallback on earlier versions\n" 985<< Indentation <<
"}";
990boolDiagnoseUnguardedAvailability::VisitTypeLoc(
TypeLocTy) {
997 if(
const auto*TT = dyn_cast<TagType>(TyPtr)) {
999DiagnoseDeclAvailability(TD,
Range);
1001}
else if(
const auto*TD = dyn_cast<TypedefType>(TyPtr)) {
1003DiagnoseDeclAvailability(
D,
Range);
1005}
else if(
const auto*ObjCO = dyn_cast<ObjCObjectType>(TyPtr)) {
1007DiagnoseDeclAvailability(
D,
Range);
1013structExtractedAvailabilityExpr {
1015 boolisNegated =
false;
1018ExtractedAvailabilityExpr extractAvailabilityExpr(
const Expr*IfCond) {
1019 const auto*
E= IfCond;
1020 boolIsNegated =
false;
1023 if(
const auto*AE = dyn_cast<ObjCAvailabilityCheckExpr>(
E)) {
1024 returnExtractedAvailabilityExpr{AE, IsNegated};
1027 const auto*UO = dyn_cast<UnaryOperator>(
E);
1028 if(!UO || UO->getOpcode() != UO_LNot) {
1029 returnExtractedAvailabilityExpr{};
1031 E= UO->getSubExpr();
1032IsNegated = !IsNegated;
1036boolDiagnoseUnguardedAvailability::TraverseIfStmt(
IfStmt*
If) {
1037ExtractedAvailabilityExpr IfCond = extractAvailabilityExpr(
If->getCond());
1040 returnDynamicRecursiveASTVisitor::TraverseIfStmt(
If);
1043VersionTuple CondVersion = IfCond.E->getVersion();
1046 if(CondVersion.empty() || CondVersion <= AvailabilityStack.back()) {
1047 returnTraverseStmt(
If->getThen()) && TraverseStmt(
If->getElse());
1050 auto*Guarded =
If->getThen();
1051 auto*Unguarded =
If->getElse();
1052 if(IfCond.isNegated) {
1053std::swap(Guarded, Unguarded);
1056AvailabilityStack.push_back(CondVersion);
1057 boolShouldContinue = TraverseStmt(Guarded);
1058AvailabilityStack.pop_back();
1060 returnShouldContinue && TraverseStmt(Unguarded);
1066 Stmt*Body =
nullptr;
1069Body = FD->getBody();
1071 if(
auto*CD = dyn_cast<CXXConstructorDecl>(FD))
1073DiagnoseUnguardedAvailability(*
this,
D).IssueDiagnostics(CI->getInit());
1075}
else if(
auto*MD = dyn_cast<ObjCMethodDecl>(
D))
1076Body = MD->getBody();
1077 else if(
auto*BD = dyn_cast<BlockDecl>(
D))
1078Body = BD->getBody();
1080assert(Body &&
"Need a body here!");
1082DiagnoseUnguardedAvailability(*
this,
D).IssueDiagnostics(Body);
1099 boolObjCPropertyAccess,
1100 boolAvoidPartialAvailabilityChecks,
1102std::string Message;
1106std::tie(
Result, OffendingDecl) =
1112 if(AvoidPartialAvailabilityChecks)
1119 Context->HasPotentialAvailabilityViolations =
true;
1125 if(
const auto*MD = dyn_cast<ObjCMethodDecl>(
D)) {
1128 if(PDeclResult ==
Result)
1134UnknownObjCClass, ObjCPDecl, ObjCPropertyAccess);
Defines the C++ template declaration subclasses.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Defines the clang::LangOptions interface.
llvm::MachO::Target Target
Defines the clang::Preprocessor interface.
static unsigned getAvailabilityDiagnosticKind(const ASTContext &Context, const VersionTuple &DeploymentVersion, const VersionTuple &DeclVersion, bool HasMatchingEnv)
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 hasMatchingEnvironmentOrNone(const ASTContext &Context, const AvailabilityAttr *AA)
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 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)
static bool ShouldDiagnoseAvailabilityInContext(Sema &S, AvailabilityResult K, VersionTuple DeclVersion, const IdentifierInfo *DeclEnv, Decl *Ctx, const NamedDecl *OffendingDecl)
whether we should emit a diagnostic for K and DeclVersion in the context of Ctx.
This file declares semantic analysis for Objective-C.
Defines the Objective-C statement AST node classes.
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
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.
Recursive AST visitor that supports extension via dynamic dispatch.
virtual bool TraverseStmt(MaybeConst< Stmt > *S)
Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dy...
This represents one expression.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
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.
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
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.
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.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
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.
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.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
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.
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.
SourceLocation getBegin() const
Stmt - This represents one statement.
SourceLocation getBeginLoc() const LLVM_READONLY
Represents the declaration of a struct/union/class/enum.
Exposes information about the current target.
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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4