summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorErik Pilkington <erik.pilkington@gmail.com>2016-07-28 22:09:53 +0000
committerErik Pilkington <erik.pilkington@gmail.com>2016-07-28 22:09:53 +0000
commit4f2dd2d4f282ee83be1f9ef45dd208d2b04069b0 (patch)
tree54ed4d3649e5679a8502409145347d90d1ea79c1 /clang/lib/Sema/SemaExpr.cpp
parente45d4d9b35e26faf1566797499b7385342903465 (diff)
downloadbcm5719-llvm-4f2dd2d4f282ee83be1f9ef45dd208d2b04069b0.tar.gz
bcm5719-llvm-4f2dd2d4f282ee83be1f9ef45dd208d2b04069b0.zip
[ObjC] Consider availability of context when emitting availability warnings
This means that a function marked with an availability attribute can safely refer to a declaration that is greater than the deployment target, but less then or equal to the context availability without -Wpartial-availability firing. Differential revision: https://reviews.llvm.org/D22697 llvm-svn: 277058
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 19a3d035d37..6539790224d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -107,9 +107,14 @@ static AvailabilityResult
DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc,
const ObjCInterfaceDecl *UnknownObjCClass,
bool ObjCPropertyAccess) {
- // See if this declaration is unavailable or deprecated.
+ VersionTuple ContextVersion;
+ if (const DeclContext *DC = S.getCurObjCLexicalContext())
+ ContextVersion = S.getVersionForDecl(cast<Decl>(DC));
+
+ // See if this declaration is unavailable, deprecated, or partial in the
+ // current context.
std::string Message;
- AvailabilityResult Result = D->getAvailability(&Message);
+ AvailabilityResult Result = D->getAvailability(&Message, ContextVersion);
// For typedefs, if the typedef declaration appears available look
// to the underlying type to see if it is more restrictive.
@@ -117,7 +122,7 @@ DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc,
if (Result == AR_Available) {
if (const TagType *TT = TD->getUnderlyingType()->getAs<TagType>()) {
D = TT->getDecl();
- Result = D->getAvailability(&Message);
+ Result = D->getAvailability(&Message, ContextVersion);
continue;
}
}
@@ -128,7 +133,7 @@ DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc,
if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(D)) {
if (IDecl->getDefinition()) {
D = IDecl->getDefinition();
- Result = D->getAvailability(&Message);
+ Result = D->getAvailability(&Message, ContextVersion);
}
}
@@ -136,7 +141,7 @@ DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc,
if (Result == AR_Available) {
const DeclContext *DC = ECD->getDeclContext();
if (const EnumDecl *TheEnumDecl = dyn_cast<EnumDecl>(DC))
- Result = TheEnumDecl->getAvailability(&Message);
+ Result = TheEnumDecl->getAvailability(&Message, ContextVersion);
}
const ObjCPropertyDecl *ObjCPDecl = nullptr;
@@ -144,7 +149,8 @@ DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc,
Result == AR_NotYetIntroduced) {
if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {
if (const ObjCPropertyDecl *PD = MD->findPropertyDecl()) {
- AvailabilityResult PDeclResult = PD->getAvailability(nullptr);
+ AvailabilityResult PDeclResult =
+ PD->getAvailability(nullptr, ContextVersion);
if (PDeclResult == Result)
ObjCPDecl = PD;
}
@@ -198,7 +204,7 @@ DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc,
break;
}
- return Result;
+ return Result;
}
/// \brief Emit a note explaining that this function is deleted.
OpenPOWER on IntegriCloud