erik.pilkington created this revision. erik.pilkington added a reviewer: arphaman. Herald added subscribers: dexonsmith, jkorous.
Mention the deployment target, and don't say "partial" which doesn't really mean anything to users. rdar://problem/33601513 Repository: rC Clang https://reviews.llvm.org/D56523 Files: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaExpr.cpp clang/test/Sema/attr-availability.c clang/test/Sema/availability-guard-format.mm clang/test/SemaObjC/attr-availability.m clang/test/SemaObjC/property-deprecated-warning.m clang/test/SemaObjC/unguarded-availability-new.m clang/test/SemaObjC/unguarded-availability.m
Index: clang/test/SemaObjC/unguarded-availability.m =================================================================== --- clang/test/SemaObjC/unguarded-availability.m +++ clang/test/SemaObjC/unguarded-availability.m @@ -5,14 +5,14 @@ #define AVAILABLE_10_11 __attribute__((availability(macos, introduced = 10.11))) #define AVAILABLE_10_12 __attribute__((availability(macos, introduced = 10.12))) -typedef int AVAILABLE_10_12 new_int; // expected-note + {{marked partial here}} +typedef int AVAILABLE_10_12 new_int; // expected-note + {{'new_int' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}} -int func_10_11() AVAILABLE_10_11; // expected-note 8 {{'func_10_11' has been explicitly marked partial here}} +int func_10_11() AVAILABLE_10_11; // expected-note 8 {{'func_10_11' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.4.0}} #ifdef OBJCPP -// expected-note@+2 6 {{marked partial here}} +// expected-note@+2 6 {{'func_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}} #endif -int func_10_12() AVAILABLE_10_12; // expected-note 7 {{'func_10_12' has been explicitly marked partial here}} +int func_10_12() AVAILABLE_10_12; // expected-note 7 {{'func_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}} int func_10_0() AVAILABLE_10_0; @@ -61,11 +61,11 @@ } } -typedef int int_10_11 AVAILABLE_10_11; // expected-note {{'int_10_11' has been explicitly marked partial here}} +typedef int int_10_11 AVAILABLE_10_11; // expected-note {{'int_10_11' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.4.0}} #ifdef OBJCPP -// expected-note@+2 {{marked partial here}} +// expected-note@+2 {{'int_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}} #endif -typedef int int_10_12 AVAILABLE_10_12; // expected-note 2 {{'int_10_12' has been explicitly marked partial here}} +typedef int int_10_12 AVAILABLE_10_12; // expected-note 2 {{'int_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}} void use_typedef() { int_10_11 x; // expected-warning{{'int_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'int_10_11' in an @available check to silence this warning}} @@ -106,10 +106,10 @@ struct S { int m1; - int m2 __attribute__((availability(macos, introduced = 10.12))); // expected-note{{marked partial here}} + int m2 __attribute__((availability(macos, introduced = 10.12))); // expected-note{{has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}} struct Nested { - int nested_member __attribute__((availability(macos, introduced = 10.12))); // expected-note{{marked partial here}} + int nested_member __attribute__((availability(macos, introduced = 10.12))); // expected-note{{'nested_member' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}} } n; }; @@ -139,9 +139,9 @@ AVAILABLE_10_12 __attribute__((objc_root_class)) -@interface InterWithProp // expected-note 2 {{marked partial here}} +@interface InterWithProp // expected-note 2 {{'InterWithProp' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}} @property(class) int x; -+ (void) setX: (int)newX AVAILABLE_10_12; // expected-note{{marked partial here}} ++ (void) setX: (int)newX AVAILABLE_10_12; // expected-note{{'setX:' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}} @end void test_property(void) { int y = InterWithProp.x; // expected-warning{{'InterWithProp' is only available on macOS 10.12 or newer}} expected-note{{@available}} @@ -150,7 +150,7 @@ __attribute__((objc_root_class)) @interface Subscriptable -- (id)objectAtIndexedSubscript:(int)sub AVAILABLE_10_12; // expected-note{{marked partial here}} +- (id)objectAtIndexedSubscript:(int)sub AVAILABLE_10_12; // expected-note{{'objectAtIndexedSubscript:' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}} @end void test_at(Subscriptable *x) { @@ -196,7 +196,7 @@ } template <class> -int with_availability_attr() AVAILABLE_10_11 { // expected-note 2 {{marked partial here}} +int with_availability_attr() AVAILABLE_10_11 { // expected-note 2 {{'with_availability_attr<int>' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.4.0}} return 0; } @@ -244,7 +244,7 @@ }; #ifdef OBJCPP -static constexpr int AVAILABLE_10_12 SomeConstexprValue = 2; // expected-note{{marked partial here}} +static constexpr int AVAILABLE_10_12 SomeConstexprValue = 2; // expected-note{{'SomeConstexprValue' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}} typedef enum { // expected-note{{annotate anonymous enum with an availability attribute}} SomeValue = SomeConstexprValue // expected-warning{{'SomeConstexprValue' is only available on macOS 10.12 or newer}} } SomeEnum; @@ -268,7 +268,7 @@ // Avoid the warning on protocol requirements. AVAILABLE_10_12 -@protocol NewProtocol // expected-note {{'NewProtocol' has been explicitly marked partial here}} +@protocol NewProtocol // expected-note {{'NewProtocol' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}} @end @protocol ProtocolWithNewProtocolRequirement <NewProtocol> // expected-note {{annotate 'ProtocolWithNewProtocolRequirement' with an availability attribute to silence}} @@ -291,7 +291,7 @@ typedef enum { AK_Dodo __attribute__((availability(macos, deprecated=10.3))), // expected-note 3 {{marked deprecated here}} AK_Cat __attribute__((availability(macos, introduced=10.4))), - AK_CyborgCat __attribute__((availability(macos, introduced=10.12))), // expected-note {{marked partial here}} + AK_CyborgCat __attribute__((availability(macos, introduced=10.12))), // expected-note {{'AK_CyborgCat' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}} } Animals; void switchAnimals(Animals a) { Index: clang/test/SemaObjC/unguarded-availability-new.m =================================================================== --- clang/test/SemaObjC/unguarded-availability-new.m +++ clang/test/SemaObjC/unguarded-availability-new.m @@ -68,15 +68,15 @@ void previouslyAvailable() AVAILABLE_PREV; #ifdef WARN_PREV - // expected-note@-2 {{'previouslyAvailable' has been explicitly marked partial here}} +// expected-note@-2 {{'previouslyAvailable' has been marked as being introduced}} #endif void currentlyAvailable() AVAILABLE_CURRENT; #ifdef WARN_CURRENT - // expected-note@-2 {{'currentlyAvailable' has been explicitly marked partial here}} +// expected-note@-2 {{'currentlyAvailable' has been marked as being introduced}} #endif void willBeAvailabile() AVAILABLE_NEXT; #ifndef NO_WARNING - // expected-note@-2 {{'willBeAvailabile' has been explicitly marked partial here}} +// expected-note@-2 {{'willBeAvailabile' has been marked as being introduced in}} #endif #ifdef TEST_FUNC_CURRENT @@ -91,7 +91,7 @@ typedef int AVAILABLE_NEXT new_int; #ifndef NO_WARNING - // expected-note@-2 {{'new_int' has been explicitly marked partial here}} +// expected-note@-2 {{'new_int' has been marked as being introduced in}} #endif FUNC_AVAILABLE new_int x; #ifndef NO_WARNING Index: clang/test/SemaObjC/property-deprecated-warning.m =================================================================== --- clang/test/SemaObjC/property-deprecated-warning.m +++ clang/test/SemaObjC/property-deprecated-warning.m @@ -9,7 +9,7 @@ @property(nonatomic,assign) id ptarget __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{property 'ptarget' is declared deprecated here}} expected-note {{'ptarget' has been explicitly marked deprecated here}} #if defined(WARN_PARTIAL) -// expected-note@+2 {{'partialPtarget' has been explicitly marked partial here}} +// expected-note@+2 {{'partialPtarget' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0.0}} #endif @property(nonatomic,assign) id partialPtarget __attribute__((availability(ios,introduced=5.0))); @end @@ -24,7 +24,7 @@ @property(nonatomic,assign) id target __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{property 'target' is declared deprecated here}} expected-note {{'setTarget:' has been explicitly marked deprecated here}} #if defined(WARN_PARTIAL) -// expected-note@+2 {{'setPartialTarget:' has been explicitly marked partial here}} +// expected-note@+2 {{'setPartialTarget:' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0.0}} #endif @property(nonatomic,assign) id partialTarget __attribute__((availability(ios,introduced=5.0))); @end @@ -40,7 +40,8 @@ // expected-note 2 {{'setDep_target:' has been explicitly marked deprecated here}} #if defined(WARN_PARTIAL) -// expected-note@+2 2 {{'partial_dep_target' has been explicitly marked partial here}} expected-note@+2 2 {{'setPartial_dep_target:' has been explicitly marked partial here}} +// expected-note@+3 2 {{'partial_dep_target' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0.0}} +// expected-note@+2 2 {{'setPartial_dep_target:' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0.0}} #endif @property(nonatomic,assign) id partial_dep_target __attribute__((availability(ios,introduced=5.0))); @end @@ -100,12 +101,12 @@ @property(setter=setNewDelegate:,assign) id delegate __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{'setNewDelegate:' has been explicitly marked deprecated here}} expected-note {{property 'delegate' is declared deprecated here}} #if defined(WARN_PARTIAL) -// expected-note@+2 {{'partialIsEnabled' has been explicitly marked partial here}} +// expected-note@+2 {{'partialIsEnabled' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0.0}} #endif @property(getter=partialIsEnabled,assign) BOOL partialEnabled __attribute__((availability(ios,introduced=5.0))); #if defined(WARN_PARTIAL) -// expected-note@+2 {{'partialSetNewDelegate:' has been explicitly marked partial here}} +// expected-note@+2 {{'partialSetNewDelegate:' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0.0}} #endif @property(setter=partialSetNewDelegate:,assign) id partialDelegate __attribute__((availability(ios,introduced=5.0))); @end Index: clang/test/SemaObjC/attr-availability.m =================================================================== --- clang/test/SemaObjC/attr-availability.m +++ clang/test/SemaObjC/attr-availability.m @@ -5,7 +5,7 @@ - (void)proto_method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note 2 {{'proto_method' has been explicitly marked deprecated here}} #if defined(WARN_PARTIAL) - // expected-note@+2 2 {{'partial_proto_method' has been explicitly marked partial here}} +// expected-note@+2 2 {{'partial_proto_method' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}} #endif - (void)partial_proto_method __attribute__((availability(macosx,introduced=10.8))); @end @@ -13,7 +13,7 @@ @interface A <P> - (void)method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note {{'method' has been explicitly marked deprecated here}} #if defined(WARN_PARTIAL) - // expected-note@+2 2 {{'partialMethod' has been explicitly marked partial here}} +// expected-note@+2 2 {{'partialMethod' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}} #endif - (void)partialMethod __attribute__((availability(macosx,introduced=10.8))); @@ -137,8 +137,8 @@ @interface PartialI <PartialProt> #ifdef WARN_PARTIAL -// expected-note@+3{{marked partial here}} -// expected-note@+3{{marked partial here}} +// expected-note@+3{{'partialMethod' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}} +// expected-note@+3{{'partialMethod' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}} #endif - (void)partialMethod __attribute__((availability(macosx,introduced=10.8))); + (void)partialMethod __attribute__((availability(macosx,introduced=10.8))); @@ -147,12 +147,12 @@ @interface PartialI () - (void)ipartialMethod1 __attribute__((availability(macosx,introduced=10.8))); #if defined(WARN_PARTIAL) - // expected-note@+2 {{'ipartialMethod2' has been explicitly marked partial here}} +// expected-note@+2 {{'ipartialMethod2' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}} #endif - (void)ipartialMethod2 __attribute__((availability(macosx,introduced=10.8))); + (void)ipartialMethod1 __attribute__((availability(macosx,introduced=10.8))); #if defined(WARN_PARTIAL) - // expected-note@+2 {{'ipartialMethod2' has been explicitly marked partial here}} +// expected-note@+2 {{'ipartialMethod2' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}} #endif + (void)ipartialMethod2 __attribute__((availability(macosx,introduced=10.8))); @end @@ -190,7 +190,7 @@ } #if defined(WARN_PARTIAL) - // expected-note@+2 2 {{'PartialI2' has been explicitly marked partial here}} +// expected-note@+2 2 {{'PartialI2' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}} #endif __attribute__((availability(macosx, introduced = 10.8))) @interface PartialI2 @end @@ -314,8 +314,8 @@ #if defined(WARN_PARTIAL) int fn_10_5() __attribute__((availability(macosx, introduced=10.5))); -int fn_10_7() __attribute__((availability(macosx, introduced=10.7))); // expected-note{{marked partial here}} -int fn_10_8() __attribute__((availability(macosx, introduced=10.8))) { // expected-note{{marked partial here}} +int fn_10_7() __attribute__((availability(macosx, introduced=10.7))); // expected-note{{'fn_10_7' has been marked as being introduced in macOS 10.7 here, but the deployment target is macOS 10.5.0}} +int fn_10_8() __attribute__((availability(macosx, introduced=10.8))) { // expected-note{{'fn_10_8' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}} return fn_10_7(); } Index: clang/test/Sema/availability-guard-format.mm =================================================================== --- clang/test/Sema/availability-guard-format.mm +++ clang/test/Sema/availability-guard-format.mm @@ -3,7 +3,7 @@ // Testing that even for source code using '_' as a delimiter in availability version tuple '.' is actually used in diagnostic output as a delimiter. @interface foo -- (void) method_bar __attribute__((availability(macosx, introduced = 10_12))); // expected-note {{'method_bar' has been explicitly marked partial here}} +- (void) method_bar __attribute__((availability(macosx, introduced = 10_12))); // expected-note {{'method_bar' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}} @end int main() { Index: clang/test/Sema/attr-availability.c =================================================================== --- clang/test/Sema/attr-availability.c +++ clang/test/Sema/attr-availability.c @@ -16,13 +16,13 @@ ATSFontGetPostScriptName(int flags) __attribute__((availability(macosx,introduced=8.0,obsoleted=9.0, message="use ATSFontGetFullPostScriptName"))); // expected-note {{'ATSFontGetPostScriptName' has been explicitly marked unavailable here}} #if defined(WARN_PARTIAL) -// expected-note@+3 {{has been explicitly marked partial here}} +// expected-note@+3 {{'PartiallyAvailable' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}} #endif extern void PartiallyAvailable() __attribute__((availability(macosx,introduced=10.8))); #ifdef WARN_PARTIAL -// expected-note@+2 2 {{marked partial here}} +// expected-note@+2 2 {{'PartialEnum' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}} #endif enum __attribute__((availability(macosx,introduced=10.8))) PartialEnum { kPartialEnumConstant, @@ -41,7 +41,7 @@ #ifdef WARN_PARTIAL // FIXME: This note should point to the declaration with the availability // attribute. -// expected-note@+2 {{marked partial here}} +// expected-note@+2 {{'PartiallyAvailable' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}} #endif extern void PartiallyAvailable() ; void with_redeclaration() { Index: clang/lib/Sema/SemaExpr.cpp =================================================================== --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -121,7 +121,7 @@ return NoteDeletedInheritingConstructor(Ctor); Diag(Decl->getLocation(), diag::note_availability_specified_here) - << Decl << true; + << Decl << 1; } /// Determine whether a FunctionDecl was ever declared with an Index: clang/lib/Sema/SemaDeclAttr.cpp =================================================================== --- clang/lib/Sema/SemaDeclAttr.cpp +++ clang/lib/Sema/SemaDeclAttr.cpp @@ -7509,14 +7509,16 @@ unsigned Warning = UseNewWarning ? diag::warn_unguarded_availability_new : diag::warn_unguarded_availability; - S.Diag(Loc, Warning) - << OffendingDecl - << AvailabilityAttr::getPrettyPlatformName( - S.getASTContext().getTargetInfo().getPlatformName()) - << Introduced.getAsString(); + std::string PlatformName = AvailabilityAttr::getPrettyPlatformName( + S.getASTContext().getTargetInfo().getPlatformName()); - S.Diag(OffendingDecl->getLocation(), diag::note_availability_specified_here) - << OffendingDecl << /* partial */ 3; + S.Diag(Loc, Warning) << OffendingDecl << PlatformName + << Introduced.getAsString(); + + S.Diag(OffendingDecl->getLocation(), + diag::note_partial_availability_specified_here) + << OffendingDecl << PlatformName << Introduced.getAsString() + << S.Context.getTargetInfo().getPlatformMinVersion().getAsString(); if (const auto *Enclosing = findEnclosingDeclToAnnotate(Ctx)) { if (const auto *TD = dyn_cast<TagDecl>(Enclosing)) @@ -7969,15 +7971,18 @@ ? diag::warn_unguarded_availability_new : diag::warn_unguarded_availability; + std::string PlatformName = AvailabilityAttr::getPrettyPlatformName( + SemaRef.getASTContext().getTargetInfo().getPlatformName()); + SemaRef.Diag(Range.getBegin(), DiagKind) - << Range << D - << AvailabilityAttr::getPrettyPlatformName( - SemaRef.getASTContext().getTargetInfo().getPlatformName()) - << Introduced.getAsString(); + << Range << D << PlatformName << Introduced.getAsString(); SemaRef.Diag(OffendingDecl->getLocation(), - diag::note_availability_specified_here) - << OffendingDecl << /* partial */ 3; + diag::note_partial_availability_specified_here) + << OffendingDecl << PlatformName << Introduced.getAsString() + << SemaRef.Context.getTargetInfo() + .getPlatformMinVersion() + .getAsString(); auto FixitDiag = SemaRef.Diag(Range.getBegin(), diag::note_unguarded_available_silence) Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -4565,7 +4565,10 @@ InGroup<UnavailableDeclarations>; def note_availability_specified_here : Note< "%0 has been explicitly marked " - "%select{unavailable|deleted|deprecated|partial}1 here">; + "%select{unavailable|deleted|deprecated}1 here">; +def note_partial_availability_specified_here : Note< + "%0 has been marked as being introduced in %1 %2 here, " + "but the deployment target is %1 %3">; def note_implicitly_deleted : Note< "explicitly defaulted function was implicitly deleted here">; def warn_not_enough_argument : Warning<
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits