aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2025-07-25 15:13:35 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2025-07-25 15:13:35 -0400
commitd38c7faf31cc66a66c912bd0ae74c7aa986f9ad2 (patch)
tree631e4588de64c099b8bc8ce48250c88f3845de70 /gcc
parente84867ce352a5699a3f99d126ef5da4431461103 (diff)
downloadgcc-d38c7faf31cc66a66c912bd0ae74c7aa986f9ad2.zip
gcc-d38c7faf31cc66a66c912bd0ae74c7aa986f9ad2.tar.gz
gcc-d38c7faf31cc66a66c912bd0ae74c7aa986f9ad2.tar.bz2
diagnostics: move edit_context to namespace/dir "diagnostics"
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>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/Makefile.in2
-rw-r--r--gcc/diagnostic-format-html.cc2
-rw-r--r--gcc/diagnostic.cc4
-rw-r--r--gcc/diagnostic.h8
-rw-r--r--gcc/diagnostics/edit-context.cc (renamed from gcc/edit-context.cc)8
-rw-r--r--gcc/diagnostics/edit-context.h (renamed from gcc/edit-context.h)11
-rw-r--r--gcc/libgdiagnostics.cc7
-rw-r--r--gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.cc4
-rw-r--r--gcc/toplev.cc2
9 files changed, 30 insertions, 18 deletions
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index fc5ffc7..7610deb 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -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 \
diff --git a/gcc/diagnostic-format-html.cc b/gcc/diagnostic-format-html.cc
index 33dca5c..a8e36d6 100644
--- a/gcc/diagnostic-format-html.cc
+++ b/gcc/diagnostic-format-html.cc
@@ -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"
diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index 09329f0..b2b8f0a 100644
--- a/gcc/diagnostic.cc
+++ b/gcc/diagnostic.cc
@@ -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
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index 4ddc4b0..e51de43 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -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
- - an edit_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 {
diff --git a/gcc/edit-context.cc b/gcc/diagnostics/edit-context.cc
index c767394..e8c328d 100644
--- a/gcc/edit-context.cc
+++ b/gcc/diagnostics/edit-context.cc
@@ -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>
diff --git a/gcc/edit-context.h b/gcc/diagnostics/edit-context.h
index 9bd2aba..63ade30 100644
--- a/gcc/edit-context.h
+++ b/gcc/diagnostics/edit-context.h
@@ -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. */
diff --git a/gcc/libgdiagnostics.cc b/gcc/libgdiagnostics.cc
index 7e93593..a1a5b59 100644
--- a/gcc/libgdiagnostics.cc
+++ b/gcc/libgdiagnostics.cc
@@ -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
diff --git a/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.cc b/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.cc
index 7b9b8d4..8abed14 100644
--- a/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.cc
+++ b/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.cc
@@ -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);
diff --git a/gcc/toplev.cc b/gcc/toplev.cc
index 931466c..1ce61f14 100644
--- a/gcc/toplev.cc
+++ b/gcc/toplev.cc
@@ -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"