r218884 - Patch to accept '_' in addition to '.' as version

Douglas Gregor dgregor at apple.com
Thu Oct 2 09:56:47 PDT 2014


> On Oct 2, 2014, at 9:39 AM, Fariborz Jahanian <fjahanian at apple.com> 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 <rdar://18490958>

Seems kind of weird that we allow version numbers like “10_3.4” and “10.5_3”. Otherwise, LGTM, thanks!

	- Doug

> 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
> +
> + at 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}}
> + at end
> +
> + at 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}}
> + at end
> +
> +// rdar://11475360
> + at 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)}}
> +- (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}}
> + at 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.
> + at interface C
> +- (void) method __attribute__((availability(macosx,introduced=10_1,deprecated=10_2))); // expected-note {{'method' has been explicitly marked deprecated here}}
> + at end
> +
> + at interface D : C
> +- (void) method;
> + at end
> +
> + at interface E : D
> +- (void) method;
> + at end
> +
> + at implementation D
> +- (void) method {
> +  [super method]; // expected-warning {{'method' is deprecated: first deprecated in OS X 10.2}}
> +}
> + at end
> +
> + at implementation E
> +- (void) method {
> +  [super method]; // no-warning
> +}
> + at end
> +
> +// rdar://18059669
> + at class NSMutableArray;
> +
> + at interface NSDictionary
> ++ (instancetype)dictionaryWithObjectsAndKeys:(id)firstObject, ... __attribute__((sentinel(0,1)));
> + at end
> +
> + at class NSString;
> +
> +extern NSString *NSNibTopLevelObjects __attribute__((availability(macosx,introduced=10_0 ,deprecated=10_8,message="" )));
> +id NSNibOwner, topNibObjects;
> +
> + at interface AppDelegate (SIEImport) // expected-error {{cannot find interface declaration for 'AppDelegate'}}
> +
> +-(void)__attribute__((ibaction))importFromSIE:(id)sender;
> +
> + at end
> +
> + at 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)];
> +}
> +
> + at end
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141002/4e696cfa/attachment.html>


More information about the cfe-commits mailing list