public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pushed] diagnostics: make m_lang_mask private
@ 2023-11-16 13:36 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2023-11-16 13:36 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

No functional change intended.

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r14-5530-g4547c271c455dc.

gcc/ChangeLog:
	* diagnostic.cc (diagnostic_context::set_option_hooks): Add
	"lang_mask" param.
	* diagnostic.h (diagnostic_context::option_enabled_p): Update for
	move of m_lang_mask.
	(diagnostic_context::set_option_hooks): Add "lang_mask" param.
	(diagnostic_context::get_lang_mask): New.
	(diagnostic_context::m_lang_mask): Move into m_option_callbacks,
	thus making private.
	* lto-wrapper.cc (main): Update for new lang_mask param of
	set_option_hooks.
	* toplev.cc (init_asm_output): Use get_lang_mask.
	(general_init): Move initialization of global_dc's lang_mask to
	new lang_mask param of set_option_hooks.
---
 gcc/diagnostic.cc  |  4 +++-
 gcc/diagnostic.h   | 16 +++++++++++-----
 gcc/lto-wrapper.cc |  3 ++-
 gcc/toplev.cc      |  6 +++---
 4 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index eb0df6890564..b4ebcd29457c 100644
--- a/gcc/diagnostic.cc
+++ b/gcc/diagnostic.cc
@@ -423,12 +423,14 @@ diagnostic_context::
 set_option_hooks (diagnostic_option_enabled_cb option_enabled_cb,
 		  void *option_state,
 		  diagnostic_make_option_name_cb make_option_name_cb,
-		  diagnostic_make_option_url_cb make_option_url_cb)
+		  diagnostic_make_option_url_cb make_option_url_cb,
+		  unsigned lang_mask)
 {
   m_option_callbacks.m_option_enabled_cb = option_enabled_cb;
   m_option_callbacks.m_option_state = option_state;
   m_option_callbacks.m_make_option_name_cb = make_option_name_cb;
   m_option_callbacks.m_make_option_url_cb = make_option_url_cb;
+  m_option_callbacks.m_lang_mask = lang_mask;
 }
 
 void
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index db61b0e27477..dbf972d25875 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -506,7 +506,7 @@ public:
       return true;
     return m_option_callbacks.m_option_enabled_cb
       (option_index,
-       m_lang_mask,
+       m_option_callbacks.m_lang_mask,
        m_option_callbacks.m_option_state);
   }
 
@@ -532,7 +532,13 @@ public:
   set_option_hooks (diagnostic_option_enabled_cb option_enabled_cb,
 		    void *option_state,
 		    diagnostic_make_option_name_cb make_option_name_cb,
-		    diagnostic_make_option_url_cb make_option_url_cb);
+		    diagnostic_make_option_url_cb make_option_url_cb,
+		    unsigned lang_mask);
+
+  unsigned get_lang_mask () const
+  {
+    return m_option_callbacks.m_lang_mask;
+  }
 
 private:
   bool includes_seen_p (const line_map_ordinary *map);
@@ -673,6 +679,9 @@ private:
        is available.  May be passed 0 as well as the index of a
        particular option.  */
     diagnostic_make_option_url_cb m_make_option_url_cb;
+
+    /* A copy of lang_hooks.option_lang_mask ().  */
+    unsigned m_lang_mask;
   } m_option_callbacks;
 
   /* An optional hook for adding URLs to quoted text strings in
@@ -698,9 +707,6 @@ private:
   int m_lock;
 
 public:
-  /* A copy of lang_hooks.option_lang_mask ().  */
-  unsigned m_lang_mask;
-
   bool m_inhibit_notes_p;
 
   diagnostic_source_printing_options m_source_printing;
diff --git a/gcc/lto-wrapper.cc b/gcc/lto-wrapper.cc
index 7c76635ef213..7b01ecc2d889 100644
--- a/gcc/lto-wrapper.cc
+++ b/gcc/lto-wrapper.cc
@@ -2149,7 +2149,8 @@ main (int argc, char *argv[])
   global_dc->set_option_hooks (nullptr,
 			       nullptr,
 			       nullptr,
-			       get_option_url);
+			       get_option_url,
+			       0);
 
   if (atexit (lto_wrapper_cleanup) != 0)
     fatal_error (input_location, "%<atexit%> failed");
diff --git a/gcc/toplev.cc b/gcc/toplev.cc
index ae2f3d52602b..8c3fcd337bee 100644
--- a/gcc/toplev.cc
+++ b/gcc/toplev.cc
@@ -715,7 +715,7 @@ init_asm_output (const char *name)
 		     "cannot open %qs for writing: %m", asm_file_name);
     }
 
-  if (!flag_syntax_only && !(global_dc->m_lang_mask & CL_LTODump))
+  if (!flag_syntax_only && !(global_dc->get_lang_mask () & CL_LTODump))
     {
       targetm.asm_out.file_start ();
 
@@ -1020,7 +1020,6 @@ general_init (const char *argv0, bool init_signals)
   /* Initialize the diagnostics reporting machinery, so option parsing
      can give warnings and errors.  */
   diagnostic_initialize (global_dc, N_OPTS);
-  global_dc->m_lang_mask = lang_hooks.option_lang_mask ();
   /* Set a default printer.  Language specific initializations will
      override it later.  */
   tree_diagnostics_defaults (global_dc);
@@ -1048,7 +1047,8 @@ general_init (const char *argv0, bool init_signals)
   global_dc->set_option_hooks (option_enabled,
 			       &global_options,
 			       option_name,
-			       get_option_url);
+			       get_option_url,
+			       lang_hooks.option_lang_mask ());
   global_dc->set_urlifier (make_gcc_urlifier ());
 
   if (init_signals)
-- 
2.26.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-16 13:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-16 13:36 [pushed] diagnostics: make m_lang_mask private David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).