Skip to content

Commit

Permalink
Pre-increment (rather than post-increment) STL iterators in for loops… (
Browse files Browse the repository at this point in the history
#1692)

* Pre-increment (rather than post-increment) STL iterators in for loops. #1594

* Fix a goof. #1594
  • Loading branch information
jmpenn authored Apr 18, 2024
1 parent e515144 commit 5065d96
Show file tree
Hide file tree
Showing 51 changed files with 118 additions and 118 deletions.
2 changes: 1 addition & 1 deletion include/trick/ClassSizeCheck.hh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace Trick {
*/
void print_nonzero_diffs() {
std::map<std::string, ClassSizeDiffInfo>::iterator it ;
for ( it = name_to_diff.begin() ; it != name_to_diff.end() ; it++ ) {
for ( it = name_to_diff.begin() ; it != name_to_diff.end() ; ++it ) {
int curr_diff = it->second.diff ;
ATTRIBUTES * attr = Trick::AttributesMap::attributes_map()->get_attr(it->first) ;
unsigned int ii ;
Expand Down
4 changes: 2 additions & 2 deletions include/trick/checkpoint_sequence_stl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int checkpoint_sequence_i(STL & in_stl , std::string object_name , std::string v
//message_publish(1, "CHECKPOINT_SEQUENCE_STL with %s\n", var_declare) ;

/* copy the contents of the stl */
for ( ii = 0 , it = in_stl.begin() , end = in_stl.end() ; it != end ; it++ , ii++ ) {
for ( ii = 0 , it = in_stl.begin() , end = in_stl.end() ; it != end ; ++it , ii++ ) {
items[ii] = *it ;
}
}
Expand Down Expand Up @@ -103,7 +103,7 @@ int checkpoint_sequence_s(STL & in_stl , std::string object_name , std::string v
//message_publish(1, "CHECKPOINT_SEQUENCE_STL_STL with %s\n", temp_str.c_str()) ;

/* create the names of the sub stl checkpoint names we're going to be using */
for ( ii = 0 , it = in_stl.begin() , end = in_stl.end() ; it != end ; it++ , ii++ ) {
for ( ii = 0 , it = in_stl.begin() , end = in_stl.end() ; it != end ; ++it , ii++ ) {
std::ostringstream sub_elements ;
sub_elements << object_name << "_" << var_name << "_" << ii ;
items[ii] = sub_elements.str() ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int Trick::SegmentedExecutive::add_segment( Trick::Segment * ps ) {

// Gets the job class to job queue map for this segment and adds the job classes to the executive.
std::map < std::string , Trick::ScheduledJobQueue * >::iterator it ;
for ( it = ps->get_job_queues().begin() ; it != ps->get_job_queues().end() ; it++ ) {
for ( it = ps->get_job_queues().begin() ; it != ps->get_job_queues().end() ; ++it ) {
class_map[(*it).first] = num_classes ;
class_to_queue[num_classes++] = (*it).second ;
}
Expand All @@ -41,7 +41,7 @@ int Trick::SegmentedExecutive::gather_segmented_jobs() {
std::map < std::string , Trick::Segment * >::iterator mit ;
std::set< std::string > segment_tags ;

for ( mit = segment_map.begin() ; mit != segment_map.end() ; mit++ ) {
for ( mit = segment_map.begin() ; mit != segment_map.end() ; ++mit ) {
segment_tags.insert((*mit).first) ;
}

Expand Down Expand Up @@ -129,7 +129,7 @@ int Trick::SegmentedExecutive::segment_set_jobs_onoff() {
Trick::JobData * job ;
std::set < Trick::JobData * >::iterator it ;

for ( it = all_segmented_jobs.begin() ; it != all_segmented_jobs.end() ; it++ ) {
for ( it = all_segmented_jobs.begin() ; it != all_segmented_jobs.end() ; ++it ) {
job = *it ;
// Test to see if the next segment is present in the job tags.
// Set the disabled flag to the negation of the tag's presence
Expand Down Expand Up @@ -164,10 +164,10 @@ int Trick::SegmentedExecutive::write_s_job_execution(FILE *fp) {
fprintf(fp, "Segment Jobs:\n") ;

std::map < std::string , Trick::Segment * >::iterator pmit ;
for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; pmit++ ) {
for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; ++pmit ) {
Trick::Segment * pb = (*pmit).second ;
std::map < std::string , Trick::ScheduledJobQueue * >::iterator jqit ;
for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; jqit++ ) {
for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; ++jqit ) {
(*jqit).second->write_non_sched_queue(fp) ;
}
}
Expand All @@ -187,10 +187,10 @@ int Trick::SegmentedExecutive::instrument_job_before( Trick::JobData * instrumen

//go through all of the segmented jobs and instrument them.
std::map < std::string , Trick::Segment * >::iterator pmit ;
for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; pmit++ ) {
for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; ++pmit ) {
Trick::Segment * pb = (*pmit).second ;
std::map < std::string , Trick::ScheduledJobQueue * >::iterator jqit ;
for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; jqit++ ) {
for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; ++jqit ) {
(*jqit).second->instrument_before(instrument_job) ;
}
}
Expand All @@ -209,10 +209,10 @@ int Trick::SegmentedExecutive::instrument_job_after( Trick::JobData * instrument

//go through all of the segmented jobs and instrument them.
std::map < std::string , Trick::Segment * >::iterator pmit ;
for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; pmit++ ) {
for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; ++pmit ) {
Trick::Segment * pb = (*pmit).second ;
std::map < std::string , Trick::ScheduledJobQueue * >::iterator jqit ;
for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; jqit++ ) {
for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; ++jqit ) {
(*jqit).second->instrument_after(instrument_job) ;
}
}
Expand All @@ -226,10 +226,10 @@ int Trick::SegmentedExecutive::instrument_job_remove(std::string in_job) {
Trick::Executive::instrument_job_remove( in_job ) ;

std::map < std::string , Trick::Segment * >::iterator pmit ;
for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; pmit++ ) {
for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; ++pmit ) {
Trick::Segment * pb = (*pmit).second ;
std::map < std::string , Trick::ScheduledJobQueue * >::iterator jqit ;
for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; jqit++ ) {
for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; ++jqit ) {
(*jqit).second->instrument_remove(in_job) ;
}
}
Expand Down
4 changes: 2 additions & 2 deletions trick_sims/ODE/models/DrawStuff/DrawStuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ void DrawStuff::start() {

void DrawStuff::step(int) {
std::vector<DrawStuffObject *>::iterator it ;
for( it = objects.begin() ; it != objects.end() ; it++ ) {
for( it = objects.begin() ; it != objects.end() ; ++it ) {
(*it)->draw() ;
}
}

void DrawStuff::command(int cmd) {
std::vector<DrawStuffObject *>::iterator it ;
for( it = objects.begin() ; it != objects.end() ; it++ ) {
for( it = objects.begin() ; it != objects.end() ; ++it ) {
(*it)->command(cmd) ;
}
}
Expand Down
14 changes: 7 additions & 7 deletions trick_source/codegen/Interface_Code_Gen/ClassValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ClassValues::ClassValues() :

ClassValues::~ClassValues() {
std::vector<FieldDescription *>::iterator fdit ;
for ( fdit = field_descripts.begin() ; fdit != field_descripts.end() ; fdit++ ) {
for ( fdit = field_descripts.begin() ; fdit != field_descripts.end() ; ++fdit ) {
delete (*fdit) ;
}
}
Expand Down Expand Up @@ -57,7 +57,7 @@ void ClassValues::addInheritedFieldDescriptions(std::vector<FieldDescription *>

std::vector<FieldDescription *>::iterator fdit ;
// Loop through the incoming inherited variable names
for ( fdit = in_fdes.begin() ; fdit != in_fdes.end() ; fdit++ ) {
for ( fdit = in_fdes.begin() ; fdit != in_fdes.end() ; ++fdit ) {

(*fdit)->setBaseClassOffset( class_offset ) ;
(*fdit)->setInherited( true ) ;
Expand All @@ -72,7 +72,7 @@ void ClassValues::addInheritedFieldDescriptions(std::vector<FieldDescription *>
#else
{
#endif
for ( fdit = in_fdes.begin() ; fdit != in_fdes.end() ; fdit++ ) {
for ( fdit = in_fdes.begin() ; fdit != in_fdes.end() ; ++fdit ) {

std::string in_name = (*fdit)->getName() ;
// search existing names for incoming inherited variable name.
Expand Down Expand Up @@ -113,7 +113,7 @@ void ClassValues::addInheritedFieldDescriptions(std::vector<FieldDescription *>
void ClassValues::saveInheritAncestry( ClassValues * in_cv ) {

std::map< std::string , unsigned int >::iterator mit ;
for ( mit = in_cv->all_inherited_class_names_map.begin() ; mit != in_cv->all_inherited_class_names_map.end() ; mit++ ) {
for ( mit = in_cv->all_inherited_class_names_map.begin() ; mit != in_cv->all_inherited_class_names_map.end() ; ++mit ) {
all_inherited_class_names_map[(*mit).first] += (*mit).second ;
}

Expand All @@ -123,7 +123,7 @@ void ClassValues::saveInheritAncestry( ClassValues * in_cv ) {
void ClassValues::setContainerClassForFields() {
std::vector<FieldDescription *>::iterator fdit ;
// Loop through all fields
for ( fdit = field_descripts.begin() ; fdit != field_descripts.end() ; fdit++ ) {
for ( fdit = field_descripts.begin() ; fdit != field_descripts.end() ; ++fdit ) {
// Prepend the field container class with the current class name.
(*fdit)->setContainerClass( name + "::" + (*fdit)->getContainerClass() ) ;
}
Expand All @@ -134,13 +134,13 @@ void ClassValues::clearAmbiguousVariables() {
std::map< std::string , unsigned int >::iterator mit ;
std::vector<FieldDescription *>::iterator fdit ;

for ( mit = all_inherited_class_names_map.begin() ; mit != all_inherited_class_names_map.end() ; mit++ ) {
for ( mit = all_inherited_class_names_map.begin() ; mit != all_inherited_class_names_map.end() ; ++mit ) {
// If a class in inherited more than once we have a diamond. We'll need to modify variables that were
// inherited from that class.
if ( (*mit).second > 1 ) {
std::string str = (*mit).first + "::" ;
// Loop through all fields testing for the diamond inherited class in the name.
for ( fdit = field_descripts.begin() ; fdit != field_descripts.end() ; fdit++ ) {
for ( fdit = field_descripts.begin() ; fdit != field_descripts.end() ; ++fdit ) {
std::string fdit_name = (*fdit)->getName() ;
size_t f = fdit_name.find(str) ;
// If the variable contains the diamond class string, remove the diamond class qualification.
Expand Down
6 changes: 3 additions & 3 deletions trick_source/codegen/Interface_Code_Gen/ClassVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ bool CXXRecordVisitor::VisitCXXRecordDecl( clang::CXXRecordDecl *rec ) {
} else {
// Test all constructors to see if any of those are the default and public
clang::CXXRecordDecl::ctor_iterator cit ;
for ( cit = rec->ctor_begin() ; cit != rec->ctor_end() ; cit++ ) {
for ( cit = rec->ctor_begin() ; cit != rec->ctor_end() ; ++cit ) {
if ( ( !(*cit)->isDeleted() ) and (*cit)->isDefaultConstructor() and (*cit)->getAccess() == clang::AS_public ) {
cval.setHasDefaultConstructor(true) ;
}
Expand All @@ -234,7 +234,7 @@ bool CXXRecordVisitor::VisitCXXRecordDecl( clang::CXXRecordDecl *rec ) {
//std::cout << "parsing " << cval.getName() << std::endl ;
//std::cout << " processing inheritance " << rec->getNumBases() << " " << rec->getNumVBases() << "" << std::endl ;
clang::CXXRecordDecl::base_class_iterator bcii ;
for ( bcii = rec->bases_begin() ; bcii != rec->bases_end() ; bcii++ ) {
for ( bcii = rec->bases_begin() ; bcii != rec->bases_end() ; ++bcii ) {
if ( !bcii->isVirtual() ) {
const clang::Type * temp = bcii->getType().getTypePtr() ;
//std::cout << "\ninherited Type = " << temp->getTypeClassName() << "" << std::endl ;
Expand Down Expand Up @@ -282,7 +282,7 @@ bool CXXRecordVisitor::VisitCXXRecordDecl( clang::CXXRecordDecl *rec ) {
// When processing inherited classes include_virtual_base will be set to true
// so we don't process virtual inherited classes multiple times.
if ( include_virtual_base ) {
for ( bcii = rec->vbases_begin() ; bcii != rec->vbases_end() ; bcii++ ) {
for ( bcii = rec->vbases_begin() ; bcii != rec->vbases_end() ; ++bcii ) {
const clang::Type * temp = bcii->getType().getTypePtr() ;
//std::cout << "\ninherited Type = " << temp->getTypeClassName() << "" << std::endl ;
const clang::RecordType * rt = temp->getAs<clang::RecordType>() ;
Expand Down
2 changes: 1 addition & 1 deletion trick_source/codegen/Interface_Code_Gen/CommentSaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ std::string CommentSaver::getTrickHeaderComment( std::string file_name ) {
if ( resolved_path != NULL ) {
if ( trick_header_comments.find(resolved_path) == trick_header_comments.end() ) {
trick_header_comments[resolved_path] = std::string() ;
for ( cit = comment_map[resolved_path].begin() ; cit != comment_map[resolved_path].end() ; cit++ ) {
for ( cit = comment_map[resolved_path].begin() ; cit != comment_map[resolved_path].end() ; ++cit ) {
std::string comment_str = getComment((*cit).second) ;
if ( comment_str.find("@trick_parse") != std::string::npos or
comment_str.find("\\trick_parse") != std::string::npos ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void FieldDescription::parseComment(std::string comment) {
// escape special characters, convert tabs and newlines to spaces, remove multiple spaces.
std::ostringstream ss ;
bool is_space = false ;
for (std::string::iterator it = comment.begin(); it != comment.end(); it++) {
for (std::string::iterator it = comment.begin(); it != comment.end(); ++it) {
switch (*it) {
case '\\': ss << "\\\\"; is_space = false ; break;
case '"': ss << "\\\""; is_space = false ; break;
Expand Down
2 changes: 1 addition & 1 deletion trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ bool FieldVisitor::VisitRecordType(clang::RecordType *rt) {
// Test if we have some type from STL.
if (!tst_string.compare( 0 , 5 , "std::")) {
// If we have some type from std, figure out if it is one we support.
for ( std::map<std::string, bool>::iterator it = stl_classes.begin() ; it != stl_classes.end() ; it++ ) {
for ( std::map<std::string, bool>::iterator it = stl_classes.begin() ; it != stl_classes.end() ; ++it ) {
/* Mark STL types that are not strings and exit */
if (!tst_string.compare( 0 , (*it).first.size() , (*it).first)) {

Expand Down
6 changes: 3 additions & 3 deletions trick_source/codegen/Interface_Code_Gen/FindTrickICG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void FindTrickICG::If(clang::SourceLocation Loc, clang::SourceRange ConditionRan
if ( ref.str().find("TRICK_ICG") != std::string::npos ) {
// for each header in the stack, mark them as being exposed to TRICK_ICG
std::vector<std::string>::iterator it ;
for ( it = included_files.begin() ; it != included_files.end() ; it++ ) {
for ( it = included_files.begin() ; it != included_files.end() ; ++it ) {
hsd.addTrickICGFoundFile(*it) ;
}
// print warning messages.
Expand Down Expand Up @@ -124,7 +124,7 @@ void FindTrickICG::Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNam
if ( (loc_str.find("S_source.hh") == std::string::npos) ) {
// for each header in the stack, mark them as being exposed to TRICK_ICG
std::vector<std::string>::iterator it ;
for ( it = included_files.begin() ; it != included_files.end() ; it++ ) {
for ( it = included_files.begin() ; it != included_files.end() ; ++it ) {
hsd.addTrickICGFoundFile(*it) ;
}
// print warning messages.
Expand All @@ -149,7 +149,7 @@ void FindTrickICG::Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNa
std::string loc_str = Loc.printToString(ci.getSourceManager()) ;
// for each header in the stack, mark them as being exposed to TRICK_ICG
std::vector<std::string>::iterator it ;
for ( it = included_files.begin() ; it != included_files.end() ; it++ ) {
for ( it = included_files.begin() ; it != included_files.end() ; ++it ) {
hsd.addTrickICGFoundFile(*it) ;
}
// print warning messages.
Expand Down
Loading

0 comments on commit 5065d96

Please sign in to comment.