Refactoring: Use range for loop

This commit is contained in:
Daniel Marjamäki 2018-09-23 17:02:54 +02:00
parent 7db671fee6
commit 7f255c9e6f
1 changed files with 9 additions and 9 deletions

View File

@ -546,17 +546,17 @@ std::string ErrorLogger::ErrorMessage::toString(bool verbose, const std::string
void ErrorLogger::reportUnmatchedSuppressions(const std::list<Suppressions::Suppression> &unmatched) void ErrorLogger::reportUnmatchedSuppressions(const std::list<Suppressions::Suppression> &unmatched)
{ {
// Report unmatched suppressions // Report unmatched suppressions
for (std::list<Suppressions::Suppression>::const_iterator i = unmatched.begin(); i != unmatched.end(); ++i) { for (const Suppressions::Suppression &s : unmatched) {
// don't report "unmatchedSuppression" as unmatched // don't report "unmatchedSuppression" as unmatched
if (i->errorId == "unmatchedSuppression") if (s.errorId == "unmatchedSuppression")
continue; continue;
// check if this unmatched suppression is suppressed // check if this unmatched suppression is suppressed
bool suppressed = false; bool suppressed = false;
for (std::list<Suppressions::Suppression>::const_iterator i2 = unmatched.begin(); i2 != unmatched.end(); ++i2) { for (const Suppressions::Suppression &s2 : unmatched) {
if (i2->errorId == "unmatchedSuppression") { if (s2.errorId == "unmatchedSuppression") {
if ((i2->fileName == "*" || i2->fileName == i->fileName) && if ((s2.fileName == "*" || s2.fileName == s.fileName) &&
(i2->lineNumber == Suppressions::Suppression::NO_LINE || i2->lineNumber == i->lineNumber)) { (s2.lineNumber == Suppressions::Suppression::NO_LINE || s2.lineNumber == s.lineNumber)) {
suppressed = true; suppressed = true;
break; break;
} }
@ -567,9 +567,9 @@ void ErrorLogger::reportUnmatchedSuppressions(const std::list<Suppressions::Supp
continue; continue;
std::list<ErrorLogger::ErrorMessage::FileLocation> callStack; std::list<ErrorLogger::ErrorMessage::FileLocation> callStack;
if (!i->fileName.empty()) if (!s.fileName.empty())
callStack.emplace_back(i->fileName, i->lineNumber); callStack.emplace_back(s.fileName, s.lineNumber);
reportErr(ErrorLogger::ErrorMessage(callStack, emptyString, Severity::information, "Unmatched suppression: " + i->errorId, "unmatchedSuppression", false)); reportErr(ErrorLogger::ErrorMessage(callStack, emptyString, Severity::information, "Unmatched suppression: " + s.errorId, "unmatchedSuppression", false));
} }
} }