64 lines
2.4 KiB
C++
64 lines
2.4 KiB
C++
/*
|
|
* c++check - c/c++ syntax checking
|
|
* Copyright (C) 2007 Daniel Marjamäki
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/
|
|
*/
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
#ifndef CheckMemoryLeakH
|
|
#define CheckMemoryLeakH
|
|
//---------------------------------------------------------------------------
|
|
|
|
/** \brief Check for memory leaks */
|
|
|
|
#include <vector>
|
|
#include "tokenize.h"
|
|
|
|
enum AllocType { No, Malloc, gMalloc, New, NewA };
|
|
|
|
class CheckMemoryLeakClass
|
|
{
|
|
public:
|
|
CheckMemoryLeakClass( Tokenizer *tokenizer );
|
|
~CheckMemoryLeakClass();
|
|
void CheckMemoryLeak();
|
|
|
|
private:
|
|
void CheckMemoryLeak_ClassMembers_Variable( const std::vector<const char *> &classname, const char varname[] );
|
|
void CheckMemoryLeak_ClassMembers_ParseClass( const TOKEN *tok1, std::vector<const char *> &classname );
|
|
void CheckMemoryLeak_ClassMembers();
|
|
void CheckMemoryLeak_InFunction();
|
|
void CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const char typestr[], const char varname[] );
|
|
void simplifycode(TOKEN *tok);
|
|
void erase(TOKEN *begin, const TOKEN *end);
|
|
|
|
TOKEN *getcode(const TOKEN *tok, const char typestr[], const char varname[]);
|
|
bool notvar(const TOKEN *tok, const char *varnames[]);
|
|
void instoken(TOKEN *tok, const char str[]);
|
|
void MemoryLeak( const TOKEN *tok, const char varname[] );
|
|
void MismatchError( const TOKEN *Tok1, const char varname[] );
|
|
const char * call_func( const TOKEN *tok, const char typestr[], const char *varnames[] );
|
|
AllocType GetDeallocationType( const TOKEN *tok, const char *varnames[] );
|
|
AllocType GetAllocationType( const TOKEN *tok2 );
|
|
bool isclass( const std::string &typestr );
|
|
|
|
Tokenizer *_tokenizer;
|
|
};
|
|
|
|
//---------------------------------------------------------------------------
|
|
#endif
|