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