From 2e22c7cb1d9803b80c73f471e5d95ff0b0b687d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 26 Nov 2008 07:23:54 +0000 Subject: [PATCH] CheckMemoryLeak: Refactoring. Use TOKEN::isStandardType instead of rewriting its functionality --- CheckMemoryLeak.cpp | 17 ++++++----------- CheckMemoryLeak.h | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/CheckMemoryLeak.cpp b/CheckMemoryLeak.cpp index 6890bbc07..d76f55b79 100644 --- a/CheckMemoryLeak.cpp +++ b/CheckMemoryLeak.cpp @@ -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 { 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) ); } } diff --git a/CheckMemoryLeak.h b/CheckMemoryLeak.h index 52b8ec5c9..4e6c4160f 100644 --- a/CheckMemoryLeak.h +++ b/CheckMemoryLeak.h @@ -72,7 +72,7 @@ private: const char * call_func( const TOKEN *tok, std::list 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;