http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60761

--- Comment #9 from Martin Jambor <jamborm at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #5)
> 4.8 prints
> 
> t.ii: In function ‘void _Z3fooi.constprop.0()’:
> t.ii:14:8: warning: array subscript is above array bounds [-Warray-bounds]
>      z[i] = i;
>         ^

I think that we can perhaps get closest to that with something like:

pp_string (pp, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (t)));

which prints 

zz.C: In function ‘_Z3fooi.constprop.0’:

by using DECL_NAME instead of DECL_ASSEMBLER_NAME we can get
avoid mangling:

zz.C: In function ‘foo.constprop’:

> 
> does former_clone_of apply recursively? 

I believe that (at least currently) former_clone_of will always be the
original front-end declaration, i.e. the same as DECL_ABSTRACT_ORIGIN,
despite that...

> Thus can we have a clone of a clone?

...yes, the infrastructure allows that, although currently only such
clones are inline clones and thus not posing this problem.

> Is there a way to "pretty-print" the kind of clone?  That is, say
> <clone with foo = 1> for a ipa-cp clone with parameter foo replaced by 1?

Hm, it would require changes elsewhere to do for aggregate
replacements (we'd need to remember the old decl and we remember only
offsets, not expressions), for scalar replacements it is already
apparently quite possible:

diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 454feb5..bb8db31 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -34,6 +34,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "pointer-set.h"
 #include "c-family/c-objc.h"
 #include "ubsan.h"
+#include "cgraph.h"

 #include <new>                    // For placement-new.

@@ -1144,7 +1145,35 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags)
       /* Fall through.  */

     case FUNCTION_DECL:
-      if (! DECL_LANG_SPECIFIC (t))
+      if (DECL_ABSTRACT_ORIGIN (t))
+       {
+         dump_decl (pp, DECL_ABSTRACT_ORIGIN (t), flags);
+         
+         cgraph_node *node = cgraph_get_node (t);
+         if (node && node->clone.tree_map)
+           {
+             struct ipa_replace_map *rmap;
+             unsigned i;
+             bool first = true;
+             pp_string (pp, M_(" <clone with "));
+
+             FOR_EACH_VEC_ELT (*node->clone.tree_map, i, rmap)
+               {
+                 if (first)
+                   first = false;
+                 else 
+                   pp_string (pp, (", "));
+
+                 dump_expr (pp, rmap->new_tree, flags);
+                 pp_string (pp, M_(" for "));
+                 dump_expr (pp, rmap->old_tree, flags);
+               }
+             pp_string (pp, ">");
+           }
+         else
+           pp_string (pp, M_(" <clone>"));
+       }
+      else if (! DECL_LANG_SPECIFIC (t))
        pp_string (pp, M_("<built-in>"));
       else if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t))
        dump_global_iord (pp, t);

gives:

zz.C: In function ‘void foo(int) <clone with 4 for s>’:

Reply via email to