Code cleanup. Omit redundant actions.

This commit is contained in:
Dmitry-Me 2014-11-18 06:38:19 +01:00 committed by Daniel Marjamäki
parent 8bcf833bb7
commit e12d280e90
2 changed files with 11 additions and 9 deletions

View File

@ -636,7 +636,9 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
for (; tok; tok = tok->nextArgument()) {
++par;
if (varid > 0 && Token::Match(tok, "%varid% [,()]", varid)) {
if (varid == 0)
continue;
if (Token::Match(tok, "%varid% [,()]", varid)) {
if (dot)
return "use";
@ -648,11 +650,11 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
if (numpar != function->argCount()) // TODO: Handle default parameters
return "recursive";
if (!function->functionScope)
return "use";
const Variable* param = function->getArgumentVar(par-1);
if (!param || !param->nameToken())
return "use";
if (!function->functionScope)
return "use";
Token *func = getcode(function->functionScope->classStart->next(), callstack, param->declarationId(), alloctype, dealloctype, false, sz);
//simplifycode(func);
const Token *func_ = func;
@ -671,7 +673,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
TokenList::deleteTokens(func);
return ret;
}
if (varid > 0 && Token::Match(tok, "& %varid% [,()]", varid)) {
if (Token::Match(tok, "& %varid% [,()]", varid)) {
const Function *func = functok->function();
if (func == 0)
continue;
@ -687,7 +689,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
return ret;
}
}
if (varid > 0 && Token::Match(tok, "%varid% . %var% [,)]", varid))
if (Token::Match(tok, "%varid% . %var% [,)]", varid))
return "use";
}
return (eq || _settings->experimental) ? 0 : "callfunc";
@ -908,9 +910,9 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
break;
}
if (!used) {
if (!used && !rhs) {
if (Token::Match(tok2, "[=+(,] %varid%", varid)) {
if (!rhs && Token::Match(tok2, "[(,]")) {
if (Token::Match(tok2, "[(,]")) {
used = true;
addtoken(&rettail, tok, "use");
addtoken(&rettail, tok, ";");

View File

@ -3099,10 +3099,10 @@ std::string Preprocessor::expandMacros(const std::string &code, std::string file
}
// get parameters from line..
if (macro->params().size() && pos >= line.length())
break;
std::vector<std::string> params;
std::string::size_type pos2 = pos;
if (macro->params().size() && pos2 >= line.length())
break;
// number of newlines within macro use
unsigned int numberOfNewlines = 0;