[Driver] Fix --repl argument.

The --repl option was incorrectly defined as "Separate" (option and
value separated by a space). This resulted in the option not being
picked up when no value was specified.

This patch fixes the driver so that `--repl` is recognized again. I
split the option into two:

 - A flag: `--repl` and `-r` which take no arguments.
 - A joined option: `--repl=<flags>` and `-r=<flags>` that forward its
   values to the repl.

This should match the driver's old behavior.

llvm-svn: 349371
This commit is contained in:
Jonas Devlieghere 2018-12-17 18:11:48 +00:00
parent 3ed09eb3f8
commit 7e89627728
2 changed files with 19 additions and 8 deletions

View File

@ -373,13 +373,14 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, bool &exiting) {
} }
} }
if (auto *arg = args.getLastArg(OPT_repl)) { if (args.hasArg(OPT_repl)) {
auto arg_value = arg->getValue();
m_option_data.m_repl = true; m_option_data.m_repl = true;
if (arg_value && arg_value[0]) }
if (auto *arg = args.getLastArg(OPT_repl_)) {
m_option_data.m_repl = true;
if (auto arg_value = arg->getValue())
m_option_data.m_repl_options = arg_value; m_option_data.m_repl_options = arg_value;
else
m_option_data.m_repl_options.clear();
} }
// We need to process the options below together as their relative order // We need to process the options below together as their relative order

View File

@ -46,7 +46,8 @@ def: Flag<["-"], "P">,
HelpText<"Alias for --python-path">, HelpText<"Alias for --python-path">,
Group<grp_scripting>; Group<grp_scripting>;
def script_language: Separate<["--", "-"], "script-language">, MetaVarName<"<language>">, def script_language: Separate<["--", "-"], "script-language">,
MetaVarName<"<language>">,
HelpText<"Tells the debugger to use the specified scripting language for user-defined scripts.">, HelpText<"Tells the debugger to use the specified scripting language for user-defined scripts.">,
Group<grp_scripting>; Group<grp_scripting>;
def: Separate<["-"], "l">, def: Separate<["-"], "l">,
@ -57,13 +58,22 @@ def: Separate<["-"], "l">,
// Repl options. // Repl options.
def grp_repl : OptionGroup<"repl">, HelpText<"REPL">; def grp_repl : OptionGroup<"repl">, HelpText<"REPL">;
def repl: Separate<["--", "-"], "repl">, def repl: Flag<["--", "-"], "repl">,
HelpText<"Runs lldb in REPL mode with a stub process.">, HelpText<"Runs lldb in REPL mode with a stub process.">,
Group<grp_repl>; Group<grp_repl>;
def: Separate<["-"], "r">, def: Flag<["-"], "r">,
Alias<repl>, Alias<repl>,
HelpText<"Alias for --repl">, HelpText<"Alias for --repl">,
Group<grp_repl>; Group<grp_repl>;
def repl_: Joined<["--", "-"], "repl=">,
MetaVarName<"<flags>">,
HelpText<"Runs lldb in REPL mode with a stub process with the given flags.">,
Group<grp_repl>;
def: Joined<["-"], "r=">,
MetaVarName<"<flags>">,
Alias<repl_>,
HelpText<"Alias for --repl=<flags>">,
Group<grp_repl>;
def repl_language: Separate<["--", "-"], "repl-language">, def repl_language: Separate<["--", "-"], "repl-language">,
MetaVarName<"<language>">, MetaVarName<"<language>">,