aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/lib/sarif.py
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/lib/sarif.py')
-rw-r--r--gcc/testsuite/lib/sarif.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/testsuite/lib/sarif.py b/gcc/testsuite/lib/sarif.py
index 7daf35b..d75a87e 100644
--- a/gcc/testsuite/lib/sarif.py
+++ b/gcc/testsuite/lib/sarif.py
@@ -1,5 +1,6 @@
import json
import os
+import xml.etree.ElementTree as ET
def sarif_from_env():
# return parsed JSON content a SARIF_PATH file
@@ -21,3 +22,31 @@ def get_location_snippet_text(location):
def get_location_relationships(location):
return location['relationships']
+
+def get_result_by_index(sarif, idx):
+ runs = sarif['runs']
+ run = runs[0]
+ results = run['results']
+ return results[idx]
+
+def get_state_graph(events, event_idx):
+ graph = events[event_idx]['properties']['gcc/diagnostics/paths/event/state_graph']
+ if 0:
+ print(graph)
+ assert graph is not None
+ return graph
+
+def get_state_node_attr(obj, attr_name):
+ return obj['properties']['gcc/diagnostic_state_node/%s' % attr_name]
+
+def get_state_node_kind(obj):
+ return get_state_node_attr(obj, 'kind')
+
+def get_state_node_name(obj):
+ return get_state_node_attr(obj, 'name')
+
+def get_state_node_type(obj):
+ return get_state_node_attr(obj, 'type')
+
+def get_state_node_value(obj):
+ return get_state_node_attr(obj, 'value')