Frontend: Allow passing .sil as -primary-file along with other .sib as input.

Swift SVN r27612
This commit is contained in:
Luqman Aden
2015-04-22 22:53:18 +00:00
parent 8293f3f444
commit ce4bff5645
5 changed files with 66 additions and 0 deletions

View File

@@ -198,6 +198,11 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
// treat the input as SIL.
StringRef Input(Opts.InputFilenames[0]);
TreatAsSIL = llvm::sys::path::extension(Input).endswith(SIL_EXTENSION);
} else if (Opts.PrimaryInput.hasValue() && Opts.PrimaryInput->isFilename()) {
// If we have a primary input and it's a filename with extension "sil",
// treat the input as SIL.
StringRef Input(Opts.InputFilenames[Opts.PrimaryInput->Index]);
TreatAsSIL = llvm::sys::path::extension(Input).endswith(SIL_EXTENSION);
}
// If we have exactly one input filename, and its extension is "bc" or "ll",
@@ -215,6 +220,22 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
Diags.diagnose(SourceLoc(), diag::error_repl_requires_no_input_files);
return true;
}
} else if (TreatAsSIL && Opts.PrimaryInput.hasValue()) {
// If we have the SIL as our primary input, we can waive the one file
// requirement as long as all the other inputs are SIBs.
if (Opts.PrimaryInput.hasValue()) {
for (unsigned i = 0, e = Opts.InputFilenames.size(); i != e; ++i) {
if (i == Opts.PrimaryInput->Index)
continue;
StringRef File(Opts.InputFilenames[i]);
if (!llvm::sys::path::extension(File).endswith(SIB_EXTENSION)) {
Diags.diagnose(SourceLoc(),
diag::error_mode_requires_one_sil_multi_sib);
return true;
}
}
}
} else if (TreatAsSIL) {
if (Opts.InputFilenames.size() != 1) {
Diags.diagnose(SourceLoc(), diag::error_mode_requires_one_input_file);