contrib/gdb-7/gdb/cp-namespace.c
struct type *
cp_lookup_nested_type (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.  */
  struct type *saved_parent_type = parent_type;

  CHECK_TYPEDEF (parent_type);

  switch (TYPE_CODE (parent_type))
    {
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_NAMESPACE:
    case TYPE_CODE_UNION:
      {
	/* NOTE: carlton/2003-11-10: We don't treat C++ class members
	   of classes like, say, data or function members.  Instead,
	   they're just represented by symbols whose names are
	   qualified by the name of the surrounding class.  This is
	   just like members of namespaces; in particular,
	   lookup_symbol_namespace works when looking them up.  */

	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);

	/* Now search all static file-level symbols.  Not strictly
	   correct, but more useful than an error.  We do not try to
	   guess any imported namespace as even the fully specified
	   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",
		 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);

	return NULL;
      }
    default:
      internal_error (__FILE__, __LINE__,
		      _("cp_lookup_nested_type called "
			"on a non-aggregate type."));
    }
}
/* Look up a type 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.  */
Look up a type 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.
Look up a type 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 type *saved_parent_type = parent_type;
  CHECK_TYPEDEF (parent_type);
  switch (TYPE_CODE (parent_type))
    {
    case TYPE_CODE_STRUCT:
    case TYPE_CODE_NAMESPACE:
    case TYPE_CODE_UNION:
      {
	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);
	concatenated_name = alloca (strlen (parent_name) + 2
				    + strlen (nested_name) + 1);
	sprintf (concatenated_name, "%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);
	return NULL;
      }
    default:
      internal_error (__FILE__, __LINE__,
		      _("cp_lookup_nested_type called "
			"on a non-aggregate type."));
    }
}
struct type * cp_lookup_nested_type ( struct type * parent_type , const char * nested_name , const struct block * block ) { struct type * saved_parent_type = parent_type ; CHECK_TYPEDEF ( parent_type ) ; switch ( TYPE_CODE ( parent_type ) ) { case TYPE_CODE_STRUCT : case TYPE_CODE_NAMESPACE : case TYPE_CODE_UNION : { 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 ) ; concatenated_name = alloca ( strlen ( parent_name ) + 2 + strlen ( nested_name ) + 1 ) ; sprintf ( concatenated_name , " " , 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 ) ; return NULL ; } default : internal_error ( __FILE__ , __LINE__ , _ ( " " " " ) ) ; } }
Look up a type named NESTED_NAME that is nested inside the C++
class or namespace given by PARENT_TYPE, from within the context
given by BLOCK.
Look up a type named NESTED_NAME that is nested inside the C ++ class or namespace given by PARENT_TYPE from within the context given by BLOCK .
/* type_name_no_tag_required provides better error reporting using the
     original type.  */ /* NOTE: carlton/2003-11-10: We don't treat C++ class members
	   of classes like, say, data or function members.  Instead,
	   they're just represented by symbols whose names are
	   qualified by the name of the surrounding class.  This is
	   just like members of namespaces; in particular,
	   lookup_symbol_namespace works when looking them up.  */ /* Now search all static file-level symbols.  Not strictly
	   correct, but more useful than an error.  We do not try to
	   guess any imported namespace as even the fully specified
	   namespace seach is is already not C++ compliant and more
	   assumptions could make it too magic.  */