Fix argv when using -i in the frontend

In the frontend, only arguments after '--' will be passed as arguments
to the new process.  Also, add the input filename as argv[0], to follow
the usual conventions.

Still to come is fixing swift -i from the driver.

Swift SVN r19690
This commit is contained in:
Ben Langmuir
2014-07-08 19:38:29 +00:00
parent 9e2b68c4f9
commit f6645eb39a
3 changed files with 31 additions and 11 deletions

View File

@@ -123,12 +123,6 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
Opts.ParseStdlib |= Args.hasArg(OPT_parse_stdlib);
if (const Arg *A = Args.getLastArg(OPT__DASH_DASH)) {
for (unsigned i = 0, e = A->getNumValues(); i != e; ++i) {
Opts.ImmediateArgv.push_back(A->getValue(i));
}
}
// Determine what the user has asked the frontend to do.
FrontendOptions::ActionType Action;
if (const Arg *A = Args.getLastArg(OPT_modes_Group)) {
@@ -208,6 +202,16 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
}
}
if (Opts.RequestedAction == FrontendOptions::Immediate) {
assert(!Opts.InputFilenames.empty());
Opts.ImmediateArgv.push_back(Opts.InputFilenames[0]); // argv[0]
if (const Arg *A = Args.getLastArg(OPT__DASH_DASH)) {
for (unsigned i = 0, e = A->getNumValues(); i != e; ++i) {
Opts.ImmediateArgv.push_back(A->getValue(i));
}
}
}
if (TreatAsSIL)
Opts.InputKind = SourceFileKind::SIL;
else if (Args.hasArg(OPT_parse_as_library))