Rename cp_lookup_symbol_imports to cp_lookup_symbol_via_imports

Message ID m3iohfick1.fsf@seba.sebabeach.org
State New, archived
Headers

Commit Message

Doug Evans Dec. 13, 2014, 7:18 p.m. UTC
  Hi.

Maybe it's just me, but I find cp-namespace.c to be unreadable
in that I have to keep too much state in my head about what functions
REALLY do because their names are ambiguous and confusing.

In this case, this rename makes this part 10x easier for me to read.
I don't have to remember what "lookup symbol imports" REALLY means
(it doesn't mean anything, it's "lookup symbol VIA imports").

Also, cp_lookup_symbol_imports currently does this:

  /* First, try to find the symbol in the given namespace.  */
  if (!declaration_only)
    sym = cp_lookup_symbol_in_namespace (scope, name,
					 block, domain, 1);

That's not really in keeping with what the function is intended to do,
but moving that out is a topic for another patch.

2014-12-13  Doug Evans  <xdje42@gmail.com>

	* cp-namespace.c (cp_lookup_symbol_via_imports): Renamed from
	cp_lookup_symbol_imports.  All callers updated.
  

Comments

Doug Evans Dec. 17, 2014, 6:22 a.m. UTC | #1
On Sat, Dec 13, 2014 at 11:18 AM, Doug Evans <xdje42@gmail.com> wrote:
> Hi.
>
> Maybe it's just me, but I find cp-namespace.c to be unreadable
> in that I have to keep too much state in my head about what functions
> REALLY do because their names are ambiguous and confusing.
>
> In this case, this rename makes this part 10x easier for me to read.
> I don't have to remember what "lookup symbol imports" REALLY means
> (it doesn't mean anything, it's "lookup symbol VIA imports").
>
> Also, cp_lookup_symbol_imports currently does this:
>
>   /* First, try to find the symbol in the given namespace.  */
>   if (!declaration_only)
>     sym = cp_lookup_symbol_in_namespace (scope, name,
>                                          block, domain, 1);
>
> That's not really in keeping with what the function is intended to do,
> but moving that out is a topic for another patch.
>
> 2014-12-13  Doug Evans  <xdje42@gmail.com>
>
>         * cp-namespace.c (cp_lookup_symbol_via_imports): Renamed from
>         cp_lookup_symbol_imports.  All callers updated.

Committed.
  

Patch

diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 3066737..06290a7 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -371,12 +371,12 @@  reset_directive_searched (void *data)
    only the import of Y is considered.  */
 
 static struct symbol *
-cp_lookup_symbol_imports (const char *scope,
-                          const char *name,
-                          const struct block *block,
-                          const domain_enum domain,
-                          const int declaration_only,
-                          const int search_parents)
+cp_lookup_symbol_via_imports (const char *scope,
+			      const char *name,
+			      const struct block *block,
+			      const domain_enum domain,
+			      const int declaration_only,
+			      const int search_parents)
 {
   struct using_direct *current;
   struct symbol *sym = NULL;
@@ -472,9 +472,9 @@  cp_lookup_symbol_imports (const char *scope,
 	      /* If this import statement creates no alias, pass
 		 current->inner as NAMESPACE to direct the search
 		 towards the imported namespace.  */
-	      sym = cp_lookup_symbol_imports (current->import_src,
-					      name, block,
-					      domain, 0, 0);
+	      sym = cp_lookup_symbol_via_imports (current->import_src,
+						  name, block,
+						  domain, 0, 0);
 	    }
 	  current->searched = 0;
 	  discard_cleanups (searched_cleanup);
@@ -505,7 +505,7 @@  search_symbol_list (const char *name, int num,
   return NULL;
 }
 
-/* Like cp_lookup_symbol_imports, but if BLOCK is a function, it
+/* Like cp_lookup_symbol_via_imports, but if BLOCK is a function, it
    searches through the template parameters of the function and the
    function's type.  */
 
@@ -578,7 +578,7 @@  cp_lookup_symbol_imports_or_template (const char *scope,
 	}
     }
 
-  return cp_lookup_symbol_imports (scope, name, block, domain, 1, 1);
+  return cp_lookup_symbol_via_imports (scope, name, block, domain, 1, 1);
 }
 
  /* Searches for NAME in the current namespace, and by applying
@@ -604,8 +604,8 @@  cp_lookup_symbol_namespace (const char *scope,
      blocks.  */
   while (block != NULL)
     {
-      sym = cp_lookup_symbol_imports (scope, name, block,
-				      domain, 0, 1);
+      sym = cp_lookup_symbol_via_imports (scope, name, block,
+					  domain, 0, 1);
 
       if (sym)
 	return sym;