Skip to content

Commit da12819

Browse files
authored
Merge pull request diffblue#3136 from tautschnig/lgtm-cleanup
Cleanup some bits of code that trip up LGTM
2 parents db7f860 + a02dbfd commit da12819

File tree

9 files changed

+58
-65
lines changed

9 files changed

+58
-65
lines changed

jbmc/src/java_bytecode/generic_parameter_specialization_map_keys.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ get_all_generic_parameters(const typet &type)
3939
/// on destruction; otherwise do nothing.
4040
/// \param parameters generic parameters that are the keys of the pairs to add
4141
/// \param types a type to add for each parameter
42-
const void generic_parameter_specialization_map_keyst::insert_pairs(
42+
void generic_parameter_specialization_map_keyst::insert_pairs(
4343
const std::vector<java_generic_parametert> &parameters,
4444
const std::vector<reference_typet> &types)
4545
{
@@ -90,7 +90,7 @@ const void generic_parameter_specialization_map_keyst::insert_pairs(
9090
/// \param pointer_type pointer type to get the specialized generic types from
9191
/// \param pointer_subtype_struct struct type to which the generic pointer
9292
/// points, must be generic if the pointer is generic
93-
const void generic_parameter_specialization_map_keyst::insert_pairs_for_pointer(
93+
void generic_parameter_specialization_map_keyst::insert_pairs_for_pointer(
9494
const pointer_typet &pointer_type,
9595
const typet &pointer_subtype_struct)
9696
{
@@ -139,7 +139,7 @@ const void generic_parameter_specialization_map_keyst::insert_pairs_for_pointer(
139139
/// \param symbol_type symbol type to get the specialized generic types from
140140
/// \param symbol_struct struct type of the symbol type, must be generic if
141141
/// the symbol is generic
142-
const void generic_parameter_specialization_map_keyst::insert_pairs_for_symbol(
142+
void generic_parameter_specialization_map_keyst::insert_pairs_for_symbol(
143143
const symbol_typet &symbol_type,
144144
const typet &symbol_struct)
145145
{

jbmc/src/java_bytecode/generic_parameter_specialization_map_keys.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ class generic_parameter_specialization_map_keyst
4747
generic_parameter_specialization_map_keyst &
4848
operator=(const generic_parameter_specialization_map_keyst &) = delete;
4949

50-
const void insert_pairs_for_pointer(
50+
void insert_pairs_for_pointer(
5151
const pointer_typet &pointer_type,
5252
const typet &pointer_subtype_struct);
53-
const void insert_pairs_for_symbol(
53+
void insert_pairs_for_symbol(
5454
const symbol_typet &symbol_type,
5555
const typet &symbol_struct);
5656

@@ -60,7 +60,7 @@ class generic_parameter_specialization_map_keyst
6060
/// Keys of the entries to pop on destruction
6161
std::vector<irep_idt> erase_keys;
6262

63-
const void insert_pairs(
63+
void insert_pairs(
6464
const std::vector<java_generic_parametert> &parameters,
6565
const std::vector<reference_typet> &types);
6666
};

jbmc/src/java_bytecode/java_types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class java_class_typet:public class_typet
111111
return set(ID_access, access);
112112
}
113113

114-
const bool get_is_inner_class() const
114+
bool get_is_inner_class() const
115115
{
116116
return get_bool(ID_is_inner_class);
117117
}
@@ -141,7 +141,7 @@ class java_class_typet:public class_typet
141141
return set(ID_super_class, super_class);
142142
}
143143

144-
const bool get_is_static_class() const
144+
bool get_is_static_class() const
145145
{
146146
return get_bool(ID_is_static);
147147
}
@@ -151,7 +151,7 @@ class java_class_typet:public class_typet
151151
return set(ID_is_static, is_static_class);
152152
}
153153

154-
const bool get_is_anonymous_class() const
154+
bool get_is_anonymous_class() const
155155
{
156156
return get_bool(ID_is_anonymous);
157157
}

jbmc/unit/solvers/refinement/string_constraint_instantiation/instantiate_not_contains.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ std::set<exprt> full_index_set(const array_string_exprt &s)
100100
}
101101

102102
/// Create the cartesian product of two sets.
103-
template<class T, class U>
104-
std::set<std::pair<T, U>> product(const std::set<T> ts, const std::set<U> us)
103+
template <class X, class Y>
104+
std::set<std::pair<X, Y>> product(const std::set<X> xs, const std::set<Y> ys)
105105
{
106-
std::set<std::pair<T, U>> s;
107-
for(const auto &t : ts)
108-
for(const auto &u : us)
109-
s.insert(std::pair<T, U>(t, u));
106+
std::set<std::pair<X, Y>> s;
107+
for(const auto &x : xs)
108+
for(const auto &y : ys)
109+
s.insert(std::pair<X, Y>(x, y));
110110
return s;
111111
}
112112

src/goto-cc/linker_script_merge.cpp

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -730,45 +730,38 @@ int linker_script_merget::goto_and_object_mismatch(
730730

731731
int linker_script_merget::linker_data_is_malformed(const jsont &data) const
732732
{
733-
return (!(data.is_object() &&
734-
data.object.find("regions")!=data.object.end() &&
735-
data.object.find("addresses")!=data.object.end() &&
736-
data["regions"].is_array() &&
737-
data["addresses"].is_array() &&
738-
std::all_of(data["addresses"].array.begin(),
739-
data["addresses"].array.end(),
740-
[](jsont j)
741-
{
742-
return j.is_object() &&
743-
j.object.find("val")!=j.object.end() &&
744-
j.object.find("sym")!=j.object.end() &&
745-
j["val"].is_number() &&
746-
j["sym"].is_string();
747-
}) &&
748-
std::all_of(data["regions"].array.begin(),
749-
data["regions"].array.end(),
750-
[](jsont j)
751-
{
752-
return j.is_object() &&
753-
j.object.find("start")!=j.object.end() &&
754-
j.object.find("size")!=j.object.end() &&
755-
j.object.find("annot")!=j.object.end() &&
756-
j.object.find("commt")!=j.object.end() &&
757-
j.object.find("start-symbol")!=j.object.end() &&
758-
j.object.find("has-end-symbol")!=j.object.end() &&
759-
j.object.find("section")!=j.object.end() &&
760-
j["start"].is_number() &&
761-
j["size"].is_number() &&
762-
j["annot"].is_string() &&
763-
j["start-symbol"].is_string() &&
764-
j["section"].is_string() &&
765-
j["commt"].is_string() &&
766-
( (j["has-end-symbol"].is_true() &&
767-
j.object.find("end-symbol")!=j.object.end() &&
768-
j["end-symbol"].is_string())
769-
||(j["has-end-symbol"].is_false() &&
770-
j.object.find("size-symbol")!=j.object.end() &&
771-
j.object.find("end-symbol")==j.object.end() &&
772-
j["size-symbol"].is_string()));
773-
})));
733+
return (
734+
!(data.is_object() && data.object.find("regions") != data.object.end() &&
735+
data.object.find("addresses") != data.object.end() &&
736+
data["regions"].is_array() && data["addresses"].is_array() &&
737+
std::all_of(
738+
data["addresses"].array.begin(),
739+
data["addresses"].array.end(),
740+
[](const jsont &j) {
741+
return j.is_object() && j.object.find("val") != j.object.end() &&
742+
j.object.find("sym") != j.object.end() &&
743+
j["val"].is_number() && j["sym"].is_string();
744+
}) &&
745+
std::all_of(
746+
data["regions"].array.begin(),
747+
data["regions"].array.end(),
748+
[](const jsont &j) {
749+
return j.is_object() && j.object.find("start") != j.object.end() &&
750+
j.object.find("size") != j.object.end() &&
751+
j.object.find("annot") != j.object.end() &&
752+
j.object.find("commt") != j.object.end() &&
753+
j.object.find("start-symbol") != j.object.end() &&
754+
j.object.find("has-end-symbol") != j.object.end() &&
755+
j.object.find("section") != j.object.end() &&
756+
j["start"].is_number() && j["size"].is_number() &&
757+
j["annot"].is_string() && j["start-symbol"].is_string() &&
758+
j["section"].is_string() && j["commt"].is_string() &&
759+
((j["has-end-symbol"].is_true() &&
760+
j.object.find("end-symbol") != j.object.end() &&
761+
j["end-symbol"].is_string()) ||
762+
(j["has-end-symbol"].is_false() &&
763+
j.object.find("size-symbol") != j.object.end() &&
764+
j.object.find("end-symbol") == j.object.end() &&
765+
j["size-symbol"].is_string()));
766+
})));
774767
}

src/goto-cc/linker_script_merge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class replacement_predicatet
5050
/// If this function returns true, the entire expression should be replaced by
5151
/// a pointer whose underlying symbol is the symbol returned by
5252
/// replacement_predicatet::inner_symbol().
53-
const bool match(const exprt &expr, const namespacet &ns) const
53+
bool match(const exprt &expr, const namespacet &ns) const
5454
{
5555
return _match(expr, ns);
5656
};

src/goto-programs/printf_formatter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void printf_formattert::print(std::ostream &out)
4747
while(!eol()) process_char(out);
4848
}
4949

50-
catch(eol_exceptiont)
50+
catch(const eol_exceptiont &)
5151
{
5252
}
5353
}

src/solvers/sat/satcheck_minisat2.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void satcheck_minisat2_baset<T>::lcnf(const bvt &bv)
142142

143143
clause_counter++;
144144
}
145-
catch(Minisat::OutOfMemoryException)
145+
catch(const Minisat::OutOfMemoryException &)
146146
{
147147
messaget::error() << "SAT checker ran out of memory" << eom;
148148
status = statust::ERROR;
@@ -264,7 +264,7 @@ propt::resultt satcheck_minisat2_baset<T>::prop_solve()
264264
status=statust::UNSAT;
265265
return resultt::P_UNSATISFIABLE;
266266
}
267-
catch(Minisat::OutOfMemoryException)
267+
catch(const Minisat::OutOfMemoryException &)
268268
{
269269
messaget::error() <<
270270
"SAT checker ran out of memory" << eom;
@@ -288,7 +288,7 @@ void satcheck_minisat2_baset<T>::set_assignment(literalt a, bool value)
288288
value ^= sign;
289289
solver->model[v] = Minisat::lbool(value);
290290
}
291-
catch(Minisat::OutOfMemoryException)
291+
catch(const Minisat::OutOfMemoryException &)
292292
{
293293
messaget::error() << "SAT checker ran out of memory" << eom;
294294
status = statust::ERROR;
@@ -359,7 +359,7 @@ void satcheck_minisat_simplifiert::set_frozen(literalt a)
359359
solver->setFrozen(a.var_no(), true);
360360
}
361361
}
362-
catch(Minisat::OutOfMemoryException)
362+
catch(const Minisat::OutOfMemoryException &)
363363
{
364364
messaget::error() << "SAT checker ran out of memory" << eom;
365365
status = statust::ERROR;

src/util/sharing_map.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ class sharing_mapt
341341

342342
void iterate(
343343
const baset &n,
344-
const unsigned depth,
344+
const unsigned start_depth,
345345
std::function<void(const key_type &k, const mapped_type &m)> f) const;
346346

347347
void gather_all(const baset &n, const unsigned depth, delta_viewt &delta_view)
@@ -375,13 +375,13 @@ class sharing_mapt
375375
SHARING_MAPT(void)
376376
::iterate(
377377
const baset &n,
378-
unsigned depth,
378+
unsigned start_depth,
379379
std::function<void(const key_type &k, const mapped_type &m)> f) const
380380
{
381381
typedef std::pair<unsigned, const baset *> stack_itemt;
382382

383383
std::stack<stack_itemt> stack;
384-
stack.push({depth, &n});
384+
stack.push({start_depth, &n});
385385

386386
do
387387
{

0 commit comments

Comments
 (0)