FreeBSD/contrib/gcc/cp/mangle.c
/* TOP_LEVEL is true, if this is being called at outermost level of
  mangling. It should be false when mangling a decl appearing in an
  expression within some other mangling.

  <mangled-name>      ::= _Z <encoding>  */
TOP_LEVEL is true, if this is being called at outermost level of
mangling. It should be false when mangling a decl appearing in an
expression within some other mangling.


TOP_LEVEL is true if this is being called at outermost level of mangling . It should be false when mangling a decl appearing in an expression within some other mangling .
static void
write_mangled_name (const tree decl, bool top_level)
{
  MANGLE_TRACE_TREE ("mangled-name", decl);
  if (
      DECL_EXTERN_C_FUNCTION_P (decl)
      && !DECL_OVERLOADED_OPERATOR_P (decl))
    {
    unmangled_name:;
      if (top_level)
	write_string (IDENTIFIER_POINTER (DECL_NAME (decl)));
      else
	{
	  if (abi_version_at_least (2))
	    write_string ("_Z");
	  else
	    G.need_abi_warning = true;
	  write_source_name (DECL_NAME (decl));
	}
    }
  else if (TREE_CODE (decl) == VAR_DECL
	   && DECL_EXTERNAL_LINKAGE_P (decl)
	   && (CP_DECL_CONTEXT (decl) == global_namespace
	       || DECL_EXTERN_C_P (decl)))
    {
      if (top_level || abi_version_at_least (2))
	goto unmangled_name;
      else
	{
	  G.need_abi_warning = true;
	  goto mangled_name;
	}
    }
  else
    {
    mangled_name:;
      write_string ("_Z");
      write_encoding (decl);
      if (DECL_LANG_SPECIFIC (decl)
	  && (DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl)
	      || DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl)))
	write_string (" *INTERNAL* ");
    }
}
static void write_mangled_name ( const tree decl , bool top_level ) { MANGLE_TRACE_TREE ( " " , decl ) ; if ( DECL_EXTERN_C_FUNCTION_P ( decl ) && ! DECL_OVERLOADED_OPERATOR_P ( decl ) ) { unmangled_name : ; if ( top_level ) write_string ( IDENTIFIER_POINTER ( DECL_NAME ( decl ) ) ) ; else { if ( abi_version_at_least ( 2 ) ) write_string ( " " ) ; else G . need_abi_warning = true ; write_source_name ( DECL_NAME ( decl ) ) ; } } else if ( TREE_CODE ( decl ) == VAR_DECL && DECL_EXTERNAL_LINKAGE_P ( decl ) && ( CP_DECL_CONTEXT ( decl ) == global_namespace || DECL_EXTERN_C_P ( decl ) ) ) { if ( top_level || abi_version_at_least ( 2 ) ) goto unmangled_name ; else { G . need_abi_warning = true ; goto mangled_name ; } } else { mangled_name : ; write_string ( " " ) ; write_encoding ( decl ) ; if ( DECL_LANG_SPECIFIC ( decl ) && ( DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P ( decl ) || DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P ( decl ) ) ) write_string ( " " ) ; } }
TOP_LEVEL is true, if this is being called at outermost level of
mangling.
TOP_LEVEL is true if this is being called at outermost level of mangling .
/* The names of `extern "C"' functions are not mangled.  */ /* But overloaded operator names *are* mangled.  */ /* The standard notes: "The <encoding> of an extern "C"
	     function is treated like global-scope data, i.e. as its
	     <source-name> without a type."  We cannot write
	     overloaded operators that way though, because it contains
	     characters invalid in assembler.  */ /* The names of non-static global variables aren't mangled.  */ /* And neither are `extern "C"' variables.  */ /* We need a distinct mangled name for these entities, but
	   we should never actually output it.  So, we append some
	   characters the assembler won't like.  */