Fixed false negative in checkunusedvar.cpp and reduced code dupliaction.

This commit is contained in:
PKEuS 2012-09-11 14:24:12 +02:00
parent 623ffe23f0
commit 1863306198
2 changed files with 5 additions and 35 deletions

View File

@ -240,23 +240,8 @@ void Variables::readAliases(unsigned int varid, const Token* tok)
void Variables::readAll(unsigned int varid, const Token* tok)
{
VariableUsage *usage = find(varid);
if (usage) {
usage->_read = true;
usage->_lastAccess = tok;
std::set<unsigned int>::iterator aliases;
for (aliases = usage->_aliases.begin(); aliases != usage->_aliases.end(); ++aliases) {
VariableUsage *aliased = find(*aliases);
if (aliased) {
aliased->_read = true;
aliased->_lastAccess = tok;
}
}
}
read(varid, tok);
readAliases(varid, tok);
}
void Variables::write(unsigned int varid, const Token* tok)
@ -291,23 +276,8 @@ void Variables::writeAliases(unsigned int varid, const Token* tok)
void Variables::writeAll(unsigned int varid, const Token* tok)
{
VariableUsage *usage = find(varid);
if (usage) {
usage->_write = true;
usage->_lastAccess = tok;
std::set<unsigned int>::iterator aliases;
for (aliases = usage->_aliases.begin(); aliases != usage->_aliases.end(); ++aliases) {
VariableUsage *aliased = find(*aliases);
if (aliased) {
aliased->_write = true;
aliased->_lastAccess = tok;
}
}
}
write(varid, tok);
writeAliases(varid, tok);
}
void Variables::use(unsigned int varid, const Token* tok)

View File

@ -1372,7 +1372,7 @@ private:
" a = b[c] = 0;\n"
" return a;\n"
"}");
ASSERT_EQUALS("", errout.str());
ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'b' is assigned a value that is never used\n", errout.str());
}
void localvar24() { // ticket #1803