Skip to content

Commit fb77682

Browse files
authored
[Migrator] Add a stub for authored API change list to handle API changes that are not detected automatically. (#9477)
1 parent e997128 commit fb77682

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

include/swift/Migrator/MigratorOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct MigratorOptions {
4444
std::string DumpMigrationStatesDir = "";
4545

4646
/// If non-empty, use the api change data serialized to this path.
47-
std::string APIDigesterDataStorePath = "";
47+
std::vector<std::string> APIDigesterDataStorePaths;
4848

4949
bool shouldRunMigrator() const {
5050
return !(EmitRemapFilePath.empty() && EmitMigratedFilePath.empty() &&

lib/Frontend/CompilerInvocation.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,7 @@ bool ParseMigratorArgs(MigratorOptions &Opts, llvm::Triple &Triple,
16291629
}
16301630

16311631
if (auto DataPath = Args.getLastArg(OPT_api_diff_data_file)) {
1632-
Opts.APIDigesterDataStorePath = DataPath->getValue();
1632+
Opts.APIDigesterDataStorePaths.push_back(DataPath->getValue());
16331633
} else {
16341634
bool Supported = true;
16351635
llvm::SmallString<128> dataPath(ResourcePath);
@@ -1644,8 +1644,14 @@ bool ParseMigratorArgs(MigratorOptions &Opts, llvm::Triple &Triple,
16441644
llvm::sys::path::append(dataPath, "watchos.json");
16451645
else
16461646
Supported = false;
1647-
if (Supported)
1648-
Opts.APIDigesterDataStorePath = dataPath.str();
1647+
if (Supported) {
1648+
llvm::SmallString<128> authoredDataPath(ResourcePath);
1649+
llvm::sys::path::append(authoredDataPath, "migrator");
1650+
llvm::sys::path::append(authoredDataPath, "overlay.json");
1651+
// Add authored list first to take higher priority.
1652+
Opts.APIDigesterDataStorePaths.push_back(authoredDataPath.str());
1653+
Opts.APIDigesterDataStorePaths.push_back(dataPath.str());
1654+
}
16491655
}
16501656

16511657
return false;

lib/Migrator/APIDiffMigratorPass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,10 @@ struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker {
283283
: ASTMigratorPass(Editor, SF, Opts) {}
284284

285285
void run() {
286-
if (Opts.APIDigesterDataStorePath.empty())
286+
if (Opts.APIDigesterDataStorePaths.empty())
287287
return;
288-
DiffStore.addStorePath(Opts.APIDigesterDataStorePath);
288+
for (auto Path : Opts.APIDigesterDataStorePaths)
289+
DiffStore.addStorePath(Path);
289290
DiffStore.printIncomingUsr(Opts.DumpUsr);
290291
walk(SF);
291292
}

lib/Migrator/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set(datafiles
33
ios.json
44
tvos.json
55
watchos.json
6+
overlay.json
67
)
78
set(SWIFTLIB_DIR
89
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/swift")

lib/Migrator/overlay.json

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

0 commit comments

Comments
 (0)