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]
Other format: [Raw text]

Re: Avoid unnecessarily numbered clone symbols


On 20 October 2018 00:26:15 CEST, Michael Ploujnikov <michael.ploujnikov@oracle.com> wrote:
>While working on
>https://gcc.gnu.org/ml/gcc-patches/2018-09/msg00228.html I've
>accumulated a few easy patches.

 
+/* Return decl name IDENTIFIER with string SUFFIX appended.  */
+
+tree
+suffixed_function_name (tree identifier, const char *suffix)
+{
+  const char *name = IDENTIFIER_POINTER (identifier);
+  size_t len = strlen (name);
+  char *prefix;
+
+  prefix = XALLOCAVEC (char, len + strlen (suffix) + 2);
+  memcpy (prefix, name, len);
+  prefix[len] = symbol_table::symbol_suffix_separator ();
+  strcpy (prefix + len + 1, suffix);
+  return get_identifier (prefix);
+}
+

FWIW I think I would phrase this as

char *str = concat (
  IDENTIFIER_POINTER (identifier),
  symbol_table::symbol_suffix_separator (),
  suffix);
  tree ret = get_identifier (str);
  free (str);
  return ret;


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