Skip to content

migrator: set up placeholder migration scripts for swift 4.2 #21412

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
Dec 18, 2018
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
19 changes: 11 additions & 8 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,8 +1079,11 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
return false;
}

static std::string getScriptFileName(StringRef name) {
return (Twine(name) + "4" + ".json").str();
static std::string getScriptFileName(StringRef name, version::Version &ver) {
if (ver.isVersionAtLeast(4, 2))
return (Twine(name) + "42" + ".json").str();
else
return (Twine(name) + "4" + ".json").str();
}

static bool ParseMigratorArgs(MigratorOptions &Opts,
Expand Down Expand Up @@ -1124,20 +1127,20 @@ static bool ParseMigratorArgs(MigratorOptions &Opts,

bool Supported = true;
llvm::SmallString<128> dataPath(basePath);

auto &langVer = LangOpts.EffectiveLanguageVersion;
if (Triple.isMacOSX())
llvm::sys::path::append(dataPath, getScriptFileName("macos"));
llvm::sys::path::append(dataPath, getScriptFileName("macos", langVer));
else if (Triple.isiOS())
llvm::sys::path::append(dataPath, getScriptFileName("ios"));
llvm::sys::path::append(dataPath, getScriptFileName("ios", langVer));
else if (Triple.isTvOS())
llvm::sys::path::append(dataPath, getScriptFileName("tvos"));
llvm::sys::path::append(dataPath, getScriptFileName("tvos", langVer));
else if (Triple.isWatchOS())
llvm::sys::path::append(dataPath, getScriptFileName("watchos"));
llvm::sys::path::append(dataPath, getScriptFileName("watchos", langVer));
else
Supported = false;
if (Supported) {
llvm::SmallString<128> authoredDataPath(basePath);
llvm::sys::path::append(authoredDataPath, getScriptFileName("overlay"));
llvm::sys::path::append(authoredDataPath, getScriptFileName("overlay", langVer));
// Add authored list first to take higher priority.
Opts.APIDigesterDataStorePaths.push_back(authoredDataPath.str());
Opts.APIDigesterDataStorePaths.push_back(dataPath.str());
Expand Down
5 changes: 5 additions & 0 deletions lib/Migrator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ set(datafiles
tvos4.json
watchos4.json
overlay4.json
macos42.json
ios42.json
tvos42.json
watchos42.json
overlay42.json
)
set(SWIFTLIB_DIR
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/swift")
Expand Down
1 change: 1 addition & 0 deletions lib/Migrator/ios42.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions lib/Migrator/macos42.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
13 changes: 13 additions & 0 deletions lib/Migrator/overlay42.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"DiffItemKind": "CommonDiffItem",
"NodeKind": "Function",
"NodeAnnotation": "Rename",
"ChildIndex": "0",
"LeftUsr": "s:SlsSQ7ElementRpzrlE5index2of5IndexQzSgAB_tF",
"LeftComment": "index",
"RightUsr": "",
"RightComment": "firstIndex",
"ModuleName": "Swift"
},
]
1 change: 1 addition & 0 deletions lib/Migrator/tvos42.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions lib/Migrator/watchos42.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
2 changes: 2 additions & 0 deletions test/Migrator/stdlib_rename.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// REQUIRES: objc_interop
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -emit-migrated-file-path %t/stdlib_rename.swift.result -emit-remap-file-path %t/stdlib_rename.swift.remap -o /dev/null
// RUN: diff -u %S/stdlib_rename.swift.expected %t/stdlib_rename.swift.result
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -emit-migrated-file-path %t/stdlib_rename.swift.result -emit-remap-file-path %t/stdlib_rename.swift.remap -o /dev/null -swift-version 4.2
// RUN: diff -u %S/stdlib_rename.swift.expected %t/stdlib_rename.swift.result

func test1(_ a: [String], s: String) {
_ = a.index(of: s)
Expand Down
2 changes: 2 additions & 0 deletions test/Migrator/stdlib_rename.swift.expected
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// REQUIRES: objc_interop
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -emit-migrated-file-path %t/stdlib_rename.swift.result -emit-remap-file-path %t/stdlib_rename.swift.remap -o /dev/null
// RUN: diff -u %S/stdlib_rename.swift.expected %t/stdlib_rename.swift.result
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -emit-migrated-file-path %t/stdlib_rename.swift.result -emit-remap-file-path %t/stdlib_rename.swift.remap -o /dev/null -swift-version 4.2
// RUN: diff -u %S/stdlib_rename.swift.expected %t/stdlib_rename.swift.result

func test1(_ a: [String], s: String) {
_ = a.firstIndex(of: s)
Expand Down