[Lldb-commits] [lldb] r287307 - Remove some dead code in ValueObject.
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Thu Nov 17 19:51:19 PST 2016
Author: zturner
Date: Thu Nov 17 21:51:19 2016
New Revision: 287307
URL: http://llvm.org/viewvc/llvm-project?rev=287307&view=rev
Log:
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.
Modified:
lldb/trunk/source/Core/ValueObject.cpp
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=287307&r1=287306&r2=287307&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Thu Nov 17 21:51:19 2016
@@ -2607,14 +2607,15 @@ ValueObjectSP ValueObject::GetValueForEx
*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::GetValueForEx
*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::GetValueForEx
{
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::GetValueForEx
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::GetValueForEx
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::ExpandArraySliceExpress
{
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::ExpandArraySliceExpress
{
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::ExpandArraySliceExpress
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::ExpandArraySliceExpress
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
{
More information about the lldb-commits
mailing list