]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
toplev.c (general_init): Call register dump lang hook.
authorNathan Sidwell <nathan@acm.org>
Fri, 19 May 2017 13:10:36 +0000 (13:10 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Fri, 19 May 2017 13:10:36 +0000 (13:10 +0000)
LANG_HOOK_REGISTER_DUMPS
gcc/
* toplev.c (general_init): Call register dump lang hook.
* doc/invoke.texi: Document -fdump-lang option family.
* dumpfile.c (dump_files): Remove class dump here.
(FIRST_AUTO_NUMBERED_DUMP): Adjust.
* dumpfile.h (tree_dump_index): Remove TDI_class.
* langhooks-def.h (lhd_register_dumps): Declare.
(LANG_HOOKS_REGISTER_DUMPS): Define.
(LANG_HOOKS_INITIALIZER): Add it.
* langhooks.c (lhd_register_dumps): Define.
* langhooks.h (struct lang_hooks): Add register_dumps.
c-family/
* c-opts.c (class_dump_file, class_dump_flags): Delete.
(c_common_parse_file): Remove class dump handling.
(get_dump_info): Likewise.
cp/
* class.c (class_dump_id): Define.
(dump_class_hierarchy, dump_vtable, dump_vtt): Use it.
* cp-objcp-common.c (cp_register_dumps): New.
* cp-objcp-common.h (cp_register_dumps): Declare.
(LANG_HOOKS_REGISTER_DUMPS): Override.
* cp-tree.h (class_dump_id): Declare.
testsuite/
* g++.dg/inherit/covariant7.C: Adjust.

From-SVN: r248271

17 files changed:
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-opts.c
gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/cp-objcp-common.c
gcc/cp/cp-objcp-common.h
gcc/cp/cp-tree.h
gcc/doc/invoke.texi
gcc/dumpfile.c
gcc/dumpfile.h
gcc/langhooks-def.h
gcc/langhooks.c
gcc/langhooks.h
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/inherit/covariant7.C
gcc/toplev.c

index b11d20dee41759bf09902ba78c41dfcfa7912801..44ff6176e90650807efbd759e2f4eff4ba1669e8 100644 (file)
@@ -1,3 +1,17 @@
+2017-05-19  Nathan Sidwell  <nathan@acm.org>
+
+       LANG_HOOK_REGISTER_DUMPS
+       * toplev.c (general_init): Call register dump lang hook.
+       * doc/invoke.texi: Document -fdump-lang option family.
+       * dumpfile.c (dump_files): Remove class dump here.
+       (FIRST_AUTO_NUMBERED_DUMP): Adjust.
+       * dumpfile.h (tree_dump_index): Remove TDI_class.
+       * langhooks-def.h (lhd_register_dumps): Declare.
+       (LANG_HOOKS_REGISTER_DUMPS): Define.
+       (LANG_HOOKS_INITIALIZER): Add it.
+       * langhooks.c (lhd_register_dumps): Define.
+       * langhooks.h (struct lang_hooks): Add register_dumps.
+
 2017-05-19  Nathan Sidwell  <nathan@acm.org>
 
        * context.h (context::set_passes): New.
index 4ce70e4d67a35996d5c503e5e528eb1973da9ddd..5a842bd74d78e44b32dd2548ece9cbc3923c3b39 100644 (file)
@@ -1,3 +1,9 @@
+2017-05-19  Nathan Sidwell  <nathan@acm.org>
+
+       * c-opts.c (class_dump_file, class_dump_flags): Delete.
+       (c_common_parse_file): Remove class dump handling.
+       (get_dump_info): Likewise.
+
 2017-05-19  Richard Biener  <rguenther@suse.de>
 
        PR c++/80593
index d294c37bdbad6e2cfc7b8253a295f3e7ea0cf48b..be4478f5ce99758b57ed3327d5c61120729aeb21 100644 (file)
@@ -102,8 +102,6 @@ static size_t include_cursor;
 /* Dump files/flags to use during parsing.  */
 static FILE *original_dump_file = NULL;
 static dump_flags_t original_dump_flags;
-static FILE *class_dump_file = NULL;
-static dump_flags_t class_dump_flags;
 
 /* Whether any standard preincluded header has been preincluded.  */
 static bool done_preinclude;
@@ -1098,10 +1096,9 @@ c_common_parse_file (void)
   for (;;)
     {
       c_finish_options ();
-      /* Open the dump files to use for the original and class dump output
+      /* Open the dump file to use for the original dump output
          here, to be used during parsing for the current file.  */
       original_dump_file = dump_begin (TDI_original, &original_dump_flags);
-      class_dump_file = dump_begin (TDI_class, &class_dump_flags);
       pch_init ();
       push_file_scope ();
       c_parse_file ();
@@ -1120,11 +1117,6 @@ c_common_parse_file (void)
           dump_end (TDI_original, original_dump_file);
           original_dump_file = NULL;
         }
-      if (class_dump_file)
-        {
-          dump_end (TDI_class, class_dump_file);
-          class_dump_file = NULL;
-        }
       /* If an input file is missing, abandon further compilation.
         cpplib has issued a diagnostic.  */
       if (!this_input_filename)
@@ -1135,20 +1127,14 @@ c_common_parse_file (void)
 }
 
 /* Returns the appropriate dump file for PHASE to dump with FLAGS.  */
+
 FILE *
 get_dump_info (int phase, dump_flags_t *flags)
 {
-  gcc_assert (phase == TDI_original || phase == TDI_class);
-  if (phase == TDI_original)
-    {
-      *flags = original_dump_flags;
-      return original_dump_file;
-    }
-  else
-    {
-      *flags = class_dump_flags;
-      return class_dump_file;
-    }
+  gcc_assert (phase == TDI_original);
+
+  *flags = original_dump_flags;
+  return original_dump_file;
 }
 
 /* Common finish hook for the C, ObjC and C++ front ends.  */
index e903bfd1d715566d4d6f9af8decaec7985b0caeb..09c82699b463fb62c3436f9a1426ff1a8d6a2055 100644 (file)
@@ -1,3 +1,12 @@
+2017-05-19  Nathan Sidwell  <nathan@acm.org>
+
+       * class.c (class_dump_id): Define.
+       (dump_class_hierarchy, dump_vtable, dump_vtt): Use it.
+       * cp-objcp-common.c (cp_register_dumps): New.
+       * cp-objcp-common.h (cp_register_dumps): Declare.
+       (LANG_HOOKS_REGISTER_DUMPS): Override.
+       * cp-tree.h (class_dump_id): Declare.
+
 2017-05-18  Nathan Sidwell  <nathan@acm.org>
 
        * cp-tree.h (OVL_ARG_DEPENDENT): Delete.
index 6f3f3e6eea93faeb01e4b9b34b2f4bbbcf52dd65..c0eb945b385db2996167b2b4a4f51a572cf3fc54 100644 (file)
@@ -37,6 +37,9 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimplify.h"
 #include "intl.h"
 
+/* Id for dumping the class hierarchy.  */
+int class_dump_id;
 /* The number of nested classes being processed.  If we are not in the
    scope of any class, this is zero.  */
 
@@ -8914,11 +8917,10 @@ static void
 dump_class_hierarchy (tree t)
 {
   dump_flags_t flags;
-  FILE *stream = get_dump_info (TDI_class, &flags);
-
-  if (stream)
+  if (FILE *stream = dump_begin (class_dump_id, &flags))
     {
       dump_class_hierarchy_1 (stream, flags, t);
+      dump_end (class_dump_id, stream);
     }
 }
 
@@ -8948,7 +8950,7 @@ static void
 dump_vtable (tree t, tree binfo, tree vtable)
 {
   dump_flags_t flags;
-  FILE *stream = get_dump_info (TDI_class, &flags);
+  FILE *stream = dump_begin (class_dump_id, &flags);
 
   if (!stream)
     return;
@@ -8971,13 +8973,15 @@ dump_vtable (tree t, tree binfo, tree vtable)
       dump_array (stream, vtable);
       fprintf (stream, "\n");
     }
+
+  dump_end (class_dump_id, stream);
 }
 
 static void
 dump_vtt (tree t, tree vtt)
 {
   dump_flags_t flags;
-  FILE *stream = get_dump_info (TDI_class, &flags);
+  FILE *stream = dump_begin (class_dump_id, &flags);
 
   if (!stream)
     return;
@@ -8989,6 +8993,8 @@ dump_vtt (tree t, tree vtt)
       dump_array (stream, vtt);
       fprintf (stream, "\n");
     }
+
+  dump_end (class_dump_id, stream);
 }
 
 /* Dump a function or thunk and its thunkees.  */
index 86279780e42ebb4aed826842392a1d9060644db9..40e9ccbe5104e4b2b0a7e140dab005891e491f9a 100644 (file)
@@ -352,6 +352,15 @@ cp_pushdecl (tree decl)
   return pushdecl (decl);
 }
 
+/* Register c++-specific dumps.  */
+
+void
+cp_register_dumps (gcc::dump_manager *dumps)
+{
+  class_dump_id = dumps->dump_register
+    (".class", "lang-class", "lang-class", DK_lang, OPTGROUP_NONE, false);
+}
+
 void
 cp_common_init_ts (void)
 {
index 0d752a7a20a54f455d85c46288a089c0d563ff02..10fcdf324fc4881e61950adfa370402e9e8b00d2 100644 (file)
@@ -33,6 +33,7 @@ extern void cp_common_init_ts (void);
 extern tree cp_unit_size_without_reusable_padding (tree);
 extern tree cp_get_global_decls ();
 extern tree cp_pushdecl (tree);
+extern void cp_register_dumps (gcc::dump_manager *);
 
 /* Lang hooks that are shared between C++ and ObjC++ are defined here.  Hooks
    specific to C++ or ObjC++ go in cp/cp-lang.c and objcp/objcp-lang.c,
@@ -56,6 +57,8 @@ extern tree cp_pushdecl (tree);
 #define LANG_HOOKS_INIT_OPTIONS c_common_init_options
 #undef LANG_HOOKS_INITIALIZE_DIAGNOSTICS
 #define LANG_HOOKS_INITIALIZE_DIAGNOSTICS cxx_initialize_diagnostics
+#undef LANG_HOOKS_REGISTER_DUMPS
+#define LANG_HOOKS_REGISTER_DUMPS cp_register_dumps
 #undef LANG_HOOKS_HANDLE_OPTION
 #define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
 #undef LANG_HOOKS_HANDLE_FILENAME
index 82bb965010682c94c9a57cf50278cac29c6be9f5..e9e4b0061103ae31cdf8a903252578d12d1eda64 100644 (file)
@@ -5749,6 +5749,9 @@ concept_template_p (tree t)
    e.g  "int f(void)".  */
 extern cp_parameter_declarator *no_parameters;
 
+/* Various dump ids.  */
+extern int class_dump_id;
+
 /* in call.c */
 extern bool check_dtor_name                    (tree, tree);
 int magic_varargs_p                            (tree);
index 715830a1a438c15b2fb45ac2fe8db7a3022f6f04..4b7304ec02585bba986e6d25c035764439cb3e73 100644 (file)
@@ -544,6 +544,9 @@ Objective-C and Objective-C++ Dialects}.
 -fdump-final-insns@r{[}=@var{file}@r{]}
 -fdump-ipa-all  -fdump-ipa-cgraph  -fdump-ipa-inline @gol
 -fdump-lang-all @gol
+-fdump-lang-@var{switch} @gol
+-fdump-lang-@var{switch}-@var{options} @gol
+-fdump-lang-@var{switch}-@var{options}=@var{filename} @gol
 -fdump-passes @gol
 -fdump-rtl-@var{pass}  -fdump-rtl-@var{pass}=@var{filename} @gol
 -fdump-statistics @gol
@@ -12940,16 +12943,6 @@ When doing debugging dumps (see @option{-d} option above), suppress
 instruction numbers for the links to the previous and next instructions
 in a sequence.
 
-@item -fdump-class-hierarchy @r{(C++ only)}
-@itemx -fdump-class-hierarchy-@var{options} @r{(C++ only)}
-@opindex fdump-class-hierarchy
-Dump a representation of each class's hierarchy and virtual function
-table layout to a file.  The file name is made by appending
-@file{.class} to the source file name, and the file is created in the
-same directory as the output file.  If the @samp{-@var{options}} form
-is used, @var{options} controls the details of the dump as described
-for the @option{-fdump-tree} options.
-
 @item -fdump-ipa-@var{switch}
 @opindex fdump-ipa
 Control the dumping at various stages of inter-procedural analysis
@@ -12972,8 +12965,26 @@ Dump after function inlining.
 @end table
 
 @item -fdump-lang-all
+@itemx -fdump-lang-@var{switch}
+@itemx -fdump-lang-@var{switch}-@var{options}
+@itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
 @opindex fdump-lang-all
-Control the dumping of language-specific information.
+@opindex fdump-lang
+Control the dumping of language-specific information.  The @var{options}
+and @var{filename} portions behave as described in the
+`@option{-fdump-tree} option.  The following @var{switch} values are
+accepted:
+
+@table @samp
+@item all
+
+Enable all language-specific dumps.
+
+@item class
+Dump class hierarchy information.  Virtual table information is emitted
+unless '@option{slim}' is specified.  This option is applicable to C++ only.
+
+@end table
 
 @item -fdump-passes
 @opindex fdump-passes
index d5a0e70cf6641462886ff58a65b1ef55b5684c6a..45e47b2d4e86c02d816af1bcca816391128088e3 100644 (file)
@@ -74,11 +74,10 @@ static struct dump_file_info dump_files[TDI_end] =
   dump_file_info (".type-inheritance", "ipa-type-inheritance", DK_ipa, 0),
   dump_file_info (".ipa-clones", "ipa-clones", DK_ipa, 0),
   dump_file_info (".tu", "translation-unit", DK_lang, 1),
-  dump_file_info (".class", "class-hierarchy", DK_lang, 2),
   dump_file_info (".original", "tree-original", DK_tree, 3),
   dump_file_info (".gimple", "tree-gimple", DK_tree, 4),
   dump_file_info (".nested", "tree-nested", DK_tree, 5),
-#define FIRST_AUTO_NUMBERED_DUMP 6
+#define FIRST_AUTO_NUMBERED_DUMP 4
 
   dump_file_info (NULL, "lang-all", DK_lang, 0),
   dump_file_info (NULL, "tree-all", DK_tree, 0),
index bec2fa2188f0fe3e155bfd91e019de076b91a3ba..1f7c8de682b73e78d3ba5c20bbc47d87549bc4c0 100644 (file)
@@ -31,7 +31,6 @@ enum tree_dump_index
   TDI_inheritance,             /* dump type inheritance graph.  */
   TDI_clones,                  /* dump IPA cloning decisions.  */
   TDI_tu,                      /* dump the whole translation unit.  */
-  TDI_class,                   /* dump class hierarchy.  */
   TDI_original,                        /* dump each function before optimizing it */
   TDI_generic,                 /* dump each function after genericizing it */
   TDI_nested,                  /* dump each function after unnesting it */
index eb680848f6a50dd0770e4b8d6f61ae897e151cca..ea2006ccec5c6aa2052e87a3b9c7eb4b4c61dc8c 100644 (file)
@@ -39,6 +39,7 @@ extern void lhd_do_nothing (void);
 extern void lhd_do_nothing_t (tree);
 extern void lhd_do_nothing_f (struct function *);
 extern tree lhd_pass_through_t (tree);
+extern void lhd_register_dumps (gcc::dump_manager *);
 extern bool lhd_post_options (const char **);
 extern alias_set_type lhd_get_alias_set (tree);
 extern tree lhd_return_null_tree (tree);
@@ -97,6 +98,7 @@ extern int lhd_type_dwarf_attribute (const_tree, int);
 #define LANG_HOOKS_INIT_OPTIONS_STRUCT hook_void_gcc_optionsp
 #define LANG_HOOKS_INIT_OPTIONS                lhd_init_options
 #define LANG_HOOKS_INITIALIZE_DIAGNOSTICS lhd_initialize_diagnostics
+#define LANG_HOOKS_REGISTER_DUMPS      lhd_register_dumps
 #define LANG_HOOKS_COMPLAIN_WRONG_LANG_P lhd_complain_wrong_lang_p
 #define LANG_HOOKS_HANDLE_OPTION       lhd_handle_option
 #define LANG_HOOKS_POST_OPTIONS                lhd_post_options
@@ -294,6 +296,7 @@ extern void lhd_end_section (void);
   LANG_HOOKS_INIT_OPTIONS_STRUCT, \
   LANG_HOOKS_INIT_OPTIONS, \
   LANG_HOOKS_INITIALIZE_DIAGNOSTICS, \
+  LANG_HOOKS_REGISTER_DUMPS, \
   LANG_HOOKS_COMPLAIN_WRONG_LANG_P, \
   LANG_HOOKS_HANDLE_OPTION, \
   LANG_HOOKS_POST_OPTIONS, \
index dc19db71db247f5d6a1cf5e416d0a620b9a59b56..c54b790f0cc5eead31e63c47d94437ee3839af38 100644 (file)
@@ -322,6 +322,12 @@ lhd_initialize_diagnostics (diagnostic_context *ctx ATTRIBUTE_UNUSED)
 {
 }
 
+/* Called to register dumps.  */
+void
+lhd_register_dumps (gcc::dump_manager *)
+{
+}
+
 /* Called to perform language-specific options initialization.  */
 void
 lhd_init_options (unsigned int decoded_options_count ATTRIBUTE_UNUSED,
index 2a2ef8affef54983bad0661bed51e53525acf78f..b2f0f922b8921ea901e79a5c84b2fccdfe88f42a 100644 (file)
@@ -326,6 +326,9 @@ struct lang_hooks
      global diagnostic context structure.  */
   void (*initialize_diagnostics) (diagnostic_context *);
 
+  /* Register language-specific dumps.  */
+  void (*register_dumps) (gcc::dump_manager *);
+
   /* Return true if a warning should be given about option OPTION,
      which is for the wrong language, false if it should be quietly
      ignored.  */
index 01319bdcedae5822382222eda60845beb2780597..5f0fe80684ec8105372e9395d8f909233e029483 100644 (file)
@@ -1,3 +1,7 @@
+2017-05-19  Nathan Sidwell  <nathan@acm.org>
+
+       * g++.dg/inherit/covariant7.C: Adjust.
+
 2017-05-19  Prakhar Bahuguna  <prakhar.bahuguna@arm.com>
 
        * gcc.target/arm/tls-disable-literal-pool.c: Change
index b8c5c8e717e9dad049d76f8c53d9d62f7d2f3ec9..73663bd6ebe790c6f42a58359986b8fbe440eed8 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-prune-output "direct base" }
-// { dg-options "-fdump-class-hierarchy" }
+// { dg-options "-fdump-lang-class" }
 
 // Copyright (C) 2002 Free Software Foundation, Inc.
 // Contributed by Nathan Sidwell 27 Dec 2002 <nathan@codesourcery.com>
index 814193a4509749579d8a78702ac0c904840a6401..425315c8b5ef97e8005b38d955fb9be74fd5ef23 100644 (file)
@@ -1158,6 +1158,10 @@ general_init (const char *argv0, bool init_signals)
      dump manager.  */
   g = new gcc::context ();
 
+  /* Allow languages to register their dumps before the optimization
+     passes.  */
+  lang_hooks.register_dumps (g->get_dumps ());
+
   /* Create the passes.  */
   g->set_passes (new gcc::pass_manager (g));