swift-module-digester: output ABI/API diagnostics to a path instead of stdout.

This is handy for scripts.
This commit is contained in:
Xi Ge
2018-10-15 19:12:16 -07:00
parent d480362835
commit 70118d4db0
7 changed files with 26 additions and 14 deletions

View File

@@ -2006,6 +2006,7 @@ static void findTypeMemberDiffs(NodePtr leftSDKRoot, NodePtr rightSDKRoot,
}
static int diagnoseModuleChange(StringRef LeftPath, StringRef RightPath,
StringRef OutputPath,
CheckerOptions Opts) {
if (!fs::exists(LeftPath)) {
llvm::errs() << LeftPath << " does not exist\n";
@@ -2015,7 +2016,14 @@ static int diagnoseModuleChange(StringRef LeftPath, StringRef RightPath,
llvm::errs() << RightPath << " does not exist\n";
return 1;
}
ModuleDifferDiagsConsumer PDC(true);
llvm::raw_ostream *OS = &llvm::errs();
std::unique_ptr<llvm::raw_ostream> FileOS;
if (!OutputPath.empty()) {
std::error_code EC;
FileOS.reset(new llvm::raw_fd_ostream(OutputPath, EC, llvm::sys::fs::F_None));
OS = FileOS.get();
}
ModuleDifferDiagsConsumer PDC(true, *OS);
SDKContext Ctx(Opts);
Ctx.getDiags().addConsumer(PDC);
@@ -2333,7 +2341,8 @@ int main(int argc, char *argv[]) {
options::OutputFile, IgnoredUsrs, Opts);
else
return diagnoseModuleChange(options::SDKJsonPaths[0],
options::SDKJsonPaths[1], Opts);
options::SDKJsonPaths[1],
options::OutputFile, Opts);
case ActionType::DeserializeSDK:
case ActionType::DeserializeDiffItems: {
if (options::SDKJsonPaths.size() != 1) {