Skip to content

Commit 00b31d9

Browse files
andreast271tautschnig
authored andcommitted
Style improvements
1 parent c11a71c commit 00b31d9

6 files changed

+24
-33
lines changed

src/cpp/cpp_scope.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ void cpp_scopet::lookup(
142142
other_scope.lookup(base_name, QUALIFIED, id_class, id_set);
143143
}
144144

145-
if(!id_set.empty() &&
146-
id_class!=id_classt::TEMPLATE)
145+
if(!id_set.empty() && id_class!=id_classt::TEMPLATE)
147146
return; // done, upwards scopes are hidden
148147

149148
// secondary scopes

src/cpp/cpp_typecheck.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,11 @@ bool cpp_typecheckt::contains_cpp_name(const exprt &expr)
333333
{
334334
if(expr.id()==ID_cpp_name)
335335
return true;
336-
forall_operands(it, expr)
337-
if(contains_cpp_name(*it))
336+
337+
for(const exprt &op : expr.operands())
338+
{
339+
if(contains_cpp_name(op))
338340
return true;
341+
}
339342
return false;
340343
}

src/cpp/cpp_typecheck_declaration.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Author: Daniel Kroening, [email protected]
66
77
\********************************************************************/
88

9-
109
/// \file
1110
/// C++ Language Type Checking
1211

src/cpp/cpp_typecheck_method_bodies.cpp

+13-22
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,12 @@ void cpp_typecheckt::typecheck_method_bodies()
4040
continue;
4141

4242
#ifdef DEBUG
43-
std::cout << "convert_method_body: " << method_symbol.name << std::endl;
44-
std::cout << " is_not_nil: " << body.is_not_nil() << std::endl;
45-
std::cout << " !is_zero: " << (!body.is_zero()) << std::endl;
43+
std::cout << "convert_method_body: " << method_symbol.name << "\n";
44+
std::cout << " is_not_nil: " << body.is_not_nil() << "\n";
45+
std::cout << " !is_zero: " << (!body.is_zero()) << "\n";
4646
#endif
47-
if(body.is_not_nil() &&
48-
!body.is_zero())
49-
{
47+
if(body.is_not_nil() && !body.is_zero())
5048
convert_function(method_symbol);
51-
}
5249
}
5350

5451
old_instantiation_stack.swap(instantiation_stack);
@@ -57,22 +54,16 @@ void cpp_typecheckt::typecheck_method_bodies()
5754
void cpp_typecheckt::add_method_body(symbolt *_method_symbol)
5855
{
5956
#ifdef DEBUG
60-
std::cout << "add_method_body: " << _method_symbol->name << std::endl;
57+
std::cout << "add_method_body: " << _method_symbol->name << "\n";
6158
#endif
62-
63-
// We have to prevent the same method to be added multiple times
64-
// otherwise we get duplicated symbol prefixes
65-
if(methods_seen.find(_method_symbol->name) != methods_seen.end())
66-
{
59+
// Converting a method body might add method bodies for methods that we have
60+
// already analyzed. Adding the same method more than once causes duplicated
61+
// symbol prefixes, therefore we have to keep track.
62+
if(methods_seen.insert(_method_symbol->name).second)
63+
method_bodies.push_back(method_bodyt(
64+
_method_symbol, template_map, instantiation_stack));
6765
#ifdef DEBUG
68-
std::cout << " already exists" << std::endl;
66+
else
67+
std::cout << " already exists" << "\n";
6968
#endif
70-
return;
71-
}
72-
method_bodies.push_back(method_bodyt(
73-
_method_symbol, template_map, instantiation_stack));
74-
75-
// Converting a method body might add method bodies for methods
76-
// that we have already analyzed. Hence, we have to keep track.
77-
methods_seen.insert(_method_symbol->name);
7869
}

src/cpp/cpp_typecheck_resolve.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,9 @@ void cpp_typecheck_resolvet::disambiguate_functions(
500500
for(resolve_identifierst::const_iterator
501501
it1=old_identifiers.begin();
502502
it1!=old_identifiers.end();
503-
it1++)
503+
++it1)
504504
{
505-
#if 0
505+
#ifdef DEBUG
506506
std::cout << "I1: " << it1->get(ID_identifier) << std::endl;
507507
#endif
508508

src/cpp/parse.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -480,11 +480,10 @@ void Parser::merge_types(const typet &src, typet &dest)
480480
dest=tmp;
481481
}
482482

483-
// the end of the subtypes container needs to stay the same,
484-
// since several analysis functions traverse via the end for
485-
// merged_types
483+
// the end of the subtypes container needs to stay the same since several
484+
// analysis functions traverse via the end for merged_types
486485
typet::subtypest &sub=dest.subtypes();
487-
sub.emplace(sub.begin(), src);
486+
sub.insert(sub.begin(), src);
488487
POSTCONDITION(!dest.subtypes().empty());
489488
}
490489
}

0 commit comments

Comments
 (0)