]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2003-03-10 David Carlton <carlton@math.stanford.edu>
authorDavid Carlton <carlton@bactrian.org>
Tue, 11 Mar 2003 01:01:10 +0000 (01:01 +0000)
committerDavid Carlton <carlton@bactrian.org>
Tue, 11 Mar 2003 01:01:10 +0000 (01:01 +0000)
* buildsym.c (scan_for_anonymous_namespaces): Allow
"{anonymous}".
* cp-support.c (cp_is_anonymous): Scan for "{anonymous}".

gdb/ChangeLog
gdb/buildsym.c
gdb/cp-support.c

index 86bd57cb8dffa242ddafc975095c69716668ff27..605f7be249bef7635d7df7ddc1ff892bdd41eb92 100644 (file)
@@ -1,3 +1,9 @@
+2003-03-10  David Carlton  <carlton@math.stanford.edu>
+
+       * buildsym.c (scan_for_anonymous_namespaces): Allow
+       "{anonymous}".
+       * cp-support.c (cp_is_anonymous): Scan for "{anonymous}".
+
 2003-03-07  David Carlton  <carlton@math.stanford.edu>
 
        * symtab.c (lookup_partial_symbol): Replace uses of
index a6cbf7738b0eab8115e7bd6ce50b0151fd7f1896..494da48306277623703eb62c49559f5a85092b8d 100644 (file)
@@ -148,10 +148,6 @@ add_symbol_to_list (struct symbol *symbol, struct pending **listhead)
 /* Check to see if a symbol is contained within an anonymous
    namespace; if so, add an appropriate using directive.  */
 
-/* Optimize away strlen ("(anonymous namespace)").  */
-
-#define ANONYMOUS_NAMESPACE_LEN 21
-
 static void
 scan_for_anonymous_namespaces (struct symbol *symbol)
 {
@@ -159,22 +155,40 @@ scan_for_anonymous_namespaces (struct symbol *symbol)
   unsigned int previous_component;
   unsigned int next_component;
   const char *len;
+  const char *anonymous_name;
+  int anonymous_len;
 
-  /* Start with a quick-and-dirty check for mention of "(anonymous
-     namespace)".  */
+  /* Start with a quick-and-dirty check for mentions of anonymous
+     namespaces.  */
 
-  if (!cp_is_anonymous (name))
-    return;
+  switch (cp_is_anonymous (name))
+    {
+    case 1:
+      anonymous_name = "(anonymous namespace)";
+      break;
+    case 2:
+      /* FIXME: carlton/2003-03-10: This corresponds to GCCv2, and
+        urrently, the demangler actually can't demangle all anonymous
+        namespace mentions correctly.  (See PR gdb/1134.) Given
+        GCCv2's lack of namespace support, I'm tempted to skip this
+        case entirely.  */
+      anonymous_name = "{anonymous}";
+      break;
+    default:
+      return;
+    }
+
+  anonymous_len = strlen (anonymous_name);
 
   previous_component = 0;
   next_component = cp_find_first_component (name + previous_component);
 
   while (name[next_component] == ':')
     {
-      if ((next_component - previous_component) == ANONYMOUS_NAMESPACE_LEN
-         && strncmp (name + previous_component,
-                     "(anonymous namespace)",
-                     ANONYMOUS_NAMESPACE_LEN) == 0)
+      if ((next_component - previous_component) == anonymous_len
+         && (strncmp (name + previous_component, anonymous_name,
+                      anonymous_len)
+             == 0))
        {
          /* We've found a component of the name that's an anonymous
             namespace.  So add symbols in it to the namespace given
index 9e55ab98af8b8523c48189c2437c2be574f11de7..07c1928a680b378a59cecc0185b206b40a5a1980 100644 (file)
@@ -647,13 +647,18 @@ maintenance_print_namespace (char *args, int from_tty)
 }
 
 /* Test whether or not NAMESPACE looks like it mentions an anonymous
-   namespace; return nonzero if so.  */
+   namespace; return 1 if it mentions "(anonymous namespace)", 2 if it
+   mentions "{anonymous}", and 0 otherwise.  */
 
 int
 cp_is_anonymous (const char *namespace)
 {
-  return (strstr (namespace, "(anonymous namespace)")
-         != NULL);
+  if (strstr (namespace, "(anonymous namespace)") != NULL)
+    return 1;
+  else if (strstr (namespace, "{anonymous}") != NULL)
+    return 2;
+  else
+    return 0;
 }
 
 /* Create a copy of the initial substring of STRING of length LEN.