Make JSON fix-it outputs be per-primary in batch mode. (#14995)

This means moving the output path into SupplementaryOutputPaths, and
using the same sort of diagnostic dispatching that serialized
diagnostics use. This is part of what's needed to run the migrator
in batch mode.
This commit is contained in:
Jordan Rose
2018-03-09 11:58:54 -08:00
committed by GitHub
parent ab0c74b85c
commit 41286bc676
9 changed files with 136 additions and 50 deletions

View File

@@ -908,8 +908,10 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
return false;
}
bool ParseMigratorArgs(MigratorOptions &Opts, llvm::Triple &Triple,
StringRef ResourcePath, ArgList &Args,
bool ParseMigratorArgs(MigratorOptions &Opts,
const FrontendOptions &FrontendOpts,
const llvm::Triple &Triple,
StringRef ResourcePath, const ArgList &Args,
DiagnosticEngine &Diags) {
using namespace options;
@@ -958,6 +960,21 @@ bool ParseMigratorArgs(MigratorOptions &Opts, llvm::Triple &Triple,
}
}
if (Opts.shouldRunMigrator()) {
assert(!FrontendOpts.InputsAndOutputs.isWholeModule());
// FIXME: In order to support batch mode properly, the migrator would have
// to support having one remap file path and one migrated file path per
// primary input. The easiest way to do this would be to move processing of
// these paths into FrontendOptions, like other supplementary outputs, and
// to call migrator::updateCodeAndEmitRemapIfNeeded once for each primary
// file.
//
// Supporting WMO would be similar, but WMO is set up to only produce one
// supplementary output for the whole compilation instead of one per input,
// so it's probably not worth it.
FrontendOpts.InputsAndOutputs.assertMustNotBeMoreThanOnePrimaryInput();
}
return false;
}
@@ -1022,7 +1039,7 @@ bool CompilerInvocation::parseArgs(ArrayRef<const char *> Args,
return true;
}
if (ParseMigratorArgs(MigratorOpts, LangOpts.Target,
if (ParseMigratorArgs(MigratorOpts, FrontendOpts, LangOpts.Target,
SearchPathOpts.RuntimeResourcePath, ParsedArgs, Diags)) {
return true;
}