mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
json: split out replayer_location_map from libsarifreplay.cc
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 <dmalcolm@redhat.com>
This commit is contained in:
@@ -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
|
||||
@@ -641,4 +642,4 @@ aarch64_json_tunings_tests ()
|
||||
#undef STR
|
||||
#undef STR_
|
||||
|
||||
#endif /* CHECKING_P */
|
||||
#endif /* CHECKING_P */
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user