Skip to content

Commit de9fa65

Browse files
authored
Merge pull request #6696 from tautschnig/feature/json-xml-property-info
Include source location in JSON/XML property output
2 parents dbc5d5d + 88c5acc commit de9fa65

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

doc/assets/xml_spec.xsd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<xs:complexType>
1212
<xs:attribute name="file" type="xs:string" use="optional"/>
1313
<xs:attribute name="line" type="xs:int" use="optional"/>
14+
<xs:attribute name="column" type="xs:int" use="optional"/>
1415
<xs:attribute name="working-directory" type="xs:string"
1516
use="optional"/>
1617
<xs:attribute name="function" type="xs:string" use="optional"/>
@@ -164,6 +165,7 @@
164165
<xs:element name="result">
165166
<xs:complexType>
166167
<xs:sequence>
168+
<xs:element ref="location" minOccurs="0"/>
167169
<xs:element ref="goto_trace" minOccurs="0"/>
168170
</xs:sequence>
169171
<xs:attribute name="property" type="xs:string"/>

regression/cbmc/json-interface1/test.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ activate-multi-line-match
55
^EXIT=10$
66
^SIGNAL=0$
77
Not unwinding loop foo\.0 iteration 3 file main\.c line 5 function foo thread 0
8-
\{\n\s*"description": "assertion 0",\n\s*"property": "foo\.assertion\.(1|3)",\n\s*"status": "SUCCESS"\n\s*\}
9-
\{\n\s*"description": "assertion 0",\n\s*"property": "foo\.assertion\.(1|3)",\n\s*"status": "FAILURE",\n\s*"trace": \[
8+
\{\n\s*"description": "assertion 0",\n\s*"property": "foo\.assertion\.(1|3)",\n\s*"sourceLocation": \{\n\s*"file": "main.c",\n\s*"function": "foo",\n\s*"line": "(8|11)",\n\s*"workingDirectory": ".*json-interface1"\n\s*\},\n\s*"status": "SUCCESS"\n\s*\}
9+
\{\n\s*"description": "assertion 0",\n\s*"property": "foo\.assertion\.(1|3)",\n\s*"sourceLocation": \{\n\s*"file": "main.c",\n\s*"function": "foo",\n\s*"line": "(8|11)",\n\s*"workingDirectory": ".*json-interface1"\n\s*\},\n\s*"status": "FAILURE",\n\s*"trace": \[
1010
VERIFICATION FAILED
1111
--
1212
"property": "foo\.assertion\.2"

regression/cbmc/xml-interface1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CORE
44
^EXIT=10$
55
^SIGNAL=0$
66
Not unwinding loop foo\.0 iteration 3 file main\.c line 5 function foo thread 0
7-
<result property="foo\.assertion\.3" status="SUCCESS"/>
7+
<result property="foo\.assertion\.3" status="SUCCESS">
88
<result property="foo\.assertion\.1" status="FAILURE">
99
<goto_trace>
1010
VERIFICATION FAILED

src/goto-checker/properties.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ Author: Daniel Kroening, Peter Schrammel
1414
#include <util/exit_codes.h>
1515
#include <util/invariant.h>
1616
#include <util/json.h>
17+
#include <util/json_irep.h>
1718
#include <util/json_stream.h>
1819
#include <util/xml.h>
20+
#include <util/xml_irep.h>
1921

2022
#include <goto-programs/abstract_goto_model.h>
2123

@@ -110,6 +112,7 @@ xmlt xml(const irep_idt &property_id, const property_infot &property_info)
110112
xmlt xml_result("result");
111113
xml_result.set_attribute("property", id2string(property_id));
112114
xml_result.set_attribute("status", as_string(property_info.status));
115+
xml_result.new_element(xml(property_info.pc->source_location()));
113116
return xml_result;
114117
}
115118

@@ -122,6 +125,7 @@ static void json(
122125
result["property"] = json_stringt(property_id);
123126
result["description"] = json_stringt(property_info.description);
124127
result["status"] = json_stringt(as_string(property_info.status));
128+
result["sourceLocation"] = json(property_info.pc->source_location());
125129
}
126130

127131
json_objectt

0 commit comments

Comments
 (0)