* dwarf2read.c (read_str_index): Delete arg cu. All callers updated.
[deliverable/binutils-gdb.git] / gdb / cp-support.c
index 97524ed579f36b094dd089dc6ba1fa1d0bf798bd..2379b54c2b0251764c5ddb137b0c80a68b20bc26 100644 (file)
@@ -1,5 +1,5 @@
 /* Helper routines for C++ support in GDB.
-   Copyright (C) 2002-2005, 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002-2014 Free Software Foundation, Inc.
 
    Contributed by MontaVista Software.
 
@@ -20,7 +20,7 @@
 
 #include "defs.h"
 #include "cp-support.h"
-#include "gdb_string.h"
+#include <string.h>
 #include "demangle.h"
 #include "gdb_assert.h"
 #include "gdbcmd.h"
@@ -38,8 +38,6 @@
 
 #include "safe-ctype.h"
 
-#include "psymtab.h"
-
 #define d_left(dc) (dc)->u.s_binary.left
 #define d_right(dc) (dc)->u.s_binary.right
 
@@ -200,8 +198,9 @@ inspect_type (struct demangle_parse_info *info,
          return 0;
        }
 
-      /* If the type is a typedef, replace it.  */
-      if (TYPE_CODE (otype) == TYPE_CODE_TYPEDEF)
+      /* If the type is a typedef or namespace alias, replace it.  */
+      if (TYPE_CODE (otype) == TYPE_CODE_TYPEDEF
+         || TYPE_CODE (otype) == TYPE_CODE_NAMESPACE)
        {
          long len;
          int is_anon;
@@ -212,6 +211,13 @@ inspect_type (struct demangle_parse_info *info,
          /* Get the real type of the typedef.  */
          type = check_typedef (otype);
 
+         /* If the symbol is a namespace and its type name is no different
+            than the name we looked up, this symbol is not a namespace
+            alias and does not need to be substituted.  */
+         if (TYPE_CODE (otype) == TYPE_CODE_NAMESPACE
+             && strcmp (TYPE_NAME (type), name) == 0)
+           return 0;
+
          is_anon = (TYPE_TAG_NAME (type) == NULL
                     && (TYPE_CODE (type) == TYPE_CODE_ENUM
                         || TYPE_CODE (type) == TYPE_CODE_STRUCT
@@ -635,7 +641,7 @@ mangled_name_to_comp (const char *mangled_name, int options,
 
   /* If it doesn't, or if that failed, then try to demangle the
      name.  */
-  demangled_name = cplus_demangle (mangled_name, options);
+  demangled_name = gdb_demangle (mangled_name, options);
   if (demangled_name == NULL)
    return NULL;
   
@@ -1476,6 +1482,14 @@ cp_lookup_rtti_type (const char *name, struct block *block)
   return rtti_type;
 }
 
+/* A wrapper for bfd_demangle.  */
+
+char *
+gdb_demangle (const char *name, int options)
+{
+  return bfd_demangle (NULL, name, options);
+}
+
 /* Don't allow just "maintenance cplus".  */
 
 static  void
This page took 0.02433 seconds and 4 git commands to generate.