Refactorization: Removed unnecessary code. Variable::typeStartToken() and Variable::typeEndToken() never point to "const".

Ran AStyle
This commit is contained in:
PKEuS 2012-11-11 13:32:19 +01:00
parent 704f285c90
commit 17b720ef7d
3 changed files with 3 additions and 16 deletions

View File

@ -491,8 +491,6 @@ const char *CheckMemoryLeak::functionArgAlloc(const Function *func, unsigned int
if (!arg->isPointer()) if (!arg->isPointer())
return ""; return "";
const Token* tok = arg->typeEndToken(); const Token* tok = arg->typeEndToken();
if (tok->str() == "const")
tok = tok->previous();
tok = tok->previous(); tok = tok->previous();
if (tok->str() != "*") if (tok->str() != "*")
return ""; return "";
@ -2283,8 +2281,6 @@ void CheckMemoryLeakInClass::check()
if (!var->isStatic() && var->isPointer()) { if (!var->isStatic() && var->isPointer()) {
// allocation but no deallocation of private variables in public function.. // allocation but no deallocation of private variables in public function..
const Token *tok = var->typeStartToken(); const Token *tok = var->typeStartToken();
if (tok->str() == "const")
tok = tok->next();
if (tok->isStandardType()) { if (tok->isStandardType()) {
if (var->isPrivate()) if (var->isPrivate())
checkPublicFunctions(&(*scope), var->nameToken()); checkPublicFunctions(&(*scope), var->nameToken());

View File

@ -120,7 +120,7 @@ void CheckStl::iterators()
const Variable *variableInfo = symbolDatabase->getVariableFromVarId(tok2->varId()); const Variable *variableInfo = symbolDatabase->getVariableFromVarId(tok2->varId());
const Token *decltok = variableInfo ? variableInfo->typeStartToken() : NULL; const Token *decltok = variableInfo ? variableInfo->typeStartToken() : NULL;
if (Token::Match(decltok, "const| std :: set")) if (Token::simpleMatch(decltok, "std :: set"))
continue; // No warning continue; // No warning
// skip error message if the iterator is erased/inserted by value // skip error message if the iterator is erased/inserted by value
@ -795,8 +795,6 @@ void CheckStl::if_find()
// Is the variable a std::string or STL container? // Is the variable a std::string or STL container?
const Token * decl = var->typeStartToken(); const Token * decl = var->typeStartToken();
if (decl->str() == "const")
decl = decl->next();
// stl container // stl container
if (Token::Match(decl, "std :: %var% < %type% > &| %varid%", varid)) if (Token::Match(decl, "std :: %var% < %type% > &| %varid%", varid))
if_findError(tok, false); if_findError(tok, false);
@ -826,9 +824,6 @@ void CheckStl::if_find()
// Is the variable a std::string or STL container? // Is the variable a std::string or STL container?
const Token * decl = var->typeStartToken(); const Token * decl = var->typeStartToken();
//jump next to 'const'
if (decl->str() == "const")
decl = decl->next();
//pretty bad limitation.. but it is there in order to avoid //pretty bad limitation.. but it is there in order to avoid
//own implementations of 'find' or any container //own implementations of 'find' or any container
if (!Token::simpleMatch(decl, "std ::")) if (!Token::simpleMatch(decl, "std ::"))
@ -901,10 +896,6 @@ bool CheckStl::isStlContainer(unsigned int varid)
// find where this tokens type starts // find where this tokens type starts
const Token *type = var->typeStartToken(); const Token *type = var->typeStartToken();
// ignore "const"
if (type->str() == "const")
type = type->next();
// discard namespace if supplied // discard namespace if supplied
if (Token::simpleMatch(type, "std ::")) if (Token::simpleMatch(type, "std ::"))
type = type->tokAt(2); type = type->tokAt(2);