Skip to content

Commit c3f899e

Browse files
authored
Merge pull request #21412 from nkcsgexi/add-4-3
migrator: set up placeholder migration scripts for swift 4.2
2 parents 5debcdd + 4164600 commit c3f899e

File tree

9 files changed

+37
-8
lines changed

9 files changed

+37
-8
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,8 +1079,11 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
10791079
return false;
10801080
}
10811081

1082-
static std::string getScriptFileName(StringRef name) {
1083-
return (Twine(name) + "4" + ".json").str();
1082+
static std::string getScriptFileName(StringRef name, version::Version &ver) {
1083+
if (ver.isVersionAtLeast(4, 2))
1084+
return (Twine(name) + "42" + ".json").str();
1085+
else
1086+
return (Twine(name) + "4" + ".json").str();
10841087
}
10851088

10861089
static bool ParseMigratorArgs(MigratorOptions &Opts,
@@ -1124,20 +1127,20 @@ static bool ParseMigratorArgs(MigratorOptions &Opts,
11241127

11251128
bool Supported = true;
11261129
llvm::SmallString<128> dataPath(basePath);
1127-
1130+
auto &langVer = LangOpts.EffectiveLanguageVersion;
11281131
if (Triple.isMacOSX())
1129-
llvm::sys::path::append(dataPath, getScriptFileName("macos"));
1132+
llvm::sys::path::append(dataPath, getScriptFileName("macos", langVer));
11301133
else if (Triple.isiOS())
1131-
llvm::sys::path::append(dataPath, getScriptFileName("ios"));
1134+
llvm::sys::path::append(dataPath, getScriptFileName("ios", langVer));
11321135
else if (Triple.isTvOS())
1133-
llvm::sys::path::append(dataPath, getScriptFileName("tvos"));
1136+
llvm::sys::path::append(dataPath, getScriptFileName("tvos", langVer));
11341137
else if (Triple.isWatchOS())
1135-
llvm::sys::path::append(dataPath, getScriptFileName("watchos"));
1138+
llvm::sys::path::append(dataPath, getScriptFileName("watchos", langVer));
11361139
else
11371140
Supported = false;
11381141
if (Supported) {
11391142
llvm::SmallString<128> authoredDataPath(basePath);
1140-
llvm::sys::path::append(authoredDataPath, getScriptFileName("overlay"));
1143+
llvm::sys::path::append(authoredDataPath, getScriptFileName("overlay", langVer));
11411144
// Add authored list first to take higher priority.
11421145
Opts.APIDigesterDataStorePaths.push_back(authoredDataPath.str());
11431146
Opts.APIDigesterDataStorePaths.push_back(dataPath.str());

lib/Migrator/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ set(datafiles
44
tvos4.json
55
watchos4.json
66
overlay4.json
7+
macos42.json
8+
ios42.json
9+
tvos42.json
10+
watchos42.json
11+
overlay42.json
712
)
813
set(SWIFTLIB_DIR
914
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/swift")

lib/Migrator/ios42.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

lib/Migrator/macos42.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

lib/Migrator/overlay42.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
{
3+
"DiffItemKind": "CommonDiffItem",
4+
"NodeKind": "Function",
5+
"NodeAnnotation": "Rename",
6+
"ChildIndex": "0",
7+
"LeftUsr": "s:SlsSQ7ElementRpzrlE5index2of5IndexQzSgAB_tF",
8+
"LeftComment": "index",
9+
"RightUsr": "",
10+
"RightComment": "firstIndex",
11+
"ModuleName": "Swift"
12+
},
13+
]

lib/Migrator/tvos42.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

lib/Migrator/watchos42.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

test/Migrator/stdlib_rename.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// REQUIRES: objc_interop
22
// 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
33
// RUN: diff -u %S/stdlib_rename.swift.expected %t/stdlib_rename.swift.result
4+
// 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
5+
// RUN: diff -u %S/stdlib_rename.swift.expected %t/stdlib_rename.swift.result
46

57
func test1(_ a: [String], s: String) {
68
_ = a.index(of: s)

test/Migrator/stdlib_rename.swift.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// REQUIRES: objc_interop
22
// 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
33
// RUN: diff -u %S/stdlib_rename.swift.expected %t/stdlib_rename.swift.result
4+
// 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
5+
// RUN: diff -u %S/stdlib_rename.swift.expected %t/stdlib_rename.swift.result
46

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

0 commit comments

Comments
 (0)