memory leak : Added experimental functionality for multipass checking of memory leaks. Only added in the unit tests yet.
This commit is contained in:
parent
0a73591c5c
commit
bf37a1153c
4
Makefile
4
Makefile
|
@ -1,6 +1,6 @@
|
||||||
SRCS=checkbufferoverrun.cpp checkclass.cpp checkheaders.cpp checkmemoryleak.cpp checkfunctionusage.cpp checkother.cpp filelister.cpp preprocessor.cpp tokenize.cpp cppcheck.cpp settings.cpp token.cpp cppcheckexecutor.cpp
|
SRCS=checkbufferoverrun.cpp checkclass.cpp checkheaders.cpp checkmemoryleak.cpp checkfunctionusage.cpp checkother.cpp filelister.cpp preprocessor.cpp tokenize.cpp cppcheck.cpp settings.cpp token.cpp cppcheckexecutor.cpp
|
||||||
OBJS=$(SRCS:%.cpp=%.o)
|
OBJS=$(SRCS:%.cpp=%.o)
|
||||||
TESTS=testbufferoverrun.o testcharvar.o testclass.o testconstructors.o testdivision.o testfunctionusage.o testincompletestatement.o testother.o testmemleak.o testpreprocessor.o testredundantif.o testsimplifytokens.o testtokenize.o testtoken.o testunusedprivfunc.o testunusedvar.o testfilelister.o
|
TESTS=testbufferoverrun.o testcharvar.o testclass.o testconstructors.o testdivision.o testfunctionusage.o testincompletestatement.o testother.o testmemleak.o testmemleakmp.o testpreprocessor.o testredundantif.o testsimplifytokens.o testtokenize.o testtoken.o testunusedprivfunc.o testunusedvar.o testfilelister.o
|
||||||
BIN = ${DESTDIR}/usr/bin
|
BIN = ${DESTDIR}/usr/bin
|
||||||
|
|
||||||
all: ${OBJS} main.o
|
all: ${OBJS} main.o
|
||||||
|
@ -49,6 +49,8 @@ testother.o: testother.cpp testsuite.h errorlogger.h tokenize.h settings.h token
|
||||||
g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp
|
g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp
|
||||||
testmemleak.o: testmemleak.cpp tokenize.h settings.h errorlogger.h token.h checkmemoryleak.h testsuite.h
|
testmemleak.o: testmemleak.cpp tokenize.h settings.h errorlogger.h token.h checkmemoryleak.h testsuite.h
|
||||||
g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp
|
g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp
|
||||||
|
testmemleakmp.o: testmemleakmp.cpp tokenize.h settings.h errorlogger.h token.h checkmemoryleak.h testsuite.h
|
||||||
|
g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp
|
||||||
testpreprocessor.o: testpreprocessor.cpp testsuite.h errorlogger.h preprocessor.h
|
testpreprocessor.o: testpreprocessor.cpp testsuite.h errorlogger.h preprocessor.h
|
||||||
g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp
|
g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp
|
||||||
testredundantif.o: testredundantif.cpp testsuite.h errorlogger.h checkother.h
|
testredundantif.o: testredundantif.cpp testsuite.h errorlogger.h checkother.h
|
||||||
|
|
|
@ -491,21 +491,21 @@ void CheckClass::privateFunctions()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tok->aaaa0() == '{')
|
if (tok->str() == "{")
|
||||||
indent_level++;
|
indent_level++;
|
||||||
if (tok->aaaa0() == '}')
|
else if (tok->str() == "}")
|
||||||
{
|
{
|
||||||
if (indent_level <= 1)
|
if (indent_level <= 1)
|
||||||
break;
|
break;
|
||||||
indent_level--;
|
indent_level--;
|
||||||
}
|
}
|
||||||
if (strcmp(tok->aaaa(),"};") == 0)
|
else if (tok->str() == "};")
|
||||||
break;
|
break;
|
||||||
if (strcmp(tok->aaaa(),"private:") == 0)
|
else if (tok->str() == "private:")
|
||||||
priv = true;
|
priv = true;
|
||||||
else if (strcmp(tok->aaaa(),"public:") == 0)
|
else if (tok->str() == "public:")
|
||||||
priv = false;
|
priv = false;
|
||||||
else if (strcmp(tok->aaaa(),"protected:") == 0)
|
else if (tok->str() == "protected:")
|
||||||
priv = false;
|
priv = false;
|
||||||
else if (priv && indent_level == 1)
|
else if (priv && indent_level == 1)
|
||||||
{
|
{
|
||||||
|
@ -515,7 +515,7 @@ void CheckClass::privateFunctions()
|
||||||
if (TOKEN::Match(tok, "%var% (") &&
|
if (TOKEN::Match(tok, "%var% (") &&
|
||||||
!TOKEN::Match(tok,classname.c_str()))
|
!TOKEN::Match(tok,classname.c_str()))
|
||||||
{
|
{
|
||||||
FuncList.push_back(tok->aaaa());
|
FuncList.push_back(tok->str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1344,5 +1344,12 @@ void CheckMemoryLeakClass::CheckMemoryLeak()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// Non-recursive function analysis
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
TOKEN * CheckMemoryLeakClass::functionCode(const char funcname[])
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,12 @@ private:
|
||||||
ErrorLogger *_errorLogger;
|
ErrorLogger *_errorLogger;
|
||||||
const Settings _settings;
|
const Settings _settings;
|
||||||
std::list<AllocFunc> _listAllocFunc;
|
std::list<AllocFunc> _listAllocFunc;
|
||||||
|
|
||||||
|
// Experimental functionality..
|
||||||
|
#ifdef UNIT_TESTING
|
||||||
|
public:
|
||||||
|
#endif
|
||||||
|
TOKEN * functionCode(const char funcname[]);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue