Skip to content

Normalize version tuples in availability attributes coming from clang to use "." #11739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7029,7 +7029,8 @@ void ClangImporter::Implementation::importAttributes(

StringRef message = avail->getMessage();

const auto &deprecated = avail->getDeprecated();
clang::VersionTuple deprecated = avail->getDeprecated();

if (!deprecated.empty()) {
if (platformAvailability.deprecatedAsUnavailableFilter &&
platformAvailability.deprecatedAsUnavailableFilter(
Expand All @@ -7041,8 +7042,14 @@ void ClangImporter::Implementation::importAttributes(
}
}

const auto &obsoleted = avail->getObsoleted();
const auto &introduced = avail->getIntroduced();
clang::VersionTuple obsoleted = avail->getObsoleted();
clang::VersionTuple introduced = avail->getIntroduced();

// Swift only allows "." separators.
obsoleted.UseDotAsSeparator();
introduced.UseDotAsSeparator();
deprecated.UseDotAsSeparator();

const auto &replacement = avail->getReplacement();

StringRef swiftReplacement = "";
Expand Down
7 changes: 7 additions & 0 deletions test/IDE/Inputs/print_clang_header/header-to-print.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ struct Arkham;
@protocol Soul;

typedef struct __attribute__((objc_bridge(id))) __MyLittleCFType *MyLittleCFType;

@interface MaybeAvailable
-(void)method1 __attribute__((availability(macosx, introduced=10.1)));
-(void)method2 __attribute__((availability(macosx, introduced=10_1)));
-(void)method3 __attribute__((availability(macosx, deprecated=10_10)));
-(void)method4 __attribute__((availability(macosx, introduced=10_1, deprecated=10_10, obsoleted=10_11)));
@end
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,22 @@ protocol Superproto {

class MyLittleCFType {
}

class MaybeAvailable {
@available(OSX 10.1, *)
class func method1()
@available(OSX 10.1, *)
func method1()
@available(OSX 10.1, *)
class func method2()
@available(OSX 10.1, *)
func method2()
@available(OSX, deprecated: 10.10)
class func method3()
@available(OSX, deprecated: 10.10)
func method3()
@available(OSX, introduced: 10.1, deprecated: 10.10, obsoleted: 10.11)
class func method4()
@available(OSX, introduced: 10.1, deprecated: 10.10, obsoleted: 10.11)
func method4()
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,22 @@ protocol Superproto {

class MyLittleCFType : _CFObject {
}

class MaybeAvailable {
@available(OSX 10.1, *)
class func method1()
@available(OSX 10.1, *)
func method1()
@available(OSX 10.1, *)
class func method2()
@available(OSX 10.1, *)
func method2()
@available(OSX, deprecated: 10.10)
class func method3()
@available(OSX, deprecated: 10.10)
func method3()
@available(OSX, introduced: 10.1, deprecated: 10.10, obsoleted: 10.11)
class func method4()
@available(OSX, introduced: 10.1, deprecated: 10.10, obsoleted: 10.11)
func method4()
}
19 changes: 19 additions & 0 deletions test/IDE/Inputs/print_clang_header/header-to-print.h.printed.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,22 @@ protocol Superproto {

class MyLittleCFType : _CFObject {
}

class MaybeAvailable {
@available(OSX 10.1, *)
class func method1()
@available(OSX 10.1, *)
func method1()
@available(OSX 10.1, *)
class func method2()
@available(OSX 10.1, *)
func method2()
@available(OSX, deprecated: 10.10)
class func method3()
@available(OSX, deprecated: 10.10)
func method3()
@available(OSX, introduced: 10.1, deprecated: 10.10, obsoleted: 10.11)
class func method4()
@available(OSX, introduced: 10.1, deprecated: 10.10, obsoleted: 10.11)
func method4()
}