Index: include/lldb/Interpreter/OptionValue.h =================================================================== --- include/lldb/Interpreter/OptionValue.h +++ include/lldb/Interpreter/OptionValue.h @@ -106,7 +106,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) = 0; virtual Error - SetValueFromCString (const char *value, VarSetOperationType op = eVarSetOperationAssign); + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Clear () = 0; Index: include/lldb/Interpreter/OptionValueArch.h =================================================================== --- include/lldb/Interpreter/OptionValueArch.h +++ include/lldb/Interpreter/OptionValueArch.h @@ -71,7 +71,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Index: include/lldb/Interpreter/OptionValueArray.h =================================================================== --- include/lldb/Interpreter/OptionValueArray.h +++ include/lldb/Interpreter/OptionValueArray.h @@ -49,7 +49,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Index: include/lldb/Interpreter/OptionValueBoolean.h =================================================================== --- include/lldb/Interpreter/OptionValueBoolean.h +++ include/lldb/Interpreter/OptionValueBoolean.h @@ -54,7 +54,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Index: include/lldb/Interpreter/OptionValueChar.h =================================================================== --- include/lldb/Interpreter/OptionValueChar.h +++ include/lldb/Interpreter/OptionValueChar.h @@ -54,7 +54,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Index: include/lldb/Interpreter/OptionValueDictionary.h =================================================================== --- include/lldb/Interpreter/OptionValueDictionary.h +++ include/lldb/Interpreter/OptionValueDictionary.h @@ -50,7 +50,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Index: include/lldb/Interpreter/OptionValueEnumeration.h =================================================================== --- include/lldb/Interpreter/OptionValueEnumeration.h +++ include/lldb/Interpreter/OptionValueEnumeration.h @@ -55,7 +55,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Index: include/lldb/Interpreter/OptionValueFileSpec.h =================================================================== --- include/lldb/Interpreter/OptionValueFileSpec.h +++ include/lldb/Interpreter/OptionValueFileSpec.h @@ -48,7 +48,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Index: include/lldb/Interpreter/OptionValueFileSpecList.h =================================================================== --- include/lldb/Interpreter/OptionValueFileSpecList.h +++ include/lldb/Interpreter/OptionValueFileSpecList.h @@ -54,7 +54,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Index: include/lldb/Interpreter/OptionValueFormat.h =================================================================== --- include/lldb/Interpreter/OptionValueFormat.h +++ include/lldb/Interpreter/OptionValueFormat.h @@ -55,7 +55,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Index: include/lldb/Interpreter/OptionValueFormatEntity.h =================================================================== --- include/lldb/Interpreter/OptionValueFormatEntity.h +++ include/lldb/Interpreter/OptionValueFormatEntity.h @@ -43,7 +43,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override; Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign) override; bool Index: include/lldb/Interpreter/OptionValuePathMappings.h =================================================================== --- include/lldb/Interpreter/OptionValuePathMappings.h +++ include/lldb/Interpreter/OptionValuePathMappings.h @@ -48,7 +48,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Index: include/lldb/Interpreter/OptionValueProperties.h =================================================================== --- include/lldb/Interpreter/OptionValueProperties.h +++ include/lldb/Interpreter/OptionValueProperties.h @@ -61,7 +61,7 @@ DeepCopy () const; virtual Error - SetValueFromCString (const char *value, VarSetOperationType op = eVarSetOperationAssign); + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual void DumpValue (const ExecutionContext *exe_ctx, Index: include/lldb/Interpreter/OptionValueRegex.h =================================================================== --- include/lldb/Interpreter/OptionValueRegex.h +++ include/lldb/Interpreter/OptionValueRegex.h @@ -49,7 +49,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Index: include/lldb/Interpreter/OptionValueSInt64.h =================================================================== --- include/lldb/Interpreter/OptionValueSInt64.h +++ include/lldb/Interpreter/OptionValueSInt64.h @@ -77,7 +77,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Index: include/lldb/Interpreter/OptionValueString.h =================================================================== --- include/lldb/Interpreter/OptionValueString.h +++ include/lldb/Interpreter/OptionValueString.h @@ -137,7 +137,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Index: include/lldb/Interpreter/OptionValueUInt64.h =================================================================== --- include/lldb/Interpreter/OptionValueUInt64.h +++ include/lldb/Interpreter/OptionValueUInt64.h @@ -70,7 +70,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Index: include/lldb/Interpreter/OptionValueUUID.h =================================================================== --- include/lldb/Interpreter/OptionValueUUID.h +++ include/lldb/Interpreter/OptionValueUUID.h @@ -53,7 +53,7 @@ DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Index: source/Commands/CommandObjectBreakpoint.cpp =================================================================== --- source/Commands/CommandObjectBreakpoint.cpp +++ source/Commands/CommandObjectBreakpoint.cpp @@ -1950,15 +1950,15 @@ { case 'N': if (BreakpointID::StringIsBreakpointName(option_value, error) && error.Success()) - m_name.SetValueFromCString(option_value); + m_name.SetValueFromString(option_value); break; case 'B': - if (m_breakpoint.SetValueFromCString(option_value).Fail()) + if (m_breakpoint.SetValueFromString(option_value).Fail()) error.SetErrorStringWithFormat ("unrecognized value \"%s\" for breakpoint", option_value); break; case 'D': - if (m_use_dummy.SetValueFromCString(option_value).Fail()) + if (m_use_dummy.SetValueFromString(option_value).Fail()) error.SetErrorStringWithFormat ("unrecognized value \"%s\" for use-dummy", option_value); break; Index: source/Commands/CommandObjectCommands.cpp =================================================================== --- source/Commands/CommandObjectCommands.cpp +++ source/Commands/CommandObjectCommands.cpp @@ -85,7 +85,7 @@ switch (short_option) { case 'c': - error = m_count.SetValueFromCString(option_arg,eVarSetOperationAssign); + error = m_count.SetValueFromString(option_arg,eVarSetOperationAssign); break; case 's': if (option_arg && strcmp("end", option_arg) == 0) @@ -94,10 +94,10 @@ m_start_idx.SetOptionWasSet(); } else - error = m_start_idx.SetValueFromCString(option_arg,eVarSetOperationAssign); + error = m_start_idx.SetValueFromString(option_arg,eVarSetOperationAssign); break; case 'e': - error = m_stop_idx.SetValueFromCString(option_arg,eVarSetOperationAssign); + error = m_stop_idx.SetValueFromString(option_arg,eVarSetOperationAssign); break; case 'C': m_clear.SetCurrentValue(true); @@ -326,15 +326,15 @@ switch (short_option) { case 'e': - error = m_stop_on_error.SetValueFromCString(option_arg); + error = m_stop_on_error.SetValueFromString(option_arg); break; case 'c': - error = m_stop_on_continue.SetValueFromCString(option_arg); + error = m_stop_on_continue.SetValueFromString(option_arg); break; case 's': - error = m_silent_run.SetValueFromCString(option_arg); + error = m_silent_run.SetValueFromString(option_arg); break; default: Index: source/Commands/CommandObjectMemory.cpp =================================================================== --- source/Commands/CommandObjectMemory.cpp +++ source/Commands/CommandObjectMemory.cpp @@ -95,7 +95,7 @@ switch (short_option) { case 'l': - error = m_num_per_line.SetValueFromCString (option_arg); + error = m_num_per_line.SetValueFromString (option_arg); if (m_num_per_line.GetCurrentValue() == 0) error.SetErrorStringWithFormat("invalid value for --num-per-line option '%s'", option_arg); break; @@ -105,7 +105,7 @@ break; case 't': - error = m_view_as_type.SetValueFromCString (option_arg); + error = m_view_as_type.SetValueFromString (option_arg); break; case 'r': @@ -981,20 +981,20 @@ switch (short_option) { case 'e': - m_expr.SetValueFromCString(option_arg); + m_expr.SetValueFromString(option_arg); break; case 's': - m_string.SetValueFromCString(option_arg); + m_string.SetValueFromString(option_arg); break; case 'c': - if (m_count.SetValueFromCString(option_arg).Fail()) + if (m_count.SetValueFromString(option_arg).Fail()) error.SetErrorString("unrecognized value for count"); break; case 'o': - if (m_offset.SetValueFromCString(option_arg).Fail()) + if (m_offset.SetValueFromString(option_arg).Fail()) error.SetErrorString("unrecognized value for dump-offset"); break; Index: source/Core/Disassembler.cpp =================================================================== --- source/Core/Disassembler.cpp +++ source/Core/Disassembler.cpp @@ -726,7 +726,7 @@ { case OptionValue::eTypeUInt64: data_value_sp.reset (new OptionValueUInt64 (0, 0)); - data_value_sp->SetValueFromCString (value.c_str()); + data_value_sp->SetValueFromString (value); break; // Other types can be added later as needed. default: @@ -834,7 +834,7 @@ else if ((value[0] == '0') && (value[1] == 'x')) { value_sp.reset (new OptionValueUInt64 (0, 0)); - value_sp->SetValueFromCString (value.c_str()); + value_sp->SetValueFromString (value); } else { Index: source/Interpreter/OptionGroupBoolean.cpp =================================================================== --- source/Interpreter/OptionGroupBoolean.cpp +++ source/Interpreter/OptionGroupBoolean.cpp @@ -56,7 +56,7 @@ } else { - error = m_value.SetValueFromCString (option_arg); + error = m_value.SetValueFromString (option_arg); } return error; } Index: source/Interpreter/OptionGroupFile.cpp =================================================================== --- source/Interpreter/OptionGroupFile.cpp +++ source/Interpreter/OptionGroupFile.cpp @@ -47,7 +47,7 @@ uint32_t option_idx, const char *option_arg) { - Error error (m_file.SetValueFromCString (option_arg)); + Error error (m_file.SetValueFromString (option_arg)); return error; } @@ -88,7 +88,7 @@ uint32_t option_idx, const char *option_arg) { - Error error (m_file_list.SetValueFromCString (option_arg)); + Error error (m_file_list.SetValueFromString (option_arg)); return error; } Index: source/Interpreter/OptionGroupFormat.cpp =================================================================== --- source/Interpreter/OptionGroupFormat.cpp +++ source/Interpreter/OptionGroupFormat.cpp @@ -78,7 +78,7 @@ switch (short_option) { case 'f': - error = m_format.SetValueFromCString (option_arg); + error = m_format.SetValueFromString (option_arg); break; case 'c': @@ -88,7 +88,7 @@ } else { - error = m_count.SetValueFromCString (option_arg); + error = m_count.SetValueFromString (option_arg); if (m_count.GetCurrentValue() == 0) error.SetErrorStringWithFormat("invalid --count option value '%s'", option_arg); } @@ -101,7 +101,7 @@ } else { - error = m_byte_size.SetValueFromCString (option_arg); + error = m_byte_size.SetValueFromString (option_arg); if (m_byte_size.GetCurrentValue() == 0) error.SetErrorStringWithFormat("invalid --size option value '%s'", option_arg); } Index: source/Interpreter/OptionGroupOutputFile.cpp =================================================================== --- source/Interpreter/OptionGroupOutputFile.cpp +++ source/Interpreter/OptionGroupOutputFile.cpp @@ -62,7 +62,7 @@ switch (short_option) { case 'o': - error = m_file.SetValueFromCString (option_arg); + error = m_file.SetValueFromString (option_arg); break; case SHORT_OPTION_APND: Index: source/Interpreter/OptionGroupString.cpp =================================================================== --- source/Interpreter/OptionGroupString.cpp +++ source/Interpreter/OptionGroupString.cpp @@ -48,7 +48,7 @@ uint32_t option_idx, const char *option_arg) { - Error error (m_value.SetValueFromCString (option_arg)); + Error error (m_value.SetValueFromString (option_arg)); return error; } Index: source/Interpreter/OptionGroupUInt64.cpp =================================================================== --- source/Interpreter/OptionGroupUInt64.cpp +++ source/Interpreter/OptionGroupUInt64.cpp @@ -48,7 +48,7 @@ uint32_t option_idx, const char *option_arg) { - Error error (m_value.SetValueFromCString (option_arg)); + Error error (m_value.SetValueFromString (option_arg)); return error; } Index: source/Interpreter/OptionGroupUUID.cpp =================================================================== --- source/Interpreter/OptionGroupUUID.cpp +++ source/Interpreter/OptionGroupUUID.cpp @@ -56,7 +56,7 @@ switch (short_option) { case 'u': - error = m_uuid.SetValueFromCString (option_arg); + error = m_uuid.SetValueFromString (option_arg); if (error.Success()) m_uuid.SetOptionWasSet(); break; Index: source/Interpreter/OptionValue.cpp =================================================================== --- source/Interpreter/OptionValue.cpp +++ source/Interpreter/OptionValue.cpp @@ -622,7 +622,7 @@ } if (value_sp) - error = value_sp->SetValueFromCString (value_cstr, eVarSetOperationAssign); + error = value_sp->SetValueFromString (value_cstr, eVarSetOperationAssign); else error.SetErrorString("unsupported type mask"); return value_sp; @@ -664,7 +664,7 @@ } Error -OptionValue::SetValueFromCString (const char *value, VarSetOperationType op) +OptionValue::SetValueFromString (llvm::StringRef value, VarSetOperationType op) { Error error; switch (op) Index: source/Interpreter/OptionValueArch.cpp =================================================================== --- source/Interpreter/OptionValueArch.cpp +++ source/Interpreter/OptionValueArch.cpp @@ -43,7 +43,7 @@ } Error -OptionValueArch::SetValueFromCString (const char *value_cstr, VarSetOperationType op) +OptionValueArch::SetValueFromString (llvm::StringRef value, VarSetOperationType op) { Error error; switch (op) @@ -55,30 +55,23 @@ case eVarSetOperationReplace: case eVarSetOperationAssign: - if (value_cstr) { - std::string value = llvm::StringRef(value_cstr).trim().str(); - value_cstr = value.c_str(); - if (m_current_value.SetTriple (value_cstr)) + std::string value_str = value.trim().str(); + if (m_current_value.SetTriple (value_str.c_str())) { m_value_was_set = true; NotifyValueChanged(); } else - error.SetErrorStringWithFormat("unsupported architecture '%s'", value_cstr); + error.SetErrorStringWithFormat("unsupported architecture '%s'", value_str.c_str()); + break; } - else - { - error.SetErrorString("invalid value string"); - } - break; - case eVarSetOperationInsertBefore: case eVarSetOperationInsertAfter: case eVarSetOperationRemove: case eVarSetOperationAppend: case eVarSetOperationInvalid: - error = OptionValue::SetValueFromCString (value_cstr, op); + error = OptionValue::SetValueFromString (value, op); break; } return error; Index: source/Interpreter/OptionValueArray.cpp =================================================================== --- source/Interpreter/OptionValueArray.cpp +++ source/Interpreter/OptionValueArray.cpp @@ -74,9 +74,9 @@ } Error -OptionValueArray::SetValueFromCString (const char *value, VarSetOperationType op) +OptionValueArray::SetValueFromString (llvm::StringRef value, VarSetOperationType op) { - Args args(value); + Args args(value.str().c_str()); Error error = SetArgs (args, op); if (error.Success()) NotifyValueChanged(); Index: source/Interpreter/OptionValueBoolean.cpp =================================================================== --- source/Interpreter/OptionValueBoolean.cpp +++ source/Interpreter/OptionValueBoolean.cpp @@ -37,7 +37,7 @@ } Error -OptionValueBoolean::SetValueFromCString (const char *value_cstr, +OptionValueBoolean::SetValueFromString (llvm::StringRef value_str, VarSetOperationType op) { Error error; @@ -52,7 +52,7 @@ case eVarSetOperationAssign: { bool success = false; - bool value = Args::StringToBoolean(value_cstr, false, &success); + bool value = Args::StringToBoolean(value_str.str().c_str(), false, &success); if (success) { m_value_was_set = true; @@ -61,12 +61,11 @@ } else { - if (value_cstr == nullptr) - error.SetErrorString ("invalid boolean string value: NULL"); - else if (value_cstr[0] == '\0') + if (value_str.size() == 0) error.SetErrorString ("invalid boolean string value "); else - error.SetErrorStringWithFormat ("invalid boolean string value: '%s'", value_cstr); + error.SetErrorStringWithFormat ("invalid boolean string value: '%s'", + value_str.str().c_str()); } } break; @@ -76,7 +75,7 @@ case eVarSetOperationRemove: case eVarSetOperationAppend: case eVarSetOperationInvalid: - error = OptionValue::SetValueFromCString (value_cstr, op); + error = OptionValue::SetValueFromString (value_str, op); break; } return error; Index: source/Interpreter/OptionValueChar.cpp =================================================================== --- source/Interpreter/OptionValueChar.cpp +++ source/Interpreter/OptionValueChar.cpp @@ -39,7 +39,7 @@ } Error -OptionValueChar::SetValueFromCString (const char *value_cstr, +OptionValueChar::SetValueFromString (llvm::StringRef value, VarSetOperationType op) { Error error; @@ -53,19 +53,19 @@ case eVarSetOperationAssign: { bool success = false; - char char_value = Args::StringToChar(value_cstr, '\0', &success); + char char_value = Args::StringToChar(value.str().c_str(), '\0', &success); if (success) { m_current_value = char_value; m_value_was_set = true; } else - error.SetErrorStringWithFormat("'%s' cannot be longer than 1 character", value_cstr); + error.SetErrorStringWithFormat("'%s' cannot be longer than 1 character", value.str().c_str()); } break; default: - error = OptionValue::SetValueFromCString (value_cstr, op); + error = OptionValue::SetValueFromString (value.str().c_str(), op); break; } return error; Index: source/Interpreter/OptionValueDictionary.cpp =================================================================== --- source/Interpreter/OptionValueDictionary.cpp +++ source/Interpreter/OptionValueDictionary.cpp @@ -211,16 +211,16 @@ case eVarSetOperationInsertBefore: case eVarSetOperationInsertAfter: case eVarSetOperationInvalid: - error = OptionValue::SetValueFromCString (nullptr, op); + error = OptionValue::SetValueFromString (llvm::StringRef(), op); break; } return error; } Error -OptionValueDictionary::SetValueFromCString (const char *value_cstr, VarSetOperationType op) +OptionValueDictionary::SetValueFromString (llvm::StringRef value, VarSetOperationType op) { - Args args(value_cstr); + Args args(value.str().c_str()); Error error = SetArgs (args, op); if (error.Success()) NotifyValueChanged(); @@ -335,7 +335,7 @@ const bool will_modify = true; lldb::OptionValueSP value_sp (GetSubValue (exe_ctx, name, will_modify, error)); if (value_sp) - error = value_sp->SetValueFromCString(value, op); + error = value_sp->SetValueFromString(value, op); else { if (error.AsCString() == nullptr) @@ -381,7 +381,7 @@ return false; if (pos->second->GetType() == OptionValue::eTypeString) { - pos->second->SetValueFromCString(value); + pos->second->SetValueFromString(value); return true; } } Index: source/Interpreter/OptionValueEnumeration.cpp =================================================================== --- source/Interpreter/OptionValueEnumeration.cpp +++ source/Interpreter/OptionValueEnumeration.cpp @@ -55,7 +55,7 @@ } Error -OptionValueEnumeration::SetValueFromCString (const char *value, VarSetOperationType op) +OptionValueEnumeration::SetValueFromString (llvm::StringRef value, VarSetOperationType op) { Error error; switch (op) @@ -67,9 +67,8 @@ case eVarSetOperationReplace: case eVarSetOperationAssign: - if (value && value[0]) { - ConstString const_enumerator_name(llvm::StringRef(value).trim()); + ConstString const_enumerator_name(value.trim()); const EnumerationMapEntry *enumerator_entry = m_enumerations.FindFirstValueForName (const_enumerator_name.GetCString()); if (enumerator_entry) { @@ -79,7 +78,7 @@ else { StreamString error_strm; - error_strm.Printf("invalid enumeration value '%s'", value); + error_strm.Printf("invalid enumeration value '%s'", value.str().c_str()); const size_t count = m_enumerations.GetSize (); if (count) { @@ -91,19 +90,15 @@ } error.SetErrorString(error_strm.GetData()); } + break; } - else - { - error.SetErrorString("invalid enumeration value"); - } - break; case eVarSetOperationInsertBefore: case eVarSetOperationInsertAfter: case eVarSetOperationRemove: case eVarSetOperationAppend: case eVarSetOperationInvalid: - error = OptionValue::SetValueFromCString (value, op); + error = OptionValue::SetValueFromString (value, op); break; } return error; Index: source/Interpreter/OptionValueFileSpec.cpp =================================================================== --- source/Interpreter/OptionValueFileSpec.cpp +++ source/Interpreter/OptionValueFileSpec.cpp @@ -70,7 +70,7 @@ } Error -OptionValueFileSpec::SetValueFromCString (const char *value_cstr, +OptionValueFileSpec::SetValueFromString (llvm::StringRef value, VarSetOperationType op) { Error error; @@ -83,23 +83,16 @@ case eVarSetOperationReplace: case eVarSetOperationAssign: - if (value_cstr && value_cstr[0]) + if (value.size() > 0) { // The setting value may have whitespace, double-quotes, or single-quotes around the file // path to indicate that internal spaces are not word breaks. Strip off any ws & quotes // from the start and end of the file path - we aren't doing any word // breaking here so // the quoting is unnecessary. NB this will cause a problem if someone tries to specify // a file path that legitimately begins or ends with a " or ' character, or whitespace. - std::string filepath(value_cstr); - auto prefix_chars_to_trim = filepath.find_first_not_of ("\"' \t"); - if (prefix_chars_to_trim != std::string::npos && prefix_chars_to_trim > 0) - filepath.erase(0, prefix_chars_to_trim); - auto suffix_chars_to_trim = filepath.find_last_not_of ("\"' \t"); - if (suffix_chars_to_trim != std::string::npos && suffix_chars_to_trim < filepath.size()) - filepath.erase (suffix_chars_to_trim + 1); - + value = value.trim("\"' \t"); m_value_was_set = true; - m_current_value.SetFile(filepath.c_str(), true); + m_current_value.SetFile(value.str().c_str(), true); m_data_sp.reset(); NotifyValueChanged(); } @@ -114,7 +107,7 @@ case eVarSetOperationRemove: case eVarSetOperationAppend: case eVarSetOperationInvalid: - error = OptionValue::SetValueFromCString (value_cstr, op); + error = OptionValue::SetValueFromString (value, op); break; } return error; Index: source/Interpreter/OptionValueFileSpecLIst.cpp =================================================================== --- source/Interpreter/OptionValueFileSpecLIst.cpp +++ source/Interpreter/OptionValueFileSpecLIst.cpp @@ -42,10 +42,10 @@ } Error -OptionValueFileSpecList::SetValueFromCString (const char *value, VarSetOperationType op) +OptionValueFileSpecList::SetValueFromString (llvm::StringRef value, VarSetOperationType op) { Error error; - Args args(value); + Args args(value.str().c_str()); const size_t argc = args.GetArgumentCount(); switch (op) @@ -174,7 +174,7 @@ break; case eVarSetOperationInvalid: - error = OptionValue::SetValueFromCString (value, op); + error = OptionValue::SetValueFromString (value, op); break; } return error; Index: source/Interpreter/OptionValueFormat.cpp =================================================================== --- source/Interpreter/OptionValueFormat.cpp +++ source/Interpreter/OptionValueFormat.cpp @@ -36,7 +36,7 @@ } Error -OptionValueFormat::SetValueFromCString (const char *value_cstr, VarSetOperationType op) +OptionValueFormat::SetValueFromString (llvm::StringRef value, VarSetOperationType op) { Error error; switch (op) @@ -50,7 +50,7 @@ case eVarSetOperationAssign: { Format new_format; - error = Args::StringToFormat (value_cstr, new_format, nullptr); + error = Args::StringToFormat (value.str().c_str(), new_format, nullptr); if (error.Success()) { m_value_was_set = true; @@ -65,7 +65,7 @@ case eVarSetOperationRemove: case eVarSetOperationAppend: case eVarSetOperationInvalid: - error = OptionValue::SetValueFromCString (value_cstr, op); + error = OptionValue::SetValueFromString (value, op); break; } return error; Index: source/Interpreter/OptionValueFormatEntity.cpp =================================================================== --- source/Interpreter/OptionValueFormatEntity.cpp +++ source/Interpreter/OptionValueFormatEntity.cpp @@ -67,7 +67,7 @@ } Error -OptionValueFormatEntity::SetValueFromCString (const char *value_cstr, +OptionValueFormatEntity::SetValueFromString (llvm::StringRef value_str, VarSetOperationType op) { Error error; @@ -82,12 +82,11 @@ case eVarSetOperationAssign: { FormatEntity::Entry entry; - llvm::StringRef value_str(value_cstr); error = FormatEntity::Parse(value_str, entry); if (error.Success()) { m_current_entry = std::move(entry); - m_current_format = value_cstr; + m_current_format = value_str; m_value_was_set = true; NotifyValueChanged(); } @@ -99,7 +98,7 @@ case eVarSetOperationRemove: case eVarSetOperationAppend: case eVarSetOperationInvalid: - error = OptionValue::SetValueFromCString (value_cstr, op); + error = OptionValue::SetValueFromString (value_str, op); break; } return error; Index: source/Interpreter/OptionValuePathMappings.cpp =================================================================== --- source/Interpreter/OptionValuePathMappings.cpp +++ source/Interpreter/OptionValuePathMappings.cpp @@ -34,10 +34,10 @@ } Error -OptionValuePathMappings::SetValueFromCString (const char *value, VarSetOperationType op) +OptionValuePathMappings::SetValueFromString (llvm::StringRef value, VarSetOperationType op) { Error error; - Args args(value); + Args args(value.str().c_str()); const size_t argc = args.GetArgumentCount(); switch (op) @@ -175,7 +175,7 @@ break; case eVarSetOperationInvalid: - error = OptionValue::SetValueFromCString (value, op); + error = OptionValue::SetValueFromString (value, op); break; } return error; Index: source/Interpreter/OptionValueProperties.cpp =================================================================== --- source/Interpreter/OptionValueProperties.cpp +++ source/Interpreter/OptionValueProperties.cpp @@ -226,7 +226,7 @@ const bool will_modify = true; lldb::OptionValueSP value_sp (GetSubValue (exe_ctx, name, will_modify, error)); if (value_sp) - error = value_sp->SetValueFromCString(value, op); + error = value_sp->SetValueFromString(value ? llvm::StringRef(value) : llvm::StringRef(), op); else { if (error.AsCString() == nullptr) @@ -600,7 +600,7 @@ Error -OptionValueProperties::SetValueFromCString (const char *value, VarSetOperationType op) +OptionValueProperties::SetValueFromString (llvm::StringRef value, VarSetOperationType op) { Error error; @@ -619,7 +619,7 @@ case eVarSetOperationInsertAfter: case eVarSetOperationAppend: case eVarSetOperationInvalid: - error = OptionValue::SetValueFromCString (value, op); + error = OptionValue::SetValueFromString (value, op); break; } Index: source/Interpreter/OptionValueRegex.cpp =================================================================== --- source/Interpreter/OptionValueRegex.cpp +++ source/Interpreter/OptionValueRegex.cpp @@ -41,7 +41,7 @@ } Error -OptionValueRegex::SetValueFromCString (const char *value_cstr, +OptionValueRegex::SetValueFromString (llvm::StringRef value, VarSetOperationType op) { Error error; @@ -52,7 +52,7 @@ case eVarSetOperationInsertAfter: case eVarSetOperationRemove: case eVarSetOperationAppend: - error = OptionValue::SetValueFromCString (value_cstr, op); + error = OptionValue::SetValueFromString (value, op); break; case eVarSetOperationClear: @@ -62,7 +62,7 @@ case eVarSetOperationReplace: case eVarSetOperationAssign: - if (m_regex.Compile (value_cstr)) + if (m_regex.Compile (value.str().c_str())) { m_value_was_set = true; NotifyValueChanged(); Index: source/Interpreter/OptionValueSInt64.cpp =================================================================== --- source/Interpreter/OptionValueSInt64.cpp +++ source/Interpreter/OptionValueSInt64.cpp @@ -36,9 +36,8 @@ } Error -OptionValueSInt64::SetValueFromCString (const char *value_cstr, VarSetOperationType op) +OptionValueSInt64::SetValueFromString (llvm::StringRef value_ref, VarSetOperationType op) { - //printf ("%p: SetValueFromCString (s=\"%s\", op=%i)\n", this, value_cstr, op); Error error; switch (op) { @@ -51,7 +50,7 @@ case eVarSetOperationAssign: { bool success = false; - std::string value_str = llvm::StringRef(value_cstr).trim().str(); + std::string value_str = value_ref.trim().str(); int64_t value = StringConvert::ToSInt64 (value_str.c_str(), 0, 0, &success); if (success) { @@ -69,7 +68,8 @@ } else { - error.SetErrorStringWithFormat ("invalid int64_t string value: '%s'", value_cstr); + error.SetErrorStringWithFormat ("invalid int64_t string value: '%s'", + value_ref.str().c_str()); } } break; @@ -79,7 +79,7 @@ case eVarSetOperationRemove: case eVarSetOperationAppend: case eVarSetOperationInvalid: - error = OptionValue::SetValueFromCString (value_cstr, op); + error = OptionValue::SetValueFromString (value_ref, op); break; } return error; Index: source/Interpreter/OptionValueString.cpp =================================================================== --- source/Interpreter/OptionValueString.cpp +++ source/Interpreter/OptionValueString.cpp @@ -51,31 +51,30 @@ } Error -OptionValueString::SetValueFromCString (const char *value_cstr, +OptionValueString::SetValueFromString (llvm::StringRef value, VarSetOperationType op) { Error error; - std::string value_str_no_quotes; - llvm::StringRef trimmed = value_cstr ? llvm::StringRef(value_cstr).trim() : llvm::StringRef(); - if (trimmed.size() > 0) + std::string value_str = value.str(); + value = value.trim(); + if (value.size() > 0) { - switch (trimmed.front()) + switch (value.front()) { case '"': case '\'': { - if (trimmed.size() <= 1 || trimmed.back() != trimmed.front()) + if (value.size() <= 1 || value.back() != value.front()) { error.SetErrorString("mismatched quotes"); return error; } - trimmed = trimmed.drop_front().drop_back().str(); + value = value.drop_front().drop_back().str(); } break; } - value_str_no_quotes = trimmed.str(); - value_cstr = value_str_no_quotes.c_str(); + value_str = value.str(); } switch (op) @@ -86,26 +85,26 @@ case eVarSetOperationRemove: if (m_validator) { - error = m_validator(value_cstr,m_validator_baton); + error = m_validator(value_str.c_str(),m_validator_baton); if (error.Fail()) return error; } - error = OptionValue::SetValueFromCString (value_cstr, op); + error = OptionValue::SetValueFromString (value, op); break; case eVarSetOperationAppend: { std::string new_value(m_current_value); - if (value_cstr && value_cstr[0]) + if (value.size() > 0) { if (m_options.Test (eOptionEncodeCharacterEscapeSequences)) { std::string str; - Args::EncodeEscapeSequences (value_cstr, str); + Args::EncodeEscapeSequences (value_str.c_str(), str); new_value.append(str); } else - new_value.append(value_cstr); + new_value.append(value); } if (m_validator) { @@ -127,18 +126,18 @@ case eVarSetOperationAssign: if (m_validator) { - error = m_validator(value_cstr,m_validator_baton); + error = m_validator(value_str.c_str(), m_validator_baton); if (error.Fail()) return error; } m_value_was_set = true; if (m_options.Test (eOptionEncodeCharacterEscapeSequences)) { - Args::EncodeEscapeSequences (value_cstr, m_current_value); + Args::EncodeEscapeSequences (value_str.c_str(), m_current_value); } else { - SetCurrentValue (value_cstr); + SetCurrentValue (value_str.c_str()); } NotifyValueChanged(); break; Index: source/Interpreter/OptionValueUInt64.cpp =================================================================== --- source/Interpreter/OptionValueUInt64.cpp +++ source/Interpreter/OptionValueUInt64.cpp @@ -23,7 +23,7 @@ OptionValueUInt64::Create (const char *value_cstr, Error &error) { lldb::OptionValueSP value_sp (new OptionValueUInt64()); - error = value_sp->SetValueFromCString (value_cstr); + error = value_sp->SetValueFromString (value_cstr); if (error.Fail()) value_sp.reset(); return value_sp; @@ -44,7 +44,7 @@ } Error -OptionValueUInt64::SetValueFromCString (const char *value_cstr, VarSetOperationType op) +OptionValueUInt64::SetValueFromString (llvm::StringRef value_ref, VarSetOperationType op) { Error error; switch (op) @@ -58,7 +58,7 @@ case eVarSetOperationAssign: { bool success = false; - std::string value_str = llvm::StringRef(value_cstr).trim().str(); + std::string value_str = value_ref.trim().str(); uint64_t value = StringConvert::ToUInt64 (value_str.c_str(), 0, 0, &success); if (success) { @@ -68,7 +68,7 @@ } else { - error.SetErrorStringWithFormat ("invalid uint64_t string value: '%s'", value_cstr); + error.SetErrorStringWithFormat ("invalid uint64_t string value: '%s'", value_str.c_str()); } } break; @@ -78,7 +78,7 @@ case eVarSetOperationRemove: case eVarSetOperationAppend: case eVarSetOperationInvalid: - error = OptionValue::SetValueFromCString (value_cstr, op); + error = OptionValue::SetValueFromString (value_ref, op); break; } return error; Index: source/Interpreter/OptionValueUUID.cpp =================================================================== --- source/Interpreter/OptionValueUUID.cpp +++ source/Interpreter/OptionValueUUID.cpp @@ -37,7 +37,7 @@ } Error -OptionValueUUID::SetValueFromCString (const char *value_cstr, +OptionValueUUID::SetValueFromString (llvm::StringRef value, VarSetOperationType op) { Error error; @@ -51,8 +51,8 @@ case eVarSetOperationReplace: case eVarSetOperationAssign: { - if (m_uuid.SetFromCString(value_cstr) == 0) - error.SetErrorStringWithFormat ("invalid uuid string value '%s'", value_cstr); + if (m_uuid.SetFromCString(value.str().c_str()) == 0) + error.SetErrorStringWithFormat ("invalid uuid string value '%s'", value.str().c_str()); else { m_value_was_set = true; @@ -66,7 +66,7 @@ case eVarSetOperationRemove: case eVarSetOperationAppend: case eVarSetOperationInvalid: - error = OptionValue::SetValueFromCString (value_cstr, op); + error = OptionValue::SetValueFromString (value, op); break; } return error; Index: source/Interpreter/Property.cpp =================================================================== --- source/Interpreter/Property.cpp +++ source/Interpreter/Property.cpp @@ -80,11 +80,11 @@ m_value_sp.reset (enum_value); if (definition.default_cstr_value) { - if (enum_value->SetValueFromCString(definition.default_cstr_value).Success()) + if (enum_value->SetValueFromString(definition.default_cstr_value).Success()) { enum_value->SetDefaultValue(enum_value->GetCurrentValue()); // Call Clear() since we don't want the value to appear as - // having been set since we called SetValueFromCString() above. + // having been set since we called SetValueFromString() above. // Clear will set the current value to the default and clear // the boolean that says that the value has been set. enum_value->Clear();