From 1557bac992faf6719a27edc68958a97bcb9e6929 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 17 Jul 2025 09:00:18 -0400
Subject: [PATCH 24/41] {needs ChangeLog} diagnostic-macro-unwinding.{cc,h} ->
 diagnostics/macro-unwinding.{cc,h}

---
 gcc/Makefile.in                                    |  2 +-
 gcc/c-family/c-opts.cc                             |  4 ++--
 .../macro-unwinding.cc}                            | 13 +++++++++----
 .../macro-unwinding.h}                             | 14 +++++++++-----
 gcc/diagnostics/paths-output.cc                    |  2 +-
 5 files changed, 22 insertions(+), 13 deletions(-)
 rename gcc/{diagnostic-macro-unwinding.cc => diagnostics/macro-unwinding.cc} (96%)
 rename gcc/{diagnostic-macro-unwinding.h => diagnostics/macro-unwinding.h} (74%)

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 01e6056f91a4..fa68c6d1480f 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1853,13 +1853,13 @@ OBJS = \
 # no target dependencies.
 OBJS-libcommon = diagnostic-spec.o diagnostic.o diagnostic-color.o \
 	diagnostic-global-context.o \
-	diagnostic-macro-unwinding.o \
 	diagnostics/digraphs.o \
 	diagnostics/edit-context.o \
 	diagnostics/output-spec.o \
 	diagnostics/html-sink.o \
 	diagnostics/sarif-sink.o \
 	diagnostics/text-sink.o \
+	diagnostics/macro-unwinding.o \
 	diagnostics/paths.o \
 	diagnostics/paths-output.o \
 	diagnostics/source-printing.o \
diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index 4ecbc4e18ad4..bc3a72c87c1a 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -32,7 +32,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "flags.h"
 #include "toplev.h"
 #include "langhooks.h"
-#include "diagnostic-macro-unwinding.h" /* for virt_loc_aware_diagnostic_finalizer */
+#include "diagnostics/macro-unwinding.h" /* for virt_loc_aware_diagnostic_finalizer */
 #include "intl.h"
 #include "cppdefault.h"
 #include "incpath.h"
@@ -182,7 +182,7 @@ c_diagnostic_text_finalizer (diagnostics::text_sink &text_output,
 			 diagnostic->richloc, diagnostic->kind, pp);
   /* By default print macro expansion contexts in the diagnostic
      finalizer -- for tokens resulting from macro expansion.  */
-  virt_loc_aware_diagnostic_finalizer (text_output, diagnostic);
+  diagnostics::virt_loc_aware_text_finalizer (text_output, diagnostic);
   pp_set_prefix (pp, saved_prefix);
   pp_flush (pp);
 }
diff --git a/gcc/diagnostic-macro-unwinding.cc b/gcc/diagnostics/macro-unwinding.cc
similarity index 96%
rename from gcc/diagnostic-macro-unwinding.cc
rename to gcc/diagnostics/macro-unwinding.cc
index 765060684041..184256937d35 100644
--- a/gcc/diagnostic-macro-unwinding.cc
+++ b/gcc/diagnostics/macro-unwinding.cc
@@ -22,10 +22,12 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tree.h"
 #include "diagnostic.h"
-#include "diagnostic-macro-unwinding.h"
+#include "diagnostics/macro-unwinding.h"
 #include "diagnostics/text-sink.h"
 #include "intl.h"
 
+namespace diagnostics {
+
 /* This is a pair made of a location and the line map it originated
    from.  It's used in the maybe_unwind_expanded_macro_loc function
    below.  */
@@ -215,8 +217,11 @@ maybe_unwind_expanded_macro_loc (diagnostics::text_sink &text_output,
     that is similar to what is done for function call stacks, or
     template instantiation contexts.  */
 void
-virt_loc_aware_diagnostic_finalizer (diagnostics::text_sink &text_output,
-				     const diagnostic_info *diagnostic)
+virt_loc_aware_text_finalizer (diagnostics::text_sink &text_output,
+			       const diagnostic_info *diagnostic)
 {
-  maybe_unwind_expanded_macro_loc (text_output, diagnostic_location (diagnostic));
+  maybe_unwind_expanded_macro_loc (text_output,
+				   diagnostic_location (diagnostic));
 }
+
+} // namespace diagnostics
diff --git a/gcc/diagnostic-macro-unwinding.h b/gcc/diagnostics/macro-unwinding.h
similarity index 74%
rename from gcc/diagnostic-macro-unwinding.h
rename to gcc/diagnostics/macro-unwinding.h
index b2173bcee256..f695cc3c6ff3 100644
--- a/gcc/diagnostic-macro-unwinding.h
+++ b/gcc/diagnostics/macro-unwinding.h
@@ -17,13 +17,17 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#ifndef GCC_DIAGNOSTIC_MACRO_UNWINDING_H
-#define GCC_DIAGNOSTIC_MACRO_UNWINDING_H
+#ifndef GCC_DIAGNOSTICS_MACRO_UNWINDING_H
+#define GCC_DIAGNOSTICS_MACRO_UNWINDING_H
 
-void virt_loc_aware_diagnostic_finalizer (diagnostics::text_sink &,
-					  const diagnostic_info *);
+namespace diagnostics {
+
+extern void virt_loc_aware_text_finalizer (diagnostics::text_sink &,
+					   const diagnostic_info *);
 
 extern void maybe_unwind_expanded_macro_loc (diagnostics::text_sink &,
 					     location_t where);
 
-#endif /* ! GCC_DIAGNOSTIC_MACRO_UNWINDING_H */
+} // namespace diagnostics
+
+#endif /* ! GCC_DIAGNOSTICS_MACRO_UNWINDING_H */
diff --git a/gcc/diagnostics/paths-output.cc b/gcc/diagnostics/paths-output.cc
index 599d6849cfc7..5cf61ceb10bf 100644
--- a/gcc/diagnostics/paths-output.cc
+++ b/gcc/diagnostics/paths-output.cc
@@ -26,7 +26,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "diagnostic.h"
-#include "diagnostic-macro-unwinding.h"
+#include "diagnostics/macro-unwinding.h"
 #include "intl.h"
 #include "diagnostics/paths.h"
 #include "gcc-rich-location.h"
-- 
2.26.3

