Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Test clang-tidy --checks modernize-loop-convert #29935

Closed
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Checks: -*,
,modernize-use-equals-delete,
,modernize-use-nullptr,
,modernize-use-override,
,modernize-loop-convert,
,performance-unnecessary-copy-initialization,
,readability-container-size-empty,
,readability-redundant-string-cstr,
Expand Down
4 changes: 2 additions & 2 deletions Alignment/APEEstimation/plugins/ApeEstimator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2640,8 +2640,8 @@ void ApeEstimator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet
const std::vector<TrajectoryMeasurement> v_meas = (*traj).measurements();

//Loop over Hits
for (std::vector<TrajectoryMeasurement>::const_iterator i_meas = v_meas.begin(); i_meas != v_meas.end(); ++i_meas) {
TrackStruct::HitParameterStruct hitParams = this->fillHitVariables(*i_meas, iSetup);
for (const auto& v_mea : v_meas) {
TrackStruct::HitParameterStruct hitParams = this->fillHitVariables(v_mea, iSetup);
if (this->hitSelected(hitParams))
trackStruct.v_hitParams.push_back(hitParams);
}
Expand Down
8 changes: 3 additions & 5 deletions Alignment/APEEstimation/plugins/ApeEstimatorSummary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1020,11 +1020,9 @@ void ApeEstimatorSummary::analyze(const edm::Event& iEvent, const edm::EventSetu
unsigned int nModules(0);
for (auto const& i_rawId : i_sector.second.v_rawId) {
std::vector<AlignTransformErrorExtended> alignErrors = alignmentErrors->m_alignError;
for (std::vector<AlignTransformErrorExtended>::const_iterator i_alignError = alignErrors.begin();
i_alignError != alignErrors.end();
++i_alignError) {
if (i_rawId == i_alignError->rawId()) {
CLHEP::HepSymMatrix errMatrix = i_alignError->matrix();
for (const auto& alignError : alignErrors) {
if (i_rawId == alignError.rawId()) {
CLHEP::HepSymMatrix errMatrix = alignError.matrix();
defaultApeX += errMatrix[0][0];
defaultApeY += errMatrix[1][1];
nModules++;
Expand Down
4 changes: 2 additions & 2 deletions Alignment/CocoaModel/interface/MeasurementCOPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
class MeasurementCOPS : public Measurement {
public:
MeasurementCOPS(const ALIint measdim, ALIstring& type, ALIstring& name) : Measurement(measdim, type, name) {
for (unsigned int ii = 0; ii < 4; ii++)
theXlaserLine[ii] = -1;
for (int& ii : theXlaserLine)
ii = -1;
};
MeasurementCOPS(){};
~MeasurementCOPS() override{};
Expand Down
32 changes: 16 additions & 16 deletions Alignment/CocoaModel/src/ALIUnitsTable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ ALIdouble ALIUnitDefinition::GetValueOf(ALIstring stri) {
if (theUnitsTable.empty())
BuildUnitsTable();
ALIstring name, symbol;
for (size_t i = 0; i < theUnitsTable.size(); i++) {
ALIUnitsContainer& units = theUnitsTable[i]->GetUnitsList();
for (size_t j = 0; j < units.size(); j++) {
name = units[j]->GetName();
symbol = units[j]->GetSymbol();
for (auto& i : theUnitsTable) {
ALIUnitsContainer& units = i->GetUnitsList();
for (auto& unit : units) {
name = unit->GetName();
symbol = unit->GetSymbol();
if (stri == name || stri == symbol)
return units[j]->GetValue();
return unit->GetValue();
}
}
std::cout << "Warning from ALIUnitDefinition::GetValueOf(" << stri << ")."
Expand All @@ -87,13 +87,13 @@ ALIstring ALIUnitDefinition::GetCategory(ALIstring stri) {
if (theUnitsTable.empty())
BuildUnitsTable();
ALIstring name, symbol;
for (size_t i = 0; i < theUnitsTable.size(); i++) {
ALIUnitsContainer& units = theUnitsTable[i]->GetUnitsList();
for (size_t j = 0; j < units.size(); j++) {
name = units[j]->GetName();
symbol = units[j]->GetSymbol();
for (auto& i : theUnitsTable) {
ALIUnitsContainer& units = i->GetUnitsList();
for (auto& unit : units) {
name = unit->GetName();
symbol = unit->GetSymbol();
if (stri == name || stri == symbol)
return theUnitsTable[i]->GetName();
return i->GetName();
}
}
std::cout << "Warning from ALIUnitDefinition::GetCategory(" << stri << ")."
Expand Down Expand Up @@ -231,8 +231,8 @@ void ALIUnitDefinition::BuildUnitsTable() {

void ALIUnitDefinition::PrintUnitsTable() {
std::cout << "\n ----- The Table of Units ----- \n";
for (size_t i = 0; i < theUnitsTable.size(); i++)
theUnitsTable[i]->PrintCategory();
for (auto& i : theUnitsTable)
i->PrintCategory();
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Expand Down Expand Up @@ -273,8 +273,8 @@ ALIint ALIUnitsCategory::operator!=(const ALIUnitsCategory& right) const { retur

void ALIUnitsCategory::PrintCategory() {
std::cout << "\n category: " << Name << std::endl;
for (size_t i = 0; i < UnitsList.size(); i++)
UnitsList[i]->PrintDefinition();
for (auto& i : UnitsList)
i->PrintDefinition();
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Expand Down
4 changes: 2 additions & 2 deletions Alignment/CocoaModel/src/Measurement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ void Measurement::constructFromOA(OpticalAlignMeasurementInfo& measInfo) {
if (ALIUtils::debug >= 3) {
std::cout << "@@@@ Reading Measurement " << name() << " TYPE= " << type() << " " << measInfo << std::endl
<< " MEASURED OPTO NAMES: ";
for (size_t ii = 0; ii < _OptONameList.size(); ii++) {
std::cout << _OptONameList[ii] << " ";
for (const auto& ii : _OptONameList) {
std::cout << ii << " ";
}
std::cout << std::endl;
}
Expand Down
27 changes: 13 additions & 14 deletions Alignment/CocoaToDDL/src/CocoaToDDLMgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ void CocoaToDDLMgr::writeHeader(ALIstring filename) { newPartPre(filename); }
void CocoaToDDLMgr::writeMaterials() {
newSectPre_ma("");
auto& optolist = Model::OptOList();
for (auto ite = optolist.begin(); ite != optolist.end(); ite++) {
if ((*ite)->type() == "system")
for (auto& ite : optolist) {
if (ite->type() == "system")
continue;
CocoaMaterialElementary* mat = (*ite)->getMaterial();
CocoaMaterialElementary* mat = ite->getMaterial();
//- std::cout << " mat of opto " << (*ite)->name() << " = " << mat->getName() << std::endl;
if (mat) {
if (!materialIsRepeated(mat))
Expand Down Expand Up @@ -119,10 +119,10 @@ void CocoaToDDLMgr::writePhysicalVolumes() {
newSectPre_pv("");

auto& optolist = Model::OptOList();
for (auto ite = optolist.begin(); ite != optolist.end(); ite++) {
if ((*ite)->type() == "system")
for (auto& ite : optolist) {
if (ite->type() == "system")
continue;
pv(*ite);
pv(ite);
}

newSectPost_pv("");
Expand All @@ -146,10 +146,10 @@ void CocoaToDDLMgr::writeSpecPars() {
newSectPre_specPar("");

auto& optolist = Model::OptOList();
for (auto ite = optolist.begin(); ite != optolist.end(); ite++) {
if ((*ite)->type() == "system")
for (auto& ite : optolist) {
if (ite->type() == "system")
continue;
specPar(*ite);
specPar(ite);
}

writeSpecParsCocoa();
Expand Down Expand Up @@ -583,8 +583,7 @@ void CocoaToDDLMgr::specPar(OpticalObject* opto) {
}

const std::vector<Entry*>& extraEnt = opto->ExtraEntryList();
for (ALIuint ii = 0; ii < extraEnt.size(); ii++) {
Entry* ent = extraEnt[ii];
for (auto ent : extraEnt) {
file_ << " <Parameter name=\"extra_entry\" value=\"" << ent->name() << "\" eval=\"false\" /> " << std::endl;
file_ << " <Parameter name=\"dimType\" value=\"" << ent->type() << "\" eval=\"false\" /> " << std::endl;
file_ << " <Parameter name=\"value\" value=\"";
Expand Down Expand Up @@ -672,10 +671,10 @@ void CocoaToDDLMgr::writeSpecParsCocoa() {
file_ << "<!-- Define volumes as COCOA objects --> " << std::endl << " <SpecPar name=\"COCOA\"> " << std::endl;

auto& optolist = Model::OptOList();
for (auto ite = optolist.begin(); ite != optolist.end(); ite++) {
if ((*ite)->type() == "system")
for (auto& ite : optolist) {
if (ite->type() == "system")
continue;
file_ << " <PartSelector path=\"/" << (*ite)->name() << "\"/> " << std::endl;
file_ << " <PartSelector path=\"/" << ite->name() << "\"/> " << std::endl;
}

file_ << " <String name=\"COCOA\" value=\"COCOA\"/> " << std::endl << " </SpecPar> " << std::endl;
Expand Down
36 changes: 18 additions & 18 deletions Alignment/CocoaToDDL/src/CocoaUnitsTable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ CocoaUnitDefinition::CocoaUnitDefinition(const ALIstring& name,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....

CocoaUnitDefinition::~CocoaUnitDefinition() {
for (size_t i = 0; i < theUnitsTable.size(); i++) {
delete theUnitsTable[i];
for (auto& i : theUnitsTable) {
delete i;
}
}

Expand Down Expand Up @@ -74,13 +74,13 @@ ALIdouble CocoaUnitDefinition::GetValueOf(const ALIstring& str) {
if (theUnitsTable.empty())
BuildUnitsTable();
ALIstring name, symbol;
for (size_t i = 0; i < theUnitsTable.size(); i++) {
CocoaUnitsContainer& units = theUnitsTable[i]->GetUnitsList();
for (size_t j = 0; j < units.size(); j++) {
name = units[j]->GetName();
symbol = units[j]->GetSymbol();
for (auto& i : theUnitsTable) {
CocoaUnitsContainer& units = i->GetUnitsList();
for (auto& unit : units) {
name = unit->GetName();
symbol = unit->GetSymbol();
if (str == name || str == symbol)
return units[j]->GetValue();
return unit->GetValue();
}
}
std::cout << "Warning from CocoaUnitDefinition::GetValueOf(" << str << ")."
Expand All @@ -95,13 +95,13 @@ ALIstring CocoaUnitDefinition::GetCategory(const ALIstring& str) {
if (theUnitsTable.empty())
BuildUnitsTable();
ALIstring name, symbol;
for (size_t i = 0; i < theUnitsTable.size(); i++) {
CocoaUnitsContainer& units = theUnitsTable[i]->GetUnitsList();
for (size_t j = 0; j < units.size(); j++) {
name = units[j]->GetName();
symbol = units[j]->GetSymbol();
for (auto& i : theUnitsTable) {
CocoaUnitsContainer& units = i->GetUnitsList();
for (auto& unit : units) {
name = unit->GetName();
symbol = unit->GetSymbol();
if (str == name || str == symbol)
return theUnitsTable[i]->GetName();
return i->GetName();
}
}
std::cout << "Warning from CocoaUnitDefinition::GetCategory(" << str << ")."
Expand Down Expand Up @@ -238,8 +238,8 @@ void CocoaUnitDefinition::BuildUnitsTable() {

void CocoaUnitDefinition::PrintUnitsTable() {
std::cout << "\n ----- The Table of Units ----- \n";
for (size_t i = 0; i < theUnitsTable.size(); i++) {
theUnitsTable[i]->PrintCategory();
for (auto& i : theUnitsTable) {
i->PrintCategory();
}
}

Expand Down Expand Up @@ -279,8 +279,8 @@ ALIint CocoaUnitsCategory::operator!=(const CocoaUnitsCategory& right) const { r

void CocoaUnitsCategory::PrintCategory() {
std::cout << "\n category: " << Name << std::endl;
for (size_t i = 0; i < UnitsList.size(); i++)
UnitsList[i]->PrintDefinition();
for (auto& i : UnitsList)
i->PrintDefinition();
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Expand Down
8 changes: 4 additions & 4 deletions Alignment/CommonAlignment/src/AlignTools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ void align::createPoints(align::GlobalVectors* Vs,
ali->setSurvey(new SurveyDet(ali->surface(), error * 1e-6));
}
const align::GlobalPoints& points = ali->surface().toGlobal(ali->survey()->localPoints());
for (unsigned int j = 0; j < points.size(); ++j) {
align::GlobalVector dummy(points[j].x(), points[j].y(), points[j].z());
for (const auto& point : points) {
align::GlobalVector dummy(point.x(), point.y(), point.z());
Vs->push_back(dummy);
}
}
Expand All @@ -141,8 +141,8 @@ void align::createPoints(align::GlobalVectors* Vs,
ali->setSurvey(new SurveyDet(ali->surface(), error * 1e-6));
}
const align::GlobalPoints& points = ali->surface().toGlobal(ali->survey()->localPoints());
for (unsigned int j = 0; j < points.size(); ++j) {
align::GlobalVector dummy(points[j].x(), points[j].y(), points[j].z());
for (const auto& point : points) {
align::GlobalVector dummy(point.x(), point.y(), point.z());
Vs->push_back(dummy);
}
}
Expand Down
5 changes: 2 additions & 3 deletions Alignment/CommonAlignment/src/Alignable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,10 @@ AlignmentSurfaceDeformations* Alignable::surfaceDeformations(void) const {

AlignmentSurfaceDeformations* allSurfaceDeformations = new AlignmentSurfaceDeformations();

for (std::vector<IdSurfaceDeformationPtrPair>::const_iterator iPair = result.begin(); iPair != result.end();
++iPair) {
for (const auto& iPair : result) {
// should we check for 'empty' parameters here (all zeros) and skip ?
// may be add 'empty' method to SurfaceDeformation
allSurfaceDeformations->add((*iPair).first, (*iPair).second->type(), (*iPair).second->parameters());
allSurfaceDeformations->add(iPair.first, iPair.second->type(), iPair.second->parameters());
}

return allSurfaceDeformations;
Expand Down
4 changes: 2 additions & 2 deletions Alignment/CommonAlignment/src/AlignableComposite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ AlignableComposite::AlignableComposite(align::ID id, StructureType type, const R

//__________________________________________________________________________________________________
AlignableComposite::~AlignableComposite() {
for (unsigned int i = 0; i < theComponents.size(); ++i)
delete theComponents[i];
for (auto& theComponent : theComponents)
delete theComponent;
}

//__________________________________________________________________________________________________
Expand Down
4 changes: 2 additions & 2 deletions Alignment/CommonAlignment/src/AlignableDet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ AlignableDet::AlignableDet(const GeomDet* geomDet, bool addComponents)
<< " has no components, use AlignableDetUnit.\n";
} else { // Push back all components
const std::vector<const GeomDet*>& geomDets = geomDet->components();
for (std::vector<const GeomDet*>::const_iterator idet = geomDets.begin(); idet != geomDets.end(); ++idet) {
const GeomDetUnit* unit = dynamic_cast<const GeomDetUnit*>(*idet);
for (auto geomDet : geomDets) {
const GeomDetUnit* unit = dynamic_cast<const GeomDetUnit*>(geomDet);
if (!unit) {
throw cms::Exception("BadHierarchy")
<< "[AlignableDet] component not GeomDetUnit, call with addComponents==false"
Expand Down
12 changes: 6 additions & 6 deletions Alignment/CommonAlignment/src/AlignableExtras.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ void AlignableExtras::dump(void) const {
edm::LogInfo("AlignableDump") << " AlignableExtras knows " << comp.size() << " alignable(s)" << std::endl;

// Dump components
for (Alignables::iterator i = comp.begin(); i != comp.end(); ++i)
(*i)->dump();
for (auto& i : comp)
i->dump();
}

//__________________________________________________________________________________________________
Alignments* AlignableExtras::alignments(void) const {
align::Alignables comp = this->components();
Alignments* m_alignments = new Alignments();
// Add components recursively
for (align::Alignables::iterator i = comp.begin(); i != comp.end(); ++i) {
Alignments* tmpAlignments = (*i)->alignments();
for (auto& i : comp) {
Alignments* tmpAlignments = i->alignments();
std::copy(tmpAlignments->m_align.begin(), tmpAlignments->m_align.end(), std::back_inserter(m_alignments->m_align));
delete tmpAlignments;
}
Expand All @@ -60,8 +60,8 @@ AlignmentErrorsExtended* AlignableExtras::alignmentErrors(void) const {
AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended();

// Add components recursively
for (align::Alignables::iterator i = comp.begin(); i != comp.end(); ++i) {
AlignmentErrorsExtended* tmpAlignmentErrorsExtended = (*i)->alignmentErrors();
for (auto& i : comp) {
AlignmentErrorsExtended* tmpAlignmentErrorsExtended = i->alignmentErrors();
std::copy(tmpAlignmentErrorsExtended->m_alignError.begin(),
tmpAlignmentErrorsExtended->m_alignError.end(),
std::back_inserter(m_alignmentErrors->m_alignError));
Expand Down
4 changes: 2 additions & 2 deletions Alignment/CommonAlignment/src/AlignableMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ align::Alignables& AlignableMap::find(const std::string& name) {
//_____________________________________________________________________________
void AlignableMap::dump(void) const {
edm::LogInfo("AlignableMap") << "Printing out AlignSetup: ";
for (typename Container::const_iterator it = theStore.begin(); it != theStore.end(); ++it) {
edm::LogVerbatim("AlignableMap") << it->first << std::endl;
for (const auto& it : theStore) {
edm::LogVerbatim("AlignableMap") << it.first << std::endl;
}
}
Loading