r219124 - Patch to wrap up '_' as separator in version numbers

Aaron Ballman aaron at aaronballman.com
Mon Oct 6 10:13:08 PDT 2014


Thank you for finishing this up!

~Aaron

On Mon, Oct 6, 2014 at 12:46 PM, Fariborz Jahanian <fjahanian at apple.com> wrote:
> Author: fjahanian
> Date: Mon Oct  6 11:46:02 2014
> New Revision: 219124
>
> URL: http://llvm.org/viewvc/llvm-project?rev=219124&view=rev
> Log:
> Patch to wrap up '_' as separator in version numbers
> in availability attribute by preserving this info.
> in VersionTuple and using it in pretty printing of attributes
> and yet using '.' as separator when diagnosing unavailable
> message calls. rdar://18490958
>
> Modified:
>     cfe/trunk/include/clang/Basic/VersionTuple.h
>     cfe/trunk/lib/AST/DeclBase.cpp
>     cfe/trunk/lib/Basic/VersionTuple.cpp
>     cfe/trunk/lib/Parse/ParseDecl.cpp
>     cfe/trunk/test/Misc/ast-print-objectivec.m
>     cfe/trunk/test/SemaObjC/attr-availability-1.m
>
> Modified: cfe/trunk/include/clang/Basic/VersionTuple.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VersionTuple.h?rev=219124&r1=219123&r2=219124&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/VersionTuple.h (original)
> +++ cfe/trunk/include/clang/Basic/VersionTuple.h Mon Oct  6 11:46:02 2014
> @@ -24,30 +24,35 @@ namespace clang {
>
>  /// \brief Represents a version number in the form major[.minor[.subminor]].
>  class VersionTuple {
> -  unsigned Major;
> +  unsigned Major : 31;
>    unsigned Minor : 31;
>    unsigned Subminor : 31;
>    unsigned HasMinor : 1;
>    unsigned HasSubminor : 1;
> +  unsigned UsesUnderscores : 1;
>
>  public:
>    VersionTuple()
> -    : Major(0), Minor(0), Subminor(0), HasMinor(false), HasSubminor(false) { }
> +    : Major(0), Minor(0), Subminor(0), HasMinor(false), HasSubminor(false),
> +      UsesUnderscores(false) { }
>
>    explicit VersionTuple(unsigned Major)
> -    : Major(Major), Minor(0), Subminor(0), HasMinor(false), HasSubminor(false)
> +    : Major(Major), Minor(0), Subminor(0), HasMinor(false), HasSubminor(false),
> +      UsesUnderscores(false)
>    { }
>
> -  explicit VersionTuple(unsigned Major, unsigned Minor)
> +  explicit VersionTuple(unsigned Major, unsigned Minor,
> +                        bool UsesUnderscores = false)
>      : Major(Major), Minor(Minor), Subminor(0), HasMinor(true),
> -      HasSubminor(false)
> +      HasSubminor(false), UsesUnderscores(UsesUnderscores)
>    { }
>
> -  explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor)
> +  explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
> +                        bool UsesUnderscores = false)
>      : Major(Major), Minor(Minor), Subminor(Subminor), HasMinor(true),
> -      HasSubminor(true)
> +      HasSubminor(true), UsesUnderscores(UsesUnderscores)
>    { }
> -
> +
>    /// \brief Determine whether this version information is empty
>    /// (e.g., all version components are zero).
>    bool empty() const { return Major == 0 && Minor == 0 && Subminor == 0; }
> @@ -69,6 +74,14 @@ public:
>      return Subminor;
>    }
>
> +  bool usesUnderscores() const {
> +    return UsesUnderscores;
> +  }
> +
> +  void UseDotAsSeparator() {
> +    UsesUnderscores = false;
> +  }
> +
>    /// \brief Determine if two version numbers are equivalent. If not
>    /// provided, minor and subminor version numbers are considered to be zero.
>    friend bool operator==(const VersionTuple& X, const VersionTuple &Y) {
>
> Modified: cfe/trunk/lib/AST/DeclBase.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=219124&r1=219123&r2=219124&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/DeclBase.cpp (original)
> +++ cfe/trunk/lib/AST/DeclBase.cpp Mon Oct  6 11:46:02 2014
> @@ -374,8 +374,10 @@ static AvailabilityResult CheckAvailabil
>      if (Message) {
>        Message->clear();
>        llvm::raw_string_ostream Out(*Message);
> +      VersionTuple VTI(A->getIntroduced());
> +      VTI.UseDotAsSeparator();
>        Out << "introduced in " << PrettyPlatformName << ' '
> -          << A->getIntroduced() << HintMessage;
> +          << VTI << HintMessage;
>      }
>
>      return AR_NotYetIntroduced;
> @@ -386,8 +388,10 @@ static AvailabilityResult CheckAvailabil
>      if (Message) {
>        Message->clear();
>        llvm::raw_string_ostream Out(*Message);
> +      VersionTuple VTO(A->getObsoleted());
> +      VTO.UseDotAsSeparator();
>        Out << "obsoleted in " << PrettyPlatformName << ' '
> -          << A->getObsoleted() << HintMessage;
> +          << VTO << HintMessage;
>      }
>
>      return AR_Unavailable;
> @@ -398,8 +402,10 @@ static AvailabilityResult CheckAvailabil
>      if (Message) {
>        Message->clear();
>        llvm::raw_string_ostream Out(*Message);
> +      VersionTuple VTD(A->getDeprecated());
> +      VTD.UseDotAsSeparator();
>        Out << "first deprecated in " << PrettyPlatformName << ' '
> -          << A->getDeprecated() << HintMessage;
> +          << VTD << HintMessage;
>      }
>
>      return AR_Deprecated;
>
> Modified: cfe/trunk/lib/Basic/VersionTuple.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VersionTuple.cpp?rev=219124&r1=219123&r2=219124&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Basic/VersionTuple.cpp (original)
> +++ cfe/trunk/lib/Basic/VersionTuple.cpp Mon Oct  6 11:46:02 2014
> @@ -29,9 +29,9 @@ raw_ostream& clang::operator<<(raw_ostre
>                                       const VersionTuple &V) {
>    Out << V.getMajor();
>    if (Optional<unsigned> Minor = V.getMinor())
> -    Out << '.' << *Minor;
> +    Out << (V.usesUnderscores() ? '_' : '.') << *Minor;
>    if (Optional<unsigned> Subminor = V.getSubminor())
> -    Out << '.' << *Subminor;
> +    Out << (V.usesUnderscores() ? '_' : '.') << *Subminor;
>    return Out;
>  }
>
>
> Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=219124&r1=219123&r2=219124&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Oct  6 11:46:02 2014
> @@ -714,7 +714,7 @@ VersionTuple Parser::ParseVersionTuple(S
>        return VersionTuple();
>      }
>
> -    return VersionTuple(Major, Minor);
> +    return VersionTuple(Major, Minor, (AfterMajorSeparator == '_'));
>    }
>
>    const char AfterMinorSeparator = ThisTokBegin[AfterMinor];
> @@ -745,7 +745,7 @@ VersionTuple Parser::ParseVersionTuple(S
>      return VersionTuple();
>    }
>    ConsumeToken();
> -  return VersionTuple(Major, Minor, Subminor);
> +  return VersionTuple(Major, Minor, Subminor, (AfterMajorSeparator == '_'));
>  }
>
>  /// \brief Parse the contents of the "availability" attribute.
>
> Modified: cfe/trunk/test/Misc/ast-print-objectivec.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-objectivec.m?rev=219124&r1=219123&r2=219124&view=diff
> ==============================================================================
> --- cfe/trunk/test/Misc/ast-print-objectivec.m (original)
> +++ cfe/trunk/test/Misc/ast-print-objectivec.m Mon Oct  6 11:46:02 2014
> @@ -11,7 +11,7 @@
>  @end
>
>  @interface I(CAT)
> -- (void)MethCAT __attribute__((availability(macosx,introduced=10.1.0,deprecated=10.2)));
> +- (void)MethCAT __attribute__((availability(macosx,introduced=10_1_0,deprecated=10_2)));
>  @end
>
>  @implementation I
> @@ -28,7 +28,7 @@
>  // CHECK: @end
>
>  // CHECK: @interface I(CAT)
> -// CHECK: - (void) MethCAT __attribute__((availability(macosx, introduced=10.1.0, deprecated=10.2)));
> +// CHECK: - (void) MethCAT __attribute__((availability(macosx, introduced=10_1_0, deprecated=10_2)));
>  // CHECK: @end
>
>  // CHECK: @implementation I
>
> Modified: cfe/trunk/test/SemaObjC/attr-availability-1.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-availability-1.m?rev=219124&r1=219123&r2=219124&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaObjC/attr-availability-1.m (original)
> +++ cfe/trunk/test/SemaObjC/attr-availability-1.m Mon Oct  6 11:46:02 2014
> @@ -21,10 +21,10 @@
>  // 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)}}
> +- (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)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
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list