CheckMemoryLeak: Refactoring. Use TOKEN::isStandardType instead of rewriting its functionality

This commit is contained in:
Daniel Marjamäki 2008-11-26 07:23:54 +00:00
parent b179083788
commit 2e22c7cb1d
2 changed files with 7 additions and 12 deletions

View File

@ -49,18 +49,13 @@ CheckMemoryLeakClass::~CheckMemoryLeakClass()
}
bool CheckMemoryLeakClass::isclass( const std::string &typestr )
{
if ( typestr == "char" ||
typestr == "short" ||
typestr == "int" ||
typestr == "long" ||
typestr == "float" ||
typestr == "double" )
bool CheckMemoryLeakClass::isclass( const TOKEN *tok )
{
if ( tok->isStandardType() )
return false;
std::ostringstream pattern;
pattern << "struct " << typestr;
pattern << "struct " << tok->str();
if ( TOKEN::findmatch( _tokenizer->tokens(), pattern.str().c_str() ) )
return false;
@ -343,7 +338,7 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list<const TOKEN *>
{
if ( TOKEN::Match(tok->tokAt(3), "new %type% [(;]") )
{
if ( isclass( tok->strAt(4) ) )
if ( isclass( tok->tokAt(4) ) )
alloc = No;
}
}
@ -982,7 +977,7 @@ void CheckMemoryLeakClass::CheckMemoryLeak_ClassMembers_ParseClass( const TOKEN
{
if ( tok->isName() || strchr(";}", tok->aaaa0()) )
{
if (_settings._showAll || !isclass(tok->strAt(1)))
if (_settings._showAll || !isclass(tok->tokAt(1)))
CheckMemoryLeak_ClassMembers_Variable( classname, tok->strAt(3) );
}
}

View File

@ -72,7 +72,7 @@ private:
const char * call_func( const TOKEN *tok, std::list<const TOKEN *> callstack, const char *varnames[], AllocType &alloctype, AllocType &dealloctype );
AllocType GetDeallocationType( const TOKEN *tok, const char *varnames[]);
AllocType GetAllocationType( const TOKEN *tok2 );
bool isclass( const std::string &typestr );
bool isclass( const TOKEN *typestr );
const Tokenizer *_tokenizer;
ErrorLogger *_errorLogger;