C++11: Favor auto, range for. No functional change intended.

This commit is contained in:
Wilson Snyder
2020-08-16 11:44:06 -04:00
parent 034737d2a8
commit ee9d6dd63f
77 changed files with 371 additions and 505 deletions
+27 -29
View File
@@ -70,8 +70,8 @@ void VlcTop::writeCoverage(const string& filename) {
}
os << "# SystemC::Coverage-3" << endl;
for (VlcPoints::ByName::const_iterator it = m_points.begin(); it != m_points.end(); ++it) {
const VlcPoint& point = m_points.pointNumber(it->second);
for (const auto& i : m_points) {
const VlcPoint& point = m_points.pointNumber(i.second);
os << "C '" << point.name() << "' " << point.count() << endl;
}
}
@@ -107,17 +107,17 @@ void VlcTop::writeInfo(const string& filename) {
// end_of_record
os << "TN:verilator_coverage\n";
for (VlcSources::NameMap::iterator sit = m_sources.begin(); sit != m_sources.end(); ++sit) {
VlcSource& source = sit->second;
for (auto& si : m_sources) {
VlcSource& source = si.second;
os << "SF:" << source.name() << endl;
VlcSource::LinenoMap& lines = source.lines();
for (VlcSource::LinenoMap::iterator lit = lines.begin(); lit != lines.end(); ++lit) {
int lineno = lit->first;
VlcSource::ColumnMap& cmap = lit->second;
for (auto& li : lines) {
int lineno = li.first;
VlcSource::ColumnMap& cmap = li.second;
bool first = true;
vluint64_t min_count = 0; // Minimum across all columns on line
for (VlcSource::ColumnMap::iterator cit = cmap.begin(); cit != cmap.end(); ++cit) {
VlcSourceCount& col = cit->second;
for (auto& ci : cmap) {
VlcSourceCount& col = ci.second;
if (first) {
min_count = col.count();
first = false;
@@ -148,17 +148,16 @@ void VlcTop::rank() {
// Sort by computrons, so fast tests get selected first
std::vector<VlcTest*> bytime;
for (VlcTests::ByName::const_iterator it = m_tests.begin(); it != m_tests.end(); ++it) {
VlcTest* testp = *it;
for (const auto& testp : m_tests) {
if (testp->bucketsCovered()) { // else no points, so can't help us
bytime.push_back(*it);
bytime.push_back(testp);
}
}
sort(bytime.begin(), bytime.end(), CmpComputrons()); // Sort the vector
VlcBuckets remaining;
for (VlcPoints::ByName::const_iterator it = m_points.begin(); it != m_points.end(); ++it) {
VlcPoint* pointp = &points().pointNumber(it->second);
for (const auto& i : m_points) {
VlcPoint* pointp = &points().pointNumber(i.second);
// If any tests hit this point, then we'll need to cover it.
if (pointp->testsCovering()) remaining.addData(pointp->pointNum(), 1);
}
@@ -174,8 +173,7 @@ void VlcTop::rank() {
}
VlcTest* bestTestp = nullptr;
vluint64_t bestRemain = 0;
for (std::vector<VlcTest*>::iterator it = bytime.begin(); it != bytime.end(); ++it) {
VlcTest* testp = *it;
for (const auto& testp : bytime) {
if (!testp->rank()) {
vluint64_t remain = testp->buckets().dataPopCount(remaining);
if (remain > bestRemain) {
@@ -198,8 +196,8 @@ void VlcTop::rank() {
void VlcTop::annotateCalc() {
// Calculate per-line information into filedata structure
for (VlcPoints::ByName::const_iterator it = m_points.begin(); it != m_points.end(); ++it) {
const VlcPoint& point = m_points.pointNumber(it->second);
for (const auto& i : m_points) {
const VlcPoint& point = m_points.pointNumber(i.second);
string filename = point.filename();
int lineno = point.lineno();
if (!filename.empty() && lineno != 0) {
@@ -244,15 +242,15 @@ void VlcTop::annotateCalcNeeded() {
// coverage in all categories
int totCases = 0;
int totOk = 0;
for (VlcSources::NameMap::iterator sit = m_sources.begin(); sit != m_sources.end(); ++sit) {
VlcSource& source = sit->second;
for (auto& si : m_sources) {
VlcSource& source = si.second;
// UINFO(1,"Source "<<source.name()<<endl);
if (opt.annotateAll()) source.needed(true);
VlcSource::LinenoMap& lines = source.lines();
for (VlcSource::LinenoMap::iterator lit = lines.begin(); lit != lines.end(); ++lit) {
VlcSource::ColumnMap& cmap = lit->second;
for (VlcSource::ColumnMap::iterator cit = cmap.begin(); cit != cmap.end(); ++cit) {
VlcSourceCount& col = cit->second;
for (auto& li : lines) {
VlcSource::ColumnMap& cmap = li.second;
for (auto& ci : cmap) {
VlcSourceCount& col = ci.second;
// UINFO(0,"Source "<<source.name()<<":"<<col.lineno()<<":"<<col.column()<<endl);
++totCases;
if (col.ok()) {
@@ -272,8 +270,8 @@ void VlcTop::annotateCalcNeeded() {
void VlcTop::annotateOutputFiles(const string& dirname) {
// Create if uncreated, ignore errors
V3Os::createDir(dirname);
for (VlcSources::NameMap::iterator sit = m_sources.begin(); sit != m_sources.end(); ++sit) {
VlcSource& source = sit->second;
for (auto& si : m_sources) {
VlcSource& source = si.second;
if (!source.needed()) continue;
string filename = source.name();
string outfilename = dirname + "/" + V3Os::filenameNonDir(filename);
@@ -302,11 +300,11 @@ void VlcTop::annotateOutputFiles(const string& dirname) {
bool first = true;
VlcSource::LinenoMap& lines = source.lines();
VlcSource::LinenoMap::iterator lit = lines.find(lineno);
const auto lit = lines.find(lineno);
if (lit != lines.end()) {
VlcSource::ColumnMap& cmap = lit->second;
for (VlcSource::ColumnMap::iterator cit = cmap.begin(); cit != cmap.end(); ++cit) {
VlcSourceCount& col = cit->second;
for (auto& ci : cmap) {
VlcSourceCount& col = ci.second;
// UINFO(0,"Source
// "<<source.name()<<":"<<col.lineno()<<":"<<col.column()<<endl);
os << (col.ok() ? " " : "%") << std::setfill('0') << std::setw(6)