Skip to content

Commit 0315816

Browse files
authored
Merge pull request diffblue#2180 from thomasspriggs/json_id2string
Remove `id2string` from inside calls to the `json_stringt` constructor.
2 parents 8941567 + b6a4382 commit 0315816

11 files changed

+48
-53
lines changed

src/cbmc/all_properties.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ void bmc_all_propertiest::report(const cover_goalst &cover_goals)
214214
for(const auto &g : goal_map)
215215
{
216216
json_stream_objectt &result = result_array.push_back_stream_object();
217-
result["property"]=json_stringt(id2string(g.first));
218-
result["description"]=json_stringt(id2string(g.second.description));
217+
result["property"] = json_stringt(g.first);
218+
result["description"] = json_stringt(g.second.description);
219219
result["status"]=json_stringt(g.second.status_string());
220220

221221
if(g.second.status==goalt::statust::FAILURE)

src/cbmc/bmc.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ void bmct::error_trace()
7474
json_stream_objectt &json_result =
7575
status().json_stream().push_back_stream_object();
7676
const goto_trace_stept &step=goto_trace.steps.back();
77-
json_result["property"]=
78-
json_stringt(id2string(step.pc->source_location.get_property_id()));
79-
json_result["description"]=
80-
json_stringt(id2string(step.pc->source_location.get_comment()));
77+
json_result["property"] =
78+
json_stringt(step.pc->source_location.get_property_id());
79+
json_result["description"] =
80+
json_stringt(step.pc->source_location.get_comment());
8181
json_result["status"]=json_stringt("failed");
8282
json_stream_arrayt &json_trace =
8383
json_result.push_back_stream_array("trace");

src/cbmc/bmc_cover.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ bool bmc_covert::operator()()
355355

356356
json_result["status"] =
357357
json_stringt(goal.satisfied ? "satisfied" : "failed");
358-
json_result["goal"] = json_stringt(id2string(goal_pair.first));
358+
json_result["goal"] = json_stringt(goal_pair.first);
359359
json_result["description"] = json_stringt(goal.description);
360360

361361
if(goal.source_location.is_not_nil())
@@ -382,7 +382,7 @@ bool bmc_covert::operator()()
382382
if(step.is_input())
383383
{
384384
json_objectt json_input;
385-
json_input["id"]=json_stringt(id2string(step.io_id));
385+
json_input["id"] = json_stringt(step.io_id);
386386
if(step.io_args.size()==1)
387387
json_input["value"]=
388388
json(step.io_args.front(), bmc.ns, ID_unknown);
@@ -393,7 +393,7 @@ bool bmc_covert::operator()()
393393
json_arrayt &goal_refs=result["coveredGoals"].make_array();
394394
for(const auto &goal_id : test.covered_goals)
395395
{
396-
goal_refs.push_back(json_stringt(id2string(goal_id)));
396+
goal_refs.push_back(json_stringt(goal_id));
397397
}
398398
}
399399

src/goto-analyzer/static_analyzer.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,9 @@ void static_analyzert::json_report(const std::string &file_name)
153153
else
154154
j["status"]=json_stringt("UNKNOWN");
155155

156-
j["file"]=json_stringt(id2string(i_it->source_location.get_file()));
156+
j["file"] = json_stringt(i_it->source_location.get_file());
157157
j["line"]=json_numbert(id2string(i_it->source_location.get_line()));
158-
j["description"]=json_stringt(id2string(
159-
i_it->source_location.get_comment()));
158+
j["description"] = json_stringt(i_it->source_location.get_comment());
160159
}
161160
}
162161

src/goto-analyzer/taint_analysis.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,9 @@ bool taint_analysist::operator()(
351351
if(use_json)
352352
{
353353
json_objectt json;
354-
json["bugClass"]=
355-
json_stringt(id2string(i_it->source_location.get_property_class()));
356-
json["file"]=
357-
json_stringt(id2string(i_it->source_location.get_file()));
354+
json["bugClass"] =
355+
json_stringt(i_it->source_location.get_property_class());
356+
json["file"] = json_stringt(i_it->source_location.get_file());
358357
json["line"]=
359358
json_numbert(id2string(i_it->source_location.get_line()));
360359
json_result.array.push_back(json);

src/goto-analyzer/unreachable_instructions.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static void add_to_json(
127127
DATA_INVARIANT(end_function->is_end_function(),
128128
"The last instruction in a goto-program must be END_FUNCTION");
129129

130-
entry["function"]=json_stringt(id2string(end_function->function));
130+
entry["function"] = json_stringt(end_function->function);
131131
entry["fileName"]=
132132
json_stringt(concat_dir_file(
133133
id2string(end_function->source_location.get_working_directory()),
@@ -261,7 +261,7 @@ static void json_output_function(
261261
{
262262
json_objectt &entry=dest.push_back().make_object();
263263

264-
entry["function"]=json_stringt(id2string(function));
264+
entry["function"] = json_stringt(function);
265265
entry["file name"]=
266266
json_stringt(concat_dir_file(
267267
id2string(first_location.get_working_directory()),

src/goto-diff/goto_diff_base.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ void goto_difft::convert_function_json(
136136
namespacet ns(goto_model.symbol_table);
137137
const symbolt &symbol = ns.lookup(function_name);
138138

139-
result["name"] = json_stringt(id2string(function_name));
139+
result["name"] = json_stringt(function_name);
140140
result["sourceLocation"] = json(symbol.location);
141141

142142
if(options.get_bool_option("show-properties"))

src/goto-programs/json_goto_trace.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ void convert_assert(
5252
json_failure["hidden"] = jsont::json_boolean(step.hidden);
5353
json_failure["internal"] = jsont::json_boolean(step.internal);
5454
json_failure["thread"] = json_numbert(std::to_string(step.thread_nr));
55-
json_failure["reason"] = json_stringt(id2string(step.comment));
56-
json_failure["property"] = json_stringt(id2string(property_id));
55+
json_failure["reason"] = json_stringt(step.comment);
56+
json_failure["property"] = json_stringt(property_id);
5757

5858
if(!location.is_null())
5959
json_failure["sourceLocation"] = location;
@@ -133,7 +133,7 @@ void convert_decl(
133133
if(type_string == "")
134134
type_string = from_type(ns, identifier, symbol->type);
135135

136-
json_assignment["mode"] = json_stringt(id2string(symbol->mode));
136+
json_assignment["mode"] = json_stringt(symbol->mode);
137137
exprt simplified = simplify_expr(step.full_lhs_value, ns);
138138

139139
full_lhs_value = json(simplified, ns, symbol->mode);
@@ -183,7 +183,7 @@ void convert_output(
183183
json_output["hidden"] = jsont::json_boolean(step.hidden);
184184
json_output["internal"] = jsont::json_boolean(step.internal);
185185
json_output["thread"] = json_numbert(std::to_string(step.thread_nr));
186-
json_output["outputID"] = json_stringt(id2string(step.io_id));
186+
json_output["outputID"] = json_stringt(step.io_id);
187187

188188
// Recovering the mode from the function
189189
irep_idt mode;
@@ -193,7 +193,7 @@ void convert_output(
193193
mode = ID_unknown;
194194
else
195195
mode = function_name->mode;
196-
json_output["mode"] = json_stringt(id2string(mode));
196+
json_output["mode"] = json_stringt(mode);
197197
json_arrayt &json_values = json_output["values"].make_array();
198198

199199
for(const auto &arg : step.io_args)
@@ -226,7 +226,7 @@ void convert_input(
226226
json_input["hidden"] = jsont::json_boolean(step.hidden);
227227
json_input["internal"] = jsont::json_boolean(step.internal);
228228
json_input["thread"] = json_numbert(std::to_string(step.thread_nr));
229-
json_input["inputID"] = json_stringt(id2string(step.io_id));
229+
json_input["inputID"] = json_stringt(step.io_id);
230230

231231
// Recovering the mode from the function
232232
irep_idt mode;
@@ -236,7 +236,7 @@ void convert_input(
236236
mode = ID_unknown;
237237
else
238238
mode = function_name->mode;
239-
json_input["mode"] = json_stringt(id2string(mode));
239+
json_input["mode"] = json_stringt(mode);
240240
json_arrayt &json_values = json_input["values"].make_array();
241241

242242
for(const auto &arg : step.io_args)
@@ -275,8 +275,8 @@ void convert_return(
275275

276276
const symbolt &symbol = ns.lookup(step.identifier);
277277
json_objectt &json_function = json_call_return["function"].make_object();
278-
json_function["displayName"] = json_stringt(id2string(symbol.display_name()));
279-
json_function["identifier"] = json_stringt(id2string(step.identifier));
278+
json_function["displayName"] = json_stringt(symbol.display_name());
279+
json_function["identifier"] = json_stringt(step.identifier);
280280
json_function["sourceLocation"] = json(symbol.location);
281281

282282
if(!location.is_null())

src/goto-programs/show_goto_functions_json.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ json_objectt show_goto_functions_jsont::convert(
4848

4949
json_objectt &json_function=
5050
json_functions.push_back(jsont()).make_object();
51-
json_function["name"]=json_stringt(id2string(function_name));
51+
json_function["name"] = json_stringt(function_name);
5252
json_function["isBodyAvailable"]=
5353
jsont::json_boolean(function.body_available());
5454
bool is_internal=

src/goto-programs/show_properties.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,13 @@ void convert_properties_json(
131131

132132
json_objectt &json_property=
133133
json_properties.push_back(jsont()).make_object();
134-
json_property["name"]=json_stringt(id2string(property_id));
135-
json_property["class"]=json_stringt(id2string(property_class));
134+
json_property["name"] = json_stringt(property_id);
135+
json_property["class"] = json_stringt(property_class);
136136
if(!source_location.get_basic_block_covered_lines().empty())
137-
json_property["coveredLines"]=
138-
json_stringt(
139-
id2string(source_location.get_basic_block_covered_lines()));
137+
json_property["coveredLines"] =
138+
json_stringt(source_location.get_basic_block_covered_lines());
140139
json_property["sourceLocation"]=json(source_location);
141-
json_property["description"]=json_stringt(id2string(description));
140+
json_property["description"] = json_stringt(description);
142141
json_property["expression"]=
143142
json_stringt(from_expr(ns, identifier, ins.guard));
144143
}

src/util/json_expr.cpp

+16-18
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,22 @@ json_objectt json(const source_locationt &location)
8585
json_objectt result;
8686

8787
if(!location.get_working_directory().empty())
88-
result["workingDirectory"]=
89-
json_stringt(id2string(location.get_working_directory()));
88+
result["workingDirectory"] = json_stringt(location.get_working_directory());
9089

9190
if(!location.get_file().empty())
92-
result["file"]=json_stringt(id2string(location.get_file()));
91+
result["file"] = json_stringt(location.get_file());
9392

9493
if(!location.get_line().empty())
95-
result["line"]=json_stringt(id2string(location.get_line()));
94+
result["line"] = json_stringt(location.get_line());
9695

9796
if(!location.get_column().empty())
98-
result["column"]=json_stringt(id2string(location.get_column()));
97+
result["column"] = json_stringt(location.get_column());
9998

10099
if(!location.get_function().empty())
101-
result["function"]=json_stringt(id2string(location.get_function()));
100+
result["function"] = json_stringt(location.get_function());
102101

103102
if(!location.get_java_bytecode_index().empty())
104-
result["bytecodeIndex"]=
105-
json_stringt(id2string(location.get_java_bytecode_index()));
103+
result["bytecodeIndex"] = json_stringt(location.get_java_bytecode_index());
106104

107105
return result;
108106
}
@@ -193,7 +191,7 @@ json_objectt json(
193191
for(const auto &component : components)
194192
{
195193
json_objectt &e=members.push_back().make_object();
196-
e["name"]=json_stringt(id2string(component.get_name()));
194+
e["name"] = json_stringt(component.get_name());
197195
e["type"]=json(component.type(), ns, mode);
198196
}
199197
}
@@ -206,7 +204,7 @@ json_objectt json(
206204
for(const auto &component : components)
207205
{
208206
json_objectt &e=members.push_back().make_object();
209-
e["name"]=json_stringt(id2string(component.get_name()));
207+
e["name"] = json_stringt(component.get_name());
210208
e["type"]=json(component.type(), ns, mode);
211209
}
212210
}
@@ -263,15 +261,15 @@ json_objectt json(
263261
std::size_t width=to_bitvector_type(type).get_width();
264262

265263
result["name"]=json_stringt("integer");
266-
result["binary"]=json_stringt(id2string(constant_expr.get_value()));
264+
result["binary"] = json_stringt(constant_expr.get_value());
267265
result["width"]=json_numbert(std::to_string(width));
268266
result["type"]=json_stringt(type_string);
269267
result["data"]=json_stringt(value_string);
270268
}
271269
else if(type.id()==ID_c_enum)
272270
{
273271
result["name"]=json_stringt("integer");
274-
result["binary"]=json_stringt(id2string(constant_expr.get_value()));
272+
result["binary"] = json_stringt(constant_expr.get_value());
275273
result["width"]=json_numbert(type.subtype().get_string(ID_width));
276274
result["type"]=json_stringt("enum");
277275
result["data"]=json_stringt(value_string);
@@ -286,21 +284,21 @@ json_objectt json(
286284
else if(type.id()==ID_bv)
287285
{
288286
result["name"]=json_stringt("bitvector");
289-
result["binary"]=json_stringt(id2string(constant_expr.get_value()));
287+
result["binary"] = json_stringt(constant_expr.get_value());
290288
}
291289
else if(type.id()==ID_fixedbv)
292290
{
293291
result["name"]=json_stringt("fixed");
294292
result["width"]=json_numbert(type.get_string(ID_width));
295-
result["binary"]=json_stringt(id2string(constant_expr.get_value()));
293+
result["binary"] = json_stringt(constant_expr.get_value());
296294
result["data"]=
297295
json_stringt(fixedbvt(to_constant_expr(expr)).to_ansi_c_string());
298296
}
299297
else if(type.id()==ID_floatbv)
300298
{
301299
result["name"]=json_stringt("float");
302300
result["width"]=json_numbert(type.get_string(ID_width));
303-
result["binary"]=json_stringt(id2string(constant_expr.get_value()));
301+
result["binary"] = json_stringt(constant_expr.get_value());
304302
result["data"]=
305303
json_stringt(ieee_floatt(to_constant_expr(expr)).to_ansi_c_string());
306304
}
@@ -341,7 +339,7 @@ json_objectt json(
341339
else if(type.id()==ID_string)
342340
{
343341
result["name"]=json_stringt("string");
344-
result["data"]=json_stringt(id2string(constant_expr.get_value()));
342+
result["data"] = json_stringt(constant_expr.get_value());
345343
}
346344
else
347345
{
@@ -381,7 +379,7 @@ json_objectt json(
381379
{
382380
json_objectt &e=members.push_back().make_object();
383381
e["value"]=json(expr.operands()[m], ns, mode);
384-
e["name"]=json_stringt(id2string(components[m].get_name()));
382+
e["name"] = json_stringt(components[m].get_name());
385383
}
386384
}
387385
}
@@ -392,7 +390,7 @@ json_objectt json(
392390
const union_exprt &union_expr=to_union_expr(expr);
393391
json_objectt &e=result["member"].make_object();
394392
e["value"]=json(union_expr.op(), ns, mode);
395-
e["name"]=json_stringt(id2string(union_expr.get_component_name()));
393+
e["name"] = json_stringt(union_expr.get_component_name());
396394
}
397395
else
398396
result["name"]=json_stringt("unknown");

0 commit comments

Comments
 (0)