diff options
| author | Zachary Turner <zturner@google.com> | 2016-11-18 03:51:19 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2016-11-18 03:51:19 +0000 |
| commit | c2d5558b21afcc7e14c326c4a54c6373b229f330 (patch) | |
| tree | d6bf82d38abcb01d2caf28ed6f854ebe05019be7 /lldb/source/Core | |
| parent | 63e10c9c96af3d1b352ade216aa3bb6b5ff1c3e4 (diff) | |
| download | bcm5719-llvm-c2d5558b21afcc7e14c326c4a54c6373b229f330.tar.gz bcm5719-llvm-c2d5558b21afcc7e14c326c4a54c6373b229f330.zip | |
Remove some dead code in ValueObject.
Originally I converted this entire function and all dependents
to use StringRef, but there were some test failures that
were tricky to track down, as this is a complicated function.
So I'm starting over, this time in smaller increments.
llvm-svn: 287307
Diffstat (limited to 'lldb/source/Core')
| -rw-r--r-- | lldb/source/Core/ValueObject.cpp | 65 |
1 files changed, 21 insertions, 44 deletions
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index e349e03f236..30ec0daf916 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -2607,14 +2607,15 @@ ValueObjectSP ValueObject::GetValueForExpressionPath_Impl( *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; return ValueObjectSP(); } - if (!separator_position || - separator_position > close_bracket_position) // if no separator, this - // is either [] or [N] - { + + if (!separator_position || separator_position > close_bracket_position) { + // if no separator, this is of the form [N]. Note that this cannot + // be an unbounded range of the form [], because that case was handled + // above with an unconditional return. char *end = NULL; unsigned long index = ::strtoul(expression_cstr + 1, &end, 0); - if (!end || end != close_bracket_position) // if something weird is in - // our way return an error + if (end != close_bracket_position) // if something weird is in + // our way return an error { *first_unparsed = expression_cstr; *reason_to_stop = @@ -2622,24 +2623,6 @@ ValueObjectSP ValueObject::GetValueForExpressionPath_Impl( *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; return ValueObjectSP(); } - if (end - expression_cstr == - 1) // if this is [], only return a valid value for arrays - { - if (root_compiler_type_info.Test(eTypeIsArray)) { - *first_unparsed = expression_cstr + 2; - *reason_to_stop = - ValueObject::eExpressionPathScanEndReasonArrayRangeOperatorMet; - *final_result = - ValueObject::eExpressionPathEndResultTypeUnboundedRange; - return root; - } else { - *first_unparsed = expression_cstr; - *reason_to_stop = - ValueObject::eExpressionPathScanEndReasonEmptyRangeNotAllowed; - *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; - return ValueObjectSP(); - } - } // from here on we do have a valid index if (root_compiler_type_info.Test(eTypeIsArray)) { ValueObjectSP child_valobj_sp = root->GetChildAtIndex(index, true); @@ -2791,8 +2774,8 @@ ValueObjectSP ValueObject::GetValueForExpressionPath_Impl( { char *end = NULL; unsigned long index_lower = ::strtoul(expression_cstr + 1, &end, 0); - if (!end || end != separator_position) // if something weird is in our - // way return an error + if (end != separator_position) // if something weird is in our + // way return an error { *first_unparsed = expression_cstr; *reason_to_stop = @@ -2801,8 +2784,8 @@ ValueObjectSP ValueObject::GetValueForExpressionPath_Impl( return ValueObjectSP(); } unsigned long index_higher = ::strtoul(separator_position + 1, &end, 0); - if (!end || end != close_bracket_position) // if something weird is in - // our way return an error + if (end != close_bracket_position) // if something weird is in + // our way return an error { *first_unparsed = expression_cstr; *reason_to_stop = @@ -2811,11 +2794,8 @@ ValueObjectSP ValueObject::GetValueForExpressionPath_Impl( return ValueObjectSP(); } if (index_lower > index_higher) // swap indices if required - { - unsigned long temp = index_lower; - index_lower = index_higher; - index_higher = temp; - } + std::swap(index_lower, index_higher); + if (root_compiler_type_info.Test( eTypeIsScalar)) // expansion only works for scalars { @@ -2975,8 +2955,8 @@ int ValueObject::ExpandArraySliceExpression( { char *end = NULL; unsigned long index = ::strtoul(expression_cstr + 1, &end, 0); - if (!end || end != close_bracket_position) // if something weird is in - // our way return an error + if (end != close_bracket_position) // if something weird is in + // our way return an error { *first_unparsed = expression_cstr; *reason_to_stop = @@ -3093,8 +3073,8 @@ int ValueObject::ExpandArraySliceExpression( { char *end = NULL; unsigned long index_lower = ::strtoul(expression_cstr + 1, &end, 0); - if (!end || end != separator_position) // if something weird is in our - // way return an error + if (end != separator_position) // if something weird is in our + // way return an error { *first_unparsed = expression_cstr; *reason_to_stop = @@ -3103,8 +3083,8 @@ int ValueObject::ExpandArraySliceExpression( return 0; } unsigned long index_higher = ::strtoul(separator_position + 1, &end, 0); - if (!end || end != close_bracket_position) // if something weird is in - // our way return an error + if (end != close_bracket_position) // if something weird is in + // our way return an error { *first_unparsed = expression_cstr; *reason_to_stop = @@ -3113,11 +3093,8 @@ int ValueObject::ExpandArraySliceExpression( return 0; } if (index_lower > index_higher) // swap indices if required - { - unsigned long temp = index_lower; - index_lower = index_higher; - index_higher = temp; - } + std::swap(index_lower, index_higher); + if (root_compiler_type_info.Test( eTypeIsScalar)) // expansion only works for scalars { |

