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/SemaDeclAttr.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/SemaDeclAttr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 9351c52afbc..bfb82ac1388 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -1916,6 +1916,7 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, + bool IsNopartial, AvailabilityMergeKind AMK, unsigned AttrSpellingListIndex) { VersionTuple MergedIntroduced = Introduced; @@ -2062,7 +2063,7 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range, return ::new (Context) AvailabilityAttr(Range, Context, Platform, Introduced, Deprecated, Obsoleted, IsUnavailable, Message, - AttrSpellingListIndex); + IsNopartial, AttrSpellingListIndex); } return nullptr; } @@ -2089,6 +2090,7 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, AvailabilityChange Deprecated = Attr.getAvailabilityDeprecated(); AvailabilityChange Obsoleted = Attr.getAvailabilityObsoleted(); bool IsUnavailable = Attr.getUnavailableLoc().isValid(); + bool IsNopartial = Attr.getNopartialLoc().isValid(); StringRef Str; if (const StringLiteral *SE = dyn_cast_or_null<StringLiteral>(Attr.getMessageExpr())) @@ -2099,6 +2101,7 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, Deprecated.Version, Obsoleted.Version, IsUnavailable, Str, + IsNopartial, Sema::AMK_None, Index); if (NewAttr) @@ -2143,6 +2146,7 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, NewDeprecated, NewObsoleted, IsUnavailable, Str, + IsNopartial, Sema::AMK_None, Index); if (NewAttr) @@ -2165,6 +2169,7 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, Deprecated.Version, Obsoleted.Version, IsUnavailable, Str, + IsNopartial, Sema::AMK_None, Index); if (NewAttr) @@ -5957,6 +5962,14 @@ static void DoEmitAvailabilityWarning(Sema &S, Sema::AvailabilityDiagnostic K, property_note_select = /* partial */ 2; available_here_select_kind = /* partial */ 3; break; + + case Sema::AD_NotYetIntroduced: + diag = diag::err_notyetintroduced; + diag_message = diag::err_notyetintroduced_message; + diag_fwdclass_message = diag::warn_notyetintroduced_fwdclass_message; + property_note_select = /* deprecated */ 3; + available_here_select_kind = /* notyetintroduced */ 4; + break; } if (!Message.empty()) { @@ -5983,10 +5996,22 @@ static void DoEmitAvailabilityWarning(Sema &S, Sema::AvailabilityDiagnostic K, static void handleDelayedAvailabilityCheck(Sema &S, DelayedDiagnostic &DD, Decl *Ctx) { assert(DD.Kind == DelayedDiagnostic::Deprecation || - DD.Kind == DelayedDiagnostic::Unavailable); - Sema::AvailabilityDiagnostic AD = DD.Kind == DelayedDiagnostic::Deprecation - ? Sema::AD_Deprecation - : Sema::AD_Unavailable; + DD.Kind == DelayedDiagnostic::Unavailable || + DD.Kind == DelayedDiagnostic::NotYetIntroduced); + Sema::AvailabilityDiagnostic AD; + switch (DD.Kind) { + case DelayedDiagnostic::Deprecation: + AD = Sema::AD_Deprecation; + break; + case DelayedDiagnostic::Unavailable: + AD = Sema::AD_Unavailable; + break; + case DelayedDiagnostic::NotYetIntroduced: + AD = Sema::AD_NotYetIntroduced; + break; + default: + llvm_unreachable("Expecting: deprecated, unavailable, not-yet-introduced"); + } DD.Triggered = true; DoEmitAvailabilityWarning( S, AD, Ctx, DD.getDeprecationDecl(), DD.getDeprecationMessage(), DD.Loc, |