Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions scripts/cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
'readability/function_comment'
'runtime/arrays',
'runtime/casting',
'runtime/endl',
'runtime/explicit',
'runtime/int',
'runtime/init',
Expand Down Expand Up @@ -6198,6 +6199,12 @@ def CheckNamespaceOrUsing(filename, clean_lines, linenum, error):
error(filename, linenum, 'readability/namespace', 4,
'Do not use using')

def CheckForEndl(filename, clean_lines, linenum, error):
"""Check that the line does not contain std::endl."""
line = clean_lines.elided[linenum]
if Match(r'[^a-zA-Z0-9_]*std::endl[^a-zA-Z0-9_]*', line):
error(filename, linenum, 'runtime/endl', 4, 'Do not use std::endl')

def ProcessLine(filename, file_extension, clean_lines, line,
include_state, function_state, nesting_state, error,
extra_check_functions=[]):
Expand Down Expand Up @@ -6239,6 +6246,7 @@ def ProcessLine(filename, file_extension, clean_lines, line,
CheckMakePairUsesDeduction(filename, clean_lines, line, error)
CheckRedundantVirtual(filename, clean_lines, line, error)
CheckNamespaceOrUsing(filename, clean_lines, line, error)
CheckForEndl(filename, clean_lines, line, error)
for check_fn in extra_check_functions:
check_fn(filename, clean_lines, line, error)

Expand Down
2 changes: 1 addition & 1 deletion src/analyses/constant_propagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void constant_propagator_domaint::assign_rec(

#ifdef DEBUG
std::cout << "assign: " << from_expr(ns, "", lhs)
<< " := " << from_type(ns, "", rhs_type) << std::endl;
<< " := " << from_type(ns, "", rhs_type) << '\n';
#endif

if(lhs.id()==ID_symbol && rhs.id()==ID_if)
Expand Down
4 changes: 2 additions & 2 deletions src/analyses/dependence_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void dep_graph_domaint::output(
out << ",";
out << (*it)->location_number;
}
out << std::endl;
out << '\n';
}

if(!data_deps.empty())
Expand All @@ -341,7 +341,7 @@ void dep_graph_domaint::output(
out << ",";
out << (*it)->location_number;
}
out << std::endl;
out << '\n';
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/analyses/dirty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ Function: dirtyt::output
void dirtyt::output(std::ostream &out) const
{
for(const auto &d : dirty)
out << d << std::endl;
out << d << '\n';
}
11 changes: 4 additions & 7 deletions src/analyses/flow_insensitive_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ void flow_insensitive_analysis_baset::output(
{
forall_goto_functions(f_it, goto_functions)
{
out << "////" << std::endl;
out << "//// Function: " << f_it->first << std::endl;
out << "////" << std::endl;
out << std::endl;
out << "////\n" << "//// Function: " << f_it->first << "\n////\n\n";

output(f_it->second.body, f_it->first, out);
}
Expand Down Expand Up @@ -253,7 +250,7 @@ bool flow_insensitive_analysis_baset::visit(

#if 0
std::cout << "Visiting: " << l->function << " " <<
l->location_number << std::endl;
l->location_number << '\n';
#endif

seen_locations.insert(l);
Expand Down Expand Up @@ -294,14 +291,14 @@ bool flow_insensitive_analysis_baset::visit(
}

// if (id2string(l->function).find("debug")!=std::string::npos)
// std::cout << l->function << std::endl; //=="messages::debug")
// std::cout << l->function << '\n'; //=="messages::debug")

// {
// static unsigned state_cntr=0;
// std::string s("pastate"); s += std::to_string(state_cntr);
// std::ofstream f(s.c_str());
// goto_program.output_instruction(ns, "", f, l);
// f << std::endl;
// f << '\n';
// get_state().output(ns, f);
// f.close();
// state_cntr++;
Expand Down
10 changes: 5 additions & 5 deletions src/analyses/goto_rw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,22 @@ Function: rw_range_sett::output

void rw_range_sett::output(std::ostream &out) const
{
out << "READ:" << std::endl;
out << "READ:\n";
forall_rw_range_set_r_objects(it, *this)
{
out << " " << it->first;
it->second->output(ns, out);
out << std::endl;
out << '\n';
}

out << std::endl;
out << '\n';

out << "WRITE:" << std::endl;
out << "WRITE:\n";
forall_rw_range_set_w_objects(it, *this)
{
out << " " << it->first;
it->second->output(ns, out);
out << std::endl;
out << '\n';
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/analyses/invariant_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Function: inv_object_storet::output
void inv_object_storet::output(std::ostream &out) const
{
for(unsigned i=0; i<entries.size(); i++)
out << "STORE " << i << ": " << to_string(i, "") << std::endl;
out << "STORE " << i << ": " << to_string(i, "") << '\n';
}

/*******************************************************************\
Expand Down Expand Up @@ -488,7 +488,7 @@ void invariant_sett::output(
{
if(is_false)
{
out << "FALSE" << std::endl;
out << "FALSE\n";
return;
}

Expand All @@ -510,28 +510,28 @@ void invariant_sett::output(
out << to_string(j, identifier);
}

out << std::endl;
out << '\n';
}

for(const auto &bounds : bounds_map)
{
out << to_string(bounds.first, identifier)
<< " in " << bounds.second
<< std::endl;
<< '\n';
}

for(const auto &le : le_set)
{
out << to_string(le.first, identifier)
<< " <= " << to_string(le.second, identifier)
<< std::endl;
<< '\n';
}

for(const auto &ne : ne_set)
{
out << to_string(ne.first, identifier)
<< " != " << to_string(ne.second, identifier)
<< std::endl;
<< '\n';
}
}

Expand Down Expand Up @@ -604,7 +604,7 @@ void invariant_sett::strengthen_rec(const exprt &expr)
throw "non-Boolean argument to strengthen()";

#if 0
std::cout << "S: " << from_expr(*ns, "", expr) << std::endl;
std::cout << "S: " << from_expr(*ns, "", expr) << '\n';
#endif

if(is_false)
Expand Down Expand Up @@ -836,7 +836,7 @@ tvt invariant_sett::implies_rec(const exprt &expr) const
throw "implies: non-Boolean expression";

#if 0
std::cout << "I: " << from_expr(*ns, "", expr) << std::endl;
std::cout << "I: " << from_expr(*ns, "", expr) << '\n';
#endif

if(is_false) // can't get any stronger
Expand Down Expand Up @@ -1508,7 +1508,7 @@ void invariant_sett::apply_code(const codet &code)
}
else
{
std::cerr << code.pretty() << std::endl;
std::cerr << code.pretty() << '\n';
throw "invariant_sett: unexpected statement: "+id2string(statement);
}
}
4 changes: 2 additions & 2 deletions src/analyses/natural_loops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ void show_natural_loops(const goto_functionst &goto_functions)
{
forall_goto_functions(it, goto_functions)
{
std::cout << "*** " << it->first << std::endl;
std::cout << "*** " << it->first << '\n';

natural_loopst natural_loops;
natural_loops(it->second.body);
natural_loops.output(std::cout);

std::cout << std::endl;
std::cout << '\n';
}
}
4 changes: 2 additions & 2 deletions src/analyses/reaching_definitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ Function: rd_range_domaint::output

void rd_range_domaint::output(std::ostream &out) const
{
out << "Reaching definitions:" << std::endl;
out << "Reaching definitions:\n";

if(has_values.is_known())
{
Expand Down Expand Up @@ -681,7 +681,7 @@ void rd_range_domaint::output(std::ostream &out) const
out << "@" << itl->first->location_number;
}

out << "]" << std::endl;
out << "]\n";

clear_cache(identifier);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/file_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ int main()
std::cout << ch;
}

std::cout << "\\n\"" << std::endl;
std::cout << "\\n\"\n";
}
}
2 changes: 1 addition & 1 deletion src/ansi-c/library/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main()
std::cout << ch;
}

std::cout << "\\n\"" << std::endl;
std::cout << "\\n\"\n";
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/ansi-c/parser_static.inc
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ Function: merge_types
static void merge_types(irept &dest, irept &src)
{
#if 0
std::cout << "D: " << dest.pretty() << std::endl;
std::cout << "S: " << src.pretty() << std::endl;
std::cout << "D: " << dest.pretty() << '\n';
std::cout << "S: " << src.pretty() << '\n';
#endif

if(src.is_nil())
Expand Down Expand Up @@ -183,8 +183,8 @@ static void make_subtype(typet &dest, typet &src)
// find spot in 'dest' where to insert 'src'

#if 0
std::cout << "D: " << dest.pretty() << std::endl;
std::cout << "S: " << src.pretty() << std::endl;
std::cout << "D: " << dest.pretty() << '\n';
std::cout << "S: " << src.pretty() << '\n';
#endif

assert(src.id()==ID_array ||
Expand Down
6 changes: 3 additions & 3 deletions src/cbmc/cbmc_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ int main(int argc, const char **argv)
int res=parse_options.main();

#ifdef IREP_HASH_STATS
std::cout << "IREP_HASH_CNT=" << irep_hash_cnt << std::endl;
std::cout << "IREP_CMP_CNT=" << irep_cmp_cnt << std::endl;
std::cout << "IREP_CMP_NE_CNT=" << irep_cmp_ne_cnt << std::endl;
std::cout << "IREP_HASH_CNT=" << irep_hash_cnt << '\n';
std::cout << "IREP_CMP_CNT=" << irep_cmp_cnt << '\n';
std::cout << "IREP_CMP_NE_CNT=" << irep_cmp_ne_cnt << '\n';
#endif

return res;
Expand Down
2 changes: 1 addition & 1 deletion src/cbmc/cbmc_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ int cbmc_parse_optionst::doit()
{
if(cmdline.isset("version"))
{
std::cout << CBMC_VERSION << std::endl;
std::cout << CBMC_VERSION << '\n';
return 0; // should contemplate EX_OK from sysexits.h
}

Expand Down
4 changes: 2 additions & 2 deletions src/cbmc/symex_coverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ void goto_program_coverage_recordt::compute_coverage_lines(
{
if(!(c_entry->second.size()==1 || is_branch))
{
std::cerr << it->location_number << std::endl;
std::cerr << it->location_number << '\n';
for(const auto &cov : c_entry->second)
std::cerr << cov.second.succ->location_number << std::endl;
std::cerr << cov.second.succ->location_number << '\n';
}
assert(c_entry->second.size()==1 || is_branch);

Expand Down
10 changes: 5 additions & 5 deletions src/clobber/clobber_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ int clobber_parse_optionst::doit()
{
if(cmdline.isset("version"))
{
std::cout << CBMC_VERSION << std::endl;
std::cout << CBMC_VERSION << '\n';
return 0;
}

Expand Down Expand Up @@ -532,7 +532,7 @@ void clobber_parse_optionst::report_success()
xmlt xml("cprover-status");
xml.data="SUCCESS";
std::cout << xml;
std::cout << std::endl;
std::cout << '\n';
}
break;

Expand Down Expand Up @@ -561,15 +561,15 @@ void clobber_parse_optionst::show_counterexample(
switch(get_ui())
{
case ui_message_handlert::uit::PLAIN:
std::cout << std::endl << "Counterexample:" << std::endl;
std::cout << "\nCounterexample:\n";
show_goto_trace(std::cout, ns, error_trace);
break;

case ui_message_handlert::uit::XML_UI:
{
xmlt xml;
convert(ns, error_trace, xml);
std::cout << xml << std::endl;
std::cout << xml << '\n';
}
break;

Expand Down Expand Up @@ -604,7 +604,7 @@ void clobber_parse_optionst::report_failure()
xmlt xml("cprover-status");
xml.data="FAILURE";
std::cout << xml;
std::cout << std::endl;
std::cout << '\n';
}
break;

Expand Down
4 changes: 2 additions & 2 deletions src/cpp/cpp_convert_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void cpp_convert_typet::read(const typet &type)
other.clear();

#if 0
std::cout << "cpp_convert_typet::read: " << type.pretty() << std::endl;
std::cout << "cpp_convert_typet::read: " << type.pretty() << '\n';
#endif

read_rec(type);
Expand All @@ -88,7 +88,7 @@ void cpp_convert_typet::read_rec(const typet &type)
{
#if 0
std::cout << "cpp_convert_typet::read_rec: "
<< type.pretty() << std::endl;
<< type.pretty() << '\n';
#endif

if(type.id()==ID_merged_type)
Expand Down
Loading