Omit unnecessary operations

This commit is contained in:
Dmitry-Me 2015-03-19 15:14:07 +03:00
parent 302d4d4e71
commit 4fcbe00913
1 changed files with 6 additions and 4 deletions

View File

@ -1736,13 +1736,15 @@ Check::FileInfo* CheckBufferOverrun::getFileInfo(const Tokenizer *tokenizer, con
tok->next()->astOperand2()) {
const ValueFlow::Value *value = tok->next()->astOperand2()->getMaxValue(false);
if (value && value->intvalue > 0) {
const int arrayIndex = value->intvalue;
std::map<std::string, struct MyFileInfo::ArrayUsage>::iterator it = fileInfo->arrayUsage.find(tok->str());
if (it != fileInfo->arrayUsage.end() && it->second.index >= arrayIndex)
continue;
struct MyFileInfo::ArrayUsage arrayUsage;
arrayUsage.index = value->intvalue;
arrayUsage.index = arrayIndex;
arrayUsage.fileName = tokenizer->list.file(tok);
arrayUsage.linenr = tok->linenr();
std::map<std::string, struct MyFileInfo::ArrayUsage>::iterator it = fileInfo->arrayUsage.find(tok->str());
if (it == fileInfo->arrayUsage.end() || it->second.index < arrayUsage.index)
fileInfo->arrayUsage[tok->str()] = arrayUsage;
fileInfo->arrayUsage[tok->str()] = arrayUsage;
}
}
}