diff --git a/gcc/config/aarch64/aarch64-json-tunings-parser.cc b/gcc/config/aarch64/aarch64-json-tunings-parser.cc
index 19598034761..afad1a65170 100644
--- a/gcc/config/aarch64/aarch64-json-tunings-parser.cc
+++ b/gcc/config/aarch64/aarch64-json-tunings-parser.cc
@@ -17,6 +17,7 @@
along with GCC; see the file COPYING3. If not see
. */
+#define INCLUDE_MAP
#define INCLUDE_STRING
#define INCLUDE_VECTOR
#define INCLUDE_TYPE_TRAITS
@@ -641,4 +642,4 @@ aarch64_json_tunings_tests ()
#undef STR
#undef STR_
-#endif /* CHECKING_P */
\ No newline at end of file
+#endif /* CHECKING_P */
diff --git a/gcc/json-parsing.cc b/gcc/json-parsing.cc
index b3711e50f11..88c515e3f86 100644
--- a/gcc/json-parsing.cc
+++ b/gcc/json-parsing.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
. */
+#define INCLUDE_MAP
#include "config.h"
#include "system.h"
#include "coretypes.h"
diff --git a/gcc/json-parsing.h b/gcc/json-parsing.h
index 2b698bcaaf5..7721dc88c23 100644
--- a/gcc/json-parsing.h
+++ b/gcc/json-parsing.h
@@ -55,6 +55,30 @@ public:
virtual void on_finished_parsing () {}
};
+/* Implementation of json::location_map that records ranges to a std::map. */
+
+class simple_location_map : public location_map
+{
+public:
+ void
+ record_range_for_value (json::value *jv,
+ const range &r) final override
+ {
+ m_map_jv_to_range[jv] = r;
+ }
+
+ const json::location_map::range &
+ get_range_for_value (const json::value &jv) const
+ {
+ auto iter = m_map_jv_to_range.find (&jv);
+ gcc_assert (iter != m_map_jv_to_range.end ());
+ return iter->second;
+ }
+
+private:
+ std::map m_map_jv_to_range;
+};
+
/* Class for recording an error within a JSON file. */
class error
diff --git a/gcc/libsarifreplay.cc b/gcc/libsarifreplay.cc
index 966e181fa0c..9cc37fc7708 100644
--- a/gcc/libsarifreplay.cc
+++ b/gcc/libsarifreplay.cc
@@ -316,27 +316,6 @@ public:
const replay_options &replay_opts);
private:
- class replayer_location_map : public json::location_map
- {
- public:
- void record_range_for_value (json::value *jv,
- const range &r) final override
- {
- m_map_jv_to_range[jv] = r;
- }
-
- const json::location_map::range &
- get_range_for_value (const json::value &jv) const
- {
- auto iter = m_map_jv_to_range.find (&jv);
- gcc_assert (iter != m_map_jv_to_range.end ());
- return iter->second;
- }
-
- private:
- std::map m_map_jv_to_range;
- };
-
enum status emit_sarif_as_diagnostics (const json::value &jv);
libgdiagnostics::message_buffer
@@ -743,7 +722,7 @@ private:
/* The file within m_control_mgr representing the .sarif file. */
libgdiagnostics::file m_loaded_file;
- replayer_location_map m_json_location_map;
+ json::simple_location_map m_json_location_map;
const json::object *m_driver_obj;
const json::array *m_artifacts_arr;