aboutsummaryrefslogtreecommitdiff
path: root/gdb/cp-namespace.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-01-25 17:36:01 +0000
committerTom Tromey <tromey@redhat.com>2013-01-25 17:36:01 +0000
commit12aaed36e3f39b4dadf6bc8f74d254d4d8a3909f (patch)
treef61366b0050baf69e9284321710e3d1725e1a713 /gdb/cp-namespace.c
parent7fc75ca750afe059352f475d7511330506e835ef (diff)
downloadgdb-12aaed36e3f39b4dadf6bc8f74d254d4d8a3909f.zip
gdb-12aaed36e3f39b4dadf6bc8f74d254d4d8a3909f.tar.gz
gdb-12aaed36e3f39b4dadf6bc8f74d254d4d8a3909f.tar.bz2
* 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.
Diffstat (limited to 'gdb/cp-namespace.c')
-rw-r--r--gdb/cp-namespace.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 8511bf1..32f6d34 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -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));