No functional change intended, but make this code usable elsewhere.
gcc/ChangeLog:
* config/aarch64/aarch64-json-tunings-parser.cc: Define
INCLUDE_MAP.
* json-parsing.cc: Likewise.
* json-parsing.h (class simple_location_map): New class, moved and
renamed from...
* libsarifreplay.cc (class replayer_location_map): ...here.
(sarif_replayer::m_json_location_map): Update for renaming of
class.
Signed-off-by: David Malcolm <[email protected]>
---
.../aarch64/aarch64-json-tunings-parser.cc | 3 ++-
gcc/json-parsing.cc | 1 +
gcc/json-parsing.h | 24 +++++++++++++++++++
gcc/libsarifreplay.cc | 23 +-----------------
4 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/gcc/config/aarch64/aarch64-json-tunings-parser.cc
b/gcc/config/aarch64/aarch64-json-tunings-parser.cc
index 59c745e347ef2..326d52e02d1ce 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
<http://www.gnu.org/licenses/>. */
+#define INCLUDE_MAP
#define INCLUDE_STRING
#define INCLUDE_VECTOR
#define INCLUDE_TYPE_TRAITS
@@ -627,4 +628,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 b3711e50f11f5..88c515e3f8606 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
<http://www.gnu.org/licenses/>. */
+#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 2b698bcaaf55e..7721dc88c2396 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<const json::value *, range> 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 966e181fa0c58..9cc37fc770855 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<const json::value *, range> 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;
--
2.26.3