contrib/gdb-7/gdb/cp-namespace.c
void
cp_scan_for_anonymous_namespaces (const struct symbol *const symbol,
				  struct objfile *const objfile)
{
  if (SYMBOL_DEMANGLED_NAME (symbol) != NULL)
    {
      const char *name = SYMBOL_DEMANGLED_NAME (symbol);
      unsigned int previous_component;
      unsigned int next_component;

      /* Start with a quick-and-dirty check for mention of "(anonymous
	 namespace)".  */

      if (!cp_is_anonymous (name))
	return;

      previous_component = 0;
      next_component = cp_find_first_component (name + previous_component);

      while (name[next_component] == ':')
	{
	  if (((next_component - previous_component)
	       == CP_ANONYMOUS_NAMESPACE_LEN)
	      && strncmp (name + previous_component,
			  CP_ANONYMOUS_NAMESPACE_STR,
			  CP_ANONYMOUS_NAMESPACE_LEN) == 0)
	    {
	      int dest_len = (previous_component == 0
			      ? 0 : previous_component - 2);
	      int src_len = next_component;

	      char *dest = alloca (dest_len + 1);
	      char *src = alloca (src_len + 1);

	      memcpy (dest, name, dest_len);
	      memcpy (src, name, src_len);

	      dest[dest_len] = '\0';
	      src[src_len] = '\0';

	      /* We've found a component of the name that's an
		 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,
	                              &objfile->objfile_obstack);
	    }
	  /* The "+ 2" is for the "::".  */
	  previous_component = next_component + 2;
	  next_component = (previous_component
			    + cp_find_first_component (name
						       + previous_component));
	}
    }
}
/* Check to see if SYMBOL refers to an object contained within an
   anonymous namespace; if so, add an appropriate using directive.  */
Check to see if SYMBOL refers to an object contained within an
anonymous namespace; if so, add an appropriate using directive.
Check to see if SYMBOL refers to an object contained within an anonymous namespace ; if so add an appropriate using directive .
void
cp_scan_for_anonymous_namespaces (const struct symbol *const symbol,
				  struct objfile *const objfile)
{
  if (SYMBOL_DEMANGLED_NAME (symbol) != NULL)
    {
      const char *name = SYMBOL_DEMANGLED_NAME (symbol);
      unsigned int previous_component;
      unsigned int next_component;
      if (!cp_is_anonymous (name))
	return;
      previous_component = 0;
      next_component = cp_find_first_component (name + previous_component);
      while (name[next_component] == ':')
	{
	  if (((next_component - previous_component)
	       == CP_ANONYMOUS_NAMESPACE_LEN)
	      && strncmp (name + previous_component,
			  CP_ANONYMOUS_NAMESPACE_STR,
			  CP_ANONYMOUS_NAMESPACE_LEN) == 0)
	    {
	      int dest_len = (previous_component == 0
			      ? 0 : previous_component - 2);
	      int src_len = next_component;
	      char *dest = alloca (dest_len + 1);
	      char *src = alloca (src_len + 1);
	      memcpy (dest, name, dest_len);
	      memcpy (src, name, src_len);
	      dest[dest_len] = '\0';
	      src[src_len] = '\0';
	      cp_add_using_directive (dest, src, NULL, NULL, NULL,
	                              &objfile->objfile_obstack);
	    }
	  previous_component = next_component + 2;
	  next_component = (previous_component
			    + cp_find_first_component (name
						       + previous_component));
	}
    }
}
void cp_scan_for_anonymous_namespaces ( const struct symbol * const symbol , struct objfile * const objfile ) { if ( SYMBOL_DEMANGLED_NAME ( symbol ) != NULL ) { const char * name = SYMBOL_DEMANGLED_NAME ( symbol ) ; unsigned int previous_component ; unsigned int next_component ; if ( ! cp_is_anonymous ( name ) ) return ; previous_component = 0 ; next_component = cp_find_first_component ( name + previous_component ) ; while ( name [ next_component ] == ' ' ) { if ( ( ( next_component - previous_component ) == CP_ANONYMOUS_NAMESPACE_LEN ) && strncmp ( name + previous_component , CP_ANONYMOUS_NAMESPACE_STR , CP_ANONYMOUS_NAMESPACE_LEN ) == 0 ) { int dest_len = ( previous_component == 0 ? 0 : previous_component - 2 ) ; int src_len = next_component ; char * dest = alloca ( dest_len + 1 ) ; char * src = alloca ( src_len + 1 ) ; memcpy ( dest , name , dest_len ) ; memcpy ( src , name , src_len ) ; dest [ dest_len ] = ' \0 ' ; src [ src_len ] = ' \0 ' ; cp_add_using_directive ( dest , src , NULL , NULL , NULL , & objfile -> objfile_obstack ) ; } previous_component = next_component + 2 ; next_component = ( previous_component + cp_find_first_component ( name + previous_component ) ) ; } } }
Check to see if SYMBOL refers to an object contained within an
anonymous namespace; if so, add an appropriate using directive.
Check to see if SYMBOL refers to an object contained within an anonymous namespace ; if so add an appropriate using directive .
/* Start with a quick-and-dirty check for mention of "(anonymous
	 namespace)".  */ /* We've found a component of the name that's an
		 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.  */ /* The "+ 2" is for the "::".  */