Skip to content

Commit 2b15ce0

Browse files
committed
Remove unnecessary brackets in constructon of json_objectt
With the new constructors, these brackets are no longer required and can be removed, in order to improve readability.
1 parent 4453296 commit 2b15ce0

File tree

13 files changed

+109
-110
lines changed

13 files changed

+109
-110
lines changed

jbmc/src/jbmc/jbmc_parse_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ int jbmc_parse_optionst::doit()
465465
break;
466466
case ui_message_handlert::uit::JSON_UI:
467467
{
468-
json_objectt json_options({{"options", options.to_json()}});
468+
json_objectt json_options{{"options", options.to_json()}};
469469
debug() << json_options;
470470
break;
471471
}

src/analyses/ai.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ jsont ai_baset::output_json(
101101
std::ostringstream out;
102102
goto_program.output_instruction(ns, identifier, out, *i_it);
103103

104-
json_objectt location(
105-
{{"locationNumber", json_numbert(std::to_string(i_it->location_number))},
106-
{"sourceLocation", json_stringt(i_it->source_location.as_string())},
107-
{"abstractState", abstract_state_before(i_it)->output_json(*this, ns)},
108-
{"instruction", json_stringt(out.str())}});
104+
json_objectt location{
105+
{"locationNumber", json_numbert(std::to_string(i_it->location_number))},
106+
{"sourceLocation", json_stringt(i_it->source_location.as_string())},
107+
{"abstractState", abstract_state_before(i_it)->output_json(*this, ns)},
108+
{"instruction", json_stringt(out.str())}};
109109

110110
contents.push_back(std::move(location));
111111
}

src/analyses/dependence_graph.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -283,19 +283,19 @@ jsont dep_graph_domaint::output_json(
283283

284284
for(const auto &cd : control_deps)
285285
{
286-
json_objectt link(
287-
{{"locationNumber", json_numbert(std::to_string(cd->location_number))},
288-
{"sourceLocation", json(cd->source_location)},
289-
{"type", json_stringt("control")}});
286+
json_objectt link{
287+
{"locationNumber", json_numbert(std::to_string(cd->location_number))},
288+
{"sourceLocation", json(cd->source_location)},
289+
{"type", json_stringt("control")}};
290290
graph.push_back(std::move(link));
291291
}
292292

293293
for(const auto &dd : data_deps)
294294
{
295-
json_objectt link(
296-
{{"locationNumber", json_numbert(std::to_string(dd->location_number))},
297-
{"sourceLocation", json(dd->source_location)},
298-
{"type", json_stringt("data")}});
295+
json_objectt link{
296+
{"locationNumber", json_numbert(std::to_string(dd->location_number))},
297+
{"sourceLocation", json(dd->source_location)},
298+
{"type", json_stringt("data")}};
299299
graph.push_back(std::move(link));
300300
}
301301

src/cbmc/bmc_cover.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ bool bmc_covert::operator()()
383383
{
384384
if(step.is_input())
385385
{
386-
json_objectt json_input({{"id", json_stringt(step.io_id)}});
386+
json_objectt json_input{{"id", json_stringt(step.io_id)}};
387387
if(step.io_args.size()==1)
388388
json_input["value"]=
389389
json(step.io_args.front(), bmc.ns, ID_unknown);

src/goto-analyzer/taint_analysis.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,12 @@ bool taint_analysist::operator()(
353353

354354
if(use_json)
355355
{
356-
json_objectt json(
357-
{{"bugClass",
358-
json_stringt(i_it->source_location.get_property_class())},
359-
{"file", json_stringt(i_it->source_location.get_file())},
360-
{"line",
361-
json_numbert(id2string(i_it->source_location.get_line()))}});
356+
json_objectt json{
357+
{"bugClass",
358+
json_stringt(i_it->source_location.get_property_class())},
359+
{"file", json_stringt(i_it->source_location.get_file())},
360+
{"line",
361+
json_numbert(id2string(i_it->source_location.get_line()))}};
362362
json_result.push_back(std::move(json));
363363
}
364364
else

src/goto-analyzer/unreachable_instructions.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ static void add_to_json(
124124
DATA_INVARIANT(end_function->is_end_function(),
125125
"The last instruction in a goto-program must be END_FUNCTION");
126126

127-
json_objectt entry(
128-
{{"function", json_stringt(end_function->function)},
129-
{"fileName",
130-
json_stringt(concat_dir_file(
131-
id2string(end_function->source_location.get_working_directory()),
132-
id2string(end_function->source_location.get_file())))}});
127+
json_objectt entry{
128+
{"function", json_stringt(end_function->function)},
129+
{"fileName",
130+
json_stringt(concat_dir_file(
131+
id2string(end_function->source_location.get_working_directory()),
132+
id2string(end_function->source_location.get_file())))}};
133133

134134
json_arrayt &dead_ins=entry["unreachableInstructions"].make_array();
135135

@@ -152,8 +152,8 @@ static void add_to_json(
152152

153153
// print info for file actually with full path
154154
const source_locationt &l=it->second->source_location;
155-
json_objectt i_entry(
156-
{{"sourceLocation", json(l)}, {"statement", json_stringt(s)}});
155+
json_objectt i_entry{{"sourceLocation", json(l)},
156+
{"statement", json_stringt(s)}};
157157
dead_ins.push_back(std::move(i_entry));
158158
}
159159

@@ -256,14 +256,14 @@ static void json_output_function(
256256
const source_locationt &last_location,
257257
json_arrayt &dest)
258258
{
259-
json_objectt entry(
260-
{{"function", json_stringt(function)},
261-
{"file name",
262-
json_stringt(concat_dir_file(
263-
id2string(first_location.get_working_directory()),
264-
id2string(first_location.get_file())))},
265-
{"first line", json_numbert(id2string(first_location.get_line()))},
266-
{"last line", json_numbert(id2string(last_location.get_line()))}});
259+
json_objectt entry{
260+
{"function", json_stringt(function)},
261+
{"file name",
262+
json_stringt(concat_dir_file(
263+
id2string(first_location.get_working_directory()),
264+
id2string(first_location.get_file())))},
265+
{"first line", json_numbert(id2string(first_location.get_line()))},
266+
{"last line", json_numbert(id2string(last_location.get_line()))}};
267267

268268
dest.push_back(std::move(entry));
269269
}

src/goto-diff/goto_diff_base.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ void goto_difft::output_functions() const
3838
}
3939
case ui_message_handlert::uit::JSON_UI:
4040
{
41-
json_objectt json_result(
42-
{{"totalNumberOfFunctions",
43-
json_stringt(std::to_string(total_functions_count))}});
41+
json_objectt json_result{
42+
{"totalNumberOfFunctions",
43+
json_stringt(std::to_string(total_functions_count))}};
4444
convert_function_group_json(
4545
json_result["newFunctions"].make_array(), new_functions, goto_model2);
4646
convert_function_group_json(

src/goto-instrument/unwind.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,10 @@ jsont goto_unwindt::unwind_logt::output_log_json() const
339339
goto_programt::const_targett target=it->first;
340340
unsigned location_number=it->second;
341341

342-
json_objectt object(
343-
{{"originalLocationNumber",
344-
json_numbert(std::to_string(location_number))},
345-
{"newLocationNumber",
346-
json_numbert(std::to_string(target->location_number))}});
342+
json_objectt object{
343+
{"originalLocationNumber", json_numbert(std::to_string(location_number))},
344+
{"newLocationNumber",
345+
json_numbert(std::to_string(target->location_number))}};
347346

348347
json_unwound.push_back(std::move(object));
349348
}

src/goto-programs/goto_inline_class.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -887,17 +887,17 @@ jsont goto_inlinet::goto_inline_logt::output_inline_log_json() const
887887

888888
PRECONDITION(start->location_number <= end->location_number);
889889

890-
json_arrayt json_orig(
891-
{json_numbert(std::to_string(info.begin_location_number)),
892-
json_numbert(std::to_string(info.end_location_number))});
893-
json_arrayt json_new({json_numbert(std::to_string(start->location_number)),
894-
json_numbert(std::to_string(end->location_number))});
895-
896-
json_objectt object(
897-
{{"call", json_numbert(std::to_string(info.call_location_number))},
898-
{"function", json_stringt(info.function.c_str())},
899-
{"originalSegment", std::move(json_orig)},
900-
{"inlinedSegment", std::move(json_new)}});
890+
json_arrayt json_orig{
891+
json_numbert(std::to_string(info.begin_location_number)),
892+
json_numbert(std::to_string(info.end_location_number))};
893+
json_arrayt json_new{json_numbert(std::to_string(start->location_number)),
894+
json_numbert(std::to_string(end->location_number))};
895+
896+
json_objectt object{
897+
{"call", json_numbert(std::to_string(info.call_location_number))},
898+
{"function", json_stringt(info.function.c_str())},
899+
{"originalSegment", std::move(json_orig)},
900+
{"inlinedSegment", std::move(json_new)}};
901901

902902
json_inlined.push_back(std::move(object));
903903
}

src/goto-programs/json_expr.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ json_objectt json(const typet &type, const namespacet &ns, const irep_idt &mode)
172172
to_struct_type(type).components();
173173
for(const auto &component : components)
174174
{
175-
json_objectt e({{"name", json_stringt(component.get_name())},
176-
{"type", json(component.type(), ns, mode)}});
175+
json_objectt e{{"name", json_stringt(component.get_name())},
176+
{"type", json(component.type(), ns, mode)}};
177177
members.push_back(std::move(e));
178178
}
179179
}
@@ -185,8 +185,8 @@ json_objectt json(const typet &type, const namespacet &ns, const irep_idt &mode)
185185
to_union_type(type).components();
186186
for(const auto &component : components)
187187
{
188-
json_objectt e({{"name", json_stringt(component.get_name())},
189-
{"type", json(component.type(), ns, mode)}});
188+
json_objectt e{{"name", json_stringt(component.get_name())},
189+
{"type", json(component.type(), ns, mode)}};
190190
members.push_back(std::move(e));
191191
}
192192
}
@@ -348,8 +348,8 @@ json_objectt json(const exprt &expr, const namespacet &ns, const irep_idt &mode)
348348

349349
forall_operands(it, expr)
350350
{
351-
json_objectt e({{"index", json_numbert(std::to_string(index))},
352-
{"value", json(*it, ns, mode)}});
351+
json_objectt e{{"index", json_numbert(std::to_string(index))},
352+
{"value", json(*it, ns, mode)}};
353353
elements.push_back(std::move(e));
354354
index++;
355355
}
@@ -370,8 +370,8 @@ json_objectt json(const exprt &expr, const namespacet &ns, const irep_idt &mode)
370370
json_arrayt &members = result["members"].make_array();
371371
for(std::size_t m = 0; m < expr.operands().size(); m++)
372372
{
373-
json_objectt e({{"value", json(expr.operands()[m], ns, mode)},
374-
{"name", json_stringt(components[m].get_name())}});
373+
json_objectt e{{"value", json(expr.operands()[m], ns, mode)},
374+
{"name", json_stringt(components[m].get_name())}};
375375
members.push_back(std::move(e));
376376
}
377377
}

src/goto-programs/show_goto_functions_json.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ json_objectt show_goto_functions_jsont::convert(
7070
for(const goto_programt::instructiont &instruction :
7171
function.body.instructions)
7272
{
73-
json_objectt instruction_entry(
74-
{{"instructionId", json_stringt(instruction.to_string())}});
73+
json_objectt instruction_entry{
74+
{"instructionId", json_stringt(instruction.to_string())}};
7575

7676
if(instruction.code.source_location().is_not_nil())
7777
{

src/goto-programs/show_properties.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ void convert_properties_json(
129129

130130
irep_idt property_id=source_location.get_property_id();
131131

132-
json_objectt json_property(
133-
{{"name", json_stringt(property_id)},
134-
{"class", json_stringt(property_class)},
135-
{"sourceLocation", json(source_location)},
136-
{"description", json_stringt(description)},
137-
{"expression", json_stringt(from_expr(ns, identifier, ins.guard))}});
132+
json_objectt json_property{
133+
{"name", json_stringt(property_id)},
134+
{"class", json_stringt(property_class)},
135+
{"sourceLocation", json(source_location)},
136+
{"description", json_stringt(description)},
137+
{"expression", json_stringt(from_expr(ns, identifier, ins.guard))}};
138138

139139
if(!source_location.get_basic_block_covered_lines().empty())
140140
json_property["coveredLines"] =
@@ -155,7 +155,7 @@ void show_properties_json(
155155
for(const auto &fct : goto_functions.function_map)
156156
convert_properties_json(json_properties, ns, fct.first, fct.second.body);
157157

158-
json_objectt json_result({{"properties", json_properties}});
158+
json_objectt json_result{{"properties", json_properties}};
159159
msg.result() << json_result;
160160
}
161161

src/goto-programs/show_symbol_table.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -194,36 +194,36 @@ static void show_symbol_table_json_ui(
194194
if(symbol.value.is_not_nil())
195195
ptr->from_expr(symbol.value, value_str, ns);
196196

197-
json_objectt symbol_json(
198-
{{"prettyName", json_stringt(symbol.pretty_name)},
199-
{"name", json_stringt(symbol.name)},
200-
{"baseName", json_stringt(symbol.base_name)},
201-
{"mode", json_stringt(symbol.mode)},
202-
{"module", json_stringt(symbol.module)},
203-
204-
{"prettyType", json_stringt(type_str)},
205-
{"prettyValue", json_stringt(value_str)},
206-
207-
{"type", irep_converter.convert_from_irep(symbol.type)},
208-
{"value", irep_converter.convert_from_irep(symbol.value)},
209-
{"location", irep_converter.convert_from_irep(symbol.location)},
210-
211-
{"isType", jsont::json_boolean(symbol.is_type)},
212-
{"isMacro", jsont::json_boolean(symbol.is_macro)},
213-
{"isExported", jsont::json_boolean(symbol.is_exported)},
214-
{"isInput", jsont::json_boolean(symbol.is_input)},
215-
{"isOutput", jsont::json_boolean(symbol.is_output)},
216-
{"isStateVar", jsont::json_boolean(symbol.is_state_var)},
217-
{"isProperty", jsont::json_boolean(symbol.is_property)},
218-
{"isStaticLifetime", jsont::json_boolean(symbol.is_static_lifetime)},
219-
{"isThreadLocal", jsont::json_boolean(symbol.is_thread_local)},
220-
{"isLvalue", jsont::json_boolean(symbol.is_lvalue)},
221-
{"isFileLocal", jsont::json_boolean(symbol.is_file_local)},
222-
{"isExtern", jsont::json_boolean(symbol.is_extern)},
223-
{"isVolatile", jsont::json_boolean(symbol.is_volatile)},
224-
{"isParameter", jsont::json_boolean(symbol.is_parameter)},
225-
{"isAuxiliary", jsont::json_boolean(symbol.is_auxiliary)},
226-
{"isWeak", jsont::json_boolean(symbol.is_weak)}});
197+
json_objectt symbol_json{
198+
{"prettyName", json_stringt(symbol.pretty_name)},
199+
{"name", json_stringt(symbol.name)},
200+
{"baseName", json_stringt(symbol.base_name)},
201+
{"mode", json_stringt(symbol.mode)},
202+
{"module", json_stringt(symbol.module)},
203+
204+
{"prettyType", json_stringt(type_str)},
205+
{"prettyValue", json_stringt(value_str)},
206+
207+
{"type", irep_converter.convert_from_irep(symbol.type)},
208+
{"value", irep_converter.convert_from_irep(symbol.value)},
209+
{"location", irep_converter.convert_from_irep(symbol.location)},
210+
211+
{"isType", jsont::json_boolean(symbol.is_type)},
212+
{"isMacro", jsont::json_boolean(symbol.is_macro)},
213+
{"isExported", jsont::json_boolean(symbol.is_exported)},
214+
{"isInput", jsont::json_boolean(symbol.is_input)},
215+
{"isOutput", jsont::json_boolean(symbol.is_output)},
216+
{"isStateVar", jsont::json_boolean(symbol.is_state_var)},
217+
{"isProperty", jsont::json_boolean(symbol.is_property)},
218+
{"isStaticLifetime", jsont::json_boolean(symbol.is_static_lifetime)},
219+
{"isThreadLocal", jsont::json_boolean(symbol.is_thread_local)},
220+
{"isLvalue", jsont::json_boolean(symbol.is_lvalue)},
221+
{"isFileLocal", jsont::json_boolean(symbol.is_file_local)},
222+
{"isExtern", jsont::json_boolean(symbol.is_extern)},
223+
{"isVolatile", jsont::json_boolean(symbol.is_volatile)},
224+
{"isParameter", jsont::json_boolean(symbol.is_parameter)},
225+
{"isAuxiliary", jsont::json_boolean(symbol.is_auxiliary)},
226+
{"isWeak", jsont::json_boolean(symbol.is_weak)}};
227227

228228
result.push_back(id2string(symbol.name), std::move(symbol_json));
229229
}
@@ -265,15 +265,15 @@ static void show_symbol_table_brief_json_ui(
265265
if(symbol.type.is_not_nil())
266266
ptr->from_type(symbol.type, type_str, ns);
267267

268-
json_objectt symbol_json(
269-
{{"prettyName", json_stringt(symbol.pretty_name)},
270-
{"baseName", json_stringt(symbol.base_name)},
271-
{"mode", json_stringt(symbol.mode)},
272-
{"module", json_stringt(symbol.module)},
268+
json_objectt symbol_json{
269+
{"prettyName", json_stringt(symbol.pretty_name)},
270+
{"baseName", json_stringt(symbol.base_name)},
271+
{"mode", json_stringt(symbol.mode)},
272+
{"module", json_stringt(symbol.module)},
273273

274-
{"prettyType", json_stringt(type_str)},
274+
{"prettyType", json_stringt(type_str)},
275275

276-
{"type", irep_converter.convert_from_irep(symbol.type)}});
276+
{"type", irep_converter.convert_from_irep(symbol.type)}};
277277

278278
result.push_back(id2string(symbol.name), std::move(symbol_json));
279279
}

0 commit comments

Comments
 (0)