]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.
authorTom Tromey <tromey@redhat.com>
Fri, 25 Jan 2013 17:36:01 +0000 (17:36 +0000)
committerTom Tromey <tromey@redhat.com>
Fri, 25 Jan 2013 17:36:01 +0000 (17:36 +0000)
(cp_add_using_directive): Add 'copy_names' argument.
* cp-support.h (cp_add_using_directive): Update.
(struct using_direct) <import_src, import_dest, alias,
declaration>: Now const.
* dwarf2read.c (read_import_statement): Use obconcat.
Don't copy names passed to cp_add_using_directive.

gdb/ChangeLog
gdb/cp-namespace.c
gdb/cp-support.h
gdb/dwarf2read.c

index 01765e1f4ae13d4be40b170288a4da7b24abfa22..86878e215d593ba7dd8d68169308f6be750fba52 100644 (file)
@@ -1,3 +1,13 @@
+2013-01-25  Tom Tromey  <tromey@redhat.com>
+
+       * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.
+       (cp_add_using_directive): Add 'copy_names' argument.
+       * cp-support.h (cp_add_using_directive): Update.
+       (struct using_direct) <import_src, import_dest, alias,
+       declaration>: Now const.
+       * dwarf2read.c (read_import_statement): Use obconcat.
+       Don't copy names passed to cp_add_using_directive.
+
 2013-01-25  Tom Tromey  <tromey@redhat.com>
 
        * c-exp.y (qualified_name): Use TYPE_SAFE_NAME.
index 8511bf10033b2b3544d36f38119711a322144849..32f6d34997d408ce148c1df25524f31fb2165ad0 100644 (file)
@@ -96,7 +96,7 @@ cp_scan_for_anonymous_namespaces (const struct symbol *const symbol,
                 anonymous namespace.  So add symbols in it to the
                 namespace given by the previous component if there is
                 one, or to the global namespace if there isn't.  */
-             cp_add_using_directive (dest, src, NULL, NULL, NULL,
+             cp_add_using_directive (dest, src, NULL, NULL, NULL, 1,
                                      &objfile->objfile_obstack);
            }
          /* The "+ 2" is for the "::".  */
@@ -117,9 +117,10 @@ cp_scan_for_anonymous_namespaces (const struct symbol *const symbol,
    in the current scope.  If ALIAS is NULL then the namespace is known
    by its original name.  DECLARATION is the name if the imported
    varable if this is a declaration import (Eg. using A::x), otherwise
-   it is NULL.  EXCLUDES is a list of names not to import from an imported
-   module or NULL.  The arguments are copied into newly allocated memory so
-   they can be temporaries.  For EXCLUDES the VEC pointers are copied but the
+   it is NULL.  EXCLUDES is a list of names not to import from an
+   imported module or NULL.  If COPY_NAMES is non-zero, then the
+   arguments are copied into newly allocated memory so they can be
+   temporaries.  For EXCLUDES the VEC pointers are copied but the
    pointed to characters are not copied.  */
 
 void
@@ -128,6 +129,7 @@ cp_add_using_directive (const char *dest,
                        const char *alias,
                        const char *declaration,
                        VEC (const_char_ptr) *excludes,
+                       int copy_names,
                         struct obstack *obstack)
 {
   struct using_direct *current;
@@ -173,15 +175,27 @@ cp_add_using_directive (const char *dest,
                                    * sizeof (*new->excludes))));
   memset (new, 0, sizeof (*new));
 
-  new->import_src = obstack_copy0 (obstack, src, strlen (src));
-  new->import_dest = obstack_copy0 (obstack, dest, strlen (dest));
+  if (copy_names)
+    {
+      new->import_src = obstack_copy0 (obstack, src, strlen (src));
+      new->import_dest = obstack_copy0 (obstack, dest, strlen (dest));
+    }
+  else
+    {
+      new->import_src = src;
+      new->import_dest = dest;
+    }
 
-  if (alias != NULL)
+  if (alias != NULL && copy_names)
     new->alias = obstack_copy0 (obstack, alias, strlen (alias));
+  else
+    new->alias = alias;
 
-  if (declaration != NULL)
+  if (declaration != NULL && copy_names)
     new->declaration = obstack_copy0 (obstack,
                                      declaration, strlen (declaration));
+  else
+    new->declaration = declaration;
 
   memcpy (new->excludes, VEC_address (const_char_ptr, excludes),
          VEC_length (const_char_ptr, excludes) * sizeof (*new->excludes));
index c22c1e7ff0a7d763fbc710d5655e84e69cd5785d..3734886818eca9fb7f01a4eb011ef55357a756b9 100644 (file)
@@ -125,11 +125,11 @@ struct demangle_parse_info
 
 struct using_direct
 {
-  char *import_src;
-  char *import_dest;
+  const char *import_src;
+  const char *import_dest;
 
-  char *alias;
-  char *declaration;
+  const char *alias;
+  const char *declaration;
 
   struct using_direct *next;
 
@@ -186,6 +186,7 @@ extern void cp_add_using_directive (const char *dest,
                                     const char *alias,
                                    const char *declaration,
                                    VEC (const_char_ptr) *excludes,
+                                   int copy_names,
                                     struct obstack *obstack);
 
 extern void cp_set_block_scope (const struct symbol *symbol,
index 8ac062a6b2173ab9ba55cede1143a59e8bbc69e0..6395eca8a558b8916d39c24647d085240d85b007 100644 (file)
@@ -7713,8 +7713,6 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
   VEC (const_char_ptr) *excludes = NULL;
   struct cleanup *cleanups;
 
-  char *temp;
-
   import_attr = dwarf2_attr (die, DW_AT_import, cu);
   if (import_attr == NULL)
     {
@@ -7780,14 +7778,9 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
       canonical_name = imported_name_prefix;
     }
   else if (strlen (imported_name_prefix) > 0)
-    {
-      temp = alloca (strlen (imported_name_prefix)
-                     + 2 + strlen (imported_name) + 1);
-      strcpy (temp, imported_name_prefix);
-      strcat (temp, "::");
-      strcat (temp, imported_name);
-      canonical_name = temp;
-    }
+    canonical_name = obconcat (&objfile->objfile_obstack,
+                              imported_name_prefix, "::", imported_name,
+                              (char *) NULL);
   else
     canonical_name = imported_name;
 
@@ -7842,6 +7835,7 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
                           import_alias,
                           imported_declaration,
                          excludes,
+                         0,
                           &objfile->objfile_obstack);
 
   do_cleanups (cleanups);
@@ -12108,7 +12102,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu)
          const char *previous_prefix = determine_prefix (die, cu);
 
          cp_add_using_directive (previous_prefix, TYPE_NAME (type), NULL,
-                                 NULL, NULL, &objfile->objfile_obstack);
+                                 NULL, NULL, 0, &objfile->objfile_obstack);
        }
     }