diff options
author | Manman Ren <manman.ren@gmail.com> | 2016-02-17 22:05:48 +0000 |
---|---|---|
committer | Manman Ren <manman.ren@gmail.com> | 2016-02-17 22:05:48 +0000 |
commit | b636b904c229f02d574a27b3f6f2a41c39a1d541 (patch) | |
tree | 146892ac295d3d9d8b8809e2c23253d3452e25d7 /clang/lib/Sema/SemaExpr.cpp | |
parent | 4083e038e918ccc1a5800f424c3e814bdd425e79 (diff) | |
download | bcm5719-llvm-b636b904c229f02d574a27b3f6f2a41c39a1d541.tar.gz bcm5719-llvm-b636b904c229f02d574a27b3f6f2a41c39a1d541.zip |
Add 'nopartial' qualifier for availability attributes.
An optional nopartial can be placed after the platform name.
int bar() __attribute__((availability(macosx,nopartial,introduced=10.12))
When deploying back to a platform version prior to when the declaration was
introduced, with 'nopartial', Clang emits an error specifying that the function
is not introduced yet; without 'nopartial', the behavior stays the same: the
declaration is `weakly linked`.
A member is added to the end of AttributeList to save the location of the
'nopartial' keyword. A bool member is added to AvailabilityAttr.
The diagnostics for 'nopartial' not-yet-introduced is handled in the same way as
we handle unavailable cases.
Reviewed by Doug Gregor and Jordan Rose.
rdar://23791325
llvm-svn: 261163
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 5976c2c9f34..cbac36b7bff 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -137,7 +137,7 @@ DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc, const ObjCPropertyDecl *ObjCPDecl = nullptr; if (Result == AR_Deprecated || Result == AR_Unavailable || - AR_NotYetIntroduced) { + Result == AR_NotYetIntroduced) { if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) { if (const ObjCPropertyDecl *PD = MD->findPropertyDecl()) { AvailabilityResult PDeclResult = PD->getAvailability(nullptr); @@ -159,11 +159,20 @@ DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc, break; case AR_NotYetIntroduced: { + // With nopartial, the compiler will emit delayed error just like how + // "deprecated, unavailable" are handled. + AvailabilityAttr *AA = D->getAttr<AvailabilityAttr>(); + if (AA && AA->getNopartial() && + S.getCurContextAvailability() != AR_NotYetIntroduced) + S.EmitAvailabilityWarning(Sema::AD_NotYetIntroduced, + D, Message, Loc, UnknownObjCClass, ObjCPDecl, + ObjCPropertyAccess); + // Don't do this for enums, they can't be redeclared. if (isa<EnumConstantDecl>(D) || isa<EnumDecl>(D)) break; - bool Warn = !D->getAttr<AvailabilityAttr>()->isInherited(); + bool Warn = !AA->isInherited(); // Objective-C method declarations in categories are not modelled as // redeclarations, so manually look for a redeclaration in a category // if necessary. |