This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Remove gratuitous demangler differences


This patch removes differences between the old and new demangler that
really aren't necessary (unsigned vs unsigned int, () vs (void)). It also
adds a DMGL_VERBOSE flag that can be passed to cp-demangle to set
flag_verbose.

Index: include/demangle.h
===================================================================
RCS file: /cvs/src/src/include/demangle.h,v
retrieving revision 1.5
diff -c -3 -p -r1.5 demangle.h
*** demangle.h	2001/02/02 18:58:10	1.5
--- demangle.h	2001/02/10 18:39:48
***************
*** 28,33 ****
--- 28,34 ----
  #define DMGL_PARAMS	 (1 << 0)	/* Include function args */
  #define DMGL_ANSI	 (1 << 1)	/* Include const, volatile, etc */
  #define DMGL_JAVA	 (1 << 2)	/* Demangle as Java rather than C++. */
+ #define DMGL_VERBOSE     (1 << 3)       /* For v3 abi, set verbose flag */

  #define DMGL_AUTO	 (1 << 8)
  #define DMGL_GNU	 (1 << 9)
*************** cplus_demangle_name_to_style PARAMS ((co
*** 122,128 ****

  /* V3 ABI demangling entry points, defined in cp-demangle.c.  */
  extern char*
! cplus_demangle_v3 PARAMS ((const char* mangled));

  extern char*
  java_demangle_v3 PARAMS ((const char* mangled));
--- 123,129 ----

  /* V3 ABI demangling entry points, defined in cp-demangle.c.  */
  extern char*
! cplus_demangle_v3 PARAMS ((const char* mangled, int));

  extern char*
  java_demangle_v3 PARAMS ((const char* mangled));
Index: libiberty/cp-demangle.c
===================================================================
RCS file: /cvs/src/src/libiberty/cp-demangle.c,v
retrieving revision 1.8
diff -c -3 -p -r1.8 cp-demangle.c
*** cp-demangle.c	2001/02/02 18:58:39	1.8
--- cp-demangle.c	2001/02/10 18:39:49
***************
*** 46,52 ****
  #include "libiberty.h"
  #include "dyn-string.h"
  #include "demangle.h"
-
  /* If CP_DEMANGLE_DEBUG is defined, a trace of the grammar evaluation,
     and other debugging output, will be generated. */
  #ifdef CP_DEMANGLE_DEBUG
--- 46,51 ----
*************** demangle_type_ptr (dm, insert_pos, subst
*** 2100,2110 ****
        /* Demangle the underlying type.  */
        RETURN_IF_ERROR (demangle_type_ptr (dm, insert_pos,
  					  substitution_start));
        /* Insert an asterisk where we're told to; it doesn't
  	 necessarily go at the end.  If we're doing Java style output,
  	 there is no pointer symbol.  */
        if (dm->style != DMGL_JAVA)
! 	RETURN_IF_ERROR (result_insert_char (dm, *insert_pos, '*'));
        /* The next (outermost) pointer or reference character should go
  	 after this one.  */
        ++(*insert_pos);
--- 2099,2110 ----
        /* Demangle the underlying type.  */
        RETURN_IF_ERROR (demangle_type_ptr (dm, insert_pos,
  					  substitution_start));
+
        /* Insert an asterisk where we're told to; it doesn't
  	 necessarily go at the end.  If we're doing Java style output,
  	 there is no pointer symbol.  */
        if (dm->style != DMGL_JAVA)
! 	RETURN_IF_ERROR (result_insert (dm, *insert_pos, " *"));
        /* The next (outermost) pointer or reference character should go
  	 after this one.  */
        ++(*insert_pos);
*************** demangle_type_ptr (dm, insert_pos, subst
*** 2118,2124 ****
  					  substitution_start));
        /* Insert an ampersand where we're told to; it doesn't
  	 necessarily go at the end.  */
!       RETURN_IF_ERROR (result_insert_char (dm, *insert_pos, '&'));
        /* The next (outermost) pointer or reference character should go
  	 after this one.  */
        ++(*insert_pos);
--- 2118,2124 ----
  					  substitution_start));
        /* Insert an ampersand where we're told to; it doesn't
  	 necessarily go at the end.  */
!       RETURN_IF_ERROR (result_insert (dm, *insert_pos, " &"));
        /* The next (outermost) pointer or reference character should go
  	 after this one.  */
        ++(*insert_pos);
*************** static const char *const builtin_type_na
*** 2460,2466 ****
    "__float128",               /* g */
    "unsigned char",            /* h */
    "int",                      /* i */
!   "unsigned",                 /* j */
    NULL,                       /* k */
    "long",                     /* l */
    "unsigned long",            /* m */
--- 2460,2466 ----
    "__float128",               /* g */
    "unsigned char",            /* h */
    "int",                      /* i */
!   "unsigned int",             /* j */
    NULL,                       /* k */
    "long",                     /* l */
    "unsigned long",            /* m */
*************** demangle_bare_function_type (dm, return_
*** 2693,2712 ****
  	}
        else
  	{
! 	  /* Skip `void' parameter types.  One should only occur as
! 	     the only type in a parameter list; in that case, we want
! 	     to print `foo ()' instead of `foo (void)'.  */
! 	  if (peek_char (dm) == 'v')
! 	    /* Consume the v.  */
! 	    advance_char (dm);
! 	  else
! 	    {
! 	      /* Separate parameter types by commas.  */
! 	      if (sequence > 0)
! 		RETURN_IF_ERROR (result_add (dm, ", "));
! 	      /* Demangle the type.  */
! 	      RETURN_IF_ERROR (demangle_type (dm));
! 	    }
  	}

        ++sequence;
--- 2693,2703 ----
  	}
        else
  	{
! 	  /* Separate parameter types by commas.  */
! 	  if (sequence > 0)
! 	    RETURN_IF_ERROR (result_add (dm, ", "));
! 	  /* Demangle the type.  */
! 	  RETURN_IF_ERROR (demangle_type (dm));
  	}

        ++sequence;
*************** cp_demangle (name, result, style)
*** 3450,3455 ****
--- 3441,3450 ----
  {
    status_t status;
    int length = strlen (name);
+   if (style & DMGL_VERBOSE)
+ 	  flag_verbose = 1;
+   else
+ 	  flag_verbose = 0;

    if (length > 2 && name[0] == '_' && name[1] == 'Z')
      {
*************** __cxa_demangle (mangled_name, output_buf
*** 3646,3653 ****
     If the demangling failes, returns NULL.  */

  char *
! cplus_demangle_v3 (mangled)
       const char* mangled;
  {
    dyn_string_t demangled;
    status_t status;
--- 3641,3649 ----
     If the demangling failes, returns NULL.  */

  char *
! cplus_demangle_v3 (mangled, options)
       const char* mangled;
+      int options;
  {
    dyn_string_t demangled;
    status_t status;
*************** cplus_demangle_v3 (mangled)
*** 3659,3665 ****
    /* Create a dyn_string to hold the demangled name.  */
    demangled = dyn_string_new (0);
    /* Attempt the demangling.  */
!   status = cp_demangle ((char *) mangled, demangled, 0);

    if (STATUS_NO_ERROR (status))
      /* Demangling succeeded.  */
--- 3655,3661 ----
    /* Create a dyn_string to hold the demangled name.  */
    demangled = dyn_string_new (0);
    /* Attempt the demangling.  */
!   status = cp_demangle ((char *) mangled, demangled, options);

    if (STATUS_NO_ERROR (status))
      /* Demangling succeeded.  */
Index: libiberty/cplus-dem.c
===================================================================
RCS file: /cvs/src/src/libiberty/cplus-dem.c,v
retrieving revision 1.18
diff -c -3 -p -r1.18 cplus-dem.c
*** cplus-dem.c	2001/02/02 18:58:39	1.18
--- cplus-dem.c	2001/02/10 18:39:49
*************** cplus_demangle (mangled, options)
*** 917,923 ****
    /* The V3 ABI demangling is implemented elsewhere.  */
    if (GNU_V3_DEMANGLING || AUTO_DEMANGLING)
      {
!       ret = cplus_demangle_v3 (mangled);
        if (ret || GNU_V3_DEMANGLING)
  	return ret;
      }
--- 917,923 ----
    /* The V3 ABI demangling is implemented elsewhere.  */
    if (GNU_V3_DEMANGLING || AUTO_DEMANGLING)
      {
!       ret = cplus_demangle_v3 (mangled, options);
        if (ret || GNU_V3_DEMANGLING)
  	return ret;
      }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]