Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Iain Buclaw <ibuclaw@gdcproject.org>
To: GDB Patches <gdb-patches@sourceware.org>
Subject: [PATCH 2/2] [D] Remove search_parents parameter from d_lookup_symbol_imports
Date: Sun, 11 Oct 2015 12:01:00 -0000	[thread overview]
Message-ID: <CABOHX+dAvESSm0gHL4vvwX4JuoZhiy+uac6hSirQ6c35Da0_SQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 447 bytes --]

Whilst looking at part one, a moment of insight came to me and I
realized this code is completely nonsensical.

For a start, when importing modules, you don't gain access to all
parent packages of the given module.

To add some confusion, even the comment was wrong.  It doesn't even
cater for the example given (it's d_lookup_symbol_module that walks up
each block scope).

I feel embarrassed it didn't come to me before. :-)

Regards,
Iain.
---

[-- Attachment #2: dlang-searchparents.patch --]
[-- Type: text/x-diff, Size: 2410 bytes --]

gdb/ChangeLog:

	* d-namespace.c (d_lookup_symbol_imports): Remove argument
	'search_parents'.  All callers updated.

---
diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c
index da5da58..1524047 100644
--- a/gdb/d-namespace.c
+++ b/gdb/d-namespace.c
@@ -388,31 +388,15 @@ reset_directive_searched (void *data)
 }
 
 /* Search for NAME by applying all import statements belonging to
-   BLOCK which are applicable in SCOPE.
-
-   If SEARCH_PARENTS the search will include imports which are
-   applicable in parents of SCOPE.
-   Example:
-
-     module A;
-     import X;
-     void B() {
-       import Y;
-     }
-
-   If SCOPE is "A.B" and SEARCH_PARENTS is true, the imports of
-   modules X and Y will be considered.  If SEARCH_PARENTS is false
-   only the import of Y is considered.  */
+   BLOCK which are applicable in SCOPE.  */
 
 static struct block_symbol
 d_lookup_symbol_imports (const char *scope, const char *name,
 			 const struct block *block,
-			 const domain_enum domain,
-			 const int search_parents)
+			 const domain_enum domain)
 {
   struct using_direct *current;
   struct block_symbol sym;
-  int directive_match;
   struct cleanup *searched_cleanup;
 
   /* First, try to find the symbol in the given module.  */
@@ -430,18 +414,9 @@ d_lookup_symbol_imports (const char *scope, const char *name,
        current = current->next)
     {
       const char **excludep;
-      int len = strlen (current->import_dest);
-
-      directive_match = (search_parents
-			 ? (strncmp (scope, current->import_dest, len) == 0
-			    && (len == 0
-				|| scope[len] == '.'
-				|| scope[len] == '\0'))
-			 : strcmp (scope, current->import_dest) == 0);
-
-      /* If the import destination is the current scope or one of its
-	 ancestors then it is applicable.  */
-      if (directive_match && !current->searched)
+
+      /* If the import destination is the current scope then search it.  */
+      if (!current->searched && strcmp (scope, current->import_dest) == 0)
 	{
 	  /* Mark this import as searched so that the recursive call
 	     does not search it again.  */
@@ -554,7 +529,7 @@ d_lookup_symbol_module (const char *scope, const char *name,
      blocks.  */
   while (block != NULL)
     {
-      sym = d_lookup_symbol_imports (scope, name, block, domain, 1);
+      sym = d_lookup_symbol_imports (scope, name, block, domain);
 
       if (sym.symbol != NULL)
 	return sym;

             reply	other threads:[~2015-10-11 12:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-11 12:01 Iain Buclaw [this message]
2015-10-19 15:42 ` Pedro Alves
2015-10-25 11:19   ` Iain Buclaw
2015-10-26  3:47     ` Doug Evans
2015-10-29 17:10       ` Iain Buclaw
2016-01-30 13:50         ` Iain Buclaw
2015-10-26 21:35     ` Pedro Alves
2015-10-29 17:10       ` Iain Buclaw

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABOHX+dAvESSm0gHL4vvwX4JuoZhiy+uac6hSirQ6c35Da0_SQ@mail.gmail.com \
    --to=ibuclaw@gdcproject.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox