diff options
author | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
---|---|---|
committer | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
commit | b9c1b51e45b845debb76d8658edabca70ca56079 (patch) | |
tree | dfcb5a13ef2b014202340f47036da383eaee74aa /lldb/source/Interpreter/OptionValueString.cpp | |
parent | d5aa73376966339caad04013510626ec2e42c760 (diff) | |
download | bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip |
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
Diffstat (limited to 'lldb/source/Interpreter/OptionValueString.cpp')
-rw-r--r-- | lldb/source/Interpreter/OptionValueString.cpp | 268 |
1 files changed, 117 insertions, 151 deletions
diff --git a/lldb/source/Interpreter/OptionValueString.cpp b/lldb/source/Interpreter/OptionValueString.cpp index 63f006e643f..d6e05da6846 100644 --- a/lldb/source/Interpreter/OptionValueString.cpp +++ b/lldb/source/Interpreter/OptionValueString.cpp @@ -1,4 +1,5 @@ -//===-- OptionValueString.cpp ------------------------------------*- C++ -*-===// +//===-- OptionValueString.cpp ------------------------------------*- C++ +//-*-===// // // The LLVM Compiler Infrastructure // @@ -19,171 +20,136 @@ using namespace lldb; using namespace lldb_private; -void -OptionValueString::DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) -{ +void OptionValueString::DumpValue(const ExecutionContext *exe_ctx, Stream &strm, + uint32_t dump_mask) { + if (dump_mask & eDumpOptionType) + strm.Printf("(%s)", GetTypeAsCString()); + if (dump_mask & eDumpOptionValue) { if (dump_mask & eDumpOptionType) - strm.Printf ("(%s)", GetTypeAsCString ()); - if (dump_mask & eDumpOptionValue) - { - if (dump_mask & eDumpOptionType) - strm.PutCString (" = "); - if (!m_current_value.empty() || m_value_was_set) - { - if (m_options.Test (eOptionEncodeCharacterEscapeSequences)) - { - std::string expanded_escape_value; - Args::ExpandEscapedCharacters(m_current_value.c_str(), expanded_escape_value); - if (dump_mask & eDumpOptionRaw) - strm.Printf ("%s", expanded_escape_value.c_str()); - else - strm.Printf ("\"%s\"", expanded_escape_value.c_str()); - } - else - { - if (dump_mask & eDumpOptionRaw) - strm.Printf ("%s", m_current_value.c_str()); - else - strm.Printf ("\"%s\"", m_current_value.c_str()); - } - } + strm.PutCString(" = "); + if (!m_current_value.empty() || m_value_was_set) { + if (m_options.Test(eOptionEncodeCharacterEscapeSequences)) { + std::string expanded_escape_value; + Args::ExpandEscapedCharacters(m_current_value.c_str(), + expanded_escape_value); + if (dump_mask & eDumpOptionRaw) + strm.Printf("%s", expanded_escape_value.c_str()); + else + strm.Printf("\"%s\"", expanded_escape_value.c_str()); + } else { + if (dump_mask & eDumpOptionRaw) + strm.Printf("%s", m_current_value.c_str()); + else + strm.Printf("\"%s\"", m_current_value.c_str()); + } } + } } -Error -OptionValueString::SetValueFromString (llvm::StringRef value, - VarSetOperationType op) -{ - Error error; +Error OptionValueString::SetValueFromString(llvm::StringRef value, + VarSetOperationType op) { + Error error; - std::string value_str = value.str(); - value = value.trim(); - if (value.size() > 0) - { - switch (value.front()) - { - case '"': - case '\'': - { - if (value.size() <= 1 || value.back() != value.front()) - { - error.SetErrorString("mismatched quotes"); - return error; - } - value = value.drop_front().drop_back(); - } - break; - } - value_str = value.str(); + std::string value_str = value.str(); + value = value.trim(); + if (value.size() > 0) { + switch (value.front()) { + case '"': + case '\'': { + if (value.size() <= 1 || value.back() != value.front()) { + error.SetErrorString("mismatched quotes"); + return error; + } + value = value.drop_front().drop_back(); + } break; } + value_str = value.str(); + } - switch (op) - { - case eVarSetOperationInvalid: - case eVarSetOperationInsertBefore: - case eVarSetOperationInsertAfter: - case eVarSetOperationRemove: - if (m_validator) - { - error = m_validator(value_str.c_str(),m_validator_baton); - if (error.Fail()) - return error; - } - error = OptionValue::SetValueFromString (value, op); - break; + switch (op) { + case eVarSetOperationInvalid: + case eVarSetOperationInsertBefore: + case eVarSetOperationInsertAfter: + case eVarSetOperationRemove: + if (m_validator) { + error = m_validator(value_str.c_str(), m_validator_baton); + if (error.Fail()) + return error; + } + error = OptionValue::SetValueFromString(value, op); + break; - case eVarSetOperationAppend: - { - std::string new_value(m_current_value); - if (value.size() > 0) - { - if (m_options.Test (eOptionEncodeCharacterEscapeSequences)) - { - std::string str; - Args::EncodeEscapeSequences (value_str.c_str(), str); - new_value.append(str); - } - else - new_value.append(value); - } - if (m_validator) - { - error = m_validator(new_value.c_str(),m_validator_baton); - if (error.Fail()) - return error; - } - m_current_value.assign(new_value); - NotifyValueChanged(); - } - break; + case eVarSetOperationAppend: { + std::string new_value(m_current_value); + if (value.size() > 0) { + if (m_options.Test(eOptionEncodeCharacterEscapeSequences)) { + std::string str; + Args::EncodeEscapeSequences(value_str.c_str(), str); + new_value.append(str); + } else + new_value.append(value); + } + if (m_validator) { + error = m_validator(new_value.c_str(), m_validator_baton); + if (error.Fail()) + return error; + } + m_current_value.assign(new_value); + NotifyValueChanged(); + } break; - case eVarSetOperationClear: - Clear (); - NotifyValueChanged(); - break; + case eVarSetOperationClear: + Clear(); + NotifyValueChanged(); + break; - case eVarSetOperationReplace: - case eVarSetOperationAssign: - if (m_validator) - { - 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_str.c_str(), m_current_value); - } - else - { - SetCurrentValue (value_str.c_str()); - } - NotifyValueChanged(); - break; + case eVarSetOperationReplace: + case eVarSetOperationAssign: + if (m_validator) { + error = m_validator(value_str.c_str(), m_validator_baton); + if (error.Fail()) + return error; } - return error; + m_value_was_set = true; + if (m_options.Test(eOptionEncodeCharacterEscapeSequences)) { + Args::EncodeEscapeSequences(value_str.c_str(), m_current_value); + } else { + SetCurrentValue(value_str.c_str()); + } + NotifyValueChanged(); + break; + } + return error; } - -lldb::OptionValueSP -OptionValueString::DeepCopy () const -{ - return OptionValueSP(new OptionValueString(*this)); +lldb::OptionValueSP OptionValueString::DeepCopy() const { + return OptionValueSP(new OptionValueString(*this)); } -Error -OptionValueString::SetCurrentValue (const char *value) -{ - if (m_validator) - { - Error error(m_validator(value,m_validator_baton)); - if (error.Fail()) - return error; - } - if (value && value[0]) - m_current_value.assign (value); - else - m_current_value.clear(); - return Error(); +Error OptionValueString::SetCurrentValue(const char *value) { + if (m_validator) { + Error error(m_validator(value, m_validator_baton)); + if (error.Fail()) + return error; + } + if (value && value[0]) + m_current_value.assign(value); + else + m_current_value.clear(); + return Error(); } -Error -OptionValueString::AppendToCurrentValue (const char *value) -{ - if (value && value[0]) - { - if (m_validator) - { - std::string new_value(m_current_value); - new_value.append(value); - Error error(m_validator(value,m_validator_baton)); - if (error.Fail()) - return error; - m_current_value.assign(new_value); - } - else - m_current_value.append (value); - } - return Error(); +Error OptionValueString::AppendToCurrentValue(const char *value) { + if (value && value[0]) { + if (m_validator) { + std::string new_value(m_current_value); + new_value.append(value); + Error error(m_validator(value, m_validator_baton)); + if (error.Fail()) + return error; + m_current_value.assign(new_value); + } else + m_current_value.append(value); + } + return Error(); } |