ARI fixes: Avoid sprintf function use rule.
[deliverable/binutils-gdb.git] / gdb / cp-namespace.c
index 9f3a60803ba77e6ebd817d32ea073a708e37c35b..1a694023b9e7c490c0a98f2accd94a4ca9a5a256 100644 (file)
@@ -1,6 +1,5 @@
 /* Helper routines for C++ support in GDB.
-   Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 2003-2004, 2007-2012 Free Software Foundation, Inc.
 
    Contributed by David Carlton and by Kealia, Inc.
 
@@ -661,14 +660,14 @@ lookup_symbol_file (const char *name,
   return sym;
 }
 
-/* Look up a type named NESTED_NAME that is nested inside the C++
+/* Look up a symbol named NESTED_NAME that is nested inside the C++
    class or namespace given by PARENT_TYPE, from within the context
    given by BLOCK.  Return NULL if there is no such nested type.  */
 
-struct type *
-cp_lookup_nested_type (struct type *parent_type,
-                      const char *nested_name,
-                      const struct block *block)
+struct symbol *
+cp_lookup_nested_symbol (struct type *parent_type,
+                        const char *nested_name,
+                        const struct block *block)
 {
   /* type_name_no_tag_required provides better error reporting using the
      original type.  */
@@ -689,14 +688,15 @@ cp_lookup_nested_type (struct type *parent_type,
           just like members of namespaces; in particular,
           lookup_symbol_namespace works when looking them up.  */
 
+       int size;
        const char *parent_name = type_name_no_tag_or_error (saved_parent_type);
        struct symbol *sym
          = cp_lookup_symbol_in_namespace (parent_name, nested_name,
                                           block, VAR_DOMAIN);
        char *concatenated_name;
 
-       if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
-         return SYMBOL_TYPE (sym);
+       if (sym != NULL)
+         return sym;
 
        /* Now search all static file-level symbols.  Not strictly
           correct, but more useful than an error.  We do not try to
@@ -704,20 +704,19 @@ cp_lookup_nested_type (struct type *parent_type,
           namespace seach is is already not C++ compliant and more
           assumptions could make it too magic.  */
 
-       concatenated_name = alloca (strlen (parent_name) + 2
-                                   + strlen (nested_name) + 1);
-       sprintf (concatenated_name, "%s::%s",
+       size = strlen (parent_name) + 2 + strlen (nested_name) + 1;
+       concatenated_name = alloca (size);
+       xsnprintf (concatenated_name, size, "%s::%s",
                 parent_name, nested_name);
-       sym = lookup_static_symbol_aux (concatenated_name,
-                                       VAR_DOMAIN);
-       if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
-         return SYMBOL_TYPE (sym);
+       sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN);
+       if (sym != NULL)
+         return sym;
 
        return NULL;
       }
     default:
       internal_error (__FILE__, __LINE__,
-                     _("cp_lookup_nested_type called "
+                     _("cp_lookup_nested_symbol called "
                        "on a non-aggregate type."));
     }
 }
This page took 0.025342 seconds and 4 git commands to generate.