Merge pull request #19904 from nkcsgexi/redirect-diags

This commit is contained in:
swift-ci
2018-10-15 20:06:13 -07:00
committed by GitHub
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);
@@ -2330,7 +2338,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) {