Skip to content

Commit 8ea00d9

Browse files
author
Daniel Kroening
committed
compilet: use ranged for
1 parent 1324a2c commit 8ea00d9

File tree

1 file changed

+17
-30
lines changed

1 file changed

+17
-30
lines changed

src/goto-cc/compile.cpp

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,15 @@ bool compilet::doit()
8181
add_compiler_specific_defines(config);
8282

8383
// Parse command line for source and object file names
84-
for(std::size_t i = 0; i < cmdline.args.size(); i++)
85-
if(add_input_file(cmdline.args[i]))
84+
for(const auto &arg : cmdline.args)
85+
if(add_input_file(arg))
8686
return true;
8787

88-
for(std::list<std::string>::const_iterator it = libraries.begin();
89-
it!=libraries.end();
90-
it++)
88+
for(const auto &library : libraries)
9189
{
92-
if(!find_library(*it))
90+
if(!find_library(library))
9391
// GCC is going to complain if this doesn't exist
94-
debug() << "Library not found: " << *it << " (ignoring)" << eom;
92+
debug() << "Library not found: " << library << " (ignoring)" << eom;
9593
}
9694

9795
statistics() << "No. of source files: " << source_files.size() << eom;
@@ -308,15 +306,12 @@ bool compilet::find_library(const std::string &name)
308306
{
309307
std::string tmp;
310308

311-
for(std::list<std::string>::const_iterator
312-
it=library_paths.begin();
313-
it!=library_paths.end();
314-
it++)
309+
for(const auto &library_path : library_paths)
315310
{
316311
#ifdef _WIN32
317-
tmp = *it + "\\lib";
312+
tmp = library_path + "\\lib";
318313
#else
319-
tmp = *it + "/lib";
314+
tmp = library_path + "/lib";
320315
#endif
321316

322317
std::ifstream in(tmp+name+".a");
@@ -674,21 +669,16 @@ compilet::~compilet()
674669
{
675670
// clean up temp dirs
676671

677-
for(std::list<std::string>::const_iterator it = tmp_dirs.begin();
678-
it!=tmp_dirs.end();
679-
it++)
680-
delete_directory(*it);
672+
for(const auto &dir : tmp_dirs)
673+
delete_directory(dir);
681674
}
682675

683676
unsigned compilet::function_body_count(const goto_functionst &functions) const
684677
{
685678
int fbs=0;
686679

687-
for(goto_functionst::function_mapt::const_iterator it=
688-
functions.function_map.begin();
689-
it != functions.function_map.end();
690-
it++)
691-
if(it->second.body_available())
680+
for(const auto &f : functions.function_map)
681+
if(f.second.body_available())
692682
fbs++;
693683

694684
return fbs;
@@ -719,14 +709,11 @@ void compilet::convert_symbols(goto_functionst &dest)
719709
symbols.insert(named_symbol.first);
720710

721711
// the symbol table iterators aren't stable
722-
for(symbols_sett::const_iterator
723-
it=symbols.begin();
724-
it!=symbols.end();
725-
++it)
712+
for(const auto &symbol : symbols)
726713
{
727-
symbol_tablet::symbolst::const_iterator s_it=
728-
symbol_table.symbols.find(*it);
729-
assert(s_it!=symbol_table.symbols.end());
714+
symbol_tablet::symbolst::const_iterator s_it =
715+
symbol_table.symbols.find(symbol);
716+
CHECK_RETURN(s_it != symbol_table.symbols.end());
730717

731718
if(s_it->second.type.id()==ID_code &&
732719
!s_it->second.is_macro &&
@@ -736,7 +723,7 @@ void compilet::convert_symbols(goto_functionst &dest)
736723
{
737724
debug() << "Compiling " << s_it->first << eom;
738725
converter.convert_function(s_it->first, dest.function_map[s_it->first]);
739-
symbol_table.get_writeable_ref(*it).value=exprt("compiled");
726+
symbol_table.get_writeable_ref(symbol).value = exprt("compiled");
740727
}
741728
}
742729
}

0 commit comments

Comments
 (0)