Enforce exclusivity between -primary-file and -primary-filelist.

This commit is contained in:
David Ungar
2017-12-13 09:45:53 -08:00
parent fb141bb16d
commit 9c78480bdf
4 changed files with 15 additions and 1 deletions

View File

@@ -157,6 +157,9 @@ ERROR(error_primary_file_not_found,none,
ERROR(error_cannot_have_input_files_with_file_list,none, ERROR(error_cannot_have_input_files_with_file_list,none,
"cannot have input files with file list", ()) "cannot have input files with file list", ())
ERROR(error_cannot_have_primary_files_with_primary_file_list,none,
"cannot have primary input files with primary file list", ())
ERROR(error_duplicate_input_file,none, ERROR(error_duplicate_input_file,none,
"duplicate input file '%0'", (StringRef)) "duplicate input file '%0'", (StringRef))

View File

@@ -27,7 +27,7 @@ def primary_file : Separate<["-"], "primary-file">,
def filelist : Separate<["-"], "filelist">, def filelist : Separate<["-"], "filelist">,
HelpText<"Specify source inputs in a file rather than on the command line">; HelpText<"Specify source inputs in a file rather than on the command line">;
def primary_filelist : Separate<["-"], "primary-filelist">, def primary_filelist : Separate<["-"], "primary-filelist">,
HelpText<"Specify primary inputs in a file in addition to the command line">; HelpText<"Specify primary inputs in a file rather than on the command line">;
def output_filelist : Separate<["-"], "output-filelist">, def output_filelist : Separate<["-"], "output-filelist">,
HelpText<"Specify outputs in a file rather than on the command line">; HelpText<"Specify outputs in a file rather than on the command line">;

View File

@@ -152,6 +152,14 @@ private:
diag::error_cannot_have_input_files_with_file_list); diag::error_cannot_have_input_files_with_file_list);
return true; return true;
} }
// The following is not strictly necessary, but the restriction makes
// it easier to understand a given command line:
if (Args.hasArg(options::OPT_primary_file) && PrimaryFilelistPathArg) {
Diags.diagnose(
SourceLoc(),
diag::error_cannot_have_primary_files_with_primary_file_list);
return true;
}
return false; return false;
} }

View File

@@ -19,6 +19,9 @@
// RUN: not %target-swift-frontend -typecheck -filelist %t/input.txt -primary-filelist %t/primary.txt 2>&1 | %FileCheck -check-prefix=CHECK-PRIMARYNOTFOUND %s // RUN: not %target-swift-frontend -typecheck -filelist %t/input.txt -primary-filelist %t/primary.txt 2>&1 | %FileCheck -check-prefix=CHECK-PRIMARYNOTFOUND %s
// CHECK-PRIMARYNOTFOUND: error: primary file '{{.*}}/../Inputs/empty.swift' was not found in file list '{{.*}}/input.txt' // CHECK-PRIMARYNOTFOUND: error: primary file '{{.*}}/../Inputs/empty.swift' was not found in file list '{{.*}}/input.txt'
// RUN: not %target-swift-frontend -primary-file %s -primary-filelist nonexistent 2>&1 | %FileCheck -check-prefix=CHECK-BADFILEANDFILELIST %s
// CHECK-BADFILEANDFILELIST: error: cannot have primary input files with primary file list
func test() { func test() {
#if !WORKING #if !WORKING