diff options
author | Steven Wu <stevenwu@apple.com> | 2018-04-16 23:34:18 +0000 |
---|---|---|
committer | Steven Wu <stevenwu@apple.com> | 2018-04-16 23:34:18 +0000 |
commit | 3bb4aa566e1f6f468651b877937d789d1cab444e (patch) | |
tree | c7c22b1625ddb1381e11e3775ac005872de91041 /clang/lib/Sema/SemaDeclObjC.cpp | |
parent | 4a6a2b1ce313f0901c8c1e03a8c62fa0f7f526d8 (diff) | |
download | bcm5719-llvm-3bb4aa566e1f6f468651b877937d789d1cab444e.tar.gz bcm5719-llvm-3bb4aa566e1f6f468651b877937d789d1cab444e.zip |
[Availability] Improve availability to consider functions run at load time
Summary:
There are some functions/methods that run when the application launches
or the library loads. Those functions will run reguardless the OS
version as long as it satifies the minimum deployment target. Annotate
them with availability attributes doesn't really make sense because they
are essentially available on all targets since minimum deployment
target.
rdar://problem/36093384
Reviewers: arphaman, erik.pilkington
Reviewed By: erik.pilkington
Subscribers: erik.pilkington, cfe-commits
Differential Revision: https://reviews.llvm.org/D45699
llvm-svn: 330166
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 75c5ff56be6..5b8a9f39176 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -4734,6 +4734,17 @@ Decl *Sema::ActOnMethodDeclaration( Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86) checkObjCMethodX86VectorTypes(*this, ObjCMethod); + // + load method cannot have availability attributes. It get called on + // startup, so it has to have the availability of the deployment target. + if (const auto *attr = ObjCMethod->getAttr<AvailabilityAttr>()) { + if (ObjCMethod->isClassMethod() && + ObjCMethod->getSelector().getAsString() == "load") { + Diag(attr->getLocation(), diag::warn_availability_on_static_initializer) + << 0; + ObjCMethod->dropAttr<AvailabilityAttr>(); + } + } + ActOnDocumentableDecl(ObjCMethod); return ObjCMethod; |