llvm-project/lldb/source/Interpreter
Pavel Labath 5f56fca4e1 Move option parsing out of the Args class
Summary:
The args class is used in plenty of places (a lot of them in the lower lldb
layers) for representing a list of arguments, and most of these places don't
care about option parsing. Moving the option parsing out of the class removes
the largest external dependency (there are a couple more, but these are in
static functions), and brings us closer to being able to move it to the
Utility module).

The new home for these functions is the Options class, which was already used
as an argument to the parse calls, so this just inverts the dependency between
the two.

The functions are themselves are mainly just copied -- the biggest functional
change I've made to them is to avoid modifying the input Args argument (getopt
likes to permute the argument vector), as it was weird to have another class
reorder the entries in Args class. So now the functions don't modify the input
arguments, and (for those where it makes sense) return a new Args vector
instead. I've also made the addition of a "fake arg0" (required for getopt
compatibility) an implementation detail rather than a part of interface.

While doing that I noticed that ParseForCompletion function was recording the
option indexes in the shuffled vector, but then the consumer was looking up the
entries in the unshuffled one. This manifested itself as us not being able to
complete "watchpoint set variable foo --" (because getopt would move "foo" to
the end). Surprisingly all other completions (e.g. "watchpoint set variable foo
--w") were not affected by this. However, I couldn't find a comprehensive test
for command argument completion, so I consolidated the existing tests and added
a bunch of new ones.

Reviewers: davide, jingham, zturner

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D43837

llvm-svn: 327110
2018-03-09 10:39:40 +00:00
..
Args.cpp Move option parsing out of the Args class 2018-03-09 10:39:40 +00:00
CMakeLists.txt [CMake] Add accurate dependency specifications 2017-01-31 20:43:05 +00:00
CommandAlias.cpp Move option parsing out of the Args class 2018-03-09 10:39:40 +00:00
CommandHistory.cpp Fix !N and !-N commands and add a test case. 2017-04-19 23:21:04 +00:00
CommandInterpreter.cpp Delete some unused #includes of CleanUp.h, NFC 2018-02-23 00:29:40 +00:00
CommandObject.cpp Move option parsing out of the Args class 2018-03-09 10:39:40 +00:00
CommandObjectRegexCommand.cpp Make CommandObject help getters/setters use StringRef. 2016-11-12 20:41:02 +00:00
CommandObjectScript.cpp *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectScript.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandOptionValidators.cpp *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandReturnObject.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionGroupArchitecture.cpp Invert ArchSpec<->Platform dependency 2017-10-31 10:56:03 +00:00
OptionGroupBoolean.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionGroupFile.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionGroupFormat.cpp Move ArchSpec to the Utility module 2017-11-13 16:16:33 +00:00
OptionGroupOutputFile.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionGroupPlatform.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionGroupString.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionGroupUInt64.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionGroupUUID.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionGroupValueObjectDisplay.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionGroupVariable.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionGroupWatchpoint.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValue.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValueArch.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValueArgs.cpp Rewrite all Property related functions in terms of StringRef. 2016-11-17 18:08:12 +00:00
OptionValueArray.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValueBoolean.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValueChar.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValueDictionary.cpp [Interpreter] Remove unused variable usage. NFCI. 2017-11-01 23:46:21 +00:00
OptionValueEnumeration.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValueFileSpec.cpp Make sure DataBufferLLVM contents are writable 2017-12-21 10:54:30 +00:00
OptionValueFileSpecLIst.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValueFormat.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValueFormatEntity.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValueLanguage.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValuePathMappings.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValueProperties.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValueRegex.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValueSInt64.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValueString.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValueUInt64.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
OptionValueUUID.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
Options.cpp Move option parsing out of the Args class 2018-03-09 10:39:40 +00:00
Property.cpp Don't allow direct access to StreamString's internal buffer. 2016-11-16 21:15:24 +00:00
ScriptInterpreter.cpp [Interpreter] Simplify else after return. NFCI. 2017-09-03 19:27:56 +00:00
embedded_interpreter.py *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00