mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user