Index: cfe/trunk/include/clang/Basic/VersionTuple.h =================================================================== --- cfe/trunk/include/clang/Basic/VersionTuple.h +++ cfe/trunk/include/clang/Basic/VersionTuple.h @@ -24,9 +24,7 @@ /// Represents a version number in the form major[.minor[.subminor[.build]]]. class VersionTuple { - unsigned Major : 31; - - unsigned UsesUnderscores : 1; + unsigned Major : 32; unsigned Minor : 31; unsigned HasMinor : 1; @@ -39,30 +37,25 @@ public: VersionTuple() - : Major(0), UsesUnderscores(false), Minor(0), HasMinor(false), - Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {} + : Major(0), Minor(0), HasMinor(false), Subminor(0), HasSubminor(false), + Build(0), HasBuild(false) {} explicit VersionTuple(unsigned Major) - : Major(Major), UsesUnderscores(false), Minor(0), HasMinor(false), - Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {} - - explicit VersionTuple(unsigned Major, unsigned Minor, - bool UsesUnderscores = false) - : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor), - HasMinor(true), Subminor(0), HasSubminor(false), Build(0), - HasBuild(false) {} + : Major(Major), Minor(0), HasMinor(false), Subminor(0), + HasSubminor(false), Build(0), HasBuild(false) {} - explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor, - bool UsesUnderscores = false) - : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor), - HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(0), - HasBuild(false) {} + explicit VersionTuple(unsigned Major, unsigned Minor) + : Major(Major), Minor(Minor), HasMinor(true), Subminor(0), + HasSubminor(false), Build(0), HasBuild(false) {} + + explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor) + : Major(Major), Minor(Minor), HasMinor(true), Subminor(Subminor), + HasSubminor(true), Build(0), HasBuild(false) {} explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor, - unsigned Build, bool UsesUnderscores = false) - : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor), - HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(Build), - HasBuild(true) {} + unsigned Build) + : Major(Major), Minor(Minor), HasMinor(true), Subminor(Subminor), + HasSubminor(true), Build(Build), HasBuild(true) {} /// Determine whether this version information is empty /// (e.g., all version components are zero). @@ -93,14 +86,6 @@ return None; return Build; } - - bool usesUnderscores() const { - return UsesUnderscores; - } - - void UseDotAsSeparator() { - UsesUnderscores = false; - } /// Determine if two version numbers are equivalent. If not /// provided, minor and subminor version numbers are considered to be zero. Index: cfe/trunk/lib/AST/DeclBase.cpp =================================================================== --- cfe/trunk/lib/AST/DeclBase.cpp +++ cfe/trunk/lib/AST/DeclBase.cpp @@ -550,7 +550,6 @@ Message->clear(); llvm::raw_string_ostream Out(*Message); VersionTuple VTI(A->getIntroduced()); - VTI.UseDotAsSeparator(); Out << "introduced in " << PrettyPlatformName << ' ' << VTI << HintMessage; } @@ -564,7 +563,6 @@ Message->clear(); llvm::raw_string_ostream Out(*Message); VersionTuple VTO(A->getObsoleted()); - VTO.UseDotAsSeparator(); Out << "obsoleted in " << PrettyPlatformName << ' ' << VTO << HintMessage; } @@ -578,7 +576,6 @@ Message->clear(); llvm::raw_string_ostream Out(*Message); VersionTuple VTD(A->getDeprecated()); - VTD.UseDotAsSeparator(); Out << "first deprecated in " << PrettyPlatformName << ' ' << VTD << HintMessage; } Index: cfe/trunk/lib/Basic/VersionTuple.cpp =================================================================== --- cfe/trunk/lib/Basic/VersionTuple.cpp +++ cfe/trunk/lib/Basic/VersionTuple.cpp @@ -29,11 +29,11 @@ const VersionTuple &V) { Out << V.getMajor(); if (Optional Minor = V.getMinor()) - Out << (V.usesUnderscores() ? '_' : '.') << *Minor; + Out << '.' << *Minor; if (Optional Subminor = V.getSubminor()) - Out << (V.usesUnderscores() ? '_' : '.') << *Subminor; + Out << '.' << *Subminor; if (Optional Build = V.getBuild()) - Out << (V.usesUnderscores() ? '_' : '.') << *Build; + Out << '.' << *Build; return Out; } Index: cfe/trunk/lib/Parse/ParseDecl.cpp =================================================================== --- cfe/trunk/lib/Parse/ParseDecl.cpp +++ cfe/trunk/lib/Parse/ParseDecl.cpp @@ -762,8 +762,10 @@ /// /// version: /// simple-integer -/// simple-integer ',' simple-integer -/// simple-integer ',' simple-integer ',' simple-integer +/// simple-integer '.' simple-integer +/// simple-integer '_' simple-integer +/// simple-integer '.' simple-integer '.' simple-integer +/// simple-integer '_' simple-integer '_' simple-integer VersionTuple Parser::ParseVersionTuple(SourceRange &Range) { Range = SourceRange(Tok.getLocation(), Tok.getEndLoc()); @@ -841,7 +843,7 @@ return VersionTuple(); } - return VersionTuple(Major, Minor, (AfterMajorSeparator == '_')); + return VersionTuple(Major, Minor); } const char AfterMinorSeparator = ThisTokBegin[AfterMinor]; @@ -872,7 +874,7 @@ return VersionTuple(); } ConsumeToken(); - return VersionTuple(Major, Minor, Subminor, (AfterMajorSeparator == '_')); + return VersionTuple(Major, Minor, Subminor); } /// Parse the contents of the "availability" attribute. Index: cfe/trunk/test/Misc/ast-print-objectivec.m =================================================================== --- cfe/trunk/test/Misc/ast-print-objectivec.m +++ cfe/trunk/test/Misc/ast-print-objectivec.m @@ -30,7 +30,7 @@ // CHECK: @end // CHECK: @interface I(CAT) -// CHECK: - (void)MethCAT __attribute__((availability(macos, introduced=10_1_0, deprecated=10_2))); +// CHECK: - (void)MethCAT __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2))); // CHECK: @end // CHECK: @implementation I Index: cfe/trunk/test/Sema/availability-guard-format.mm =================================================================== --- cfe/trunk/test/Sema/availability-guard-format.mm +++ cfe/trunk/test/Sema/availability-guard-format.mm @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macosx-10.11 -Wunguarded-availability -fdiagnostics-parseable-fixits -fsyntax-only -verify %s + +// 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}} +@end + +int main() { + [foo method_bar]; // \ + // expected-warning {{'method_bar' is only available on macOS 10.12 or newer}} \ + // expected-note {{enclose 'method_bar' in an @available check to silence this warning}} \ + // CHECK: "fix-it:.*if (@available(macOS 10.12, *))" + return 0; +} Index: cfe/trunk/test/SemaObjC/attr-availability-1.m =================================================================== --- cfe/trunk/test/SemaObjC/attr-availability-1.m +++ cfe/trunk/test/SemaObjC/attr-availability-1.m @@ -25,10 +25,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 macOS (10_4 vs. 10_3)}} +- (void)overridden __attribute__((availability(macosx,introduced=10_4))); // expected-warning{{overriding method introduced after overridden method on macOS (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 macOS (10_3 vs. 10_2)}} +- (void)overridden4 __attribute__((availability(macosx,deprecated=10_2))); // expected-warning{{overriding method deprecated before overridden method on macOS (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 macOS when its overridden method is available}} @end