On Thu, Oct 2, 2014 at 12:39 PM, Fariborz Jahanian <[email protected]> wrote: > Author: fjahanian > Date: Thu Oct 2 11:39:45 2014 > New Revision: 218884 > > URL: http://llvm.org/viewvc/llvm-project?rev=218884&view=rev > Log: > Patch to accept '_' in addition to '.' as version > number separator in "availability" attribute. > rdar://18490958
This does not behave the way I was hoping it would when you asked about implementing it... > > Added: > cfe/trunk/test/SemaObjC/attr-availability-1.m > Modified: > cfe/trunk/lib/Parse/ParseDecl.cpp > > Modified: cfe/trunk/lib/Parse/ParseDecl.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=218884&r1=218883&r2=218884&view=diff > ============================================================================== > --- cfe/trunk/lib/Parse/ParseDecl.cpp (original) > +++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Oct 2 11:39:45 2014 > @@ -627,6 +627,10 @@ void Parser::ParseOpenCLQualifiers(Parse > AttributeList::AS_Keyword); > } > > +static bool VersionNumberSeparator(const char Separator) { > + return (Separator == '.' || Separator == '_'); > +} > + > /// \brief Parse a version number. > /// > /// version: > @@ -684,7 +688,8 @@ VersionTuple Parser::ParseVersionTuple(S > return VersionTuple(Major); > } > > - if (ThisTokBegin[AfterMajor] != '.' || (AfterMajor + 1 == ActualLength)) { > + if (!VersionNumberSeparator(ThisTokBegin[AfterMajor]) > + || (AfterMajor + 1 == ActualLength)) { > Diag(Tok, diag::err_expected_version); > SkipUntil(tok::comma, tok::r_paren, > StopAtSemi | StopBeforeMatch | StopAtCodeCompletion); > @@ -711,8 +716,8 @@ VersionTuple Parser::ParseVersionTuple(S > return VersionTuple(Major, Minor); > } > > - // If what follows is not a '.', we have a problem. > - if (ThisTokBegin[AfterMinor] != '.') { > + // If what follows is not a '.' or '_', we have a problem. > + if (!VersionNumberSeparator(ThisTokBegin[AfterMinor])) { > Diag(Tok, diag::err_expected_version); > SkipUntil(tok::comma, tok::r_paren, > StopAtSemi | StopBeforeMatch | StopAtCodeCompletion); > > Added: cfe/trunk/test/SemaObjC/attr-availability-1.m > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-availability-1.m?rev=218884&view=auto > ============================================================================== > --- cfe/trunk/test/SemaObjC/attr-availability-1.m (added) > +++ cfe/trunk/test/SemaObjC/attr-availability-1.m Thu Oct 2 11:39:45 2014 > @@ -0,0 +1,92 @@ > +// RUN: %clang_cc1 -triple x86_64-apple-darwin9.0.0 -fsyntax-only -verify %s > +// RUN: %clang_cc1 -x objective-c++ -std=c++11 -triple > x86_64-apple-darwin9.0.0 -fsyntax-only -verify %s > +// RUN: %clang_cc1 -x objective-c++ -std=c++03 -triple > x86_64-apple-darwin9.0.0 -fsyntax-only -verify %s > +// rdar://18490958 > + > +@protocol P > +- (void)proto_method > __attribute__((availability(macosx,introduced=10_1,deprecated=10_2))); // > expected-note 2 {{'proto_method' has been explicitly marked deprecated here}} > +@end > + > +@interface A <P> > +- (void)method > __attribute__((availability(macosx,introduced=10_1,deprecated=10_2))); // > expected-note {{'method' has been explicitly marked deprecated here}} > + > +- (void)overridden __attribute__((availability(macosx,introduced=10_3))); // > expected-note{{overridden method is here}} > +- (void)overridden2 __attribute__((availability(macosx,introduced=10_3))); > +- (void)overridden3 __attribute__((availability(macosx,deprecated=10_3))); > +- (void)overridden4 __attribute__((availability(macosx,deprecated=10_3))); > // expected-note{{overridden method is here}} > +- (void)overridden5 __attribute__((availability(macosx,unavailable))); > +- (void)overridden6 __attribute__((availability(macosx,introduced=10_3))); > // expected-note{{overridden method is here}} > +@end > + > +// rdar://11475360 > +@interface B : A > +- (void)method; // NOTE: we expect 'method' to *not* inherit availability. > +- (void)overridden __attribute__((availability(macosx,introduced=10_4))); // > expected-warning{{overriding method introduced after overridden method on OS > X (10.4 vs. 10.3)}} This does not print the diagnostic the way I would expect. It should print 10_4 vs 10_3 as that's what the user wrote. Same elsewhere. > +- (void)overridden2 __attribute__((availability(macosx,introduced=10_2))); > +- (void)overridden3 __attribute__((availability(macosx,deprecated=10_4))); > +- (void)overridden4 __attribute__((availability(macosx,deprecated=10_2))); > // expected-warning{{overriding method deprecated before overridden method on > OS X (10.3 vs. 10.2)}} > +- (void)overridden5 __attribute__((availability(macosx,introduced=10_3))); > +- (void)overridden6 __attribute__((availability(macosx,unavailable))); // > expected-warning{{overriding method cannot be unavailable on OS X when its > overridden method is available}} > +@end > + > +void f(A *a, B *b) { > + [a method]; // expected-warning{{'method' is deprecated: first deprecated > in OS X 10.2}} > + [b method]; // no-warning > + [a proto_method]; // expected-warning{{'proto_method' is deprecated: first > deprecated in OS X 10.2}} > + [b proto_method]; // expected-warning{{'proto_method' is deprecated: first > deprecated in OS X 10.2}} > +} > + > +// Test case for <rdar://problem/11627873>. Warn about > +// using a deprecated method when that method is re-implemented in a > +// subclass where the redeclared method is not deprecated. > +@interface C > +- (void) method > __attribute__((availability(macosx,introduced=10_1,deprecated=10_2))); // > expected-note {{'method' has been explicitly marked deprecated here}} > +@end > + > +@interface D : C > +- (void) method; > +@end > + > +@interface E : D > +- (void) method; > +@end > + > +@implementation D > +- (void) method { > + [super method]; // expected-warning {{'method' is deprecated: first > deprecated in OS X 10.2}} > +} > +@end > + > +@implementation E > +- (void) method { > + [super method]; // no-warning > +} > +@end > + > +// rdar://18059669 > +@class NSMutableArray; > + > +@interface NSDictionary > ++ (instancetype)dictionaryWithObjectsAndKeys:(id)firstObject, ... > __attribute__((sentinel(0,1))); > +@end > + > +@class NSString; > + > +extern NSString *NSNibTopLevelObjects > __attribute__((availability(macosx,introduced=10_0 > ,deprecated=10_8,message="" ))); > +id NSNibOwner, topNibObjects; > + > +@interface AppDelegate (SIEImport) // expected-error {{cannot find interface > declaration for 'AppDelegate'}} > + > +-(void)__attribute__((ibaction))importFromSIE:(id)sender; > + > +@end > + > +@implementation AppDelegate (SIEImport) // expected-error {{cannot find > interface declaration for 'AppDelegate'}} > + > +-(void)__attribute__((ibaction))importFromSIE:(id)sender { > + > + NSMutableArray *topNibObjects; > + NSDictionary *nibLoadDict = [NSDictionary > dictionaryWithObjectsAndKeys:self, NSNibOwner, topNibObjects, > NSNibTopLevelObjects, ((void *)0)]; > +} > + > +@end I see no tests that ensure this is pretty-printed out the way the user originally wrote it. ~Aaron _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
