Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4262)

Issue 5902061: [pph] Adjust mangling when emitting PPH

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years ago by Diego Novillo
Modified:
12 years ago
Reviewers:
CC:
Lawrence Crowl, gcc-patches_gcc.gnu.org
Visibility:
Public.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+44 lines, -2 lines) Patch
M gcc/cp/ChangeLog.pph View 1 chunk +6 lines, -0 lines 0 comments Download
M gcc/cp/mangle.c View 2 chunks +38 lines, -2 lines 0 comments Download

Messages

Total messages: 1
Diego Novillo
12 years ago (2012-03-26 16:10:39 UTC) #1
Mangle TRAIT_EXPR and CONST_DECLs in template parameters.

We use the mangler to generate unique strings to represent types and symbols
that need to be merged.  However, the C++ mangler does not handle all
possible combinations.  This patch works around this problem by using
a combination of the pretty printer and the mangler.  This only works
when a PPH image is being generated, so it does not affect the
standard mangler.

2012-03-25   Diego Novillo  <dnovillo@google.com>

	* mangle.c (write_expression): Handle TRAIT_EXPR when PPH is enabled.
	(write_template_arg_literal): Handle CONST_DECLs that do not have
	a constant DECL_INITIAL when PPH is enabled.
---
 gcc/cp/ChangeLog.pph |    6 ++++++
 gcc/cp/mangle.c      |   39 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletions(-)

diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph
index 2c64375..1cf90b4 100644
--- a/gcc/cp/ChangeLog.pph
+++ b/gcc/cp/ChangeLog.pph
@@ -1,3 +1,9 @@
+2012-03-25   Diego Novillo  <dnovillo@google.com>
+
+	* mangle.c (write_expression): Handle TRAIT_EXPR when PPH is enabled.
+	(write_template_arg_literal): Handle CONST_DECLs that do not have
+	a constant DECL_INITIAL when PPH is enabled.
+
 2012-03-23   Diego Novillo  <dnovillo@google.com>
 
 	* name-lookup.c (pph_set_identifier_binding): If DECL is a USING_DECL,
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index a54200a..51ed8c5 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -2754,6 +2754,30 @@ write_expression (tree expr)
     {
       write_unqualified_id (dependent_name (expr));
     }
+  else if (TREE_CODE (expr) == TRAIT_EXPR)
+    {
+      /* FIXME pph.  This is almost certainly wrong as a mangled
+	 representation.
+
+	 We use the mangler to generate unique strings to represent
+	 types and symbols that need to be merged.  The C++ mangler
+	 does not handle ALL possible combinations, so we work around
+	 it by using the pretty printer.  We are not trying to
+	 generate a valid mangled name, but any string that will allow
+	 us to do merging.  */
+      gcc_assert (pph_writer_enabled_p ());
+      if (TRAIT_EXPR_TYPE1 (expr))
+	write_type (TRAIT_EXPR_TYPE1 (expr));
+      else
+	write_string("<nil>");
+      if (TRAIT_EXPR_TYPE2 (expr))
+	write_type (TRAIT_EXPR_TYPE2 (expr));
+      else
+	write_string("<nil>");
+      write_number ((unsigned HOST_WIDE_INT) TRAIT_EXPR_KIND (expr),
+		    /*unsigned_p*/ 1,
+		    /*base*/ 16);
+    }
   else
     {
       int i, len;
@@ -2914,7 +2938,20 @@ write_template_arg_literal (const tree value)
     switch (TREE_CODE (value))
       {
       case CONST_DECL:
-	write_integer_cst (value);
+	if (CONSTANT_CLASS_P (DECL_INITIAL (value)))
+	  write_integer_cst (value);
+	else
+	  {
+	    /* FIXME pph - We use the mangler to generate unique
+	       strings to represent types and symbols that need
+	       to be merged.  The C++ mangler does not handle
+	       ALL possible combinations, so we work around it by
+	       using the pretty printer.  We are not trying to
+	       generate a valid mangled name, but any string that will
+	       allow us to do merging.  */
+	    gcc_assert (pph_writer_enabled_p ());
+	    write_string (cxx_printable_name (value, 2));
+	  }
 	break;
 
       case INTEGER_CST:
-- 
1.7.7.3


--
This patch is available for review at http://codereview.appspot.com/5902061
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b