[3/3] Fix mapped_index::find_name_components_bounds upper bound computation

Message ID 1511138515-25996-3-git-send-email-palves@redhat.com
State New, archived
Headers

Commit Message

Pedro Alves Nov. 20, 2017, 12:41 a.m. UTC
  Here we want to find where we'd insert "after", so we want
std::lower_bound, not std::upper_bound.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

	* dwarf2read.c (mapped_index::find_name_components_bounds)
	<completion mode, upper bound>: Use std::lower_bound instead of
	std::upper_bound.
	(test_mapped_index_find_name_component_bounds): Remove incorrect
	"t1_fund" from expected symbols.
---
 gdb/dwarf2read.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
  

Comments

Simon Marchi Nov. 20, 2017, 3:17 a.m. UTC | #1
On 2017-11-19 07:41 PM, Pedro Alves wrote:
> Here we want to find where we'd insert "after", so we want
> std::lower_bound, not std::upper_bound.
> 
> gdb/ChangeLog:
> yyyy-mm-dd  Pedro Alves  <palves@redhat.com>
> 
> 	* dwarf2read.c (mapped_index::find_name_components_bounds)
> 	<completion mode, upper bound>: Use std::lower_bound instead of
> 	std::upper_bound.
> 	(test_mapped_index_find_name_component_bounds): Remove incorrect
> 	"t1_fund" from expected symbols.
> ---
>  gdb/dwarf2read.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
> index 53548ca..c4d1254 100644
> --- a/gdb/dwarf2read.c
> +++ b/gdb/dwarf2read.c
> @@ -4319,8 +4319,8 @@ mapped_index::find_name_components_bounds
>  	  std::string after = make_sort_after_prefix_name (cplus);
>  	  if (after.empty ())
>  	    return end;
> -	  return std::upper_bound (lower, end, after.c_str (),
> -				   lookup_compare_upper);
> +	  return std::lower_bound (lower, end, after.c_str (),
> +				   lookup_compare_lower);
>  	}
>        else
>  	return std::upper_bound (lower, end, cplus, lookup_compare_upper);
> @@ -4659,7 +4659,6 @@ test_mapped_index_find_name_component_bounds ()
>      static const char *expected_syms[] = {
>        "t1_func",
>        "t1_func1",
> -      "t1_fund", /* This one's incorrect.  */
>      };
>  
>      SELF_CHECK (check_find_bounds_finds (mock_index.index (),
> 

LGTM.
  

Patch

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 53548ca..c4d1254 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -4319,8 +4319,8 @@  mapped_index::find_name_components_bounds
 	  std::string after = make_sort_after_prefix_name (cplus);
 	  if (after.empty ())
 	    return end;
-	  return std::upper_bound (lower, end, after.c_str (),
-				   lookup_compare_upper);
+	  return std::lower_bound (lower, end, after.c_str (),
+				   lookup_compare_lower);
 	}
       else
 	return std::upper_bound (lower, end, cplus, lookup_compare_upper);
@@ -4659,7 +4659,6 @@  test_mapped_index_find_name_component_bounds ()
     static const char *expected_syms[] = {
       "t1_func",
       "t1_func1",
-      "t1_fund", /* This one's incorrect.  */
     };
 
     SELF_CHECK (check_find_bounds_finds (mock_index.index (),