erc: Avoid casting between iterators

The iterator for containers should always match the container type.
Using auto here re-forces the match.
This commit is contained in:
Seth Hillbrand 2019-08-05 20:03:29 -07:00
parent 2b55f8a1aa
commit 2e66d80af8
1 changed files with 15 additions and 17 deletions

View File

@ -770,18 +770,17 @@ void NETLIST_OBJECT_LIST::TestforSimilarLabels()
// build global labels and compare // build global labels and compare
std::set<NETLIST_OBJECT*, compare_label_names> loc_labelList; std::set<NETLIST_OBJECT*, compare_label_names> loc_labelList;
std::set<NETLIST_OBJECT*>::const_iterator it;
for( it = uniqueLabelList.begin(); it != uniqueLabelList.end(); ++it ) for( auto it = uniqueLabelList.begin(); it != uniqueLabelList.end(); ++it )
{ {
if( (*it)->IsLabelGlobal() ) if( (*it)->IsLabelGlobal() )
loc_labelList.insert( *it ); loc_labelList.insert( *it );
} }
// compare global labels (same label names appears only once in list) // compare global labels (same label names appears only once in list)
for( it = loc_labelList.begin(); it != loc_labelList.end(); ++it ) for( auto it = loc_labelList.begin(); it != loc_labelList.end(); ++it )
{ {
std::set<NETLIST_OBJECT*>::const_iterator it_aux = it; auto it_aux = it;
for( ++it_aux; it_aux != loc_labelList.end(); ++it_aux ) for( ++it_aux; it_aux != loc_labelList.end(); ++it_aux )
{ {
@ -802,48 +801,47 @@ void NETLIST_OBJECT_LIST::TestforSimilarLabels()
// Build paths list // Build paths list
std::set<NETLIST_OBJECT*, compare_paths> pathsList; std::set<NETLIST_OBJECT*, compare_paths> pathsList;
for( it = uniqueLabelList.begin(); it != uniqueLabelList.end(); ++it ) for( auto it = uniqueLabelList.begin(); it != uniqueLabelList.end(); ++it )
pathsList.insert( *it ); pathsList.insert( *it );
// Examine each label inside a sheet path: // Examine each label inside a sheet path:
for( it = pathsList.begin(); it != pathsList.end(); ++it ) for( auto it = pathsList.begin(); it != pathsList.end(); ++it )
{ {
loc_labelList.clear(); loc_labelList.clear();
std::set<NETLIST_OBJECT*>::const_iterator it_aux = uniqueLabelList.begin(); auto it_uniq = uniqueLabelList.begin();
for( ; it_aux != uniqueLabelList.end(); ++it_aux ) for( ; it_uniq != uniqueLabelList.end(); ++it_uniq )
{ {
if( (*it)->m_SheetPath.Path() == (*it_aux)->m_SheetPath.Path() ) if( ( *it )->m_SheetPath.Path() == ( *it_uniq )->m_SheetPath.Path() )
loc_labelList.insert( *it_aux ); loc_labelList.insert( *it_uniq );
} }
// at this point, loc_labelList contains labels of the current sheet path. // at this point, loc_labelList contains labels of the current sheet path.
// Detect similar labels (same label names appears only once in list) // Detect similar labels (same label names appears only once in list)
std::set<NETLIST_OBJECT*>::const_iterator ref_it;
for( ref_it = loc_labelList.begin(); ref_it != loc_labelList.end(); ++ref_it ) for( auto ref_it = loc_labelList.begin(); ref_it != loc_labelList.end(); ++ref_it )
{ {
NETLIST_OBJECT* ref_item = *ref_it; NETLIST_OBJECT* ref_item = *ref_it;
it_aux = ref_it; auto it_aux = ref_it;
for( ++it_aux; it_aux != loc_labelList.end(); ++it_aux ) for( ++it_aux; it_aux != loc_labelList.end(); ++it_aux )
{ {
// global label versus global label was already examined. // global label versus global label was already examined.
// here, at least one label must be local // here, at least one label must be local
if( ref_item->IsLabelGlobal() && (*it_aux)->IsLabelGlobal() ) if( ref_item->IsLabelGlobal() && ( *it_aux )->IsLabelGlobal() )
continue; continue;
if( ref_item->m_Label.CmpNoCase( (*it_aux)->m_Label ) == 0 ) if( ref_item->m_Label.CmpNoCase( ( *it_aux )->m_Label ) == 0 )
{ {
// Create new marker for ERC. // Create new marker for ERC.
int cntA = countIndenticalLabels( fullLabelList, ref_item ); int cntA = countIndenticalLabels( fullLabelList, ref_item );
int cntB = countIndenticalLabels( fullLabelList, *it_aux ); int cntB = countIndenticalLabels( fullLabelList, *it_aux );
if( cntA <= cntB ) if( cntA <= cntB )
SimilarLabelsDiagnose( ref_item, (*it_aux) ); SimilarLabelsDiagnose( ref_item, ( *it_aux ) );
else else
SimilarLabelsDiagnose( (*it_aux), ref_item ); SimilarLabelsDiagnose( ( *it_aux ), ref_item );
} }
} }
} }