Skip to content

Commit 66aa851

Browse files
Merge pull request diffblue#2109 from LAJW/lajw/free-lambda-from-cpplint-oppression
Remove curly brace CPP Lint checks
2 parents 7339638 + 18cab61 commit 66aa851

20 files changed

+68
-107
lines changed

CODING_STANDARD.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ Formatting is enforced using clang-format. For more information about this, see
1919
- Nested function calls do not need to be broken up into separate lines
2020
even if the outer function call does.
2121
- If a method is bigger than 50 lines, break it into parts.
22-
- Put matching `{ }` into the same column.
22+
- Put matching `{ }` into the same column, except for initializer lists and
23+
lambdas, where you should place `{` directly after the closing `)`. This is
24+
to comply with clang-format, which doesn't support aligned curly braces in
25+
these cases.
2326
- Spaces around binary operators (`=`, `+`, `==` ...)
2427
- Space after comma (parameter lists, argument lists, ...)
2528
- Space after colon inside `for`

scripts/cpplint.py

-8
Original file line numberDiff line numberDiff line change
@@ -3972,14 +3972,6 @@ def CheckBracesSpacing(filename, clean_lines, linenum, nesting_state, error):
39723972
error(filename, linenum, 'whitespace/braces', 5,
39733973
'Missing space before {')
39743974

3975-
# Make sure '} else {' has spaces.
3976-
# if Search(r'}else', line):
3977-
# error(filename, linenum, 'whitespace/braces', 5,
3978-
# 'Missing space before else')
3979-
if (Search(r'^.*[^\s].*}$', line) or Search(r'^.*[^\s].*{$', line)) and not(Search(r'{[^}]*}', line)):
3980-
error(filename, linenum, 'whitespace/braces', 5,
3981-
'Put braces on a separate next line')
3982-
39833975
# You shouldn't have a space before a semicolon at the end of the line.
39843976
# There's a special case for "for" since the style guide allows space before
39853977
# the semicolon there.

src/goto-programs/goto_convert.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -1823,10 +1823,8 @@ void goto_convertt::generate_ifthenelse(
18231823
// Note this depends on the fact that `instructions` is a std::list
18241824
// and so goto-program-destructive-append preserves iterator validity.
18251825
if(is_guarded_goto)
1826-
guarded_gotos.push_back({ // NOLINT(whitespace/braces)
1827-
tmp_v.instructions.begin(),
1828-
tmp_w.instructions.begin(),
1829-
guard});
1826+
guarded_gotos.push_back(
1827+
{tmp_v.instructions.begin(), tmp_w.instructions.begin(), guard});
18301828

18311829
dest.destructive_append(tmp_v);
18321830
dest.destructive_append(tmp_w);

src/goto-programs/lazy_goto_model.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ class lazy_goto_modelt : public abstract_goto_modelt
5353
message_handlert &message_handler)
5454
{
5555
return lazy_goto_modelt(
56-
[&handler, &options]
57-
(goto_model_functiont &fun, const abstract_goto_modelt &model) { // NOLINT(*)
56+
[&handler,
57+
&options](goto_model_functiont &fun, const abstract_goto_modelt &model) {
5858
handler.process_goto_function(fun, model, options);
5959
},
60-
[&handler, &options] (goto_modelt &goto_model) -> bool { // NOLINT(*)
60+
[&handler, &options](goto_modelt &goto_model) -> bool {
6161
return handler.process_goto_functions(goto_model, options);
6262
},
6363
message_handler);

src/goto-symex/symex_main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ void goto_symext::symex_threaded_step(
166166
static goto_symext::get_goto_functiont get_function_from_goto_functions(
167167
const goto_functionst &goto_functions)
168168
{
169-
return [&goto_functions](const irep_idt &key) ->
170-
const goto_functionst::goto_functiont & { // NOLINT(*)
169+
return [&goto_functions](
170+
const irep_idt &key) -> const goto_functionst::goto_functiont & {
171171
return goto_functions.function_map.at(key);
172172
};
173173
}

src/java_bytecode/expr2java.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ std::string floating_point_to_java_string(float_type value)
6666
return class_name + ".POSITIVE_INFINITY";
6767
if(std::isinf(value) && value <= 0.)
6868
return class_name + ".NEGATIVE_INFINITY";
69-
const std::string decimal = [&]() -> std::string { // NOLINT
69+
const std::string decimal = [&]() -> std::string {
7070
// Using ostringstream instead of to_string to get string without
7171
// trailing zeros
7272
std::ostringstream raw_stream;
@@ -76,7 +76,7 @@ std::string floating_point_to_java_string(float_type value)
7676
return raw_decimal + ".0";
7777
return raw_decimal;
7878
}();
79-
const bool is_lossless = [&] { // NOLINT
79+
const bool is_lossless = [&] {
8080
if(value == std::numeric_limits<float_type>::min())
8181
return true;
8282
try
@@ -88,7 +88,7 @@ std::string floating_point_to_java_string(float_type value)
8888
return false;
8989
}
9090
}();
91-
const std::string lossless = [&]() -> std::string { // NOLINT
91+
const std::string lossless = [&]() -> std::string {
9292
if(is_lossless)
9393
return decimal;
9494
std::ostringstream stream;

src/java_bytecode/java_bytecode_convert_method.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -895,10 +895,8 @@ static void gather_symbol_live_ranges(
895895
if(e.id()==ID_symbol)
896896
{
897897
const auto &symexpr=to_symbol_expr(e);
898-
auto findit=
899-
result.insert({ // NOLINT(whitespace/braces)
900-
symexpr.get_identifier(),
901-
java_bytecode_convert_methodt::variablet()});
898+
auto findit = result.insert(
899+
{symexpr.get_identifier(), java_bytecode_convert_methodt::variablet()});
902900
auto &var=findit.first->second;
903901
if(findit.second)
904902
{

src/java_bytecode/java_bytecode_instrument.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class java_bytecode_instrumentt:public messaget
7575
optionalt<codet> instrument_expr(const exprt &expr);
7676
};
7777

78-
const std::vector<std::string> exception_needed_classes = { // NOLINT
78+
const std::vector<std::string> exception_needed_classes = {
7979
"java.lang.ArithmeticException",
8080
"java.lang.ArrayIndexOutOfBoundsException",
8181
"java.lang.ClassCastException",

src/java_bytecode/java_bytecode_language.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ bool java_bytecode_languaget::parse(
157157
{
158158
string_preprocess.initialize_known_type_table();
159159

160-
auto get_string_base_classes = [this](const irep_idt &id) { // NOLINT (*)
160+
auto get_string_base_classes = [this](const irep_idt &id) {
161161
return string_preprocess.get_string_type_base_classes(id);
162162
};
163163

src/java_bytecode/remove_exceptions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ void remove_exceptions(
572572
std::map<irep_idt, std::set<irep_idt>> exceptions_map;
573573
uncaught_exceptions(goto_functions, ns, exceptions_map);
574574
remove_exceptionst::function_may_throwt function_may_throw =
575-
[&exceptions_map](const irep_idt &id) { // NOLINT(whitespace/braces)
575+
[&exceptions_map](const irep_idt &id) {
576576
return !exceptions_map[id].empty();
577577
};
578578
remove_exceptionst remove_exceptions(

src/java_bytecode/remove_instanceof.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ std::size_t remove_instanceoft::lower_instanceof(
9090
// Sort alphabetically to make order of generated disjuncts
9191
// independent of class loading order
9292
std::sort(
93-
children.begin(),
94-
children.end(),
95-
[](const irep_idt &a, const irep_idt &b) { // NOLINT
93+
children.begin(), children.end(), [](const irep_idt &a, const irep_idt &b) {
9694
return a.compare(b) < 0;
9795
});
9896

src/java_bytecode/replace_java_nondet.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,7 @@ static goto_programt::targett check_and_replace_target(
249249
"goto_program missing END_FUNCTION instruction");
250250

251251
std::for_each(
252-
target,
253-
after_matching_assignment,
254-
[](goto_programt::instructiont &instr) { // NOLINT (*)
252+
target, after_matching_assignment, [](goto_programt::instructiont &instr) {
255253
instr.make_skip();
256254
});
257255

src/jbmc/jbmc_parse_options.cpp

+12-13
Original file line numberDiff line numberDiff line change
@@ -493,13 +493,13 @@ int jbmc_parse_optionst::doit()
493493
std::function<void(bmct &, const symbol_tablet &)> configure_bmc = nullptr;
494494
if(options.get_bool_option("java-unwind-enum-static"))
495495
{
496-
configure_bmc = [](
497-
bmct &bmc, const symbol_tablet &symbol_table) { // NOLINT (*)
498-
bmc.add_loop_unwind_handler([&symbol_table](
499-
const irep_idt &function_id,
500-
unsigned loop_number,
501-
unsigned unwind,
502-
unsigned &max_unwind) { // NOLINT (*)
496+
configure_bmc = [](bmct &bmc, const symbol_tablet &symbol_table) {
497+
bmc.add_loop_unwind_handler(
498+
[&symbol_table](
499+
const irep_idt &function_id,
500+
unsigned loop_number,
501+
unsigned unwind,
502+
unsigned &max_unwind) {
503503
return java_enum_static_init_unwind_handler(
504504
function_id,
505505
loop_number,
@@ -564,7 +564,7 @@ int jbmc_parse_optionst::doit()
564564
// executes. If --paths is active, these dump routines run after every
565565
// paths iteration. Its return value indicates that if we ran any dump
566566
// function, then we should skip the actual solver phase.
567-
auto callback_after_symex = [this, &lazy_goto_model]() { // NOLINT (*)
567+
auto callback_after_symex = [this, &lazy_goto_model]() {
568568
return show_loaded_functions(lazy_goto_model);
569569
};
570570

@@ -729,11 +729,10 @@ void jbmc_parse_optionst::process_goto_function(
729729
remove_exceptions_typest::REMOVE_ADDED_INSTANCEOF);
730730
}
731731

732-
auto function_is_stub =
733-
[&symbol_table, &model](const irep_idt &id) { // NOLINT(*)
734-
return symbol_table.lookup_ref(id).value.is_nil() &&
735-
!model.can_produce_function(id);
736-
};
732+
auto function_is_stub = [&symbol_table, &model](const irep_idt &id) {
733+
return symbol_table.lookup_ref(id).value.is_nil() &&
734+
!model.can_produce_function(id);
735+
};
737736

738737
remove_returns(function, function_is_stub);
739738

src/jsil/jsil_types.cpp

+14-32
Original file line numberDiff line numberDiff line change
@@ -15,54 +15,38 @@ Author: Daiva Naudziuniene, [email protected]
1515

1616
typet jsil_any_type()
1717
{
18-
return jsil_union_typet({ // NOLINT(whitespace/braces)
19-
jsil_empty_type(),
20-
jsil_reference_type(),
21-
jsil_value_type()
22-
});
18+
return jsil_union_typet(
19+
{jsil_empty_type(), jsil_reference_type(), jsil_value_type()});
2320
}
2421

2522
typet jsil_value_or_empty_type()
2623
{
27-
return jsil_union_typet({ // NOLINT(whitespace/braces)
28-
jsil_value_type(),
29-
jsil_empty_type()
30-
});
24+
return jsil_union_typet({jsil_value_type(), jsil_empty_type()});
3125
}
3226

3327
typet jsil_value_or_reference_type()
3428
{
35-
return jsil_union_typet({ // NOLINT(whitespace/braces)
36-
jsil_value_type(),
37-
jsil_reference_type()
38-
});
29+
return jsil_union_typet({jsil_value_type(), jsil_reference_type()});
3930
}
4031

4132
typet jsil_value_type()
4233
{
43-
return jsil_union_typet({ // NOLINT(whitespace/braces)
44-
jsil_undefined_type(),
45-
jsil_null_type(),
46-
jsil_prim_type(),
47-
jsil_object_type()
48-
});
34+
return jsil_union_typet(
35+
{jsil_undefined_type(),
36+
jsil_null_type(),
37+
jsil_prim_type(),
38+
jsil_object_type()});
4939
}
5040

5141
typet jsil_prim_type()
5242
{
53-
return jsil_union_typet({ // NOLINT(whitespace/braces)
54-
floatbv_typet(),
55-
string_typet(),
56-
bool_typet()
57-
});
43+
return jsil_union_typet({floatbv_typet(), string_typet(), bool_typet()});
5844
}
5945

6046
typet jsil_reference_type()
6147
{
62-
return jsil_union_typet({ // NOLINT(whitespace/braces)
63-
jsil_member_reference_type(),
64-
jsil_variable_reference_type()
65-
});
48+
return jsil_union_typet(
49+
{jsil_member_reference_type(), jsil_variable_reference_type()});
6650
}
6751

6852
typet jsil_member_reference_type()
@@ -77,10 +61,8 @@ typet jsil_variable_reference_type()
7761

7862
typet jsil_object_type()
7963
{
80-
return jsil_union_typet({ // NOLINT(whitespace/braces)
81-
jsil_user_object_type(),
82-
jsil_builtin_object_type()
83-
});
64+
return jsil_union_typet(
65+
{jsil_user_object_type(), jsil_builtin_object_type()});
8466
}
8567

8668
typet jsil_user_object_type()

src/solvers/refinement/string_constraint_generator_transformation.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ exprt string_constraint_generatort::add_axioms_for_substring(
128128
lemmas.push_back(equal_exprt(res.length(), minus_exprt(end1, start1)));
129129

130130
// Axiom 2.
131-
constraints.push_back([&] { // NOLINT
131+
constraints.push_back([&] {
132132
const symbol_exprt idx = fresh_univ_index("QA_index_substring", index_type);
133133
return string_constraintt(
134134
idx, res.length(), equal_exprt(res[idx], str[plus_exprt(start1, idx)]));
@@ -197,7 +197,7 @@ exprt string_constraint_generatort::add_axioms_for_trim(
197197
constraints.push_back(a6);
198198

199199
// Axiom 7.
200-
constraints.push_back([&] { // NOLINT
200+
constraints.push_back([&] {
201201
const symbol_exprt n2 = fresh_univ_index("QA_index_trim2", index_type);
202202
const minus_exprt bound(minus_exprt(str.length(), idx), res.length());
203203
const binary_relation_exprt eqn2(
@@ -473,7 +473,7 @@ exprt string_constraint_generatort::add_axioms_for_replace(
473473
char_array_of_pointer(f.arguments()[1], f.arguments()[0]);
474474
if(
475475
const auto maybe_chars =
476-
to_char_pair(f.arguments()[3], f.arguments()[4], [this](const exprt &e) { // NOLINT
476+
to_char_pair(f.arguments()[3], f.arguments()[4], [this](const exprt &e) {
477477
return get_string_expr(e);
478478
}))
479479
{

src/solvers/refinement/string_refinement.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ decision_proceduret::resultt string_refinementt::dec_solve()
692692
constraints.begin(),
693693
constraints.end(),
694694
std::back_inserter(axioms.universal),
695-
[&](string_constraintt constraint) { // NOLINT
695+
[&](string_constraintt constraint) {
696696
symbol_resolve.replace_expr(constraint);
697697
DATA_INVARIANT(
698698
is_valid_string_constraint(error(), ns, constraint),
@@ -707,14 +707,14 @@ decision_proceduret::resultt string_refinementt::dec_solve()
707707
not_contains_constraints.begin(),
708708
not_contains_constraints.end(),
709709
std::back_inserter(axioms.not_contains),
710-
[&](string_not_contains_constraintt axiom) { // NOLINT
710+
[&](string_not_contains_constraintt axiom) {
711711
symbol_resolve.replace_expr(axiom);
712712
return axiom;
713713
});
714714

715715
for(const auto &nc_axiom : axioms.not_contains)
716716
{
717-
const auto &witness_type = [&] { // NOLINT
717+
const auto &witness_type = [&] {
718718
const auto &rtype = to_array_type(nc_axiom.s0().type());
719719
const typet &index_type = rtype.size().type();
720720
return array_typet(index_type, infinity_exprt(index_type));
@@ -1920,7 +1920,7 @@ static void update_index_set(
19201920
static optionalt<exprt>
19211921
find_index(const exprt &expr, const exprt &str, const symbol_exprt &qvar)
19221922
{
1923-
auto index_str_containing_qvar = [&](const exprt &e) { // NOLINT
1923+
auto index_str_containing_qvar = [&](const exprt &e) {
19241924
if(auto index_expr = expr_try_dynamic_cast<index_exprt>(e))
19251925
{
19261926
const auto &arr = index_expr->array();

src/util/graph.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ void get_reachable(
486486
{
487487
auto n = stack.back();
488488
stack.pop_back();
489-
for_each_successor(n, [&](const nodet &node) { // NOLINT
489+
for_each_successor(n, [&](const nodet &node) {
490490
if(set.insert(node).second)
491491
stack.push_back(node);
492492
});
@@ -749,8 +749,8 @@ void output_dot_generic(
749749
&for_each_succ,
750750
const std::function<std::string(const node_index_type &)> node_to_string)
751751
{
752-
for_each_node([&](const node_index_type &i) { // NOLINT
753-
for_each_succ(i, [&](const node_index_type &n) { // NOLINT
752+
for_each_node([&](const node_index_type &i) {
753+
for_each_succ(i, [&](const node_index_type &n) {
754754
out << node_to_string(i) << " -> " << node_to_string(n) << '\n';
755755
});
756756
});
@@ -784,14 +784,13 @@ template <class N>
784784
void grapht<N>::output_dot(std::ostream &out) const
785785
{
786786
const auto for_each_node =
787-
[&](const std::function<void(const node_indext &)> &f) { // NOLINT
787+
[&](const std::function<void(const node_indext &)> &f) {
788788
for(node_indext i = 0; i < nodes.size(); ++i)
789789
f(i);
790790
};
791791

792792
const auto for_each_succ = [&](
793-
const node_indext &i,
794-
const std::function<void(const node_indext &)> &f) { // NOLINT
793+
const node_indext &i, const std::function<void(const node_indext &)> &f) {
795794
for_each_successor(i, f);
796795
};
797796

unit/java_bytecode/inherited_static_fields/inherited_static_fields.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
/// \return true if a suitable symbol_exprt is found
2020
static bool contains_symbol_reference(const exprt &expr, const irep_idt &id)
2121
{
22-
return
23-
std::any_of(
24-
expr.depth_begin(),
25-
expr.depth_end(),
26-
[id](const exprt &e) { // NOLINT (*)
27-
return e.id() == ID_symbol && to_symbol_expr(e).get_identifier() == id;
28-
});
22+
return std::any_of(
23+
expr.depth_begin(), expr.depth_end(), [id](const exprt &e) {
24+
return e.id() == ID_symbol && to_symbol_expr(e).get_identifier() == id;
25+
});
2926
}
3027

3128
SCENARIO(

0 commit comments

Comments
 (0)