]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
diagnostics: move edit_context to namespace/dir "diagnostics"
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 25 Jul 2025 19:13:35 +0000 (15:13 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Fri, 25 Jul 2025 19:13:35 +0000 (15:13 -0400)
No functional change intended.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Replace edit-context.o with
diagnostics/edit-context.o.
* diagnostic-format-html.cc: Update #include for move
of edit-context.h to diagnostics subdir.
* diagnostic.cc: Likewise.  Update for move of edit_context to
diagnostics::edit_context.
* diagnostic.h: Likewise.
* edit-context.cc: Move to...
* diagnostics/edit-context.cc: ...here.  Update #include for move
of edit-context.h to diagnostics subdir.  Move all code
within namespace diagnostics.
* edit-context.h: Move to...
* diagnostics/edit-context.h: ...here, updating header guard.
Move all code within namespace diagnostics.
* libgdiagnostics.cc: Update #include for move of edit-context.h
to diagnostics subdir.  Update for move of edit_context
to diagnostics::edit_context.
* toplev.cc: Update #include for move of edit-context.h
to diagnostics subdir.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/expensive_selftests_plugin.cc: Update #include for
move of edit-context.h to diagnostics subdir.  Update
for move of edit_context to diagnostics::edit_context.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/Makefile.in
gcc/diagnostic-format-html.cc
gcc/diagnostic.cc
gcc/diagnostic.h
gcc/diagnostics/edit-context.cc [moved from gcc/edit-context.cc with 99% similarity]
gcc/diagnostics/edit-context.h [moved from gcc/edit-context.h with 92% similarity]
gcc/libgdiagnostics.cc
gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.cc
gcc/toplev.cc

index fc5ffc72df720f6d109a9b4e5b98461ad48a7557..7610debabcd7b99ac3d7d8cb2cf671e594c8f4ad 100644 (file)
@@ -1863,10 +1863,10 @@ OBJS-libcommon = diagnostic-spec.o diagnostic.o diagnostic-color.o \
        diagnostic-path-output.o \
        diagnostic-show-locus.o \
        diagnostics/digraphs.o \
+       diagnostics/edit-context.o \
        diagnostics/state-graphs.o \
        diagnostics/state-graphs-to-dot.o \
        diagnostics/selftest-logical-locations.o \
-       edit-context.o \
        graphviz.o pex.o \
        pretty-print.o intl.o \
        json.o json-parsing.o \
index 33dca5c0147cf5667842635594fb85c4efac7131..a8e36d6f4f14ad8d03024496ebead37b262c392b 100644 (file)
@@ -38,7 +38,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "selftest-diagnostic.h"
 #include "pretty-print-format-impl.h"
 #include "pretty-print-urlifier.h"
-#include "edit-context.h"
+#include "diagnostics/edit-context.h"
 #include "intl.h"
 #include "xml.h"
 #include "xml-printer.h"
index 09329f0712f6effaaf4937178bf9a9c4cfdc6818..b2b8f0a805114474217165cca8c7a26212349b15 100644 (file)
@@ -40,7 +40,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic-format.h"
 #include "diagnostic-format-sarif.h"
 #include "diagnostic-format-text.h"
-#include "edit-context.h"
+#include "diagnostics/edit-context.h"
 #include "selftest.h"
 #include "selftest-diagnostic.h"
 #include "opts.h"
@@ -663,7 +663,7 @@ diagnostic_context::create_edit_context ()
 {
   delete m_edit_context_ptr;
   gcc_assert (m_file_cache);
-  m_edit_context_ptr = new edit_context (*m_file_cache);
+  m_edit_context_ptr = new diagnostics::edit_context (*m_file_cache);
 }
 
 /* Initialize DIAGNOSTIC, where the message MSG has already been
index 4ddc4b062d2ad055885705715ab11057d47c2fa1..e51de435b20bd3399cfece4b5c71366ac96740d8 100644 (file)
@@ -39,6 +39,7 @@ namespace diagnostics {
   } // namespace diagnostics::logical_locations
 
   class diagram;
+  class edit_context;
 
 } // namespace diagnostics
 
@@ -235,7 +236,6 @@ public:
   virtual char *make_option_url (diagnostic_option_id option_id) const = 0;
 };
 
-class edit_context;
 class diagnostic_client_data_hooks;
 class diagnostic_source_effect_info;
 class diagnostic_output_format;
@@ -549,7 +549,7 @@ struct diagnostic_counters
      source code
    - a cache for use when quoting the user's source code (class file_cache)
    - a text_art::theme
-   - aedit_context for generating patches from fix-it hints
+   - a diagnostics::edit_context for generating patches from fix-it hints
    - diagnostic_client_data_hooks for metadata.
 
    Try to avoid adding new responsibilities to this class itself, to avoid
@@ -726,7 +726,7 @@ public:
     return *m_file_cache;
   }
 
-  edit_context *get_edit_context () const
+  diagnostics::edit_context *get_edit_context () const
   {
     return m_edit_context_ptr;
   }
@@ -1060,7 +1060,7 @@ private:
      applied, for generating patches.
      Owned by the context; this would be a std::unique_ptr if
      diagnostic_context had a proper ctor.  */
-  edit_context *m_edit_context_ptr;
+  diagnostics::edit_context *m_edit_context_ptr;
 
   /* Fields relating to diagnostic groups.  */
   struct {
similarity index 99%
rename from gcc/edit-context.cc
rename to gcc/diagnostics/edit-context.cc
index c767394433d69c1d11524ac71494b3ea01a9208c..e8c328d3a3db5a63bfed0876345fba7924123c71 100644 (file)
@@ -21,11 +21,13 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "line-map.h"
-#include "edit-context.h"
+#include "diagnostics/edit-context.h"
 #include "pretty-print.h"
 #include "diagnostic-color.h"
 #include "selftest.h"
 
+namespace diagnostics {
+
 /* This file implements a way to track the effect of fix-its,
    via a class edit_context; the other classes are support classes for
    edit_context.
@@ -895,12 +897,16 @@ edited_line::ensure_terminated ()
   m_content[m_len] = '\0';
 }
 
+} // namespace diagnostics
+
 #if CHECKING_P
 
 /* Selftests of code-editing.  */
 
 namespace selftest {
 
+using edit_context = diagnostics::edit_context;
+
 /* A wrapper class for ensuring that the underlying pointer is freed.  */
 
 template <typename POINTER_T>
similarity index 92%
rename from gcc/edit-context.h
rename to gcc/diagnostics/edit-context.h
index 9bd2abaa5117ddab2bebde299bf96fd8e1eeedee..63ade305c7a8269aa223cb8554ab20d6ea4408e9 100644 (file)
@@ -17,12 +17,15 @@ 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_EDIT_CONTEXT_H
-#define GCC_EDIT_CONTEXT_H
+#ifndef GCC_DIAGNOSTICS_EDIT_CONTEXT_H
+#define GCC_DIAGNOSTICS_EDIT_CONTEXT_H
 
 #include "typed-splay-tree.h"
 
 class fixit_hint;
+
+namespace diagnostics {
+
 class edit_context;
 class edited_file;
 
@@ -68,4 +71,6 @@ class edit_context
   typed_splay_tree<const char *, edited_file *> m_files;
 };
 
-#endif /* GCC_EDIT_CONTEXT_H.  */
+} // namespace diagnostics
+
+#endif /* GCC_DIAGNOSTICS_EDIT_CONTEXT_H.  */
index 7e93593da2a9a696c116755c073f4077c56201e4..a1a5b590faf7f9f923b026681e51509980ad96db 100644 (file)
@@ -36,7 +36,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostics/digraphs.h"
 #include "diagnostics/state-graphs.h"
 #include "diagnostics/logical-locations.h"
-#include "edit-context.h"
+#include "diagnostics/edit-context.h"
 #include "libgdiagnostics.h"
 #include "libgdiagnostics-private.h"
 #include "pretty-print-format-impl.h"
@@ -670,7 +670,8 @@ public:
 
     diagnostic_text_starter (&m_dc) = diagnostic_text_sink::text_starter;
 
-    m_edit_context = std::make_unique <edit_context> (m_dc.get_file_cache ());
+    m_edit_context
+      = std::make_unique <diagnostics::edit_context> (m_dc.get_file_cache ());
   }
 
   ~diagnostic_manager ()
@@ -901,7 +902,7 @@ private:
   logical_locs_map_t m_logical_locs;
   const diagnostic *m_current_diag;
   const diagnostic_logical_location *m_prev_diag_logical_loc;
-  std::unique_ptr<edit_context> m_edit_context;
+  std::unique_ptr<diagnostics::edit_context> m_edit_context;
 };
 
 class impl_rich_location : public rich_location
index 7b9b8d4c031c3be4eaff63caf0946c5fe60260dd..8abed140ac9c4bf5680fb676d670aaafde94a76c 100644 (file)
@@ -6,7 +6,7 @@
 #include "system.h"
 #include "coretypes.h"
 #include "diagnostic.h"
-#include "edit-context.h"
+#include "diagnostics/edit-context.h"
 #include "selftest.h"
 #include "selftest-diagnostic.h"
 
@@ -52,7 +52,7 @@ test_richloc (rich_location *richloc)
                         richloc, DK_ERROR, dc.get_reference_printer ());
 
   /* Generate a diff.  */
-  edit_context ec (global_dc->get_file_cache ());
+  diagnostics::edit_context ec (global_dc->get_file_cache ());
   ec.add_fixits (richloc);
   char *diff = ec.generate_diff (true);
   free (diff);
index 931466ca6324e75fd89496bd1de22e44484622df..1ce61f140d3ac54b5449490b5d7691f51fa32faa 100644 (file)
@@ -81,7 +81,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "ipa-utils.h"
 #include "gcse.h"
 #include "omp-offload.h"
-#include "edit-context.h"
+#include "diagnostics/edit-context.h"
 #include "tree-pass.h"
 #include "dumpfile.h"
 #include "ipa-fnsummary.h"