summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-11-22 17:10:15 +0000
committerZachary Turner <zturner@google.com>2016-11-22 17:10:15 +0000
commitd6a24757876e7c1d29113f41ea241db262d9609c (patch)
tree8bc7a925d2d5bb5cc73b321929e7414f19947577 /lldb/source/Interpreter
parent04dc211e6aa5936caf72297e2c305d2ae23096dd (diff)
downloadbcm5719-llvm-d6a24757876e7c1d29113f41ea241db262d9609c.tar.gz
bcm5719-llvm-d6a24757876e7c1d29113f41ea241db262d9609c.zip
Re-add "demonstrate new Args API"
This fixes the build breakage due to the use of C++14. llvm-svn: 287647
Diffstat (limited to 'lldb/source/Interpreter')
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp7
-rw-r--r--lldb/source/Interpreter/OptionValueDictionary.cpp121
2 files changed, 64 insertions, 64 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 251f591ec9c..36651519eb9 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1859,9 +1859,8 @@ int CommandInterpreter::HandleCompletion(
// put an empty string in element 0.
std::string command_partial_str;
if (cursor_index >= 0)
- command_partial_str.assign(parsed_line.GetArgumentAtIndex(cursor_index),
- parsed_line.GetArgumentAtIndex(cursor_index) +
- cursor_char_position);
+ command_partial_str =
+ parsed_line[cursor_index].ref.take_front(cursor_char_position);
std::string common_prefix;
matches.LongestCommonPrefix(common_prefix);
@@ -1872,7 +1871,7 @@ int CommandInterpreter::HandleCompletion(
// Only do this if the completer told us this was a complete word,
// however...
if (num_command_matches == 1 && word_complete) {
- char quote_char = parsed_line.GetArgumentQuoteCharAtIndex(cursor_index);
+ char quote_char = parsed_line[cursor_index].quote;
common_prefix =
Args::EscapeLLDBCommandArgument(common_prefix, quote_char);
if (quote_char != '\0')
diff --git a/lldb/source/Interpreter/OptionValueDictionary.cpp b/lldb/source/Interpreter/OptionValueDictionary.cpp
index ea18b941ab1..dfba435603b 100644
--- a/lldb/source/Interpreter/OptionValueDictionary.cpp
+++ b/lldb/source/Interpreter/OptionValueDictionary.cpp
@@ -101,73 +101,74 @@ Error OptionValueDictionary::SetArgs(const Args &args, VarSetOperationType op) {
case eVarSetOperationAppend:
case eVarSetOperationReplace:
case eVarSetOperationAssign:
- if (argc > 0) {
- for (size_t i = 0; i < argc; ++i) {
- llvm::StringRef key_and_value(args.GetArgumentAtIndex(i));
- if (!key_and_value.empty()) {
- if (key_and_value.find('=') == llvm::StringRef::npos) {
- error.SetErrorString(
- "assign operation takes one or more key=value arguments");
- return error;
- }
+ if (argc == 0) {
+ error.SetErrorString(
+ "assign operation takes one or more key=value arguments");
+ return error;
+ }
+ for (const auto &entry : args) {
+ if (entry.ref.empty()) {
+ error.SetErrorString("empty argument");
+ return error;
+ }
+ if (!entry.ref.contains('=')) {
+ error.SetErrorString(
+ "assign operation takes one or more key=value arguments");
+ return error;
+ }
+
+ llvm::StringRef key, value;
+ std::tie(key, value) = entry.ref.split('=');
+ bool key_valid = false;
+ if (key.empty()) {
+ error.SetErrorString("empty dictionary key");
+ return error;
+ }
- std::pair<llvm::StringRef, llvm::StringRef> kvp(
- key_and_value.split('='));
- llvm::StringRef key = kvp.first;
- bool key_valid = false;
- if (!key.empty()) {
- if (key.front() == '[') {
- // Key name starts with '[', so the key value must be in single or
- // double quotes like:
- // ['<key>']
- // ["<key>"]
- if ((key.size() > 2) && (key.back() == ']')) {
- // Strip leading '[' and trailing ']'
- key = key.substr(1, key.size() - 2);
- const char quote_char = key.front();
- if ((quote_char == '\'') || (quote_char == '"')) {
- if ((key.size() > 2) && (key.back() == quote_char)) {
- // Strip the quotes
- key = key.substr(1, key.size() - 2);
- key_valid = true;
- }
- } else {
- // square brackets, no quotes
- key_valid = true;
- }
- }
- } else {
- // No square brackets or quotes
+ if (key.front() == '[') {
+ // Key name starts with '[', so the key value must be in single or
+ // double quotes like:
+ // ['<key>']
+ // ["<key>"]
+ if ((key.size() > 2) && (key.back() == ']')) {
+ // Strip leading '[' and trailing ']'
+ key = key.substr(1, key.size() - 2);
+ const char quote_char = key.front();
+ if ((quote_char == '\'') || (quote_char == '"')) {
+ if ((key.size() > 2) && (key.back() == quote_char)) {
+ // Strip the quotes
+ key = key.substr(1, key.size() - 2);
key_valid = true;
}
- }
- if (!key_valid) {
- error.SetErrorStringWithFormat(
- "invalid key \"%s\", the key must be a bare string or "
- "surrounded by brackets with optional quotes: [<key>] or "
- "['<key>'] or [\"<key>\"]",
- kvp.first.str().c_str());
- return error;
- }
-
- lldb::OptionValueSP value_sp(CreateValueFromCStringForTypeMask(
- kvp.second.data(), m_type_mask, error));
- if (value_sp) {
- if (error.Fail())
- return error;
- m_value_was_set = true;
- SetValueForKey(ConstString(key), value_sp, true);
} else {
- error.SetErrorString("dictionaries that can contain multiple types "
- "must subclass OptionValueArray");
+ // square brackets, no quotes
+ key_valid = true;
}
- } else {
- error.SetErrorString("empty argument");
}
+ } else {
+ // No square brackets or quotes
+ key_valid = true;
+ }
+ if (!key_valid) {
+ error.SetErrorStringWithFormat(
+ "invalid key \"%s\", the key must be a bare string or "
+ "surrounded by brackets with optional quotes: [<key>] or "
+ "['<key>'] or [\"<key>\"]",
+ key.str().c_str());
+ return error;
+ }
+
+ lldb::OptionValueSP value_sp(CreateValueFromCStringForTypeMask(
+ value.str().c_str(), m_type_mask, error));
+ if (value_sp) {
+ if (error.Fail())
+ return error;
+ m_value_was_set = true;
+ SetValueForKey(ConstString(key), value_sp, true);
+ } else {
+ error.SetErrorString("dictionaries that can contain multiple types "
+ "must subclass OptionValueArray");
}
- } else {
- error.SetErrorString(
- "assign operation takes one or more key=value arguments");
}
break;
OpenPOWER on IntegriCloud