Merge pull request #715 from Dmitry-Me/eliminateRepeatedLookup3
Remove repeated lookup
This commit is contained in:
commit
57e9954390
|
@ -596,14 +596,16 @@ void CheckOther::checkRedundantAssignment()
|
||||||
if (param1->varId() && param1->strAt(1) == "," && !Token::Match(tok, "strcat|strncat|wcscat|wcsncat")) {
|
if (param1->varId() && param1->strAt(1) == "," && !Token::Match(tok, "strcat|strncat|wcscat|wcsncat")) {
|
||||||
if (tok->str() == "memset" && initialized.find(param1->varId()) == initialized.end() && param1->variable() && param1->variable()->isLocal() && param1->variable()->isArray())
|
if (tok->str() == "memset" && initialized.find(param1->varId()) == initialized.end() && param1->variable() && param1->variable()->isLocal() && param1->variable()->isArray())
|
||||||
initialized.insert(param1->varId());
|
initialized.insert(param1->varId());
|
||||||
else if (memAssignments.find(param1->varId()) == memAssignments.end())
|
|
||||||
memAssignments[param1->varId()] = tok;
|
|
||||||
else {
|
else {
|
||||||
const std::map<unsigned int, const Token*>::const_iterator it = memAssignments.find(param1->varId());
|
const std::map<unsigned int, const Token*>::const_iterator it = memAssignments.find(param1->varId());
|
||||||
if (printWarning && scope->type == Scope::eSwitch && Token::findmatch(it->second, "default|case", tok))
|
if (it == memAssignments.end())
|
||||||
redundantCopyInSwitchError(it->second, tok, param1->str());
|
memAssignments[param1->varId()] = tok;
|
||||||
else if (printPerformance)
|
else {
|
||||||
redundantCopyError(it->second, tok, param1->str());
|
if (printWarning && scope->type == Scope::eSwitch && Token::findmatch(it->second, "default|case", tok))
|
||||||
|
redundantCopyInSwitchError(it->second, tok, param1->str());
|
||||||
|
else if (printPerformance)
|
||||||
|
redundantCopyError(it->second, tok, param1->str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (scope->type == Scope::eSwitch) { // Avoid false positives if noreturn function is called in switch
|
} else if (scope->type == Scope::eSwitch) { // Avoid false positives if noreturn function is called in switch
|
||||||
|
|
Loading…
Reference in New Issue