Skip to content

Commit f07b80a

Browse files
committed
(un)reachable functions: normalize JSON and XML keys
JSON uses camelCase, XML uses underscores or dashes (we liberally mix them across the code base).
1 parent af43b4d commit f07b80a

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
CORE
22
../unreachable-instructions-basic-text/unreachable.c
33
--unreachable-functions --json -
4-
"file name": ".*unreachable.c",
5-
"first line": 3,
4+
"file": ".*unreachable.c",
5+
"firstLine": 3,
66
"function": "not_called",
7-
"last line": 6
7+
"lastLine": 6
88
^EXIT=0$
99
^SIGNAL=0$
1010
--
11-
"last line":[[:space:]]*$
11+
"lastLine":[[:space:]]*$
1212
^warning: ignoring

src/goto-analyzer/unreachable_instructions.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static void add_to_json(
127127

128128
json_objectt entry{{"function", json_stringt(function_identifier)}};
129129
if(auto file_name_opt = file_name_string_opt(end_function->source_location))
130-
entry["fileName"] = json_stringt{*file_name_opt};
130+
entry["file"] = json_stringt{*file_name_opt};
131131

132132
json_arrayt &dead_ins=entry["unreachableInstructions"].make_array();
133133

@@ -270,11 +270,11 @@ static void json_output_function(
270270
{
271271
json_objectt entry{{"function", json_stringt(function)}};
272272
if(auto file_name_opt = file_name_string_opt(first_location))
273-
entry["file name"] = json_stringt{*file_name_opt};
273+
entry["file"] = json_stringt{*file_name_opt};
274274
if(auto line_opt = line_string_opt(first_location))
275-
entry["first line"] = json_numbert{*line_opt};
275+
entry["firstLine"] = json_numbert{*line_opt};
276276
if(auto line_opt = line_string_opt(last_location))
277-
entry["last line"] = json_numbert{*line_opt};
277+
entry["lastLine"] = json_numbert{*line_opt};
278278

279279
dest.push_back(std::move(entry));
280280
}
@@ -289,11 +289,11 @@ static void xml_output_function(
289289

290290
x.set_attribute("name", id2string(function));
291291
if(auto file_name_opt = file_name_string_opt(first_location))
292-
x.set_attribute("file name", *file_name_opt);
292+
x.set_attribute("file", *file_name_opt);
293293
if(auto line_opt = line_string_opt(first_location))
294-
x.set_attribute("first line", *line_opt);
294+
x.set_attribute("first_line", *line_opt);
295295
if(auto line_opt = line_string_opt(last_location))
296-
x.set_attribute("last line", *line_opt);
296+
x.set_attribute("last_line", *line_opt);
297297
}
298298

299299
static void list_functions(

0 commit comments

Comments
 (0)